openAI-math-dataset / lean /OAI /SetTheory /PartitionPrinciple /Forcing /GroundBinaryRowNameCodes.lean
roseking's picture
Sync from openai/math@faee2cf485a8 (part 25)
3277efa verified
Raw History Blame Contribute Delete
16.7 kB
import OAI.SetTheory.PartitionPrinciple.Definability.GroundBinaryRowSets
namespace OAI
section
namespace PartitionPilot.Forcing.SetFormula
def binaryRowEntryFormula {n} (z c q i one bit : Fin n) : SetFormula n :=
ex (ex (ex (.conj (.mem 2 c.succ.succ.succ)
(.conj (.mem 1 q.succ.succ.succ)
(.conj (binaryApplication uniformCheckFormula (extend one.succ.succ.succ Fin.elim0) 2 0)
(.conj (BoundedFormula.tripleMembershipFormula i.succ.succ.succ 2 bit.succ.succ.succ 1).toFormula
(orderedPairFormula z.succ.succ.succ 0 1)))))))
def binaryRowCodeFormula : SetFormula 6 :=
let entry := reindex (extend 0 (extend 3 (extend 4 (extend 1
(extend 5 (extend 6 Fin.elim0)))))) (binaryRowEntryFormula 0 1 2 3 4 5)
.all (.conj (imp (.mem 0 2) entry) (imp entry (.mem 0 2)))
def binaryRowSetEntryFormula : SetFormula 6 :=
ex (ex (.conj (.mem 1 3)
(.conj (binaryApplication binaryRowCodeFormula
(extend 4 (extend 5 (extend 6 (extend 7 Fin.elim0)))) 1 0)
(orderedPairFormula 2 0 6))))
end PartitionPilot.Forcing.SetFormula
namespace PartitionPilot.Forcing.TransitiveGround
open SetRealization SetFormula
universe u
variable (M : TransitiveGround.{u})
theorem realize_binaryRowEntryFormula (I C : ZFSet.{u})
(one : SetMembers (M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega))
(i : ZFSet.{u})
(pairing : Realize M.sets SetFormula.pairing Fin.elim0)
(unions : Realize M.sets SetFormula.union Fin.elim0)
(powers : Realize M.sets powerSet Fin.elim0)
(separation : SeparationSchema M.sets) (collection : CollectionSchema M.sets)
(hC : C ∈ M.sets)
(hQ : M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega ∈ M.sets)
(hi : i ∈ M.sets) (hbit : (natSetCode 1 : ZFSet.{u}) ∈ M.sets)
(z : ZFSet.{u}) (hz : z ∈ M.sets) :
Realize M.sets (binaryRowEntryFormula 0 1 2 3 4 5)
(extend z (extend C (extend
(M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega)
(extend i (extend (SetMembers.raw one) (extend (natSetCode 1) Fin.elim0)))))) ↔
z ∈ (M.binaryRowName I C one i).val := by
let Q := M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega
let s := SetMembers.presentation Q
have hone : s.encode one ∈ M.sets := M.transitive hQ (SetMembers.raw_mem one)
have children (c : ZFSet.{u}) (hc : c ∈ C) : (Name.check s one c).val ∈ M.sets :=
M.check_mem s one pairing unions powers separation collection hone c (M.transitive hC hc)
have assignment (c p w : ZFSet.{u}) (hc : c ∈ M.sets) (hp : p ∈ M.sets) (hw : w ∈ M.sets) :
Realize M.sets (BoundedFormula.tripleMembershipFormula 6 2 8 1).toFormula
(extend w (extend p (extend c (extend z (extend C (extend Q
(extend i (extend (SetMembers.raw one) (extend (natSetCode 1) Fin.elim0))))))))) ↔
ZFSet.pair (ZFSet.pair i c) (natSetCode 1) ∈ p :=
(BoundedFormula.realize_toFormula M _ _
(Fin.cases hw (Fin.cases hp (Fin.cases hc (Fin.cases hz (Fin.cases hC
(Fin.cases hQ (Fin.cases hi (Fin.cases hone (Fin.cases hbit (fun j => Fin.elim0 j))))))))))).trans
(BoundedFormula.truth_tripleMembershipFormula 6 2 8 1 _)
rw [binaryRowEntryFormula, realize_ex]
constructor
· rintro ⟨c, hcM, rest⟩
obtain ⟨p, hpM, rest⟩ := (realize_ex M.sets _ _).1 rest
obtain ⟨w, hwM, hc, hp, checked, assigned, shape⟩ := (realize_ex M.sets _ _).1 rest
rw [realize_binaryApplication, map_extend, map_empty] at checked
have eq := (M.realize_uniformCheckFormula s one pairing unions powers separation collection
hone c w hcM hwM).1 checked
have pair := (M.realize_orderedPairFormula pairing 3 0 1 _ hz hwM hpM).1 shape
apply (M.mem_binaryRowName_code I C one i z).2
exact ⟨c, hc, p, hp,
pair.trans (congrArg (fun v => ZFSet.pair v p) eq), (assignment c p w hcM hpM hwM).1 assigned⟩
· intro member
obtain ⟨c, hc, p, hp, shape, assigned⟩ := (M.mem_binaryRowName_code I C one i z).1 member
have hcM := M.transitive hC hc
have hpM := M.transitive hQ hp
refine ⟨c, hcM, ?_⟩
rw [realize_ex]
refine ⟨p, hpM, ?_⟩
rw [realize_ex]
refine ⟨(Name.check s one c).val, children c hc, hc, hp, ?_, ?_, ?_⟩
· rw [realize_binaryApplication, map_extend, map_empty]
exact (M.realize_uniformCheckFormula s one pairing unions powers separation collection
hone c _ hcM (children c hc)).2 rfl
· exact (assignment c p _ hcM hpM (children c hc)).2 assigned
· exact (M.realize_orderedPairFormula pairing 3 0 1 _ hz (children c hc) hpM).2 shape
theorem binaryRowName_mem
(pairing : Realize M.sets SetFormula.pairing Fin.elim0)
(unions : Realize M.sets SetFormula.union Fin.elim0)
(powers : Realize M.sets powerSet Fin.elim0)
(separation : SeparationSchema M.sets) (collection : CollectionSchema M.sets)
(infinite : Realize M.sets infinity Fin.elim0)
{I C : ZFSet.{u}} (hI : I ∈ M.sets) (hC : C ∈ M.sets)
(one : SetMembers (M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega))
(i : ZFSet.{u}) (hi : i ∈ M.sets) : (M.binaryRowName I C one i).val ∈ M.sets := by
let Q := M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega
let s := SetMembers.presentation Q
have hQ : Q ∈ M.sets := M.countablePartialFunctions_mem pairing unions powers separation infinite
(M.prod_mem pairing unions powers separation hI hC) (M.natSetCode_mem separation infinite 2)
have hone : s.encode one ∈ M.sets := M.transitive hQ (SetMembers.raw_mem one)
have hcheck := M.check_mem s one pairing unions powers separation collection hone C hC
have childBound (c : ZFSet.{u}) (hc : c ∈ C) :
(Name.check s one c).val ∈ ZFSet.sUnion (ZFSet.sUnion (Name.check s one C).val) :=
Name.child_mem_doubleUnion ((Name.entry_check one C (Name.check s one c) one).2 ⟨c, hc, rfl, rfl⟩)
obtain ⟨B, hB, pairBound⟩ := M.exists_pair_bound pairing unions powers
(M.union_mem unions (M.union_mem unions hcheck)) hQ
have bound : (M.binaryRowName I C one i).val ⊆ B := by
intro z hz
obtain ⟨c, hc, p, hp, eq, _⟩ := (M.mem_binaryRowName_code I C one i z).1 hz
exact eq.symm ▸ pairBound _ (childBound c hc) p hp
let params := extend C (extend Q (extend i (extend (SetMembers.raw one)
(extend (natSetCode 1) Fin.elim0))))
have hbit := M.natSetCode_mem separation infinite 1
have selected := M.separation_mem separation (binaryRowEntryFormula 0 1 2 3 4 5) params
(Fin.cases hC (Fin.cases hQ (Fin.cases hi (Fin.cases hone
(Fin.cases hbit (fun j => Fin.elim0 j)))))) hB
have eq : ZFSet.sep (fun z => Realize M.sets (binaryRowEntryFormula 0 1 2 3 4 5)
(extend z params)) B = (M.binaryRowName I C one i).val := by
apply ZFSet.ext
intro z
rw [ZFSet.mem_sep]
constructor
· rintro ⟨hz, rel⟩
exact (M.realize_binaryRowEntryFormula I C one i pairing unions powers separation collection
hC hQ hi hbit z (M.transitive hB hz)).1 rel
· intro hz
exact ⟨bound hz, (M.realize_binaryRowEntryFormula I C one i pairing unions powers separation collection
hC hQ hi hbit z (M.transitive hB (bound hz))).2 hz⟩
exact eq ▸ selected
theorem realize_binaryRowCodeFormula
(pairing : Realize M.sets SetFormula.pairing Fin.elim0)
(unions : Realize M.sets SetFormula.union Fin.elim0)
(powers : Realize M.sets powerSet Fin.elim0)
(separation : SeparationSchema M.sets) (collection : CollectionSchema M.sets)
(infinite : Realize M.sets infinity Fin.elim0)
{I C : ZFSet.{u}} (hI : I ∈ M.sets) (hC : C ∈ M.sets)
(one : SetMembers (M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega))
(i w : ZFSet.{u}) (hi : i ∈ M.sets) (hw : w ∈ M.sets) :
Realize M.sets binaryRowCodeFormula (extend i (extend w (extend C (extend
(M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega)
(extend (SetMembers.raw one) (extend (natSetCode 1) Fin.elim0)))))) ↔
w = (M.binaryRowName I C one i).val := by
have hQ := M.countablePartialFunctions_mem pairing unions powers separation infinite
(M.prod_mem pairing unions powers separation hI hC) (M.natSetCode_mem separation infinite 2)
have hname := M.binaryRowName_mem pairing unions powers separation collection infinite hI hC one i hi
have hbit := M.natSetCode_mem separation infinite 1
rw [binaryRowCodeFormula]
constructor
· intro spec
apply ZFSet.ext
intro z
constructor
· intro hz
have hzM := M.transitive hw hz
have rel := (realize_imp M.sets _ _ _).1 (spec z hzM).1 hz
rw [realize_reindex, map_extend, map_extend, map_extend, map_extend, map_extend,
map_extend, map_empty] at rel
exact (M.realize_binaryRowEntryFormula I C one i pairing unions powers separation collection
hC hQ hi hbit z hzM).1 rel
· intro hz
have hzM := M.transitive hname hz
apply (realize_imp M.sets _ _ _).1 (spec z hzM).2
rw [realize_reindex, map_extend, map_extend, map_extend, map_extend, map_extend,
map_extend, map_empty]
exact (M.realize_binaryRowEntryFormula I C one i pairing unions powers separation collection
hC hQ hi hbit z hzM).2 hz
· intro eq z hzM
constructor
· apply (realize_imp M.sets _ _ _).2
intro hz
rw [realize_reindex, map_extend, map_extend, map_extend, map_extend, map_extend,
map_extend, map_empty]
exact (M.realize_binaryRowEntryFormula I C one i pairing unions powers separation collection
hC hQ hi hbit z hzM).2 (eq ▸ hz)
· apply (realize_imp M.sets _ _ _).2
intro rel
rw [realize_reindex, map_extend, map_extend, map_extend, map_extend, map_extend,
map_extend, map_empty] at rel
exact eq.symm ▸ (M.realize_binaryRowEntryFormula I C one i pairing unions powers separation collection
hC hQ hi hbit z hzM).1 rel
theorem exists_binaryRowName_bound
(pairing : Realize M.sets SetFormula.pairing Fin.elim0)
(unions : Realize M.sets SetFormula.union Fin.elim0)
(powers : Realize M.sets powerSet Fin.elim0)
(separation : SeparationSchema M.sets) (collection : CollectionSchema M.sets)
(infinite : Realize M.sets infinity Fin.elim0)
{I C : ZFSet.{u}} (hI : I ∈ M.sets) (hC : C ∈ M.sets)
(one : SetMembers (M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega)) :
∃ W ∈ M.sets, ∀ i ∈ I, (M.binaryRowName I C one i).val ∈ W := by
let Q := M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega
have hQ : Q ∈ M.sets := M.countablePartialFunctions_mem pairing unions powers separation infinite
(M.prod_mem pairing unions powers separation hI hC) (M.natSetCode_mem separation infinite 2)
have hone := M.transitive hQ (SetMembers.raw_mem one)
let params := extend C (extend Q (extend (SetMembers.raw one) (extend (natSetCode 1) Fin.elim0)))
have members : ∀ j, params j ∈ M.sets := Fin.cases hC (Fin.cases hQ
(Fin.cases hone (Fin.cases (M.natSetCode_mem separation infinite 1) (fun j => Fin.elim0 j))))
have witnesses : ∀ i ∈ I, ∃ w ∈ M.sets,
Realize M.sets binaryRowCodeFormula (extend i (extend w params)) := by
intro i hi
have hiM := M.transitive hI hi
have hname := M.binaryRowName_mem pairing unions powers separation collection infinite hI hC one i hiM
exact ⟨(M.binaryRowName I C one i).val, hname,
(M.realize_binaryRowCodeFormula pairing unions powers separation collection infinite
hI hC one i _ hiM hname).2 rfl⟩
obtain ⟨W, hW, covers⟩ := M.collection_witness collection binaryRowCodeFormula params members hI witnesses
refine ⟨W, hW, ?_⟩
intro i hi
obtain ⟨w, hw, code⟩ := covers i hi
have eq := (M.realize_binaryRowCodeFormula pairing unions powers separation collection infinite
hI hC one i w (M.transitive hI hi) (M.transitive hW hw)).1 code
exact eq ▸ hw
theorem realize_binaryRowSetEntryFormula
(pairing : Realize M.sets SetFormula.pairing Fin.elim0)
(unions : Realize M.sets SetFormula.union Fin.elim0)
(powers : Realize M.sets powerSet Fin.elim0)
(separation : SeparationSchema M.sets) (collection : CollectionSchema M.sets)
(infinite : Realize M.sets infinity Fin.elim0)
{I C : ZFSet.{u}} (hI : I ∈ M.sets) (hC : C ∈ M.sets)
(one : SetMembers (M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega))
(z : ZFSet.{u}) (hz : z ∈ M.sets) :
Realize M.sets binaryRowSetEntryFormula (extend z (extend I (extend C (extend
(M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega)
(extend (SetMembers.raw one) (extend (natSetCode 1) Fin.elim0)))))) ↔
z ∈ (M.binaryRowSetName I C one).val := by
have hQ := M.countablePartialFunctions_mem pairing unions powers separation infinite
(M.prod_mem pairing unions powers separation hI hC) (M.natSetCode_mem separation infinite 2)
have hone := M.transitive hQ (SetMembers.raw_mem one)
rw [binaryRowSetEntryFormula, realize_ex]
constructor
· rintro ⟨i, hiM, rest⟩
obtain ⟨w, hwM, hi, code, shape⟩ := (realize_ex M.sets _ _).1 rest
rw [realize_binaryApplication, map_extend, map_extend, map_extend, map_extend, map_empty] at code
have eq := (M.realize_binaryRowCodeFormula pairing unions powers separation collection infinite
hI hC one i w hiM hwM).1 code
have pair := (M.realize_orderedPairFormula pairing 2 0 6 _ hz hwM hone).1 shape
exact (M.mem_binaryRowSetName_code I C one z).2
⟨i, hi, pair.trans (congrArg (fun v => ZFSet.pair v (SetMembers.raw one)) eq)⟩
· intro member
obtain ⟨i, hi, shape⟩ := (M.mem_binaryRowSetName_code I C one z).1 member
have hiM := M.transitive hI hi
have hname := M.binaryRowName_mem pairing unions powers separation collection infinite hI hC one i hiM
refine ⟨i, hiM, ?_⟩
rw [realize_ex]
refine ⟨(M.binaryRowName I C one i).val, hname, hi, ?_, ?_⟩
· rw [realize_binaryApplication, map_extend, map_extend, map_extend, map_extend, map_empty]
exact (M.realize_binaryRowCodeFormula pairing unions powers separation collection infinite
hI hC one i _ hiM hname).2 rfl
· exact (M.realize_orderedPairFormula pairing 2 0 6 _ hz hname hone).2 shape
theorem binaryRowSetName_mem
(pairing : Realize M.sets SetFormula.pairing Fin.elim0)
(unions : Realize M.sets SetFormula.union Fin.elim0)
(powers : Realize M.sets powerSet Fin.elim0)
(separation : SeparationSchema M.sets) (collection : CollectionSchema M.sets)
(infinite : Realize M.sets infinity Fin.elim0)
{I C : ZFSet.{u}} (hI : I ∈ M.sets) (hC : C ∈ M.sets)
(one : SetMembers (M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega)) :
(M.binaryRowSetName I C one).val ∈ M.sets := by
have hQ := M.countablePartialFunctions_mem pairing unions powers separation infinite
(M.prod_mem pairing unions powers separation hI hC) (M.natSetCode_mem separation infinite 2)
have hone := M.transitive hQ (SetMembers.raw_mem one)
obtain ⟨W, hW, inW⟩ := M.exists_binaryRowName_bound pairing unions powers separation collection infinite
hI hC one
obtain ⟨B, hB, pairBound⟩ := M.exists_pair_bound pairing unions powers hW
(M.unorderedPair_mem pairing hone hone)
have bound : (M.binaryRowSetName I C one).val ⊆ B := by
intro z hz
obtain ⟨i, hi, eq⟩ := (M.mem_binaryRowSetName_code I C one z).1 hz
exact eq.symm ▸ pairBound _ (inW i hi) _ (ZFSet.mem_pair.2 (Or.inl rfl))
let params := extend I (extend C (extend
(M.smallPartialFunctions (ZFSet.prod I C) (natSetCode 2) ZFSet.omega)
(extend (SetMembers.raw one) (extend (natSetCode 1) Fin.elim0))))
have selected := M.separation_mem separation binaryRowSetEntryFormula params
(Fin.cases hI (Fin.cases hC (Fin.cases hQ (Fin.cases hone
(Fin.cases (M.natSetCode_mem separation infinite 1) (fun j => Fin.elim0 j)))))) hB
have eq : ZFSet.sep (fun z => Realize M.sets binaryRowSetEntryFormula
(extend z params)) B = (M.binaryRowSetName I C one).val := by
apply ZFSet.ext
intro z
rw [ZFSet.mem_sep]
constructor
· rintro ⟨hz, rel⟩
exact (M.realize_binaryRowSetEntryFormula pairing unions powers separation collection infinite
hI hC one z (M.transitive hB hz)).1 rel
· intro hz
exact ⟨bound hz, (M.realize_binaryRowSetEntryFormula pairing unions powers separation collection infinite
hI hC one z (M.transitive hB (bound hz))).2 hz⟩
exact eq ▸ selected
end PartitionPilot.Forcing.TransitiveGround
end
end OAI