This theory file contains properties of finite sets related to order relations. Part of this is similar to what is done in Finite_ZF_1 except that the development is based on the notion of finite powerset defined in Finite_ZF rather the one defined in standard Isabelle Finite theory.
The goal of this section is to show that finite sets are bounded and have maxima and minima.
For total and transitive relations nonempty finite set has a maximum.
theorem fin_has_max:
assumes A1: \( r \text{ is total on } X \) and A2: \( \text{trans}(r) \) and A3: \( B \in \text{FinPow}(X) \) and A4: \( B \neq 0 \)
shows \( \text{HasAmaximum}(r,B) \)proofFor linearly ordered nonempty finite sets the maximum is in the set and indeed it is the greatest element of the set.
lemma linord_max_props:
assumes A1: \( \text{IsLinOrder}(X,r) \) and A2: \( A \in \text{FinPow}(X) \), \( A \neq 0 \)
shows \( \text{Maximum}(r,A) \in A \), \( \text{Maximum}(r,A) \in X \), \( \forall a\in A.\ \langle a, \text{Maximum}(r,A)\rangle \in r \)proofEvery nonempty subset of a natural number has a maximum with expected properties.
lemma nat_max_props:
assumes \( n\in nat \), \( A\subseteq n \), \( A\neq 0 \)
shows \( \text{Maximum}(Le,A) \in A \), \( \text{Maximum}(Le,A) \in nat \), \( \forall k\in A.\ k \leq \text{Maximum}(Le,A) \)proofYet another version of induction where the induction step is valid only up to \(n\in \mathbb{N}\) rather than for all natural numbers. This lemma is redundant as it is easier to prove this assertion using lemma fin_nat_ind from Nat_ZF_IML which was done in lemma fin_nat_ind1 there. It is left here for now as an alternative proof based on properties of the maximum of a finite set.
lemma ind_on_nat2:
assumes \( n\in nat \) and \( P(0) \) and \( \forall j\in n.\ P(j)\longrightarrow P(j + 1) \)
shows \( \forall j\in n + 1.\ P(j) \) and \( P(n) \)proofIn this section we establish that if two linearly ordered finite sets have the same number of elements, then they are order-isomorphic and the isomorphism is unique. This allows us to talk about ''enumeration'' of a linearly ordered finite set. We define the enumeration as the order isomorphism between the number of elements of the set (which is a natural number \(n = \{0,1,..,n-1\}\)) and the set.
A really weird corner case - empty set is order isomorphic with itself.
lemma empty_ord_iso:
shows \( ord\_iso(0,r,0,R) \neq 0 \)proofEven weirder than empty_ord_iso The order automorphism of the empty set is unique.
lemma empty_ord_iso_uniq:
assumes \( f \in ord\_iso(0,r,0,R) \), \( g \in ord\_iso(0,r,0,R) \)
shows \( f = g \)proofThe empty set is the only order automorphism of itself.
lemma empty_ord_iso_empty:
shows \( ord\_iso(0,r,0,R) = \{0\} \)proofAn induction (or maybe recursion?) scheme for linearly ordered sets. The induction step is that we show that if the property holds when the set is a singleton or for a set with the maximum removed, then it holds for the set. The idea is that since we can build any finite set by adding elements on the right, then if the property holds for the empty set and is invariant with respect to this operation, then it must hold for all finite sets.
lemma fin_ord_induction:
assumes A1: \( \text{IsLinOrder}(X,r) \) and A2: \( P(0) \) and A3: \( \forall A \in \text{FinPow}(X).\ A \neq 0 \longrightarrow (P(A - \{ \text{Maximum}(r,A)\}) \longrightarrow P(A)) \) and A4: \( B \in \text{FinPow}(X) \)
shows \( P(B) \)proofA sligltly more complicated version of fin_ord_induction that allows to prove properties that are not true for the empty set.
lemma fin_ord_ind:
assumes A1: \( \text{IsLinOrder}(X,r) \) and A2: \( \forall A \in \text{FinPow}(X).\ \) \( A = 0 \vee (A = \{ \text{Maximum}(r,A)\} \vee P(A - \{ \text{Maximum}(r,A)\}) \longrightarrow P(A)) \) and A3: \( B \in \text{FinPow}(X) \) and A4: \( B\neq 0 \)
shows \( P(B) \)proofYet another induction scheme. We build a linearly ordered set by adding elements that are greater than all elements in the set.
lemma fin_ind_add_max:
assumes A1: \( \text{IsLinOrder}(X,r) \) and A2: \( P(0) \) and A3: \( \forall A \in \text{FinPow}(X).\ \) \( ( \forall x \in X-A.\ P(A) \wedge (\forall a\in A.\ \langle a,x\rangle \in r ) \longrightarrow P(A \cup \{x\})) \) and A4: \( B \in \text{FinPow}(X) \)
shows \( P(B) \)proofThe only order automorphism of a linearly ordered finite set is the identity.
theorem fin_ord_auto_id:
assumes A1: \( \text{IsLinOrder}(X,r) \) and A2: \( B \in \text{FinPow}(X) \) and A3: \( B\neq 0 \)
shows \( ord\_iso(B,r,B,r) = \{id(B)\} \)proofEvery two finite linearly ordered sets are order isomorphic. The statement is formulated to make the proof by induction on the size of the set easier, see fin_ord_iso_ex for an alternative formulation.
lemma fin_order_iso:
assumes A1: \( \text{IsLinOrder}(X,r) \), \( \text{IsLinOrder}(Y,R) \) and A2: \( n \in nat \)
shows \( \forall A \in \text{FinPow}(X).\ \forall B \in \text{FinPow}(Y).\ \) \( A \approx n \wedge B \approx n \longrightarrow ord\_iso(A,r,B,R) \neq 0 \)proofEvery two finite linearly ordered sets are order isomorphic.
lemma fin_ord_iso_ex:
assumes A1: \( \text{IsLinOrder}(X,r) \), \( \text{IsLinOrder}(Y,R) \) and A2: \( A \in \text{FinPow}(X) \), \( B \in \text{FinPow}(Y) \) and A3: \( B \approx A \)
shows \( ord\_iso(A,r,B,R) \neq 0 \)proofExistence and uniqueness of order isomorphism for two linearly ordered sets with the same number of elements.
theorem fin_ord_iso_ex_uniq:
assumes A1: \( \text{IsLinOrder}(X,r) \), \( \text{IsLinOrder}(Y,R) \) and A2: \( A \in \text{FinPow}(X) \), \( B \in \text{FinPow}(Y) \) and A3: \( B \approx A \)
shows \( \exists !f.\ f \in ord\_iso(A,r,B,R) \)proofassumes \( r \text{ is total on } X \)
shows \( \text{refl}(X,r) \)assumes \( \text{refl}(X,r) \) and \( a\in X \)
shows \( \text{HasAmaximum}(r,\{a\}) \), \( \text{HasAminimum}(r,\{a\}) \)assumes \( r \text{ is total on } X \) and \( \text{trans}(r) \) and \( A\subseteq X \) and \( a\in X \) and \( \text{HasAmaximum}(r,A) \)
shows \( \text{HasAmaximum}(r,A\cup \{a\}) \)assumes \( P(0) \) and \( \forall A \in \text{FinPow}(X).\ P(A) \longrightarrow (\forall a\in X.\ P(A \cup \{a\})) \) and \( B \in \text{FinPow}(X) \)
shows \( P(B) \)assumes \( r \text{ is total on } X \) and \( \text{trans}(r) \) and \( B \in \text{FinPow}(X) \) and \( B \neq 0 \)
shows \( \text{HasAmaximum}(r,B) \)assumes \( \text{antisym}(r) \) and \( \text{HasAmaximum}(r,A) \)
shows \( \text{Maximum}(r,A) \in A \), \( \forall x\in A.\ \langle x, \text{Maximum}(r,A)\rangle \in r \)assumes \( n \in nat \)
shows \( n \in \text{FinPow}(nat) \)assumes \( A \in \text{FinPow}(X) \) and \( B \subseteq A \)
shows \( B \in \text{FinPow}(X) \)assumes \( \text{IsLinOrder}(X,r) \) and \( A \in \text{FinPow}(X) \), \( A \neq 0 \)
shows \( \text{Maximum}(r,A) \in A \), \( \text{Maximum}(r,A) \in X \), \( \forall a\in A.\ \langle a, \text{Maximum}(r,A)\rangle \in r \)assumes \( \text{IsLinOrder}(X,r) \) and \( A \in \text{FinPow}(X) \), \( A \neq 0 \)
shows \( \text{Maximum}(r,A) \in A \), \( \text{Maximum}(r,A) \in X \), \( \forall a\in A.\ \langle a, \text{Maximum}(r,A)\rangle \in r \)assumes \( n \in nat \)
shows \( 0 \in succ(n) \)assumes \( n\in nat \), \( A\subseteq n \), \( A\neq 0 \)
shows \( \text{Maximum}(Le,A) \in A \), \( \text{Maximum}(Le,A) \in nat \), \( \forall k\in A.\ k \leq \text{Maximum}(Le,A) \)assumes \( n\in nat \)
shows \( n + 1 = succ(n) \), \( n + 1 \in nat \), \( \{0\} + n = succ(n) \), \( n + \{0\} = succ(n) \), \( succ(n) \in nat \), \( 0 \in n + 1 \), \( n \subseteq n + 1 \)assumes \( n \in nat \), \( i\in n \)
shows \( succ(i) \in succ(n) \), \( i + 1 \in n + 1 \), \( i \in n + 1 \)assumes \( x\in A \) and \( y=x \)
shows \( y\in A \)assumes \( f: X\rightarrow Y \), \( g: X\rightarrow Z \) and \( \forall x\in X.\ f(x) = g(x) \)
shows \( f = g \)assumes \( f:X\rightarrow Y \)
shows \( f \subseteq X\times Y \)assumes \( f \in ord\_iso(0,r,0,R) \), \( g \in ord\_iso(0,r,0,R) \)
shows \( f = g \)assumes \( P(0) \) and \( \forall A \in \text{FinPow}(X).\ A \neq 0 \longrightarrow (\exists a\in A.\ P(A-\{a\}) \longrightarrow P(A)) \) and \( B \in \text{FinPow}(X) \)
shows \( P(B) \)assumes \( \forall A \in \text{FinPow}(X).\ \) \( A = 0 \vee (\exists a\in A.\ A = \{a\} \vee P(A-\{a\}) \longrightarrow P(A)) \) and \( A \in \text{FinPow}(X) \) and \( A\neq 0 \)
shows \( P(A) \)assumes \( A \in \text{FinPow}(X) \)
shows \( A - \{a\} \in \text{FinPow}(X) \)assumes \( \text{IsLinOrder}(X,r) \) and \( P(0) \) and \( \forall A \in \text{FinPow}(X).\ A \neq 0 \longrightarrow (P(A - \{ \text{Maximum}(r,A)\}) \longrightarrow P(A)) \) and \( B \in \text{FinPow}(X) \)
shows \( P(B) \)assumes \( \text{antisym}(r) \) and \( f \in ord\_iso(A,r,B,R) \) and \( \text{HasAmaximum}(r,A) \) and \( M = \text{Maximum}(r,A) \)
shows \( \text{restrict}(f,A-\{M\}) \in ord\_iso(A-\{M\}, r, B-\{f(M)\},R) \)assumes \( \text{antisym}(r) \) and \( f \in ord\_iso(A,r,A,r) \) and \( \text{HasAmaximum}(r,A) \)
shows \( \text{Maximum}(r,A) = f( \text{Maximum}(r,A)) \)assumes \( f:X\rightarrow X \) and \( p\in X \) and \( f(p) = p \) and \( \text{restrict}(f, X-\{p\}) = id(X-\{p\}) \)
shows \( f = id(X) \)assumes \( \text{IsLinOrder}(X,r) \) and \( \forall A \in \text{FinPow}(X).\ \) \( A = 0 \vee (A = \{ \text{Maximum}(r,A)\} \vee P(A - \{ \text{Maximum}(r,A)\}) \longrightarrow P(A)) \) and \( B \in \text{FinPow}(X) \) and \( B\neq 0 \)
shows \( P(B) \)assumes \( \text{IsLinOrder}(X,r) \) and \( A\subseteq X \)
shows \( \text{IsLinOrder}(A,r) \) and \( \text{IsLinOrder}(A,r \cap A\times A) \)assumes \( \text{IsLinOrder}(X,r) \), \( \text{IsLinOrder}(Y,R) \) and \( \text{HasAmaximum}(r,X) \), \( \text{HasAmaximum}(R,Y) \), \( ord\_iso(X - \{ \text{Maximum}(r,X)\},r,Y - \{ \text{Maximum}(R,Y)\},R) \neq 0 \)
shows \( ord\_iso(X,r,Y,R) \neq 0 \)assumes \( n\in nat \) and \( P(0) \) and \( \forall k\in nat.\ P(k)\longrightarrow P(succ(k)) \)
shows \( P(n) \)assumes \( \text{IsLinOrder}(X,r) \), \( \text{IsLinOrder}(Y,R) \) and \( n \in nat \)
shows \( \forall A \in \text{FinPow}(X).\ \forall B \in \text{FinPow}(Y).\ \) \( A \approx n \wedge B \approx n \longrightarrow ord\_iso(A,r,B,R) \neq 0 \)assumes \( \text{IsLinOrder}(X,r) \), \( \text{IsLinOrder}(Y,R) \) and \( A \in \text{FinPow}(X) \), \( B \in \text{FinPow}(Y) \) and \( B \approx A \)
shows \( ord\_iso(A,r,B,R) \neq 0 \)assumes \( \text{IsLinOrder}(X,r) \) and \( B \in \text{FinPow}(X) \) and \( B\neq 0 \)
shows \( ord\_iso(B,r,B,r) = \{id(B)\} \)assumes \( a \in \text{bij}(A,B) \), \( b \in \text{bij}(A,B) \) and \( converse(b)\circ a = id(A) \)
shows \( a = b \)