IsarMathLib

Proofs by humans, for humans, formally verified by Isabelle/ZF proof assistant

theory Finite_ZF imports ZF1 Nat_ZF_IML ZF.Cardinal func1
begin

Standard Isabelle Finite.thy contains a very useful notion of finite powerset: the set of finite subsets of a given set. The definition, however, is specific to Isabelle and based on the notion of "datatype", obviously not something that belongs to ZF set theory. This theory file devolops the notion of finite powerset similarly as in Finite.thy, but based on standard library's Cardinal.thy. This theory file is intended to replace IsarMathLib's Finite1 and Finite_ZF_1 theories that are currently derived from the "datatype" approach.

Definition and basic properties of finite powerset

The goal of this section is to prove an induction theorem about finite powersets: if the empty set has some property and this property is preserved by adding a single element of a set, then this property is true for all finite subsets of this set.

We defined the finite powerset FinPow(X) as those elements of the powerset that are finite.

definition

FinPow(X){APow(X). Finite(A)}

The cardinality of an element of finite powerset is a natural number.

lemma card_fin_is_nat:

assumes AFinPow(X)

shows |A|nat and A|A| using assms, FinPow_def, Finite_def, cardinal_cong, nat_into_Card, Card_cardinal_eq

The cardinality of a finite set is a natural number.

lemma card_fin_is_nat1:

assumes Finite(A)

shows |A|nat using assms, card_fin_is_nat(1) unfolding FinPow_def

A reformulation of card_fin_is_nat: for a finit set A there is a bijection between |A| and A.

lemma fin_bij_card:

assumes A1: AFinPow(X)

shows b. bbij(|A|,A)proof

If a set has the same number of elements as nN, then its cardinality is n. Recall that in set theory a natural number n is a set that has n elements.

lemma card_card:

assumes An and nnat

shows |A|=n using assms, cardinal_cong, nat_into_Card, Card_cardinal_eq

If we add a point to a finite set, the cardinality increases by one. To understand the second assertion |A{a}|=|A|{|A|} recall that the cardinality |A| of A is a natural number and for natural numbers we have n+1=n{n}.

lemma card_fin_add_one:

assumes A1: AFinPow(X) and A2: aXA

shows |A{a}|=succ(|A|), |A{a}|=|A|{|A|}proof

We can decompose the finite powerset into collection of sets of the same natural cardinalities.

lemma finpow_decomp:

shows FinPow(X)=(nnat. {APow(X). An}) using Finite_def, FinPow_def

Finite powerset is the union of sets of cardinality bounded by natural numbers.

lemma finpow_union_card_nat:

shows FinPow(X)=(nnat. {APow(X). An})proof

A different form of finpow_union_card_nat (see above) - a subset that has not more elements than a given natural number is in the finite powerset.

lemma lepoll_nat_in_finpow:

assumes nnat, AX, An

shows AFinPow(X) using assms, finpow_union_card_nat

Natural numbers are finite subsets of the set of natural numbers.

lemma nat_finpow_nat:

assumes nnat

shows nFinPow(nat) using assms, nat_into_Finite, nat_subset_nat, FinPow_def

A finite subset is a finite subset of itself.

lemma fin_finpow_self:

assumes AFinPow(X)

shows AFinPow(A) using assms, FinPow_def

A set is finite iff it is in its finite powerset.

lemma fin_finpow_iff:

shows Finite(A)AFinPow(A) unfolding FinPow_def

If we remove an element and put it back we get the set back.

lemma rem_add_eq:

assumes aA

shows (A{a}){a}=A using assms

Induction for finite powerset. This is smilar to the standard Isabelle's Fin_induct.

theorem FinPow_induct:

assumes A1: P(0) and A2: AFinPow(X). P(A)(aX. P(A{a})) and A3: BFinPow(X)

shows P(B)proof

A subset of a finite subset is a finite subset.

lemma subset_finpow:

assumes AFinPow(X) and BA

shows BFinPow(X) using assms, FinPow_def, subset_Finite

If we subtract anything from a finite set, the resulting set is finite.

lemma diff_finpow:

assumes AFinPow(X)

shows ABFinPow(X) using assms, subset_finpow

If we remove a point from a finites subset, we get a finite subset.

corollary fin_rem_point_fin:

assumes AFinPow(X)

shows A{a}FinPow(X) using assms, diff_finpow

Cardinality of a nonempty finite set is a successsor of some natural number.

lemma card_non_empty_succ:

assumes A1: AFinPow(X) and A2: A0

shows nnat. |A|=succ(n)proof

Nonempty set has non-zero cardinality. This is probably true without the assumption that the set is finite, but I couldn't derive it from standard Isabelle theorems.

lemma card_non_empty_non_zero:

assumes AFinPow(X) and A0

shows |A|0proof

Another variation on the induction theme: If we can show something holds for the empty set and if it holds for all finite sets with at most k elements then it holds for all finite sets with at most k+1 elements, the it holds for all finite sets.

theorem FinPow_card_ind:

assumes A1: P(0) and A2: knat.  (AFinPow(X). AkP(A)) (AFinPow(X). Asucc(k)P(A)) and A3: AFinPow(X)

shows P(A)proof

Another type of induction (or, maybe recursion). In the induction step we try to find a point in the set that if we remove it, the fact that the property holds for the smaller set implies that the property holds for the whole set.

lemma FinPow_ind_rem_one:

assumes A1: P(0) and A2: AFinPow(X). A0(aA. P(A{a})P(A)) and A3: BFinPow(X)

shows P(B)proof

Yet another induction theorem. This is similar, but slightly more complicated than FinPow_ind_rem_one. The difference is in the treatment of the empty set to allow to show properties that are not true for empty set.

lemma FinPow_rem_ind:

assumes A1: AFinPow(X).  A=0(aA. A={a}P(A{a})P(A)) and A2: AFinPow(X) and A3: A0

shows P(A)proof

If a family of sets is closed with respect to taking intersections of two sets then it is closed with respect to taking intersections of any nonempty finite collection.

lemma inter_two_inter_fin:

assumes A1: VT. WT. VWT and A2: N0 and A3: NFinPow(T)

shows (NT)proof

If a family of sets contains the empty set and is closed with respect to taking unions of two sets then it is closed with respect to taking unions of any finite collection.

lemma union_two_union_fin:

assumes A1: 0C and A2: AC. BC. ABC and A3: NFinPow(C)

shows NCproof

Empty set is in finite power set, hence finite power set is never empty.

lemma empty_in_finpow:

shows FinPow(X) and FinPow(X) using FinPow_def

Singleton is in the finite powerset.

lemma singleton_in_finpow:

assumes xX

shows {x}FinPow(X) using assms, FinPow_def

If a set is nonempty then its finite power set contains a nonempty set.

lemma finpow_nempty_nempty:

assumes X

shows FinPow(X){} using assms, singleton_in_finpow

Union of two finite subsets is a finite subset.

lemma union_finpow:

assumes AFinPow(X) and BFinPow(X)

shows ABFinPow(X) using assms, FinPow_def

Union of finite number of finite sets is finite.

lemma fin_union_finpow:

assumes MFinPow(FinPow(X))

shows MFinPow(X) using assms, empty_in_finpow, union_finpow, union_two_union_fin

If a set is finite after removing one element, then it is finite.

lemma rem_point_fin_fin:

assumes A1: xX and A2: A{x}FinPow(X)

shows AFinPow(X)proof

An image of a finite set is finite.

lemma fin_image_fin:

assumes VB. K(V)C and NFinPow(B)

shows {K(V). VN}FinPow(C)proof

If a set X is finite then the set {K(x).xX} is also finite. Its basically standard Isalelle/ZF Finite_RepFun in nicer notation.

lemma fin_rep_fin:

assumes Finite(X)

shows Finite({K(x). xX}) using assms, Finite_RepFun

The image of a singleton by any function is finite. It's of course either empty or has exactly one element, but showing that it's a finite subset of the codomain is good enough for us.

lemma image_singleton_fin:

assumes f:XY

shows f{x}FinPow(Y)proof

Union of a finite indexed family of finite sets is finite.

lemma union_fin_list_fin:

assumes A1: nnat and A2: kn. N(k)FinPow(X)

shows {N(k). kn}FinPow(FinPow(X)) and (kn. N(k))FinPow(X)proof
end