# IsarMathLib

## A library of formalized mathematics for Isabelle/ZF theorem proving environment

theory InductiveSeq_ZF imports Nat_ZF_IML FiniteSeq_ZF
begin

In this theory we discuss sequences defined by conditions of the form $$a_0 = x,\ a_{n+1} = f(a_n)$$ and similar.

### Sequences defined by induction

One way of defining a sequence (that is a function $$a:\mathbb{N}\rightarrow X$$) is to provide the first element of the sequence and a function to find the next value when we have the current one. This is usually called "defining a sequence by induction". In this section we set up the notion of a sequence defined by induction and prove the theorems needed to use it.

First we define a helper notion of the sequence defined inductively up to a given natural number $$n$$.

Definition

$$\text{InductiveSequenceN}(x,f,n) \equiv$$ $$\text{The } a.\ a: succ(n) \rightarrow domain(f) \wedge a(0) = x \wedge (\forall k\in n.\ a(succ(k)) = f(a(k)))$$

From that we define the inductive sequence on the whole set of natural numbers. Recall that in Isabelle/ZF the set of natural numbers is denoted nat.

Definition

$$\text{InductiveSequence}(x,f) \equiv \bigcup n\in nat.\ \text{InductiveSequenceN}(x,f,n)$$

First we will consider the question of existence and uniqueness of finite inductive sequences. The proof is by induction and the next lemma is the $$P(0)$$ step. To understand the notation recall that for natural numbers in set theory we have $$n = \{0,1,..,n-1\}$$ and $$succ(n)$$$$= \{0,1,..,n\}$$.

lemma indseq_exun0:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$

shows $$\exists ! a.\ a: succ(0) \rightarrow X \wedge a(0) = x \wedge ( \forall k\in 0.\ a(succ(k)) = f(a(k)) )$$proof
fix $$a$$ $$b$$
assume A3: $$a: succ(0) \rightarrow X \wedge a(0) = x \wedge ( \forall k\in 0.\ a(succ(k)) = f(a(k)) )$$, $$b: succ(0) \rightarrow X \wedge b(0) = x \wedge ( \forall k\in 0.\ b(succ(k)) = f(b(k)) )$$
moreover
have $$succ(0) = \{0\}$$
ultimately have $$a: \{0\} \rightarrow X$$, $$b: \{0\} \rightarrow X$$
then have $$a = \{\langle 0, a(0)\rangle \}$$, $$b = \{\langle 0, b(0)\rangle \}$$ using func_singleton_pair
with A3 show $$a=b$$
next
let $$a = \{\langle 0,x\rangle \}$$
have $$a : \{0\} \rightarrow \{x\}$$ using singleton_fun
moreover
from A1, A2 have $$\{x\} \subseteq X$$
ultimately have $$a : \{0\} \rightarrow X$$ using func1_1_L1B
moreover
have $$\{0\} = succ(0)$$
ultimately have $$a : succ(0) \rightarrow X$$
with A1 show $$\exists a.\ a: succ(0) \rightarrow X \wedge a(0) = x \wedge (\forall k\in 0.\ a(succ(k)) = f(a(k)))$$ using singleton_apply
qed

A lemma about restricting finite sequences needed for the proof of the inductive step of the existence and uniqueness of finite inductive seqences.

lemma indseq_restrict:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$ and A3: $$n \in nat$$ and A4: $$a: succ(succ(n))\rightarrow X \wedge a(0) = x \wedge (\forall k\in succ(n).\ a(succ(k)) = f(a(k)))$$ and A5: $$a_r = \text{restrict}(a,succ(n))$$

shows $$a_r: succ(n) \rightarrow X \wedge a_r(0) = x \wedge ( \forall k\in n.\ a_r(succ(k)) = f(a_r(k)) )$$proof
from A3 have $$succ(n) \subseteq succ(succ(n))$$
with A4, A5 have $$a_r: succ(n) \rightarrow X$$ using restrict_type2
moreover
from A3 have $$0 \in succ(n)$$ using empty_in_every_succ
with A4, A5 have $$a_r(0) = x$$ using restrict_if
moreover
from A3, A4, A5 have $$\forall k\in n.\ a_r(succ(k)) = f(a_r(k))$$ using succ_ineq , restrict_if
ultimately show $$thesis$$
qed

Existence and uniqueness of finite inductive sequences. The proof is by induction and the next lemma is the inductive step.

lemma indseq_exun_ind:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$ and A3: $$n \in nat$$ and A4: $$\exists ! a.\ a: succ(n) \rightarrow X \wedge a(0) = x \wedge (\forall k\in n.\ a(succ(k)) = f(a(k)))$$

shows $$\exists ! a.\ a: succ(succ(n)) \rightarrow X \wedge a(0) = x \wedge$$ $$( \forall k\in succ(n).\ a(succ(k)) = f(a(k)) )$$proof
fix $$a$$ $$b$$
assume A5: $$a: succ(succ(n)) \rightarrow X \wedge a(0) = x \wedge$$ $$( \forall k\in succ(n).\ a(succ(k)) = f(a(k)) )$$ and A6: $$b: succ(succ(n)) \rightarrow X \wedge b(0) = x \wedge$$ $$( \forall k\in succ(n).\ b(succ(k)) = f(b(k)) )$$
show $$a = b$$proof
let $$a_r = \text{restrict}(a,succ(n))$$
let $$b_r = \text{restrict}(b,succ(n))$$
note A1, A2, A3, A5
moreover
have $$a_r = \text{restrict}(a,succ(n))$$
ultimately have I: $$a_r: succ(n) \rightarrow X \wedge a_r(0) = x \wedge ( \forall k\in n.\ a_r(succ(k)) = f(a_r(k)) )$$ by (rule indseq_restrict )
note A1, A2, A3, A6
moreover
have $$b_r = \text{restrict}(b,succ(n))$$
ultimately have $$b_r: succ(n) \rightarrow X \wedge b_r(0) = x \wedge ( \forall k\in n.\ b_r(succ(k)) = f(b_r(k)) )$$ by (rule indseq_restrict )
with A4, I have II: $$a_r = b_r$$
from A3 have $$succ(n) \in nat$$
moreover
from A5, A6 have $$a: succ(succ(n)) \rightarrow X$$ and $$b: succ(succ(n)) \rightarrow X$$
moreover
note II
moreover
have T: $$n \in succ(n)$$
then have $$a_r(n) = a(n)$$ and $$b_r(n) = b(n)$$ using restrict
with A5, A6, II, T have $$a(succ(n)) = b(succ(n))$$
ultimately show $$a = b$$ by (rule finseq_restr_eq )
qed
next
show $$\exists a.\ a: succ(succ(n)) \rightarrow X \wedge a(0) = x \wedge$$ $$( \forall k\in succ(n).\ a(succ(k)) = f(a(k)) )$$proof
from A4 obtain $$a$$ where III: $$a: succ(n) \rightarrow X$$ and IV: $$a(0) = x$$ and V: $$\forall k\in n.\ a(succ(k)) = f(a(k))$$
let $$b = a \cup \{\langle succ(n), f(a(n))\rangle \}$$
from A1, III have VI: $$b : succ(succ(n)) \rightarrow X$$ and VII: $$\forall k \in succ(n).\ b(k) = a(k)$$ and VIII: $$b(succ(n)) = f(a(n))$$ using apply_funtype , finseq_extend
from A3 have $$0 \in succ(n)$$ using empty_in_every_succ
with IV, VII have IX: $$b(0) = x$$
{
fix $$k$$
assume $$k \in succ(n)$$
then have $$k\in n \vee k = n$$
moreover {
assume A7: $$k \in n$$
with A3, VII have $$b(succ(k)) = a(succ(k))$$ using succ_ineq
also
from A7, V, VII have $$a(succ(k)) = f(b(k))$$
finally have $$b(succ(k)) = f(b(k))$$
} moreover {
assume A8: $$k = n$$
with VIII have $$b(succ(k)) = f(a(k))$$
with A8, VII, VIII have $$b(succ(k)) = f(b(k))$$
} ultimately have $$b(succ(k)) = f(b(k))$$
}
then have $$\forall k \in succ(n).\ b(succ(k)) = f(b(k))$$
with VI, IX show $$thesis$$
qed
qed

The next lemma combines indseq_exun0 and indseq_exun_ind to show the existence and uniqueness of finite sequences defined by induction.

lemma indseq_exun:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$ and A3: $$n \in nat$$

shows $$\exists ! a.\ a: succ(n) \rightarrow X \wedge a(0) = x \wedge (\forall k\in n.\ a(succ(k)) = f(a(k)))$$proof
note A3
moreover
from A1, A2 have $$\exists ! a.\ a: succ(0) \rightarrow X \wedge a(0) = x \wedge ( \forall k\in 0.\ a(succ(k)) = f(a(k)) )$$ using indseq_exun0
moreover
from A1, A2 have $$\forall k \in nat.\$$ $$( \exists ! a.\ a: succ(k) \rightarrow X \wedge a(0) = x \wedge$$ $$( \forall i\in k.\ a(succ(i)) = f(a(i)) )) \longrightarrow$$ $$( \exists ! a.\ a: succ(succ(k)) \rightarrow X \wedge a(0) = x \wedge$$ $$( \forall i\in succ(k).\ a(succ(i)) = f(a(i)) ) )$$ using indseq_exun_ind
ultimately show $$\exists ! a.\ a: succ(n) \rightarrow X \wedge a(0) = x \wedge ( \forall k\in n.\ a(succ(k)) = f(a(k)) )$$ by (rule ind_on_nat )
qed

We are now ready to prove the main theorem about finite inductive sequences.

theorem fin_indseq_props:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$ and A3: $$n \in nat$$ and A4: $$a = \text{InductiveSequenceN}(x,f,n)$$

shows $$a: succ(n) \rightarrow X$$, $$a(0) = x$$, $$\forall k\in n.\ a(succ(k)) = f(a(k))$$proof
let $$i = \text{The } a.\ a: succ(n) \rightarrow X \wedge a(0) = x \wedge$$ $$( \forall k\in n.\ a(succ(k)) = f(a(k)) )$$
from A1, A2, A3 have $$\exists ! a.\ a: succ(n) \rightarrow X \wedge a(0) = x \wedge ( \forall k\in n.\ a(succ(k)) = f(a(k)) )$$ using indseq_exun
then have $$i: succ(n) \rightarrow X \wedge i(0) = x \wedge ( \forall k\in n.\ i(succ(k)) = f(i(k)) )$$ by (rule theI )
moreover
from A1, A4 have $$a = i$$ using InductiveSequenceN_def , func1_1_L1
ultimately show $$a: succ(n) \rightarrow X$$, $$a(0) = x$$, $$\forall k\in n.\ a(succ(k)) = f(a(k))$$
qed

A corollary about the domain of a finite inductive sequence.

corollary fin_indseq_domain:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$ and A3: $$n \in nat$$

shows $$domain( \text{InductiveSequenceN}(x,f,n)) = succ(n)$$proof
from assms have $$\text{InductiveSequenceN}(x,f,n) : succ(n) \rightarrow X$$ using fin_indseq_props
then show $$thesis$$ using func1_1_L1
qed

The collection of finite sequences defined by induction is consistent in the sense that the restriction of the sequence defined on a larger set to the smaller set is the same as the sequence defined on the smaller set.

lemma indseq_consistent:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$ and A3: $$i \in nat$$, $$j \in nat$$ and A4: $$i \subseteq j$$

shows $$\text{restrict}( \text{InductiveSequenceN}(x,f,j),succ(i)) = \text{InductiveSequenceN}(x,f,i)$$proof
let $$a = \text{InductiveSequenceN}(x,f,j)$$
let $$b = \text{restrict}( \text{InductiveSequenceN}(x,f,j),succ(i))$$
let $$c = \text{InductiveSequenceN}(x,f,i)$$
from A1, A2, A3 have $$a: succ(j) \rightarrow X$$, $$a(0) = x$$, $$\forall k\in j.\ a(succ(k)) = f(a(k))$$ using fin_indseq_props
with A3, A4 have $$b: succ(i) \rightarrow X \wedge b(0) = x \wedge ( \forall k\in i.\ b(succ(k)) = f(b(k)))$$ using succ_subset , restrict_type2 , empty_in_every_succ , restrict , succ_ineq
moreover
from A1, A2, A3 have $$c: succ(i) \rightarrow X \wedge c(0) = x \wedge ( \forall k\in i.\ c(succ(k)) = f(c(k)))$$ using fin_indseq_props
moreover
from A1, A2, A3 have $$\exists ! a.\ a: succ(i) \rightarrow X \wedge a(0) = x \wedge ( \forall k\in i.\ a(succ(k)) = f(a(k)) )$$ using indseq_exun
ultimately show $$b = c$$
qed

For any two natural numbers one of the corresponding inductive sequences is contained in the other.

lemma indseq_subsets:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$ and A3: $$i \in nat$$, $$j \in nat$$ and A4: $$a = \text{InductiveSequenceN}(x,f,i)$$, $$b = \text{InductiveSequenceN}(x,f,j)$$

shows $$a \subseteq b \vee b \subseteq a$$proof
from A3 have $$i\subseteq j \vee j\subseteq i$$ using nat_incl_total
moreover {
assume $$i\subseteq j$$
with A1, A2, A3, A4 have $$\text{restrict}(b,succ(i)) = a$$ using indseq_consistent
moreover
have $$\text{restrict}(b,succ(i)) \subseteq b$$ using restrict_subset
ultimately have $$a \subseteq b \vee b \subseteq a$$
} moreover {
assume $$j\subseteq i$$
with A1, A2, A3, A4 have $$\text{restrict}(a,succ(j)) = b$$ using indseq_consistent
moreover
have $$\text{restrict}(a,succ(j)) \subseteq a$$ using restrict_subset
ultimately have $$a \subseteq b \vee b \subseteq a$$
} ultimately show $$a \subseteq b \vee b \subseteq a$$
qed

The first theorem about properties of infinite inductive sequences: inductive sequence is a indeed a sequence (i.e. a function on the set of natural numbers.

theorem indseq_seq:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$

shows $$\text{InductiveSequence}(x,f) : nat \rightarrow X$$proof
let $$S = \{ \text{InductiveSequenceN}(x,f,n).\ n \in nat\}$$
{
fix $$a$$
assume $$a\in S$$
then obtain $$n$$ where $$n \in nat$$ and $$a = \text{InductiveSequenceN}(x,f,n)$$
with A1, A2 have $$a : succ(n)\rightarrow X$$ using fin_indseq_props
then have $$\exists A B.\ a:A\rightarrow B$$
}
then have $$\forall a \in S.\ \exists A B.\ a:A\rightarrow B$$
moreover {
fix $$a$$ $$b$$
assume $$a\in S$$, $$b\in S$$
then obtain $$i$$ $$j$$ where $$i\in nat$$, $$j\in nat$$ and $$a = \text{InductiveSequenceN}(x,f,i)$$, $$b = \text{InductiveSequenceN}(x,f,j)$$
with A1, A2 have $$a\subseteq b \vee b\subseteq a$$ using indseq_subsets
}
then have $$\forall a\in S.\ \forall b\in S.\ a\subseteq b \vee b\subseteq a$$
ultimately have $$\bigcup S : domain(\bigcup S) \rightarrow \text{range}(\bigcup S)$$ using fun_Union
with A1, A2 have I: $$\bigcup S : nat \rightarrow \text{range}(\bigcup S)$$ using domain_UN , fin_indseq_domain , nat_union_succ
moreover {
fix $$k$$
assume A3: $$k \in nat$$
let $$y = (\bigcup S)(k)$$
note I, A3
moreover
have $$y = (\bigcup S)(k)$$
ultimately have $$\langle k,y\rangle \in (\bigcup S)$$ by (rule func1_1_L5A )
then obtain $$n$$ where $$n \in nat$$ and II: $$\langle k,y\rangle \in \text{InductiveSequenceN}(x,f,n)$$
with A1, A2 have $$\text{InductiveSequenceN}(x,f,n): succ(n) \rightarrow X$$ using fin_indseq_props
with II have $$y \in X$$ using func1_1_L5
}
then have $$\forall k \in nat.\ (\bigcup S)(k) \in X$$
ultimately have $$\bigcup S : nat \rightarrow X$$ using func1_1_L1A
then show $$\text{InductiveSequence}(x,f) : nat \rightarrow X$$ using InductiveSequence_def
qed

Restriction of an inductive sequence to a finite domain is the corresponding finite inductive sequence.

lemma indseq_restr_eq:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$ and A3: $$n \in nat$$

shows $$\text{restrict}( \text{InductiveSequence}(x,f),succ(n)) = \text{InductiveSequenceN}(x,f,n)$$proof
let $$a = \text{InductiveSequence}(x,f)$$
let $$b = \text{InductiveSequenceN}(x,f,n)$$
let $$S = \{ \text{InductiveSequenceN}(x,f,n).\ n \in nat\}$$
from A1, A2, A3 have I: $$a : nat \rightarrow X$$ and $$succ(n) \subseteq nat$$ using indseq_seq , succnat_subset_nat
then have $$\text{restrict}(a,succ(n)) : succ(n) \rightarrow X$$ using restrict_type2
moreover
from A1, A2, A3 have $$b : succ(n) \rightarrow X$$ using fin_indseq_props
moreover {
fix $$k$$
assume A4: $$k \in succ(n)$$
from A1, A2, A3, I have $$\bigcup S : nat \rightarrow X$$, $$b \in S$$, $$b : succ(n) \rightarrow X$$ using InductiveSequence_def , fin_indseq_props
with A4 have $$\text{restrict}(a,succ(n))(k) = b(k)$$ using fun_Union_apply , InductiveSequence_def , restrict_if
}
then have $$\forall k \in succ(n).\ \text{restrict}(a,succ(n))(k) = b(k)$$
ultimately show $$thesis$$ by (rule func_eq )
qed

The first element of the inductive sequence starting at $$x$$ and generated by $$f$$ is indeed $$x$$.

theorem indseq_valat0:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$

shows $$\text{InductiveSequence}(x,f)(0) = x$$proof
let $$a = \text{InductiveSequence}(x,f)$$
let $$b = \text{InductiveSequenceN}(x,f,0)$$
have T: $$0\in nat$$, $$0 \in succ(0)$$
with A1, A2 have $$b(0) = x$$ using fin_indseq_props
moreover
from T have $$\text{restrict}(a,succ(0))(0) = a(0)$$ using restrict_if
moreover
from A1, A2, T have $$\text{restrict}(a,succ(0)) = b$$ using indseq_restr_eq
ultimately show $$a(0) = x$$
qed

An infinite inductive sequence satisfies the inductive relation that defines it.

theorem indseq_vals:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$ and A3: $$n \in nat$$

shows $$\text{InductiveSequence}(x,f)(succ(n)) = f( \text{InductiveSequence}(x,f)(n))$$proof
let $$a = \text{InductiveSequence}(x,f)$$
let $$b = \text{InductiveSequenceN}(x,f,succ(n))$$
from A3 have T: $$succ(n) \in succ(succ(n))$$, $$succ(succ(n)) \in nat$$, $$n \in succ(succ(n))$$
then have $$a(succ(n)) = \text{restrict}(a,succ(succ(n)))(succ(n))$$ using restrict_if
also
from A1, A2, T have $$\ldots = f(\text{restrict}(a,succ(succ(n)))(n))$$ using indseq_restr_eq , fin_indseq_props
also
from T have $$\ldots = f(a(n))$$ using restrict_if
finally show $$a(succ(n)) = f(a(n))$$
qed

### Images of inductive sequences

In this section we consider the properties of sets that are images of inductive sequences, that is are of the form $$\{f^{(n)} (x) : n \in N\}$$ for some $$x$$ in the domain of $$f$$, where $$f^{(n)}$$ denotes the $$n$$'th iteration of the function $$f$$. For a function $$f:X\rightarrow X$$ and a point $$x\in X$$ such set is set is sometimes called the orbit of $$x$$ generated by $$f$$.

The basic properties of orbits.

theorem ind_seq_image:

assumes A1: $$f: X\rightarrow X$$ and A2: $$x\in X$$ and A3: $$A = \text{InductiveSequence}(x,f)(nat)$$

shows $$x\in A$$ and $$\forall y\in A.\ f(y) \in A$$proof
let $$a = \text{InductiveSequence}(x,f)$$
from A1, A2 have $$a : nat \rightarrow X$$ using indseq_seq
with A3 have I: $$A = \{a(n).\ n \in nat\}$$ using func_imagedef
hence $$a(0) \in A$$
with A1, A2 show $$x\in A$$ using indseq_valat0
{
fix $$y$$
assume $$y\in A$$
with I obtain $$n$$ where II: $$n \in nat$$ and III: $$y = a(n)$$
with A1, A2 have $$a(succ(n)) = f(y)$$ using indseq_vals
moreover
from I, II have $$a(succ(n)) \in A$$
ultimately have $$f(y) \in A$$
}
then show $$\forall y\in A.\ f(y) \in A$$
qed

### Subsets generated by a binary operation

In algebra we often talk about sets "generated" by an element, that is sets of the form (in multiplicative notation) $$\{a^n | n\in Z\}$$. This is a related to a general notion of "power" (as in $$a^n = a\cdot a \cdot .. \cdot a$$ ) or multiplicity $$n\cdot a = a+a+..+a$$. The intuitive meaning of such notions is obvious, but we need to do some work to be able to use it in the formalized setting. This sections is devoted to sequences that are created by repeatedly applying a binary operation with the second argument fixed to some constant.

Basic propertes of sets generated by binary operations.

theorem binop_gen_set:

assumes A1: $$f: X\times Y \rightarrow X$$ and A2: $$x\in X$$, $$y\in Y$$ and A3: $$a = \text{InductiveSequence}(x, \text{Fix2ndVar}(f,y))$$

shows $$a : nat \rightarrow X$$, $$a(nat) \in Pow(X)$$, $$x \in a(nat)$$, $$\forall z \in a(nat).\ \text{Fix2ndVar}(f,y)(z) \in a(nat)$$proof
let $$g = \text{Fix2ndVar}(f,y)$$
from A1, A2 have I: $$g : X\rightarrow X$$ using fix_2nd_var_fun
with A2, A3 show $$a : nat \rightarrow X$$ using indseq_seq
then show $$a(nat) \in Pow(X)$$ using func1_1_L6
from A2, A3, I show $$x \in a(nat)$$ using ind_seq_image
from A2, A3, I have $$g : X\rightarrow X$$, $$x\in X$$, $$a(nat) = \text{InductiveSequence}(x,g)(nat)$$
then show $$\forall z \in a(nat).\ \text{Fix2ndVar}(f,y)(z) \in a(nat)$$ by (rule ind_seq_image )
qed

A simple corollary to the theorem binop_gen_set: a set that contains all iterations of the application of a binary operation exists.

lemma binop_gen_set_ex:

assumes A1: $$f: X\times Y \rightarrow X$$ and A2: $$x\in X$$, $$y\in Y$$

shows $$\{A \in Pow(X).\ x\in A \wedge (\forall z \in A.\ f\langle z,y\rangle \in A) \} \neq 0$$proof
let $$a = \text{InductiveSequence}(x, \text{Fix2ndVar}(f,y))$$
let $$A = a(nat)$$
from A1, A2 have I: $$A \in Pow(X)$$ and $$x \in A$$ using binop_gen_set
moreover {
fix $$z$$
assume T: $$z\in A$$
with A1, A2 have $$\text{Fix2ndVar}(f,y)(z) \in A$$ using binop_gen_set
moreover
from I, T have $$z \in X$$
with A1, A2 have $$\text{Fix2ndVar}(f,y)(z) = f\langle z,y\rangle$$ using fix_var_val
ultimately have $$f\langle z,y\rangle \in A$$
}
then have $$\forall z \in A.\ f\langle z,y\rangle \in A$$
ultimately show $$thesis$$
qed

A more general version of binop_gen_set where the generating binary operation acts on a larger set.

theorem binop_gen_set1:

assumes A1: $$f: X\times Y \rightarrow X$$ and A2: $$X_1 \subseteq X$$ and A3: $$x\in X_1$$, $$y\in Y$$ and A4: $$\forall t\in X_1.\ f\langle t,y\rangle \in X_1$$ and A5: $$a = \text{InductiveSequence}(x, \text{Fix2ndVar}(\text{restrict}(f,X_1\times Y),y))$$

shows $$a : nat \rightarrow X_1$$, $$a(nat) \in Pow(X_1)$$, $$x \in a(nat)$$, $$\forall z \in a(nat).\ \text{Fix2ndVar}(f,y)(z) \in a(nat)$$, $$\forall z \in a(nat).\ f\langle z,y\rangle \in a(nat)$$proof
let $$h = \text{restrict}(f,X_1\times Y)$$
let $$g = \text{Fix2ndVar}(h,y)$$
from A2 have $$X_1\times Y \subseteq X\times Y$$
with A1 have I: $$h : X_1\times Y \rightarrow X$$ using restrict_type2
with A3 have II: $$g: X_1 \rightarrow X$$ using fix_2nd_var_fun
from A3, A4, I have $$\forall t\in X_1.\ g(t) \in X_1$$ using restrict , fix_var_val
with II have III: $$g : X_1 \rightarrow X_1$$ using func1_1_L1A
with A3, A5 show $$a : nat \rightarrow X_1$$ using indseq_seq
then show IV: $$a(nat) \in Pow(X_1)$$ using func1_1_L6
from A3, A5, III show $$x \in a(nat)$$ using ind_seq_image
from A3, A5, III have $$g : X_1 \rightarrow X_1$$, $$x\in X_1$$, $$a(nat) = \text{InductiveSequence}(x,g)(nat)$$
then have $$\forall z \in a(nat).\ \text{Fix2ndVar}(h,y)(z) \in a(nat)$$ by (rule ind_seq_image )
moreover {
fix $$z$$
assume $$z \in a(nat)$$
with IV have $$z \in X_1$$
with A1, A2, A3 have $$g(z) = \text{Fix2ndVar}(f,y)(z)$$ using fix_2nd_var_restr_comm , restrict
}
then have $$\forall z \in a(nat).\ g(z) = \text{Fix2ndVar}(f,y)(z)$$
ultimately show $$\forall z \in a(nat).\ \text{Fix2ndVar}(f,y)(z) \in a(nat)$$
moreover {
fix $$z$$
assume $$z \in a(nat)$$
with A2, IV have $$z\in X$$
with A1, A3 have $$\text{Fix2ndVar}(f,y)(z) = f\langle z,y\rangle$$ using fix_var_val
}
then have $$\forall z \in a(nat).\ \text{Fix2ndVar}(f,y)(z) = f\langle z,y\rangle$$
ultimately show $$\forall z \in a(nat).\ f\langle z,y\rangle \in a(nat)$$
qed

A generalization of binop_gen_set_ex that applies when the binary operation acts on a larger set. This is used in our Metamath translation to prove the existence of the set of real natural numbers. Metamath defines the real natural numbers as the smallest set that cantains $$1$$ and is closed with respect to operation of adding $$1$$.

lemma binop_gen_set_ex1:

assumes A1: $$f: X\times Y \rightarrow X$$ and A2: $$X_1 \subseteq X$$ and A3: $$x\in X_1$$, $$y\in Y$$ and A4: $$\forall t\in X_1.\ f\langle t,y\rangle \in X_1$$

shows $$\{A \in Pow(X_1).\ x\in A \wedge (\forall z \in A.\ f\langle z,y\rangle \in A) \} \neq 0$$proof
let $$a = \text{InductiveSequence}(x, \text{Fix2ndVar}(\text{restrict}(f,X_1\times Y),y))$$
let $$A = a(nat)$$
from A1, A2, A3, A4 have $$A \in Pow(X_1)$$, $$x \in A$$, $$\forall z \in A.\ f\langle z,y\rangle \in A$$ using binop_gen_set1
thus $$thesis$$
qed

### Inductive sequences with changing generating function

A seemingly more general form of a sequence defined by induction is a sequence generated by the difference equation $$x_{n+1} = f_{n} (x_n)$$ where $$n\mapsto f_n$$ is a given sequence of functions such that each maps $$X$$ into inself. For example when $$f_n (x) := x + x_n$$ then the equation $$S_{n+1} = f_{n} (S_n)$$ describes the sequence $$n \mapsto S_n = s_0 +\sum_{i=0}^n x_n$$, i.e. the sequence of partial sums of the sequence $$\{s_0, x_0, x_1, x_3,..\}$$.

The situation where the function that we iterate changes with $$n$$ can be derived from the simpler case if we define the generating function appropriately. Namely, we replace the generating function in the definitions of InductiveSequenceN by the function $$f: X\times n \rightarrow X\times n$$, $$f\langle x,k\rangle = \langle f_k(x), k+1 \rangle$$ if $$k < n$$, $$\langle f_k(x), k \rangle$$ otherwise. The first notion defines the expression we will use to define the generating function. To understand the notation recall that in standard Isabelle/ZF for a pair $$s=\langle x,n \rangle$$ we have fst$$(s)=x$$ and snd$$(s)=n$$.

Definition

$$\text{StateTransfFunNMeta}(F,n,s) \equiv$$ $$\text{if }(\text{snd}(s) \in n)\text{ then }\langle F(\text{snd}(s))(\text{fst}(s)), succ(\text{snd}(s))\rangle \text{ else }s$$

Then we define the actual generating function on sets of pairs from $$X\times \{0,1, .. ,n\}$$.

Definition

$$\text{StateTransfFunN}(X,F,n) \equiv \{\langle s, \text{StateTransfFunNMeta}(F,n,s)\rangle .\ s \in X\times succ(n)\}$$

Having the generating function we can define the expression that we cen use to define the inductive sequence generates.

Definition

$$\text{StatesSeq}(x,X,F,n) \equiv$$ $$\text{InductiveSequenceN}(\langle x,0\rangle , \text{StateTransfFunN}(X,F,n),n)$$

Finally we can define the sequence given by a initial point $$x$$, and a sequence $$F$$ of $$n$$ functions.

Definition

$$\text{InductiveSeqVarFN}(x,X,F,n) \equiv \{\langle k,\text{fst}( \text{StatesSeq}(x,X,F,n)(k))\rangle .\ k \in succ(n)\}$$

The state transformation function (StateTransfFunN is a function that transforms $$X\times n$$ into itself.

lemma state_trans_fun:

assumes A1: $$n \in nat$$ and A2: $$F: n \rightarrow (X\rightarrow X)$$

shows $$\text{StateTransfFunN}(X,F,n): X\times succ(n) \rightarrow X\times succ(n)$$proof
{
fix $$s$$
assume A3: $$s \in X\times succ(n)$$
let $$x = \text{fst}(s)$$
let $$k = \text{snd}(s)$$
let $$S = \text{StateTransfFunNMeta}(F,n,s)$$
from A3 have T: $$x \in X$$, $$k \in succ(n)$$ and $$\langle x,k\rangle = s$$
{
assume A4: $$k \in n$$
with A1 have $$succ(k) \in succ(n)$$ using succ_ineq
with A2, T, A4 have $$S \in X\times succ(n)$$ using apply_funtype , StateTransfFunNMeta_def
}
with A2, A3, T have $$S \in X\times succ(n)$$ using apply_funtype , StateTransfFunNMeta_def
}
then have $$\forall s \in X\times succ(n).\ \text{StateTransfFunNMeta}(F,n,s) \in X\times succ(n)$$
then have $$\{\langle s, \text{StateTransfFunNMeta}(F,n,s)\rangle .\ s \in X\times succ(n)\} : X\times succ(n) \rightarrow X\times succ(n)$$ by (rule ZF_fun_from_total )
then show $$\text{StateTransfFunN}(X,F,n): X\times succ(n) \rightarrow X\times succ(n)$$ using StateTransfFunN_def
qed

We can apply fin_indseq_props to the sequence used in the definition of InductiveSeqVarFN to get the properties of the sequence of states generated by the StateTransfFunN.

lemma states_seq_props:

assumes A1: $$n \in nat$$ and A2: $$F: n \rightarrow (X\rightarrow X)$$ and A3: $$x\in X$$ and A4: $$b = \text{StatesSeq}(x,X,F,n)$$

shows $$b : succ(n) \rightarrow X\times succ(n)$$, $$b(0) = \langle x,0\rangle$$, $$\forall k \in succ(n).\ \text{snd}(b(k)) = k$$, $$\forall k\in n.\ b(succ(k)) = \langle F(k)(\text{fst}(b(k))), succ(k)\rangle$$proof
let $$f = \text{StateTransfFunN}(X,F,n)$$
from A1, A2 have I: $$f : X\times succ(n) \rightarrow X\times succ(n)$$ using state_trans_fun
moreover
from A1, A3 have II: $$\langle x,0\rangle \in X\times succ(n)$$ using empty_in_every_succ
moreover
note A1
moreover
from A4 have III: $$b = \text{InductiveSequenceN}(\langle x,0\rangle ,f,n)$$ using StatesSeq_def
ultimately show IV: $$b : succ(n) \rightarrow X\times succ(n)$$ by (rule fin_indseq_props )
from I, II, A1, III show V: $$b(0) = \langle x,0\rangle$$ by (rule fin_indseq_props )
from I, II, A1, III have VI: $$\forall k\in n.\ b(succ(k)) = f(b(k))$$ by (rule fin_indseq_props )
{
fix $$k$$
note I
moreover
assume A5: $$k \in n$$
hence $$k \in succ(n)$$
with IV have $$b(k) \in X\times succ(n)$$ using apply_funtype
moreover
have $$f = \{\langle s, \text{StateTransfFunNMeta}(F,n,s)\rangle .\ s \in X\times succ(n)\}$$ using StateTransfFunN_def
ultimately have $$f(b(k)) = \text{StateTransfFunNMeta}(F,n,b(k))$$ by (rule ZF_fun_from_tot_val )
}
then have VII: $$\forall k \in n.\ f(b(k)) = \text{StateTransfFunNMeta}(F,n,b(k))$$
{
fix $$k$$
assume A5: $$k \in succ(n)$$
note A1, A5
moreover
from V have $$\text{snd}(b(0)) = 0$$
moreover
from VI, VII have $$\forall j\in n.\ \text{snd}(b(j)) = j \longrightarrow \text{snd}(b(succ(j))) = succ(j)$$ using StateTransfFunNMeta_def
ultimately have $$\text{snd}(b(k)) = k$$ by (rule fin_nat_ind )
}
then show $$\forall k \in succ(n).\ \text{snd}(b(k)) = k$$
with VI, VII show $$\forall k\in n.\ b(succ(k)) = \langle F(k)(\text{fst}(b(k))), succ(k)\rangle$$ using StateTransfFunNMeta_def
qed

Basic properties of sequences defined by equation $$x_{n+1}=f_n (x_n)$$.

theorem fin_indseq_var_f_props:

assumes A1: $$n \in nat$$ and A2: $$x\in X$$ and A3: $$F: n \rightarrow (X\rightarrow X)$$ and A4: $$a = \text{InductiveSeqVarFN}(x,X,F,n)$$

shows $$a: succ(n) \rightarrow X$$, $$a(0) = x$$, $$\forall k\in n.\ a(succ(k)) = F(k)(a(k))$$proof
let $$f = \text{StateTransfFunN}(X,F,n)$$
let $$b = \text{StatesSeq}(x,X,F,n)$$
from A1, A2, A3 have $$b : succ(n) \rightarrow X\times succ(n)$$ using states_seq_props
then have $$\forall k \in succ(n).\ b(k) \in X\times succ(n)$$ using apply_funtype
hence $$\forall k \in succ(n).\ \text{fst}(b(k)) \in X$$
then have I: $$\{\langle k,\text{fst}(b(k))\rangle .\ k \in succ(n)\} : succ(n) \rightarrow X$$ by (rule ZF_fun_from_total )
with A4 show II: $$a: succ(n) \rightarrow X$$ using InductiveSeqVarFN_def
moreover
from A1 have $$0 \in succ(n)$$ using empty_in_every_succ
moreover
from A4 have III: $$a = \{\langle k,\text{fst}( \text{StatesSeq}(x,X,F,n)(k))\rangle .\ k \in succ(n)\}$$ using InductiveSeqVarFN_def
ultimately have $$a(0) = \text{fst}(b(0))$$ by (rule ZF_fun_from_tot_val )
with A1, A2, A3 show $$a(0) = x$$ using states_seq_props
{
fix $$k$$
assume A5: $$k \in n$$
with A1 have T1: $$succ(k) \in succ(n)$$ and T2: $$k \in succ(n)$$ using succ_ineq
from II, T1, III have $$a(succ(k)) = \text{fst}(b(succ(k)))$$ by (rule ZF_fun_from_tot_val )
with A1, A2, A3, A5 have $$a(succ(k)) = F(k)(\text{fst}(b(k)))$$ using states_seq_props
moreover
from II, T2, III have $$a(k) = \text{fst}(b(k))$$ by (rule ZF_fun_from_tot_val )
ultimately have $$a(succ(k)) = F(k)(a(k))$$
}
then show $$\forall k\in n.\ a(succ(k)) = F(k)(a(k))$$
qed

A consistency condition: if we make the sequence of generating functions shorter, then we get a shorter inductive sequence with the same values as in the original sequence.

lemma fin_indseq_var_f_restrict:

assumes A1: $$n \in nat$$, $$i \in nat$$, $$x\in X$$, $$F: n \rightarrow (X\rightarrow X)$$, $$G: i \rightarrow (X\rightarrow X)$$ and A2: $$i \subseteq n$$ and A3: $$\forall j\in i.\ G(j) = F(j)$$ and A4: $$k \in succ(i)$$

shows $$\text{InductiveSeqVarFN}(x,X,G,i)(k) = \text{InductiveSeqVarFN}(x,X,F,n)(k)$$proof
let $$a = \text{InductiveSeqVarFN}(x,X,F,n)$$
let $$b = \text{InductiveSeqVarFN}(x,X,G,i)$$
from A1, A4 have $$i \in nat$$, $$k \in succ(i)$$
moreover
from A1 have $$b(0) = a(0)$$ using fin_indseq_var_f_props
moreover
from A1, A2, A3 have $$\forall j\in i.\ b(j) = a(j) \longrightarrow b(succ(j)) = a(succ(j))$$ using fin_indseq_var_f_props
ultimately show $$b(k) = a(k)$$ by (rule fin_nat_ind )
qed
end
lemma func_singleton_pair:

assumes $$f : \{a\}\rightarrow X$$

shows $$f = \{\langle a, f(a)\rangle \}$$
lemma func1_1_L1B:

assumes $$f:X\rightarrow Y$$ and $$Y\subseteq Z$$

shows $$f:X\rightarrow Z$$
lemma empty_in_every_succ:

assumes $$n \in nat$$

shows $$0 \in succ(n)$$
lemma succ_ineq:

assumes $$n \in nat$$

shows $$\forall i \in n.\ succ(i) \in succ(n)$$
lemma indseq_restrict:

assumes $$f: X\rightarrow X$$ and $$x\in X$$ and $$n \in nat$$ and $$a: succ(succ(n))\rightarrow X \wedge a(0) = x \wedge (\forall k\in succ(n).\ a(succ(k)) = f(a(k)))$$ and $$a_r = \text{restrict}(a,succ(n))$$

shows $$a_r: succ(n) \rightarrow X \wedge a_r(0) = x \wedge ( \forall k\in n.\ a_r(succ(k)) = f(a_r(k)) )$$
lemma finseq_restr_eq:

assumes $$n \in nat$$ and $$a: succ(n) \rightarrow X$$, $$b: succ(n) \rightarrow X$$ and $$\text{restrict}(a,n) = \text{restrict}(b,n)$$ and $$a(n) = b(n)$$

shows $$a = b$$
lemma finseq_extend:

assumes $$a:n\rightarrow X$$, $$y\in X$$, $$b = a \cup \{\langle n,y\rangle \}$$

shows $$b: succ(n) \rightarrow X$$, $$\forall k\in n.\ b(k) = a(k)$$, $$b(n) = y$$
lemma indseq_exun0:

assumes $$f: X\rightarrow X$$ and $$x\in X$$

shows $$\exists ! a.\ a: succ(0) \rightarrow X \wedge a(0) = x \wedge ( \forall k\in 0.\ a(succ(k)) = f(a(k)) )$$
lemma indseq_exun_ind:

assumes $$f: X\rightarrow X$$ and $$x\in X$$ and $$n \in nat$$ and $$\exists ! a.\ a: succ(n) \rightarrow X \wedge a(0) = x \wedge (\forall k\in n.\ a(succ(k)) = f(a(k)))$$

shows $$\exists ! a.\ a: succ(succ(n)) \rightarrow X \wedge a(0) = x \wedge$$ $$( \forall k\in succ(n).\ a(succ(k)) = f(a(k)) )$$
theorem ind_on_nat:

assumes $$n\in nat$$ and $$P(0)$$ and $$\forall k\in nat.\ P(k)\longrightarrow P(succ(k))$$

shows $$P(n)$$
lemma indseq_exun:

assumes $$f: X\rightarrow X$$ and $$x\in X$$ and $$n \in nat$$

shows $$\exists ! a.\ a: succ(n) \rightarrow X \wedge a(0) = x \wedge (\forall k\in n.\ a(succ(k)) = f(a(k)))$$
Definition of InductiveSequenceN: $$\text{InductiveSequenceN}(x,f,n) \equiv$$ $$\text{The } a.\ a: succ(n) \rightarrow domain(f) \wedge a(0) = x \wedge (\forall k\in n.\ a(succ(k)) = f(a(k)))$$
lemma func1_1_L1:

assumes $$f:A\rightarrow C$$

shows $$domain(f) = A$$
theorem fin_indseq_props:

assumes $$f: X\rightarrow X$$ and $$x\in X$$ and $$n \in nat$$ and $$a = \text{InductiveSequenceN}(x,f,n)$$

shows $$a: succ(n) \rightarrow X$$, $$a(0) = x$$, $$\forall k\in n.\ a(succ(k)) = f(a(k))$$
lemma succ_subset:

assumes $$k \in nat$$, $$n \in nat$$ and $$k\subseteq n$$

shows $$succ(k) \subseteq succ(n)$$
lemma nat_incl_total:

assumes $$i \in nat$$, $$j \in nat$$

shows $$i \subseteq j \vee j \subseteq i$$
lemma indseq_consistent:

assumes $$f: X\rightarrow X$$ and $$x\in X$$ and $$i \in nat$$, $$j \in nat$$ and $$i \subseteq j$$

shows $$\text{restrict}( \text{InductiveSequenceN}(x,f,j),succ(i)) = \text{InductiveSequenceN}(x,f,i)$$
lemma indseq_subsets:

assumes $$f: X\rightarrow X$$ and $$x\in X$$ and $$i \in nat$$, $$j \in nat$$ and $$a = \text{InductiveSequenceN}(x,f,i)$$, $$b = \text{InductiveSequenceN}(x,f,j)$$

shows $$a \subseteq b \vee b \subseteq a$$
corollary fin_indseq_domain:

assumes $$f: X\rightarrow X$$ and $$x\in X$$ and $$n \in nat$$

shows $$domain( \text{InductiveSequenceN}(x,f,n)) = succ(n)$$
lemma nat_union_succ: shows $$nat = (\bigcup n \in nat.\ succ(n))$$
lemma func1_1_L5A:

assumes $$f:X\rightarrow Y$$, $$x\in X$$, $$y = f(x)$$

shows $$\langle x,y\rangle \in f$$, $$y \in \text{range}(f)$$
lemma func1_1_L5:

assumes $$\langle x,y\rangle \in f$$ and $$f:X\rightarrow Y$$

shows $$x\in X \wedge y\in Y$$
lemma func1_1_L1A:

assumes $$f:X\rightarrow Y$$ and $$\forall x\in X.\ f(x) \in Z$$

shows $$f:X\rightarrow Z$$
Definition of InductiveSequence: $$\text{InductiveSequence}(x,f) \equiv \bigcup n\in nat.\ \text{InductiveSequenceN}(x,f,n)$$
theorem indseq_seq:

assumes $$f: X\rightarrow X$$ and $$x\in X$$

shows $$\text{InductiveSequence}(x,f) : nat \rightarrow X$$
lemma succnat_subset_nat:

assumes $$n \in nat$$

shows $$succ(n) \subseteq nat$$
lemma fun_Union_apply:

assumes $$\bigcup F : X\rightarrow Y$$ and $$f\in F$$ and $$f:A\rightarrow B$$ and $$x\in A$$

shows $$(\bigcup F)(x) = f(x)$$
lemma func_eq:

assumes $$f: X\rightarrow Y$$, $$g: X\rightarrow Z$$ and $$\forall x\in X.\ f(x) = g(x)$$

shows $$f = g$$
lemma indseq_restr_eq:

assumes $$f: X\rightarrow X$$ and $$x\in X$$ and $$n \in nat$$

shows $$\text{restrict}( \text{InductiveSequence}(x,f),succ(n)) = \text{InductiveSequenceN}(x,f,n)$$
lemma func_imagedef:

assumes $$f:X\rightarrow Y$$ and $$A\subseteq X$$

shows $$f(A) = \{f(x).\ x \in A\}$$
theorem indseq_valat0:

assumes $$f: X\rightarrow X$$ and $$x\in X$$

shows $$\text{InductiveSequence}(x,f)(0) = x$$
theorem indseq_vals:

assumes $$f: X\rightarrow X$$ and $$x\in X$$ and $$n \in nat$$

shows $$\text{InductiveSequence}(x,f)(succ(n)) = f( \text{InductiveSequence}(x,f)(n))$$
lemma fix_2nd_var_fun:

assumes $$f : X\times Y \rightarrow Z$$ and $$y\in Y$$

shows $$\text{Fix2ndVar}(f,y) : X \rightarrow Z$$
lemma func1_1_L6:

assumes $$f:X\rightarrow Y$$

shows $$f(B) \subseteq \text{range}(f)$$ and $$f(B) \subseteq Y$$
theorem ind_seq_image:

assumes $$f: X\rightarrow X$$ and $$x\in X$$ and $$A = \text{InductiveSequence}(x,f)(nat)$$

shows $$x\in A$$ and $$\forall y\in A.\ f(y) \in A$$
theorem binop_gen_set:

assumes $$f: X\times Y \rightarrow X$$ and $$x\in X$$, $$y\in Y$$ and $$a = \text{InductiveSequence}(x, \text{Fix2ndVar}(f,y))$$

shows $$a : nat \rightarrow X$$, $$a(nat) \in Pow(X)$$, $$x \in a(nat)$$, $$\forall z \in a(nat).\ \text{Fix2ndVar}(f,y)(z) \in a(nat)$$
lemma fix_var_val:

assumes $$f : X\times Y \rightarrow Z$$ and $$x\in X$$, $$y\in Y$$

shows $$\text{Fix1stVar}(f,x)(y) = f\langle x,y\rangle$$, $$\text{Fix2ndVar}(f,y)(x) = f\langle x,y\rangle$$
lemma fix_2nd_var_restr_comm:

assumes $$f : X\times Y \rightarrow Z$$ and $$y\in Y$$ and $$X_1 \subseteq X$$

shows $$\text{Fix2ndVar}(\text{restrict}(f,X_1\times Y),y) = \text{restrict}( \text{Fix2ndVar}(f,y),X_1)$$
theorem binop_gen_set1:

assumes $$f: X\times Y \rightarrow X$$ and $$X_1 \subseteq X$$ and $$x\in X_1$$, $$y\in Y$$ and $$\forall t\in X_1.\ f\langle t,y\rangle \in X_1$$ and $$a = \text{InductiveSequence}(x, \text{Fix2ndVar}(\text{restrict}(f,X_1\times Y),y))$$

shows $$a : nat \rightarrow X_1$$, $$a(nat) \in Pow(X_1)$$, $$x \in a(nat)$$, $$\forall z \in a(nat).\ \text{Fix2ndVar}(f,y)(z) \in a(nat)$$, $$\forall z \in a(nat).\ f\langle z,y\rangle \in a(nat)$$
Definition of StateTransfFunNMeta: $$\text{StateTransfFunNMeta}(F,n,s) \equiv$$ $$\text{if }(\text{snd}(s) \in n)\text{ then }\langle F(\text{snd}(s))(\text{fst}(s)), succ(\text{snd}(s))\rangle \text{ else }s$$
lemma ZF_fun_from_total:

assumes $$\forall x\in X.\ b(x) \in Y$$

shows $$\{\langle x,b(x)\rangle .\ x\in X\} : X\rightarrow Y$$
Definition of StateTransfFunN: $$\text{StateTransfFunN}(X,F,n) \equiv \{\langle s, \text{StateTransfFunNMeta}(F,n,s)\rangle .\ s \in X\times succ(n)\}$$
lemma state_trans_fun:

assumes $$n \in nat$$ and $$F: n \rightarrow (X\rightarrow X)$$

shows $$\text{StateTransfFunN}(X,F,n): X\times succ(n) \rightarrow X\times succ(n)$$
Definition of StatesSeq: $$\text{StatesSeq}(x,X,F,n) \equiv$$ $$\text{InductiveSequenceN}(\langle x,0\rangle , \text{StateTransfFunN}(X,F,n),n)$$
lemma ZF_fun_from_tot_val:

assumes $$f:X\rightarrow Y$$, $$x\in X$$ and $$f = \{\langle x,b(x)\rangle .\ x\in X\}$$

shows $$f(x) = b(x)$$
lemma fin_nat_ind:

assumes $$n \in nat$$ and $$k \in succ(n)$$ and $$P(0)$$ and $$\forall j\in n.\ P(j) \longrightarrow P(succ(j))$$

shows $$P(k)$$
lemma states_seq_props:

assumes $$n \in nat$$ and $$F: n \rightarrow (X\rightarrow X)$$ and $$x\in X$$ and $$b = \text{StatesSeq}(x,X,F,n)$$

shows $$b : succ(n) \rightarrow X\times succ(n)$$, $$b(0) = \langle x,0\rangle$$, $$\forall k \in succ(n).\ \text{snd}(b(k)) = k$$, $$\forall k\in n.\ b(succ(k)) = \langle F(k)(\text{fst}(b(k))), succ(k)\rangle$$
Definition of InductiveSeqVarFN: $$\text{InductiveSeqVarFN}(x,X,F,n) \equiv \{\langle k,\text{fst}( \text{StatesSeq}(x,X,F,n)(k))\rangle .\ k \in succ(n)\}$$
theorem fin_indseq_var_f_props:

assumes $$n \in nat$$ and $$x\in X$$ and $$F: n \rightarrow (X\rightarrow X)$$ and $$a = \text{InductiveSeqVarFN}(x,X,F,n)$$

shows $$a: succ(n) \rightarrow X$$, $$a(0) = x$$, $$\forall k\in n.\ a(succ(k)) = F(k)(a(k))$$
260
100
41
41