User module:Slawekk/Sandbox

We first import propositional logic and first-order logic.  import (CLASSICAL Interface:Classical_propositional_calculus ) import (FIRSTORDER Interface:First-order_logic_with_quantifiability (CLASSICAL) ) 

We also import Interface:Basic operations of Zermelo–Fraenkel set theory, which is the current home of some of the basic results involving singletons, unordered pairs, and the like.  import (BASIC Interface:Basic_operations_of_Zermelo–Fraenkel_set_theory (CLASSICAL FIRSTORDER) ) 

As usual, capital letters starting from  are set expressions (that is, objects or "classes") and lowercase letters starting with   are set variables.  var (object A B C D A0 A1 B0 B1 α β Z) var (variable a b x y z w a′ b′ x′ y′ z′) var (formula φ ψ antecedent) 

Ordered pair
The ordered pair  can be defined in several ways as long as the definition implies the key ordered pair theorem. The most widely adopted definition is, which is the one we use. Because the notation  is not available in JHilbert, we call it.  def ((orderedPair A B) (unorderedPair (singleton A) (unorderedPair A B))) 

Ordered pair builder
Equals can be substituted for equals in ordered pairs, that is,. This forms one direction of the ordered pair theorem (it is the less interesting of the two, as it holds for a wide variety of operations, not just ordered pairs).  thm (OrderedPairBuilder  (((A0 = A1) ∧ (B0 = B1)) → ((orderedPair A0 B0) = (orderedPair A1 B1))) ( (A0 = A1) (B0 = B1) ConjunctionRightElimination A0 A1 SingletonBuilder applySyllogism

A0 A1 B0 B1 UnorderedPairBuilder

composeConjunction

(singleton A0) (singleton A1) (unorderedPair A0 B0) (unorderedPair A1 B1) UnorderedPairBuilder applySyllogism )) 

We also provide the usual convenience builders.  thm (OrderedPairBuilderLL  ((B0 = B1) → ((orderedPair A B0) = (orderedPair A B1))) ( A EqualityReflexivity A A B0 B1 OrderedPairBuilder export applyModusPonens ))

thm (buildOrderedPairLLInConsequent  ((H (antecedent → (B0 = B1))))  (antecedent → ((orderedPair A B0) = (orderedPair A B1))) ( H       B0 B1 A OrderedPairBuilderLL applySyllogism ))

thm (OrderedPairBuilderRR  ((A0 = A1) → ((orderedPair A0 B) = (orderedPair A1 B))) ( B EqualityReflexivity A0 A1 B B OrderedPairBuilder export applyComm applyModusPonens ))

thm (buildOrderedPairRRInConsequent  ((H (antecedent → (A0 = A1))))  (antecedent → ((orderedPair A0 B) = (orderedPair A1 B))) ( H       A0 A1 B OrderedPairBuilderRR applySyllogism )) 

First half of the ordered pair theorem
In this section we prove.

Our first lemma is a simple consequence of our definition of ordered pair.  thm (OrderedPairTheoremForwardFirst-1  ((singleton A) ∈ (orderedPair A B)) ( (singleton A) (unorderedPair A B) UnorderedPairLeftMembership )) 

The next lemma,, also follows directly from our definition of ordered pair.  thm (OrderedPairTheoremForwardFirst-2  ((A ∈ (orderedPair B C)) ↔ ((A = (singleton B)) ∨ (A = (unorderedPair B C)))) ( A (singleton B) (unorderedPair B C) UnorderedPair )) 

We're ready for. We rename the variables in an effort to make the proof easier to read:  thm (OrderedPairTheoremForwardFirst  (((orderedPair A B) = (orderedPair C D)) → (A = C)) ( </jh> The first step is, from our builder for.

But  is true unconditionally, so this formula reduces to.  C D OrderedPairTheoremForwardFirst-1 (orderedPair A B) (orderedPair C D) (singleton C) MembershipBuilderLL detachImplicationBiconditionalRight </jh> We now apply our other lemma to turn  into.  (singleton C) A B OrderedPairTheoremForwardFirst-2 eliminateBiconditionalReverse applySyllogism </jh> We'll show that each half of  implies. The left half follows from  once we detach the theorem.  A SingletonMembership (singleton C) (singleton A) A MembershipBuilderLL detachImplicationBiconditionalRight </jh> The right half is similar: the builder gives us  and we can detach.  A B UnorderedPairLeftMembership (singleton C) (unorderedPair A B) A MembershipBuilderLL detachImplicationBiconditionalRight </jh> We now compose the two and combine with our earlier result to get  composeDisjunction applySyllogism </jh> Transforming  to   finishes the proof.  A C Singleton eliminateBiconditionalReverse applySyllogism )) </jh>

Second half of the ordered pair theorem
In this section we prove.

Our first lemma is.  thm (OrderedPairTheoremForwardSecond-1  (((orderedPair C D) = (orderedPair C B)) → (D = B)) ( </jh> The definition of ordered pair gives us  and two applications of   give us.  (singleton C) (unorderedPair C D) (unorderedPair C B) UnorderedPairSecondMembersEqual C D B UnorderedPairSecondMembersEqual applySyllogism )) </jh>

The next lemma is most of the work. It is.  thm (OrderedPairTheoremForwardSecond-2  (((orderedPair A B) = (orderedPair C D)) → ((A = C) → (D = B))) ( </jh> We start with.  (orderedPair A B) (orderedPair C D) (orderedPair C B) EqualityBuilderRR </jh> The ordered pair builder and a bit of rearrangment turns that into.  ((orderedPair A B) = (orderedPair C B)) ((orderedPair C D) = (orderedPair C B)) BiconditionalReverseElimination applySyllogism

A C B OrderedPairBuilderRR ((orderedPair C D) = (orderedPair C B)) addCommonConsequent applySyllogism </jh> Applying the lemma  turns this into , our desired result.  C D B OrderedPairTheoremForwardSecond-1 (A = C) addCommonAntecedent applySyllogism )) </jh>

We now combine  and   to get.  thm (OrderedPairTheoremForwardSecond  (((orderedPair A B) = (orderedPair C D)) → (B = D)) ( A B C D OrderedPairTheoremForwardFirst A B C D OrderedPairTheoremForwardSecond-2 applyModusPonensInConsequent

D B EqualitySymmetry eliminateBiconditionalReverse applySyllogism )) </jh>

Ordered pair theorem
We are now ready to combine these results to prove the ordered pair theorem. We prove the forward implication,  thm (OrderedPairTheoremForward  (((orderedPair A0 B0) = (orderedPair A1 B1)) → ((A0 = A1) ∧ (B0 = B1))) ( A0 B0 A1 B1 OrderedPairTheoremForwardFirst A0 B0 A1 B1 OrderedPairTheoremForwardSecond composeConjunction )) </jh>

and the biconditionalized theorem.  thm (OrderedPairTheorem  (((orderedPair A0 B0) = (orderedPair A1 B1)) ↔ ((A0 = A1) ∧ (B0 = B1))) ( A0 B0 A1 B1 OrderedPairTheoremForward A0 A1 B0 B1 OrderedPairBuilder introduceBiconditionalFromImplications )) </jh>

Relations
A relation is a set of ordered pairs. We typically use the letters R, S, T, and U for relations. <jh> def ((relation A) (∀ z (((value z) ∈ A) → (∃ x (∃ y ((value z) = (orderedPair (value x) (value y)))))))) var (object R S T U) </jh>

Here we prove a theorem form of the definition. The distinct variable constraints are needed for soundness (analogous to the distinct variable constraints in, for example, metamath's dfss2 ). <jh> thm (Relation ((x y z A) (x′ y′ z′ x y z A))  ((relation A) ↔ (∀ z (((value z) ∈ A) → (∃ x (∃ y ((value z) = (orderedPair (value x) (value y)))))))) ( </jh> To prove this we need to prove that the truth of the formula doesn't depend on the choice of variables for,  , and. In other words,

We'll first worry about the explicit substitutions and getting them in the right place relative to the quantifiers. We work from the outside in, so the first step is <jh> z (((value z) ∈ A) → (∃ x (∃ y ((value z) = (orderedPair (value x) (value y)))))) z′ ChangeVariableExplicitForAll </jh> We now move the substitution inside all quantifiers. <jh> (value z′) z ((value z) ∈ A) (∃ x (∃ y ((value z) = (orderedPair (value x) (value y))))) SubstImplication z′ buildForAll applyBiconditionalTransitivity

(value z′) z x (∃ y ((value z) = (orderedPair (value x) (value y)))) SubstThereExists (subst (value z′) z ((value z) ∈ A)) buildImplicationAntecedent z′ buildForAll applyBiconditionalTransitivity

(value z′) z y ((value z) = (orderedPair (value x) (value y))) SubstThereExists x buildThereExists (subst (value z′) z ((value z) ∈ A)) buildImplicationAntecedent z′ buildForAll applyBiconditionalTransitivity </jh> That gives us. The next step is to add the substitution for. <jh> x (∃ y (subst (value z′) z ((value z) = (orderedPair (value x) (value y))))) x′ ChangeVariableExplicitThereExists (subst (value z′) z ((value z) ∈ A)) buildImplicationAntecedent z′ buildForAll applyBiconditionalTransitivity

(value x′) x y (subst (value z′) z ((value z) = (orderedPair (value x) (value y)))) SubstThereExists x′ buildThereExists (subst (value z′) z ((value z) ∈ A)) buildImplicationAntecedent z′ buildForAll applyBiconditionalTransitivity </jh> That gives us. The next step is to add the substitution for. <jh> y (subst (value x′) x (subst (value z′) z ((value z) = (orderedPair (value x) (value y))))) y′ ChangeVariableExplicitThereExists x′ buildThereExists (subst (value z′) z ((value z) ∈ A)) buildImplicationAntecedent z′ buildForAll applyBiconditionalTransitivity </jh> Now we perform the substitutions. The first one is. <jh> (value z) (value z′) A MembershipBuilderRR makeSubstExplicit </jh> The next is. <jh> (value z) (value z′) (orderedPair (value x) (value y)) EqualityBuilderRR makeSubstExplicit

(value x′) x buildSubst </jh> The next is. <jh> (value x) (value x′) (value y) OrderedPairBuilderRR (value z′) buildEqualityLLInConsequent makeSubstExplicit applyBiconditionalTransitivity

(value y′) y buildSubst </jh> The next is. <jh> (value y) (value y′) (value x′) OrderedPairBuilderLL (value z′) buildEqualityLLInConsequent makeSubstExplicit applyBiconditionalTransitivity </jh> We combine with the  substitution. <jh> y′ buildThereExists x′ buildThereExists

buildImplication z′ buildForAll applyBiconditionalTransitivity </jh> We have proved. JHilbert will unify the one with the primes with, if we just put it on the left hand side. <jh> swapBiconditional )) </jh>

A relation for two objects holds if and only if the corresponding ordered pair is an element of the relation. A more conventional notation would just write this as  rather than , but JHilbert does not offer that option. <jh> def ((relates A R B) ((orderedPair A B) ∈ R)) </jh>

The domain of a relation
A relation is a set of ordered pairs, and the domain of a relation is a set consisting of all of the first elements of those ordered pairs.

Our notation is  (a slight variation of the common notation  ). To show that the domain of a relation exists, we will show that the domain is contained in. That is, we define  as  and then show that this definition works as expected, that is that. One detail: the definition, and the theorems that follow, do not insist that  is a relation. But we will refer to it as a relation simply because the definition and the theorems aren't particularly interesting if it is not. <jh> def ((domain R) (separate x (⋃ (⋃ R)) (∃ y ((orderedPair (value x) (value y)) ∈ R)))) </jh>

As usual, we may sometimes need to fold or unfold the definition while specifying the dummy variables in the definition. Unlike some such cases, we do not export this definition, but just use it in this file. That is because our definition of domain is specific to our definition of ordered pair, and isn't really needed once we prove  below. <jh> thm (Domain-def ((x R) (y R) (x y)  (x′ y′) (x y′) (x′ R) (y′ R) (x′ x) (y′ y))   ((domain R) = (separate x (⋃ (⋃ R)) (∃ y ((orderedPair (value x) (value y)) ∈ R)))) ( </jh> We start by changing  to , that is. <jh> (value x′) (value x) (value y′) OrderedPairBuilderRR R buildMembershipRRInConsequent y′ buildThereExistsInConsequent (⋃ (⋃ R)) ChangeVariableSeparation </jh> Then we show , <jh> (value y′) (value y) (value x) OrderedPairBuilderLL R buildMembershipRRInConsequent ChangeVariableThereExists </jh> and combine the two parts. <jh> x (⋃ (⋃ R)) buildSeparation applyEqualityTransitivity )) </jh>

The first lemma is. This is the part where we make use of our definition of the ordered pair. <jh> thm (Domain-1 ( (z A) (z B) (z R))  (((orderedPair A B) ∈ R) → ((unorderedPair A B) ∈ (⋃ R))) ( </jh> We will prove  by. That is, we need. We prove this by presenting such a, which is just   (matters will be clearer if we write it with the definition of ordered pair expanded:.

The first step is. <jh> ((unorderedPair (singleton A) (unorderedPair A B)) ∈ R) ImplicationReflexivity (unorderedPair A B) (singleton A) UnorderedPairRightMembership introduceLeftConjunctToConsequent </jh> Now we need to replace  with a variable. <jh> (value z)         (unorderedPair (singleton A) (unorderedPair A B)) (unorderedPair A B)         MembershipBuilderLL

(value z)         (unorderedPair (singleton A) (unorderedPair A B)) R         MembershipBuilderRR

buildConjunctionInConsequent

makeSubstExplicit eliminateBiconditionalForward applySyllogism </jh> Turning the substitution into ∃ gives us, and applying   we are done. <jh> (unorderedPair (singleton A) (unorderedPair A B)) z         (((unorderedPair A B) ∈ (value z)) ∧ ((value z) ∈ R)) ThereExistsIntroductionFromObject applySyllogism

(unorderedPair A B) R z Union eliminateBiconditionalForward applySyllogism )) </jh>

Our second lemma is, which goes most of the way towards showing that our definition of domain does what we expect it to. <jh> thm (Domain-2 ((y A) (y R))  ((∃ y ((orderedPair A (value y)) ∈ R)) → (A ∈ (⋃ (⋃ R)))) ( </jh> First we put  on the proof stack for later use. <jh> A (value y) UnorderedPairLeftMembership </jh> Leaving that aside for the moment, we start with the previous lemma, which is, and turn the consequent into. <jh> A (value y) R Domain-1

(unorderedPair A (value y)) (⋃ R) MembershipSubsetUnion applySyllogism </jh> Now we turn  into  , <jh> (unorderedPair A (value y)) (⋃ (⋃ R)) A SubsetMembership applySyllogism </jh> and then detach. That gives us  so adding   to the antecedent we are done. <jh> detachImplicationImplication y addThereExistsToAntecedent )) </jh>

We're now ready to prove the main result,. The proof follows fairly directly from the previous lemma, via  and a substitution. <jh> thm (Domain ((y B) (y R) (x y) (x B) (x R))   ((B ∈ (domain R)) ↔ (∃ y ((orderedPair B (value y)) ∈ R))) ( </jh> We expand  so that we can specify the variables involved. <jh> R x y Domain-def B buildMembershipLL </jh> We first apply  to get. <jh> y (value x) R Domain-2 B FormulaBound applyBiconditionalTransitivity </jh> The left side of that is just ; the right side is a subsitution away from being what we need. <jh> (value x) B (value y) OrderedPairBuilderRR R buildMembershipRRInConsequent y buildThereExistsInConsequent makeSubstExplicit applyBiconditionalTransitivity )) </jh>

Cartesian product
The Cartesian product of two sets is the set of all ordered pairs consisting of one set from the first given set and one set from the second given set.

To show that it exists, we need to define it terms of a larger set which contains it. The larger set is  (this choice depends on our definition of ordered pair). Based on this concept, we define  to be. <jh> def ((× A B) (separate z (power (power (A ∪ B))) (∃ a (∃ b (((value z) = (orderedPair (value a) (value b))) ∧   (((value a) ∈ A) ∧ ((value b) ∈ B))))))) </jh>

Changing quantifiers
We first add the ability to specify the variables of quantification, as we do with most such definitions. Currently we do this for  and  ; we could also do it for   if need be. <jh> thm (CartesianProduct ((b′ z) (b′ a) (b′ b) (b′ A) (b′ B)    (b z) (b a) (b A) (b B)    (a′ z) (a′ b′) (a′ A) (a′ B)    (a z) (a A) (a B)    (a a′) (b b′) (z A) (z B) )   ((separate z (power (power (A ∪ B)))      (∃ a′ (∃ b′ (((value z) = (orderedPair (value a′) (value b′))) ∧ (((value a′) ∈ A) ∧ ((value b′) ∈ B)))))) = (separate z (power (power (A ∪ B)))     (∃ a (∃ b (((value z) = (orderedPair (value a) (value b))) ∧ (((value a) ∈ A) ∧ ((value b) ∈ B))))))) ( </jh> First we show. <jh> (value a′) (value a) (value b′) OrderedPairBuilderRR (value z) buildEqualityLLInConsequent

(value a′) (value a) A MembershipBuilderRR ((value b′) ∈ B) buildConjunctionRRInConsequent

buildConjunctionInConsequent b′ buildThereExistsInConsequent

ChangeVariableThereExists </jh> The change of the inner quantifier starts with, which then leads to  <jh> (value b′) (value b) (value a) OrderedPairBuilderLL (value z) buildEqualityLLInConsequent

(value b′) (value b) B MembershipBuilderRR ((value a) ∈ A) buildConjunctionLLInConsequent

buildConjunctionInConsequent

ChangeVariableThereExists </jh> Combining the two variable changes gives us everything except the separation, which we then add. <jh> a buildThereExists applyBiconditionalTransitivity

z (power (power (A ∪ B))) buildSeparation )) </jh>

Membership in a Cartesian product
To go from the definition to various theorems which restate what a Cartesian product is, our first lemma is. <jh> thm (MembershipCartesianProductLemma   (((α ∈ A) ∧ (β ∈ B)) → ((orderedPair α β) ∈ (power (power (A ∪ B))))) ( </jh> The ordered pair  has two elements,   and. We start with the former, and the first step is <jh> (α ∈ A) (β ∈ B) ConjunctionRightElimination

α A SingletonSubset eliminateBiconditionalReverse applySyllogism </jh> The consequent in turn implies , <jh> (singleton α) A B SubsetUnionRightIntroduction applySyllogism </jh> which then becomes. <jh> (singleton α) (A ∪ B) PowerSet eliminateBiconditionalForward applySyllogism </jh> Turning our attention to, we start with. <jh> α A B MembershipUnionRightIntroduction β B A MembershipUnionLeftIntroduction conjoin </jh> The consequent implies , <jh> α (A ∪ B) β UnorderedPairSubset eliminateBiconditionalReverse applySyllogism </jh> which in turn implies. <jh> (unorderedPair α β) (A ∪ B) PowerSet eliminateBiconditionalForward applySyllogism </jh> Combining  and   gives. <jh> composeConjunction (singleton α) (power (A ∪ B)) (unorderedPair α β) UnorderedPairSubset eliminateBiconditionalReverse applySyllogism </jh> That in turn is just, which is what we are seeking to prove. <jh> (orderedPair α β) (power (A ∪ B)) PowerSet eliminateBiconditionalForward applySyllogism )) </jh>

The next lemma combines the previous one with a substitution and adds some quantifiers: <jh> thm (MembershipCartesianProduct-2 ((a Z) (b Z) (a A) (b A) (a B) (b B))  ((∃ a (∃ b ((Z = (orderedPair (value a) (value b))) ∧ (((value a) ∈ A) ∧ ((value b) ∈ B))))) → (Z ∈ (power (power (A ∪ B))))) ( </jh> We start with  (which was the previous lemma), and then conjoin   to both antecedent and consequent. <jh> (value a) A (value b) B MembershipCartesianProductLemma (Z = (orderedPair (value a) (value b))) conjoinLL </jh> Next we take the substitution  and rearrange it into <jh> Z         (orderedPair (value a) (value b)) (power (power (A ∪ B))) MembershipBuilderRR eliminateBiconditionalForwardInConsequent import </jh> That's almost it. Combining those implications gives, and then we just add the quantifiers. <jh> applySyllogism

b addThereExistsToAntecedent a addThereExistsToAntecedent )) </jh>

It just takes some logic to turn that into, which we can take as a basic equivalence which "defines" the meaning of a Cartesian product. <jh> thm (MembershipCartesianProduct ((a b A) (a b B) (a b C)    (C z a′ b′) (a b z a′ b′) (A z a′ b′) (B z a′ b′))   ((C ∈ (A × B)) ↔ (∃ a (∃ b ((C = (orderedPair (value a) (value b)))     ∧ (((value a) ∈ A) ∧ ((value b) ∈ B)))))) ( </jh> We start by expanding the definition of. <jh> z A B a′ b′ a b CartesianProduct C buildMembershipLL </jh> We now proceed to. <jh> a b (value z) A B MembershipCartesianProduct-2 C FormulaBound applyBiconditionalTransitivity </jh> We now have. We now just perform the substitution, starting with <jh> (value z) C (orderedPair (value a) (value b)) EqualityBuilderRR (((value a) ∈ A) ∧ ((value b) ∈ B)) buildConjunctionRRInConsequent b buildThereExistsInConsequent a buildThereExistsInConsequent makeSubstExplicit

applyBiconditionalTransitivity )) </jh>

An ordered pair which is a member of a Cartesian product
Here we show that. <jh> thm (OrderedPairCartesianProduct ( (a b A) (a b B) (a b A0) (a b B0))  (((orderedPair A0 B0) ∈ (A × B)) ↔ ((A0 ∈ A) ∧ (B0 ∈ B))) ( </jh> The first step is invoking  with the ordered pair as the element. That is, <jh> (orderedPair A0 B0) A B a b MembershipCartesianProduct </jh> Applying the ordered pair theorem and rearranging the conjunctions turns this into. <jh> A0 B0 (value a) (value b) OrderedPairTheorem (((value a) ∈ A) ∧ ((value b) ∈ B)) buildConjunctionRR b buildThereExists a buildThereExists applyBiconditionalTransitivity

(A0 = (value a)) (B0 = (value b)) ((value a) ∈ A) ((value b) ∈ B) Conjunction4 b buildThereExists a buildThereExists applyBiconditionalTransitivity </jh> We now scatter the quantifiers to give. <jh> a         b          ((A0 = (value a)) ∧ ((value a) ∈ A)) ((B0 = (value b)) ∧ ((value b) ∈ B)) ThereExistsScattering applyBiconditionalTransitivity </jh> Each half of that is equivalent to a membership formula (that is,  and likewise for the other half). <jh> A0 (value a) EqualitySymmetry ((value a) ∈ A) buildConjunctionRR a buildThereExist

A0 A a MembershipThereExists swapBiconditional applyBiconditionalTransitivity

B0 (value b) EqualitySymmetry ((value b) ∈ B) buildConjunctionRR b buildThereExists

B0 B b MembershipThereExists swapBiconditional applyBiconditionalTransitivity

buildConjunction applyBiconditionalTransitivity )) </jh>

To be added
Either here or in other set theory files: induction, recursion, ordinal successors. some kinds of unions, intersection, set difference, and so on.

Export
We export to Interface:Set theory. <jh> export (SETS Interface:Set_theory (CLASSICAL FIRSTORDER) ) </jh>