This theory treats finite sequences (i.e. maps
A natural way of representing (finite) lists in set theory is through
(finite) sequences.
In such view a list of elements of a set
We define the set of lists with values in set
definition
The set of nonempty
definition
We first define the shift that moves the second sequence
to the domain
definition
We define concatenation of two sequences as the union of the first sequence
with the shifted second sequence. The result of concatenating lists
definition
For a finite sequence we define the sequence of all elements except the first one. This corresponds to the "tail" function in Haskell. We call it Tail here as well.
definition
A dual notion to Tail is the list of all elements of a list except the last one. Borrowing the terminology from Haskell again, we will call this Init.
definition
Another obvious operation we can talk about is appending an element at the end of a sequence. This is called Append.
definition
If lists are modeled as finite sequences (i.e. functions on natural
intervals
definition
A formula for tail of a finite list.
lemma tail_as_set:
assumes
Formula for the tail of a list defined by an expression:
lemma tail_formula:
assumes
Codomain of a nonempty list is nonempty.
lemma nelist_vals_nonempty:
assumes
Shifted sequence is a function on a the interval of natural numbers.
lemma shifted_seq_props:
assumes A1:
Basis properties of the contatenation of two finite sequences.
theorem concat_props:
assumes A1:
Properties of concatenating three lists.
lemma concat_concat_list:
assumes A1:
Properties of concatenating a list with a concatenation of two other lists.
lemma concat_list_concat:
assumes A1:
Concatenation is associative.
theorem concat_assoc:
assumes A1:
Properties of Tail.
theorem tail_props:
assumes A1:
Essentially the second assertion of tail_props but formulated using notation
lemma tail_props2:
assumes
A nonempty list can be decomposed into concatenation of its first element and the tail.
lemma first_concat_tail:
assumes
Properties of Append. It is a bit surprising that
the we don't need to assume that
theorem append_props:
assumes A1:
A special case of append_props: appending to a nonempty list does not change the head (first element) of the list.
corollary head_of_append:
assumes
Tail commutes with Append.
theorem tail_append_commute:
assumes A1:
@{term NELists} are non-empty lists
lemma non_zero_List_func_is_NEList:
showsProperties of Init.
theorem init_props:
assumes A1:
The initial part of a non-empty list is a list, and the domain of the original list is the successor of its initial part.
theorem init_NElist:
assumes
If we take init of the result of append, we get back the same list.
lemma init_append:
assumes A1:
A reformulation of definition of Init.
lemma init_def:
assumes
Another reformulation of the definition of Init, starting with the expression defining the list.
lemma init_def_alt:
assumes
A lemma about extending a finite sequence by one more value. This is just a more explicit version of append_props.
lemma finseq_extend:
assumes
The next lemma is a bit displaced as it is mainly
about finite sets. It is proven here because it uses
the notion of Append.
Suppose we have a list of element of
lemma bij_append_point:
assumes A1:
The next lemma rephrases the definition of Last.
Recall that in ZF we have
lemma last_seq_elem:
assumes
The last element of a non-empty list valued in
lemma last_type:
assumes
The last element of a list of length at least 2 is the same as the last element of the tail of that list.
lemma last_tail_last:
assumes
If two finite sequences are the same when restricted to domain one shorter than the original and have the same value on the last element, then they are equal.
lemma finseq_restr_eq:
assumes A1:
Concatenating a list of length
lemma append_1elem:
assumes A1:
If
lemma list_len1_singleton:
assumes
A singleton list is in fact a singleton set with a pair as the only element.
lemma list_singleton_pair:
assumes A1:
When we append an element to the empty list we get
a list with length
lemma empty_append1:
assumes A1:
Appending an element is the same as concatenating with certain pair.
lemma append_concat_pair:
assumes
An associativity property involving concatenation and appending. For proof we just convert appending to concatenation and use concat_assoc.
lemma concat_append_assoc:
assumes A1:
An identity involving concatenating with init and appending the last element.
lemma concat_init_last_elem:
assumes
A lemma about creating lists by composition and how Append behaves in such case.
lemma list_compose_append:
assumes A1:
A lemma about appending an element to a list defined by set comprehension.
lemma set_list_append:
assumes A1:
A version of set_list_append using
lemma set_list_append1:
assumes
defines
An induction theorem for lists.
lemma list_induct:
assumes A1:
A dual notion to Append is Prepend where we add an element to the list at the beginning of the
list. We define the value of the list
definition
If
lemma prepend_props:
assumes
When prepending an element to a list the values at positive indices do not change.
lemma prepend_val:
assumes
The tail of a list prepended by an element is equal to the list.
lemma tail_prepend:
assumes
Lists of length
There is a natural bijection between the space
lemma lists_cart_prod:
assumes
We can identify a set
lemma singleton_list_bij:
showsWe can identify a set of
lemma list_singleton_bij:
showsWhat is the inverse image of a set by the natural bijection between
lemma singleton_vimage:
assumes
A technical lemma about extending a list by values from a set.
lemma list_append_from:
assumes A1: