General set theory

We start by importing the theorems of propositional logic and predicate logic, and the Interface:Axioms of general set theory. We also define some variables.  import (CLASSICAL Interface:Classical_propositional_calculus ) import (FIRSTORDER Interface:First-order_logic_with_quantifiability (CLASSICAL) ) import (AXIOMS Interface:Axioms_of_general_set_theory (CLASSICAL FIRSTORDER) )

var (variable x y z w result) var (object A B C D A0 A1 B0 B1) 

Empty set
The empty set, or null set, is the set with no elements. We start with the conventional form of the axiom of empty set, which is a theorem rather than an axiom for us (and for many other axiomizations of set theory).  thm (axnul ((x y z)) (∃ x (∀ y (¬ ((value y) ∈ (value x))))) (  The only set theory axiom we use in the proof is the axiom of separation, which says that given the existence of any set (which is implicit in some the predicate logic steps), we can construct a subset of it which has no elements. Here is our application of separation, which we will use at the end of the proof (after a bunch of logical steps).  x y z (((value y) ∈ (value y)) ∧ (¬ ((value y) ∈ (value y)))) Separation  The proof starts with  (¬ ((value y) ∈ (value y))) TertiumNonDatur collectNegationNDN  We now add  to get  ((value y) ∈ (value z)) (((value y) ∈ (value y)) ∧ (¬ ((value y) ∈ (value y)))) ConjunctionLeftElimination introduceTransposition applyModusPonens  We note that  implies itself.  (((value y) ∈ (value x)) ↔ (((value y) ∈ (value z)) ∧ (((value y) ∈ (value y)) ∧ (¬ ((value y) ∈ (value y)))))) ImplicationReflexivity  We detach half the biconditional to get  negatedDetachImplicationBiconditionalRight  We're almost there. We just need to add the quantifiers and apply the instance of the axiom of separation that we started with.  y addForAll x addThereExists applyModusPonens )) 

Now we introduce the symbol  for the empty set.

 var (variable emptyElement) def ((∅) (abstract emptyElement (⊥)))

thm (EmptySetVariable ((result x y)) ((value x) ∉ (abstract y (⊥))) ( </jh> To apply, we need. This follows from, the   relationship between negation and  , and the fact that substituting a variable in   has no effect.  result x axnul

((value x) ∈ (value result)) NegationBiconditional ((value x) ∈ (value result)) BiconditionalReflexivity (value x) y (⊥) NullSubstitution swapBiconditional buildBiconditional applyBiconditionalTransitivity

x buildForAll result buildThereExists

eliminateBiconditionalReverse applyModusPonens </jh> Now that we have, we can apply   to get.  Abstraction </jh> Moving the substitution which has no effect  (value x) y (⊥) NullSubstitution applyBiconditionalTransitivity </jh> gives us and then   gives us our desired result.  ((value x) ∈ (abstract y (⊥))) NegationBiconditional eliminateBiconditionalForward applyModusPonens )) </jh>

We provide a version with object instead of variable.  thm (EmptySetObject ((x A y)) (A ∉ (abstract y (⊥))) ( </jh> The substitution to apply  is   (value x) A (abstract y (⊥)) MembershipBuilderRR addNegationInConsequent

x y EmptySetVariable

VariableToObject ))

thm (EmptySet ((A emptyElement)) (A ∉ (∅)) ( A emptyElement EmptySetObject )) </jh>

Adjunction for objects
The  axiom allows us to form a set with the elements of a given set and a single additional given element, where the given sets are represented by variables. Here we prove the same thing, but with object in place of variable. The proof is by straightforward application of  with the usual substitution machinery.  thm (AdjunctionObject-1 ((A x z w) (y x z w)) (∃ w (∀ z (((value z) ∈ (value w)) ↔ (((value z) ∈ A) ∨ ((value z) = (value y)))))) ( (value x) A (value z) MembershipBuilderLL ((value z) = (value y)) buildDisjunctionRRInConsequent ((value z) ∈ (value w)) buildBiconditionalLLInConsequent z buildForAllInConsequent w buildThereExistsInConsequent

w z x y Adjunction

VariableToObject ))

thm (AdjunctionObject ((A y z w) (B y z w)) (∃ w (∀ z (((value z) ∈ (value w)) ↔ (((value z) ∈ A) ∨ ((value z) = B))))) ( (value y) B (value z) EqualityBuilderLL ((value z) ∈ A) buildDisjunctionLLInConsequent ((value z) ∈ (value w)) buildBiconditionalLLInConsequent z buildForAllInConsequent w buildThereExistsInConsequent

w z A y AdjunctionObject-1

VariableToObject )) </jh>

Object version of extensionality
Here is a variant of extensionality,, which changes variables to objects. We first prove a lemma.

 thm (Extensionality-1 ((z A) (x y z) (x A)) ((∀ z (((value z) ∈ A) ↔ ((value z) ∈ (value y)))) → (A = (value y))) ( </jh> This lemma changes  to , using   applied to   (value x) A (value z) MembershipBuilderLL ((value z) ∈ (value y)) buildBiconditionalRRInConsequent z buildForAllInConsequent

(value x) A (value y) EqualityBuilderRR

buildImplicationInConsequent

z x y ExtensionalityVariable VariableToObject ))

thm (Extensionality ((A z) (B z) (z y) (A y) (B y)) ((∀ z (((value z) ∈ A) ↔ ((value z) ∈ B))) → (A = B)) ( </jh> To prove this, we change  to , using   applied to   (value y) B (value z) MembershipBuilderLL ((value z) ∈ A) buildBiconditionalLLInConsequent z buildForAllInConsequent

(value y) B A EqualityBuilderLL

buildImplicationInConsequent

z A y Extensionality-1 VariableToObject )) </jh>

Singletons
Given a set (object), here we construct a set   which has   as its only element. That is, we are trying to prove the theorem.

Our first lemma is, which is the first step towards applying the adjunction axiom to singletons. To avoid having to write  everywhere, we use   for an object which corresponds to the variable.

Another detail is that if we specified the empty set as, it would expand to a dummy variable which we are unable to express a distinct variable constraint for. By writing  instead we get to include the distinct variable constraints on. In our informal descriptions we will continue to say  in such situations.  var (object yy) thm (Singleton-1 ((yy emptyElement)) ((yy = A) ↔ ((yy ∈ (abstract emptyElement (⊥))) ∨ (yy = A))) ( (yy = A) (yy ∈ (abstract emptyElement (⊥))) DisjunctionLeftIntroduction

yy emptyElement EmptySetObject (yy ≠ A) introduceAntecedent eliminateTransposition

(yy = A) ImplicationReflexivity

composeDisjunction

introduceBiconditionalFromImplications )) </jh>

In a few places we'll need.  thm (Singleton-eq ((yy z) (z A)) ((subst yy z ((value z) = A)) ↔ (yy = A)) ( </jh> Our substitution is.  ((value z) = yy) ImplicationReflexivity A buildEqualityRRInConsequent </jh> Making this explicit gives us our result.  makeSubstExplicit )) </jh>

Applying  to the left hand side of   gets us.  thm (Singleton-2 ((yy z) (z A) (yy emptyElement)) ((subst yy z ((value z) = A)) ↔ ((yy ∈ (abstract emptyElement (⊥))) ∨ (yy = A))) ( yy z A Singleton-eq yy A emptyElement Singleton-1 applyBiconditionalTransitivity )) </jh>

The next step is to take  and apply builders until we get <jh> thm (Singleton-3 ((y z) (z A) (y emptyElement)) ((∃ result (∀ y (((value y) ∈ (value result)) ↔ (subst (value y) z ((value z) = A))))) ↔ (∃ result (∀ y (((value y) ∈ (value result)) ↔ (((value y) ∈ (abstract emptyElement (⊥))) ∨ ((value y) = A)))))) ( (value y) z A emptyElement Singleton-2 ((value y) ∈ (value result)) buildBiconditionalLL y buildForAll result buildThereExists )) </jh>

The right hand side of  holds by adjunction, so we can conclude the left hand side as a theorem. <jh> thm (Singleton-4 ((y z) (z A) (result y A) (result y emptyElement)) (∃ result (∀ y (((value y) ∈ (value result)) ↔ (subst (value y) z ((value z) = A))))) ( result y (abstract emptyElement (⊥)) A AdjunctionObject

result y z A emptyElement Singleton-3 eliminateBiconditionalForward

applyModusPonens )) </jh>

Because the notation  is not available, we call it. <jh> def ((singleton A) (abstract y ((value y) = A))) </jh>

We can now prove that <jh> var (variable singletonElement) thm (SingletonVariable ((result z y A)) (((value y) ∈ (abstract z ((value z) = A))) ↔ ((value y) = A)) ( result y z A Singleton-4 Abstraction

(value y) z A Singleton-eq applyBiconditionalTransitivity )) </jh>

Getting rid of the distinct variable constraint and changing  from a variable to an object are accomplished by invoking. <jh> thm (SingletonObject ((y B) (y A singletonElement)) ((B ∈ (abstract singletonElement ((value singletonElement) = A))) ↔ (B = A)) ( </jh> Our substitution is. <jh> (value y) B (abstract singletonElement ((value singletonElement) = A)) MembershipBuilderRR (value y) B A EqualityBuilderRR buildBiconditionalInConsequent

y singletonElement A SingletonVariable

VariableToObject ))

thm (Singleton ((singletonElement A)) ((B ∈ (singleton A)) ↔ (B = A)) ( B singletonElement A SingletonObject )) </jh>

Builder
The builder for singletons is. <jh> var (variable a b) thm (SingletonBuilder-1 ((z A) (z B) (z a) (z b) (A a) (B b)) ((A = B) → ((abstract a ((value a) = A)) = (abstract b ((value b) = B)))) ( </jh> The equality builder gives us. <jh> A B (value z) EqualityBuilderLL </jh> Applying  twice gives us  <jh> (value z) a A SingletonObject (value z) b B SingletonObject buildBiconditional </jh> We now combine those two results to get <jh> eliminateBiconditionalForward applySyllogism </jh> Extensionality turns  into. <jh> z addForAllToConsequent

z (abstract a ((value a) = A)) (abstract b ((value b) = B)) Extensionality applySyllogism ))

thm (SingletonBuilder-2 ((A a) (B b)) ((A = B) → ((singleton A) = (abstract b ((value b) = B)))) ( A B a b SingletonBuilder-1 ))

thm (SingletonBuilder ((B b)) ((A = B) → ((singleton A) = (singleton B))) ( A B b SingletonBuilder-2 )) </jh>

Unordered pair
The unordered pair  has   and   as elements. That is, we seek to prove. The idea of the proof is easy: apply adjunction to  and , but formalizing this involves much the same substitution machinery that we saw with singletons.

The first lemma is. <jh> thm (UnorderedPair-1 ((singletonElement A)) (((yy ∈ (abstract singletonElement ((value singletonElement) = A))) ∨ (yy = B)) ↔ ((yy = A) ∨ (yy = B))) ( yy singletonElement A SingletonObject (yy = B) buildDisjunctionRR )) </jh>

The next lemma,, is a substitution that we'll use two places. <jh> thm (UnorderedPair-sub ((z yy) (z A) (z B)) ((subst yy z (((value z) = A) ∨ ((value z) = B))) ↔ ((yy = A) ∨ (yy = B))) ( </jh> We construct the substitution  and then make it explicit. <jh> (value z) yy A EqualityBuilderRR (value z) yy B EqualityBuilderRR buildDisjunctionInConsequent

makeSubstExplicit )) </jh>

We now combine the previous two results and apply some builders to get <jh> thm (UnorderedPair-3 ((singletonElement A) (z y) (z A) (z B)) ((∃ result (∀ y (((value y) ∈ (value result)) ↔ (subst (value y) z (((value z) = A) ∨ ((value z) = B)))))) ↔ (∃ result (∀ y (((value y) ∈ (value result)) ↔ (((value y) ∈ (abstract singletonElement ((value singletonElement) = A))) ∨ ((value y) = B)))))) ( (value y) z A B UnorderedPair-sub (value y) singletonElement A B UnorderedPair-1 swapBiconditional applyBiconditionalTransitivity

((value y) ∈ (value result)) buildBiconditionalLL y buildForAll result buildThereExists )) </jh>

The right hand side of  holds by adjunction, so we can conclude the left hand side as a theorem. <jh> thm (UnorderedPair-4 ((y z) (z A) (z B) (result y A) (result y B) (result y singletonElement) (singletonElement A))  (∃ result (∀ y (((value y) ∈ (value result)) ↔ (subst (value y) z (((value z) = A) ∨ ((value z) = B)))))) ( result y (abstract singletonElement ((value singletonElement) = A)) B AdjunctionObject

result y z A B singletonElement UnorderedPair-3 eliminateBiconditionalForward

applyModusPonens )) </jh>

Because the notation  is not available, we call it. <jh> def ((unorderedPair A B) (abstract y (((value y) = A) ∨ ((value y) = B)))) </jh>

We can now prove that <jh> var (variable pairElement) thm (UnorderedPairVariable ((result z y A) (result z y B))  (((value y) ∈ (abstract z (((value z) = A) ∨ ((value z) = B)))) ↔ (((value y) = A) ∨ ((value y) = B))) ( result y z A B UnorderedPair-4 Abstraction

(value y) z A B UnorderedPair-sub applyBiconditionalTransitivity )) </jh>

Getting rid of the distinct variable constraint and changing  from a variable to an object are accomplished by invoking. <jh> thm (UnorderedPairObject ((y C) (y A pairElement) (y B pairElement)) ((C ∈ (abstract pairElement (((value pairElement) = A) ∨ ((value pairElement) = B)))) ↔ ((C = A) ∨ (C = B))) ( </jh> Our substitution is. <jh> (value y) C (abstract pairElement (((value pairElement) = A) ∨ ((value pairElement) = B))) MembershipBuilderRR

(value y) C A EqualityBuilderRR (value y) C B EqualityBuilderRR buildDisjunctionInConsequent buildBiconditionalInConsequent

y pairElement A B UnorderedPairVariable

VariableToObject ))

thm (UnorderedPair ((pairElement A) (pairElement B)) ((C ∈ (unorderedPair A B)) ↔ ((C = A) ∨ (C = B))) ( C pairElement A B UnorderedPairObject )) </jh>

Builder
The builder for unordered pairs is. <jh> thm (UnorderedPairBuilder-1 ((z a) (z A0) (z A1) (z b) (z B0) (z B1) (a A0) (a A1) (b B0) (b B1))    (((A0 = B0) ∧ (A1 = B1)) → ((abstract a (((value a) = A0) ∨ ((value a) = A1))) = (abstract b (((value b) = B0) ∨ ((value b) = B1))))) ( </jh> Applying builders for equality and disjunction, we get. <jh> (A0 = B0) (A1 = B1) ConjunctionRightElimination A0 B0 (value z) EqualityBuilderLL applySyllogism

(A0 = B0) (A1 = B1) ConjunctionLeftElimination A1 B1 (value z) EqualityBuilderLL applySyllogism

composeConjunction

((value z) = A0) ((value z) = B0) ((value z) = A1) ((value z) = B1) DisjunctionFunction applySyllogism </jh> Applying, we get. <jh> (value z) a A0 A1 UnorderedPairObject swapBiconditional transformImplicationBiconditionalLeft

(value z) b B0 B1 UnorderedPairObject swapBiconditional transformImplicationBiconditionalRight </jh> By extensionality, the right hand side implies. <jh> z addForAllToConsequent z (abstract a (((value a) = A0) ∨ ((value a) = A1))) (abstract b (((value b) = B0) ∨ ((value b) = B1))) Extensionality applySyllogism ))

thm (UnorderedPairBuilder-2 ((a A0) (a A1) (b B0) (b B1)) (((A0 = B0) ∧ (A1 = B1)) → ((abstract a (((value a) = A0) ∨ ((value a) = A1))) = (unorderedPair B0 B1))) ( A0 B0 A1 B1 a b UnorderedPairBuilder-1 ))

thm (UnorderedPairBuilder ((a A0) (a A1)) (((A0 = B0) ∧ (A1 = B1)) → ((unorderedPair A0 A1) = (unorderedPair B0 B1))) ( A0 B0 A1 B1 a UnorderedPairBuilder-2 )) </jh>

Done
We have now proved all the theorems in Interface:Basic operations of general set theory.

<jh> export (GENERAL Interface:Basic_operations_of_general_set_theory (CLASSICAL FIRSTORDER) ) </jh>