diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPersistenceDegreeModel.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPersistenceDegreeModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..77ee010761aa01bd6a21ee36e2d6fb31b80c5097 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPersistenceDegreeModel.lean @@ -0,0 +1,72 @@ +import OAI.Computability.DegreeRigidity.Constructibility.PersistenceExtensionAbsoluteness +import OAI.Computability.DegreeRigidity.Representation.SourceTModelBridge + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel EncodedForcing PersistentRestrictions PersistentPresentation OracleJump +open ArithmeticTree ArithmeticPersistence +universe u + +theorem sourceT_arithmetic_persistent_graph (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (S : ZFSet.{u}) (hSM : S ∈ M) + (hS : ∀ A : Oracle, realCode A ∈ S ↔ A ∈ modelReals M) + (hSd : ∀ x ∈ S, ∃ A : Oracle, realCode A = x) + (A R : Oracle) (hA : A ∈ modelReals M) (hR : R ∈ modelReals M) + (hp : ∀ H ∈ modelReals M, Base A R ∧ Matrix (parameters A R H) 0) : + ∃ I : CountableIdeal, ∃ hAI : Presented I A, ∃ ρ : I ≃o I, + (∀ v, R v = true ↔ Graph ρ hAI v) ∧ Persistent I ρ ∧ + presentationGraph S A R ∈ M ∧ + (LevySigma.persistent 0 1 2 3 4).Realize M + (modelDegreeEnv S (presentationSet S A) (presentationGraph S A R)) := by + obtain ⟨I,hAI,hz,ρ,hgraph,hpers⟩ := (sourceT_persistence_presentation M hM hT A R hA hR).mp hp + have hc : ∀ n, realCode (columns A n) ∈ S := + fun n => (hS _).mpr (sourceT_real_column M hM hT hA n) + have hbridge := sourceT_arbitrary_persistent_graph M hM hT S hSM hS hSd hAI hA ρ hpers hz + (presentationGraph S A R) (fun _ h => (ZFSet.mem_sep.mp h).1) + (presentationGraph_actual S hAI hc ρ hgraph) + exact ⟨I,hAI,ρ,hgraph,hpers,hbridge⟩ + +theorem sourceT_presentation_transfer (M N : ZFSet.{u}) + (hM : Transitive M) (hN : Transitive N) (hTM : SourceT M) (hTN : SourceT N) + (A R : Oracle) (hAM : A ∈ modelReals M) (hRM : R ∈ modelReals M) + (hAN : A ∈ modelReals N) (hRN : R ∈ modelReals N) + (hp : ∀ H ∈ modelReals M, Base A R ∧ Matrix (parameters A R H) 0) : + ∃ S ∈ N, degreeUniverse S ∈ N ∧ degreeOrder S ∈ N ∧ + presentationGraph S A R ∈ N ∧ + (LevySigma.persistent 0 1 2 3 4).Realize N + (modelDegreeEnv S (presentationSet S A) (presentationGraph S A R)) := by + have hpN := (persistence_between_models M N hM hN hTM hTN A R hAM hRM hAN hRN).mp hp + obtain ⟨S,hSN,hS,hSd⟩ := internal_real_power N hN hTN + have hd : ∀ x ∈ S, ∃ B : Oracle, realCode B = x := by + intro x hx; obtain ⟨B,_,hB⟩ := hSd x hx; exact ⟨B,hB⟩ + obtain ⟨_,_,_,_,_,hgraph,hpers⟩ := sourceT_arithmetic_persistent_graph N hN hTN S hSN hS hd A R hAN hRN hpN + exact ⟨S,hSN,internal_degreeUniverse N hN hTN S hSN hd, + internal_degreeOrder N hN hTN S hSN hd,hgraph,hpers⟩ + +theorem generic_extension_persistent_degree_model (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : CountableForcing.GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) + (htop : ⊤ ∈ G.carrier) (A R : Oracle) (hA : A ∈ modelReals M) (hR : R ∈ modelReals M) + (hp : ∀ H ∈ modelReals M, Base A R ∧ Matrix (parameters A R H) 0) : + let E := genericExtensionSet M c G.carrier + ∃ S ∈ E, degreeUniverse S ∈ E ∧ degreeOrder S ∈ E ∧ + presentationGraph S A R ∈ E ∧ + (LevySigma.persistent 0 1 2 3 4).Realize E + (modelDegreeEnv S (presentationSet S A) (presentationGraph S A R)) := by + have hi := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier htop + have hAE : A ∈ modelReals (genericExtensionSet M c G.carrier) := by + change realCode A ∈ genericExtensionSet M c G.carrier + exact hi hA + have hRE : R ∈ modelReals (genericExtensionSet M c G.carrier) := by + change realCode R ∈ genericExtensionSet M c G.carrier + exact hi hR + exact sourceT_presentation_transfer M _ hM (genericExtensionSet_transitive M c hM G.carrier) + hT (extension_sourceT M hM hT hc hoM ho G hG htop) A R hA hR hAE hRE hp + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPrefixFamilies.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPrefixFamilies.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a7fafae516340acde926299ae7681e9e5bd9205 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPrefixFamilies.lean @@ -0,0 +1,49 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticGenericTruth + +namespace OAI + + +namespace TuringRigidity.ArithmeticPrefixFamilies +open UniformArithmetic ArithmeticPrefixForcing ShuffleRequirements FiniteShuffle + +theorem prefix_comp {Q : PrefixPredicate} (hQ : ArithmeticPrefix Q) + {f : ℕ → ℕ} (hf : Primrec f) : ArithmeticPrefix (fun O v => Q O (f v)) := + (hQ.comp _ (Primrec₂.natPair.comp (hf.comp left_primrec) right_primrec)).congr + (fun _ _ => by simp only [left,right,Nat.unpair_pair]) + +theorem prefix_exists {Q : PrefixPredicate} (hQ : ArithmeticPrefix Q) : + ArithmeticPrefix (fun O v s => ∃ n, Q O (Nat.pair v n) s) := + ((hQ.comp _ (Primrec₂.natPair.comp + (Primrec₂.natPair.comp (left_primrec.comp left_primrec) right_primrec) + (right_primrec.comp left_primrec))).ex).congr + (fun _ _ => by simp only [left,right,Nat.unpair_pair]) + +theorem dense_and {D E : List Bool → Prop} (hD : DenseOpen D) (hE : DenseOpen E) : + DenseOpen (fun s => D s ∧ E s) := by + constructor + · intro s + obtain ⟨t,hst,ht⟩ := hD.1 s + obtain ⟨u,htu,hu⟩ := hE.1 t + exact ⟨u,hst.trans htu,hD.2 t u htu ht,hu⟩ + · intro s t hst hs + exact ⟨hD.2 s t hst hs.1,hE.2 s t hst hs.2⟩ + +theorem dense_true : DenseOpen (fun _ : List Bool => True) := + ⟨fun s => ⟨s,List.prefix_rfl,True.intro⟩,fun _ _ _ _ => True.intro⟩ + +theorem avoid_truth_of_decides (Q : List Bool → Prop) (hQ : Upward Q) (G : Oracle) + (hG : G ∈ OpenSet (Decides Q)) : + G ∈ OpenSet (Avoid Q) ↔ ¬ G ∈ OpenSet Q := by + constructor + · rintro ⟨s,hs,hGs⟩ ⟨t,ht,hGt⟩ + obtain ⟨u,hsu,htu,_⟩ := realizes_common hGs hGt + exact hs u hsu (hQ t u htu ht) + · intro hn + obtain ⟨s,hs,hGs⟩ := hG + rcases hs with hs | hs + · exact False.elim (hn ⟨s,hs,hGs⟩) + · exact ⟨s,hs,hGs⟩ + +end TuringRigidity.ArithmeticPrefixFamilies + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPrefixForcing.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPrefixForcing.lean new file mode 100644 index 0000000000000000000000000000000000000000..d408b644256e9a339d079ebe3c0e81678f21a3c8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPrefixForcing.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticCommonRequirement +import OAI.Computability.DegreeRigidity.SetModels.ShuffleRequirements + +namespace OAI + + +namespace TuringRigidity.ArithmeticPrefixForcing +open Encodable UniformArithmetic FiniteShuffle ShuffleRequirements +open EncodedForcing (word word_primrec) + +abbrev PrefixPredicate := Oracles → ℕ → List Bool → Prop +abbrev ArithmeticPrefix (Q : PrefixPredicate) := + Arith (fun O v => Q O (left v) (word (right v))) + +def Upward (Q : List Bool → Prop) : Prop := + ∀ s t, s <+: t → Q s → Q t + +def Avoid (Q : List Bool → Prop) (s : List Bool) : Prop := + ∀ t, s <+: t → ¬ Q t + +def Decides (Q : List Bool → Prop) (s : List Bool) : Prop := Q s ∨ Avoid Q s + +def Generic (O : Oracles) (G : Oracle) : Prop := + ∀ D : Oracles → List Bool → Prop, + Arith (fun O n => D O (word n)) → DenseOpen (D O) → + ∃ s, D O s ∧ Realizes s G + +theorem avoids_upward (Q : List Bool → Prop) : Upward (Avoid Q) := + fun _ _ h hs u hu => hs u (h.trans hu) + +theorem decides_dense (Q : List Bool → Prop) (hQ : Upward Q) : + DenseOpen (Decides Q) := by + classical + constructor + · intro s + by_cases h : ∃ t, s <+: t ∧ Q t + · obtain ⟨t,ht,hq⟩ := h + exact ⟨t,ht,Or.inl hq⟩ + · exact ⟨s,List.prefix_rfl,Or.inr (fun t ht hq => h ⟨t,ht,hq⟩)⟩ + · intro s t h + exact Or.imp (hQ s t h) (avoids_upward Q s t h) + +theorem avoids_arith {Q : PrefixPredicate} (hQ : ArithmeticPrefix Q) : + ArithmeticPrefix (fun O v => Avoid (Q O v)) := by + have hp := ArithmeticCommonRequirement.prefix_arith + (right_primrec.comp left_primrec) right_primrec + have h := hQ.comp _ (Primrec₂.natPair.comp (left_primrec.comp left_primrec) right_primrec) + apply (hp.imp h.neg).all.congr + intro O v + simp only [left,right,Nat.unpair_pair] + constructor + · intro h t ht + have hh := h (encode t) + simpa only [word,Encodable.encodek,Option.getD_some] using hh (by + simpa only [word,Encodable.encodek,Option.getD_some] using ht) + · intro h t ht + exact h (word t) ht + +theorem decides_arith {Q : PrefixPredicate} (hQ : ArithmeticPrefix Q) : + ArithmeticPrefix (fun O v => Decides (Q O v)) := hQ.or (avoids_arith hQ) + +theorem realizes_common {s t : List Bool} {G : Oracle} + (hs : Realizes s G) (ht : Realizes t G) : + ∃ u, s <+: u ∧ t <+: u ∧ Realizes u G := by + refine ⟨initial G (max s.length t.length), ?_, ?_, + (realizes_initial _ _ _).mpr (fun _ _ => rfl)⟩ + · rw [←prefix_default s] + exact initial_prefix (by simp) hs + · rw [←prefix_default t] + exact initial_prefix (by simp) ht + +theorem open_and (Q R : List Bool → Prop) (hQ : Upward Q) (hR : Upward R) (G : Oracle) : + G ∈ OpenSet (fun s => Q s ∧ R s) ↔ G ∈ OpenSet Q ∧ G ∈ OpenSet R := by + constructor + · rintro ⟨s,⟨hq,hr⟩,hs⟩ + exact ⟨⟨s,hq,hs⟩,⟨s,hr,hs⟩⟩ + · rintro ⟨⟨s,hq,hs⟩,⟨t,hr,ht⟩⟩ + obtain ⟨u,hsu,htu,hu⟩ := realizes_common hs ht + exact ⟨u,⟨hQ s u hsu hq,hR t u htu hr⟩,hu⟩ + +theorem open_avoid {Q : PrefixPredicate} (hQ : ArithmeticPrefix Q) + (hup : ∀ O v, Upward (Q O v)) (O : Oracles) (v : ℕ) (G : Oracle) + (hG : Generic O G) : + G ∈ OpenSet (Avoid (Q O v)) ↔ ¬ G ∈ OpenSet (Q O v) := by + constructor + · rintro ⟨s,hs,hGs⟩ ⟨t,ht,hGt⟩ + obtain ⟨u,hsu,htu,_⟩ := realizes_common hGs hGt + exact hs u hsu (hup O v t u htu ht) + · intro hn + have hd : Arith (fun O n => Decides (Q O v) (word n)) := + ((decides_arith hQ).comp _ (Primrec₂.natPair.comp (Primrec.const v) Primrec.id)).congr + (fun _ _ => by simp only [left,right,Nat.unpair_pair,id_eq]) + obtain ⟨s,hs,hGs⟩ := hG (fun O s => Decides (Q O v) s) hd (decides_dense _ (hup O v)) + rcases hs with hs | hs + · exact False.elim (hn ⟨s,hs,hGs⟩) + · exact ⟨s,hs,hGs⟩ + +end TuringRigidity.ArithmeticPrefixForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPresentation.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..10d0f50023f78bca7f64dceba985aa964a3513f0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPresentation.lean @@ -0,0 +1,50 @@ +import OAI.Computability.DegreeRigidity.SetModels.EnumerationTransport + +namespace OAI + +namespace TuringRigidity.ArithmeticPresentation +open OracleJump ArithmeticHierarchy EncodedForcing BoundedDecoding IdealInterpretation +open EnumerationDecoding EnumerationConstruction EnumerationTransport GlobalLocality +noncomputable section + +theorem reduces_iterate (H : Oracle) (n : ℕ) : Reduces H (iterate H n) := by + induction n with + | zero => exact reduces_refl H + | succ n ih => exact reduces_trans ih (reduces_jump _) + +def Graph (π : Degree ≃o Degree) (H : Oracle) (v : ℕ) : Prop := + π (degree (columns H (Nat.unpair v).1)) = degree (columns H (Nat.unpair v).2) + +theorem graph_arithmetic (π : Degree ≃o Degree) (H : Oracle) + (hz : Reduces (jump FixedArithmetic.zero) H) + (hpre : π.symm (degree (jump FixedArithmetic.zero)) ≤ degree H) : + Sigma (iterate H 6) 5 (Graph π H) ∧ RecursivePred (iterate H 11) (Graph π H) := by + obtain ⟨c,hout,hS,hP⟩ := enumeration_exists H hz + let d := mapEnumeration π c + obtain ⟨hdS,hdP⟩ := mapEnumeration_below π c (degree (jump H)) hS hP + have hb : π (degree (jump H)) ≤ degree (iterate H 6) := by + have hh := source_3_3_1 π (degree (jump H)) (hpre.trans (reduces_jump H)) + rw [degreeIterate_degree] at hh + exact hh + have hg := graph_sigma (reduces_iterate H 6) d (hdS.mono hb) (hdP.mono hb) + have h : Sigma (iterate H 6) 5 (Graph π H) := hg.congr (fun v => by + simp only [d,mapEnumeration,hout,Graph]) + have hr := form_recursive h + exact ⟨h,hr⟩ + +theorem source_3_3_5 (π : Degree ≃o Degree) (I : DegreeIdeal) (H : Oracle) + (hpres : ∀ x, x ∈ I.carrier ↔ ∃ k, degree (columns H k) = x) + (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (hinv : ∀ x, π x ∈ I.carrier ↔ x ∈ I.carrier) : + Sigma (iterate H 6) 5 (Graph π H) ∧ RecursivePred (iterate H 11) (Graph π H) := by + have hbound (x : Degree) (hx : x ∈ I.carrier) : x ≤ degree H := by + obtain ⟨k,rfl⟩ := (hpres x).mp hx + exact CodingExtraction.column_projection_reduces H k + have hp : π.symm (degree (jump FixedArithmetic.zero)) ∈ I.carrier := + (hinv _).mp (by simpa only [π.apply_symm_apply] using hz) + exact graph_arithmetic π H (hbound _ hz) (hbound _ hp) + +end +end TuringRigidity.ArithmeticPresentation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPresentationProperty.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPresentationProperty.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d2714343b3eaa971730434d5986cee59e9594bb --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPresentationProperty.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticPersistence + +namespace OAI + +namespace TuringRigidity.ArithmeticPersistence +open EncodedForcing OracleJump UniformArithmetic PersistentRestrictions +open PersistentPresentation NumericalAutomorphism +noncomputable section + +def IdealCode (A : Oracle) : Prop := + (∀ n e, IndexPresentation.Dom (columns A n) e → + ∃ m, IndexPresentation.value (columns A n) e = degree (columns A m)) ∧ + ∀ n m, ∃ k, degree (columns A n) ⊔ degree (columns A m) = degree (columns A k) + +def idealOfCode (A : Oracle) (h : IdealCode A) : CountableIdeal where + carrier := Set.range (fun n => degree (columns A n)) + nonempty := ⟨degree (columns A 0),0,rfl⟩ + countable := Set.countable_range _ + lower := by + intro a b hab hb + obtain ⟨n,rfl⟩ := hb + obtain ⟨e,he,hv⟩ := IndexPresentation.value_surjective (columns A n) a hab + obtain ⟨m,hm⟩ := h.1 n e he + exact ⟨m,hm.symm.trans hv⟩ + join_mem := by + intro a b ha hb + obtain ⟨n,rfl⟩ := ha + obtain ⟨m,rfl⟩ := hb + obtain ⟨k,hk⟩ := h.2 n m + exact ⟨k,hk.symm⟩ + +theorem ideal_code {I : CountableIdeal} {A : Oracle} (hA : Presented I A) : IdealCode A := by + constructor + · intro n e _ + obtain ⟨m,hm⟩ := (hA _).mp + (I.lower (IndexPresentation.value_below (columns A n) e) (entry hA n).property) + exact ⟨m,hm.symm⟩ + · intro n m + obtain ⟨k,hk⟩ := (hA _).mp (I.join_mem (entry hA n).property (entry hA m).property) + exact ⟨k,hk.symm⟩ + +def Base (A R : Oracle) : Prop := + IdealCode A ∧ (∃ n, degree (jump FixedArithmetic.zero) = degree (columns A n)) ∧ + Action A (fun v => R v = true) + +def Property (A R : Oracle) : Prop := + ∃ I : CountableIdeal, ∃ hA : Presented I A, + degree (jump FixedArithmetic.zero) ∈ I.carrier ∧ + ∃ ρ : I ≃o I, (∀ v, R v = true ↔ Graph ρ hA v) ∧ Persistent I ρ + +theorem property_iff (A R : Oracle) : Property A R ↔ Base A R ∧ Criterion A R := by + constructor + · rintro ⟨I,hA,hz,ρ,hR,hp⟩ + have ha : Action A (fun v => R v = true) := + (PersistenceCriterion.action_congr hR).mpr (action_of_automorphism hA ρ) + obtain ⟨n,hn⟩ := (hA _).mp hz + exact ⟨⟨ideal_code hA,⟨n,hn.symm⟩,ha⟩,(persistent_iff hA ρ hz hR).mp hp⟩ + · rintro ⟨⟨hi,⟨n,hn⟩,ha⟩,hc⟩ + let I := idealOfCode A hi + have hA : Presented I A := fun _ => Iff.rfl + have hz : degree (jump FixedArithmetic.zero) ∈ I.carrier := (hA _).mpr ⟨n,hn.symm⟩ + obtain ⟨ρ,hR⟩ := reconstruct hA ha + exact ⟨I,hA,hz,ρ,hR,(persistent_iff hA ρ hz hR).mpr hc⟩ + +theorem base_arith : Arith (fun O (_ : ℕ) => Base (O 0) (O 1)) := by + have hA := parameter_arith 0 + have hR := parameter_arith 1 + have hz : ArithmeticOracle (fun _ _ => FixedArithmetic.zero) := by + exact (equal (Primrec.const 0) (Primrec.const 1)).congr + (fun _ _ => by simp [FixedArithmetic.zero]) + have hz' := (degree_equal_arith (jump_arith hz) (column_arith hA UniformArithmetic.right_primrec)).ex + have hi := (lower_arith hA).and (join_closed_arith hA) + exact (hi.and (hz'.and (action_arith hA hR))).congr + (fun _ _ => by simp only [Base,IdealCode,UniformArithmetic.right,Nat.unpair_pair]) + +def parameters (A R H : Oracle) : Oracles + | 0 => A + | 1 => R + | _ => H + +def PiOneOne (P : Oracle → Oracle → Prop) : Prop := + ∃ Q : Predicate, Arith Q ∧ ∀ A R, P A R ↔ ∀ H : Oracle, Q (parameters A R H) 0 + +theorem source_4_2_1 : PiOneOne Property := by + refine ⟨fun O v => Base (O 0) (O 1) ∧ Matrix O v, + base_arith.and matrix_arith,fun A R => ?_⟩ + rw [property_iff] + change Base A R ∧ Criterion A R ↔ ∀ H, Base A R ∧ + (NumericalIdeal.JumpCode H → NumericalIdeal.Includes A H → + ∃ e, NumericalAutomorphism.Action H (fun v => tableOracle (iterate H 11) e v = true) ∧ + NumericalExtension.Compatible A H (fun v => R v = true) + (fun v => tableOracle (iterate H 11) e v = true)) + exact ⟨fun h H => ⟨h.1,h.2 H⟩,fun h => ⟨(h FixedArithmetic.zero).1,fun H => (h H).2⟩⟩ + +end +end TuringRigidity.ArithmeticPersistence + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPrincipalIntersection.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPrincipalIntersection.lean new file mode 100644 index 0000000000000000000000000000000000000000..322b3841232160df05534b35aa3596c076395f23 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticPrincipalIntersection.lean @@ -0,0 +1,52 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticRelations +import OAI.Computability.DegreeRigidity.Representation.GenericIdentity + +namespace OAI + + +namespace TuringRigidity.ArithmeticPrincipalIntersection +open Encodable UniformArithmetic TableIndices IndexMatrix + +theorem principal_iff_tables (U L R : Oracle) : + GenericIdentity.PrincipalIntersection U L R ↔ + Reduces U L ∧ Reduces U R ∧ ∀ e : ℕ, IndexPresentation.Dom L e → + Reduces (tableOracle L e) R → Reduces (tableOracle L e) U := by + constructor + · intro h + have hU := (h (degree U)).mp le_rfl + refine ⟨hU.1,hU.2,fun e he hR => ?_⟩ + exact (h (degree (tableOracle L e))).mpr + ⟨represents_reduces ((valid_tableOracle L e).mp he),hR⟩ + · rintro ⟨hL,hR,h⟩ b + obtain ⟨A,rfl⟩ := degree_surjective b + constructor + · intro hA + exact ⟨reduces_trans hA hL,reduces_trans hA hR⟩ + · rintro ⟨haL,haR⟩ + change Reduces A R at haR + change Reduces A U + obtain ⟨d,hd⟩ := (reduces_iff_represents A L).mp haL + have he : Represents L (machine (encode d)) A := by simpa using hd + have hvalid : IndexPresentation.Dom L (encode d) := + (valid_iff_represents L _).mpr ⟨A,he⟩ + have ht := tableOracle_eq he + have hh := h (encode d) hvalid (by simpa only [ht] using haR) + simpa only [ht] using hh + +theorem principal_arith {U L R : OracleFamily} + (hU : ArithmeticOracle U) (hL : ArithmeticOracle L) (hR : ArithmeticOracle R) : + Arith (fun O v => GenericIdentity.PrincipalIntersection (U O v) (L O v) (R O v)) := by + have hleft := reduces_arith hU hL + have hright := reduces_arith hU hR + have hd := valid_arith (hL.comp left_primrec) right_primrec + have hout := tableOracle_arith (hL.comp left_primrec) right_primrec + have hr := reduces_arith hout (hR.comp left_primrec) + have hu := reduces_arith hout (hU.comp left_primrec) + apply (hleft.and (hright.and (hd.imp (hr.imp hu)).all)).congr + intro O v + simp only [left,right,Nat.unpair_pair] + exact (principal_iff_tables (U O v) (L O v) (R O v)).symm + +end TuringRigidity.ArithmeticPrincipalIntersection + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticProgramGraph.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticProgramGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a5c3c86a787f2e719c0f577c9bad150d2f4db98 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticProgramGraph.lean @@ -0,0 +1,43 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformPartialGraph +import OAI.Computability.DegreeRigidity.Computability.ArithmeticRelations +import OAI.Computability.DegreeRigidity.Representation.GenericTotality + +namespace OAI + + +namespace TuringRigidity.ArithmeticProgramGraph +open Encodable UniformArithmetic IndexMatrix GenericIdentity + +theorem eval_arith (p : OracleCode) {B : OracleFamily} (hB : ArithmeticOracle B) + {c n a : ℕ → ℕ} (hc : Primrec c) (hn : Primrec n) (ha : Primrec a) : + Arith (fun O v => a v ∈ OracleCode.eval (oracleFunction (B O (c v))) p (n v)) := by + obtain ⟨d, hd⟩ := UniformPartialGraph.eval_iff_table p + have h := (run_arith hB (hc.comp left_primrec) (Primrec.const (encode d)) + (hn.comp left_primrec) right_primrec (ha.comp left_primrec)).ex + exact h.congr (fun O v => by + simpa only [left, right, Nat.unpair_pair, machine_encode, Option.mem_def] using + (hd (B O (c v)) (n v) (a v)).symm) + +theorem output_arith (p : OracleCode) {B : OracleFamily} (hB : ArithmeticOracle B) : + ArithmeticOracle (fun O v => programOutput p (B O v)) := + (eval_arith p hB left_primrec right_primrec (Primrec.const 1)).congr + (fun _ _ => by simp [programOutput]) + +theorem value_arith (p : OracleCode) {P A : OracleFamily} + (hP : ArithmeticOracle P) (hA : ArithmeticOracle A) : + ArithmeticOracle (fun O v => value p (P O v) (A O v)) := + output_arith p (join_arith hA hP) + +theorem total_arith (p : OracleCode) {P A : OracleFamily} + (hP : ArithmeticOracle P) (hA : ArithmeticOracle A) : + Arith (fun O v => Total p (P O v) (A O v)) := by + have hB := join_arith hA hP + have h0 := eval_arith p hB left_primrec right_primrec (Primrec.const 0) + have h1 := eval_arith p hB left_primrec right_primrec (Primrec.const 1) + exact (h0.or h1).all.congr (fun O v => by + simpa only [left, right, Nat.unpair_pair, BinaryHalts] using + (total_iff_binaryHalts p (P O v) (A O v)).symm) + +end TuringRigidity.ArithmeticProgramGraph + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticRelations.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticRelations.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb6a0200f15953ef62d3c086107da7a931a3b6c5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticRelations.lean @@ -0,0 +1,75 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticOracles + +namespace OAI + +namespace TuringRigidity.UniformArithmetic +open Encodable CommonIdeal IndexMatrix TableIndices OracleJump +noncomputable section + +theorem represents_arith {A B : OracleFamily} (hA : ArithmeticOracle A) + (hB : ArithmeticOracle B) {e : ℕ → ℕ} (he : Primrec e) : + Arith (fun O v => Represents (B O v) (machine (e v)) (A O v)) := by + let c := left_primrec.comp (left_primrec.comp left_primrec) + let n := right_primrec.comp (left_primrec.comp left_primrec) + let z := right_primrec.comp left_primrec + have hr := run_arith hB c (he.comp c) n z right_primrec + have hb := bit_equal hA c n right_primrec + have h := ((hr.imp hb).all.all.all).and ((hr.and hb).ex.ex.all) + apply h.congr + intro O v + simp only [left,right,Nat.unpair_pair] + constructor + · rintro ⟨hs,ht⟩ + exact ⟨fun n z a ha => hs n z a (Option.mem_def.mp ha), + fun n => by obtain ⟨z,a,ha,_⟩ := ht n; exact ⟨z,a,Option.mem_def.mpr ha⟩⟩ + · rintro ⟨hs,ht⟩ + exact ⟨fun n z a ha => hs n z a (Option.mem_def.mpr ha), + fun n => by obtain ⟨z,a,ha⟩ := ht n; exact ⟨z,a,Option.mem_def.mp ha,hs n z a ha⟩⟩ + +theorem valid_tableOracle (B : Oracle) (e : ℕ) : + Valid B (machine e) ↔ Represents B (machine e) (tableOracle B e) := by + constructor + · intro hv + obtain ⟨A,hA⟩ := (valid_iff_represents B (machine e)).mp hv + rw [tableOracle_eq hA] + exact hA + · intro h + exact (valid_iff_represents B (machine e)).mpr ⟨_,h⟩ + +theorem valid_arith {B : OracleFamily} (hB : ArithmeticOracle B) + {e : ℕ → ℕ} (he : Primrec e) : + Arith (fun O v => IndexPresentation.Dom (B O v) (e v)) := + (represents_arith (tableOracle_arith hB he) hB he).congr + (fun O v => (valid_tableOracle (B O v) (e v)).symm) + +theorem reduces_arith {A B : OracleFamily} (hA : ArithmeticOracle A) + (hB : ArithmeticOracle B) : Arith (fun O v => Reduces (A O v) (B O v)) := by + have h := (represents_arith (hA.comp left_primrec) (hB.comp left_primrec) right_primrec).ex + apply h.congr + intro O v + simp only [left,right,Nat.unpair_pair] + rw [reduces_iff_represents] + constructor + · rintro ⟨e,he⟩ + exact ⟨machine e,he⟩ + · rintro ⟨e,he⟩ + exact ⟨encode e,by simpa using he⟩ + +theorem degree_equal_arith {A B : OracleFamily} (hA : ArithmeticOracle A) + (hB : ArithmeticOracle B) : Arith (fun O v => degree (A O v) = degree (B O v)) := + ((reduces_arith hA hB).and (reduces_arith hB hA)).congr + (fun O v => (degree_eq_iff (A O v) (B O v)).symm) + +theorem join_arith {A B : OracleFamily} (hA : ArithmeticOracle A) + (hB : ArithmeticOracle B) : ArithmeticOracle (fun O v => join (A O v) (B O v)) := by + have ht : Arith (fun (_ : Oracles) v => (right v).bodd = true) := + .pure _ (Primrec.eq.comp (Primrec.nat_bodd.comp right_primrec) (Primrec.const true)) + have hd : Primrec (fun v => right v / 2) := Primrec.nat_div.comp right_primrec (Primrec.const 2) + exact ((ht.and (query_at hB left_primrec hd)).or + (ht.neg.and (query_at hA left_primrec hd))).congr (fun O v => by + cases h : (right v).bodd <;> simp [join,h]) + +end +end TuringRigidity.UniformArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticSetSyntax.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticSetSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..76cb9c5ae5886c1e3dc887538d2aa5521bdf7ccc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticSetSyntax.lean @@ -0,0 +1,103 @@ +import OAI.Computability.DegreeRigidity.Syntax.PrimitivePredicateFormula +import OAI.Computability.DegreeRigidity.SetModels.ModelReals +import OAI.Computability.DegreeRigidity.Computability.UniformArithmetic + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open UniformArithmetic +universe u + +noncomputable def arithmeticEnv (Q : ZFSet.{u}) (O : Oracles) (n : ℕ) : ℕ → ZFSet.{u} := + cons (natSet n) (cons ZFSet.omega (cons Q (fun i => realCode (O i)))) + +def DefinesArithmetic (φ : Formula) (P : Predicate) : Prop := + ∀ Q : ZFSet.{u}, (∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ Q) → ∀ O n, + (φ.Eval (arithmeticEnv Q O n) ↔ P O n) + +namespace Formula +def arithmeticVars (k : ℕ) : ℕ → ℕ + | 0 => 0 + | i+1 => i+k+1 + +theorem eval_arithmetic_shift_one (φ : Formula) (Q : ZFSet.{u}) (O : Oracles) (n m : ℕ) : + (φ.rename (arithmeticVars 1)).Eval (cons (natSet m) (arithmeticEnv Q O n)) ↔ + φ.Eval (arithmeticEnv Q O m) := by + rw [eval_rename] + have he : (fun i => cons (natSet m) (arithmeticEnv Q O n) (arithmeticVars 1 i)) = arithmeticEnv Q O m := by + funext i; cases i <;> rfl + rw [he] + +theorem eval_arithmetic_shift_two (φ : Formula) (Q : ZFSet.{u}) (O : Oracles) (n k m : ℕ) : + (φ.rename (arithmeticVars 2)).Eval (cons (natSet m) (cons (natSet k) (arithmeticEnv Q O n))) ↔ + φ.Eval (arithmeticEnv Q O m) := by + rw [eval_rename] + have he : (fun i => cons (natSet m) (cons (natSet k) (arithmeticEnv Q O n)) (arithmeticVars 2 i)) = + arithmeticEnv Q O m := by + funext i; cases i <;> rfl + rw [he] + +def arithmeticExists (φ : Formula) : Formula := .existsMem 1 (.existsMem 2 + (.conj (naturalPair 3 4 2 1 0) (φ.rename (arithmeticVars 2)))) + +def arithmeticComp (φ ψ : Formula) : Formula := .existsMem 1 + (.conj (unary ψ 2 3 1 0) (φ.rename (arithmeticVars 1))) +end Formula + +theorem DefinesArithmetic.existsNat {φ : Formula} {P : Predicate} (hφ : DefinesArithmetic.{u} φ P) : + DefinesArithmetic.{u} φ.arithmeticExists (fun O n => ∃ k, P O (Nat.pair n k)) := by + intro Q hQ O n + have hp (k : ℕ) (w : ZFSet.{u}) := Formula.naturalPair_spec 3 4 2 1 0 + (cons w (cons (natSet k) (arithmeticEnv Q O n))) rfl hQ n k rfl rfl + simp only [Formula.arithmeticExists,Formula.Eval,arithmeticEnv,cons_zero,cons_succ] + constructor + · rintro ⟨x,hx,w,_,hpair,h⟩ + obtain ⟨k,rfl⟩ := (mem_omega x).mp hx + obtain rfl := (hp k w).mp hpair + exact ⟨k,(hφ Q hQ O _).mp ((Formula.eval_arithmetic_shift_two φ Q O n k _).mp h)⟩ + · rintro ⟨k,h⟩ + exact ⟨natSet k,(mem_omega _).mpr ⟨k,rfl⟩,natSet (Nat.pair n k), + (mem_omega _).mpr ⟨Nat.pair n k,rfl⟩,(hp k _).mpr rfl, + (Formula.eval_arithmetic_shift_two φ Q O n k _).mpr ((hφ Q hQ O _).mpr h)⟩ + +theorem DefinesArithmetic.comp {φ ψ : Formula} {P : Predicate} {f : ℕ → ℕ} + (hφ : DefinesArithmetic.{u} φ P) (hψ : DefinesNatural.{u} ψ f) : + DefinesArithmetic.{u} (φ.arithmeticComp ψ) (fun O n => P O (f n)) := by + intro Q hQ O n + have hf (w : ZFSet.{u}) := Formula.unary_spec hψ 2 3 1 0 + (cons w (arithmeticEnv Q O n)) rfl hQ n rfl + simp only [Formula.arithmeticComp,Formula.Eval,arithmeticEnv,cons_zero,cons_succ] + constructor + · rintro ⟨w,_,hw,h⟩ + obtain rfl := (hf w).mp hw + exact (hφ Q hQ O _).mp ((Formula.eval_arithmetic_shift_one φ Q O n _).mp h) + · intro h + exact ⟨natSet (f n),(mem_omega _).mpr ⟨f n,rfl⟩,(hf _).mpr rfl, + (Formula.eval_arithmetic_shift_one φ Q O n _).mpr ((hφ Q hQ O _).mpr h)⟩ + +theorem arithmetic_bounded_definition {P : Predicate} (hP : Arith P) : + ∃ φ : Formula, DefinesArithmetic.{u} φ P := by + induction hP with + | pure P hP => + obtain ⟨φ,hφ⟩ := primitive_predicate_bounded.{u} hP + exact ⟨φ,fun Q hQ O n => hφ (arithmeticEnv Q O n) rfl hQ n rfl⟩ + | query i => + exact ⟨.member 0 (i+3),fun Q _ O n => natSet_mem_realCode (O i) n⟩ + | neg h ih => + obtain ⟨φ,hφ⟩ := ih + exact ⟨.neg φ,fun Q hQ O n => not_congr (hφ Q hQ O n)⟩ + | and h k ih ik => + obtain ⟨φ,hφ⟩ := ih; obtain ⟨ψ,hψ⟩ := ik + exact ⟨.conj φ ψ,fun Q hQ O n => and_congr (hφ Q hQ O n) (hψ Q hQ O n)⟩ + | ex h ih => + obtain ⟨φ,hφ⟩ := ih + exact ⟨φ.arithmeticExists,hφ.existsNat⟩ + | comp f h hf ih => + obtain ⟨φ,hφ⟩ := ih + obtain ⟨ψ,hψ⟩ := primitive_bounded_definition.{u} (Primrec.nat_iff.mp hf) + exact ⟨φ.arithmeticComp ψ,hφ.comp hψ⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticShuffleCertificate.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticShuffleCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..88caabbf86a74bdc993a1940d6117fe9eec42734 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticShuffleCertificate.lean @@ -0,0 +1,59 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteShuffleComputation +import OAI.Computability.DegreeRigidity.Computability.UniformArithmetic + +namespace OAI + + +namespace TuringRigidity.ArithmeticShuffleCertificate +open Encodable UniformArithmetic FiniteShuffleComputation FiniteShuffleCertificate +open EncodedForcing (word word_primrec) + +theorem certificate_arith : + Arith (fun O n => Certificate (fun t => O 0 (encode t) = true) (word n)) := by + let L := left_primrec + let R := right_primrec + + let hn := L.comp (L.comp L) + let hk := R.comp (L.comp L) + let hs := R.comp L + have hshuffle := finiteShuffleWord_primrec.comp + (Primrec₂.natPair.comp hs (Primrec₂.natPair.comp hn R)) + have hquery := (Arith.query 0).comp _ hshuffle + have hbound := Arith.pure (fun v => right v ≤ right (left (left v))) + (Primrec.nat_le.comp R hk) + have hex := (hbound.and hquery).ex + have hlength := equal (Primrec.list_length.comp (word_primrec.comp R)) (R.comp L) + have hall := (hlength.imp hex).all + have hsize := Arith.pure (fun v => 2 * right v ≤ (word (left v)).length) + (Primrec.nat_le.comp (Primrec.nat_mul.comp (Primrec.const 2) R) + (Primrec.list_length.comp (word_primrec.comp L))) + apply (hsize.and hall).ex.congr + intro O n + simp only [left,right,Nat.unpair_pair,finiteShuffleWord] + constructor + · rintro ⟨k,hk,h⟩ + refine ⟨k,hk,fun s hs => ?_⟩ + have hlen : (word (encode s)).length = k := by simpa [word] using hs + simpa [word] using h (encode s) hlen + · rintro ⟨k,hk,h⟩ + exact ⟨k,hk,fun s hs => h (word s) hs⟩ + +theorem open_arith : Arith (fun O n => + ∃ r : List Bool, O 0 (encode r) = true ∧ r <+: word n) := by + have hp : Arith (fun (_ : Oracles) v => word (right v) <+: word (left v)) := + (Arith.pure _ (Primrec.eq.comp (word_primrec.comp right_primrec) + (Primrec.list_take.comp (Primrec.list_length.comp (word_primrec.comp right_primrec)) + (word_primrec.comp left_primrec)))).congr (fun _ _ => List.prefix_iff_eq_take.symm) + have hq := (Arith.query 0).comp _ (Primrec.encode.comp (word_primrec.comp right_primrec)) + apply (hq.and hp).ex.congr + intro O n + simp only [left,right,Nat.unpair_pair] + constructor + · rintro ⟨r,hr,hp⟩ + exact ⟨word r,hr,hp⟩ + · rintro ⟨r,hr,hp⟩ + exact ⟨encode r,by simpa [word] using hr,by simpa [word] using hp⟩ + +end TuringRigidity.ArithmeticShuffleCertificate + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticShuffleGraph.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticShuffleGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..bcdfc883a68af5993f649cd656dc3aa23b287cea --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticShuffleGraph.lean @@ -0,0 +1,77 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticOracles +import OAI.Computability.DegreeRigidity.Effective.FiniteShuffleComputation + +namespace OAI + + +namespace TuringRigidity.ArithmeticShuffleGraph +open Encodable UniformArithmetic FiniteShuffle ShuffleRequirements GenericCoding +open EncodedForcing (word word_primrec) + +theorem realizes_arith {B : OracleFamily} (hB : ArithmeticOracle B) + {c s : ℕ → ℕ} (hc : Primrec c) (hs : Primrec s) : + Arith (fun O v => Realizes (word (s v)) (B O (c v))) := by + have hb := Arith.pure (fun v => (word (s (left v))).getD (right v) false = true) + (Primrec.eq.comp ((Primrec.list_getD false).comp + (word_primrec.comp (hs.comp left_primrec)) right_primrec) (Primrec.const true)) + have hq := query_at hB (hc.comp left_primrec) right_primrec + have hl := less right_primrec + (Primrec.list_length.comp (word_primrec.comp (hs.comp left_primrec))) + apply (hl.imp (hb.iff hq)).all.congr + intro O v + simp only [left, right, Nat.unpair_pair] + constructor + · intro h i hi + have hh := h i hi + cases hb : (word (s v)).getD i false <;> cases ho : B O (c v) i <;> simp_all + · intro h i hi + rw [show (word (s v)).getD i false = B O (c v) i from h i hi] + +theorem code_bit_iff (Y L : Oracle) (n : ℕ) : + code Y L n = true ↔ ∃ s t : ℕ, + (word s).length = n + 1 ∧ (word t).length = 2 * (n + 1) ∧ + Realizes (word s) Y ∧ Realizes (word t) L ∧ + code (fun i => (word s).getD i false) (fun i => (word t).getD i false) n = true := by + constructor + · intro h + refine ⟨encode (initial Y (n + 1)), encode (initial L (2 * (n + 1))), ?_⟩ + simp only [word, Encodable.encodek, Option.getD_some, prefix_length] + have hy : Realizes (initial Y (n + 1)) Y := + (realizes_initial _ _ _).mpr (fun _ _ => rfl) + have hl : Realizes (initial L (2 * (n + 1))) L := + (realizes_initial _ _ _).mpr (fun _ _ => rfl) + have he := code_agree (n := n + 1) + (show Agree (n + 1) (fun i => (initial Y (n+1)).getD i false) Y from + fun i hi => prefix_getD Y _ i hi) + (show Agree (2 * (n + 1)) (fun i => (initial L (2*(n+1))).getD i false) L from + fun i hi => prefix_getD L _ i hi) + exact ⟨True.intro, True.intro, hy, hl, (he n (by omega)).trans h⟩ + · rintro ⟨s,t,hs,ht,hy,hl,h⟩ + have hy' : Agree (n + 1) (fun i => (word s).getD i false) Y := by + simpa only [Realizes, hs] using hy + have hl' : Agree (2 * (n + 1)) (fun i => (word t).getD i false) L := by + simpa only [Realizes, ht] using hl + exact ((code_agree hy' hl') n (by omega)).symm.trans h + +theorem code_arith {Y L : OracleFamily} + (hY : ArithmeticOracle Y) (hL : ArithmeticOracle L) : + ArithmeticOracle (fun O v => code (Y O v) (L O v)) := by + let base := left_primrec.comp (left_primrec.comp left_primrec) + let n := right_primrec.comp (left_primrec.comp left_primrec) + let s := right_primrec.comp left_primrec + let t := right_primrec + have hs := equal (Primrec.list_length.comp (word_primrec.comp s)) (Primrec.succ.comp n) + have ht := equal (Primrec.list_length.comp (word_primrec.comp t)) + (Primrec.nat_mul.comp (Primrec.const 2) (Primrec.succ.comp n)) + have hy := realizes_arith hY base s + have hl := realizes_arith hL base t + have hb := Arith.pure _ (Primrec.eq.comp + (FiniteShuffleComputation.wordShuffleBit_primrec.comp + ((word_primrec.comp s).pair ((word_primrec.comp t).pair n))) (Primrec.const true)) + exact (hs.and (ht.and (hy.and (hl.and hb)))).ex.ex.congr (fun O v => by + simpa only [base,n,s,t,left,right,Nat.unpair_pair] using + (code_bit_iff (Y O (left v)) (L O (left v)) (right v)).symm) + +end TuringRigidity.ArithmeticShuffleGraph + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticSkolem.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticSkolem.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa47095be383e5a1ae54486c4e7a8dc7d54cbe8f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticSkolem.lean @@ -0,0 +1,165 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticFiniteTest + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic +noncomputable section + +def HasTest (P : Predicate) : Prop := ∃ t : Test, t.Presents P + +namespace HasTest + +private def col (k : ℕ) (t : Test) : Test := + t.subst .input (fun s => .witness (.pair (.const k) s)) + +private theorem col_eval (k : ℕ) (t : Test) (O : Oracles) (f : ℕ → ℕ) (v : ℕ) : + (col k t).eval O f v ↔ t.eval O (fun n => f (Nat.pair k n)) v := + t.eval_subst _ _ O f _ v (fun _ => rfl) + +theorem pure (P : ℕ → Prop) (hP : PrimrecPred P) : HasTest (fun _ v => P v) := by + refine ⟨.pure P hP (.left .input),fun O v => ?_⟩ + simp only [Test.eval,Term.eval,Term.left,UniformArithmetic.left,Nat.unpair_pair] + exact ⟨fun h => ⟨fun _ => 0,fun _ => h⟩,fun ⟨_,h⟩ => h 0⟩ + +theorem query (i : ℕ) : HasTest (fun O v => O i v = true) := by + refine ⟨.query i (.left .input),fun O v => ?_⟩ + simp only [Test.eval,Term.eval,Term.left,UniformArithmetic.left,Nat.unpair_pair] + exact ⟨fun h => ⟨fun _ => 0,fun _ => h⟩,fun ⟨_,h⟩ => h 0⟩ + +theorem not_pure (P : ℕ → Prop) (hP : PrimrecPred P) : HasTest (fun _ v => ¬ P v) := by + refine ⟨.neg (.pure P hP (.left .input)),fun O v => ?_⟩ + simp only [Test.eval,Term.eval,Term.left,UniformArithmetic.left,Nat.unpair_pair] + exact ⟨fun h => ⟨fun _ => 0,fun _ => h⟩,fun ⟨_,h⟩ => h 0⟩ + +theorem not_query (i : ℕ) : HasTest (fun O v => ¬ O i v = true) := by + refine ⟨.neg (.query i (.left .input)),fun O v => ?_⟩ + simp only [Test.eval,Term.eval,Term.left,UniformArithmetic.left,Nat.unpair_pair] + exact ⟨fun h => ⟨fun _ => 0,fun _ => h⟩,fun ⟨_,h⟩ => h 0⟩ + +theorem and {P Q} (hP : HasTest P) (hQ : HasTest Q) : + HasTest (fun O v => P O v ∧ Q O v) := by + classical + obtain ⟨t,ht⟩ := hP + obtain ⟨s,hs⟩ := hQ + refine ⟨.and (col 0 t) (col 1 s),fun O v => ?_⟩ + simp only [Test.eval,col_eval] + constructor + · rintro ⟨hp,hq⟩ + obtain ⟨f,hf⟩ := (ht O v).mp hp + obtain ⟨g,hg⟩ := (hs O v).mp hq + refine ⟨fun k => if (Nat.unpair k).1 = 0 then f (Nat.unpair k).2 else g (Nat.unpair k).2,?_⟩ + intro n + constructor + · simpa only [Nat.unpair_pair,ite_eq_left rfl,ite_true] using hf n + · simpa only [Nat.unpair_pair,ite_eq_right (Nat.one_ne_zero)] using hg n + · rintro ⟨f,hf⟩ + exact ⟨(ht O v).mpr ⟨_,fun n => (hf n).1⟩, + (hs O v).mpr ⟨_,fun n => (hf n).2⟩⟩ + +private def tailTest (t : Test) : Test := + t.subst .input (fun s => .witness (.prim Nat.succ Primrec.succ s)) + +private theorem tail_eval (t : Test) (O : Oracles) (f : ℕ → ℕ) (v : ℕ) : + (tailTest t).eval O f v ↔ t.eval O (fun n => f (n+1)) v := + t.eval_subst _ _ O f _ v (fun _ => rfl) + +private def zeroTag : Test := + .pure (fun n => n = 0) (Primrec.eq.comp Primrec.id (Primrec.const 0)) + (.witness (.const 0)) + +theorem or {P Q} (hP : HasTest P) (hQ : HasTest Q) : + HasTest (fun O v => P O v ∨ Q O v) := by + classical + obtain ⟨t,ht⟩ := hP + obtain ⟨s,hs⟩ := hQ + refine ⟨(Test.and zeroTag (tailTest t)).or (.and (.neg zeroTag) (tailTest s)),fun O v => ?_⟩ + simp only [Test.eval_or,Test.eval,tail_eval,zeroTag,Term.eval] + constructor + · intro h + rcases h with hp | hq + · obtain ⟨f,hf⟩ := (ht O v).mp hp + exact ⟨(fun n => Nat.casesOn n 0 f),fun n => Or.inl ⟨rfl,hf n⟩⟩ + · obtain ⟨g,hg⟩ := (hs O v).mp hq + exact ⟨(fun n => Nat.casesOn n 1 g),fun n => Or.inr ⟨by simp,hg n⟩⟩ + · rintro ⟨f,hf⟩ + by_cases hz : f 0 = 0 + · exact Or.inl ((ht O v).mpr ⟨_,fun n => ((hf n).resolve_right (fun h => h.1 hz)).2⟩) + · exact Or.inr ((hs O v).mpr ⟨_,fun n => ((hf n).resolve_left (fun h => hz h.1)).2⟩) + +theorem comp {P} (hP : HasTest P) (g : ℕ → ℕ) (hg : Primrec g) : + HasTest (fun O v => P O (g v)) := by + obtain ⟨t,ht⟩ := hP + let inputTerm : Term := .pair (.prim g hg (.left .input)) (.right .input) + refine ⟨t.subst inputTerm Term.witness,fun O v => ?_⟩ + dsimp only + rw [ht] + apply exists_congr + intro f + apply forall_congr' + intro n + simpa only [inputTerm,Term.eval,Term.left,Term.right,UniformArithmetic.left, + UniformArithmetic.right,Nat.unpair_pair] using + (t.eval_subst inputTerm Term.witness O f f (Nat.pair v n) (fun _ => rfl)).symm + +theorem ex {P} (hP : HasTest P) : HasTest (fun O v => ∃ k, P O (Nat.pair v k)) := by + obtain ⟨t,ht⟩ := hP + let inputTerm : Term := .pair (.pair (.left .input) (.witness (.const 0))) (.right .input) + let q : Term → Term := fun s => .witness (.prim Nat.succ Primrec.succ s) + have he O f v n : (t.subst inputTerm q).eval O f (Nat.pair v n) ↔ + t.eval O (fun k => f (k+1)) (Nat.pair (Nat.pair v (f 0)) n) := by + simpa only [inputTerm,Term.eval,Term.left,Term.right,UniformArithmetic.left, + UniformArithmetic.right,Nat.unpair_pair] using + t.eval_subst inputTerm q O f (fun k => f (k+1)) (Nat.pair v n) (fun _ => rfl) + refine ⟨t.subst inputTerm q,fun O v => ?_⟩ + constructor + · rintro ⟨k,hk⟩ + obtain ⟨f,hf⟩ := (ht O (Nat.pair v k)).mp hk + exact ⟨(fun n => Nat.casesOn n k f),fun n => (he _ _ _ _).mpr (hf n)⟩ + · rintro ⟨f,hf⟩ + exact ⟨f 0,(ht O _).mpr ⟨_,fun n => (he _ _ _ _).mp (hf n)⟩⟩ + +theorem all {P} (hP : HasTest P) : HasTest (fun O v => ∀ k, P O (Nat.pair v k)) := by + classical + obtain ⟨t,ht⟩ := hP + let inputTerm : Term := .pair (.pair (.left .input) (.left (.right .input))) (.right (.right .input)) + let q : Term → Term := fun s => .witness (.pair (.left (.right .input)) s) + have he O f v n : (t.subst inputTerm q).eval O f (Nat.pair v n) ↔ + t.eval O (fun k => f (Nat.pair (Nat.unpair n).1 k)) + (Nat.pair (Nat.pair v (Nat.unpair n).1) (Nat.unpair n).2) := by + simpa only [inputTerm,Term.eval,Term.left,Term.right,UniformArithmetic.left, + UniformArithmetic.right,Nat.unpair_pair] using + t.eval_subst inputTerm q O f (fun k => f (Nat.pair (Nat.unpair n).1 k)) + (Nat.pair v n) (fun _ => by simp [q,Term.eval,Term.left,Term.right, + UniformArithmetic.left,UniformArithmetic.right]) + refine ⟨t.subst inputTerm q,fun O v => ?_⟩ + constructor + · intro h + have hh : ∀ k, ∃ f, ∀ n, t.eval O f (Nat.pair (Nat.pair v k) n) := + fun k => (ht O _).mp (h k) + choose f hf using hh + refine ⟨fun n => f (Nat.unpair n).1 (Nat.unpair n).2,fun n => (he _ _ _ _).mpr ?_⟩ + simpa only [Nat.unpair_pair] using hf (Nat.unpair n).1 (Nat.unpair n).2 + · rintro ⟨f,hf⟩ k + refine (ht O _).mpr ⟨fun n => f (Nat.pair k n),fun n => ?_⟩ + simpa only [Nat.unpair_pair] using (he _ _ _ _).mp (hf (Nat.pair k n)) + +theorem congr {P Q} (hP : HasTest P) (he : ∀ O v, P O v ↔ Q O v) : HasTest Q := by + obtain ⟨t,ht⟩ := hP + exact ⟨t,fun O v => (he O v).symm.trans (ht O v)⟩ +end HasTest + +theorem arithmetic_tests {P} (h : Arith P) : HasTest P ∧ HasTest (fun O v => ¬ P O v) := by + induction h with + | pure P hP => exact ⟨HasTest.pure P hP,HasTest.not_pure P hP⟩ + | query i => exact ⟨HasTest.query i,HasTest.not_query i⟩ + | neg h ih => exact ⟨ih.2,ih.1.congr (fun _ _ => not_not.symm)⟩ + | and h k ih ik => + exact ⟨ih.1.and ik.1,(ih.2.or ik.2).congr (fun _ _ => not_and_or.symm)⟩ + | ex h ih => exact ⟨ih.1.ex,ih.2.all.congr (fun _ _ => not_exists.symm)⟩ + | comp f h hf ih => exact ⟨ih.1.comp f hf,ih.2.comp f hf⟩ + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticSourceEquation.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticSourceEquation.lean new file mode 100644 index 0000000000000000000000000000000000000000..35a4c9c4601c278ccccafc153dfc9641c4af07c0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticSourceEquation.lean @@ -0,0 +1,31 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticProgramGraph +import OAI.Computability.DegreeRigidity.Computability.ArithmeticShuffleGraph +import OAI.Computability.DegreeRigidity.Computability.ArithmeticPrincipalIntersection + +namespace OAI + + +namespace TuringRigidity.ArithmeticSourceEquation +open UniformArithmetic ArithmeticProgramGraph ArithmeticShuffleGraph GenericIdentity + +theorem equation_arith (p : OracleCode) {P Y L R : OracleFamily} + (hP : ArithmeticOracle P) (hY : ArithmeticOracle Y) + (hL : ArithmeticOracle L) (hR : ArithmeticOracle R) : + Arith (fun O v => SourceEquation p (P O v) (Y O v, L O v, R O v)) := by + have hYL := code_arith hY hL + have hYR := code_arith hY hR + have hi := ArithmeticPrincipalIntersection.principal_arith (value_arith p hP hY) + (join_arith (value_arith p hP hYL) (value_arith p hP hL)) + (join_arith (value_arith p hP hYR) (value_arith p hP hR)) + exact (total_arith p hP hY).and ((total_arith p hP hL).and + ((total_arith p hP hR).and ((total_arith p hP hYL).and + ((total_arith p hP hYR).and hi)))) + +theorem sourceEquation_arith (p : OracleCode) : + Arith (fun O _ => SourceEquation p (O 0) (O 1, O 2, O 3)) := + equation_arith p (parameter_arith 0) (parameter_arith 1) + (parameter_arith 2) (parameter_arith 3) + +end TuringRigidity.ArithmeticSourceEquation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticSourceTruth.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticSourceTruth.lean new file mode 100644 index 0000000000000000000000000000000000000000..21c65e3f07b4ecdfd0272fa69fbae979821b05fa --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticSourceTruth.lean @@ -0,0 +1,48 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticSourceEquation +import OAI.Computability.DegreeRigidity.Computability.ArithmeticGenericDensity + +namespace OAI + + +namespace TuringRigidity.ArithmeticSourceTruth +open UniformArithmetic ArithmeticPrefixForcing GenericIdentity GenericTruth ShuffleRequirements + +theorem binary_column_arith {B : OracleFamily} (hB : ArithmeticOracle B) (b : Bool) : + ArithmeticOracle (fun O v => PairGenericSelection.column b (B O v)) := by + have he := Primrec.nat_mul.comp (Primrec.const 2) right_primrec + cases b with + | false => exact query_at hB left_primrec he + | true => exact query_at hB left_primrec (Primrec.succ.comp he) + +theorem triple_equation_arith (p : OracleCode) : + Arith (fun O _ => SourceEquation p (O 1) (triple (O 0))) := + ArithmeticSourceEquation.equation_arith p (parameter_arith 1) + (binary_column_arith (parameter_arith 0) false) + (binary_column_arith (binary_column_arith (parameter_arith 0) true) false) + (binary_column_arith (binary_column_arith (parameter_arith 0) true) true) + +theorem source_equation_truth (p : OracleCode) : + ∃ Q : PrefixPredicate, ArithmeticPrefix Q ∧ (∀ O v, Upward (Q O v)) ∧ + ∀ P G : Oracle, Generic (fun _ => P) G → + (SourceEquation p P (triple G) ↔ + G ∈ OpenSet (Q (fun _ => P) 0)) := by + obtain ⟨Q,hQ,hup,ht⟩ := ArithmeticGenericTruth.arithmetic_generic_truth (triple_equation_arith p) + refine ⟨Q,hQ,hup,?_⟩ + intro P G hG + simpa using ht (fun _ => P) 0 G hG + +theorem source_equation_of_dense (p : OracleCode) (P : Oracle) + (hd : ∀ s : List Bool, ∃ H : Oracle, + Generic (fun _ => P) H ∧ Realizes s H ∧ SourceEquation p P (triple H)) : + ∀ G : Oracle, Generic (fun _ => P) G → SourceEquation p P (triple G) := by + have hden : ∀ s : List Bool, ∃ H : Oracle, + Generic (fun _ => P) H ∧ Realizes s H ∧ + SourceEquation p ((Function.update (fun _ => P) 0 H) 1) + (triple ((Function.update (fun _ => P) 0 H) 0)) := by + simpa using hd + simpa using ArithmeticGenericDensity.truth_of_dense (triple_equation_arith p) + (fun _ => P) 0 hden + +end TuringRigidity.ArithmeticSourceTruth + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTables.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7a1e2079a84afbd07ac79cdeb686c7a777a7069 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTables.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.Computability.UniformArithmetic + +namespace OAI + +namespace TuringRigidity.UniformArithmetic +open Encodable UniformOracle CommonIdeal IndexMatrix + +abbrev OracleFamily := Oracles → ℕ → Oracle +abbrev ArithmeticOracle (B : OracleFamily) := + Arith (fun O v => B O (left v) (right v) = true) + +theorem query_at {B : OracleFamily} (hB : ArithmeticOracle B) + {c n : ℕ → ℕ} (hc : Primrec c) (hn : Primrec n) : + Arith (fun O v => B O (c v) (n v) = true) := + (hB.comp _ (Primrec₂.natPair.comp hc hn)).congr + (fun _ _ => by simp only [left,right,Nat.unpair_pair]) + +theorem bit_equal {B : OracleFamily} (hB : ArithmeticOracle B) + {c n a : ℕ → ℕ} (hc : Primrec c) (hn : Primrec n) (ha : Primrec a) : + Arith (fun O v => a v = bit (B O (c v) (n v))) := by + have h := query_at hB hc hn + exact ((h.and (equal ha (Primrec.const 1))).or + (h.neg.and (equal ha (Primrec.const 0)))).congr (fun O v => by + cases B O (c v) (n v) <;> simp [bit]) + +def table (c : ℕ) : List ℕ := (decode c).getD [] +def item (c k : ℕ) : ℕ := (table c).getD k 0 + +theorem table_primrec : Primrec table := + Primrec.option_getD.comp Primrec.decode (Primrec.const []) +theorem item_primrec : Primrec₂ item := + (Primrec.list_getD 0).comp (table_primrec.comp Primrec.fst) Primrec.snd + +def Prefix (B : Oracle) (m c : ℕ) : Prop := + (table c).length = m ∧ ∀ k, k < m → item c k = bit (B k) + +theorem prefix_iff (B : Oracle) (m c : ℕ) : + Prefix B m c ↔ table c = oraclePrefix (fun k => bit (B k)) m := by + constructor + · rintro ⟨hlen,he⟩ + apply List.ext_getElem + · simpa [oraclePrefix] using hlen + · intro k hk hk' + have hkm : k < m := by simpa [oraclePrefix] using hk' + have hh := he k hkm + simpa [item,List.getD_eq_getElem?_getD,List.getElem?_eq_getElem hk, + oraclePrefix] using hh + · intro he + constructor + · simp [he,oraclePrefix] + · intro k hk + simp [item,he,oraclePrefix,List.getD_eq_getElem?_getD,List.getElem?_range hk] + +theorem prefix_arith {B : OracleFamily} (hB : ArithmeticOracle B) + {c m l : ℕ → ℕ} (hc : Primrec c) (hm : Primrec m) (hl : Primrec l) : + Arith (fun O v => Prefix (B O (c v)) (m v) (l v)) := by + have hb := bit_equal hB (hc.comp left_primrec) right_primrec + (item_primrec.comp (hl.comp left_primrec) right_primrec) + have ht := ((less right_primrec (hm.comp left_primrec)).imp hb).all + exact ((equal (Primrec.list_length.comp (table_primrec.comp hl)) hm).and ht).congr + (fun _ _ => by simp only [Prefix,left,right,Nat.unpair_pair]) + +def trialTest (e n m t a : ℕ) : Prop := + (machine e).evaln t (Nat.pair (encode (table m)) n) = some a + +theorem trialTest_arith {e n m t a : ℕ → ℕ} + (he : Primrec e) (hn : Primrec n) (hm : Primrec m) (ht : Primrec t) (ha : Primrec a) : + Arith (fun _ v => trialTest (e v) (n v) (m v) (t v) (a v)) := by + apply Arith.pure + exact Primrec.eq.comp + (Nat.Partrec.Code.primrec_evaln.comp + ((ht.pair (machine_primrec.comp he)).pair + (Primrec₂.natPair.comp (Primrec.encode.comp (table_primrec.comp hm)) hn))) + (Primrec.option_some.comp ha) + +theorem run_arith {B : OracleFamily} (hB : ArithmeticOracle B) + {c e n z a : ℕ → ℕ} (hc : Primrec c) (he : Primrec e) (hn : Primrec n) + (hz : Primrec z) (ha : Primrec a) : + Arith (fun O v => TableIndices.run (B O (c v)) (machine (e v)) (n v) (z v) = some (a v)) := by + have hp := prefix_arith hB (hc.comp left_primrec) + ((left_primrec.comp hz).comp left_primrec) right_primrec + have ht := trialTest_arith (he.comp left_primrec) (hn.comp left_primrec) + right_primrec ((right_primrec.comp hz).comp left_primrec) (ha.comp left_primrec) + apply (hp.and ht).ex.congr + intro O v + simp only [left,right,Nat.unpair_pair] + constructor + · rintro ⟨l,hp,ht⟩ + rw [prefix_iff] at hp + simpa [trialTest,TableIndices.run,trial,hp] using ht + · intro ht + let L := oraclePrefix (fun k => bit (B O (c v) k)) (Nat.unpair (z v)).1 + refine ⟨encode L,?_,?_⟩ + · rw [prefix_iff] + simp [table,L] + · simpa [trialTest,table,L,TableIndices.run,trial] using ht + +end TuringRigidity.UniformArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTestApproximation.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTestApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2b98cc0e1699f55942d696ad71f90e85b737d81 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTestApproximation.lean @@ -0,0 +1,155 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticFiniteTest + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic +noncomputable section +attribute [local instance] Classical.propDecidable + +abbrev Approx := ℕ → Option ℕ + +def Extends (s t : Approx) : Prop := ∀ i a, s i = some a → t i = some a + +def Captures (s : Approx) (f : ℕ → ℕ) (N : ℕ) : Prop := ∀ i < N, s i = some (f i) + +theorem Captures.mono {s f N K} (h : Captures s f N) (hK : K ≤ N) : Captures s f K := + fun i hi => h i (lt_of_lt_of_le hi hK) + +namespace Term + +def approx (s : Approx) (v : ℕ) : Term → Option ℕ + | .input => some v + | .const n => some n + | .prim g _ t => (t.approx s v).bind (fun a => some (g a)) + | .pair t u => (t.approx s v).bind (fun a => (u.approx s v).bind (fun b => some (Nat.pair a b))) + | .witness t => (t.approx s v).bind s + +theorem approx_mono (t : Term) {s u : Approx} (h : Extends s u) (v a : ℕ) + (ha : t.approx s v = some a) : t.approx u v = some a := by + induction t generalizing a with + | input => exact ha + | const n => exact ha + | prim g hg t ih => + simp only [approx,Option.bind_eq_some_iff] at ha ⊢ + obtain ⟨b,hb,he⟩ := ha + exact ⟨b,ih b hb,he⟩ + | pair t w ih ik => + simp only [approx,Option.bind_eq_some_iff] at ha ⊢ + obtain ⟨b,hb,c,hc,he⟩ := ha + exact ⟨b,ih b hb,c,ik c hc,he⟩ + | witness t ih => + simp only [approx,Option.bind_eq_some_iff] at ha ⊢ + obtain ⟨b,hb,he⟩ := ha + exact ⟨b,ih b hb,h b a he⟩ + +@[simp] theorem approx_full (t : Term) (f : ℕ → ℕ) (v : ℕ) : + t.approx (fun i => some (f i)) v = some (t.eval f v) := by + induction t <;> simp_all [approx,eval] + +theorem approx_sound (t : Term) {s : Approx} {f : ℕ → ℕ} + (h : Extends s (fun i => some (f i))) (v a : ℕ) (ha : t.approx s v = some a) : + t.eval f v = a := by + simpa only [approx_full,Option.some.injEq] using t.approx_mono h v a ha + +theorem approx_complete (t : Term) (f : ℕ → ℕ) (v : ℕ) : + ∃ N, ∀ s : Approx, Captures s f N → t.approx s v = some (t.eval f v) := by + induction t with + | input => exact ⟨0,fun _ _ => rfl⟩ + | const n => exact ⟨0,fun _ _ => rfl⟩ + | prim g hg t ih => + obtain ⟨N,hN⟩ := ih + exact ⟨N,fun s hs => by simp [approx,eval,hN s hs]⟩ + | pair t u ih ik => + obtain ⟨N,hN⟩ := ih + obtain ⟨K,hK⟩ := ik + exact ⟨max N K,fun s hs => by + simp [approx,eval,hN s (hs.mono (le_max_left _ _)),hK s (hs.mono (le_max_right _ _))]⟩ + | witness t ih => + obtain ⟨N,hN⟩ := ih + refine ⟨max N (t.eval f v + 1),fun s hs => ?_⟩ + simp only [approx,hN s (hs.mono (le_max_left _ _)),Option.bind_some,eval] + exact hs _ (lt_of_lt_of_le (Nat.lt_succ_self _) (le_max_right _ _)) +end Term + +namespace Test + +def approx (O : Oracles) (s : Approx) (v : ℕ) : Test → Option Bool + | .pure P _ t => (t.approx s v).bind (fun a => some (decide (P a))) + | .query i t => (t.approx s v).bind (fun a => some (O i a)) + | .neg t => (t.approx O s v).bind (fun a => some (!a)) + | .and t u => (t.approx O s v).bind (fun a => (u.approx O s v).bind (fun b => some (a && b))) + +private theorem approx_mono (t : Test) (O : Oracles) {s u : Approx} (h : Extends s u) + (v : ℕ) (a : Bool) (ha : t.approx O s v = some a) : t.approx O u v = some a := by + induction t generalizing a with + | pure P hP t => + simp only [approx,Option.bind_eq_some_iff] at ha ⊢ + obtain ⟨b,hb,he⟩ := ha + exact ⟨b,t.approx_mono h v b hb,he⟩ + | query i t => + simp only [approx,Option.bind_eq_some_iff] at ha ⊢ + obtain ⟨b,hb,he⟩ := ha + exact ⟨b,t.approx_mono h v b hb,he⟩ + | neg t ih => + simp only [approx,Option.bind_eq_some_iff] at ha ⊢ + obtain ⟨b,hb,he⟩ := ha + exact ⟨b,ih b hb,he⟩ + | and t w ih ik => + simp only [approx,Option.bind_eq_some_iff] at ha ⊢ + obtain ⟨b,hb,c,hc,he⟩ := ha + exact ⟨b,ih b hb,c,ik c hc,he⟩ + +@[simp] theorem approx_full (t : Test) (O : Oracles) (f : ℕ → ℕ) (v : ℕ) : + t.approx O (fun i => some (f i)) v = some (decide (t.eval O f v)) := by + induction t with + | pure P hP t => + by_cases h : P (t.eval f v) <;> simp [approx,eval,h] + | query i t => cases h : O i (t.eval f v) <;> simp [approx,eval,h] + | neg t ih => by_cases h : t.eval O f v <;> simp [approx,eval,ih,h] + | and t w ih ik => + by_cases ht : t.eval O f v <;> by_cases hw : w.eval O f v <;> simp [approx,eval,ih,ik,ht,hw] + +theorem approx_sound (t : Test) (O : Oracles) {s : Approx} {f : ℕ → ℕ} + (h : Extends s (fun i => some (f i))) (v : ℕ) (a : Bool) + (ha : t.approx O s v = some a) : t.eval O f v ↔ a = true := by + have he : decide (t.eval O f v) = a := by + simpa only [approx_full,Option.some.injEq] using t.approx_mono O h v a ha + rw [← he] + simp + +theorem approx_complete (t : Test) (O : Oracles) (f : ℕ → ℕ) (v : ℕ) : + ∃ N, ∀ s : Approx, Captures s f N → + t.approx O s v = some (decide (t.eval O f v)) := by + induction t with + | pure P hP t => + obtain ⟨N,hN⟩ := t.approx_complete f v + refine ⟨N,fun s hs => ?_⟩ + rw [← approx_full] + simp only [approx,hN s hs,Term.approx_full] + | query i t => + obtain ⟨N,hN⟩ := t.approx_complete f v + refine ⟨N,fun s hs => ?_⟩ + rw [← approx_full] + simp only [approx,hN s hs,Term.approx_full] + | neg t ih => + obtain ⟨N,hN⟩ := ih + refine ⟨N,fun s hs => ?_⟩ + rw [← approx_full] + simp only [approx,hN s hs,approx_full] + | and t u ih ik => + obtain ⟨N,hN⟩ := ih + obtain ⟨K,hK⟩ := ik + refine ⟨max N K,fun s hs => ?_⟩ + rw [← approx_full] + simp only [approx,hN s (hs.mono (le_max_left _ _)),hK s (hs.mono (le_max_right _ _)),approx_full] + +theorem rejection_mono (t : Test) (O : Oracles) {s u : Approx} (h : Extends s u) + (v : ℕ) (ha : t.approx O s v = some false) : t.approx O u v = some false := + t.approx_mono O h v false ha +end Test + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTreeDefinability.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTreeDefinability.lean new file mode 100644 index 0000000000000000000000000000000000000000..609a77cdd24f8a28d42a3f1a14a066907255a103 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTreeDefinability.lean @@ -0,0 +1,110 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticWitnessTree +import Mathlib.Computability.Primrec.List + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic Encodable +noncomputable section +attribute [local instance] Classical.propDecidable + +theorem Term.approx_primrec (t : Term) : + Primrec (fun p : List ℕ × ℕ => t.approx (listApprox p.1) p.2) := by + induction t with + | input => exact Primrec.option_some.comp Primrec.snd + | const n => exact Primrec.const (some n) + | prim g hg t ih => + exact Primrec.option_bind ih (Primrec.option_some.comp (hg.comp Primrec.snd)) + | pair t u ih ik => + exact Primrec.option_bind ih (Primrec.option_bind (ik.comp Primrec.fst) + (Primrec.option_some.comp (Primrec₂.natPair.comp (Primrec.snd.comp Primrec.fst) Primrec.snd))) + | witness t ih => + exact Primrec.option_bind ih + (Primrec.list_getElem?.comp (Primrec.fst.comp Primrec.fst) Primrec.snd) + +private theorem option_neg_iff (a : Option Bool) (b : Bool) : + (a.bind (fun c => some (!c)) = some b) ↔ a = some (!b) := by + cases a with + | none => simp + | some a => cases a <;> cases b <;> decide + +private theorem option_and_true (a b : Option Bool) : + (a.bind (fun c => b.bind (fun d => some (c && d))) = some true) ↔ + a = some true ∧ b = some true := by + cases a with + | none => simp + | some a => cases b with + | none => simp + | some b => cases a <;> cases b <;> decide + +private theorem option_and_false (a b : Option Bool) : + (a.bind (fun c => b.bind (fun d => some (c && d))) = some false) ↔ + (a = some false ∧ b = some false) ∨ + (a = some false ∧ b = some true) ∨ (a = some true ∧ b = some false) := by + cases a with + | none => simp + | some a => cases b with + | none => simp + | some b => cases a <;> cases b <;> decide + +theorem Test.approx_arith (t : Test) {s : ℕ → List ℕ} (hs : Primrec s) + {v : ℕ → ℕ} (hv : Primrec v) (b : Bool) : + Arith (fun O k => t.approx O (listApprox (s k)) (v k) = some b) := by + induction t generalizing s v b with + | pure P hP t => + have hp : Primrec (fun k : ℕ => (t.approx (listApprox (s k)) (v k)).bind + (fun a => some (decide (P a)))) := Primrec.option_bind ((t.approx_primrec).comp (hs.pair hv)) + (Primrec.option_some.comp (hP.decide.comp Primrec.snd)) + exact .pure _ (Primrec.eq.comp hp (Primrec.const (some b))) + | query i t => + have ht := (t.approx_primrec).comp ((hs.comp left_primrec).pair (hv.comp left_primrec)) + have hh : Arith (fun _ k => t.approx (listApprox (s (left k))) (v (left k)) = some (right k)) := + .pure _ (Primrec.eq.comp ht (Primrec.option_some.comp right_primrec)) + have hq : Arith (fun O k => O i (right k) = b) := by + cases b with + | true => exact (Arith.query i).comp _ right_primrec + | false => + exact ((Arith.query i).comp _ right_primrec).neg.congr + (fun O k => by cases O i (right k) <;> simp) + exact (hh.and hq).ex.congr (fun O k => by + simp only [left,right,Nat.unpair_pair,Test.approx,Option.bind_eq_some_iff,Option.some.injEq]) + | neg t ih => + exact (ih hs hv (!b)).congr (fun O k => (option_neg_iff _ b).symm) + | and t u ih ik => + cases b with + | true => + exact ((ih hs hv true).and (ik hs hv true)).congr + (fun O k => (option_and_true _ _).symm) + | false => + exact (((ih hs hv false).and (ik hs hv false)).or + (((ih hs hv false).and (ik hs hv true)).or ((ih hs hv true).and (ik hs hv false)))).congr + (fun O k => (option_and_false _ _).symm) + +theorem Test.accepts_arith (t : Test) {s : ℕ → List ℕ} (hs : Primrec s) + {v : ℕ → ℕ} (hv : Primrec v) : Arith (fun O k => t.accepts O (v k) (s k)) := by + have hlen : Arith (fun _ k => right k < (s (left k)).length) := + .pure _ (Primrec.nat_lt.comp right_primrec (Primrec.list_length.comp (hs.comp left_primrec))) + have ht := t.approx_arith (hs.comp left_primrec) + (Primrec₂.natPair.comp (hv.comp left_primrec) right_primrec) false + exact (hlen.imp ht.neg).all.congr (fun O k => by + simp only [Test.accepts,left,right,Nat.unpair_pair]) + +def decodeNode (n : ℕ) : List ℕ := (decode (α := List ℕ) n).getD [] + +theorem decodeNode_primrec : Primrec decodeNode := + Primrec.option_getD.comp Primrec.decode (Primrec.const []) + +@[simp] theorem decodeNode_encode (s : List ℕ) : decodeNode (encode s) = s := by + simp [decodeNode] + +def Test.nodeCode (t : Test) (O : Oracles) (v : ℕ) : Oracle := + fun n => decide (t.accepts O v (decodeNode n)) + +theorem Test.nodeCode_arith (t : Test) (v : ℕ) : + Arith (fun O n => t.nodeCode O v n = true) := + (t.accepts_arith decodeNode_primrec (Primrec.const v)).congr (fun _ _ => by simp [Test.nodeCode]) + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTreeDescent.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTreeDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..786f2898835e0525da0d5baac0ea8d40be0e8b1a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTreeDescent.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelTreeRelations +import OAI.Computability.DegreeRigidity.Constructibility.PersistenceWitnessTree + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic SetModelReals SetModelSyntax SetModelFunctions +universe u +noncomputable section +attribute [local instance] Classical.propDecidable + +def unionRead (c : ℕ → ℕ) (i : ℕ) : ℕ := (decodeNode (c (i+1)))[i]?.getD 0 + +private theorem length_chain (c : ℕ → ℕ) + (hs : ∀ n, ∃ a, decodeNode (c (n+1)) = decodeNode (c n) ++ [a]) (n : ℕ) : + n ≤ (decodeNode (c n)).length := by + induction n with + | zero => omega + | succ n ih => + obtain ⟨a,ha⟩ := hs n + simp only [ha,List.length_append,List.length_singleton] + omega + +private theorem extends_chain (c : ℕ → ℕ) + (hs : ∀ n, ∃ a, decodeNode (c (n+1)) = decodeNode (c n) ++ [a]) + {i j : ℕ} (hij : i ≤ j) : Extends (listApprox (decodeNode (c i))) (listApprox (decodeNode (c j))) := by + induction j, hij using Nat.le_induction with + | base => exact fun _ _ h => h + | succ j hj ih => + obtain ⟨a,ha⟩ := hs j + intro k b hb + rw [ha] + exact listApprox_append _ _ k b (ih k b hb) + +theorem unionRead_captures (c : ℕ → ℕ) + (hs : ∀ n, ∃ a, decodeNode (c (n+1)) = decodeNode (c n) ++ [a]) (n : ℕ) : + Captures (listApprox (decodeNode (c n))) (unionRead c) n := by + intro i hi + have hil : i < (decodeNode (c (i+1))).length := + lt_of_lt_of_le (Nat.lt_succ_self _) (length_chain c hs _) + have he : (decodeNode (c (i+1)))[i]? = some ((decodeNode (c (i+1)))[i]) := + List.getElem?_eq_some_iff.mpr ⟨hil,rfl⟩ + have hv : unionRead c i = (decodeNode (c (i+1)))[i] := by simp [unionRead,he] + rw [hv] + exact extends_chain c hs (Nat.succ_le_of_lt hi) i _ he + +theorem Test.eval_of_descent (t : Test) (O : Oracles) (v : ℕ) (c : ℕ → ℕ) + (hc : ∀ n, t.edgePredicate O v (c (n+1)) (c n)) : + ∀ n, t.eval O (unionRead c) (Nat.pair v n) := by + have hs : ∀ n, ∃ a, decodeNode (c (n+1)) = decodeNode (c n) ++ [a] := fun n => (hc n).2.2 + intro n + obtain ⟨N,hN⟩ := t.approx_complete O (unionRead c) (Nat.pair v n) + let K := max N (n+1) + have he := hN (listApprox (decodeNode (c K))) ((unionRead_captures c hs K).mono (le_max_left _ _)) + have hnK : n < (decodeNode (c K)).length := + lt_of_lt_of_le (lt_of_lt_of_le (Nat.lt_succ_self _) (le_max_right _ _)) (length_chain c hs K) + have hh := (hc K).2.1.2 n hnK + by_contra hp + exact hh (he.trans (by simp [hp])) + +private theorem read_primrec : Primrec (fun p : ℕ × ℕ => (decodeNode p.1)[p.2]?.getD 0) := + Primrec.option_getD.comp (Primrec.list_getElem?.comp (decodeNode_primrec.comp Primrec.fst) Primrec.snd) + (Primrec.const 0) + +theorem union_real_mem {M : ZFSet.{u}} (C : Context M) (G : Oracle) (hG : G ∈ reals M) + (c : ℕ → ℕ) (hc : ∀ n k, G (Nat.pair n k) = true ↔ k = c n) : + Test.realPart (unionRead c) ∈ reals M := by + let idx : ℕ → ℕ := fun n => Nat.pair 0 n + have hi : Primrec idx := Primrec₂.natPair.comp (Primrec.const 0) Primrec.id + have hq := (Arith.query 0).comp + (fun n => Nat.pair (idx (left n)+1) (right n)) + (Primrec₂.natPair.comp (Primrec.succ.comp (hi.comp left_primrec)) right_primrec) + have hr : Arith (fun _ n => (decodeNode (right n))[idx (left n)]?.getD 0 = 1) := + .pure _ (Primrec.eq.comp (read_primrec.comp (right_primrec.pair (hi.comp left_primrec))) (Primrec.const 1)) + apply arithmetic_comprehension C (hq.and hr).ex (fun _ => G) (fun _ => hG) _ + intro n + simp only [left,right,Nat.unpair_pair] + change (∃ k, G (Nat.pair (idx n + 1) k) = true ∧ (decodeNode k)[idx n]?.getD 0 = 1) ↔ _ + simp only [hc,exists_eq_left,Test.realPart,unionRead,idx] + exact ⟨decide_eq_true,of_decide_eq_true⟩ + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTreeSequence.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTreeSequence.lean new file mode 100644 index 0000000000000000000000000000000000000000..e05de0dacc14b5dd326be7cf643ec5e9f434b19a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTreeSequence.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticTreeDefinability + +namespace OAI + + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic Encodable +noncomputable section + +def Test.codeChild (t : Test) (O : Oracles) (v x y : ℕ) : Prop := + t.accepts O v (decodeNode x) ∧ t.accepts O v (decodeNode y) ∧ + ∃ a, decodeNode x = decodeNode y ++ [a] + +theorem Test.codeChild_arith (t : Test) (v : ℕ) : + Arith (fun O k => t.codeChild O v (left k) (right k)) := by + have hx := t.accepts_arith (decodeNode_primrec.comp left_primrec) (Primrec.const v) + have hy := t.accepts_arith (decodeNode_primrec.comp right_primrec) (Primrec.const v) + have he : Arith (fun _ k => decodeNode (left (left k)) = decodeNode (right (left k)) ++ [right k]) := + .pure _ (Primrec.eq.comp (decodeNode_primrec.comp (left_primrec.comp left_primrec)) + (Primrec.list_append.comp (decodeNode_primrec.comp (right_primrec.comp left_primrec)) + (Primrec.list_cons.comp right_primrec (Primrec.const [])))) + exact (hx.and (hy.and he.ex)).congr (fun _ _ => by + simp only [Test.codeChild,left,right,Nat.unpair_pair]) + +def chainValue (s : ℕ → ℕ) (i : ℕ) : ℕ := ((decodeNode (s (i+1)))[i]?).getD 0 + +theorem code_chain_extends (s : ℕ → ℕ) + (h : ∀ n, ∃ a, decodeNode (s (n+1)) = decodeNode (s n) ++ [a]) + {i j : ℕ} (hij : i ≤ j) : + Extends (listApprox (decodeNode (s i))) (listApprox (decodeNode (s j))) := by + induction j, hij using Nat.le_induction with + | base => exact fun _ _ h => h + | succ j hj ih => + obtain ⟨a,ha⟩ := h j + intro k b hb + rw [ha] + exact listApprox_append _ _ k b (ih k b hb) + +theorem code_chain_length (s : ℕ → ℕ) + (h : ∀ n, ∃ a, decodeNode (s (n+1)) = decodeNode (s n) ++ [a]) (n : ℕ) : + n ≤ (decodeNode (s n)).length := by + induction n with + | zero => omega + | succ n ih => + obtain ⟨a,ha⟩ := h n + simp only [ha,List.length_append,List.length_singleton] + omega + +theorem code_chain_captures (s : ℕ → ℕ) + (h : ∀ n, ∃ a, decodeNode (s (n+1)) = decodeNode (s n) ++ [a]) (n : ℕ) : + Captures (listApprox (decodeNode (s n))) (chainValue s) n := by + intro i hi + have hil : i < (decodeNode (s (i+1))).length := + lt_of_lt_of_le (Nat.lt_succ_self _) (code_chain_length s h _) + have he : (decodeNode (s (i+1)))[i]? = some (chainValue s i) := by + simp only [chainValue,List.getElem?_eq_getElem hil,Option.getD_some] + exact code_chain_extends s h (Nat.succ_le_of_lt hi) i _ he + +theorem Test.code_chain_eval (t : Test) (O : Oracles) (v : ℕ) (s : ℕ → ℕ) + (h : ∀ n, t.codeChild O v (s (n+1)) (s n)) : + ∀ n, t.eval O (chainValue s) (Nat.pair v n) := by + intro n + have hstep := fun k => (h k).2.2 + obtain ⟨N,hN⟩ := t.approx_complete O (chainValue s) (Nat.pair v n) + let K := max N (n+1) + have he := hN (listApprox (decodeNode (s K))) + ((code_chain_captures s hstep K).mono (le_max_left _ _)) + have hn : n < (decodeNode (s K)).length := + lt_of_lt_of_le (lt_of_lt_of_le (Nat.lt_succ_self _) (le_max_right _ _)) + (code_chain_length s hstep K) + have hh := (h K).2.1 n hn + by_contra hp + exact hh (he.trans (by simp [hp])) + +theorem Test.code_chain_exists (t : Test) (O : Oracles) (v : ℕ) + (h : ∃ f : ℕ → ℕ, ∀ n, t.eval O f (Nat.pair v n)) : + ∃ s : ℕ → ℕ, ∀ n, t.codeChild O v (s (n+1)) (s n) := by + obtain ⟨f,hf⟩ := h + refine ⟨fun n => encode (initialSegment f n),fun n => ?_⟩ + simp only [Test.codeChild,decodeNode_encode] + exact ⟨(t.branch_iff O v f).mpr hf (n+1),(t.branch_iff O v f).mpr hf n, + f n,prefix_succ f n⟩ + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTruthRequirements.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTruthRequirements.lean new file mode 100644 index 0000000000000000000000000000000000000000..a6f48b20dabb006e910f779aaed87f7697ba01c0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticTruthRequirements.lean @@ -0,0 +1,133 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticPrefixFamilies + +namespace OAI + + +namespace TuringRigidity.ArithmeticTruthRequirements +open UniformArithmetic ArithmeticPrefixForcing ArithmeticPrefixFamilies +open ArithmeticGenericTruth FiniteShuffle ShuffleRequirements +open EncodedForcing (word word_primrec) + +theorem arithmetic_truth_requirements {P : Predicate} (hP : Arith P) : + ∃ Q D : PrefixPredicate, ArithmeticPrefix Q ∧ ArithmeticPrefix D ∧ + (∀ O v, Upward (Q O v)) ∧ + (∀ O v n, DenseOpen (D O (Nat.pair v n))) ∧ + ∀ O v G, GenericFor (fun n => D O (Nat.pair v n)) G → + (P (Function.update O 0 G) v ↔ G ∈ OpenSet (Q O v)) := by + have htrue : ArithmeticPrefix (fun _ _ _ => True) := + (equal (Primrec.const 0) (Primrec.const 0)).congr (fun _ _ => by simp) + induction hP with + | pure P hP => + refine ⟨fun _ v _ => P v, fun _ _ _ => True, .pure _ (hP.comp left_primrec), htrue, + fun _ _ _ _ _ h => h, fun _ _ _ => dense_true, ?_⟩ + intro O v G _ + exact (open_constant _ _).symm + | query i => + by_cases hi : i = 0 + · subst i + let Q : PrefixPredicate := fun _ v s => v < s.length ∧ s.getD v false = true + have hQ : ArithmeticPrefix Q := + (less left_primrec (Primrec.list_length.comp (word_primrec.comp right_primrec))).and + (.pure _ (Primrec.eq.comp ((Primrec.list_getD false).comp + (word_primrec.comp right_primrec) left_primrec) (Primrec.const true))) + refine ⟨Q,fun _ _ _ => True,hQ,htrue,?_,fun _ _ _ => dense_true,?_⟩ + · intro O v s t hst hs + exact ⟨lt_of_lt_of_le hs.1 hst.length_le, + (getD_of_prefix hst v hs.1).symm.trans hs.2⟩ + · intro O v G _ + simp only [Function.update_self] + constructor + · intro hv + refine ⟨initial G (v+1),⟨?_,?_⟩, + (realizes_initial _ _ _).mpr (fun _ _ => rfl)⟩ + · simp + · exact (prefix_getD G _ v (by omega)).trans hv + · rintro ⟨s,hs,hGs⟩ + exact (hGs v hs.1).symm.trans hs.2 + · refine ⟨fun O v _ => O i v = true, fun _ _ _ => True, (Arith.query i).comp _ left_primrec, htrue, + fun _ _ _ _ _ h => h, fun _ _ _ => dense_true, ?_⟩ + intro O v G _ + simpa only [Function.update_of_ne hi] using (open_constant (O i v = true) G).symm + | neg h ih => + obtain ⟨Q,D,hQ,hD,hup,hden,ht⟩ := ih + let E : PrefixPredicate := fun O v s => D O v s ∧ Decides (Q O (left v)) s + have hE : ArithmeticPrefix E := hD.and (prefix_comp (decides_arith hQ) left_primrec) + refine ⟨fun O v => Avoid (Q O v),E,avoids_arith hQ,hE, + fun O v => avoids_upward _,?_,?_⟩ + · intro O v n + simpa only [E,left,Nat.unpair_pair] using + dense_and (hden O v n) (decides_dense (Q O v) (hup O v)) + · intro O v G hG + have hGD : GenericFor (fun n => D O (Nat.pair v n)) G := by + intro n + obtain ⟨s,hs,hGs⟩ := hG n + exact ⟨s,hs.1,hGs⟩ + have hdec : G ∈ OpenSet (Decides (Q O v)) := by + obtain ⟨s,hs,hGs⟩ := hG 0 + exact ⟨s,by simpa only [left,Nat.unpair_pair] using hs.2,hGs⟩ + exact (not_congr (ht O v G hGD)).trans + (avoid_truth_of_decides (Q O v) (hup O v) G hdec).symm + | and h k ih ik => + obtain ⟨Q,D,hQ,hD,hQu,hDd,hQt⟩ := ih + obtain ⟨R,E,hR,hE,hRu,hEd,hRt⟩ := ik + let F : PrefixPredicate := fun O v s => + D O (Nat.pair (left v) (left (right v))) s ∧ + E O (Nat.pair (left v) (right (right v))) s + have hF : ArithmeticPrefix F := + (prefix_comp hD (Primrec₂.natPair.comp left_primrec (left_primrec.comp right_primrec))).and + (prefix_comp hE (Primrec₂.natPair.comp left_primrec (right_primrec.comp right_primrec))) + refine ⟨fun O v s => Q O v s ∧ R O v s,F,hQ.and hR,hF, + fun O v s t hst hs => ⟨hQu O v s t hst hs.1,hRu O v s t hst hs.2⟩,?_,?_⟩ + · intro O v n + simpa only [F,left,right,Nat.unpair_pair] using + dense_and (hDd O v (left n)) (hEd O v (right n)) + · intro O v G hG + have hGD : GenericFor (fun n => D O (Nat.pair v n)) G := by + intro n + obtain ⟨s,hs,hGs⟩ := hG (Nat.pair n 0) + exact ⟨s,by simpa only [left,right,Nat.unpair_pair] using hs.1,hGs⟩ + have hGE : GenericFor (fun n => E O (Nat.pair v n)) G := by + intro n + obtain ⟨s,hs,hGs⟩ := hG (Nat.pair 0 n) + exact ⟨s,by simpa only [left,right,Nat.unpair_pair] using hs.2,hGs⟩ + exact (and_congr (hQt O v G hGD) (hRt O v G hGE)).trans + (open_and (Q O v) (R O v) (hQu O v) (hRu O v) G).symm + | ex h ih => + obtain ⟨Q,D,hQ,hD,hup,hden,ht⟩ := ih + let E : PrefixPredicate := fun O v => + D O (Nat.pair (Nat.pair (left v) (left (right v))) (right (right v))) + have hE : ArithmeticPrefix E := prefix_comp hD + (Primrec₂.natPair.comp + (Primrec₂.natPair.comp left_primrec (left_primrec.comp right_primrec)) + (right_primrec.comp right_primrec)) + refine ⟨fun O v s => ∃ n, Q O (Nat.pair v n) s,E,prefix_exists hQ,hE,?_,?_,?_⟩ + · rintro O v s t hst ⟨n,hn⟩ + exact ⟨n,hup O _ s t hst hn⟩ + · intro O v n + simpa only [E,left,right,Nat.unpair_pair] using + hden O (Nat.pair v (left n)) (right n) + · intro O v G hG + have hGD (n : ℕ) : GenericFor (fun k => D O (Nat.pair (Nat.pair v n) k)) G := by + intro k + simpa only [E,left,right,Nat.unpair_pair] using hG (Nat.pair n k) + constructor + · rintro ⟨n,hn⟩ + obtain ⟨s,hs,hGs⟩ := (ht O _ G (hGD n)).mp hn + exact ⟨s,⟨n,hs⟩,hGs⟩ + · rintro ⟨s,⟨n,hs⟩,hGs⟩ + exact ⟨n,(ht O _ G (hGD n)).mpr ⟨s,hs,hGs⟩⟩ + | comp f h hf ih => + obtain ⟨Q,D,hQ,hD,hup,hden,ht⟩ := ih + let E : PrefixPredicate := fun O v => D O (Nat.pair (f (left v)) (right v)) + refine ⟨fun O v => Q O (f v),E,prefix_comp hQ hf, + prefix_comp hD (Primrec₂.natPair.comp (hf.comp left_primrec) right_primrec), + fun O v => hup O (f v),?_,?_⟩ + · intro O v n + simpa only [E,left,right,Nat.unpair_pair] using hden O (f v) n + · intro O v G hG + apply ht O (f v) G + simpa only [E,left,right,Nat.unpair_pair] using hG + +end TuringRigidity.ArithmeticTruthRequirements + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticWitnessTree.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticWitnessTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bb7688d9723a561c70183400b6d640c8657e646 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ArithmeticWitnessTree.lean @@ -0,0 +1,127 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticTestApproximation +import Mathlib.SetTheory.Descriptive.Tree +import Mathlib.Order.WellFounded + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic +noncomputable section +attribute [local instance] Classical.propDecidable + +abbrev listApprox (s : List ℕ) : Approx := fun i => s[i]? + +theorem listApprox_append (s t : List ℕ) : Extends (listApprox s) (listApprox (s ++ t)) := by + intro i a ha + obtain ⟨hi,_⟩ := List.getElem?_eq_some_iff.mp ha + simpa only [listApprox,List.getElem?_append_left hi] using ha + +def initialSegment (f : ℕ → ℕ) (n : ℕ) : List ℕ := List.ofFn (fun i : Fin n => f i.val) + +@[simp] theorem prefix_length (f : ℕ → ℕ) (n : ℕ) : (initialSegment f n).length = n := by + simp [initialSegment] + +theorem prefix_succ (f : ℕ → ℕ) (n : ℕ) : initialSegment f (n+1) = initialSegment f n ++ [f n] := by + unfold initialSegment + rw [List.ofFn_succ_last] + rfl + +theorem prefix_captures (f : ℕ → ℕ) (n : ℕ) : Captures (listApprox (initialSegment f n)) f n := by + intro i hi + simp [listApprox,initialSegment,hi] + +theorem prefix_extends (f : ℕ → ℕ) (n : ℕ) : + Extends (listApprox (initialSegment f n)) (fun i => some (f i)) := by + intro i a ha + obtain ⟨hi,he⟩ := List.getElem?_eq_some_iff.mp ha + simp only [prefix_length] at hi + have hb := prefix_captures f n i hi + exact hb.symm.trans ha + +namespace Test + +def accepts (t : Test) (O : Oracles) (v : ℕ) (s : List ℕ) : Prop := + ∀ n < s.length, t.approx O (listApprox s) (Nat.pair v n) ≠ some false + +def tree (t : Test) (O : Oracles) (v : ℕ) : Descriptive.tree ℕ := + ⟨{s | t.accepts O v s},by + intro s a h n hn he + exact h n (by simp; omega) (t.rejection_mono O (listApprox_append s [a]) _ he)⟩ + +theorem branch_iff (t : Test) (O : Oracles) (v : ℕ) (f : ℕ → ℕ) : + (∀ N, initialSegment f N ∈ t.tree O v) ↔ ∀ n, t.eval O f (Nat.pair v n) := by + constructor + · intro h n + obtain ⟨N,hN⟩ := t.approx_complete O f (Nat.pair v n) + let K := max N (n+1) + have he := hN (listApprox (initialSegment f K)) ((prefix_captures f K).mono (le_max_left _ _)) + have hn : n < (initialSegment f K).length := by simp [K] + have hh := h K n hn + by_contra hp + exact hh (he.trans (by simp [hp])) + · intro h N n hn he + have ha := (t.approx_sound O (prefix_extends f N) _ false he).mp (h n) + exact Bool.false_ne_true ha + +def Child (t : Test) (O : Oracles) (v : ℕ) (s r : t.tree O v) : Prop := + ∃ a, s.val = r.val ++ [a] + +private theorem chain_extends (s : ℕ → List ℕ) + (h : ∀ n, ∃ a, s (n+1) = s n ++ [a]) {i j : ℕ} (hij : i ≤ j) : + Extends (listApprox (s i)) (listApprox (s j)) := by + induction j, hij using Nat.le_induction with + | base => exact fun _ _ h => h + | succ j hj ih => + obtain ⟨a,ha⟩ := h j + intro k b hb + rw [ha] + exact listApprox_append _ _ k b (ih k b hb) + +private theorem chain_length (s : ℕ → List ℕ) + (h : ∀ n, ∃ a, s (n+1) = s n ++ [a]) (n : ℕ) : n ≤ (s n).length := by + induction n with + | zero => omega + | succ n ih => + obtain ⟨a,ha⟩ := h n + simp only [ha,List.length_append,List.length_singleton] + omega + +private theorem chain_union (s : ℕ → List ℕ) + (h : ∀ n, ∃ a, s (n+1) = s n ++ [a]) : + ∃ f : ℕ → ℕ, ∀ n, Captures (listApprox (s n)) f n := by + have hex : ∀ i, ∃ a, (s (i+1))[i]? = some a := by + intro i + have hi : i < (s (i+1)).length := lt_of_lt_of_le (Nat.lt_succ_self _) (chain_length s h _) + exact ⟨(s (i+1))[i],List.getElem?_eq_some_iff.mpr ⟨hi,rfl⟩⟩ + choose f hf using hex + refine ⟨f,fun n i hi => ?_⟩ + exact chain_extends s h (Nat.succ_le_of_lt hi) i (f i) (hf i) + +theorem wellFounded_iff (t : Test) (O : Oracles) (v : ℕ) : + WellFounded (t.Child O v) ↔ ¬ ∃ f : ℕ → ℕ, ∀ n, t.eval O f (Nat.pair v n) := by + rw [wellFounded_iff_isEmpty_descending_chain] + constructor + · intro hw ⟨f,hf⟩ + let nodes : ℕ → t.tree O v := fun n => ⟨initialSegment f n,(t.branch_iff O v f).mpr hf n⟩ + exact hw.false ⟨nodes,fun n => ⟨f n,prefix_succ f n⟩⟩ + · intro h + refine ⟨fun ⟨nodes,hn⟩ => ?_⟩ + let s : ℕ → List ℕ := fun n => (nodes n).val + have hs : ∀ n, ∃ a, s (n+1) = s n ++ [a] := hn + obtain ⟨f,hf⟩ := chain_union s hs + apply h + refine ⟨f,fun n => ?_⟩ + obtain ⟨N,hN⟩ := t.approx_complete O f (Nat.pair v n) + let K := max N (n+1) + have he := hN (listApprox (s K)) ((hf K).mono (le_max_left _ _)) + have hnK : n < (s K).length := + lt_of_lt_of_le (lt_of_lt_of_le (Nat.lt_succ_self _) (le_max_right _ _)) (chain_length s hs K) + have hh := (nodes K).property n hnK + by_contra hp + exact hh (he.trans (by simp [hp])) +end Test + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/BinaryCut.lean b/lean/OAI/Computability/DegreeRigidity/Computability/BinaryCut.lean new file mode 100644 index 0000000000000000000000000000000000000000..06713aababdc808a8e3a0851e864c76c5cfe3d1b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/BinaryCut.lean @@ -0,0 +1,99 @@ +import OAI.Computability.DegreeRigidity.Computability.BinaryMachine + +namespace OAI + +namespace TuringRigidity.BinarySeries +open UniformOracle RationalCoding Encodable Filter + +def approxDecision (z : ℕ × ℕ × ℕ) : Option ℕ := + if fracLeft (z.1,z.2.2,2^z.2.1) < fracRight (z.1,z.2.2,2^z.2.1) then some 1 + else if fracRight (z.1,z.2.2+1,2^z.2.1) < fracLeft (z.1,z.2.2+1,2^z.2.1) then some 0 + else none + +theorem approxDecision_primrec : Primrec approxDecision := by + have hD : Primrec (fun z : ℕ × ℕ × ℕ => 2^z.2.1) := powTwo_primrec.comp (Primrec.fst.comp Primrec.snd) + have hlo := Primrec.fst.pair ((Primrec.snd.comp Primrec.snd).pair hD) + have hhi := Primrec.fst.pair ((Primrec.succ.comp (Primrec.snd.comp Primrec.snd)).pair hD) + exact Primrec.ite (Primrec.nat_lt.comp (fracLeft_primrec.comp hlo) (fracRight_primrec.comp hlo)) + (Primrec.const (some 1)) + (Primrec.ite (Primrec.nat_lt.comp (fracRight_primrec.comp hhi) (fracLeft_primrec.comp hhi)) + (Primrec.const (some 0)) (Primrec.const none)) + +def approxTrial (B : Oracle) (q n : ℕ) : Option ℕ := approxDecision (q,n,numeral B n) + +theorem approxTrial_recursive (B : Oracle) : + Nat.RecursiveIn {oracleFunction B} + (fun z => Part.some (encode (approxTrial B (Nat.unpair z).1 (Nat.unpair z).2))) := by + have hq := total_primrec (O := {oracleFunction B}) (Primrec.fst.comp Primrec.unpair) + have hn := total_primrec (O := {oracleFunction B}) (Primrec.snd.comp Primrec.unpair) + have hk := total_comp (numeral_recursive B) hn + have hdec := Primrec.encode.comp (approxDecision_primrec.comp + ((Primrec.fst.comp Primrec.unpair).pair (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)))) + exact (total_comp (total_primrec hdec) (total_pair hq (total_pair hn hk))).of_eq + (fun z => by simp [approxTrial]) + +theorem approxTrial_sound (B : Oracle) (q n a : ℕ) (ha : a ∈ approxTrial B q n) : + a = if cut (value B) q then 1 else 0 := by + have hb := bracket B n + unfold approxTrial approxDecision at ha + split at ha + · rename_i h + have hq := (frac_lt_iff q (numeral B n) (2^n) (by positivity)).mp h + have hc : cut (value B) q = true := (cut_eq_true _ _).mpr (lt_of_lt_of_le (by simpa using hq) hb.1) + simpa [hc] using (Option.mem_def.mp ha).symm + · split at ha + · rename_i h + have hq := (lt_frac_iff q (numeral B n+1) (2^n) (by positivity)).mp h + have hc : cut (value B) q = false := Bool.eq_false_iff.mpr (fun hc => by + have hh := (cut_eq_true _ _).mp hc + push_cast at hq + linarith) + simpa [hc] using (Option.mem_def.mp ha).symm + · simp at ha + +theorem small_width (ε : ℝ) (hε : 0 < ε) : ∃ n : ℕ, (2^n : ℝ)⁻¹ < ε := by + have ht : Tendsto (fun n : ℕ => (2^n : ℝ)⁻¹) atTop (nhds 0) := by + simpa only [inv_pow] using + (tendsto_pow_atTop_nhds_zero_of_abs_lt_one (by norm_num : |(2:ℝ)⁻¹| < 1)) + exact (ht.eventually (eventually_lt_nhds hε)).exists + +theorem approxTrial_complete (B : Oracle) (hi : Irrational (value B)) (q : ℕ) : + ∃ n a, a ∈ approxTrial B q n := by + have hne : (rationalEnumeration q : ℝ) ≠ value B := fun h => hi ⟨_,h⟩ + rcases lt_or_gt_of_ne hne with hq | hq + · obtain ⟨n,hn⟩ := small_width (value B - rationalEnumeration q) (by linarith) + have hb := bracket B n + have hl : (rationalEnumeration q : ℝ) < (numeral B n : ℝ)/(2^n : ℕ) := by + push_cast + rw [add_div] at hb + simp only [one_div] at hb + linarith + have hd := (frac_lt_iff q (numeral B n) (2^n) (by positivity)).mpr hl + exact ⟨n,1,by simp [approxTrial,approxDecision,hd]⟩ + · obtain ⟨n,hn⟩ := small_width (rationalEnumeration q - value B) (by linarith) + have hb := bracket B n + have hu : ((numeral B n+1 : ℕ) : ℝ)/(2^n : ℕ) < rationalEnumeration q := by + push_cast + rw [add_div] + simp only [one_div] + linarith + have hd := (lt_frac_iff q (numeral B n+1) (2^n) (by positivity)).mpr hu + have hl : ¬ fracLeft (q,numeral B n,2^n) < fracRight (q,numeral B n,2^n) := by + intro hh + have hh' := (frac_lt_iff q (numeral B n) (2^n) (by positivity)).mp hh + push_cast at hh' + linarith [hb.1] + exact ⟨n,0,by simp [approxTrial,approxDecision,hl,hd]⟩ + +theorem cut_reduces (B : Oracle) (hi : Irrational (value B)) : Reduces (cut (value B)) B := by + apply RecursiveIn.iff_nat.mpr + exact total_search (approxTrial_recursive B) _ (approxTrial_sound B) (approxTrial_complete B hi) + +theorem cut_single_program (B : Oracle) (hi : Irrational (value B)) : + ∃ p : OracleCode, ∀ q, OracleCode.eval (oracleFunction B) p q = oracleFunction (cut (value B)) q := by + obtain ⟨p,hp⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp (cut_reduces B hi) + exact ⟨p,fun q => congrFun hp q⟩ + +end TuringRigidity.BinarySeries + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/BinaryMachine.lean b/lean/OAI/Computability/DegreeRigidity/Computability/BinaryMachine.lean new file mode 100644 index 0000000000000000000000000000000000000000..978aec1d8665077c9c637d418fa2f33b742bea0a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/BinaryMachine.lean @@ -0,0 +1,110 @@ +import OAI.Computability.DegreeRigidity.Computability.BinarySeries +import OAI.Computability.DegreeRigidity.Computability.RationalCut + +namespace OAI + +namespace TuringRigidity.BinarySeries +open UniformOracle RationalCoding Encodable + +theorem eventually_constant_reduces (B A : Oracle) (b : Bool) (N : ℕ) + (h : ∀ n, N ≤ n → B n = b) : Reduces B A := by + let L := (List.range N).map (bit B) + let d : ℕ := if b then 1 else 0 + have hp : Primrec (fun n => L.getD n d) := (Primrec.list_getD d).comp (Primrec.const L) Primrec.id + have he (n : ℕ) : L.getD n d = bit B n := by + by_cases hn : n < N + · simp [L, List.getD, List.getElem?_map, List.getElem?_range hn] + · have hb := h n (by omega) + have hz : (List.range N)[n]? = none := List.getElem?_eq_none (by simp; omega) + simp [L, List.getD, hz, bit, hb, d] + apply RecursiveIn.iff_nat.mpr + exact total_primrec (hp.of_eq he) + +theorem mixed_of_noncomputable (B : Oracle) (h : ¬ Reduces B (fun _ => false)) : Mixed B := by + intro N + constructor + · by_contra hn + push Not at hn + apply h + exact eventually_constant_reduces B _ false N (fun n hN => Bool.eq_false_iff.mpr (hn n hN)) + · by_contra hn + push Not at hn + apply h + exact eventually_constant_reduces B _ true N (fun n hN => Bool.eq_true_of_not_eq_false (hn n hN)) + +def foldNumeral (L : List ℕ) : ℕ := L.foldl (fun a b => 2*a+b) 0 + +theorem foldNumeral_primrec : Primrec foldNumeral := + Primrec.list_foldl Primrec.id (Primrec.const 0) + ((Primrec.nat_add.comp (Primrec.nat_mul.comp (Primrec.const 2) Primrec.fst) Primrec.snd).comp Primrec.snd).to₂ + +theorem foldNumeral_prefix (B : Oracle) (n : ℕ) : + foldNumeral (oraclePrefix (bit B) n) = numeral B n := by + induction n with + | zero => rfl + | succ n ih => + simpa [foldNumeral, oraclePrefix, List.range_succ, List.foldl_append, numeral] using + congrArg (fun a => 2*a+bit B n) ih + +theorem numeral_recursive (B : Oracle) : + Nat.RecursiveIn {oracleFunction B} (fun n => Part.some (numeral B n)) := by + have hf := total_comp (total_primrec (foldNumeral_primrec.comp + (Primrec.option_getD_default.comp Primrec.decode))) (prefix_recursive (bit B)) + exact hf.of_eq (fun n => by simp only [encodek, Option.getD_some, foldNumeral_prefix]) + +theorem powTwo_primrec : Primrec (fun n : ℕ => 2^n) := by + have hp : Primrec (fun n : ℕ => (List.range n).foldl (fun a _ => 2*a) 1) := + Primrec.list_foldl Primrec.list_range (Primrec.const 1) + ((Primrec.nat_mul.comp (Primrec.const 2) Primrec.fst).comp Primrec.snd).to₂ + apply hp.of_eq + intro n + induction n with + | zero => simp + | succ n ih => + simp only [List.range_succ, List.foldl_append, List.foldl_cons, List.foldl_nil] + rw [ih, pow_succ, Nat.mul_comm] + +def fracLeft (z : ℕ × ℕ × ℕ) : ℕ := positiveNumerator z.1 * z.2.2 +def fracRight (z : ℕ × ℕ × ℕ) : ℕ := z.2.1 * denominator z.1 + negativeNumerator z.1 * z.2.2 + +theorem fracLeft_primrec : Primrec fracLeft := Primrec.nat_mul.comp + (positiveNumerator_primrec.comp Primrec.fst) (Primrec.snd.comp Primrec.snd) +theorem fracRight_primrec : Primrec fracRight := Primrec.nat_add.comp + (Primrec.nat_mul.comp (Primrec.fst.comp Primrec.snd) (denominator_primrec.comp Primrec.fst)) + (Primrec.nat_mul.comp (negativeNumerator_primrec.comp Primrec.fst) (Primrec.snd.comp Primrec.snd)) + +theorem frac_lt_iff (q k D : ℕ) (hD : 0 < D) : + fracLeft (q,k,D) < fracRight (q,k,D) ↔ (rationalEnumeration q : ℝ) < (k : ℝ)/D := by + rw [signed_query_value, div_lt_div_iff₀ (by exact_mod_cast denominator_pos q) (by exact_mod_cast hD)] + unfold fracLeft fracRight + constructor <;> intro h + · have hh : (positiveNumerator q : ℝ)*D < k*denominator q + negativeNumerator q*D := by exact_mod_cast h + nlinarith + · have hh : (positiveNumerator q : ℝ)*D < k*denominator q + negativeNumerator q*D := by nlinarith + exact_mod_cast hh + +theorem lt_frac_iff (q k D : ℕ) (hD : 0 < D) : + fracRight (q,k,D) < fracLeft (q,k,D) ↔ (k : ℝ)/D < (rationalEnumeration q : ℝ) := by + rw [signed_query_value, div_lt_div_iff₀ (by exact_mod_cast hD) (by exact_mod_cast denominator_pos q)] + unfold fracLeft fracRight + constructor <;> intro h + · have hh : k* (denominator q : ℝ) + negativeNumerator q*D < positiveNumerator q*D := by exact_mod_cast h + nlinarith + · have hh : k* (denominator q : ℝ) + negativeNumerator q*D < positiveNumerator q*D := by nlinarith + exact_mod_cast hh + +theorem frac_eq_iff (q k D : ℕ) (hD : 0 < D) : + fracLeft (q,k,D) = fracRight (q,k,D) ↔ (rationalEnumeration q : ℝ) = (k : ℝ)/D := by + constructor + · intro he + apply le_antisymm + · exact le_of_not_gt (fun h => by have := (lt_frac_iff q k D hD).mpr h; omega) + · exact le_of_not_gt (fun h => by have := (frac_lt_iff q k D hD).mpr h; omega) + · intro he + apply Nat.le_antisymm + · exact Nat.le_of_not_gt (fun h => by have := (lt_frac_iff q k D hD).mp h; linarith) + · exact Nat.le_of_not_gt (fun h => by have := (frac_lt_iff q k D hD).mp h; linarith) + +end TuringRigidity.BinarySeries + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/BinaryRecovery.lean b/lean/OAI/Computability/DegreeRigidity/Computability/BinaryRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8cc7a2f2fed0f0dfb621cac1d81131e841fac19 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/BinaryRecovery.lean @@ -0,0 +1,131 @@ +import OAI.Computability.DegreeRigidity.Computability.BinaryMachine + +namespace OAI + +namespace TuringRigidity.BinarySeries +open UniformOracle RationalCoding Encodable + +def recoverGuard (z : ℕ × ℕ × ℕ × ℕ) : Prop := + fracLeft (z.2.2.1,z.2.1,2^(z.1+1)) = fracRight (z.2.2.1,z.2.1,2^(z.1+1)) ∧ + fracLeft (z.2.2.2,z.2.1+1,2^(z.1+1)) = fracRight (z.2.2.2,z.2.1+1,2^(z.1+1)) +instance (z : ℕ × ℕ × ℕ × ℕ) : Decidable (recoverGuard z) := inferInstanceAs (Decidable (_ ∧ _)) + +theorem recoverGuard_primrec : PrimrecPred recoverGuard := by + have hn : Primrec (fun z : ℕ × ℕ × ℕ × ℕ => 2^(z.1+1)) := + powTwo_primrec.comp (Primrec.succ.comp Primrec.fst) + have hk : Primrec (fun z : ℕ × ℕ × ℕ × ℕ => z.2.1) := Primrec.fst.comp Primrec.snd + have hi : Primrec (fun z : ℕ × ℕ × ℕ × ℕ => z.2.2.1) := Primrec.fst.comp (Primrec.snd.comp Primrec.snd) + have hj : Primrec (fun z : ℕ × ℕ × ℕ × ℕ => z.2.2.2) := Primrec.snd.comp (Primrec.snd.comp Primrec.snd) + exact (Primrec.eq.comp (fracLeft_primrec.comp (hi.pair (hk.pair hn))) + (fracRight_primrec.comp (hi.pair (hk.pair hn)))).and + (Primrec.eq.comp (fracLeft_primrec.comp (hj.pair ((Primrec.succ.comp hk).pair hn))) + (fracRight_primrec.comp (hj.pair ((Primrec.succ.comp hk).pair hn)))) + +def recoverDecision (z : (ℕ × ℕ × ℕ × ℕ) × (ℕ × ℕ)) : Option ℕ := + if recoverGuard z.1 ∧ z.2.1=1 ∧ z.2.2=0 then some (z.1.2.1%2) else none + +theorem recoverDecision_primrec : Primrec recoverDecision := + Primrec.ite ((recoverGuard_primrec.comp Primrec.fst).and + ((Primrec.eq.comp (Primrec.fst.comp Primrec.snd) (Primrec.const 1)).and + (Primrec.eq.comp (Primrec.snd.comp Primrec.snd) (Primrec.const 0)))) + (Primrec.option_some.comp (Primrec.nat_mod.comp + (Primrec.fst.comp (Primrec.snd.comp Primrec.fst)) (Primrec.const 2))) (Primrec.const none) + +noncomputable def recoverTrial (B : Oracle) (n m : ℕ) : Option ℕ := + let k := (Nat.unpair m).1 + let i := (Nat.unpair (Nat.unpair m).2).1 + let j := (Nat.unpair (Nat.unpair m).2).2 + recoverDecision ((n,k,i,j),(bit (cut (value B)) i,bit (cut (value B)) j)) + +theorem recoverTrial_recursive (B : Oracle) : + Nat.RecursiveIn {oracleFunction (cut (value B))} + (fun z => Part.some (encode (recoverTrial B (Nat.unpair z).1 (Nat.unpair z).2))) := by + let O : Set (ℕ →. ℕ) := {oracleFunction (cut (value B))} + have hn := total_primrec (O := O) (Primrec.fst.comp Primrec.unpair) + have hm := total_primrec (O := O) (Primrec.snd.comp Primrec.unpair) + have hk := total_comp (total_primrec (Primrec.fst.comp Primrec.unpair)) hm + have hi := total_comp (total_primrec (Primrec.fst.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)))) hm + have hj := total_comp (total_primrec (Primrec.snd.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)))) hm + have hg : Nat.RecursiveIn O (oracleFunction (cut (value B))) := .oracle _ (Set.mem_singleton _) + have hmeta := total_pair hn (total_pair hk (total_pair hi hj)) + have hbits := total_pair (total_comp hg hi) (total_comp hg hj) + have hdecode : Primrec (fun z : ℕ => + (((Nat.unpair (Nat.unpair z).1).1, + (Nat.unpair (Nat.unpair (Nat.unpair z).1).2).1, + Nat.unpair (Nat.unpair (Nat.unpair (Nat.unpair z).1).2).2),Nat.unpair (Nat.unpair z).2)) := by + exact (((Primrec.fst.comp Primrec.unpair).pair + (((Primrec.fst.comp Primrec.unpair).pair (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair))).comp + (Primrec.snd.comp Primrec.unpair))).comp (Primrec.fst.comp Primrec.unpair)).pair + (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)) + exact (total_comp (total_primrec (Primrec.encode.comp (recoverDecision_primrec.comp hdecode))) + (total_pair hmeta hbits)).of_eq (fun z => by simp [recoverTrial,bit]) + +theorem recoverTrial_sound (B : Oracle) (hB : Mixed B) (n m a : ℕ) + (ha : a ∈ recoverTrial B n m) : a = bit B n := by + let k := (Nat.unpair m).1 + let i := (Nat.unpair (Nat.unpair m).2).1 + let j := (Nat.unpair (Nat.unpair m).2).2 + change a ∈ recoverDecision ((n,k,i,j),(bit (cut (value B)) i,bit (cut (value B)) j)) at ha + unfold recoverDecision at ha + split at ha + · rename_i h + have hai : a=k%2 := by simpa using (Option.mem_def.mp ha).symm + have hi := (frac_eq_iff i k (2^(n+1)) (by positivity)).mp h.1.1 + have hj := (frac_eq_iff j (k+1) (2^(n+1)) (by positivity)).mp h.1.2 + have hci : cut (value B) i=true := by cases hh : cut (value B) i <;> simp_all [bit] + have hcj : cut (value B) j=false := by cases hh : cut (value B) j <;> simp_all [bit] + have hlo := (cut_eq_true _ _).mp hci + have hup : value B ≤ (rationalEnumeration j : ℝ) := le_of_not_gt (fun hh => by + have := (cut_eq_true _ _).mpr hh; simp_all) + rw [hi] at hlo + rw [hj] at hup + have hb := strict_bracket B hB (n+1) + have hD : (0 : ℝ) < (2^(n+1) : ℝ) := by positivity + have hk1 : (k : ℝ) < numeral B (n+1)+1 := by + have hh := lt_trans hlo hb.2 + push_cast at hh + exact (div_lt_div_iff_of_pos_right hD).mp hh + have hk2 : (numeral B (n+1) : ℝ) < k+1 := by + have hh := lt_of_lt_of_le hb.1 hup + push_cast at hh + exact (div_lt_div_iff_of_pos_right hD).mp hh + have hk : k = numeral B (n+1) := by + have h1 : k < numeral B (n+1)+1 := by exact_mod_cast hk1 + have h2 : numeral B (n+1) < k+1 := by exact_mod_cast hk2 + omega + rw [hai,hk,numeral] + unfold bit + split <;> omega + · simp at ha + +theorem recoverTrial_complete (B : Oracle) (hB : Mixed B) (n : ℕ) : + ∃ m a, a ∈ recoverTrial B n m := by + let k := numeral B (n+1) + let i := encode ((k : ℚ)/2^(n+1)) + let j := encode (((k+1 : ℕ) : ℚ)/2^(n+1)) + have hi : (rationalEnumeration i : ℝ) = (k : ℝ)/(2^(n+1) : ℕ) := by simp [i,rationalEnumeration] + have hj : (rationalEnumeration j : ℝ) = ((k+1 : ℕ) : ℝ)/(2^(n+1) : ℕ) := by simp [j,rationalEnumeration] + have hg : recoverGuard (n,k,i,j) := ⟨(frac_eq_iff _ _ _ (by positivity)).mpr hi, + (frac_eq_iff _ _ _ (by positivity)).mpr hj⟩ + have hb := strict_bracket B hB (n+1) + have hci : cut (value B) i=true := (cut_eq_true _ _).mpr (by simpa [hi,k] using hb.1) + have hcj : cut (value B) j=false := Bool.eq_false_iff.mpr (fun hh => by + have hh' := (cut_eq_true _ _).mp hh + rw [hj] at hh' + push_cast at hh' + dsimp only [k] at hh' + linarith [hb.2]) + exact ⟨Nat.pair k (Nat.pair i j),k%2,by simp [recoverTrial,recoverDecision,bit,hci,hcj,hg]⟩ + +theorem set_reduces_cut (B : Oracle) (hB : Mixed B) : Reduces B (cut (value B)) := by + apply RecursiveIn.iff_nat.mpr + exact total_search (recoverTrial_recursive B) _ (recoverTrial_sound B hB) (recoverTrial_complete B hB) + +theorem set_single_program (B : Oracle) (hB : Mixed B) : + ∃ p : OracleCode, ∀ n, OracleCode.eval (oracleFunction (cut (value B))) p n = oracleFunction B n := by + obtain ⟨p,hp⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp (set_reduces_cut B hB) + exact ⟨p,fun n => congrFun hp n⟩ + +end TuringRigidity.BinarySeries + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/BinarySeries.lean b/lean/OAI/Computability/DegreeRigidity/Computability/BinarySeries.lean new file mode 100644 index 0000000000000000000000000000000000000000..77837f1e52dc8ee50c3edcf4a8733e897c8bb4f0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/BinarySeries.lean @@ -0,0 +1,91 @@ +import OAI.Computability.DegreeRigidity.Computability.Cuts +import Mathlib.Analysis.Real.OfDigits + +namespace OAI + +namespace TuringRigidity.BinarySeries + +def bit (B : Oracle) (n : ℕ) : ℕ := if B n then 1 else 0 + +def digits (B : Oracle) (n : ℕ) : Fin 2 := ⟨bit B n, by unfold bit; split <;> omega⟩ + +noncomputable def value (B : Oracle) : ℝ := Real.ofDigits (digits B) + +def numeral (B : Oracle) : ℕ → ℕ + | 0 => 0 + | n+1 => 2 * numeral B n + bit B n + +theorem numeral_sum (B : Oracle) (n : ℕ) : + (∑ i ∈ Finset.range n, Real.ofDigitsTerm (digits B) i) = + (numeral B n : ℝ) / 2^n := by + induction n with + | zero => simp [numeral] + | succ n ih => + rw [Finset.sum_range_succ, ih] + simp only [numeral, Nat.cast_add, Nat.cast_mul, Nat.cast_ofNat, + Real.ofDigitsTerm, digits, pow_succ] + field_simp + +theorem split_value (B : Oracle) (n : ℕ) : + value B = (numeral B n : ℝ)/2^n + (2^n : ℝ)⁻¹ * value (fun i => B (i+n)) := by + exact (Real.ofDigits_eq_sum_add_ofDigits (digits B) n).trans (by rw [numeral_sum]; rfl) + +theorem nonneg (B : Oracle) : 0 ≤ value B := Real.ofDigits_nonneg _ +theorem le_one (B : Oracle) : value B ≤ 1 := Real.ofDigits_le_one _ + +theorem positive (B : Oracle) (h : ∃ n, B n = true) : 0 < value B := by + obtain ⟨n, hn⟩ := h + have ht : 0 < Real.ofDigitsTerm (digits B) n := by + simp [Real.ofDigitsTerm, digits, bit, hn] + exact lt_of_lt_of_le ht (Summable.le_tsum Real.summable_ofDigitsTerm n + (fun _ _ => Real.ofDigitsTerm_nonneg)) + +theorem complement (B : Oracle) : value B + value (fun n => !(B n)) = 1 := by + rw [value, value, Real.ofDigits, Real.ofDigits, ← Summable.tsum_add + Real.summable_ofDigitsTerm Real.summable_ofDigitsTerm] + have he : (fun n => Real.ofDigitsTerm (digits B) n + + Real.ofDigitsTerm (digits (fun n => !(B n))) n) = + Real.ofDigitsTerm (fun _ => (⟨1, by omega⟩ : Fin 2)) := by + funext n + cases h : B n <;> simp [Real.ofDigitsTerm, digits, bit, h] + rw [he] + exact Real.ofDigits_const_last_eq_one' (by omega : 1 < 2) + +theorem lt_one (B : Oracle) (h : ∃ n, B n = false) : value B < 1 := by + have hp := positive (fun n => !(B n)) (by obtain ⟨n, hn⟩ := h; exact ⟨n, by simp [hn]⟩) + have hc := complement B + linarith + +def Mixed (B : Oracle) : Prop := ∀ N, (∃ n, N ≤ n ∧ B n = true) ∧ (∃ n, N ≤ n ∧ B n = false) + +theorem strict_bracket (B : Oracle) (h : Mixed B) (n : ℕ) : + (numeral B n : ℝ)/2^n < value B ∧ value B < (numeral B n + 1 : ℝ)/2^n := by + have hp : 0 < value (fun i => B (i+n)) := by + apply positive + obtain ⟨k,hk,hb⟩ := (h n).1 + exact ⟨k-n, by simpa [Nat.sub_add_cancel hk] using hb⟩ + have hu : value (fun i => B (i+n)) < 1 := by + apply lt_one + obtain ⟨k,hk,hb⟩ := (h n).2 + exact ⟨k-n, by simpa [Nat.sub_add_cancel hk] using hb⟩ + rw [split_value B n] + have hd : (0 : ℝ) < (2^n : ℝ)⁻¹ := by positivity + constructor + · nlinarith + · rw [add_div] + simp only [one_div] + nlinarith + +theorem bracket (B : Oracle) (n : ℕ) : + (numeral B n : ℝ)/2^n ≤ value B ∧ value B ≤ (numeral B n + 1 : ℝ)/2^n := by + rw [split_value B n] + have hp := nonneg (fun i => B (i+n)) + have hu := le_one (fun i => B (i+n)) + have hd : (0 : ℝ) < (2^n : ℝ)⁻¹ := by positivity + constructor + · nlinarith + · rw [add_div]; simp only [one_div]; nlinarith + +end TuringRigidity.BinarySeries + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/BranchFrequency.lean b/lean/OAI/Computability/DegreeRigidity/Computability/BranchFrequency.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a322093945e9a70483f741cd22f868c9fecca9a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/BranchFrequency.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.Computability.BranchRecovery + +namespace OAI + +namespace TuringRigidity + +namespace UniformOracle + +def runningSum (f : ℕ → ℕ) : ℕ → ℕ + | 0 => 0 + | n+1 => runningSum f n + f n + +theorem runningSum_recursive {O : Set (ℕ →. ℕ)} {f : ℕ → ℕ} + (hf : Nat.RecursiveIn O (fun n => Part.some (f n))) : + Nat.RecursiveIn O (fun n => Part.some (runningSum f n)) := by + have hy := total_primrec (O := O) (Primrec.fst.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hi := total_primrec (O := O) (Primrec.snd.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hs := total_comp (total_primrec (Primrec.nat_add.comp + (Primrec.fst.comp Primrec.unpair) (Primrec.snd.comp Primrec.unpair))) + (total_pair hi (total_comp hf hy)) + have hp := Nat.RecursiveIn.prec (total_primrec (Primrec.const 0)) hs + have hh := Nat.RecursiveIn.comp hp + (total_pair (total_primrec (Primrec.const 0)) (total_primrec Primrec.id)) + apply hh.of_eq + intro n + change (Part.some (Nat.pair 0 n)).bind _ = _ + rw [Part.bind_some] + simp only [Nat.unpair_pair] + induction n with + | zero => rfl + | succ n ih => + simp only [ih] + change (Part.some (runningSum f n)).bind _ = _ + rw [Part.bind_some] + rfl +end UniformOracle + +namespace RecoveryData +variable {F : ℝ → Oracle} {t u v : ℝ} + +def count (d : RecoveryData F t u v) : ℕ → ℕ := + UniformOracle.runningSum (fun n => if d.branchOracle n then 1 else 0) + +theorem count_eq_sum (d : RecoveryData F t u v) (n : ℕ) : + (d.count n : ℝ) = ∑ k ∈ Finset.range n, branch d.test (d.delta : ℝ) t k := by + induction n with + | zero => simp [count,UniformOracle.runningSum] + | succ n ih => + simp only [count,UniformOracle.runningSum,Finset.sum_range_succ,Nat.cast_add] + rw [show (UniformOracle.runningSum (fun n => if d.branchOracle n then 1 else 0) n : ℝ) = + ∑ k ∈ Finset.range n, branch d.test (d.delta : ℝ) t k from ih] + congr 1 + cases hb : d.branchOracle n <;> simp [branch,choiceBit,branchOracle] at hb ⊢ <;> simp [hb] + +theorem count_recursive (d : RecoveryData F t u v) (ht0 : 0 < t) (ht1 : t < 1) : + Nat.RecursiveIn {oracleFunction (fourTuple F t u v d.delta)} + (fun n => Part.some (d.count n)) := by + exact UniformOracle.runningSum_recursive (RecursiveIn.iff_nat.mp (d.branch_reduces ht0 ht1)) + +theorem count_frequency_bound (d : RecoveryData F t u v) (ht0 : 0 < t) (ht1 : t < 1) + (n : ℕ) (hn : 0 < n) : + |t - (d.count n : ℝ)/(n : ℝ)| < 1/((n : ℝ)*(d.delta : ℝ)) := by + rw [count_eq_sum] + exact d.frequency_bound ht0 ht1 n hn + +end RecoveryData +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/BranchMachine.lean b/lean/OAI/Computability/DegreeRigidity/Computability/BranchMachine.lean new file mode 100644 index 0000000000000000000000000000000000000000..0dda8dd17508fe90be7a13d5cbe0a5e826570eed --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/BranchMachine.lean @@ -0,0 +1,143 @@ +import OAI.Computability.DegreeRigidity.Effective.PartialComputability +import OAI.Computability.DegreeRigidity.SetModels.ParametricEval +import OAI.Computability.DegreeRigidity.Effective.FiniteApproximation + +namespace OAI + +namespace TuringRigidity +open Computable + +def partialJoin (f g : ℕ →. ℕ) (k : ℕ) : Part ℕ := + if k.bodd then g (k/2) else f (k/2) + +namespace BranchMachine + +def initial (g : ℕ →. ℕ) (k : ℕ) : Part ℕ := g (8*k) +def anchor (g : ℕ →. ℕ) (k : ℕ) : Part ℕ := g (8*k+4) +def increment (g : ℕ →. ℕ) (h b k : ℕ) : Part ℕ := + g (if b = h then 2*k+1 else 4*k+2) + +def step (p q : OracleCode) (j h : ℕ) (g old : ℕ →. ℕ) (k : ℕ) : Part ℕ := + old j >>= fun b => + OracleCode.eval + (partialJoin (OracleCode.eval (partialJoin old (increment g h b)) p) (anchor g)) q k + +def stage (p q : OracleCode) (j h : ℕ) (g : ℕ →. ℕ) : ℕ → ℕ →. ℕ + | 0 => initial g + | n+1 => step p q j h g (stage p q j h g n) + +theorem partialJoin_approximates {f g : ℕ →. ℕ} {fs gs : ℕ → ℕ →. ℕ} + (hf : ∀ k, Approximates (f k) (fun m => fs m k)) + (hg : ∀ k, Approximates (g k) (fun m => gs m k)) (k : ℕ) : + Approximates (partialJoin f g k) (fun m => partialJoin (fs m) (gs m) k) := by + simp only [partialJoin] + split + · exact hg _ + · exact hf _ + +theorem stage_approximates (p q : OracleCode) (j h : ℕ) + {g : ℕ →. ℕ} {gs : ℕ → ℕ →. ℕ} + (hg : ∀ k, Approximates (g k) (fun m => gs m k)) : + ∀ n k, Approximates (stage p q j h g n k) + (fun m => stage p q j h (gs m) n k) := by + intro n + induction n with + | zero => intro k; exact hg _ + | succ n ih => + intro k + apply (ih j).bind + intro b + apply OracleCode.eval_approximates _ q k + intro x + apply partialJoin_approximates + · exact OracleCode.eval_approximates + (fun x => partialJoin_approximates ih (fun k => hg _) x) p + · intro x; exact hg _ + +variable {α : Type*} [Primcodable α] + +theorem partialJoin_partrec {f g : α → ℕ →. ℕ} (hf : Partrec₂ f) (hg : Partrec₂ g) : + Partrec₂ (fun a k => partialJoin (f a) (g a) k) := by + apply partrec_cond (Computable.nat_bodd.comp snd) + · exact hg.comp fst ((Primrec.nat_div.comp Primrec.id (Primrec.const 2)).to_comp.comp snd) + · exact hf.comp fst ((Primrec.nat_div.comp Primrec.id (Primrec.const 2)).to_comp.comp snd) + +theorem increment_index_computable (h : ℕ) : + Computable₂ (fun b k : ℕ => if b = h then 2*k+1 else 4*k+2) := by + apply (Computable.cond ((Primrec.beq.comp Primrec.fst (Primrec.const h)).to_comp) + ((Primrec.nat_add.comp (Primrec.nat_mul.comp (Primrec.const 2) Primrec.snd) + (Primrec.const 1)).to_comp) + ((Primrec.nat_add.comp (Primrec.nat_mul.comp (Primrec.const 4) Primrec.snd) + (Primrec.const 2)).to_comp)).of_eq + intro z + by_cases hh : z.1 = h + · simp [hh] + · have he : (z.1 == h) = false := Bool.eq_false_iff.mpr (fun he => hh (beq_iff_eq.mp he)) + simp [hh,he] + +theorem step_partrec (p q : OracleCode) (j h : ℕ) + {g old : α → ℕ →. ℕ} (hg : Partrec₂ g) (ho : Partrec₂ old) : + Partrec₂ (fun a k => step p q j h (g a) (old a) k) := by + change Partrec (fun z : α × ℕ => (old z.1 j).bind _) + apply Partrec.bind (ho.comp fst (Computable.const j)) + let β := (α × ℕ) × ℕ + have hleft : Partrec₂ (fun z : β => old z.1.1) := + ho.comp (fst.comp (fst.comp fst)) snd + have hinc : Partrec₂ (fun z : β => increment (g z.1.1) h z.2) := + hg.comp (fst.comp (fst.comp fst)) + ((increment_index_computable h).comp (snd.comp fst) snd) + have hforward := OracleCode.eval_partrec (partialJoin_partrec hleft hinc) p + have hanchor : Partrec₂ (fun z : β => anchor (g z.1.1)) := + hg.comp (fst.comp (fst.comp fst)) + ((Primrec.nat_add.comp (Primrec.nat_mul.comp (Primrec.const 8) Primrec.snd) + (Primrec.const 4)).to_comp) + exact (OracleCode.eval_partrec (partialJoin_partrec hforward hanchor) q).comp + Computable.id (snd.comp fst) + +def lookup (L : List ℕ) (k : ℕ) : Part ℕ := (L[k]? : Part ℕ) + +theorem lookup_partrec : Partrec₂ lookup := + Computable.ofOption Primrec.list_getElem?.to_comp + +theorem stage_finite_partrec (p q : OracleCode) (j h : ℕ) : + Partrec (fun z : List ℕ × ℕ × ℕ => stage p q j h (lookup z.1) z.2.1 z.2.2) := by + let α := List ℕ × ℕ × ℕ + let body (c : Nat.Partrec.Code) (z : α) : Part ℕ := + if z.2.1 == 0 then initial (lookup z.1) z.2.2 else + step p q j h (lookup z.1) + (fun k => c.eval (Encodable.encode (z.1, z.2.1-1, k))) z.2.2 + have hb : Partrec₂ body := by + apply partrec_cond ((Primrec.beq.comp + (Primrec.fst.comp (Primrec.snd.comp Primrec.snd)) (Primrec.const 0)).to_comp) + · exact lookup_partrec.comp (fst.comp snd) + ((Primrec.nat_mul.comp (Primrec.const 8) + (Primrec.snd.comp (Primrec.snd.comp Primrec.snd))).to_comp) + · have hg : Partrec₂ (fun z : Nat.Partrec.Code × α => lookup z.2.1) := + lookup_partrec.comp (fst.comp (snd.comp fst)) snd + have ho : Partrec₂ (fun z : Nat.Partrec.Code × α => + fun k => z.1.eval (Encodable.encode (z.2.1,z.2.2.1-1,k))) := + Nat.Partrec.Code.eval_part.comp (fst.comp fst) + ((Computable.encode (α := List ℕ × ℕ × ℕ)).comp ((fst.comp (snd.comp fst)).pair + ((Computable.pred.comp (fst.comp (snd.comp (snd.comp fst)))).pair snd))) + exact (step_partrec p q j h hg ho).comp Computable.id (snd.comp (snd.comp snd)) + obtain ⟨c,hc⟩ := partrec_fixed_point hb + have heq : ∀ n L k, c.eval (Encodable.encode (L,n,k)) = stage p q j h (lookup L) n k := by + intro n + induction n with + | zero => intro L k; rw [hc]; rfl + | succ n ih => + intro L k + rw [hc] + have hn0 : (n+1 == 0) = false := rfl + simp only [body, hn0, + Bool.false_eq_true, ↓reduceIte, Nat.add_sub_cancel, stage] + congr 1 + funext i + exact ih L i + exact (Nat.Partrec.Code.eval_part.comp (Computable.const c) Computable.encode).of_eq + (fun z => heq z.2.1 z.1 z.2.2) + +end BranchMachine +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/BranchRecovery.lean b/lean/OAI/Computability/DegreeRigidity/Computability/BranchRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..5bf7a176eb4d3334bbaa3cedd34de2a501924543 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/BranchRecovery.lean @@ -0,0 +1,156 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformOracle +import OAI.Computability.DegreeRigidity.Computability.RecoverySetup +import OAI.Computability.DegreeRigidity.Representation.Assembly + +namespace OAI + +namespace TuringRigidity + +@[simp] theorem partialJoin_oracle (A B : Oracle) : + partialJoin (oracleFunction A) (oracleFunction B) = oracleFunction (join A B) := by + funext k + cases hk : k.bodd <;> simp [partialJoin, oracleFunction, join, hk] + +namespace RecoveryData +variable {F : ℝ → Oracle} {t u v : ℝ} + +def highBit (d : RecoveryData F t u v) : ℕ := if F (u+d.hi) d.bit then 1 else 0 + +def branchOracle (d : RecoveryData F t u v) : Oracle := + fun n => d.test (state d.test (d.delta : ℝ) t n) + +private theorem tuple_initial (d : RecoveryData F t u v) : + BranchMachine.initial (oracleFunction (fourTuple F t u v d.delta)) = oracleFunction (F u) := by + funext k + change oracleFunction (fourTuple F t u v d.delta) (8*k) = _ + rw [show 8*k = 2*(2*(2*k)) by omega] + simp [oracleFunction, fourTuple] + +private theorem tuple_anchor (d : RecoveryData F t u v) : + BranchMachine.anchor (oracleFunction (fourTuple F t u v d.delta)) = oracleFunction (F (u-v)) := by + funext k + change oracleFunction (fourTuple F t u v d.delta) (8*k+4) = _ + rw [show 8*k+4 = 2*(2*(2*k+1)) by omega] + simp [oracleFunction, fourTuple] + +private theorem tuple_increment (d : RecoveryData F t u v) (s : ℝ) : + BranchMachine.increment (oracleFunction (fourTuple F t u v d.delta)) d.highBit + (if F (u+s) d.bit then 1 else 0) = + oracleFunction (F (v-u+(d.delta : ℝ)*(t-choiceBit d.test s))) := by + funext k + have h3 : oracleFunction (fourTuple F t u v d.delta) (4*k+2) = + oracleFunction (F (v-u+(d.delta : ℝ)*t)) k := by + rw [show 4*k+2 = 2*(2*k+1) by omega] + simp [oracleFunction, fourTuple] + have h4 : oracleFunction (fourTuple F t u v d.delta) (2*k+1) = + oracleFunction (F (v-u+(d.delta : ℝ)*(t-1))) k := by + simp [oracleFunction, fourTuple] + cases hb : F (u+s) d.bit <;> cases hh : F (u+d.hi) d.bit <;> + simp [BranchMachine.increment, highBit, choiceBit, test, hb, hh, h3, h4] + +private theorem increment_span (d : RecoveryData F t u v) (s : ℝ) : + (d.delta : ℝ)*(t-choiceBit d.test s) ∈ rationalSpan t := by + cases hb : d.test s + · exact ⟨0,d.delta,by simp [choiceBit,hb]⟩ + · refine ⟨-d.delta,d.delta,?_⟩ + simp only [choiceBit,hb,↓reduceIte,Rat.cast_neg] + ring + +private theorem increment_abs (d : RecoveryData F t u v) (ht0 : 0 < t) (ht1 : t < 1) + (s : ℝ) : |(d.delta : ℝ)*(t-choiceBit d.test s)| < d.radius := by + have hd : (0 : ℝ) < d.delta := by exact_mod_cast d.delta_pos + have hδ := d.delta_lt + apply abs_lt.mpr + cases hb : d.test s <;> simp only [choiceBit,hb,Bool.false_eq_true,↓reduceIte,sub_zero] <;> + constructor <;> nlinarith + +theorem stage_correct (d : RecoveryData F t u v) (ht0 : 0 < t) (ht1 : t < 1) : + ∀ n, BranchMachine.stage (codeEnumeration d.forward) (codeEnumeration d.backward) + d.bit d.highBit (oracleFunction (fourTuple F t u v d.delta)) n = + oracleFunction (F (u+state d.test (d.delta : ℝ) t n)) := by + intro n + induction n with + | zero => + funext input + simpa [BranchMachine.stage,state] using congrFun (tuple_initial d) input + | succ n ih => + let s := state d.test (d.delta : ℝ) t n + let a := (d.delta : ℝ)*(t-choiceBit d.test s) + have hsa : s+a = state d.test (d.delta : ℝ) t (n+1) := rfl + have hp := d.forward_correct s (state_mem_rationalSpan d.test d.delta t n) + a (increment_span d s) (d.abs_state_lt ht0 ht1 n) (increment_abs d ht0 ht1 s) + have hq := d.backward_correct (s+a) (by rw [hsa]; exact state_mem_rationalSpan _ _ _ _) + (by rw [hsa]; exact d.abs_state_lt ht0 ht1 (n+1)) + funext k + simp only [BranchMachine.stage,BranchMachine.step,ih,oracleFunction] + change (Part.some _).bind _ = _ + rw [Part.bind_some] + change OracleCode.eval + (partialJoin (OracleCode.eval + (partialJoin (oracleFunction (F (u+s))) + (BranchMachine.increment (oracleFunction (fourTuple F t u v d.delta)) d.highBit + (if F (u+s) d.bit then 1 else 0))) (codeEnumeration d.forward)) + (BranchMachine.anchor (oracleFunction (fourTuple F t u v d.delta)))) + (codeEnumeration d.backward) k = _ + rw [tuple_increment,tuple_anchor,partialJoin_oracle,hp] + rw [show v+s+a = v+(s+a) by ring,partialJoin_oracle,hq] + rfl + +theorem stage_single_program (d : RecoveryData F t u v) (ht0 : 0 < t) (ht1 : t < 1) : + ∃ c : OracleCode, ∀ n k, + OracleCode.eval (oracleFunction (fourTuple F t u v d.delta)) c (Nat.pair n k) = + oracleFunction (F (u+state d.test (d.delta : ℝ) t n)) k := by + let T := fourTuple F t u v d.delta + let g : ℕ → ℕ := fun k => if T k then 1 else 0 + let f : ℕ → ℕ := fun z => if F (u+state d.test (d.delta : ℝ) t (Nat.unpair z).1) + (Nat.unpair z).2 then 1 else 0 + have hg : (fun x => Part.some (g x)) = oracleFunction (fourTuple F t u v d.delta) := rfl + have hf := UniformOracle.stage_recursive (codeEnumeration d.forward) (codeEnumeration d.backward) + d.bit d.highBit g f (by + intro n k + rw [hg] + have hs := congrFun (d.stage_correct ht0 ht1 n) k + apply hs.trans + simp only [f,Nat.unpair_pair] + rfl) + obtain ⟨c,hc⟩ := OracleCode.exists_code hf + rw [hg] at hc + refine ⟨c,fun n k => (congrFun hc (Nat.pair n k)).trans ?_⟩ + simp only [f,Nat.unpair_pair] + rfl + +theorem branch_reduces (d : RecoveryData F t u v) (ht0 : 0 < t) (ht1 : t < 1) : + Reduces d.branchOracle (fourTuple F t u v d.delta) := by + obtain ⟨c,hc⟩ := d.stage_single_program ht0 ht1 + have he := OracleCode.eval_recursiveIn (oracleFunction (fourTuple F t u v d.delta)) c + have hp := UniformOracle.total_primrec (O := {oracleFunction (fourTuple F t u v d.delta)}) + (Primrec₂.natPair.comp Primrec.id (Primrec.const d.bit)) + have hbits : Nat.RecursiveIn {oracleFunction (fourTuple F t u v d.delta)} + (fun input => oracleFunction (F (u+state d.test (d.delta : ℝ) t input)) d.bit) := + (Nat.RecursiveIn.comp he hp).of_eq (fun n => by + change (Part.some (Nat.pair n d.bit)).bind + (fun input => OracleCode.eval (oracleFunction (fourTuple F t u v d.delta)) c input) = _ + rw [Part.bind_some,hc]) + have hcmp : Primrec (fun b : ℕ => if b = d.highBit then 1 else 0) := + Primrec.ite (Primrec.eq.comp Primrec.id (Primrec.const d.highBit)) + (Primrec.const 1) (Primrec.const 0) + apply RecursiveIn.iff_nat.mpr + apply (Nat.RecursiveIn.comp (UniformOracle.total_primrec hcmp) hbits).of_eq + intro n + simp only [oracleFunction] + change (Part.some _).bind _ = _ + rw [Part.bind_some] + cases hb : F (u+state d.test (d.delta : ℝ) t n) d.bit <;> + cases hh : F (u+d.hi) d.bit <;> + simp [branchOracle,test,highBit,hb,hh] + +theorem branch_single_program (d : RecoveryData F t u v) (ht0 : 0 < t) (ht1 : t < 1) : + ∃ c : OracleCode, + OracleCode.eval (oracleFunction (fourTuple F t u v d.delta)) c = + oracleFunction d.branchOracle := + (OracleCode.turingReducible_iff_exists_code _ _).mp (d.branch_reduces ht0 ht1) + +end RecoveryData +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/CutAddition.lean b/lean/OAI/Computability/DegreeRigidity/Computability/CutAddition.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c0a1e84b448ca1753c438e1453865fa5f1387ab --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/CutAddition.lean @@ -0,0 +1,140 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.SumComparison +import OAI.Computability.DegreeRigidity.Computability.Joins + +namespace OAI + +namespace TuringRigidity +namespace CutAddition +open RationalCoding UniformOracle + +def decision (z : ℕ × (ℕ × ℕ) × (ℕ × ℕ)) : Option ℕ := + if z.2.2.1=1 ∧ z.2.2.2=1 ∧ sumLeft (z.1,z.2.1.1,z.2.1.2) Part.some (Encodable.encode (trial x y (Nat.unpair z).1 (Nat.unpair z).2))) := by + let O : Set (ℕ →. ℕ) := {oracleFunction (join (cut x) (cut y))} + have hq := total_primrec (O := O) (Primrec.fst.comp Primrec.unpair) + have hi := total_primrec (O := O) (Primrec.fst.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair))) + have hj := total_primrec (O := O) (Primrec.snd.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair))) + have hg : Nat.RecursiveIn O (oracleFunction (join (cut x) (cut y))) := .oracle _ (Set.mem_singleton _) + have hbi := total_comp hg (total_comp + (total_primrec (Primrec.nat_mul.comp (Primrec.const 2) Primrec.id)) hi) + have hbj := total_comp hg (total_comp + (total_primrec (Primrec.nat_add.comp (Primrec.nat_mul.comp (Primrec.const 2) Primrec.id) + (Primrec.const 1))) hj) + have hdec : Primrec (fun z : ℕ => Encodable.encode (decision + ((Nat.unpair z).1,Nat.unpair (Nat.unpair (Nat.unpair z).2).1, + Nat.unpair (Nat.unpair (Nat.unpair z).2).2))) := + Primrec.encode.comp (decision_primrec.comp + ((Primrec.fst.comp Primrec.unpair).pair + ((Primrec.unpair.comp (Primrec.fst.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)))).pair + (Primrec.unpair.comp (Primrec.snd.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair))))))) + exact (total_comp (total_primrec hdec) + (total_pair hq (total_pair (total_pair hi hj) (total_pair hbi hbj)))).of_eq + (fun z => by simp [trial]) + +private theorem bit_one (b : Bool) (h : (if b then (1 : ℕ) else 0)=1) : b=true := by + cases b <;> simp_all +private theorem bit_zero (b : Bool) (h : (if b then (1 : ℕ) else 0)=0) : b=false := by + cases b <;> simp_all + +theorem trial_sound (x y : ℝ) (n m r : ℕ) (hr : r ∈ trial x y n m) : + r = if cut (x+y) n then 1 else 0 := by + let i := (Nat.unpair m).1 + let j := (Nat.unpair m).2 + change r ∈ decision (n,(i,j),(if cut x i then 1 else 0,if cut y j then 1 else 0)) at hr + generalize hbi : (if cut x i then (1 : ℕ) else 0) = bi at hr + generalize hbj : (if cut y j then (1 : ℕ) else 0) = bj at hr + unfold decision at hr + split at hr + · rename_i h + have hr' : r=1 := by symm; simpa using hr + subst r + have hx := (cut_eq_true x i).mp (bit_one _ (hbi.trans h.1)) + have hy := (cut_eq_true y j).mp (bit_one _ (hbj.trans h.2.1)) + have hq := (lt_sum_iff n i j).mp h.2.2 + have hc : cut (x+y) n=true := (cut_eq_true _ _).mpr (by linarith) + simp [hc] + · split at hr + · rename_i h + have hr' : r=0 := by symm; simpa using hr + subst r + have hx : x ≤ (rationalEnumeration i : ℝ) := le_of_not_gt + (fun hx => Bool.noConfusion ((bit_zero _ (hbi.trans h.1)).symm.trans ((cut_eq_true x i).mpr hx))) + have hy : y ≤ (rationalEnumeration j : ℝ) := le_of_not_gt + (fun hy => Bool.noConfusion ((bit_zero _ (hbj.trans h.2.1)).symm.trans ((cut_eq_true y j).mpr hy))) + have hq := (sum_lt_iff n i j).mp h.2.2 + have hnot : ¬(rationalEnumeration n : ℝ) hnot ((cut_eq_true _ _).mp hc)) + simp [hc] + · simp at hr + +theorem trial_complete (x y : ℝ) (hxy : Irrational (x+y)) (n : ℕ) : + ∃ m r, r ∈ trial x y n m := by + have hne : (rationalEnumeration n : ℝ) ≠ x+y := fun h => hxy ⟨rationalEnumeration n,h⟩ + rcases lt_or_gt_of_ne hne with h | h + · obtain ⟨a,ha,hax⟩ := exists_rat_btwn (show (rationalEnumeration n : ℝ)-y by + have hh := (cut_eq_true x i).mp hc + rw [hi] at hh + linarith) + have hcj : cut y j=false := Bool.eq_false_iff.mpr (fun hc => by + have hh := (cut_eq_true y j).mp hc + rw [hj] at hh + linarith) + have hu : sumRight (n,i,j) if cut (x+y) n then 1 else 0) + (trial_sound x y) (trial_complete x y hxy) +end CutAddition + +theorem cut_add_reduces (x y : ℝ) : Reduces (cut (x+y)) (join (cut x) (cut y)) := by + by_cases hxy : Irrational (x+y) + · exact CutAddition.irrational_add_reduces x y hxy + · obtain ⟨q,hq⟩ := not_not.mp hxy + rw [←hq] + exact rational_cut_reduces q _ + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/CutArithmetic.lean b/lean/OAI/Computability/DegreeRigidity/Computability/CutArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..a73ca2fb4f868ed36b3b039ff63a03160ffeb4d1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/CutArithmetic.lean @@ -0,0 +1,82 @@ +import OAI.Computability.DegreeRigidity.Computability.CutAddition +import OAI.Computability.DegreeRigidity.Computability.ScalarCoding +import OAI.Computability.DegreeRigidity.Representation.Assembly + +namespace OAI + +namespace TuringRigidity +open RationalCoding UniformOracle + +theorem cut_smul_reduces (r : ℚ) (x : ℝ) : Reduces (cut ((r : ℝ)*x)) (cut x) := by + by_cases hr : r=0 + · subst r + simpa using rational_cut_reduces (0 : ℚ) (cut x) + by_cases ht : Irrational ((r : ℝ)*x) + swap + · obtain ⟨q,hq⟩ := not_not.mp ht + rw [←hq] + exact rational_cut_reduces q _ + have hq : Nat.RecursiveIn {oracleFunction (cut x)} (oracleFunction (cut x)) := + .oracle _ (Set.mem_singleton _) + have hread := Nat.RecursiveIn.comp hq (divideIndex_recursive (O := {oracleFunction (cut x)}) r hr) + apply RecursiveIn.iff_nat.mpr + by_cases hpos : 0 Part.some (if cut x input then 1 else 0)) = + oracleFunction (cut ((r : ℝ)*x)) n + rw [Part.bind_some] + have hiff : cut x (divideIndex r n)=true ↔ cut ((r : ℝ)*x) n=true := by + rw [cut_eq_true,cut_eq_true,divideIndex_value,Rat.cast_div] + simpa only [mul_comm] using (div_lt_iff₀ hpos' : + (rationalEnumeration n : ℝ)/(r : ℝ) if b=0 then 1 else 0) := + Primrec.ite (Primrec.eq.comp Primrec.id (Primrec.const 0)) (Primrec.const 1) (Primrec.const 0) + apply (Nat.RecursiveIn.comp (total_primrec hc) hread).of_eq + intro n + change ((Part.some (divideIndex r n)).bind + (fun input => Part.some (if cut x input then 1 else 0))).bind + (fun value => Part.some (if value = 0 then 1 else 0)) = + oracleFunction (cut ((r : ℝ)*x)) n + simp only [Part.bind_some] + have hiff : cut x (divideIndex r n)=true ↔ (r : ℝ)*x<(rationalEnumeration n : ℝ) := by + rw [cut_eq_true,divideIndex_value,Rat.cast_div] + simpa only [mul_comm] using (div_lt_iff_of_neg hneg' : + (rationalEnumeration n : ℝ)/(r : ℝ) ht ⟨rationalEnumeration n,h⟩ + by_cases hin : cut x (divideIndex r n)=true + · have hout : cut ((r : ℝ)*x) n=false := Bool.eq_false_iff.mpr + (fun h => (not_lt_of_gt (hiff.mp hin)) ((cut_eq_true _ _).mp h)) + simp [hin,hout,oracleFunction] + · have hle : (rationalEnumeration n : ℝ) ≤ (r : ℝ)*x := + le_of_not_gt (fun h => hin (hiff.mpr h)) + have hout : cut ((r : ℝ)*x) n=true := (cut_eq_true _ _).mpr + ((lt_or_eq_of_le hle).resolve_right hneq) + have hin' := Bool.eq_false_iff.mpr hin + simp [hin',hout,oracleFunction] + +theorem cut_sub_reduces (x y : ℝ) : Reduces (cut (x-y)) (join (cut x) (cut y)) := by + have hy : Reduces (cut (-y)) (cut y) := by simpa using cut_smul_reduces (-1 : ℚ) y + have h := reduces_trans (cut_add_reduces x (-y)) (join_mono (reduces_refl (cut x)) hy) + simpa only [sub_eq_add_neg] using h + +theorem cut_translate_reduces (x : ℝ) (q : ℚ) : Reduces (cut (x+(q : ℝ))) (cut x) := + reduces_trans (cut_add_reduces x q) + (join_reduces (reduces_refl (cut x)) (rational_cut_reduces q (cut x))) + +theorem cut_arithmetic : CutArithmetic where + add := cut_add_reduces + sub := cut_sub_reduces + smul := cut_smul_reduces + translate := cut_translate_reduces + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/CutTranscript.lean b/lean/OAI/Computability/DegreeRigidity/Computability/CutTranscript.lean new file mode 100644 index 0000000000000000000000000000000000000000..c56acdbdd94b741286d8510c8ae67b8383c8f911 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/CutTranscript.lean @@ -0,0 +1,102 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteTranscript +import OAI.Computability.DegreeRigidity.Computability.Cuts +import OAI.Computability.DegreeRigidity.Computability.Joins + +namespace OAI + +open Set +namespace TuringRigidity + +theorem cut_prefix_left (x : ℝ) (m : ℕ) : + ∃ l : ℝ, l < x ∧ ∀ y, l < y → y ≤ x → ∀ k, k < m → cut y k = cut x k := by + induction m with + | zero => exact ⟨x-1, by linarith, by simp⟩ + | succ m ih => + obtain ⟨l,hl,he⟩ := ih + by_cases hq : (rationalEnumeration m : ℝ) < x + · refine ⟨max l (rationalEnumeration m), max_lt hl hq, ?_⟩ + intro y hy hyx k hk + rcases Nat.lt_succ_iff_lt_or_eq.mp hk with hk | hk + · exact he y ((le_max_left _ _).trans_lt hy) hyx k hk + · subst k + have hqy := (le_max_right l (rationalEnumeration m : ℝ)).trans_lt hy + simp [cut, hq, hqy] + · refine ⟨l,hl,?_⟩ + intro y hy hyx k hk + rcases Nat.lt_succ_iff_lt_or_eq.mp hk with hk | hk + · exact he y hy hyx k hk + · subst k + have hqy : ¬ (rationalEnumeration m : ℝ) < y := + not_lt.mpr (hyx.trans (not_lt.mp hq)) + simp [cut,hq,hqy] + +namespace CategorySearch + +noncomputable def pairOracle (A : Oracle) (p : ℝ × ℝ) : Oracle := join (join A (cut p.1)) (cut p.2) +noncomputable def value (A : Oracle) (p : ℝ × ℝ) (k : ℕ) : ℕ := if pairOracle A p k then 1 else 0 + +theorem value_prefix (A : Oracle) (p q : ℝ × ℝ) (m : ℕ) + (h1 : ∀ k, k < m → cut q.1 k = cut p.1 k) + (h2 : ∀ k, k < m → cut q.2 k = cut p.2 k) : + ∀ k, k < m → value A q k = value A p k := by + intro k hk + apply congrArg (fun b : Bool => if b then (1 : ℕ) else 0) + have hk2 : k/2 < m := by omega + have hk4 : k/2/2 < m := by omega + simp only [pairOracle,join,h1 _ hk4,h2 _ hk2] + +theorem halting_left (A : Oracle) (c : OracleCode) (p : ℝ × ℝ) (n a : ℕ) + (ha : a ∈ OracleCode.eval (oracleFunction (pairOracle A p)) c n) : + ∃ l : ℝ × ℝ, l.1 < p.1 ∧ l.2 < p.2 ∧ + ∀ q : ℝ × ℝ, l.1 < q.1 → q.1 ≤ p.1 → l.2 < q.2 → q.2 ≤ p.2 → + a ∈ OracleCode.eval (oracleFunction (pairOracle A q)) c n := by + obtain ⟨m,hm⟩ := OracleCode.eval_total_stable (value A p) c n a ha + obtain ⟨l1,h1,he1⟩ := cut_prefix_left p.1 m + obtain ⟨l2,h2,he2⟩ := cut_prefix_left p.2 m + refine ⟨(l1,l2),h1,h2,?_⟩ + intro q hq1 hq1' hq2 hq2' + exact hm (value A q) (value_prefix A p q m (he1 _ hq1 hq1') (he2 _ hq2 hq2')) + +def rectangle (l r : ℚ × ℚ) : Set (ℝ × ℝ) := + Ioo (l.1 : ℝ) (r.1 : ℝ) ×ˢ Ioo (l.2 : ℝ) (r.2 : ℝ) + +def success (A Y : Oracle) (c : OracleCode) : Set (ℝ × ℝ) := + {p | OracleCode.eval (oracleFunction (pairOracle A p)) c = oracleFunction Y} + +theorem dense_sound (A Y : Oracle) (c : OracleCode) (l r : ℚ × ℚ) + (hd : rectangle l r ⊆ closure (success A Y c)) (p : ℝ × ℝ) + (hp : p ∈ rectangle l r) (n a : ℕ) + (ha : a ∈ OracleCode.eval (oracleFunction (pairOracle A p)) c n) : + a = if Y n then 1 else 0 := by + obtain ⟨b,hb1,hb2,he⟩ := halting_left A c p n a ha + let U : Set (ℝ × ℝ) := Ioo (max b.1 (l.1 : ℝ)) p.1 ×ˢ Ioo (max b.2 (l.2 : ℝ)) p.2 + have hU : IsOpen U := isOpen_Ioo.prod isOpen_Ioo + have hne : U.Nonempty := + (nonempty_Ioo.mpr (max_lt hb1 hp.1.1)).prod (nonempty_Ioo.mpr (max_lt hb2 hp.2.1)) + have hsub : U ⊆ rectangle l r := by + intro q hq + exact ⟨⟨(le_max_right _ _).trans_lt hq.1.1,hq.1.2.trans hp.1.2⟩, + ⟨(le_max_right _ _).trans_lt hq.2.1,hq.2.2.trans hp.2.2⟩⟩ + obtain ⟨q,hq⟩ := hne + obtain ⟨z,hzU,hzS⟩ := mem_closure_iff.mp (hd (hsub hq)) U hU hq + have hz := he z ((le_max_left _ _).trans_lt hzU.1.1) hzU.1.2.le + ((le_max_left _ _).trans_lt hzU.2.1) hzU.2.2.le + rw [hzS] at hz + exact Part.mem_some_iff.mp hz + +theorem rational_halting (A : Oracle) (c : OracleCode) (l r : ℚ × ℚ) + (p : ℝ × ℝ) (hp : p ∈ rectangle l r) (n a : ℕ) + (ha : a ∈ OracleCode.eval (oracleFunction (pairOracle A p)) c n) : + ∃ q : ℚ × ℚ, ((q.1 : ℝ),(q.2 : ℝ)) ∈ rectangle l r ∧ + a ∈ OracleCode.eval (oracleFunction (pairOracle A ((q.1 : ℝ),(q.2 : ℝ)))) c n := by + obtain ⟨b,hb1,hb2,he⟩ := halting_left A c p n a ha + obtain ⟨u,hu1,hu2⟩ := exists_rat_btwn (max_lt hb1 hp.1.1) + obtain ⟨v,hv1,hv2⟩ := exists_rat_btwn (max_lt hb2 hp.2.1) + exact ⟨(u,v),⟨⟨(le_max_right _ _).trans_lt hu1,hu2.trans hp.1.2⟩, + ⟨(le_max_right _ _).trans_lt hv1,hv2.trans hp.2.2⟩⟩, + he _ ((le_max_left _ _).trans_lt hu1) hu2.le ((le_max_left _ _).trans_lt hv1) hv2.le⟩ + +end CategorySearch +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/Cuts.lean b/lean/OAI/Computability/DegreeRigidity/Computability/Cuts.lean new file mode 100644 index 0000000000000000000000000000000000000000..68a0f5082dc156857464884e95922374fba32a97 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/Cuts.lean @@ -0,0 +1,63 @@ +import OAI.Computability.DegreeRigidity.Computability.OracleCode +import OAI.Computability.DegreeRigidity.Representation.Category +import Mathlib.MeasureTheory.Constructions.BorelSpace.Real + +namespace OAI + +open Set Filter Topology +namespace TuringRigidity + +def rationalEnumeration (n : ℕ) : ℚ := (Encodable.decode (α := ℚ) n).getD 0 + +theorem rationalEnumeration_surjective : Function.Surjective rationalEnumeration := by + intro q + refine ⟨Encodable.encode q, ?_⟩ + simp [rationalEnumeration] + +noncomputable def cut (x : ℝ) : Oracle := fun n => decide ((rationalEnumeration n : ℝ) < x) + +@[simp] theorem cut_eq_true (x : ℝ) (n : ℕ) : + cut x n = true ↔ (rationalEnumeration n : ℝ) < x := by simp [cut] + +theorem cut_injective : Function.Injective cut := by + intro x y hxy + apply le_antisymm + · by_contra h + have hyx : y < x := lt_of_not_ge h + obtain ⟨q, hyq, hqx⟩ := exists_rat_btwn hyx + obtain ⟨n, hn⟩ := rationalEnumeration_surjective q + have hc : cut x n = true := (cut_eq_true x n).mpr (by simpa [hn] using hqx) + rw [hxy] at hc + have hqy := (cut_eq_true y n).mp hc + rw [hn] at hqy + exact (not_lt_of_gt hyq) hqy + · by_contra h + have hxy' : x < y := lt_of_not_ge h + obtain ⟨q, hxq, hqy⟩ := exists_rat_btwn hxy' + obtain ⟨n, hn⟩ := rationalEnumeration_surjective q + have hc : cut y n = true := (cut_eq_true y n).mpr (by simpa [hn] using hqy) + rw [← hxy] at hc + have hqx := (cut_eq_true x n).mp hc + rw [hn] at hqx + exact (not_lt_of_gt hxq) hqx + +theorem cut_measurable : Measurable cut := by + apply Measurable.of_eval + intro n + have h : MeasurableSet {x : ℝ | (rationalEnumeration n : ℝ) < x} := measurableSet_Ioi + have hm : Measurable (fun x : ℝ => if (rationalEnumeration n : ℝ) < x then true else false) := + Measurable.ite h measurable_const measurable_const + convert hm using 1 + funext x + by_cases hq : (rationalEnumeration n : ℝ) < x <;> simp [cut, hq] + +noncomputable def realDegree (x : ℝ) : Degree := degree (cut x) + +theorem represented_real_map_countable_fibers (π : Degree ≃o Degree) (F : ℝ → Oracle) + (hF : ∀ x, degree (F x) = π (realDegree x)) : + ∀ B : Oracle, {x : ℝ | F x = B}.Countable := by + exact countable_lift_fiber cut cut_injective π π.injective F hF + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/DegreeCoverage.lean b/lean/OAI/Computability/DegreeRigidity/Computability/DegreeCoverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..174feef906652e4f7e9996e7e261314ccf252c81 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/DegreeCoverage.lean @@ -0,0 +1,52 @@ +import OAI.Computability.DegreeRigidity.Computability.BinaryCut +import OAI.Computability.DegreeRigidity.Computability.BinaryRecovery +import OAI.Computability.DegreeRigidity.Representation.Assembly + +namespace OAI + +namespace TuringRigidity +namespace BinarySeries + +theorem value_eq_series (B : Oracle) : + value B = ∑' n, (bit B n : ℝ) * (2^(n+1) : ℝ)⁻¹ := rfl + +theorem irrational_of_noncomputable (B : Oracle) (h : ¬ Reduces B (fun _ => false)) : + Irrational (value B) := by + intro ⟨q,hq⟩ + apply h + have hr := set_reduces_cut B (mixed_of_noncomputable B h) + rw [←hq] at hr + exact reduces_trans hr (rational_cut_reduces q _) + +theorem rational_series_reduces (B A : Oracle) (q : ℚ) (hq : (q : ℝ) = value B) : + Reduces B A := by + by_contra h + have hn : ¬ Reduces B (fun _ => false) := by + intro hh + exact h (reduces_trans hh (eventually_constant_reduces (fun _ => false) A false 0 (by simp))) + exact irrational_of_noncomputable B hn ⟨q,hq⟩ + +theorem noncomputable_series (B : Oracle) (h : ¬ Reduces B (fun _ => false)) : + Irrational (value B) ∧ 0 < value B ∧ value B < 1 ∧ + Reduces (cut (value B)) B ∧ Reduces B (cut (value B)) := by + have hm := mixed_of_noncomputable B h + have hi := irrational_of_noncomputable B h + refine ⟨hi,positive B ?_,lt_one B ?_,cut_reduces B hi,set_reduces_cut B hm⟩ + · obtain ⟨n,_,hn⟩ := (hm 0).1 + exact ⟨n,hn⟩ + · obtain ⟨n,_,hn⟩ := (hm 0).2 + exact ⟨n,hn⟩ +end BinarySeries + +theorem irrational_degree_coverage : IrrationalDegreeCoverage := by + intro a ha + obtain ⟨B,rfl⟩ := degree_surjective a + have hn : ¬ Reduces B (fun _ => false) := by + intro h + exact ha (le_antisymm h bot_le) + obtain ⟨hi,h0,h1,hforward,hback⟩ := BinarySeries.noncomputable_series B hn + exact ⟨BinarySeries.value B,hi,h0,h1,(degree_eq_iff _ _).mpr ⟨hforward,hback⟩⟩ + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/EffectiveRecovery.lean b/lean/OAI/Computability/DegreeRigidity/Computability/EffectiveRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..f37e4be37bae5d4d4cc7027950dec7757f3bdb07 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/EffectiveRecovery.lean @@ -0,0 +1,223 @@ +import OAI.Computability.DegreeRigidity.Computability.RationalCoding +import OAI.Computability.DegreeRigidity.Computability.BranchFrequency + +namespace OAI + +namespace TuringRigidity + +namespace EffectiveRecovery +open RationalCoding + +def window (A B : ℕ) (z : Bool × (ℕ × ℕ) × (ℕ × ℕ)) : Option ℕ := + if z.1 then some 1 else + if z.2.1.1*z.2.2.1*A + z.2.1.2*B < z.2.1.2*z.2.2.2*A then some 1 else + if z.2.1.2*(z.2.2.2*A+B) < z.2.1.1*z.2.2.1*A then some 0 else none + +theorem window_primrec (A B : ℕ) : Primrec (window A B) := by + let Q := Primrec.fst.comp (Primrec.fst.comp Primrec.snd) (α := Bool × (ℕ × ℕ) × (ℕ × ℕ)) + let D := Primrec.snd.comp (Primrec.fst.comp Primrec.snd) (α := Bool × (ℕ × ℕ) × (ℕ × ℕ)) + let N := Primrec.fst.comp (Primrec.snd.comp Primrec.snd) (α := Bool × (ℕ × ℕ) × (ℕ × ℕ)) + let S := Primrec.snd.comp (Primrec.snd.comp Primrec.snd) (α := Bool × (ℕ × ℕ) × (ℕ × ℕ)) + exact Primrec.ite (Primrec.eq.comp Primrec.fst (Primrec.const true)) (Primrec.const (some 1)) + (Primrec.ite (Primrec.nat_lt.comp + (Primrec.nat_add.comp (Primrec.nat_mul.comp (Primrec.nat_mul.comp Q N) (Primrec.const A)) + (Primrec.nat_mul.comp D (Primrec.const B))) + (Primrec.nat_mul.comp (Primrec.nat_mul.comp D S) (Primrec.const A))) + (Primrec.const (some 1)) + (Primrec.ite (Primrec.nat_lt.comp + (Primrec.nat_mul.comp D (Primrec.nat_add.comp + (Primrec.nat_mul.comp S (Primrec.const A)) (Primrec.const B))) + (Primrec.nat_mul.comp (Primrec.nat_mul.comp Q N) (Primrec.const A))) + (Primrec.const (some 0)) (Primrec.const none))) + +theorem lower_iff (Q D N S A B : ℕ) (hD : 0 < D) (hN : 0 < N) (hA : 0 < A) : + (Q : ℝ)/D < (S : ℝ)/N - (B : ℝ)/(N*A) ↔ Q*N*A+D*B < D*S*A := by + have hd : (0 : ℝ) < D := by exact_mod_cast hD + have hn : (0 : ℝ) < N := by exact_mod_cast hN + have ha : (0 : ℝ) < A := by exact_mod_cast hA + have hden : (0 : ℝ) < D*N*A := mul_pos (mul_pos hd hn) ha + have he : ((S : ℝ)/N - (B : ℝ)/(N*A) - (Q : ℝ)/D) * (D*N*A) = + (D : ℝ)*S*A - ((Q : ℝ)*N*A+D*B) := by + field_simp + ring + constructor + · intro h + have hp := mul_pos (sub_pos.mpr h) hden + rw [he] at hp + exact_mod_cast sub_pos.mp hp + · intro h + have hr : (Q : ℝ)*N*A+D*B < (D : ℝ)*S*A := by exact_mod_cast h + have hp : 0 < ((S : ℝ)/N - (B : ℝ)/(N*A) - (Q : ℝ)/D) * (D*N*A) := by + rw [he]; linarith + exact sub_pos.mp ((mul_pos_iff_of_pos_right hden).mp hp) + +theorem upper_iff (Q D N S A B : ℕ) (hD : 0 < D) (hN : 0 < N) (hA : 0 < A) : + (S : ℝ)/N + (B : ℝ)/(N*A) < (Q : ℝ)/D ↔ D*(S*A+B) < Q*N*A := by + have hd : (0 : ℝ) < D := by exact_mod_cast hD + have hn : (0 : ℝ) < N := by exact_mod_cast hN + have ha : (0 : ℝ) < A := by exact_mod_cast hA + have hden : (0 : ℝ) < D*N*A := mul_pos (mul_pos hd hn) ha + have he : ((Q : ℝ)/D - ((S : ℝ)/N + (B : ℝ)/(N*A))) * (D*N*A) = + (Q : ℝ)*N*A - (D : ℝ)*(S*A+B) := by + field_simp + constructor + · intro h + have hp := mul_pos (sub_pos.mpr h) hden + rw [he] at hp + exact_mod_cast sub_pos.mp hp + · intro h + have hr : (D : ℝ)*(S*A+B) < (Q : ℝ)*N*A := by exact_mod_cast h + have hp : 0 < ((Q : ℝ)/D - ((S : ℝ)/N + (B : ℝ)/(N*A))) * (D*N*A) := by + rw [he]; linarith + exact sub_pos.mp ((mul_pos_iff_of_pos_right hden).mp hp) +end EffectiveRecovery + +namespace RecoveryData +open RationalCoding EffectiveRecovery +variable {F : ℝ → Oracle} {t u v : ℝ} + +theorem delta_numerator_pos (d : RecoveryData F t u v) : 0 < d.delta.num.natAbs := by + have hn : 0 < d.delta.num := Rat.num_pos.mpr d.delta_pos + have he : (d.delta.num.natAbs : ℤ) = d.delta.num := by + rw [Int.natCast_natAbs,abs_of_pos hn] + rw [←he] at hn + exact_mod_cast hn + +theorem delta_fraction (d : RecoveryData F t u v) : + (d.delta : ℝ) = (d.delta.num.natAbs : ℝ)/(d.delta.den : ℝ) := by + have hn : 0 < d.delta.num := Rat.num_pos.mpr d.delta_pos + have he : (d.delta.num.natAbs : ℤ) = d.delta.num := by + rw [Int.natCast_natAbs,abs_of_pos hn] + have he' : (d.delta.num.natAbs : ℝ) = (d.delta.num : ℝ) := by + simpa only [Int.cast_natCast] using congrArg (fun z : ℤ => (z : ℝ)) he + rw [Rat.cast_def,he'] + +theorem radius_fraction (d : RecoveryData F t u v) (N : ℕ) (hN : 0 < N) : + 1/((N : ℝ)*(d.delta : ℝ)) = (d.delta.den : ℝ)/((N : ℝ)*d.delta.num.natAbs) := by + have hn : (0 : ℝ) < N := by exact_mod_cast hN + have ha : (0 : ℝ) < d.delta.num.natAbs := by exact_mod_cast d.delta_numerator_pos + have hb : (0 : ℝ) < d.delta.den := by exact_mod_cast d.delta.den_pos + rw [d.delta_fraction] + field_simp + +def cutTrial (d : RecoveryData F t u v) (i m : ℕ) : Option ℕ := + window d.delta.num.natAbs d.delta.den + (negative i,(numeratorMagnitude i,denominator i),(m+1,d.count (m+1))) + +theorem cutTrial_recursive (d : RecoveryData F t u v) (ht0 : 0 < t) (ht1 : t < 1) : + Nat.RecursiveIn {oracleFunction (fourTuple F t u v d.delta)} + (fun z => Part.some (Encodable.encode (d.cutTrial (Nat.unpair z).1 (Nat.unpair z).2))) := by + let O : Set (ℕ →. ℕ) := {oracleFunction (fourTuple F t u v d.delta)} + have hq := UniformOracle.total_primrec (O := O) (Primrec.fst.comp Primrec.unpair) + have hN := UniformOracle.total_primrec (O := O) (Primrec.succ.comp (Primrec.snd.comp Primrec.unpair)) + have hS := UniformOracle.total_comp (d.count_recursive ht0 ht1) hN + have hwindow : Primrec (fun z : ℕ => Encodable.encode + (window d.delta.num.natAbs d.delta.den + (negative (Nat.unpair z).1, + (numeratorMagnitude (Nat.unpair z).1,denominator (Nat.unpair z).1), + ((Nat.unpair (Nat.unpair z).2).1,(Nat.unpair (Nat.unpair z).2).2)))) := + Primrec.encode.comp ((window_primrec _ _).comp + ((negative_primrec.comp (Primrec.fst.comp Primrec.unpair)).pair + (((numeratorMagnitude_primrec.comp (Primrec.fst.comp Primrec.unpair)).pair + (denominator_primrec.comp (Primrec.fst.comp Primrec.unpair))).pair + (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair))))) + exact (UniformOracle.total_comp (UniformOracle.total_primrec hwindow) + (UniformOracle.total_pair hq (UniformOracle.total_pair hN hS))).of_eq + (fun z => by simp [cutTrial]) + +theorem cutTrial_sound (d : RecoveryData F t u v) (ht0 : 0 < t) (ht1 : t < 1) + (i m r : ℕ) (hr : r ∈ d.cutTrial i m) : r = if cut t i then 1 else 0 := by + have hn : 0 < m+1 := Nat.succ_pos m + have he := d.count_frequency_bound ht0 ht1 (m+1) hn + rw [d.radius_fraction (m+1) hn] at he + unfold cutTrial window at hr + split at hr + · rename_i hneg + have hr' : r=1 := by symm; simpa using hr + subst r + have hq : (rationalEnumeration i : ℝ) ≤ 0 := by + rw [query_value,ite_eq_left hneg] + exact div_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr (Nat.cast_nonneg _)) (Nat.cast_nonneg _) + have hc : cut t i = true := (cut_eq_true t i).mpr (hq.trans_lt ht0) + simp [hc] + · rename_i hneg + have hq : (rationalEnumeration i : ℝ) = (numeratorMagnitude i : ℝ)/(denominator i : ℝ) := by + rw [query_value,ite_eq_right hneg] + split at hr + · rename_i hl + have hr' : r=1 := by symm; simpa using hr + subst r + have hl' := (lower_iff (numeratorMagnitude i) (denominator i) (m+1) (d.count (m+1)) + d.delta.num.natAbs d.delta.den (denominator_pos i) hn d.delta_numerator_pos).mpr hl + rw [←hq] at hl' + have hh := (abs_lt.mp he).1 + have hc : cut t i = true := (cut_eq_true t i).mpr (by linarith) + simp [hc] + · split at hr + · rename_i hu + have hr' : r=0 := by symm; simpa using hr + subst r + have hu' := (upper_iff (numeratorMagnitude i) (denominator i) (m+1) (d.count (m+1)) + d.delta.num.natAbs d.delta.den (denominator_pos i) hn d.delta_numerator_pos).mpr hu + rw [←hq] at hu' + have hh := (abs_lt.mp he).2 + have htq : t < (rationalEnumeration i : ℝ) := by linarith + have hc : cut t i = false := Bool.eq_false_iff.mpr + (fun h => (not_lt_of_gt htq) ((cut_eq_true t i).mp h)) + simp [hc] + · simp at hr + +theorem cutTrial_complete (d : RecoveryData F t u v) (ht : Irrational t) + (ht0 : 0 < t) (ht1 : t < 1) (i : ℕ) : ∃ m r, r ∈ d.cutTrial i m := by + by_cases hneg : negative i = true + · exact ⟨0,1,by simp [cutTrial,window,hneg]⟩ + · have hq : (rationalEnumeration i : ℝ) = (numeratorMagnitude i : ℝ)/(denominator i : ℝ) := by + rw [query_value,ite_eq_right hneg] + have hne : (rationalEnumeration i : ℝ) ≠ t := fun h => ht ⟨rationalEnumeration i,h⟩ + obtain ⟨⟨N,hN,hs⟩,_⟩ := comparison_search t (d.delta : ℝ) + (fun n => (d.count n : ℝ)/(n : ℝ)) (by exact_mod_cast d.delta_pos) + (fun n hn => d.count_frequency_bound ht0 ht1 n hn) (rationalEnumeration i) hne + rw [d.radius_fraction N hN,hq] at hs + have hm : N-1+1=N := by omega + rcases hs with hl | hu + · have hl' := (lower_iff (numeratorMagnitude i) (denominator i) N (d.count N) + d.delta.num.natAbs d.delta.den (denominator_pos i) hN d.delta_numerator_pos).mp hl + exact ⟨N-1,1,by simp [cutTrial,hm,window,hneg,hl']⟩ + · have hu' := (upper_iff (numeratorMagnitude i) (denominator i) N (d.count N) + d.delta.num.natAbs d.delta.den (denominator_pos i) hN d.delta_numerator_pos).mp hu + by_cases hl' : numeratorMagnitude i*N*d.delta.num.natAbs+denominator i*d.delta.den < + denominator i*d.count N*d.delta.num.natAbs + · exact ⟨N-1,1,by simp [cutTrial,hm,window,hneg,hl']⟩ + · exact ⟨N-1,0,by simp [cutTrial,hm,window,hneg,hl',hu']⟩ + +theorem cut_reduces (d : RecoveryData F t u v) (ht : Irrational t) + (ht0 : 0 < t) (ht1 : t < 1) : Reduces (cut t) (fourTuple F t u v d.delta) := by + apply RecursiveIn.iff_nat.mpr + exact UniformOracle.total_search (d.cutTrial_recursive ht0 ht1) + (fun i => if cut t i then 1 else 0) (d.cutTrial_sound ht0 ht1) + (d.cutTrial_complete ht ht0 ht1) + +theorem cut_single_program (d : RecoveryData F t u v) (ht : Irrational t) + (ht0 : 0 < t) (ht1 : t < 1) : + ∃ c : OracleCode, OracleCode.eval (oracleFunction (fourTuple F t u v d.delta)) c = + oracleFunction (cut t) := + (OracleCode.turingReducible_iff_exists_code _ _).mp (d.cut_reduces ht ht0 ht1) + +end RecoveryData + +theorem four_value_recovery : FourValueRecovery := by + intro F hF hfiber hadd t ht ht0 ht1 + obtain ⟨G,hG,hdata⟩ := recovery_data_exists F hF hfiber hadd t + refine ⟨G,hG,?_⟩ + intro p hp + obtain ⟨d⟩ := hdata p hp + refine ⟨d.delta,d.delta_pos,?_,d.cut_reduces ht ht0 ht1⟩ + exact_mod_cast d.delta_lt.trans d.radius_lt_one + +theorem main_of_remaining_obligations (hrep : BorelRepresentation) (harith : CutArithmetic) + (hcover : IrrationalDegreeCoverage) (havoid : CategoryAvoidance) : MainTheorem := + main_of_obligations hrep harith hcover four_value_recovery havoid + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/Introreducible.lean b/lean/OAI/Computability/DegreeRigidity/Computability/Introreducible.lean new file mode 100644 index 0000000000000000000000000000000000000000..83296b39febe7bacf978bad854b397faf1d05c4a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/Introreducible.lean @@ -0,0 +1,159 @@ +import OAI.Computability.DegreeRigidity.Effective.PrefixComputability +import Mathlib.Data.Set.Finite.Range +import Lean.Elab.Tactic.Omega + +namespace OAI + +namespace TuringRigidity +namespace Introreducible +open Encodable PrefixComputability + +def bit (X : Oracle) (n : ℕ) : ℕ := if X n then 1 else 0 + +def prefixCode (X : Oracle) (n : ℕ) : ℕ := encode (oraclePrefix (bit X) n) + +def codeList (c : ℕ) : List ℕ := (decode (α := List ℕ) c).getD [] +def codeLength (c : ℕ) : ℕ := (codeList c).length + +def prefixSet (X : Oracle) (c : ℕ) : Bool := decide (prefixCode X (codeLength c) = c) + +@[simp] theorem codeList_prefix (X : Oracle) (n : ℕ) : + codeList (prefixCode X n) = oraclePrefix (bit X) n := by + simp [codeList, prefixCode] + +@[simp] theorem codeLength_prefix (X : Oracle) (n : ℕ) : + codeLength (prefixCode X n) = n := by + simp [codeLength, oraclePrefix] + +@[simp] theorem prefixSet_prefix (X : Oracle) (n : ℕ) : + prefixSet X (prefixCode X n) = true := by + simp [prefixSet] + +theorem prefixCode_injective (X : Oracle) : Function.Injective (prefixCode X) := by + intro n m h + simpa using congrArg codeLength h + +theorem prefixSet_infinite (X : Oracle) : {c | prefixSet X c = true}.Infinite := by + apply (Set.infinite_range_of_injective (prefixCode_injective X)).mono + rintro _ ⟨n, rfl⟩ + exact prefixSet_prefix X n + +theorem subset_unbounded {X Z : Oracle} + (hsub : ∀ c, Z c = true → prefixSet X c = true) + (hinf : {c | Z c = true}.Infinite) (n : ℕ) : + ∃ c, Z c = true ∧ n < codeLength c := by + by_contra h + have hb : ∀ c, Z c = true → codeLength c ≤ n := by + intro c hc + by_contra hn + exact h ⟨c, hc, Nat.lt_of_not_ge hn⟩ + apply hinf + apply ((Set.finite_le_nat n).image (prefixCode X)).subset + intro c hc + have he := of_decide_eq_true (hsub c hc) + exact ⟨codeLength c, hb c hc, he⟩ + +theorem codeList_primrec : Primrec codeList := + Primrec.option_getD_default.comp Primrec.decode + +theorem codeLength_primrec : Primrec codeLength := + Primrec.list_length.comp codeList_primrec + +private def equalBit (c : ℕ) : ℕ := + if (Nat.unpair c).1 = (Nat.unpair c).2 then 1 else 0 + +private theorem equalBit_primrec : Primrec equalBit := by + apply (Primrec.ite (Primrec.eq.comp (Primrec.fst.comp Primrec.unpair) + (Primrec.snd.comp Primrec.unpair)) (Primrec.const 1) (Primrec.const 0)).of_eq + intro n + simp [equalBit] + +theorem prefixSet_reduces (X : Oracle) : Reduces (prefixSet X) X := by + apply RecursiveIn.iff_nat.mpr + have hp := total_comp (prefix_recursive (bit X)) (total_primrec codeLength_primrec) + have he := total_comp (total_primrec equalBit_primrec) + (total_pair hp (total_primrec Primrec.id)) + apply he.of_eq + intro n + by_cases h : encode (oraclePrefix (bit X) (codeLength n)) = n + · simp [oracleFunction, prefixSet, equalBit, prefixCode, h] + · simp [oracleFunction, prefixSet, equalBit, prefixCode, h] + +def codeBit (n c : ℕ) : ℕ := (codeList c).getD n 0 + +@[simp] theorem codeBit_prefix (X : Oracle) (n m : ℕ) (h : n < m) : + codeBit n (prefixCode X m) = bit X n := by + simp [codeBit, oraclePrefix, List.getD_eq_getElem?_getD, List.getElem?_range h] + +theorem codeBit_primrec : Primrec₂ codeBit := + (Primrec.list_getD 0).comp (codeList_primrec.comp Primrec.snd) Primrec.fst + +def trial (Z : Oracle) (n c : ℕ) : Option ℕ := + if Z c = true ∧ n < codeLength c then some (codeBit n c) else none + +private def trialStep (p : ℕ) : ℕ := + let n := (Nat.unpair p).1 + let c := (Nat.unpair (Nat.unpair p).2).1 + let b := (Nat.unpair (Nat.unpair p).2).2 + encode (if b = 1 ∧ n < codeLength c then some (codeBit n c) else none) + +private theorem trialStep_primrec : Primrec trialStep := by + let hn := Primrec.fst.comp Primrec.unpair + let hc := Primrec.fst.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)) + let hb := Primrec.snd.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)) + apply (Primrec.encode.comp (Primrec.ite + ((Primrec.eq.comp hb (Primrec.const 1)).and + (Primrec.nat_lt.comp hn (codeLength_primrec.comp hc))) + (Primrec.option_some.comp (codeBit_primrec.comp hn hc)) (Primrec.const none))).of_eq + intro p + simp [trialStep] + +theorem trial_recursive (Z : Oracle) : + Nat.RecursiveIn {oracleFunction Z} + (fun p => Part.some (encode (trial Z (Nat.unpair p).1 (Nat.unpair p).2))) := by + have hq : Nat.RecursiveIn {oracleFunction Z} (oracleFunction Z) := + .oracle _ (Set.mem_singleton _) + have hn := total_primrec (O := {oracleFunction Z}) (Primrec.fst.comp Primrec.unpair) + have hc := total_primrec (O := {oracleFunction Z}) (Primrec.snd.comp Primrec.unpair) + have ht := total_comp (total_primrec trialStep_primrec) + (total_pair hn (total_pair hc (total_comp hq hc))) + apply ht.of_eq + intro p + cases hz : Z (Nat.unpair p).2 <;> simp [trialStep, trial, hz] + +theorem reduces_of_infinite_subset {X Z : Oracle} + (hsub : ∀ c, Z c = true → prefixSet X c = true) + (hinf : {c | Z c = true}.Infinite) : Reduces X Z := by + apply RecursiveIn.iff_nat.mpr + change Nat.RecursiveIn {oracleFunction Z} (fun n => Part.some (bit X n)) + apply total_search (trial_recursive Z) (bit X) + · intro n c a ha + simp only [trial] at ha + split at ha + next h => + have he : prefixCode X (codeLength c) = c := of_decide_eq_true (hsub c h.1) + have ha' : a = codeBit n c := (Option.mem_some_iff.mp ha).symm + rw [ha', ← he] + exact codeBit_prefix X n (codeLength c) h.2 + next h => simp at ha + · intro n + obtain ⟨c, hc, hn⟩ := subset_unbounded hsub hinf n + exact ⟨c, codeBit n c, by simp [trial, hc, hn]⟩ + +theorem prefixSet_degree (X : Oracle) : degree (prefixSet X) = degree X := by + apply (degree_eq_iff _ _).mpr + exact ⟨prefixSet_reduces X, reduces_of_infinite_subset (fun _ h => h) + (prefixSet_infinite X)⟩ + +theorem introreducible_representative (X : Oracle) : + ∃ Y : Oracle, degree Y = degree X ∧ {n | Y n = true}.Infinite ∧ + ∀ Z : Oracle, (∀ n, Z n = true → Y n = true) → + {n | Z n = true}.Infinite → Reduces Y Z := by + refine ⟨prefixSet X, prefixSet_degree X, prefixSet_infinite X, ?_⟩ + intro Z hsub hinf + exact reduces_trans (prefixSet_reduces X) (reduces_of_infinite_subset hsub hinf) + +end Introreducible +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/Joins.lean b/lean/OAI/Computability/DegreeRigidity/Computability/Joins.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1fef91a3f9e3cac81af05a5a4b4983188d94424 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/Joins.lean @@ -0,0 +1,126 @@ +import OAI.Computability.DegreeRigidity.Computability.OracleCode +import Lean.Elab.Tactic.Omega + +namespace OAI + +namespace TuringRigidity + +def join (A B : Oracle) (n : ℕ) : Bool := if n.bodd then B (n / 2) else A (n / 2) + +private theorem total_comp {O : Set (ℕ →. ℕ)} {f g : ℕ → ℕ} + (hf : Nat.RecursiveIn O (fun n => Part.some (f n))) + (hg : Nat.RecursiveIn O (fun n => Part.some (g n))) : + Nat.RecursiveIn O (fun n => Part.some (f (g n))) := by + simpa using Nat.RecursiveIn.comp hf hg + +private theorem total_pair {O : Set (ℕ →. ℕ)} {f g : ℕ → ℕ} + (hf : Nat.RecursiveIn O (fun n => Part.some (f n))) + (hg : Nat.RecursiveIn O (fun n => Part.some (g n))) : + Nat.RecursiveIn O (fun n => Part.some (Nat.pair (f n) (g n))) := by + simpa [Seq.seq] using Nat.RecursiveIn.pair hf hg + +private theorem total_primrec {O : Set (ℕ →. ℕ)} {f : ℕ → ℕ} + (hf : Primrec f) : Nat.RecursiveIn O (fun n => Part.some (f n)) := + RecursiveIn.iff_nat.mp hf.computableIn + +@[simp] theorem join_even (A B : Oracle) (n : ℕ) : join A B (2*n) = A n := by + simp [join, Nat.bodd_mul] + +@[simp] theorem join_odd (A B : Oracle) (n : ℕ) : join A B (2*n+1) = B n := by + simp [join, Nat.bodd_mul] + congr 1 + omega + +theorem reduces_join_left (A B : Oracle) : Reduces A (join A B) := by + apply RecursiveIn.iff_nat.mpr + have horacle : Nat.RecursiveIn {oracleFunction (join A B)} (oracleFunction (join A B)) := + .oracle _ (Set.mem_singleton _) + have h := total_comp horacle (total_primrec (Primrec.nat_mul.comp (Primrec.const 2) Primrec.id)) + change Nat.RecursiveIn {oracleFunction (join A B)} (fun n => Part.some (if A n then 1 else 0)) + simpa [oracleFunction] using h + +theorem reduces_join_right (A B : Oracle) : Reduces B (join A B) := by + apply RecursiveIn.iff_nat.mpr + have horacle : Nat.RecursiveIn {oracleFunction (join A B)} (oracleFunction (join A B)) := + .oracle _ (Set.mem_singleton _) + have h := total_comp horacle (total_primrec + (Primrec.nat_add.comp (Primrec.nat_mul.comp (Primrec.const 2) Primrec.id) (Primrec.const 1))) + change Nat.RecursiveIn {oracleFunction (join A B)} (fun n => Part.some (if B n then 1 else 0)) + simpa [oracleFunction] using h + +private def selectPair (k : ℕ) : ℕ := + if (Nat.unpair k).1.bodd then (Nat.unpair (Nat.unpair k).2).2 + else (Nat.unpair (Nat.unpair k).2).1 + +private theorem selectPair_primrec : Primrec selectPair := by + apply (Primrec.cond (Primrec.nat_bodd.comp (Primrec.fst.comp Primrec.unpair)) + (Primrec.snd.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair))) + (Primrec.fst.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)))).of_eq + intro n + cases hb : (Nat.unpair n).1.bodd <;> simp [selectPair, hb] + +theorem join_reduces {A B C : Oracle} (hA : Reduces A C) (hB : Reduces B C) : + Reduces (join A B) C := by + apply RecursiveIn.iff_nat.mpr + have hA' := RecursiveIn.iff_nat.mp hA + have hB' := RecursiveIn.iff_nat.mp hB + have hdiv : Nat.RecursiveIn {oracleFunction C} (fun n => Part.some (n / 2)) := + total_primrec (Primrec.nat_div.comp Primrec.id (Primrec.const 2)) + have hp := total_pair (total_primrec Primrec.id) + (total_pair (total_comp hA' hdiv) (total_comp hB' hdiv)) + have h := total_comp (total_primrec selectPair_primrec) hp + apply Nat.RecursiveIn.of_eq h + intro n + simp only [selectPair, Nat.unpair_pair, oracleFunction, join, id_eq] + by_cases hb : n.bodd = true <;> simp [hb] + +theorem join_reduces_iff (A B C : Oracle) : + Reduces (join A B) C ↔ Reduces A C ∧ Reduces B C := + ⟨fun h => ⟨reduces_trans (reduces_join_left A B) h, + reduces_trans (reduces_join_right A B) h⟩, fun h => join_reduces h.1 h.2⟩ + +theorem join_mono {A B C D : Oracle} (hA : Reduces A C) (hB : Reduces B D) : + Reduces (join A B) (join C D) := + join_reduces (reduces_trans hA (reduces_join_left C D)) + (reduces_trans hB (reduces_join_right C D)) + +def degreeJoin (a b : Degree) : Degree := + Quotient.liftOn₂ a b (fun A B => degree (join A B)) + (fun _ _ _ _ hA hB => (degree_eq_iff _ _).mpr + ⟨join_mono hA.1 hB.1, join_mono hA.2 hB.2⟩) + +@[simp] theorem degree_join (A B : Oracle) : + degreeJoin (degree A) (degree B) = degree (join A B) := rfl + +instance : SemilatticeSup Degree where + sup := degreeJoin + le_sup_left a b := by + obtain ⟨A, rfl⟩ := degree_surjective a + obtain ⟨B, rfl⟩ := degree_surjective b + exact reduces_join_left A B + le_sup_right a b := by + obtain ⟨A, rfl⟩ := degree_surjective a + obtain ⟨B, rfl⟩ := degree_surjective b + exact reduces_join_right A B + sup_le a b c := by + obtain ⟨A, rfl⟩ := degree_surjective a + obtain ⟨B, rfl⟩ := degree_surjective b + obtain ⟨C, rfl⟩ := degree_surjective c + exact join_reduces + +instance : OrderBot Degree where + bot := degree (fun _ => false) + bot_le a := by + obtain ⟨A, rfl⟩ := degree_surjective a + apply RecursiveIn.iff_nat.mpr + change Nat.RecursiveIn {oracleFunction A} (fun _ => Part.some 0) + exact .zero + +theorem automorphism_preserves_join (π : Degree ≃o Degree) (a b : Degree) : + π (a ⊔ b) = π a ⊔ π b := π.map_sup a b + +theorem automorphism_fixes_zero (π : Degree ≃o Degree) : π ⊥ = ⊥ := π.map_bot + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/JumpIdeal.lean b/lean/OAI/Computability/DegreeRigidity/Computability/JumpIdeal.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f52dd0aff0f131ce157059f7608ee84df297685 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/JumpIdeal.lean @@ -0,0 +1,55 @@ +import OAI.Computability.DegreeRigidity.Constructibility.PersistentLocality +import OAI.Computability.DegreeRigidity.Representation.GlobalLocality + +namespace OAI + +namespace TuringRigidity.JumpIdeal +open OracleJump IdealInterpretation IdealLocality PersistentRestrictions PersistentLocality GlobalLocality +noncomputable section + +theorem iterate_monotone (x : Degree) : Monotone (degreeIterate x) := by + apply monotone_nat_of_le_succ + intro n + exact degree_le_jump _ + +def generated (x : Degree) : CountableIdeal where + carrier := {y | ∃ n, y ≤ degreeIterate x n} + nonempty := ⟨x,0,le_rfl⟩ + countable := by + have he : {y | ∃ n, y ≤ degreeIterate x n} = ⋃ n, Set.Iic (degreeIterate x n) := by + ext y + simp only [Set.mem_ofPred_eq,Set.mem_iUnion,Set.mem_Iic] + rw [he] + exact Set.countable_iUnion (fun n => countable_principal_lower _) + lower := by + intro a b hab hb + obtain ⟨n,hn⟩ := hb + exact ⟨n,hab.trans hn⟩ + join_mem := by + intro a b ha hb + obtain ⟨m,hm⟩ := ha + obtain ⟨n,hn⟩ := hb + exact ⟨max m n,sup_le (hm.trans (iterate_monotone x (le_max_left m n))) + (hn.trans (iterate_monotone x (le_max_right m n)))⟩ + +theorem includes (x : Degree) : x ∈ (generated x).carrier := ⟨0,le_rfl⟩ + +theorem closed (x : Degree) : JumpClosed (ideal (generated x)) := by + intro y hy + obtain ⟨n,hn⟩ := hy + exact ⟨n+1,degreeJump_mono hn⟩ + +theorem least (x : Degree) (J : DegreeIdeal) (hx : x ∈ J.carrier) + (hj : JumpClosed J) : (generated x).carrier ⊆ J.carrier := by + have hi (n : ℕ) : degreeIterate x n ∈ J.carrier := by + induction n with + | zero => exact hx + | succ n ih => exact hj _ ih + intro y hy + obtain ⟨n,hn⟩ := hy + exact J.lower hn (hi n) + +end +end TuringRigidity.JumpIdeal + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/JumpIdealPresentation.lean b/lean/OAI/Computability/DegreeRigidity/Computability/JumpIdealPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..1216828a1a2044bb1d3462adb77aaef432d3f5ea --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/JumpIdealPresentation.lean @@ -0,0 +1,88 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticJumpBound + +namespace OAI + +namespace TuringRigidity.JumpIdealPresentation +open Encodable EncodedForcing OracleJump ArithmeticHierarchy IndexMatrix TableIndices +open PersistentRestrictions PersistentPresentation UniformArithmetic +noncomputable section + +def omegaJump (X : Oracle) : Oracle := fun v => iterate X (Nat.unpair v).1 (Nat.unpair v).2 + +@[simp] theorem omegaJump_column (X : Oracle) (n : ℕ) : + columns (omegaJump X) n = iterate X n := by + funext k + simp [columns,omegaJump] + +def presentation (X : Oracle) : Oracle := fun v => + tableOracle (iterate X (Nat.unpair (Nat.unpair v).1).1) + (Nat.unpair (Nat.unpair v).1).2 (Nat.unpair v).2 + +@[simp] theorem presentation_column (X : Oracle) (n e : ℕ) : + columns (presentation X) (Nat.pair n e) = tableOracle (iterate X n) e := by + funext k + simp [columns,presentation] + +theorem graph_sigma (Y : Oracle) (e : ℕ) : Sigma Y 1 (tableGraph Y e) := by + classical + have hr := IndexMatrix.run_uniform_recursive Y + have hf := UniformOracle.total_comp hr (UniformOracle.total_primrec + (Primrec₂.natPair.comp (Primrec.const e) + (Primrec₂.natPair.comp UniformArithmetic.left_primrec UniformArithmetic.right_primrec))) + have hcheck : Primrec (fun q : ℕ => if q = encode (some (1 : ℕ)) then 1 else 0) := + Primrec.ite (Primrec.eq.comp Primrec.id (Primrec.const _)) (Primrec.const 1) (Primrec.const 0) + have h : RecursivePred Y (fun v => run Y (machine e) (Nat.unpair v).1 (Nat.unpair v).2 = some 1) := by + exact (UniformOracle.total_comp (UniformOracle.total_primrec hcheck) hf).of_eq + (fun v => by simp only [Nat.unpair_pair,Encodable.encode_injective.eq_iff,UniformArithmetic.left,UniformArithmetic.right]; split <;> simp_all) + exact (exists_form (n := 0) h).congr + (fun _ => by simp only [Nat.unpair_pair,tableGraph]) + +theorem tableOracle_reduces_jump (Y : Oracle) (e : ℕ) : + Reduces (tableOracle Y e) (jump Y) := by + apply RecursiveIn.iff_nat.mpr + exact (form_recursive (graph_sigma Y e)).of_eq + (fun v => by + classical + simp [oracleFunction,tableOracle]) + +theorem presents (X : Oracle) : Presented (JumpIdeal.generated (degree X)) (presentation X) := by + intro x + constructor + · rintro ⟨n,hn⟩ + have hx : x ≤ degree (iterate X n) := by simpa only [GlobalLocality.degreeIterate_degree] using hn + obtain ⟨A,rfl⟩ := degree_surjective x + obtain ⟨d,hd⟩ := reduces_represents hx + have hd' : Represents (iterate X n) (machine (encode d)) A := by simpa using hd + refine ⟨Nat.pair n (encode d),?_⟩ + rw [presentation_column,tableOracle_eq hd'] + · rintro ⟨k,rfl⟩ + obtain ⟨⟨n,e⟩,rfl⟩ := Nat.pairEquiv.surjective k + change degree (columns (presentation X) (Nat.pair n e)) ∈ _ + rw [presentation_column] + refine ⟨n+1,?_⟩ + simpa only [GlobalLocality.degreeIterate_degree,iterate,degree_le_iff] using tableOracle_reduces_jump (iterate X n) e + +theorem presentation_arith : Arith (fun O v => + tableOracle (columns (O 0) (Nat.unpair (Nat.unpair v).1).1) + (Nat.unpair (Nat.unpair v).1).2 (Nat.unpair v).2 = true) := by + have hB := column_arith (parameter_arith 0) UniformArithmetic.left_primrec + have h := tableOracle_arith hB UniformArithmetic.right_primrec + exact h + +theorem presentation_bounded (X : Oracle) : + ∃ k, Reduces (presentation X) (iterate (omegaJump X) k) := by + obtain ⟨k,hk⟩ := presentation_arith.jump_bound + refine ⟨k,RecursiveIn.iff_nat.mpr ?_⟩ + have h := hk (fun _ => omegaJump X) (omegaJump X) (fun _ => reduces_refl _) + exact h.of_eq (fun v => by + simp only [omegaJump_column] + by_cases value : presentation X v = true + · simp [oracleFunction,presentation] at value ⊢ + simp [value] + · simp [oracleFunction,presentation] at value ⊢ + simp [value]) + +end +end TuringRigidity.JumpIdealPresentation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/JumpIterationFormula.lean b/lean/OAI/Computability/DegreeRigidity/Computability/JumpIterationFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..5260a62e345a047ce7fcb2b25492e6a21ff4ae3b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/JumpIterationFormula.lean @@ -0,0 +1,39 @@ +import OAI.Computability.DegreeRigidity.Computability.JumpSetFormula +import OAI.Computability.DegreeRigidity.SetModels.ModelIterationFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open UniformArithmetic OracleJump +universe u + +def JumpFormula (φ : Formula) : Prop := ∀ o Q x y : ℕ, ∀ e : ℕ → ZFSet.{u}, + e o = ZFSet.omega → (∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) → + ∀ A B : Oracle, e x = realCode A → e y = realCode B → + ((Formula.oracleGraph φ o Q x y).Eval e ↔ B = jump A) + +namespace Formula +def jumpIteration (φ : Formula) (o R Qf Qn n A B : ℕ) : Formula := + modelIteration o R Qf n A B (oracleGraph φ (o+3) (Qn+3) 1 0) + +theorem jumpIteration_spec {φ : Formula} (hφ : JumpFormula.{u} φ) + (o R Qf Qn n x y : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQn : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Qn) + (hQf : ∀ a : ℕ → ZFSet.{u}, (∀ i, a i ∈ e R) → ∀ k, finiteModelGraph a k ∈ e Qf) + (hR : ∀ w ∈ e R, ∃ B : Oracle, realCode B = w) + (A : Oracle) (hA : ∀ i, realCode (iterate A i) ∈ e R) + (hx : e x = realCode A) (N : ℕ) (hn : e n = natSet N) : + (jumpIteration φ o R Qf Qn n x y).Eval e ↔ e y = realCode (iterate A N) := by + apply modelIteration_spec o R Qf n x y _ e ho hQf N hn + (fun i => realCode (iterate A i)) hA hx + intro i w hw + obtain ⟨B,rfl⟩ := hR w hw + rw [hφ (o+3) (Qn+3) 1 0 (cons (realCode B) (cons (realCode (iterate A i)) (cons (natSet i) e))) + ho hQn (iterate A i) B rfl rfl] + exact ⟨fun h => congrArg realCode h,fun h => realCode_injective h⟩ +end Formula + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/JumpProperties.lean b/lean/OAI/Computability/DegreeRigidity/Computability/JumpProperties.lean new file mode 100644 index 0000000000000000000000000000000000000000..9039b8ce50e6ead21fce6352c81ee07c54e9d34f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/JumpProperties.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DegreeRigidity.Computability.OracleJump +import OAI.Computability.DegreeRigidity.Computability.ArithmeticAtoms + +namespace OAI + +namespace TuringRigidity.OracleJump +open Encodable UniformOracle CommonIdeal TableIndices IndexMatrix ArithmeticHierarchy + +theorem recursive_transfer {Y Z : Oracle} {P : ℕ → Prop} + (h : RecursivePred Y P) (hYZ : Reduces Y Z) : RecursivePred Z P := + RecursiveIn.iff_nat.mp (TuringReducible.trans (RecursiveIn.iff_nat.mpr h) hYZ) + +theorem recursive_lift {Y : Oracle} {P : ℕ → Prop} (h : RecursivePred Y P) : + RecursivePred (jump Y) P := by + have hh := exists_recursive_jump (recursive_comp h (Primrec.fst.comp Primrec.unpair)) + exact Form.congr (n := 0) (s := true) hh (fun x => by simp) + +theorem reduces_jump (Y : Oracle) : Reduces Y (jump Y) := by + have h : RecursivePred Y (fun x => Y x = true) := by + classical + have hq : Nat.RecursiveIn {oracleFunction Y} (oracleFunction Y) := + .oracle _ (Set.mem_singleton _) + exact hq.of_eq (fun x => by cases hy : Y x <;> simp [oracleFunction,hy]) + apply RecursiveIn.iff_nat.mpr + exact (recursive_lift h).of_eq (fun x => by cases hy : Y x <;> simp [oracleFunction,hy]) + +theorem halts_sigma (Y : Oracle) : + Sigma Y 1 (fun v => Halts Y (Nat.unpair v).1 (Nat.unpair v).2) := by + classical + let f := Primrec.fst.comp Primrec.unpair + let s := Primrec.snd.comp Primrec.unpair + have ht := total_comp (run_uniform_recursive Y) (total_primrec + (Primrec₂.natPair.comp (f.comp f) (Primrec₂.natPair.comp (s.comp f) s))) + have hcheck : Primrec (fun v : ℕ => bit ((decode (α := Option ℕ) v).getD none).isSome) := + bit_primrec.comp (Primrec.option_isSome.comp + (Primrec.option_getD.comp Primrec.decode (Primrec.const none))) + have h : RecursivePred Y (fun v => + (TableIndices.run Y (machine (Nat.unpair (Nat.unpair v).1).1) + (Nat.unpair (Nat.unpair v).1).2 (Nat.unpair v).2).isSome = true) := by + exact (total_comp (total_primrec hcheck) ht).of_eq (fun v => by + simp only [Nat.unpair_pair, encodek, Option.getD_some, bit] + congr 1 + split <;> rfl) + apply (exists_form (n := 0) h).congr + intro v + simp only [Nat.unpair_pair, Halts] + apply exists_congr + intro z + cases TableIndices.run Y (machine (Nat.unpair v).1) (Nat.unpair v).2 z <;> simp + +theorem jump_mono {Y Z : Oracle} (hYZ : Reduces Y Z) : Reduces (jump Y) (jump Z) := by + obtain ⟨Q,hQ,he⟩ := halts_sigma Y + have h := exists_recursive_jump (recursive_transfer hQ hYZ) + have h' : RecursivePred (jump Z) (fun v => Halts Y (Nat.unpair v).1 (Nat.unpair v).2) := + Form.congr (n := 0) (s := true) h (fun v => (he v).symm) + apply RecursiveIn.iff_nat.mpr + exact h'.of_eq (fun v => by + classical + by_cases h : Halts Y (Nat.unpair v).1 (Nat.unpair v).2 <;> simp [oracleFunction, jump, h]) + +theorem iterate_mono {Y Z : Oracle} (hYZ : Reduces Y Z) (n : ℕ) : + Reduces (iterate Y n) (iterate Z n) := by + induction n with + | zero => exact hYZ + | succ n ih => exact jump_mono ih + +noncomputable def degreeJump (x : Degree) : Degree := + Quotient.liftOn x (fun Y => degree (jump Y)) (fun Y Z h => + (degree_eq_iff (jump Y) (jump Z)).mpr ⟨jump_mono h.1, jump_mono h.2⟩) + +@[simp] theorem degreeJump_degree (Y : Oracle) : degreeJump (degree Y) = degree (jump Y) := rfl + +theorem degree_le_jump (x : Degree) : x ≤ degreeJump x := by + obtain ⟨Y,rfl⟩ := degree_surjective x + exact reduces_jump Y + +theorem degreeJump_mono : Monotone degreeJump := by + intro x y h + obtain ⟨Y,rfl⟩ := degree_surjective x + obtain ⟨Z,rfl⟩ := degree_surjective y + exact jump_mono h + +end TuringRigidity.OracleJump + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/JumpSetFormula.lean b/lean/OAI/Computability/DegreeRigidity/Computability/JumpSetFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac95f0073c8228c3da45e05b0c1b3128fa344da3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/JumpSetFormula.lean @@ -0,0 +1,75 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelRealOperations + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open UniformArithmetic OracleJump +universe u + +namespace Formula +def singleOracleVars (o Q A n : ℕ) : ℕ → ℕ + | 0 => n + | 1 => o + | 2 => Q + | _+3 => A + +def singleOracle (φ : Formula) (o Q A n : ℕ) : Formula := φ.rename (singleOracleVars o Q A n) + +theorem singleOracle_spec {φ : Formula} {P : Predicate} (hφ : DefinesArithmetic.{u} φ P) + (o Q A n : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) + (B : Oracle) (hA : e A = realCode B) (N : ℕ) (hn : e n = natSet N) : + (singleOracle φ o Q A n).Eval e ↔ P (fun _ => B) N := by + rw [singleOracle,eval_rename] + have he : (fun i => e (singleOracleVars o Q A n i)) = arithmeticEnv (e Q) (fun _ => B) N := by + funext i + rcases i with _|i; exact hn + rcases i with _|i; exact ho + rcases i with _|i; rfl + exact hA + rw [he] + exact hφ _ hQ _ _ + +def oracleGraph (φ : Formula) (o Q A B : ℕ) : Formula := + allMem o (iff (.member 0 (B+1)) (singleOracle φ (o+1) (Q+1) (A+1) 0)) + +theorem oracleGraph_spec {φ : Formula} {P : Predicate} (hφ : DefinesArithmetic.{u} φ P) + (o Q x y : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) + (A B : Oracle) (hx : e x = realCode A) (hy : e y = realCode B) : + (oracleGraph φ o Q x y).Eval e ↔ ∀ n, B n = true ↔ P (fun _ => A) n := by + simp only [oracleGraph,eval_allMem,eval_iff,Formula.Eval,cons_zero,cons_succ] + rw [ho] + constructor + · intro h n + have hn := h (natSet n) ((mem_omega _).mpr ⟨n,rfl⟩) + rw [hy,natSet_mem_realCode] at hn + exact hn.trans (singleOracle_spec hφ (o+1) (Q+1) (x+1) 0 (cons (natSet n) e) ho hQ A hx n rfl) + · intro h z hz + obtain ⟨n,rfl⟩ := (mem_omega z).mp hz + rw [hy,natSet_mem_realCode] + exact (h n).trans (singleOracle_spec hφ (o+1) (Q+1) (x+1) 0 (cons (natSet n) e) ho hQ A hx n rfl).symm +end Formula + +theorem jump_bounded_relation : ∃ φ : Formula, ∀ o Q x y : ℕ, ∀ e : ℕ → ZFSet.{u}, + e o = ZFSet.omega → (∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) → + ∀ A B : Oracle, e x = realCode A → e y = realCode B → + ((Formula.oracleGraph φ o Q x y).Eval e ↔ B = jump A) := by + have h := Arith.comp (fun n => Nat.pair 0 n) (jump_arith (parameter_arith 0)) + (Primrec₂.natPair.comp (Primrec.const 0) Primrec.id) + have hp : Arith (fun O n => jump (O 0) n = true) := h.congr (fun _ _ => by simp only [right,Nat.unpair_pair]) + obtain ⟨φ,hφ⟩ := arithmetic_bounded_definition.{u} hp + refine ⟨φ,?_⟩ + intro o Q x y e ho hQ A B hx hy + rw [Formula.oracleGraph_spec hφ o Q x y e ho hQ A B hx hy] + constructor + · intro hb + funext n + have hn := hb n + cases ha : B n <;> cases hj : jump A n <;> simp_all + · intro hb; subst B; exact fun _ => Iff.rfl + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/NormalizedRecovery.lean b/lean/OAI/Computability/DegreeRigidity/Computability/NormalizedRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..09b56fc150099c1e73c552d8d39c0d121a273122 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/NormalizedRecovery.lean @@ -0,0 +1,48 @@ +import OAI.Computability.DegreeRigidity.Effective.StageNormalization + +namespace OAI + +namespace TuringRigidity.NormalizedRecovery +open EncodedForcing Encodable UniformOracle Introreducible StageNormalization + +def trial (B : Oracle) (n c : ℕ) : Option ℕ := + if B (Nat.pair (Nat.unpair n).1 c) = true ∧ (Nat.unpair n).2 < codeLength c + then some (codeBit (Nat.unpair n).2 c) else none + +theorem trial_recursive (B : Oracle) : + Nat.RecursiveIn {oracleFunction B} (fun v => Part.some (encode (trial B (Nat.unpair v).1 (Nat.unpair v).2))) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hq : Nat.RecursiveIn {oracleFunction B} (oracleFunction B) := .oracle _ (Set.mem_singleton _) + have hb := total_comp hq (total_primrec (Primrec₂.natPair.comp (f.comp f) r)) + let n := r.comp (f.comp f) + let c := r.comp f + have hpost := Primrec.encode.comp (Primrec.ite + ((Primrec.eq.comp r (Primrec.const 1)).and (Primrec.nat_lt.comp n (codeLength_primrec.comp c))) + (Primrec.option_some.comp (codeBit_primrec.comp n c)) (Primrec.const none)) + exact (total_comp (total_primrec hpost) (total_pair (total_primrec Primrec.id) hb)).of_eq + (fun v => by cases h : B (Nat.pair (Nat.unpair (Nat.unpair v).1).1 (Nat.unpair v).2) <;> + simp [trial,h]) + +theorem normalized_inverse (A : Oracle) : Reduces A (normalized A) := by + apply RecursiveIn.iff_nat.mpr + change Nat.RecursiveIn {oracleFunction (normalized A)} (fun n => Part.some (bit A n)) + apply total_search (trial_recursive (normalized A)) (bit A) + · intro n c a ha + simp only [trial] at ha + split at ha + next h => + have he : prefixCode (columns A (Nat.unpair n).1) (codeLength c) = c := by + simpa [normalized,prefixSet] using h.1 + have ha' : a = codeBit (Nat.unpair n).2 c := (Option.mem_some_iff.mp ha).symm + rw [ha',← he,codeBit_prefix _ _ _ h.2] + simp [bit,columns,Nat.pair_unpair] + next h => simp at ha + · intro n + let c := prefixCode (columns A (Nat.unpair n).1) ((Nat.unpair n).2+1) + refine ⟨c,codeBit (Nat.unpair n).2 c,?_⟩ + simp [trial,normalized,c] + +end TuringRigidity.NormalizedRecovery + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/OracleCode.lean b/lean/OAI/Computability/DegreeRigidity/Computability/OracleCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..21413af5154b40d0358023082d76476a2224e164 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/OracleCode.lean @@ -0,0 +1,125 @@ +import OAI.Computability.DegreeRigidity.SetModels.Degrees +import Mathlib.Tactic.DeriveEncodable +import Mathlib.Data.Set.Countable + +namespace OAI + +namespace TuringRigidity + +inductive OracleCode where + | zero | succ | left | right | query + | pair : OracleCode → OracleCode → OracleCode + | comp : OracleCode → OracleCode → OracleCode + | prec : OracleCode → OracleCode → OracleCode + | find : OracleCode → OracleCode + deriving Encodable + +namespace OracleCode + +def eval (g : ℕ →. ℕ) : OracleCode → ℕ →. ℕ + | .zero => fun _ => 0 + | .succ => Nat.succ + | .left => fun n => (Nat.unpair n).1 + | .right => fun n => (Nat.unpair n).2 + | .query => g + | .pair c d => fun n => Nat.pair <$> eval g c n <*> eval g d n + | .comp c d => fun n => eval g d n >>= eval g c + | .prec c d => fun p => + let (a, n) := Nat.unpair p + n.rec (eval g c a) fun y ih => do + let i ← ih + eval g d (Nat.pair a (Nat.pair y i)) + | .find c => fun a => + Nat.rfind fun n => (fun m => m = 0) <$> eval g c (Nat.pair a n) + +theorem eval_recursiveIn (g : ℕ →. ℕ) (c : OracleCode) : + Nat.RecursiveIn {g} (eval g c) := by + induction c with + | zero => exact .zero + | succ => exact .succ + | left => exact .left + | right => exact .right + | query => exact .oracle g (Set.mem_singleton g) + | pair c d hc hd => exact .pair hc hd + | comp c d hc hd => exact .comp hc hd + | prec c d hc hd => exact .prec hc hd + | find c hc => exact .rfind hc + +theorem exists_code {g f : ℕ →. ℕ} (hf : Nat.RecursiveIn {g} f) : + ∃ c : OracleCode, eval g c = f := by + induction hf with + | zero => exact ⟨.zero, rfl⟩ + | succ => exact ⟨.succ, rfl⟩ + | left => exact ⟨.left, rfl⟩ + | right => exact ⟨.right, rfl⟩ + | oracle f hf => + have hfg : f = g := Set.mem_singleton_iff.mp hf + subst f + exact ⟨.query, rfl⟩ + | pair _ _ hc hd => + obtain ⟨c, rfl⟩ := hc + obtain ⟨d, rfl⟩ := hd + exact ⟨.pair c d, rfl⟩ + | comp _ _ hc hd => + obtain ⟨c, rfl⟩ := hc + obtain ⟨d, rfl⟩ := hd + exact ⟨.comp c d, rfl⟩ + | prec _ _ hc hd => + obtain ⟨c, rfl⟩ := hc + obtain ⟨d, rfl⟩ := hd + exact ⟨.prec c d, rfl⟩ + | rfind _ hc => + obtain ⟨c, rfl⟩ := hc + exact ⟨.find c, rfl⟩ + +theorem turingReducible_iff_exists_code (f g : ℕ →. ℕ) : + TuringReducible f g ↔ ∃ c : OracleCode, eval g c = f := by + change RecursiveIn {g} f ↔ _ + rw [RecursiveIn.iff_nat] + exact ⟨exists_code, fun ⟨c, hc⟩ => hc ▸ eval_recursiveIn g c⟩ + +theorem countable_reducible (g : ℕ →. ℕ) : + {f : ℕ →. ℕ | TuringReducible f g}.Countable := by + have heq : {f : ℕ →. ℕ | TuringReducible f g} = Set.range (eval g) := by + ext f + exact turingReducible_iff_exists_code f g + rw [heq] + exact Set.countable_range _ + +end OracleCode + +theorem oracleFunction_injective : Function.Injective oracleFunction := by + intro A B hab + funext n + have h := congrFun hab n + cases ha : A n <;> cases hb : B n <;> simp [oracleFunction, ha, hb] at h ⊢ + +theorem countable_reduces (B : Oracle) : {A : Oracle | Reduces A B}.Countable := by + exact (OracleCode.countable_reducible (oracleFunction B)).preimage oracleFunction_injective + +theorem countable_degree_fiber (a : Degree) : {A : Oracle | degree A = a}.Countable := by + obtain ⟨B, rfl⟩ := degree_surjective a + apply (countable_reduces B).mono + intro A hA + exact ((degree_eq_iff A B).mp hA).1 + +theorem countable_lift_fiber {X : Type*} (C : X → Oracle) (hC : Function.Injective C) + (π : Degree → Degree) (hπ : Function.Injective π) + (F : X → Oracle) (hF : ∀ x, degree (F x) = π (degree (C x))) (B : Oracle) : + {x : X | F x = B}.Countable := by + by_cases hne : ∃ x, F x = B + · obtain ⟨x₀, hx₀⟩ := hne + apply ((countable_degree_fiber (degree (C x₀))).preimage hC).mono + intro x hx + apply hπ + rw [← hF x, ← hF x₀, hx, hx₀] + · have hempty : {x : X | F x = B} = ∅ := by + ext x + simp only [Set.mem_ofPred_eq, Set.mem_empty_iff_false, iff_false] + exact fun h => hne ⟨x,h⟩ + rw [hempty] + exact Set.countable_empty + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/OracleEnumeration.lean b/lean/OAI/Computability/DegreeRigidity/Computability/OracleEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..9484f7658a5fb618232005bcb96e2338221bfe50 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/OracleEnumeration.lean @@ -0,0 +1,96 @@ +import OAI.Computability.DegreeRigidity.Effective.PrefixComputability +import Mathlib.Data.Set.Finite.Range +import Lean.Elab.Tactic.Omega + +namespace OAI + +namespace TuringRigidity.OracleEnumeration +open PrefixComputability + +theorem exists_ge {A : Oracle} (hA : {n | A n = true}.Infinite) (n : ℕ) : + ∃ m, n ≤ m ∧ A m = true := by + by_contra h + apply hA + apply (Set.finite_le_nat n).subset + intro m hm + exact Nat.le_of_lt (Nat.lt_of_not_ge (fun hnm => h ⟨m, hnm, hm⟩)) + +noncomputable def next (A : Oracle) (hA : {n | A n = true}.Infinite) (n : ℕ) : ℕ := + Nat.find (exists_ge hA n) + +theorem next_spec (A : Oracle) (hA : {n | A n = true}.Infinite) (n : ℕ) : + n ≤ next A hA n ∧ A (next A hA n) = true := Nat.find_spec (exists_ge hA n) + +theorem next_min (A : Oracle) (hA : {n | A n = true}.Infinite) (n m : ℕ) + (hm : n ≤ m) (hAm : A m = true) : next A hA n ≤ m := + Nat.find_min' (exists_ge hA n) ⟨hm, hAm⟩ + +private def searchFlag (p : ℕ) : ℕ := + if (Nat.unpair p).1 ≤ (Nat.unpair (Nat.unpair p).2).1 ∧ + (Nat.unpair (Nat.unpair p).2).2 = 1 then 0 else 1 + +private theorem searchFlag_primrec : Primrec searchFlag := by + exact Primrec.ite ((Primrec.nat_le.comp (Primrec.fst.comp Primrec.unpair) + (Primrec.fst.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)))).and + (Primrec.eq.comp (Primrec.snd.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair))) + (Primrec.const 1))) (Primrec.const 0) (Primrec.const 1) + +theorem next_recursive (A : Oracle) (hA : {n | A n = true}.Infinite) : + Nat.RecursiveIn {oracleFunction A} (fun n => Part.some (next A hA n)) := by + have hq : Nat.RecursiveIn {oracleFunction A} (oracleFunction A) := + .oracle _ (Set.mem_singleton _) + have hn := total_primrec (O := {oracleFunction A}) (Primrec.fst.comp Primrec.unpair) + have hm := total_primrec (O := {oracleFunction A}) (Primrec.snd.comp Primrec.unpair) + have hf := total_comp (total_primrec searchFlag_primrec) + (total_pair hn (total_pair hm (total_comp hq hm))) + apply (Nat.RecursiveIn.rfind hf).of_eq_tot + intro n + apply Nat.mem_rfind.mpr + constructor + · have hs := next_spec A hA n + simp [searchFlag, hs.1, hs.2] + · intro m hm' + have hh : ¬(n ≤ m ∧ A m = true) := Nat.find_min (exists_ge hA n) hm' + cases ha : A m <;> simp_all [searchFlag] + +noncomputable def enumerate (A : Oracle) (hA : {n | A n = true}.Infinite) : ℕ → ℕ + | 0 => next A hA 0 + | n+1 => next A hA (enumerate A hA n + 1) + +theorem enumerate_mem (A : Oracle) (hA : {n | A n = true}.Infinite) (n : ℕ) : + A (enumerate A hA n) = true := by + cases n <;> exact (next_spec A hA _).2 + +theorem enumerate_strictMono (A : Oracle) (hA : {n | A n = true}.Infinite) : + StrictMono (enumerate A hA) := by + apply strictMono_nat_of_lt_succ + intro n + exact (Nat.lt_succ_self _).trans_le (next_spec A hA _).1 + +theorem le_enumerate (A : Oracle) (hA : {n | A n = true}.Infinite) (n : ℕ) : + n ≤ enumerate A hA n := (enumerate_strictMono A hA).id_le n + +theorem enumerate_recursive (A : Oracle) (hA : {n | A n = true}.Infinite) : + Nat.RecursiveIn {oracleFunction A} (fun n => Part.some (enumerate A hA n)) := by + have hnext := next_recursive A hA + have hbase := total_comp hnext (total_primrec (Primrec.const 0)) + have hstep := total_comp hnext (total_primrec + (Primrec.succ.comp (Primrec.snd.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))))) + have hrec := Nat.RecursiveIn.prec hbase hstep + have hr := Nat.RecursiveIn.comp hrec + (total_pair (total_primrec (Primrec.const 0)) (total_primrec Primrec.id)) + apply hr.of_eq + intro n + change (Part.some (Nat.pair 0 n)).bind _ = _ + rw [Part.bind_some] + simp only [Nat.unpair_pair] + induction n with + | zero => rfl + | succ n ih => + simp only [ih] + simp [enumerate] + +end TuringRigidity.OracleEnumeration + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/OracleJump.lean b/lean/OAI/Computability/DegreeRigidity/Computability/OracleJump.lean new file mode 100644 index 0000000000000000000000000000000000000000..6aa4aed13b55c03a23b615f0f87b451387cfefeb --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/OracleJump.lean @@ -0,0 +1,90 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticHierarchy +import OAI.Computability.DegreeRigidity.OrdinalCodes.IndexMatrix + +namespace OAI + +namespace TuringRigidity.OracleJump +open Encodable UniformOracle CommonIdeal TableIndices IndexMatrix ArithmeticHierarchy + +def Halts (Y : Oracle) (e n : ℕ) : Prop := ∃ z a, a ∈ TableIndices.run Y (machine e) n z + +noncomputable def jump (Y : Oracle) : Oracle := by + classical + exact fun v => decide (Halts Y (Nat.unpair v).1 (Nat.unpair v).2) + +theorem partial_table {Y : Oracle} {f : ℕ →. ℕ} + (hf : Nat.RecursiveIn {oracleFunction Y} f) : + ∃ e, ∀ n, Halts Y e n ↔ (f n).Dom := by + obtain ⟨c, hc⟩ := OracleCode.exists_code hf + have hh : Partrec₂ (fun L : List ℕ => fun n => OracleCode.eval (BranchMachine.lookup L) c n) := + OracleCode.eval_partrec BranchMachine.lookup_partrec c + obtain ⟨d, hd⟩ := partrec_code hh + have hd' : ∀ L n, d.eval (Nat.pair (encode L) n) = OracleCode.eval (BranchMachine.lookup L) c n := + fun L n => hd (L,n) + have ha (n : ℕ) : Approximates (f n) + (fun m => d.eval (Nat.pair (encode (oraclePrefix (fun k => bit (Y k)) m)) n)) := by + simp only [hd', ← hc] + exact OracleCode.eval_approximates (prefix_approximates (fun k => bit (Y k))) c n + refine ⟨encode d, fun n => ?_⟩ + constructor + · rintro ⟨z,a,ha'⟩ + simp only [machine_encode] at ha' + exact ((ha n).1 (Nat.unpair z).1 a (Nat.Partrec.Code.evaln_sound ha')).1 + · intro hf' + obtain ⟨m,hm⟩ := (ha n).2 ((f n).get hf') ⟨hf',rfl⟩ + obtain ⟨t,ht⟩ := Nat.Partrec.Code.evaln_complete.mp (hm m le_rfl) + exact ⟨Nat.pair m t, (f n).get hf', by simpa [TableIndices.run, trial] using ht⟩ + +theorem domain_recursive_jump {Y : Oracle} {f : ℕ →. ℕ} + (hf : Nat.RecursiveIn {oracleFunction Y} f) : + RecursivePred (jump Y) (fun n => (f n).Dom) := by + classical + obtain ⟨e,he⟩ := partial_table hf + have hq : Nat.RecursiveIn {oracleFunction (jump Y)} (oracleFunction (jump Y)) := + .oracle _ (Set.mem_singleton _) + have h := Nat.RecursiveIn.comp hq (total_primrec (Primrec₂.natPair.comp (Primrec.const e) Primrec.id)) + exact h.of_eq (fun n => by + change (Part.some (Nat.pair e n)).bind + (fun input => Part.some (if jump Y input then 1 else 0)) = _ + rw [Part.bind_some] + simp [jump, he]) + +theorem exists_recursive_jump {Y : Oracle} {P : ℕ → Prop} (hP : RecursivePred Y P) : + RecursivePred (jump Y) (fun x => ∃ a, P (Nat.pair x a)) := by + classical + have hN := recursive_not hP + have hs := Nat.RecursiveIn.rfind hN + have hd := domain_recursive_jump hs + apply Form.congr (n := 0) (s := true) hd + intro x + erw [Nat.rfind_dom] + simp + +theorem forall_recursive_jump {Y : Oracle} {P : ℕ → Prop} (hP : RecursivePred Y P) : + RecursivePred (jump Y) (fun x => ∀ a, P (Nat.pair x a)) := by + have h := recursive_not (exists_recursive_jump (recursive_not hP)) + simpa only [not_exists, not_not] using h + +noncomputable def iterate (Y : Oracle) : ℕ → Oracle + | 0 => Y + | n+1 => jump (iterate Y n) + +theorem form_recursive {Y n s P} (h : Form Y n s P) : RecursivePred (iterate Y n) P := by + induction n generalizing s P with + | zero => exact h + | succ n ih => + obtain ⟨Q,hQ,he⟩ := h + have hr := ih hQ + cases s with + | false => + have hh := forall_recursive_jump hr + have he' : (fun x => ∀ a, Q (Nat.pair x a)) = P := funext (fun x => propext (he x).symm) + exact he' ▸ hh + | true => + have hh := exists_recursive_jump hr + have he' : (fun x => ∃ a, Q (Nat.pair x a)) = P := funext (fun x => propext (he x).symm) + exact he' ▸ hh + +end TuringRigidity.OracleJump + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/RationalCoding.lean b/lean/OAI/Computability/DegreeRigidity/Computability/RationalCoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..48bc39651d0ce3b610651e6250a4f67af8c51902 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/RationalCoding.lean @@ -0,0 +1,157 @@ +import OAI.Computability.DegreeRigidity.Computability.Cuts +import Mathlib.Computability.Primrec.List + +namespace OAI + +namespace TuringRigidity +open Encodable + +namespace RationalCoding + +def magnitude (n : ℕ) : ℕ := n/2+n%2 + +theorem magnitude_primrec : Primrec magnitude := + Primrec.nat_add.comp (Primrec.nat_div.comp Primrec.id (Primrec.const 2)) + (Primrec.nat_mod.comp Primrec.id (Primrec.const 2)) + +theorem encode_int_nonneg (n : ℕ) : encode (Int.ofNat n) = 2*n := by + change Nat.bit false n = 2*n + simp [Nat.bit] + +theorem encode_int_neg (n : ℕ) : encode (Int.negSucc n) = 2*n+1 := by + change Nat.bit true n = 2*n+1 + simp [Nat.bit] + +theorem magnitude_encode_int (z : ℤ) : magnitude (encode z) = z.natAbs := by + cases z with + | ofNat n => + change magnitude (encode (Int.ofNat n)) = n + rw [encode_int_nonneg] + simp [magnitude] + | negSucc n => simp [encode_int_neg,magnitude]; omega + +theorem encode_rat (q : ℚ) : encode q = Nat.pair (encode q.num) q.den := rfl + +def valid (n : ℕ) : Prop := + 0 < (Nat.unpair n).2 ∧ (magnitude (Nat.unpair n).1).Coprime (Nat.unpair n).2 + +instance (n : ℕ) : Decidable (valid n) := inferInstanceAs (Decidable (_ ∧ _)) + +theorem valid_iff (n : ℕ) : valid n ↔ ∃ q : ℚ, encode q = n := by + constructor + · rintro ⟨hd,hcop⟩ + let z := Equiv.intEquivNat.symm (Nat.unpair n).1 + have hz : encode z = (Nat.unpair n).1 := Equiv.intEquivNat.apply_symm_apply _ + have hm : z.natAbs = magnitude (Nat.unpair n).1 := by rw [←hz,magnitude_encode_int] + let q : ℚ := ⟨z,(Nat.unpair n).2,Nat.ne_of_gt hd,hm.symm ▸ hcop⟩ + refine ⟨q,?_⟩ + rw [encode_rat] + change Nat.pair (encode z) (Nat.unpair n).2 = n + rw [hz,Nat.pair_unpair] + · rintro ⟨q,rfl⟩ + simp only [valid,encode_rat,Nat.unpair_pair,magnitude_encode_int] + exact ⟨q.den_pos,q.reduced⟩ + +theorem coprime_bounded (a b : ℕ) : + (0 < b ∧ a.Coprime b) ↔ + (0 < b ∧ ∀ k ∈ List.range (b+1), a%k ≠ 0 ∨ b%k ≠ 0 ∨ k=1) := by + constructor + · rintro ⟨hb,hc⟩ + refine ⟨hb,fun k _hk => ?_⟩ + by_cases ha : a%k = 0 + · by_cases hb' : b%k = 0 + · exact Or.inr (Or.inr (Nat.dvd_one.mp (by + rw [←hc] + exact Nat.dvd_gcd (Nat.dvd_of_mod_eq_zero ha) (Nat.dvd_of_mod_eq_zero hb')))) + · exact Or.inr (Or.inl hb') + · exact Or.inl ha + · rintro ⟨hb,h⟩ + refine ⟨hb,?_⟩ + have hg : a.gcd b ∈ List.range (b+1) := by + simp only [List.mem_range,Nat.lt_succ_iff] + exact Nat.gcd_le_right a hb + have hh := h (a.gcd b) hg + simpa [Nat.mod_eq_zero_of_dvd (Nat.gcd_dvd_left a b), + Nat.mod_eq_zero_of_dvd (Nat.gcd_dvd_right a b)] using hh + +theorem coprime_positive_primrec : PrimrecPred (fun p : ℕ × ℕ => 0 < p.2 ∧ p.1.Coprime p.2) := by + have hr : PrimrecRel (fun k (p : ℕ × ℕ) => p.1%k ≠ 0 ∨ p.2%k ≠ 0 ∨ k=1) := + ((Primrec.eq.comp (Primrec.nat_mod.comp (Primrec.fst.comp Primrec.snd) Primrec.fst) + (Primrec.const 0)).not).or + (((Primrec.eq.comp (Primrec.nat_mod.comp (Primrec.snd.comp Primrec.snd) Primrec.fst) + (Primrec.const 0)).not).or (Primrec.eq.comp Primrec.fst (Primrec.const 1))) + have hh := (Primrec.nat_lt.comp (Primrec.const 0) Primrec.snd).and + (hr.forall_mem_list.comp (Primrec.list_range.comp (Primrec.succ.comp Primrec.snd)) Primrec.id) + exact hh.of_eq (fun p => (coprime_bounded p.1 p.2).symm) + +theorem valid_primrec : PrimrecPred valid := + coprime_positive_primrec.comp ((magnitude_primrec.comp (Primrec.fst.comp Primrec.unpair)).pair + (Primrec.snd.comp Primrec.unpair)) + +def canonicalCode (n : ℕ) : ℕ := if valid n then n else encode (0 : ℚ) + +theorem canonicalCode_primrec : Primrec canonicalCode := + Primrec.ite valid_primrec Primrec.id (Primrec.const (encode (0 : ℚ))) + +theorem decode_invalid (n : ℕ) (hv : ¬valid n) : decode (α := ℚ) n = none := by + let z := Equiv.intEquivNat.symm (Nat.unpair n).1 + have hz : decode (α := ℤ) (Nat.unpair n).1 = some z := rfl + have henc : encode z = (Nat.unpair n).1 := Equiv.intEquivNat.apply_symm_apply _ + have hbad : ¬(0 < (Nat.unpair n).2 ∧ z.natAbs.Coprime (Nat.unpair n).2) := by + simpa only [valid, ←henc, magnitude_encode_int] using hv + have hsub : decode (α := { b : ℕ // 0 < b ∧ z.natAbs.Coprime b }) (Nat.unpair n).2 = none := by + change Encodable.decodeSubtype (P := fun b => 0 < b ∧ z.natAbs.Coprime b) _ = none + simp [Encodable.decodeSubtype,hbad] + have hsigma : decode (α := Σ z : ℤ, { b : ℕ // 0 < b ∧ z.natAbs.Coprime b }) n = none := by + change Encodable.decodeSigma (γ := fun z : ℤ => { b : ℕ // 0 < b ∧ z.natAbs.Coprime b }) n = none + simp only [Encodable.decodeSigma] + rw [hz] + simp only [Option.bind_some] + rw [hsub] + rfl + simp only [Encodable.decode_ofEquiv,hsigma,Option.map_none] + +theorem canonicalCode_eq (n : ℕ) : canonicalCode n = encode (rationalEnumeration n) := by + by_cases hv : valid n + · obtain ⟨q,rfl⟩ := (valid_iff n).mp hv + simp only [canonicalCode,ite_eq_left hv,rationalEnumeration,encodek,Option.getD_some] + · have hn := decode_invalid n hv + simp only [canonicalCode,ite_eq_right hv,rationalEnumeration,hn,Option.getD_none] + +def numeratorCode (n : ℕ) : ℕ := (Nat.unpair (canonicalCode n)).1 +def numeratorMagnitude (n : ℕ) : ℕ := magnitude (numeratorCode n) +def denominator (n : ℕ) : ℕ := (Nat.unpair (canonicalCode n)).2 +def negative (n : ℕ) : Bool := (numeratorCode n).bodd + +theorem numeratorCode_primrec : Primrec numeratorCode := + (Primrec.fst.comp Primrec.unpair).comp canonicalCode_primrec +theorem numeratorMagnitude_primrec : Primrec numeratorMagnitude := + magnitude_primrec.comp numeratorCode_primrec +theorem denominator_primrec : Primrec denominator := + (Primrec.snd.comp Primrec.unpair).comp canonicalCode_primrec +theorem negative_primrec : Primrec negative := Primrec.nat_bodd.comp numeratorCode_primrec + +theorem numeratorCode_eq (n : ℕ) : numeratorCode n = encode (rationalEnumeration n).num := by + rw [numeratorCode,canonicalCode_eq,encode_rat,Nat.unpair_pair] +theorem numeratorMagnitude_eq (n : ℕ) : numeratorMagnitude n = (rationalEnumeration n).num.natAbs := by + rw [numeratorMagnitude,numeratorCode_eq,magnitude_encode_int] +theorem denominator_eq (n : ℕ) : denominator n = (rationalEnumeration n).den := by + rw [denominator,canonicalCode_eq,encode_rat,Nat.unpair_pair] +theorem denominator_pos (n : ℕ) : 0 < denominator n := by + rw [denominator_eq] + exact (rationalEnumeration n).den_pos + +theorem query_value (n : ℕ) : (rationalEnumeration n : ℝ) = + if negative n then -(numeratorMagnitude n : ℝ)/(denominator n : ℝ) + else (numeratorMagnitude n : ℝ)/(denominator n : ℝ) := by + rw [negative,numeratorCode_eq,numeratorMagnitude_eq,denominator_eq,Rat.cast_def] + cases hz : (rationalEnumeration n).num with + | ofNat k => + rw [encode_int_nonneg] + simp [Nat.bodd_mul] + | negSucc k => simp [encode_int_neg,Nat.bodd_mul] + +end RationalCoding +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/RationalCut.lean b/lean/OAI/Computability/DegreeRigidity/Computability/RationalCut.lean new file mode 100644 index 0000000000000000000000000000000000000000..06d9fafe36413e46e948c974737f29cc3fe28256 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/RationalCut.lean @@ -0,0 +1,82 @@ +import OAI.Computability.DegreeRigidity.Computability.RationalCoding +import OAI.Computability.DegreeRigidity.Effective.UniformOracle + +namespace OAI + +namespace TuringRigidity +namespace RationalCoding + +def positiveNumerator (n : ℕ) : ℕ := if negative n then 0 else numeratorMagnitude n +def negativeNumerator (n : ℕ) : ℕ := if negative n then numeratorMagnitude n else 0 + +theorem positiveNumerator_primrec : Primrec positiveNumerator := + Primrec.ite (Primrec.eq.comp negative_primrec (Primrec.const true)) (Primrec.const 0) + numeratorMagnitude_primrec + +theorem negativeNumerator_primrec : Primrec negativeNumerator := + Primrec.ite (Primrec.eq.comp negative_primrec (Primrec.const true)) numeratorMagnitude_primrec + (Primrec.const 0) + +theorem signed_query_value (n : ℕ) : (rationalEnumeration n : ℝ) = + ((positiveNumerator n : ℝ)-(negativeNumerator n : ℝ))/(denominator n : ℝ) := by + rw [query_value] + cases hn : negative n <;> simp [positiveNumerator,negativeNumerator,hn] + +def ltCode (i j : ℕ) : Prop := + positiveNumerator i*denominator j + negativeNumerator j*denominator i < + positiveNumerator j*denominator i + negativeNumerator i*denominator j + +instance (i j : ℕ) : Decidable (ltCode i j) := inferInstanceAs (Decidable (_ < _)) + +theorem ltCode_primrec : PrimrecRel ltCode := + Primrec.nat_lt.comp + (Primrec.nat_add.comp + (Primrec.nat_mul.comp (positiveNumerator_primrec.comp Primrec.fst) + (denominator_primrec.comp Primrec.snd)) + (Primrec.nat_mul.comp (negativeNumerator_primrec.comp Primrec.snd) + (denominator_primrec.comp Primrec.fst))) + (Primrec.nat_add.comp + (Primrec.nat_mul.comp (positiveNumerator_primrec.comp Primrec.snd) + (denominator_primrec.comp Primrec.fst)) + (Primrec.nat_mul.comp (negativeNumerator_primrec.comp Primrec.fst) + (denominator_primrec.comp Primrec.snd))) + +theorem ltCode_iff (i j : ℕ) : + ltCode i j ↔ (rationalEnumeration i : ℝ) < (rationalEnumeration j : ℝ) := by + have hi : (0 : ℝ) < denominator i := by exact_mod_cast denominator_pos i + have hj : (0 : ℝ) < denominator j := by exact_mod_cast denominator_pos j + rw [signed_query_value,signed_query_value,div_lt_div_iff₀ hi hj] + constructor + · intro h + have hh : (positiveNumerator i : ℝ)*denominator j + negativeNumerator j*denominator i < + (positiveNumerator j : ℝ)*denominator i + negativeNumerator i*denominator j := by + exact_mod_cast h + nlinarith + · intro h + change positiveNumerator i*denominator j + negativeNumerator j*denominator i < + positiveNumerator j*denominator i + negativeNumerator i*denominator j + have hh : (positiveNumerator i : ℝ)*denominator j + negativeNumerator j*denominator i < + (positiveNumerator j : ℝ)*denominator i + negativeNumerator i*denominator j := by nlinarith + exact_mod_cast hh +end RationalCoding + +theorem rational_cut_computable (q : ℚ) : + Primrec (fun n => if cut (q : ℝ) n then (1 : ℕ) else 0) := by + have hp := Primrec.ite + (RationalCoding.ltCode_primrec.comp Primrec.id (Primrec.const (Encodable.encode q))) + (Primrec.const 1) (Primrec.const 0) + apply hp.of_eq + intro n + have hq : rationalEnumeration (Encodable.encode q) = q := by simp [rationalEnumeration] + have he : RationalCoding.ltCode n (Encodable.encode q) ↔ (rationalEnumeration n : ℝ) < q := by + rw [RationalCoding.ltCode_iff,hq] + by_cases h : (rationalEnumeration n : ℝ) < q + · simp [he,h,cut] + · simp [he,h,cut] + +theorem rational_cut_reduces (q : ℚ) (A : Oracle) : Reduces (cut (q : ℝ)) A := by + exact RecursiveIn.iff_nat.mpr (UniformOracle.total_primrec (rational_cut_computable q)) + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/RealProjectionSyntax.lean b/lean/OAI/Computability/DegreeRigidity/Computability/RealProjectionSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3131ce9edcc632e5fd449074b3f749a6ede80e3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/RealProjectionSyntax.lean @@ -0,0 +1,136 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructionInputData +import OAI.Computability.DegreeRigidity.SetModels.SetModelJoin + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SetModelArithmetic SetModelReals +universe u + +def bitIndex : List Bool → ℕ → ℕ + | [], n => n + | b::bs, n => 2 * bitIndex bs n + if b then 1 else 0 + +def partBits : ℕ → List Bool + | 0 => [false] + | i+1 => true :: partBits i + +def pathBits : List ℕ → List Bool + | [] => [] + | i::is => partBits i ++ pathBits is + +theorem bitIndex_append (a b : List Bool) (n : ℕ) : + bitIndex (a++b) n = bitIndex a (bitIndex b n) := by + induction a with + | nil => rfl + | cons c a ih => simp only [List.cons_append,bitIndex,ih] + +theorem realPart_bits (P : Oracle) (i n : ℕ) : + realPart P i n = P (bitIndex (partBits i) n) := by + induction i generalizing P with + | zero => simp [realPart,partBits,bitIndex] + | succ i ih => exact ih (fun k => P (2*k+1)) + +theorem pathReal_bits (P : Oracle) (path : List ℕ) (n : ℕ) : + pathReal P path n = P (bitIndex (pathBits path) n) := by + induction path generalizing P with + | nil => rfl + | cons i is ih => rw [pathReal,ih,realPart_bits,pathBits,bitIndex_append] + +def bitStep (b : Bool) (w a d x y : ℕ) : Formula := + if b then .existsMem w (.conj (tripleFormula (x+1) (x+1) 0 (a+1) (d+1)) + (.successor (y+1) 0)) else tripleFormula x x y a d + +theorem bitStep_spec (b : Bool) (w a d x y : ℕ) (e : ℕ → ZFSet.{u}) + (hw : e w = ZFSet.omega) (ha : e a = additionSet) (hd : e d = pairNumbers) + (n m : ℕ) (hx : e x = natSet n) (hy : e y = natSet m) : + (bitStep b w a d x y).Eval e ↔ m = 2*n + if b then 1 else 0 := by + cases b + · simp [bitStep,eval_tripleFormula,hx,hy,ha,hd,addition_code,two_mul] + · simp only [bitStep,ite_true,Formula.Eval,eval_tripleFormula,Formula.eval_successor, + cons_zero,cons_succ,hw,hx,hy,ha,hd] + rw [omega_exists] + simp only [natPair_mem,true_and,addition_code,natSet_successor_eq] + constructor + · rintro ⟨k,hk,hm⟩; omega + · intro hm; exact ⟨n+n,rfl,by omega⟩ + +def bitIndexFormula : List Bool → ℕ → ℕ → ℕ → ℕ → ℕ → Formula + | [], _, _, _, x, y => .equal y x + | b::bs, w, a, d, x, y => .existsMem w + (.conj (bitIndexFormula bs (w+1) (a+1) (d+1) (x+1) 0) + (bitStep b (w+1) (a+1) (d+1) 0 (y+1))) + +theorem bitIndexFormula_spec (bs : List Bool) (w a d x y : ℕ) (e : ℕ → ZFSet.{u}) + (hw : e w = ZFSet.omega) (ha : e a = additionSet) (hd : e d = pairNumbers) + (n m : ℕ) (hx : e x = natSet n) (hy : e y = natSet m) : + (bitIndexFormula bs w a d x y).Eval e ↔ m = bitIndex bs n := by + induction bs generalizing w a d x y e m with + | nil => simp [bitIndexFormula,Formula.Eval,hx,hy,bitIndex,natSet_injective.eq_iff] + | cons b bs ih => + simp only [bitIndexFormula,Formula.Eval,hw] + rw [omega_exists] + have hb (k : ℕ) := bitStep_spec b (w+1) (a+1) (d+1) 0 (y+1) + (cons (natSet k) e) hw ha hd k m rfl hy + have hi (k : ℕ) := ih (w+1) (a+1) (d+1) (x+1) 0 (cons (natSet k) e) + hw ha hd k hx rfl + simp only [hi,hb,exists_eq_left,bitIndex] + +def projectionMember (bs : List Bool) (w a d P x : ℕ) : Formula := + .conj (.member x w) (.existsMem w + (.conj (bitIndexFormula bs (w+1) (a+1) (d+1) (x+1) 0) (.member 0 (P+1)))) + +theorem projectionMember_spec (bs : List Bool) (w a d P x : ℕ) + (e : ℕ → ZFSet.{u}) (hw : e w = ZFSet.omega) (ha : e a = additionSet) + (hd : e d = pairNumbers) (Q : Oracle) (hP : e P = realCode Q) : + (projectionMember bs w a d P x).Eval e ↔ e x ∈ realCode (fun n => Q (bitIndex bs n)) := by + simp only [projectionMember,Formula.Eval,hw,cons_zero,cons_succ,hP] + constructor + · rintro ⟨hx,k,hk,hrel,hQ⟩ + obtain ⟨n,hn⟩ := (mem_omega (e x)).mp hx + obtain ⟨m,rfl⟩ := (mem_omega k).mp hk + have hm := (bitIndexFormula_spec bs (w+1) (a+1) (d+1) (x+1) 0 + (cons (natSet m) e) hw ha hd n m hn rfl).mp hrel + rw [hn,natSet_mem_realCode] + simpa [hm] using (natSet_mem_realCode Q m).mp hQ + · intro hx + obtain ⟨n,hn⟩ := (mem_omega (e x)).mp (realCode_subset _ hx) + have hnQ : Q (bitIndex bs n) = true := (natSet_mem_realCode _ n).mp (hn ▸ hx) + refine ⟨hn.symm ▸ (mem_omega _).mpr ⟨n,rfl⟩,natSet (bitIndex bs n), + (mem_omega _).mpr ⟨_,rfl⟩,?_,(natSet_mem_realCode Q _).mpr hnQ⟩ + exact (bitIndexFormula_spec bs (w+1) (a+1) (d+1) (x+1) 0 + (cons (natSet (bitIndex bs n)) e) hw ha hd n _ hn rfl).mpr rfl + +noncomputable def projectionFormula (bs : List Bool) (out w a d P : ℕ) : SentenceForm := + SentenceForm.all (SentenceForm.iff (.member 0 (out+1)) + (fromBounded (projectionMember bs (w+1) (a+1) (d+1) (P+1) 0))) + +theorem projectionFormula_spec (M : ZFSet.{u}) (hM : Transitive M) + (bs : List Bool) (out w a d P : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hw : e w = ZFSet.omega) (ha : e a = additionSet) (hd : e d = pairNumbers) + (Q : Oracle) (hP : e P = realCode Q) : + (projectionFormula bs out w a d P).Sat (M : Set ZFSet) e ↔ + e out = realCode (fun n => Q (bitIndex bs n)) := by + have hs (x : ZFSet.{u}) (hx : x ∈ M) : + (fromBounded (projectionMember bs (w+1) (a+1) (d+1) (P+1) 0)).Sat + (M : Set ZFSet) (cons x e) ↔ x ∈ realCode (fun n => Q (bitIndex bs n)) := by + rw [bounded_sat,Formula.absolute _ M hM _ + (by intro i; cases i; exact hx; exact he _)] + exact projectionMember_spec bs (w+1) (a+1) (d+1) (P+1) 0 (cons x e) hw ha hd Q hP + simp only [projectionFormula,SentenceForm.sat_all,SentenceForm.sat_iff, + SentenceForm.Sat,cons_zero,cons_succ] + constructor + · intro h + apply ZFSet.ext; intro x + constructor + · intro hx + have hxM := hM _ (he out) _ hx + exact (hs x hxM).mp ((h x hxM).mp hx) + · intro hx + have hxM := hM _ (hw ▸ he w) _ (realCode_subset _ hx) + exact (h x hxM).mpr ((hs x hxM).mpr hx) + · intro h x hx; rw [h]; exact (hs x hx).symm + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/RecoverySetup.lean b/lean/OAI/Computability/DegreeRigidity/Computability/RecoverySetup.lean new file mode 100644 index 0000000000000000000000000000000000000000..3549726113c9ff744e1a66998491f14eee4e6973 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/RecoverySetup.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DegreeRigidity.Representation.Endpoints + +namespace OAI + +open Set Filter Topology +namespace TuringRigidity + +structure RecoveryData (F : ℝ → Oracle) (t u v : ℝ) where + radius : ℝ + radius_pos : 0 < radius + radius_lt_one : radius < 1 + lo : ℝ + hi : ℝ + lo_gt : -radius < lo + lo_neg : lo < 0 + hi_pos : 0 < hi + hi_lt : hi < radius + delta : ℚ + delta_pos : 0 < delta + delta_lt : (delta : ℝ) < radius + delta_gap : 3*(delta : ℝ) < hi-lo + bit : ℕ + forward : ℕ + backward : ℕ + left : ∀ s ∈ rationalSpan t, s ∈ Icc lo (lo+(delta : ℝ)) → + F (u+s) bit ≠ F (u+hi) bit + right : ∀ s ∈ rationalSpan t, s ∈ Icc (hi-(delta : ℝ)) hi → + F (u+s) bit = F (u+hi) bit + forward_correct : ∀ s ∈ rationalSpan t, ∀ a ∈ rationalSpan t, + |s| < radius → |a| < radius → + OracleCode.eval (oracleFunction (join (F (u+s)) (F (v-u+a)))) + (codeEnumeration forward) = oracleFunction (F (v+s+a)) + backward_correct : ∀ s ∈ rationalSpan t, |s| < radius → + OracleCode.eval (oracleFunction (join (F (v+s)) (F (u-v)))) + (codeEnumeration backward) = oracleFunction (F (u+s)) + +theorem recovery_data_exists (F : ℝ → Oracle) (hF : Measurable F) + (hfiber : ∀ B, {x | F x = B}.Countable) + (hadd : ∀ x y, Reduces (F (x+y)) (join (F x) (F y))) (t : ℝ) : + ∃ G : Set (ℝ × ℝ), G ∈ residual (ℝ × ℝ) ∧ + ∀ p ∈ G, Nonempty (RecoveryData F t p.1 p.2) := by + obtain ⟨D,hD,hFD⟩ := measurable_continuousOn_residual F hF + obtain ⟨e,E,hE,he,hspec⟩ := addition_program_continuous_restriction F hF hadd + refine ⟨goodPairs t D E,goodPairs_residual t D E hD hE,?_⟩ + rintro ⟨u,v⟩ hgood + obtain ⟨p,q,ρ,hρ,hρ1,hp,hq⟩ := fixed_local_programs F t u v D E e he hgood hspec + obtain ⟨lo,hi,j,δ,hloρ,hlo,hhi,hhiρ,hδ,hδρ,hgap,hleft,hright⟩ := + exists_endpoint_bands F hfiber D hD hFD t u ρ hρ (fun s hs => (hgood s hs).1) + exact ⟨{ + radius := ρ, radius_pos := hρ, radius_lt_one := hρ1, + lo := lo, hi := hi, lo_gt := hloρ, lo_neg := hlo, hi_pos := hhi, hi_lt := hhiρ, + delta := δ, delta_pos := hδ, delta_lt := hδρ, delta_gap := hgap, + bit := j, forward := p, backward := q, + left := hleft, right := hright, forward_correct := hp, backward_correct := hq }⟩ + +namespace RecoveryData +variable {F : ℝ → Oracle} {t u v : ℝ} + +def test (d : RecoveryData F t u v) (s : ℝ) : Bool := + decide (F (u+s) d.bit = F (u+d.hi) d.bit) + +theorem bounded (d : RecoveryData F t u v) (ht0 : 0 < t) (ht1 : t < 1) (n : ℕ) : + state d.test (d.delta : ℝ) t n ∈ Icc d.lo d.hi := by + apply state_mem_Icc_on_span d.test d.delta t d.lo d.hi + (by exact_mod_cast d.delta_pos) ht0 ht1 d.lo_neg.le d.hi_pos.le + · intro s hs hb + simp [test, d.left s hs hb] + · intro s hs hb + simp [test, d.right s hs hb] + +theorem abs_state_lt (d : RecoveryData F t u v) (ht0 : 0 < t) (ht1 : t < 1) (n : ℕ) : + |state d.test (d.delta : ℝ) t n| < d.radius := by + obtain ⟨hl,hu⟩ := d.bounded ht0 ht1 n + exact abs_lt.mpr ⟨d.lo_gt.trans_le hl, hu.trans_lt d.hi_lt⟩ + +theorem frequency_bound (d : RecoveryData F t u v) (ht0 : 0 < t) (ht1 : t < 1) + (n : ℕ) (hn : 0 < n) : + |t - (∑ k ∈ Finset.range n, branch d.test (d.delta : ℝ) t k) / (n : ℝ)| < + 1 / ((n : ℝ) * (d.delta : ℝ)) := by + exact frequency_error d.test (d.delta : ℝ) t n + (by exact_mod_cast d.delta_pos) hn ((d.abs_state_lt ht0 ht1 n).trans d.radius_lt_one) + +theorem cut_search (d : RecoveryData F t u v) (ht : Irrational t) (ht0 : 0 < t) + (ht1 : t < 1) (q : ℚ) : + (q : ℝ) < t ↔ ∃ n : ℕ, 0 < n ∧ (q : ℝ) < + (∑ k ∈ Finset.range n, branch d.test (d.delta : ℝ) t k) / (n : ℝ) - + 1 / ((n : ℝ) * (d.delta : ℝ)) := by + exact irrational_cut_iff_search t (d.delta : ℝ) + (fun n => (∑ k ∈ Finset.range n, branch d.test (d.delta : ℝ) t k) / (n : ℝ)) + ht (by exact_mod_cast d.delta_pos) (fun n hn => d.frequency_bound ht0 ht1 n hn) q +end RecoveryData + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/ScalarCoding.lean b/lean/OAI/Computability/DegreeRigidity/Computability/ScalarCoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..980784748ab268589760acdc69f25b573a959d79 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/ScalarCoding.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.Computability.RationalCut + +namespace OAI + +namespace TuringRigidity +namespace RationalCoding + +def scalarLeft (r : ℕ) (z : ℕ × ℕ) : ℕ := + (positiveNumerator r*positiveNumerator z.2 + negativeNumerator r*negativeNumerator z.2)*denominator z.1 + + negativeNumerator z.1*denominator r*denominator z.2 + +def scalarRight (r : ℕ) (z : ℕ × ℕ) : ℕ := + (positiveNumerator r*negativeNumerator z.2 + negativeNumerator r*positiveNumerator z.2)*denominator z.1 + + positiveNumerator z.1*denominator r*denominator z.2 + +private theorem scalarPolynomial_primrec (a b D : ℕ) {p q c : ℕ → ℕ} + (hp : Primrec p) (hq : Primrec q) (hc : Primrec c) : + Primrec (fun z : ℕ × ℕ => (a*p z.2+b*q z.2)*denominator z.1+c z.1*D*denominator z.2) := + Primrec.nat_add.comp + (Primrec.nat_mul.comp + (Primrec.nat_add.comp (Primrec.nat_mul.comp (Primrec.const a) (hp.comp Primrec.snd)) + (Primrec.nat_mul.comp (Primrec.const b) (hq.comp Primrec.snd))) + (denominator_primrec.comp Primrec.fst)) + (Primrec.nat_mul.comp (Primrec.nat_mul.comp (hc.comp Primrec.fst) (Primrec.const D)) + (denominator_primrec.comp Primrec.snd)) + +theorem scalarLeft_primrec (r : ℕ) : Primrec (scalarLeft r) := + scalarPolynomial_primrec _ _ _ positiveNumerator_primrec negativeNumerator_primrec negativeNumerator_primrec + +theorem scalarRight_primrec (r : ℕ) : Primrec (scalarRight r) := + scalarPolynomial_primrec _ _ _ negativeNumerator_primrec positiveNumerator_primrec positiveNumerator_primrec + +theorem scalar_eq_iff (r i j : ℕ) : scalarLeft r (i,j)=scalarRight r (i,j) ↔ + (rationalEnumeration r : ℝ)*(rationalEnumeration j : ℝ)=(rationalEnumeration i : ℝ) := by + have hr : (denominator r : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (denominator_pos r)) + have hi : (denominator i : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (denominator_pos i)) + have hj : (denominator j : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (denominator_pos j)) + rw [signed_query_value,signed_query_value,signed_query_value] + have he : ((positiveNumerator r : ℝ)-negativeNumerator r)/denominator r * + (((positiveNumerator j : ℝ)-negativeNumerator j)/denominator j) = + ((positiveNumerator i : ℝ)-negativeNumerator i)/denominator i ↔ + (scalarLeft r (i,j) : ℝ)=(scalarRight r (i,j) : ℝ) := by + simp only [scalarLeft,scalarRight,Nat.cast_add,Nat.cast_mul] + field_simp + constructor <;> intro h <;> nlinarith + rw [he] + exact Nat.cast_inj.symm + +def divideIndex (r : ℚ) (i : ℕ) : ℕ := Encodable.encode (rationalEnumeration i/r) + +theorem divideIndex_value (r : ℚ) (i : ℕ) : + rationalEnumeration (divideIndex r i) = rationalEnumeration i/r := by + simp only [divideIndex,rationalEnumeration,Encodable.encodek,Option.getD_some] + +theorem divideIndex_recursive {O : Set (ℕ →. ℕ)} (r : ℚ) (hr : r ≠ 0) : + Nat.RecursiveIn O (fun i => Part.some (divideIndex r i)) := by + let ridx := Encodable.encode r + let E : ℕ → ℕ → Option ℕ := fun i j => + if valid j ∧ scalarLeft ridx (i,j)=scalarRight ridx (i,j) then some j else none + have hE : Primrec (fun z : ℕ => Encodable.encode (E (Nat.unpair z).1 (Nat.unpair z).2)) := + Primrec.encode.comp ((Primrec.ite ((valid_primrec.comp Primrec.snd).and + (Primrec.eq.comp (scalarLeft_primrec ridx) (scalarRight_primrec ridx))) + (Primrec.option_some.comp Primrec.snd) (Primrec.const none)).comp Primrec.unpair) + have hridx : rationalEnumeration ridx = r := by simp [ridx,rationalEnumeration] + apply UniformOracle.total_search (UniformOracle.total_primrec hE) (divideIndex r) + · intro i j a ha + dsimp only [E] at ha + split at ha + · rename_i h + have haj : a=j := by symm; simpa using ha + subst a + have he := (scalar_eq_iff ridx i j).mp h.2 + rw [hridx] at he + have heq : r*rationalEnumeration j=rationalEnumeration i := by exact_mod_cast he + have hval : rationalEnumeration j=rationalEnumeration i/r := + (eq_div_iff hr).mpr (by simpa [mul_comm] using heq) + have hj : canonicalCode j=j := ite_eq_left h.1 + rw [canonicalCode_eq,hval] at hj + exact hj.symm + · simp at ha + · intro i + let j := divideIndex r i + have hv : valid j := (valid_iff j).mpr ⟨rationalEnumeration i/r,rfl⟩ + have he : scalarLeft ridx (i,j)=scalarRight ridx (i,j) := by + apply (scalar_eq_iff ridx i j).mpr + rw [hridx,show rationalEnumeration j=rationalEnumeration i/r from divideIndex_value r i] + push_cast + field_simp + exact ⟨j,j,by simp [E,hv,he]⟩ + +end RationalCoding +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Computability/UniformArithmetic.lean b/lean/OAI/Computability/DegreeRigidity/Computability/UniformArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd2d6ad806c2a96ad4087b53d4d1578cd99627f0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Computability/UniformArithmetic.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticAtoms + +namespace OAI + +namespace TuringRigidity.UniformArithmetic +open Encodable + +abbrev Oracles := ℕ → Oracle +abbrev Predicate := Oracles → ℕ → Prop +abbrev left (v : ℕ) := (Nat.unpair v).1 +abbrev right (v : ℕ) := (Nat.unpair v).2 + +theorem left_primrec : Primrec left := Primrec.fst.comp Primrec.unpair +theorem right_primrec : Primrec right := Primrec.snd.comp Primrec.unpair + +inductive Arith : Predicate → Prop where + | pure (P : ℕ → Prop) : PrimrecPred P → Arith (fun _ v => P v) + | query (i : ℕ) : Arith (fun O v => O i v = true) + | neg {P} : Arith P → Arith (fun O v => ¬ P O v) + | and {P Q} : Arith P → Arith Q → Arith (fun O v => P O v ∧ Q O v) + | ex {P} : Arith P → Arith (fun O v => ∃ n, P O (Nat.pair v n)) + | comp {P} (f : ℕ → ℕ) : Arith P → Primrec f → Arith (fun O v => P O (f v)) + +theorem Arith.congr {P Q} (h : Arith P) (he : ∀ O v, P O v ↔ Q O v) : Arith Q := by + have : P = Q := funext (fun O => funext (fun v => propext (he O v))) + exact this ▸ h + +theorem Arith.or {P Q} (hP : Arith P) (hQ : Arith Q) : + Arith (fun O v => P O v ∨ Q O v) := + (hP.neg.and hQ.neg).neg.congr (fun _ _ => by + classical + tauto) + +theorem Arith.imp {P Q} (hP : Arith P) (hQ : Arith Q) : + Arith (fun O v => P O v → Q O v) := + (hP.neg.or hQ).congr (fun _ _ => by tauto) + +theorem Arith.iff {P Q} (hP : Arith P) (hQ : Arith Q) : + Arith (fun O v => P O v ↔ Q O v) := + ((hP.imp hQ).and (hQ.imp hP)).congr (fun _ _ => iff_def.symm) + +theorem Arith.all {P} (h : Arith P) : + Arith (fun O v => ∀ n, P O (Nat.pair v n)) := + h.neg.ex.neg.congr (fun _ _ => by simp) + +theorem equal {f g : ℕ → ℕ} (hf : Primrec f) (hg : Primrec g) : + Arith (fun _ v => f v = g v) := .pure _ (Primrec.eq.comp hf hg) + +theorem less {f g : ℕ → ℕ} (hf : Primrec f) (hg : Primrec g) : + Arith (fun _ v => f v < g v) := .pure _ (Primrec.nat_lt.comp hf hg) + +theorem Arith.substitute {P} (h : Arith P) + (F : Oracles → ℕ → Oracles) + (hF : ∀ i, Arith (fun O v => F O (left v) i (right v) = true)) : + Arith (fun O v => P (F O (left v)) (right v)) := by + induction h with + | pure P hP => exact .pure _ (hP.comp right_primrec) + | query i => exact hF i + | neg h ih => exact ih.neg + | and h k ih ik => exact ih.and ik + | ex h ih => + have hh := (ih.comp (fun v => Nat.pair (left (left v)) (Nat.pair (right (left v)) (right v))) + (Primrec₂.natPair.comp (left_primrec.comp left_primrec) + (Primrec₂.natPair.comp (right_primrec.comp left_primrec) right_primrec))).ex + exact hh.congr (fun _ _ => by simp only [left,right,Nat.unpair_pair]) + | comp f h hf ih => + exact (ih.comp (fun v => Nat.pair (left v) (f (right v))) + (Primrec₂.natPair.comp left_primrec (hf.comp right_primrec))).congr + (fun _ _ => by simp only [left,right,Nat.unpair_pair]) + +end TuringRigidity.UniformArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/CollectionHierarchyInternal.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/CollectionHierarchyInternal.lean new file mode 100644 index 0000000000000000000000000000000000000000..24f8cf44385db861f4710184380938e099fd346e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/CollectionHierarchyInternal.lean @@ -0,0 +1,56 @@ +import OAI.Computability.DegreeRigidity.Constructibility.CollectionHierarchyRecursion +import OAI.Computability.DegreeRigidity.Constructibility.InternalConstructibleHierarchy + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u +theorem seed_mem_collection (M R : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) (hR : R ∈ M) : + seed R ∈ M := by + obtain ⟨b,hb,hdef⟩ := collect_unionIterates M C.transitive C.pairing C.union + hRep (C.omega_mem) + (singleton_mem M C.transitive C.pairing hR) + have he : ZFSet.sUnion b = seed R := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sUnion,mem_seed] + constructor + · rintro ⟨a,ha,hz⟩ + obtain ⟨n,rfl⟩ := (hdef a).mp ha + exact ⟨n,hz⟩ + · rintro ⟨n,hz⟩ + exact ⟨_,(hdef _).mpr ⟨n,rfl⟩,hz⟩ + exact he ▸ union_mem M C.transitive C.union hb + +theorem internal_hierarchy_cover_collection (M R o : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) (hColl : SigmaCollection M) + (hR : R ∈ M) (ho : o ∈ M) : + ∃ d ∈ M, ∃ f ∈ M, o ∈ d ∧ + HierarchyGraph M (seed R) d (iterUnion 2 f) f := by + obtain ⟨c,hc,hct,hoc⟩ := internal_transitive_container M C.transitive C.pairing C.union + C.separation hRep C.infinity ho + obtain ⟨q,hq,hqdef⟩ := internal_power M C.transitive C.power hc + obtain ⟨f,hf,hfg⟩ := internal_hierarchyGraph_collection M R c q C hRep hColl (seed_mem_collection M R C hRep hR) + hc hq hct hqdef o hoc + exact ⟨hull c q o,hull_mem M c q C.transitive C.separation hc hq ho, + f,hf,self_mem_hull c q hoc,hfg⟩ + +theorem stage_mem_collection (M R o : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) (hColl : SigmaCollection M) + (hR : R ∈ M) (ho : o ∈ M) : stage R o ∈ M := by + obtain ⟨d,_,f,hf,hod,hfg⟩ := internal_hierarchy_cover_collection M R o C hRep hColl hR ho + obtain ⟨v,hv,hfv,_⟩ := hfg.2.1.2 o hod + have hvM : v ∈ M := C.transitive _ (iterUnion_mem M C.transitive C.union hf 2) v hv + rw [hfg.correct o hod v hv hfv] at hvM + exact C.transitive _ hvM _ (self_mem_definablePower (stage R o)) + +theorem level_mem_collection (M R : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) (hColl : SigmaCollection M) + (hR : R ∈ M) (o : Ordinal.{u}) (ho : o.toZFSet ∈ M) : level R o ∈ M := + stage_mem_collection M R o.toZFSet C hRep hColl hR ho + +theorem level_subset_model_collection (M R : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) (hColl : SigmaCollection M) + (hR : R ∈ M) (o : Ordinal.{u}) (ho : o.toZFSet ∈ M) : level R o ⊆ M := + fun x hx => C.transitive _ (level_mem_collection M R C hRep hColl hR o ho) x hx + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/CollectionHierarchyRecursion.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/CollectionHierarchyRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..2557ae339a904893b644cf9132ee0fc9f4c3a331 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/CollectionHierarchyRecursion.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.Constructibility.CollectionHierarchySyntax + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u +theorem internal_hierarchyGraph_collection (M R d q : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) (hColl : SigmaCollection M) + (hs : seed R ∈ M) (hdM : d ∈ M) (hqM : q ∈ M) (hd : Transitive d) + (hq : ∀ c, c ∈ q ↔ c ∈ M ∧ c ⊆ d) (x : ZFSet.{u}) (hx : x ∈ d) : + ∃ f ∈ M, HierarchyGraph M (seed R) (hull d q x) (iterUnion 2 f) f := by + let hP := C.pairing + let hU := C.union + let hS := C.separation + let hR := hRep + obtain ⟨p,e,he,hp⟩ := uniform_hierarchy_certificate_collection M R d q C hRep hColl hs hdM hqM hd hq + induction x using ZFSet.inductionOn with + | h x ih => + have hxM := C.transitive d hdM x hx + have cert (y f : ZFSet.{u}) (hy : y ∈ x) (hf : f ∈ M) : + p.Realize M (cons f (cons y e)) ↔ + ∃ r ∈ M, HierarchyGraph M (seed R) (hull d q y) r f := + hp y (hd x hx y hy) f hf + obtain ⟨b,hb,hbdef⟩ := hR p e he x hxM (by + intro y hy + obtain ⟨f,hf,hfg⟩ := ih y hy (hd x hx y hy) + refine ⟨f,hf,(cert y f hy hf).mpr + ⟨_,iterUnion_mem M C.transitive hU hf 2,hfg⟩,?_⟩ + intro g hg hcg + obtain ⟨r,_,hgg⟩ := (cert y g hy hg).mp hcg + exact hgg.unique hfg) + have hbg (f : ZFSet.{u}) : f ∈ b ↔ + ∃ y ∈ x, ∃ r ∈ M, HierarchyGraph M (seed R) (hull d q y) r f := by + constructor + · intro hf + have hfM := C.transitive b hb f hf + obtain ⟨y,hy,hc⟩ := (hbdef f hfM).mp hf + exact ⟨y,hy,(cert y f hy hfM).mp hc⟩ + · rintro ⟨y,hy,r,hr,hg⟩ + obtain ⟨f',hf',hg'⟩ := ih y hy (hd x hx y hy) + have heq := hg.unique hg' + have hfM : f ∈ M := heq ▸ hf' + exact (hbdef f hfM).mpr ⟨y,hy,(cert y f hy hfM).mpr ⟨r,hr,hg⟩⟩ + let g := ZFSet.sUnion b + have hgM : g ∈ M := union_mem M C.transitive hU hb + have hg (z : ZFSet.{u}) : z ∈ g ↔ + ∃ y ∈ x, ∃ w ∈ hull d q y, z = ZFSet.pair w (definablePower (stage R w)) := by + constructor + · intro hz + obtain ⟨f,hf,hzf⟩ := ZFSet.mem_sUnion.mp hz + obtain ⟨y,hy,r,_,hfg⟩ := (hbg f).mp hf + exact ⟨y,hy,(hfg.mem_iff z).mp hzf⟩ + · rintro ⟨y,hy,w,hw,hz⟩ + obtain ⟨f,hf,hfg⟩ := ih y hy (hd x hx y hy) + exact ZFSet.mem_sUnion.mpr ⟨f,(hbg f).mpr + ⟨y,hy,_,iterUnion_mem M C.transitive hU hf 2,hfg⟩,(hfg.mem_iff z).mpr ⟨w,hw,hz⟩⟩ + have hvalue : stageImage (seed R) x g = stage R x := by + apply ZFSet.ext; intro z + rw [mem_stageImage,mem_stage] + apply or_congr_right + constructor + · rintro ⟨y,hy,w,hw,hz⟩ + obtain ⟨a,_,v,_,hp⟩ := (hg _).mp hw + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact ⟨y,hy,hz⟩ + · rintro ⟨y,hy,hz⟩ + exact ⟨y,hy,_,(hg _).mpr + ⟨y,hy,y,self_mem_hull d q (hd x hx y hy),rfl⟩,hz⟩ + have hvM : definablePower (stage R x) ∈ M := definablePower_mem_of_context M _ C + (hvalue ▸ stageImage_mem_context M C hs hxM hgM) + let f := g ∪ ({ZFSet.pair x (definablePower (stage R x))} : ZFSet.{u}) + have hfM : f ∈ M := binary_union_mem M C.transitive hP hU hgM + (singleton_mem M C.transitive hP (orderedPair_mem M C.transitive hP hxM hvM)) + refine ⟨f,hfM,hierarchyGraph_of_mem_iff_context M R _ f C hs + (hull_mem M d q C.transitive hS hdM hqM hxM) hfM (hull_transitive d q x hd) ?_⟩ + intro z + change z ∈ g ∪ ({ZFSet.pair x (definablePower (stage R x))} : ZFSet.{u}) ↔ _ + rw [ZFSet.mem_union,ZFSet.mem_singleton,hg] + constructor + · rintro (⟨y,hy,w,hw,hz⟩|hz) + · exact ⟨w,(hull_unfold M d q C.transitive hP hU hS hR hdM hqM hd hq hx w).mpr + (Or.inr ⟨y,hy,hw⟩),hz⟩ + · exact ⟨x,self_mem_hull d q hx,hz⟩ + · rintro ⟨w,hw,hz⟩ + rcases (hull_unfold M d q C.transitive hP hU hS hR hdM hqM hd hq hx w).mp hw with rfl|⟨y,hy,hw⟩ + · exact Or.inr hz + · exact Or.inl ⟨y,hy,w,hw,hz⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/CollectionHierarchySyntax.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/CollectionHierarchySyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b22c7e0f20d51b758ef8b516ebdca60f1bed89c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/CollectionHierarchySyntax.lean @@ -0,0 +1,57 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ContextHierarchyGraph +import OAI.Computability.DegreeRigidity.Syntax.SigmaCollectionClosure +import OAI.Computability.DegreeRigidity.Constructibility.HierarchySyntax + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u +theorem hierarchyGraph_sigmaDefinable_collection {M : ZFSet.{u}} (C : Context M) (hRep : SigmaReplacement M) (hColl : SigmaCollection M) (s d r f : ℕ) : + SigmaDefinable M (fun e => HierarchyGraph M (e s) (e d) (e r) (e f)) := by + have hd := (defAllMem (defSubset C 0 (d+1)) d).toSigma C.transitive + have hf := (functionGraph_definable C d r f).toSigma C.transitive + have hv : SigmaDefinable M (fun e => e 1 = definablePower (e 0)) := + (definablePower_sigmaDefinable_context M C).subst (fun i => if i = 0 then 1 else 0) + have hs := ((stageStep_definable C (s+3) (f+3) (r+3) 2 0).toSigma C.transitive).and hv + have hi := SigmaDefinable.impBounded C (defPairMem C 1 0 (f+2)) hs.existsSet + exact hd.and (hf.and ((hi.allMem_collection C hRep hColl (r+1)).allMem_collection C hRep hColl d)) + +theorem uniform_hierarchy_certificate_collection (M R d q : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) (hColl : SigmaCollection M) (hs : seed R ∈ M) (hdM : d ∈ M) (hqM : q ∈ M) + (hd : Transitive d) (hq : ∀ c, c ∈ q ↔ c ∈ M ∧ c ⊆ d) : + ∃ p : SigmaFormula, ∃ a : ℕ → ZFSet.{u}, (∀ i, a i ∈ M) ∧ + ∀ x ∈ d, ∀ f ∈ M, p.Realize M (cons f (cons x a)) ↔ + ∃ r ∈ M, HierarchyGraph M (seed R) (hull d q x) r f := by + have hh : Definable M (fun e => e 1 ∈ q ∧ Transitive (e 1) ∧ e 3 ∈ e 1 ∧ + ∀ b ∈ q, Transitive b → e 3 ∈ b → e 1 ⊆ b) := by + refine ⟨.isHull 2 6 1 3,cons d (fun _ => q),?_,?_⟩ + · intro i; cases i; exact hdM; exact hqM + · intro e + simp [Formula.eval_isHull,mix,cons] + have hg : SigmaDefinable M (fun e => HierarchyGraph M (seed R) (e 1) (e 0) (e 2)) := by + have h := hierarchyGraph_sigmaDefinable_collection C hRep hColl 0 2 1 3 + have eq := (equal_param hs 0).toSigma C.transitive + + have hx := (eq.and h).existsSet + exact hx.congr (fun e _ => by simp [hs]) + have hc := (hh.toSigma C.transitive).and hg + obtain ⟨p,a,ha,hp⟩ := sigma_binary_relation (fun x f => + ∃ c ∈ M, ∃ r ∈ M, (c ∈ q ∧ Transitive c ∧ x ∈ c ∧ + ∀ b ∈ q, Transitive b → x ∈ b → c ⊆ b) ∧ HierarchyGraph M (seed R) c r f) + hc.existsSet.existsSet + refine ⟨p,a,ha,?_⟩ + intro x hx f hf + rw [hp x (C.transitive d hdM x hx) f hf] + constructor + · rintro ⟨c,hc,r,hr,hh,hg⟩ + have he := (isHull_iff M d q C.transitive C.separation hdM hqM hd hq hx hc).mp hh + subst c + exact ⟨r,hr,hg⟩ + · rintro ⟨r,hr,hg⟩ + have hc := hull_mem M d q C.transitive C.separation hdM hqM (C.transitive d hdM x hx) + exact ⟨_,hc,r,hr,(isHull_iff M d q C.transitive C.separation hdM hqM hd hq hx hc).mpr rfl,hg⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleBase.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleBase.lean new file mode 100644 index 0000000000000000000000000000000000000000..e228936fdd0bbf226471c5b799454a3f3e6701b5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleBase.lean @@ -0,0 +1,50 @@ +import OAI.Computability.DegreeRigidity.Syntax.DefinablePower +import OAI.Computability.DegreeRigidity.SetModels.NameUnionCode + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel +universe u + +noncomputable def seed (R : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sUnion (ZFSet.range (fun n : ℕ => iterUnion n ({R} : ZFSet))) + +theorem mem_seed (R x : ZFSet.{u}) : + x ∈ seed R ↔ ∃ n : ℕ, x ∈ iterUnion n ({R} : ZFSet) := by + rw [seed,ZFSet.mem_sUnion] + constructor + · rintro ⟨a,ha,hx⟩ + obtain ⟨n,rfl⟩ := ZFSet.mem_range.mp ha + exact ⟨n,hx⟩ + · rintro ⟨n,hx⟩ + exact ⟨_,ZFSet.mem_range_self (f := fun index : ℕ => iterUnion index ({R} : ZFSet.{u})) n,hx⟩ + +theorem parameter_mem_seed (R : ZFSet.{u}) : R ∈ seed R := + (mem_seed R R).mpr ⟨0,ZFSet.mem_singleton.mpr rfl⟩ + +theorem seed_transitive (R : ZFSet.{u}) : Transitive (seed R) := by + intro x hx y hy + obtain ⟨n,hn⟩ := (mem_seed R x).mp hx + exact (mem_seed R y).mpr ⟨n+1,ZFSet.mem_sUnion.mpr ⟨x,hn,hy⟩⟩ + +theorem parameter_subset_seed (R : ZFSet.{u}) : R ⊆ seed R := + fun x hx => seed_transitive R R (parameter_mem_seed R) x hx + +theorem seed_minimal (R M : ZFSet.{u}) (hM : Transitive M) (hR : R ∈ M) : seed R ⊆ M := by + intro x hx + obtain ⟨n,hn⟩ := (mem_seed R x).mp hx + have sub : ∀ n : ℕ, iterUnion n ({R} : ZFSet) ⊆ M := by + intro n + induction n with + | zero => intro y hy; obtain rfl := ZFSet.mem_singleton.mp hy; exact hR + | succ n ih => + intro y hy + obtain ⟨z,hz,hy⟩ := ZFSet.mem_sUnion.mp hy + exact hM z (ih hz) y hy + exact sub n hn + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleClosure.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..7be6e47ff6f39cea7c58ace5a679cb7adbc66854 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleClosure.lean @@ -0,0 +1,81 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleStages + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel SentenceForm BoundedSetTheory TransitiveNameModel +universe u + +theorem empty_mem_definablePower (A : ZFSet.{u}) : (∅ : ZFSet.{u}) ∈ definablePower A := by + apply (mem_definablePower A ∅).mpr + refine ⟨0,.neg (.equal 0 0),Fin.elim0,by decide,fun i => Fin.elim0 i,?_⟩ + apply ZFSet.ext; intro x + simp [mem_definedSubset,Sat] + +theorem pair_mem_definablePower (A a b : ZFSet.{u}) (ha : a ∈ A) (hb : b ∈ A) : + ({a,b} : ZFSet.{u}) ∈ definablePower A := by + apply (mem_definablePower A _).mpr + let v : Fin 2 → ZFSet.{u} := Fin.cases a (fun _ => b) + refine ⟨2,disj (.equal 0 1) (.equal 0 2),v,by decide,?_,?_⟩ + · intro i; exact Fin.cases ha (fun _ => hb) i + · apply ZFSet.ext; intro x + simp only [ZFSet.mem_pair,mem_definedSubset,sat_disj,Sat,cons_zero,cons_succ] + have h0 : tupleEnv v 0 = a := by simp [tupleEnv,v] + have h1 : tupleEnv v 1 = b := by simp [tupleEnv,v]; rfl + rw [h0,h1] + exact ⟨fun h => ⟨h.elim (fun h => h ▸ ha) (fun h => h ▸ hb),h⟩,And.right⟩ + +theorem union_mem_definablePower (A a : ZFSet.{u}) (hA : Transitive A) (ha : a ∈ A) : + ZFSet.sUnion a ∈ definablePower A := by + apply (mem_definablePower A _).mpr + refine ⟨1,.ex (.conj (.member 0 2) (.member 1 0)),fun _ => a, + by decide,fun _ => ha,?_⟩ + apply ZFSet.ext; intro x + simp only [ZFSet.mem_sUnion,mem_definedSubset,Sat,cons_zero,cons_succ] + have h0 : tupleEnv (fun _ : Fin 1 => a) 0 = a := by simp [tupleEnv] + rw [h0] + constructor + · rintro ⟨y,hy,hx⟩ + have hyA := hA a ha y hy + exact ⟨hA y hyA x hx,y,hyA,hy,hx⟩ + · rintro ⟨_,y,_,hy,hx⟩ + exact ⟨y,hy,hx⟩ + +theorem empty_in_relativeL (R : ZFSet.{u}) : InRelativeL R ∅ := by + refine ⟨1,?_⟩ + rw [show (1 : Ordinal) = 0+1 by simp,level_succ] + exact empty_mem_definablePower _ + +theorem pair_in_relativeL (R : ZFSet.{u}) {a b : ZFSet.{u}} + (ha : InRelativeL R a) (hb : InRelativeL R b) : InRelativeL R ({a,b} : ZFSet) := by + obtain ⟨i,hi⟩ := ha + obtain ⟨j,hj⟩ := hb + refine ⟨max i j + 1,?_⟩ + rw [level_succ] + exact pair_mem_definablePower _ a b (level_mono R (le_max_left i j) hi) + (level_mono R (le_max_right i j) hj) + +theorem union_in_relativeL (R : ZFSet.{u}) {a : ZFSet.{u}} + (ha : InRelativeL R a) : InRelativeL R (ZFSet.sUnion a) := by + obtain ⟨i,hi⟩ := ha + refine ⟨i+1,?_⟩ + rw [level_succ] + exact union_mem_definablePower _ a (level_transitive R i) hi + +theorem finite_parameters_in_level (R : ZFSet.{u}) (e : ℕ → ZFSet.{u}) (n : ℕ) + (he : ∀ i, i < n → InRelativeL R (e i)) : + ∃ o : Ordinal.{u}, ∀ i, i < n → e i ∈ level R o := by + induction n with + | zero => exact ⟨0,fun _ hi => (Nat.not_lt_zero _ hi).elim⟩ + | succ n ih => + obtain ⟨o,ho⟩ := ih (fun i hi => he i (Nat.lt_succ_of_lt hi)) + obtain ⟨p,hp⟩ := he n (Nat.lt_succ_self n) + refine ⟨max o p,fun i hi => ?_⟩ + rcases Nat.lt_succ_iff_lt_or_eq.mp hi with hi|rfl + · exact level_mono R (le_max_left o p) (ho i hi) + · exact level_mono R (le_max_right o p) hp + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleGroundReals.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleGroundReals.lean new file mode 100644 index 0000000000000000000000000000000000000000..54810691c9b5e6d91ed794cba460f36d3df8538d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleGroundReals.lean @@ -0,0 +1,54 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleSeparation +import OAI.Computability.DegreeRigidity.SetModels.ModelReals + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def groundReals (M : ZFSet.{u}) : ZFSet.{u} := + (ZFSet.powerset ZFSet.omega).sep (fun x => x ∈ M) + +theorem mem_groundReals (M x : ZFSet.{u}) : + x ∈ groundReals M ↔ x ∈ M ∧ x ⊆ ZFSet.omega := by + rw [groundReals,ZFSet.mem_sep,ZFSet.mem_powerset,and_comm] + +theorem groundReals_mem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + groundReals M ∈ M := by + obtain ⟨R,hR,hdef⟩ := internal_power M hM hT.powerSet (sourceT_omega_mem M hM hT) + have heq : R = groundReals M := by + apply ZFSet.ext; intro x + exact (hdef x).trans (mem_groundReals M x).symm + exact heq ▸ hR + +theorem realCode_mem_groundReals (M : ZFSet.{u}) (A : Oracle) : + realCode A ∈ groundReals M ↔ A ∈ modelReals M := by + rw [mem_groundReals] + exact and_iff_left (realCode_subset A) + +theorem ground_real_in_relativeL (M : ZFSet.{u}) (A : Oracle) + (hA : A ∈ modelReals M) : InRelativeL (groundReals M) (realCode A) := + relativeL_transitive _ (parameter_in_relativeL _) ((realCode_mem_groundReals M A).mpr hA) + +theorem ground_seed_subset (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + seed (groundReals M) ⊆ M := + seed_minimal _ M hM (groundReals_mem M hM hT) + +theorem omega_in_ground_relativeL (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + InRelativeL (groundReals M) ZFSet.omega := by + apply relativeL_transitive _ (parameter_in_relativeL _) + exact (mem_groundReals M _).mpr ⟨sourceT_omega_mem M hM hT,fun _ h => h⟩ + +theorem ground_relativeL_infinity (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ∃ a : ZFSet.{u}, InRelativeL (groundReals M) a ∧ (∅ : ZFSet.{u}) ∈ a ∧ + ∀ x ∈ a, insert x x ∈ a := by + refine ⟨ZFSet.omega,omega_in_ground_relativeL M hM hT,ZFSet.omega_zero,?_⟩ + intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + exact (mem_omega _).mpr ⟨n+1,rfl⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleSatisfaction.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleSatisfaction.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e36c275aa84c993ac5d117fd51d69cf55e8a534 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleSatisfaction.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.Syntax.DefinablePower +import OAI.Computability.DegreeRigidity.SetModels.InternalInfinity + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def tupleCode {n : ℕ} (v : Fin n → ZFSet.{u}) : ZFSet.{u} := + ZFSet.pair (natSet n) (ZFSet.range (fun i : Fin n => ZFSet.pair (natSet i.val) (v i))) + +theorem tupleCode_length {n m : ℕ} (v : Fin n → ZFSet.{u}) (w : Fin m → ZFSet.{u}) + (h : tupleCode v = tupleCode w) : n = m := + natSet_injective (ZFSet.pair_inj.mp h).1 + +theorem tupleCode_injective (n : ℕ) : Function.Injective (@tupleCode.{u} n) := by + intro v w h + have hg := (ZFSet.pair_inj.mp h).2 + funext i + have hi : ZFSet.pair (natSet i.val) (v i) ∈ + ZFSet.range (fun j : Fin n => ZFSet.pair (natSet j.val) (w j)) := by + rw [← hg] + exact ZFSet.mem_range_self (f := fun index : Fin n => ZFSet.pair (natSet index.val) (v index)) i + obtain ⟨j,hj⟩ := ZFSet.mem_range.mp hi + obtain ⟨he,hv⟩ := ZFSet.pair_inj.mp hj + have hji : j = i := Fin.ext (natSet_injective he) + subst j + exact hv.symm + +noncomputable def satisfactionSet (A : ZFSet.{u}) : ZFSet.{u} := + ZFSet.range (fun t : {t : Σ n : ℕ, SentenceForm × (Fin n → Conditions A) // + t.2.1.bound ≤ t.1 ∧ t.2.1.Sat (A : Set ZFSet) + (tupleEnv (fun i => label A (t.2.2 i)))} => + ZFSet.pair (natSet (Encodable.encode t.val.2.1)) + (tupleCode (fun i => label A (t.val.2.2 i)))) + +theorem satisfactionSet_spec (A : ZFSet.{u}) (p : SentenceForm) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) (hb : p.bound ≤ n) : + ZFSet.pair (natSet (Encodable.encode p)) (tupleCode v) ∈ satisfactionSet A ↔ + p.Sat (A : Set ZFSet) (tupleEnv v) := by + rw [satisfactionSet,ZFSet.mem_range] + constructor + · rintro ⟨⟨⟨m,q,w⟩,hqm,hq⟩,he⟩ + obtain ⟨hp,ht⟩ := ZFSet.pair_inj.mp he + have hqp : q = p := Encodable.encode_injective (natSet_injective hp) + subst q + have hmn : m = n := tupleCode_length _ _ ht + subst m + have hwv := tupleCode_injective n ht + rwa [hwv] at hq + · intro hs + let w : Fin n → Conditions A := fun i => equivShrink A ⟨v i,hv i⟩ + have hw : (fun i => label A (w i)) = v := by + funext i; simp [w,label] + refine ⟨⟨⟨n,p,w⟩,hb,?_⟩,?_⟩ + · rwa [hw] + · exact congrArg (fun v' => ZFSet.pair (natSet (Encodable.encode p)) (tupleCode v')) hw + +theorem satisfactionSet_environment (A : ZFSet.{u}) (p : SentenceForm) + (e : ℕ → ZFSet.{u}) (he : ∀ i, i < p.bound → e i ∈ A) : + ZFSet.pair (natSet (Encodable.encode p)) + (tupleCode (fun i : Fin p.bound => e i)) ∈ satisfactionSet A ↔ + p.Sat (A : Set ZFSet) e := by + rw [satisfactionSet_spec A p _ (fun i => he i i.isLt) (le_refl _)] + exact p.finite_support _ _ _ (fun i hi => by simp [tupleEnv,hi]) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleSeparation.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..47975726e7084266c59e300a3c1db509d00b7cff --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleSeparation.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleClosure +import OAI.Computability.DegreeRigidity.SetModels.ElementarySatisfaction + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel SentenceForm BoundedSetTheory TransitiveNameModel +universe u + +def parameterShift : ℕ → ℕ | 0 => 0 | i+1 => i+2 + +theorem shifted_parameters (p : SentenceForm) (D : Set ZFSet.{u}) + (x a : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (p.rename parameterShift).Sat D (cons x (cons a e)) ↔ p.Sat D (cons x e) := by + rw [sat_rename] + have he : (fun i => cons x (cons a e) (parameterShift i)) = cons x e := by + funext i; cases i <;> rfl + rw [he] + +theorem bounded_separation_mem_definablePower (A a : ZFSet.{u}) (hA : Transitive A) + (ha : a ∈ A) (φ : Formula) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) : + a.sep (fun x => φ.Eval (cons x e)) ∈ definablePower A := by + let ψ := SentenceForm.conj (.member 0 1) ((fromBounded φ).rename parameterShift) + have hψ := separation_mem_definablePower A ψ (cons a e) (by + intro i _; cases i; exact ha; exact he _) + have heq : A.sep (fun x => ψ.Sat (A : Set ZFSet) (cons x (cons a e))) = + a.sep (fun x => φ.Eval (cons x e)) := by + apply ZFSet.ext; intro x + simp only [ZFSet.mem_sep,ψ,Sat,cons_zero,cons_succ,shifted_parameters,bounded_sat] + constructor + · rintro ⟨hx,hxa,hφ⟩ + exact ⟨hxa,(φ.absolute A hA _ (by intro i; cases i; exact hx; exact he _)).mp hφ⟩ + · rintro ⟨hxa,hφ⟩ + have hx := hA a ha x hxa + exact ⟨hx,hxa,(φ.absolute A hA _ (by intro i; cases i; exact hx; exact he _)).mpr hφ⟩ + rwa [heq] at hψ + +theorem bounded_separation_in_relativeL (R a : ZFSet.{u}) (ha : InRelativeL R a) + (φ : Formula) (e : ℕ → ZFSet.{u}) + (he : ∀ i, i < (fromBounded φ).bound → InRelativeL R (e i)) : + InRelativeL R (a.sep (fun x => φ.Eval (cons x e))) := by + obtain ⟨i,hi⟩ := ha + obtain ⟨j,hj⟩ := finite_parameters_in_level R e (fromBounded φ).bound he + let A := level R (max i j) + have haA : a ∈ A := level_mono R (le_max_left i j) hi + let e' : ℕ → ZFSet.{u} := fun n => if n < (fromBounded φ).bound then e n else a + have heA : ∀ n, e' n ∈ A := by + intro n + dsimp [e']; split + next hn => exact level_mono R (le_max_right i j) (hj n hn) + next => exact haA + have heval (x : ZFSet.{u}) : φ.Eval (cons x e') ↔ φ.Eval (cons x e) := by + rw [← bounded_univ,← bounded_univ] + apply (fromBounded φ).finite_support + intro k hk + cases k with + | zero => rfl + | succ k => + change e' k = e k + simp [e',show k < (fromBounded φ).bound by omega] + have heq : a.sep (fun x => φ.Eval (cons x e')) = a.sep (fun x => φ.Eval (cons x e)) := by + apply ZFSet.ext; intro x + simp only [ZFSet.mem_sep,heval] + refine ⟨max i j + 1,?_⟩ + rw [level_succ,← heq] + exact bounded_separation_mem_definablePower A a (level_transitive R _) haA φ e' heA + +theorem bounded_class_absolute (R : ZFSet.{u}) (φ : Formula) + (e : ℕ → ZFSet.{u}) (he : ∀ i, InRelativeL R (e i)) : + (fromBounded φ).Sat {x | InRelativeL R x} e ↔ φ.Eval e := by + induction φ generalizing e with + | equal => rfl + | member => rfl + | conj φ ψ ihφ ihψ => exact and_congr (ihφ e he) (ihψ e he) + | neg φ ih => exact not_congr (ih e he) + | existsMem i φ ih => + simp only [fromBounded,Sat,Formula.Eval,cons_zero,cons_succ,Set.mem_ofPred_eq] + constructor + · rintro ⟨x,hx,hxi,hφ⟩ + exact ⟨x,hxi,(ih (cons x e) (by intro k; cases k; exact hx; exact he _)).mp hφ⟩ + · rintro ⟨x,hxi,hφ⟩ + have hx := relativeL_transitive R (he i) hxi + exact ⟨x,hx,hxi,(ih (cons x e) (by intro k; cases k; exact hx; exact he _)).mpr hφ⟩ + +theorem relativeL_bounded_separation (R : ZFSet.{u}) (φ : Formula) + (e : ℕ → ZFSet.{u}) (he : ∀ i, InRelativeL R (e i)) + (a : ZFSet.{u}) (ha : InRelativeL R a) : + ∃ b, InRelativeL R b ∧ ∀ x, InRelativeL R x → + (x ∈ b ↔ x ∈ a ∧ (fromBounded φ).Sat {y | InRelativeL R y} (cons x e)) := by + refine ⟨a.sep (fun x => φ.Eval (cons x e)), + bounded_separation_in_relativeL R a ha φ e (fun i _ => he i),?_⟩ + intro x hx + rw [ZFSet.mem_sep,bounded_class_absolute R φ _ (by intro i; cases i; exact hx; exact he _)] + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleStages.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleStages.lean new file mode 100644 index 0000000000000000000000000000000000000000..307d68887df485b93be49269f34ab86547e3ddd6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleStages.lean @@ -0,0 +1,113 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleBase +import Mathlib.SetTheory.ZFC.Ordinal + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel +universe u + +noncomputable def stage (R o : ZFSet.{u}) : ZFSet.{u} := + seed R ∪ ZFSet.sUnion (ZFSet.range (fun i : Shrink o => + definablePower (stage R ((equivShrink o).symm i).val))) +termination_by o +decreasing_by exact ((equivShrink o).symm i).property + +theorem mem_stage (R o x : ZFSet.{u}) : + x ∈ stage R o ↔ x ∈ seed R ∨ ∃ i ∈ o, x ∈ definablePower (stage R i) := by + rw [stage,ZFSet.mem_union,ZFSet.mem_sUnion] + apply or_congr_right + constructor + · rintro ⟨a,ha,hx⟩ + obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp ha + exact ⟨_,((equivShrink o).symm i).property,hx⟩ + · rintro ⟨i,hi,hx⟩ + refine ⟨_,ZFSet.mem_range.mpr ⟨equivShrink o ⟨i,hi⟩,rfl⟩,?_⟩ + simpa using hx + +theorem seed_subset_stage (R o : ZFSet.{u}) : seed R ⊆ stage R o := + fun x hx => (mem_stage R o x).mpr (Or.inl hx) + +theorem stage_zero (R : ZFSet.{u}) : stage R ∅ = seed R := by + apply ZFSet.ext; intro x + simp [mem_stage] + +theorem stage_transitive (R o : ZFSet.{u}) : Transitive (stage R o) := by + induction o using ZFSet.inductionOn with + | h o ih => + intro x hx y hy + rcases (mem_stage R o x).mp hx with hx|⟨i,hi,hx⟩ + · exact seed_subset_stage R o (seed_transitive R x hx y hy) + · exact (mem_stage R o y).mpr (Or.inr ⟨i,hi,definablePower_transitive (ih i hi) x hx y hy⟩) + +theorem stage_mono (R : ZFSet.{u}) {i j : ZFSet.{u}} (hij : i ⊆ j) : stage R i ⊆ stage R j := by + intro x hx + rcases (mem_stage R i x).mp hx with hx|⟨k,hk,hx⟩ + · exact seed_subset_stage R j hx + · exact (mem_stage R j x).mpr (Or.inr ⟨k,hij hk,hx⟩) + +theorem definablePower_subset_stage (R : ZFSet.{u}) {i j : ZFSet.{u}} (hi : i ∈ j) : + definablePower (stage R i) ⊆ stage R j := + fun x hx => (mem_stage R j x).mpr (Or.inr ⟨i,hi,hx⟩) + +theorem stage_mem_stage (R : ZFSet.{u}) {i j : ZFSet.{u}} (hi : i ∈ j) : + stage R i ∈ stage R j := + definablePower_subset_stage R hi (self_mem_definablePower _) + +theorem stage_succ (R o : ZFSet.{u}) : + stage R (insert o o) = definablePower (stage R o) := by + apply ZFSet.ext; intro x + constructor + · intro hx + rcases (mem_stage R (insert o o) x).mp hx with hseed|⟨i,hi,hdef⟩ + · exact subset_definablePower (stage_transitive R o) (seed_subset_stage R o hseed) + · rcases ZFSet.mem_insert_iff.mp hi with he|hi + · simpa only [he] using hdef + · exact subset_definablePower (stage_transitive R o) (definablePower_subset_stage R hi hdef) + · intro hx; exact definablePower_subset_stage R (ZFSet.mem_insert o o) hx + +noncomputable def level (R : ZFSet.{u}) (o : Ordinal.{u}) : ZFSet.{u} := stage R o.toZFSet + +theorem level_zero (R : ZFSet.{u}) : level R 0 = seed R := by + rw [level,Ordinal.toZFSet_zero,stage_zero] + +theorem level_succ (R : ZFSet.{u}) (o : Ordinal.{u}) : + level R (o+1) = definablePower (level R o) := by + simp only [level,Ordinal.toZFSet_add_one,stage_succ] + +theorem level_mono (R : ZFSet.{u}) {i j : Ordinal.{u}} (hij : i ≤ j) : level R i ⊆ level R j := + stage_mono R (Ordinal.toZFSet_monotone hij) + +theorem level_mem_level (R : ZFSet.{u}) {i j : Ordinal.{u}} (hij : i < j) : level R i ∈ level R j := + stage_mem_stage R (Ordinal.toZFSet_mem_toZFSet_iff.mpr hij) + +theorem level_transitive (R : ZFSet.{u}) (o : Ordinal.{u}) : Transitive (level R o) := + stage_transitive R o.toZFSet + +theorem mem_level_limit (R x : ZFSet.{u}) (o : Ordinal.{u}) (ho : Order.IsSuccLimit o) : + x ∈ level R o ↔ ∃ i < o, x ∈ level R i := by + constructor + · intro hx + rcases (mem_stage R o.toZFSet x).mp hx with hx|⟨a,ha,hx⟩ + · refine ⟨0,Ordinal.natCast_lt_of_isSuccLimit ho 0,?_⟩ + rwa [level_zero] + · obtain ⟨i,hi,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ha + refine ⟨i+1,ho.succ_lt hi,?_⟩ + rwa [level_succ] + · rintro ⟨i,hi,hx⟩ + exact level_mono R hi.le hx + +def InRelativeL (R x : ZFSet.{u}) : Prop := ∃ o : Ordinal.{u}, x ∈ level R o + +theorem parameter_in_relativeL (R : ZFSet.{u}) : InRelativeL R R := by + exact ⟨0,level_zero R ▸ parameter_mem_seed R⟩ + +theorem relativeL_transitive (R : ZFSet.{u}) {x y : ZFSet.{u}} + (hx : InRelativeL R x) (hy : y ∈ x) : InRelativeL R y := by + obtain ⟨o,ho⟩ := hx + exact ⟨o,level_transitive R o x ho y hy⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleSuccessorCode.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleSuccessorCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..c33b1c0e3de6ddb6894f4dffe0c1e1ecafda9254 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleSuccessorCode.lean @@ -0,0 +1,55 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleSatisfaction +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleStages + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +theorem tupleEnv_cons {n : ℕ} (x : ZFSet.{u}) (v : Fin n → ZFSet.{u}) : + tupleEnv (Fin.cases x v) = cons x (tupleEnv v) := by + funext i + cases i with + | zero => simp [tupleEnv,cons] + | succ i => + by_cases hi : i < n + · simp only [tupleEnv,cons_succ,Nat.succ_lt_succ_iff,hi,dite_eq_left] + rfl + · simp [tupleEnv,cons_succ,hi] + +theorem definedSubset_record (A x : ZFSet.{u}) (p : SentenceForm) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) (hb : p.bound ≤ n+1) : + x ∈ definedSubset A p v ↔ x ∈ A ∧ + ZFSet.pair (natSet (Encodable.encode p)) (tupleCode (Fin.cases x v)) ∈ satisfactionSet A := by + rw [mem_definedSubset] + apply and_congr_right; intro hx + rw [satisfactionSet_spec A p _ (fun i => Fin.cases hx hv i) hb,tupleEnv_cons] + +theorem definablePower_records (A S : ZFSet.{u}) : + S ∈ definablePower A ↔ + ∃ (n : ℕ) (p : SentenceForm) (v : Fin n → ZFSet.{u}), + p.bound ≤ n+1 ∧ (∀ i, v i ∈ A) ∧ ∀ x, + (x ∈ S ↔ x ∈ A ∧ ZFSet.pair (natSet (Encodable.encode p)) + (tupleCode (Fin.cases x v)) ∈ satisfactionSet A) := by + rw [mem_definablePower] + constructor + · rintro ⟨n,p,v,hb,hv,rfl⟩ + exact ⟨n,p,v,hb,hv,fun x => definedSubset_record A x p v hv hb⟩ + · rintro ⟨n,p,v,hb,hv,hS⟩ + refine ⟨n,p,v,hb,hv,?_⟩ + apply ZFSet.ext; intro x + exact (hS x).trans (definedSubset_record A x p v hv hb).symm + +theorem level_succ_records (R S : ZFSet.{u}) (o : Ordinal.{u}) : + S ∈ level R (o+1) ↔ + ∃ (n : ℕ) (p : SentenceForm) (v : Fin n → ZFSet.{u}), + p.bound ≤ n+1 ∧ (∀ i, v i ∈ level R o) ∧ ∀ x, + (x ∈ S ↔ x ∈ level R o ∧ ZFSet.pair (natSet (Encodable.encode p)) + (tupleCode (Fin.cases x v)) ∈ satisfactionSet (level R o)) := by + rw [level_succ,definablePower_records] + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleTupleSpace.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleTupleSpace.lean new file mode 100644 index 0000000000000000000000000000000000000000..03bfcca2a7e6cb4b66e386ac5006a8c1be80f283 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructibleTupleSpace.lean @@ -0,0 +1,148 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleSatisfaction +import OAI.Computability.DegreeRigidity.SetModels.ModelReals + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def tupleGraph {n : ℕ} (v : Fin n → ZFSet.{u}) : ZFSet.{u} := + ZFSet.range (fun i : Fin n => ZFSet.pair (natSet i.val) (v i)) + +theorem tupleGraph_pair {n : ℕ} (v : Fin n → ZFSet.{u}) (i : Fin n) (x : ZFSet.{u}) : + ZFSet.pair (natSet i.val) x ∈ tupleGraph v ↔ x = v i := by + rw [tupleGraph,ZFSet.mem_range] + constructor + · rintro ⟨j,hj⟩ + obtain ⟨hji,hx⟩ := ZFSet.pair_inj.mp hj + have he : j = i := Fin.ext (natSet_injective hji) + subst j; exact hx.symm + · rintro rfl; exact ⟨i,rfl⟩ + +theorem tupleGraph_function (A : ZFSet.{u}) {n : ℕ} (v : Fin n → ZFSet.{u}) + (hv : ∀ i, v i ∈ A) : FunctionGraph (natSet n) A (tupleGraph v) := by + constructor + · intro z hz + obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hz + exact ⟨natSet i.val,(natSet_mem_natSet _ _).mpr i.isLt,v i,hv i,rfl⟩ + · intro x hx + obtain ⟨i,hi,rfl⟩ := (mem_natSet n x).mp hx + exact ⟨v ⟨i,hi⟩,hv _,(tupleGraph_pair v ⟨i,hi⟩ _).mpr rfl, + fun y _ hy => (tupleGraph_pair v ⟨i,hi⟩ y).mp hy⟩ + +theorem functionGraph_tuple (A g : ZFSet.{u}) (n : ℕ) + (hg : FunctionGraph (natSet n) A g) : + ∃ v : Fin n → ZFSet.{u}, (∀ i, v i ∈ A) ∧ g = tupleGraph v := by + classical + have hex (i : Fin n) := hg.2 (natSet i.val) ((natSet_mem_natSet _ _).mpr i.isLt) + choose v hv hp hu using hex + refine ⟨v,hv,?_⟩ + apply ZFSet.ext; intro z + constructor + · intro hz + obtain ⟨x,hx,y,hy,rfl⟩ := hg.1 z hz + obtain ⟨i,hi,rfl⟩ := (mem_natSet n x).mp hx + exact (tupleGraph_pair v ⟨i,hi⟩ y).mpr (hu ⟨i,hi⟩ y hy hz) + · intro hz + obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hz + exact hp i + +theorem finite_range_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (h0 : (∅ : ZFSet.{u}) ∈ M) + (n : ℕ) (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ M) : ZFSet.range v ∈ M := by + induction n with + | zero => + have he : ZFSet.range v = ∅ := by + apply ZFSet.ext; intro x + simp only [ZFSet.mem_range,ZFSet.notMem_empty,iff_false] + rintro ⟨i,_⟩; exact Fin.elim0 i + rwa [he] + | succ n ih => + have he : ZFSet.range v = ({v 0} : ZFSet.{u}) ∪ ZFSet.range (fun i : Fin n => v i.succ) := by + apply ZFSet.ext; intro x + simp only [ZFSet.mem_range,ZFSet.mem_union,ZFSet.mem_singleton,Fin.exists_fin_succ] + exact or_congr eq_comm Iff.rfl + rw [he] + exact binary_union_mem M hM hP hU (singleton_mem M hM hP (hv 0)) + (ih _ (fun i => hv i.succ)) + +theorem tupleGraph_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hω : ZFSet.omega.{u} ∈ M) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ M) : tupleGraph v ∈ M := by + have hn (k : ℕ) : natSet.{u} k ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨k,rfl⟩) + exact finite_range_mem M hM hP hU (hn 0) n _ + (fun i => orderedPair_mem M hM hP (hn i.val) (hv i)) + +theorem tupleCode_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hω : ZFSet.omega.{u} ∈ M) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ M) : tupleCode v ∈ M := + orderedPair_mem M hM hP (hM _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩)) + (tupleGraph_mem M hM hP hU hω v hv) + +noncomputable def tupleSpace (A : ZFSet.{u}) : ZFSet.{u} := + ZFSet.range (fun t : Σ n : ℕ, Fin n → Conditions A => + tupleCode (fun i => label A (t.2 i))) + +theorem mem_tupleSpace (A t : ZFSet.{u}) : + t ∈ tupleSpace A ↔ ∃ (n : ℕ) (v : Fin n → ZFSet.{u}), + (∀ i, v i ∈ A) ∧ t = tupleCode v := by + rw [tupleSpace,ZFSet.mem_range] + constructor + · rintro ⟨⟨n,v⟩,ht⟩ + exact ⟨n,fun i => label A (v i),fun i => label_mem A (v i),ht.symm⟩ + · rintro ⟨n,v,hv,rfl⟩ + let w : Fin n → Conditions A := fun i => equivShrink A ⟨v i,hv i⟩ + refine ⟨⟨n,w⟩,?_⟩ + congr 1; funext i; simp [w,label] + +def tupleFormula (o A Q t : ℕ) : Formula := + .existsMem o (.existsMem (Q+1) + (.conj (.orderedPair (t+2) 1 0) (.functionGraph 0 1 (A+2)))) + +theorem tupleFormula_spec (o A Q t : ℕ) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) + (hQ : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ e A) → tupleGraph v ∈ e Q) : + (tupleFormula o A Q t).Eval e ↔ e t ∈ tupleSpace (e A) := by + simp only [tupleFormula,Formula.Eval,Formula.eval_orderedPair,Formula.eval_functionGraph, + cons_zero,cons_succ] + rw [ho,mem_tupleSpace] + constructor + · rintro ⟨n,hn,g,_,ht,hg⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + obtain ⟨v,hv,rfl⟩ := functionGraph_tuple (e A) g n hg + exact ⟨n,v,hv,ht⟩ + · rintro ⟨n,v,hv,ht⟩ + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,tupleGraph v,hQ n v hv,ht, + tupleGraph_function (e A) v hv⟩ + +theorem tupleSpace_mem (M A : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) : tupleSpace A ∈ M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + obtain ⟨Q,hQM,hQdef⟩ := internal_power M hM hT.powerSet + (product_mem M hM hT.pairing hT.union hT.powerSet hS hω hA) + have hQ (n : ℕ) (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) : tupleGraph v ∈ Q := by + apply (hQdef _).mpr + refine ⟨tupleGraph_mem M hM hT.pairing hT.union hω v (fun i => hM A hA _ (hv i)),?_⟩ + intro z hz + obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hz + exact ZFSet.mem_prod.mpr ⟨_,(mem_omega _).mpr ⟨i.val,rfl⟩,_,hv i,rfl⟩ + let e := cons ZFSet.omega (cons A (fun _ => Q)) + have he : ∀ i, e i ∈ M := by intro i; rcases i with _|_|i; exact hω; exact hA; exact hQM + have hs := sep_mem M hM hS (tupleFormula 1 2 3 0) e he + (product_mem M hM hT.pairing hT.union hT.powerSet hS hω hQM) + have heq : (ZFSet.prod ZFSet.omega Q).sep + (fun t => (tupleFormula 1 2 3 0).Eval (cons t e)) = tupleSpace A := by + apply ZFSet.ext; intro t + rw [ZFSet.mem_sep,tupleFormula_spec 1 2 3 0 (cons t e) rfl hQ] + change (t ∈ ZFSet.prod ZFSet.omega Q ∧ t ∈ tupleSpace A) ↔ t ∈ tupleSpace A + refine ⟨And.right,fun ht => ⟨?_,ht⟩⟩ + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp ht + exact ZFSet.mem_prod.mpr ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,tupleGraph v,hQ n v hv,rfl⟩ + exact heq ▸ hs + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionDefinition.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionDefinition.lean new file mode 100644 index 0000000000000000000000000000000000000000..4591385d2677c980b3e2eb7bf0eaf8e9b2b6f1f2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionDefinition.lean @@ -0,0 +1,66 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeConstruction +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleSuccessorCode + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel +universe u + +theorem Construction.value_mem (t : Construction.{u}) (M R : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (hR : R ∈ M) (P : Oracle) + (ht : t.Certified R P) (hi : t.Indexed M) : t.value R P ∈ M := + (t.value_in_relativeModel M R hM hT P ht hi).mem_ground hM hT hR + +theorem Construction.define_record (R : ZFSet.{u}) (P : Oracle) + (o : Ordinal.{u}) (n : ℕ) (p : SentenceForm) (c : Fin n → Construction.{u}) + (ht : (Construction.define o n p c).Certified R P) (x : ZFSet.{u}) : + x ∈ (Construction.define o n p c).value R P ↔ x ∈ level R o ∧ + ZFSet.pair (natSet (Encodable.encode p)) + (tupleCode (Fin.cases x (fun i => (c i).value R (realPart P i)))) ∈ + satisfactionSet (level R o) := + definedSubset_record _ x p _ (fun i => (ht.2 i).2) ht.1 + +theorem Construction.define_satisfaction_mem (M R : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (hR : R ∈ M) + (o : Ordinal.{u}) (n : ℕ) (p : SentenceForm) (c : Fin n → Construction.{u}) + (hi : (Construction.define o n p c).Indexed M) : + satisfactionSet (level R o) ∈ M := + satisfactionSet_mem M _ hM hT (level_mem M R hM hT hR o hi.1) + +theorem construction_definition_of_relativeModel (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (x : ZFSet.{u}) + (hx : x ∈ relativeModel M (groundReals M)) : + ∃ (o : Ordinal.{u}) (n : ℕ) (p : SentenceForm) + (c : Fin n → Construction.{u}) (P : Oracle), + o.toZFSet ∈ M ∧ P ∈ modelReals M ∧ + (Construction.define o n p c).Indexed M ∧ + (Construction.define o n p c).Certified (groundReals M) P ∧ + satisfactionSet (level (groundReals M) o) ∈ M ∧ + ∀ z, z ∈ x ↔ z ∈ level (groundReals M) o ∧ + p.Sat (level (groundReals M) o : Set ZFSet) + (cons z (tupleEnv (fun i => (c i).value (groundReals M) (realPart P i)))) := by + obtain ⟨t,P,hP,hi,ht,he⟩ := construction_of_relativeModel M hM hT x hx + obtain ⟨_,o,ho,hxo⟩ := ZFSet.mem_sep.mp hx + let c : Fin 1 → Construction.{u} := fun _ => t + let Q : Oracle := packedReal (fun _ : Fin 1 => P) + have hpart (i : Fin 1) : realPart Q i = P := realPart_packed _ i + have hcert : (Construction.define o 1 (.member 0 1) c).Certified (groundReals M) Q := by + refine ⟨by decide,fun i => ?_⟩ + change t.Certified _ _ ∧ t.value _ _ ∈ _ + rw [hpart] + exact ⟨ht,he.symm ▸ hxo⟩ + refine ⟨o,1,.member 0 1,c,Q,ho,packedReal_internal M hM hT _ (fun _ => hP), + ⟨ho,fun _ => hi⟩,hcert, + satisfactionSet_mem M _ hM hT (level_mem M _ hM hT (groundReals_mem M hM hT) o ho),?_⟩ + intro z + have hv : tupleEnv (fun i : Fin 1 => (c i).value (groundReals M) (realPart Q i)) 0 = x := by + rw [show (0 : ℕ) = (⟨0,by decide⟩ : Fin 1).val from rfl,tupleEnv_lt,hpart] + exact he + change z ∈ x ↔ z ∈ level (groundReals M) o ∧ z ∈ _ + simp only [cons_succ,hv] + exact ⟨fun hz => ⟨level_transitive _ o x hxo z hz,hz⟩,And.right⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionHeightDomains.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionHeightDomains.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d59eb9ffe1bffdc3d0169d10c8e73c9e1293cb5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionHeightDomains.lean @@ -0,0 +1,38 @@ +import OAI.Computability.DegreeRigidity.Constructibility.InternalHeightDomains +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalConstruction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u +attribute [local irreducible] Construction.ownRealsMembership SentenceForm.bound + +theorem Construction.largest_domain_definition (t : Construction.{u}) : + ∃ q : SentenceForm, ∀ M : ZFSet.{u}, Transitive M → SourceT M → + ∀ P : Oracle, P ∈ modelReals M → t.Certified (groundReals M) P → t.Indexed M → + ∃ β : Ordinal.{u}, β.toZFSet ∈ M ∧ + ∀ a : Ordinal.{u}, a.toZFSet ∈ M → β ≤ a → + let R := groundReals M + let δ := a - ordinalHeight (seed R) + 1 + δ.toZFSet ∈ M ∧ t.value R P ∈ level R δ ∧ + (∀ i, t.ordinalInputs P i ∈ level R δ) ∧ + (∀ e : ℕ → ZFSet.{u}, e 0 ∈ level R δ → + (largestOrdinalSentence.Sat (level R δ : Set ZFSet) e ↔ e 0 = a.toZFSet)) ∧ + ∀ z ∈ level R δ, + q.Sat (level R δ : Set ZFSet) (cons z (t.ordinalInputs P)) ↔ z ∈ t.value R P := by + obtain ⟨q,hq⟩ := t.ordinal_definition + refine ⟨q,?_⟩ + intro M hM hT P hP ht hi + obtain ⟨γ,hγ,hγspec⟩ := hq M hM hT P hP ht hi + obtain ⟨β,hβ,hβspec⟩ := internal_domains_with_largest_ordinal M (groundReals M) hM hT + (groundReals_mem M hM hT) γ hγ + refine ⟨β,hβ,?_⟩ + intro a ha hle + obtain ⟨hδ,hγδ,_,hmax⟩ := hβspec a ha hle + obtain ⟨hv,he,hq⟩ := hγspec _ hδ hγδ + exact ⟨hδ,hv,he,hmax,hq⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionInlining.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionInlining.lean new file mode 100644 index 0000000000000000000000000000000000000000..abb844bbbc6f40895abbc0156217dc7587cd558b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionInlining.lean @@ -0,0 +1,99 @@ +import OAI.Computability.DegreeRigidity.Syntax.SentenceInlining +import OAI.Computability.DegreeRigidity.Constructibility.ConstructionDefinition + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def Construction.inputs (R : ZFSet.{u}) (P : Oracle) : + Construction.{u} → ℕ → ZFSet.{u} + | .reals, _ => R + | .parameter, _ => realCode P + | .define o _ _ _, 0 => level R o + | .define _ n _ c, k+1 => + if h : (Nat.unpair k).1 < n then + (c ⟨(Nat.unpair k).1,h⟩).inputs R (realPart P (Nat.unpair k).1) (Nat.unpair k).2 + else R + +theorem Construction.inputs_child (R : ZFSet.{u}) (P : Oracle) + (o : Ordinal.{u}) (n : ℕ) (p : SentenceForm) (c : Fin n → Construction.{u}) + (i : Fin n) (k : ℕ) : + (Construction.define o n p c).inputs R P (Nat.pair i k+1) = + (c i).inputs R (realPart P i) k := by + simp [Construction.inputs,Nat.unpair_pair,i.isLt] + +theorem Construction.inputs_mem (t : Construction.{u}) (M R : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (hR : R ∈ M) (P : Oracle) + (ht : t.Certified R P) (hi : t.Indexed M) : ∀ k, t.inputs R P k ∈ M := by + induction t generalizing P with + | reals => exact fun _ => hR + | parameter => exact fun _ => hM R hR _ ht + | define o n p c ih => + intro k + cases k with + | zero => exact level_mem M R hM hT hR o hi.1 + | succ k => + simp only [Construction.inputs] + split + next h => + exact ih ⟨(Nat.unpair k).1,h⟩ _ (ht.2 ⟨(Nat.unpair k).1,h⟩).1 + (hi.2 ⟨(Nat.unpair k).1,h⟩) (Nat.unpair k).2 + next => exact hR + +noncomputable def Construction.formula : Construction.{u} → ℕ → (ℕ → ℕ) → SentenceForm + | .reals, out, r => .equal out (r 0) + | .parameter, out, r => .equal out (r 0) + | .define _ n p c, out, r => bindComputed n + (fun i => if h : i < n then + (c ⟨i,h⟩).formula 0 (fun k => r (Nat.pair i k+1)+1) + else .equal 0 0) + (subsetBody n out (r 0) p) + +theorem Construction.formula_spec (t : Construction.{u}) (M R : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (hR : R ∈ M) (P : Oracle) + (ht : t.Certified R P) (hi : t.Indexed M) + (out : ℕ) (r : ℕ → ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hr : ∀ k, e (r k) = t.inputs R P k) : + (t.formula out r).Sat (M : Set ZFSet) e ↔ e out = t.value R P := by + induction t generalizing P out r e with + | reals => exact Iff.of_eq (congrArg (e out = ·) (hr 0)) + | parameter => exact Iff.of_eq (congrArg (e out = ·) (hr 0)) + | define o n p c ih => + let w : ℕ → ZFSet.{u} := fun i => if h : i < n then + (c ⟨i,h⟩).value R (realPart P i) else R + have hw (i : ℕ) (hin : i < n) : w i ∈ M := by + dsimp [w]; rw [dite_eq_left hin] + exact hM _ (level_mem M R hM hT hR o hi.1) _ (ht.2 ⟨i,hin⟩).2 + have hf (i : ℕ) (hin : i < n) (x : ZFSet.{u}) (hx : x ∈ M) : + (if h : i < n then (c ⟨i,h⟩).formula 0 (fun k => r (Nat.pair i k+1)+1) + else .equal 0 0).Sat (M : Set ZFSet) (cons x e) ↔ x = w i := by + rw [dite_eq_left hin,show w i = (c ⟨i,hin⟩).value R (realPart P i) from dite_eq_left hin] + apply ih ⟨i,hin⟩ _ (ht.2 ⟨i,hin⟩).1 (hi.2 ⟨i,hin⟩) 0 _ _ + (by intro k; cases k; exact hx; exact he _) + intro k + change e (r (Nat.pair i k+1)) = _ + rw [hr,Construction.inputs_child R P o n p c ⟨i,hin⟩ k] + rw [Construction.formula,bindComputed_spec M n _ _ e w hw hf, + subsetBody_spec M hM n out (r 0) p ht.1 e w he hw] + have ha : e (r 0) = level R o := hr 0 + rw [ha] + have hv : (fun i : Fin n => w i) = (fun i : Fin n => (c i).value R (realPart P i)) := by + funext i; exact dite_eq_left i.isLt + rw [hv] + rfl + +theorem Construction.inlined_definition (t : Construction.{u}) (M R : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (hR : R ∈ M) (P : Oracle) + (ht : t.Certified R P) (hi : t.Indexed M) : + ∃ p : SentenceForm, ∀ x ∈ M, + p.Sat (M : Set ZFSet) (cons x (t.inputs R P)) ↔ x = t.value R P := by + refine ⟨t.formula 0 Nat.succ,?_⟩ + intro x hx + exact t.formula_spec M R hM hT hR P ht hi 0 Nat.succ _ + (by intro i; cases i; exact hx; exact t.inputs_mem M R hM hT hR P ht hi _) (fun _ => rfl) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionInputData.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionInputData.lean new file mode 100644 index 0000000000000000000000000000000000000000..35de0e50abf58c43d0743ff64ffa5e98bb1c7cec --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionInputData.lean @@ -0,0 +1,141 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructionInlining + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +inductive ConstructionInput : Type (u+1) + | reals + | stage (o : Ordinal.{u}) + | realPath (path : List ℕ) + +def pathReal (P : Oracle) : List ℕ → Oracle + | [] => P + | i::is => pathReal (realPart P i) is + +noncomputable def ConstructionInput.value (R : ZFSet.{u}) (P : Oracle) : + ConstructionInput.{u} → ZFSet.{u} + | .reals => R + | .stage o => level R o + | .realPath path => realCode (pathReal P path) + +def ConstructionInput.prefix (i : ℕ) : ConstructionInput.{u} → ConstructionInput.{u} + | .reals => .reals + | .stage o => .stage o + | .realPath path => .realPath (i::path) + +theorem ConstructionInput.prefix_value (d : ConstructionInput.{u}) + (R : ZFSet.{u}) (P : Oracle) (i : ℕ) : + (d.prefix i).value R P = d.value R (realPart P i) := by + cases d <;> rfl + +def ConstructionInput.Indexed (M : ZFSet.{u}) : ConstructionInput.{u} → Prop + | .reals => True + | .stage o => o.toZFSet ∈ M + | .realPath _ => True + +theorem ConstructionInput.prefix_indexed (d : ConstructionInput.{u}) + (M : ZFSet.{u}) (i : ℕ) : (d.prefix i).Indexed M ↔ d.Indexed M := by + cases d <;> rfl + +noncomputable def Construction.inputData : Construction.{u} → ℕ → ConstructionInput.{u} + | .reals, _ => .reals + | .parameter, _ => .realPath [] + | .define o _ _ _, 0 => .stage o + | .define _ n _ c, k+1 => + if h : (Nat.unpair k).1 < n then + ((c ⟨(Nat.unpair k).1,h⟩).inputData (Nat.unpair k).2).prefix (Nat.unpair k).1 + else .reals + +theorem Construction.inputs_eq_data (t : Construction.{u}) (R : ZFSet.{u}) + (P : Oracle) (k : ℕ) : t.inputs R P k = (t.inputData k).value R P := by + induction t generalizing P k with + | reals => rfl + | parameter => rfl + | define o n p c ih => + cases k with + | zero => rfl + | succ k => + simp only [Construction.inputs,Construction.inputData] + split + next h => rw [ConstructionInput.prefix_value]; exact ih _ _ _ + next => rfl + +theorem Construction.inputData_indexed (t : Construction.{u}) (M : ZFSet.{u}) + (hi : t.Indexed M) : ∀ k, (t.inputData k).Indexed M := by + induction t with + | reals => exact fun _ => trivial + | parameter => exact fun _ => trivial + | define o n p c ih => + intro k + cases k with + | zero => exact hi.1 + | succ k => + simp only [Construction.inputData] + split + next h => + rw [ConstructionInput.prefix_indexed] + exact ih _ (hi.2 _) _ + next => trivial + +noncomputable def Construction.membershipFormula (t : Construction.{u}) : SentenceForm := + .ex (.conj (t.formula 0 (fun k => k+2)) (.member 1 0)) + +theorem Construction.membershipFormula_spec (t : Construction.{u}) (M R : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (hR : R ∈ M) (P : Oracle) + (ht : t.Certified R P) (hi : t.Indexed M) (z : ZFSet.{u}) (hz : z ∈ M) : + t.membershipFormula.Sat (M : Set ZFSet) (cons z (t.inputs R P)) ↔ + z ∈ t.value R P := by + have hspec (x : ZFSet.{u}) (hx : x ∈ M) : + (t.formula 0 (fun k => k+2)).Sat (M : Set ZFSet) + (cons x (cons z (t.inputs R P))) ↔ x = t.value R P := by + apply t.formula_spec M R hM hT hR P ht hi + · intro i + rcases i with _|_|i + · exact hx + · exact hz + · exact t.inputs_mem M R hM hT hR P ht hi i + · exact fun _ => rfl + change (∃ x ∈ M, (t.formula 0 (fun k => k+2)).Sat (M : Set ZFSet) + (cons x (cons z (t.inputs R P))) ∧ z ∈ x) ↔ _ + constructor + · rintro ⟨x,hx,hf,hzx⟩ + exact (hspec x hx).mp hf ▸ hzx + · intro hzt + have hv := t.value_mem M R hM hT hR P ht hi + exact ⟨_,hv,(hspec _ hv).mpr rfl,hzt⟩ + +theorem Construction.finite_membership_definition (t : Construction.{u}) : + ∃ (n : ℕ) (p : SentenceForm) (d : Fin n → ConstructionInput.{u}), + p.bound ≤ n+1 ∧ + ∀ (M R : ZFSet.{u}) (_hM : Transitive M) (_hT : SourceT M) (_hR : R ∈ M) + (P : Oracle) (_ht : t.Certified R P) (_hi : t.Indexed M), + (∀ i, (d i).Indexed M ∧ (d i).value R P ∈ M) ∧ + ∀ z ∈ M, p.Sat (M : Set ZFSet) + (cons z (tupleEnv (fun i => (d i).value R P))) ↔ z ∈ t.value R P := by + let p := t.membershipFormula + refine ⟨p.bound,p,fun i => t.inputData i,by omega,?_⟩ + intro M R hM hT hR P ht hi + refine ⟨fun i => ⟨t.inputData_indexed M hi i,?_⟩,?_⟩ + · rw [← t.inputs_eq_data] + exact t.inputs_mem M R hM hT hR P ht hi i + · intro z hz + have hf : p.Sat (M : Set ZFSet) + (cons z (tupleEnv (fun i : Fin p.bound => (t.inputData i).value R P))) ↔ + p.Sat (M : Set ZFSet) (cons z (t.inputs R P)) := by + apply p.finite_support + intro i hin + cases i with + | zero => rfl + | succ i => + simp only [cons_succ] + change tupleEnv (fun j : Fin p.bound => (t.inputData j).value R P) i = t.inputs R P i + rw [tupleEnv, dite_eq_left (show i < p.bound by omega)] + exact (t.inputs_eq_data R P i).symm + exact hf.trans (t.membershipFormula_spec M R hM hT hR P ht hi z hz) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionStageBound.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionStageBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..81d3d4dc50576c10c2d3423ea6584104ef3107fc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ConstructionStageBound.lean @@ -0,0 +1,63 @@ +import OAI.Computability.DegreeRigidity.Constructibility.SingleRealConstruction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def Construction.stageBound : Construction.{u} → Ordinal.{u} + | .reals => 0 + | .parameter => 0 + | .define o _ _ c => max o (Finset.univ.sup (fun i => (c i).stageBound)) + 1 + +theorem internal_ordinal_finite_sup (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {α : Type*} (s : Finset α) (v : α → Ordinal.{u}) + (h : ∀ i ∈ s, (v i).toZFSet ∈ M) : (s.sup v).toZFSet ∈ M := by + classical + induction s using Finset.induction_on with + | empty => simpa using internal_ordinal_zero M hM hT + | @insert a s ha ih => + rw [Finset.sup_insert] + exact internal_ordinal_max M (h a (Finset.mem_insert_self a s)) + (ih (fun i hi => h i (Finset.mem_insert_of_mem hi))) + +theorem Construction.stageBound_mem (t : Construction.{u}) (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (hi : t.Indexed M) : t.stageBound.toZFSet ∈ M := by + induction t with + | reals => exact internal_ordinal_zero M hM hT + | parameter => exact internal_ordinal_zero M hM hT + | define o n p c ih => + exact internal_ordinal_succ M hM hT _ (internal_ordinal_max M hi.1 + (internal_ordinal_finite_sup M hM hT Finset.univ _ (fun i _ => ih i (hi.2 i)))) + +theorem Construction.stageInputs_bounded (t : Construction.{u}) (R : ZFSet.{u}) : + ∀ k, t.stageInputs R k ∈ level R t.stageBound := by + have hR (o : Ordinal.{u}) : R ∈ level R o := seed_subset_stage R o.toZFSet (parameter_mem_seed R) + induction t with + | reals => exact fun _ => hR 0 + | parameter => exact fun _ => hR 0 + | define o n p c ih => + intro k + have hupper (i : Fin n) : (c i).stageBound ≤ (Construction.define o n p c).stageBound := + (Finset.le_sup (Finset.mem_univ i)).trans + ((le_max_right o _).trans (le_of_lt (lt_add_one _))) + cases k with + | zero => + exact level_mem_level R ((le_max_left o _).trans_lt (lt_add_one _)) + | succ k => + unfold Construction.stageInputs + simp only [Construction.inputData] + by_cases h : (Nat.unpair k).1 < n + · rw [dite_eq_left h] + have hchild := level_mono R (hupper ⟨(Nat.unpair k).1,h⟩) + (ih ⟨(Nat.unpair k).1,h⟩ (Nat.unpair k).2) + unfold Construction.stageInputs at hchild + cases hd : (c ⟨(Nat.unpair k).1,h⟩).inputData (Nat.unpair k).2 <;> + simpa only [hd,ConstructionInput.prefix] using hchild + · rw [dite_eq_right h] + exact hR _ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ContextDefinablePower.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ContextDefinablePower.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cd6b8c5c2d8446b5f97d375476df53e0e7364ef --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ContextDefinablePower.lean @@ -0,0 +1,139 @@ +import OAI.Computability.DegreeRigidity.Constructibility.DefSystemCertificate + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +theorem tupleSpace_mem_of_context (M A : ZFSet.{u}) (C : Context M) (hA : A ∈ M) : tupleSpace A ∈ M := by + have hS := C.separation + have hω := C.omega_mem + obtain ⟨Q,hQM,hQdef⟩ := internal_power M C.transitive C.power + (product_mem M C.transitive C.pairing C.union C.power hS hω hA) + have hQ (n : ℕ) (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) : tupleGraph v ∈ Q := by + apply (hQdef _).mpr + refine ⟨tupleGraph_mem M C.transitive C.pairing C.union hω v (fun i => C.transitive A hA _ (hv i)),?_⟩ + intro z hz + obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hz + exact ZFSet.mem_prod.mpr ⟨_,(mem_omega _).mpr ⟨i.val,rfl⟩,_,hv i,rfl⟩ + let e := cons ZFSet.omega (cons A (fun _ => Q)) + have he : ∀ i, e i ∈ M := by intro i; rcases i with _|_|i; exact hω; exact hA; exact hQM + have hs := sep_mem M C.transitive hS (tupleFormula 1 2 3 0) e he + (product_mem M C.transitive C.pairing C.union C.power hS hω hQM) + have heq : (ZFSet.prod ZFSet.omega Q).sep + (fun t => (tupleFormula 1 2 3 0).Eval (cons t e)) = tupleSpace A := by + apply ZFSet.ext; intro t + rw [ZFSet.mem_sep,tupleFormula_spec 1 2 3 0 (cons t e) rfl hQ] + change (t ∈ ZFSet.prod ZFSet.omega Q ∧ t ∈ tupleSpace A) ↔ t ∈ tupleSpace A + refine ⟨And.right,fun ht => ⟨?_,ht⟩⟩ + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp ht + exact ZFSet.mem_prod.mpr ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,tupleGraph v,hQ n v hv,rfl⟩ + exact heq ▸ hs + +theorem truthSlice_mem_of_context (M A : ZFSet.{u}) (C : Context M) (hA : A ∈ M) (p : SentenceForm) : truthSlice A p ∈ M := by + have hS := C.separation + have hω := C.omega_mem + have hn (n : ℕ) : natSet.{u} n ∈ M := C.transitive _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩) + obtain ⟨Q,hQM,hQdef⟩ := internal_power M C.transitive C.power + (product_mem M C.transitive C.pairing C.union C.power hS hω hA) + have hQ {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) : tupleGraph v ∈ Q := by + apply (hQdef _).mpr + refine ⟨tupleGraph_mem M C.transitive C.pairing C.union hω v (fun i => C.transitive A hA _ (hv i)),?_⟩ + intro z hz + obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hz + exact ZFSet.mem_prod.mpr ⟨_,(mem_omega _).mpr ⟨i.val,rfl⟩,_,hv i,rfl⟩ + let e := cons ZFSet.omega (cons A (cons Q (cons (natSet p.bound) natSet))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|i + exact hω; exact hA; exact hQM; exact hn _; exact hn _ + let φ := tupleTruth p 1 2 3 4 0 (fun i => i+5) + have hs := sep_mem M C.transitive hS φ e he (tupleSpace_mem_of_context M A C hA) + have heq : (tupleSpace A).sep (fun t => φ.Eval (cons t e)) = truthSlice A p := by + apply ZFSet.ext; intro t + rw [truthSlice,ZFSet.mem_sep,ZFSet.mem_sep] + apply and_congr_right; intro ht + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp ht + exact (tupleTruth_spec p 1 2 3 4 0 (fun i => i+5) (cons (tupleCode v) e) + rfl rfl (fun _ _ => rfl) v hv rfl (hQ v hv)).trans (satisfactionSet_record A p v hv).symm + exact heq ▸ hs + +theorem finiteSatisfaction_mem_of_context (M A : ZFSet.{u}) (C : Context M) (hA : A ∈ M) (ps : List SentenceForm) : finiteSatisfaction A ps ∈ M := by + have hω := C.omega_mem + have hn (n : ℕ) : natSet.{u} n ∈ M := C.transitive _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩) + apply union_mem M C.transitive C.union + apply finite_range_mem M C.transitive C.pairing C.union (hn 0) + intro i + exact product_mem M C.transitive C.pairing C.union C.power C.separation + (singleton_mem M C.transitive C.pairing (hn _)) (truthSlice_mem_of_context M A C hA ps[i]) + +theorem internal_certificate_bound_of_context (M A : ZFSet.{u}) (C : Context M) (hA : A ∈ M) : + ∃ Q ∈ M, + (∀ S, S ∈ Q ↔ S ∈ M ∧ S ⊆ ZFSet.prod ZFSet.omega (tupleSpace A)) ∧ + ∀ ps : List SentenceForm, finiteSatisfaction A ps ∈ Q := by + obtain ⟨Q,hQ,hdef⟩ := internal_power M C.transitive C.power + (product_mem M C.transitive C.pairing C.union C.power C.separation + (C.omega_mem) (tupleSpace_mem_of_context M A C hA)) + refine ⟨Q,hQ,hdef,fun ps => (hdef _).mpr ⟨finiteSatisfaction_mem_of_context M A C hA ps,?_⟩⟩ + exact fun z hz => satisfactionSet_subset_product A (finiteSatisfaction_subset A ps hz) + +theorem satisfactionSet_mem_of_context (M A : ZFSet.{u}) (C : Context M) (hA : A ∈ M) : satisfactionSet A ∈ M := by + obtain ⟨Q,hQ,_,hf⟩ := internal_family_bound M C.transitive C.pairing C.union C.power C.omega_mem + obtain ⟨B,hB,hb⟩ := internal_support_bound C + obtain ⟨G,hG,hg⟩ := internal_tuple_graph_bound C hA + obtain ⟨H,hH,_,hh⟩ := internal_certificate_bound_of_context M A C hA + have ht := tupleSpace_mem_of_context M A C hA + let e := cons A (cons (tupleSpace A) (fun _ => ZFSet.omega)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i + · exact hA + · exact ht + · exact C.omega_mem + have hd := satisfactionWitness_definable C hQ hB hG hH 1 2 0 + have hs := hd.sep_mem C e he (C.prod_mem C.omega_mem ht) + have heq : (ZFSet.prod ZFSet.omega (tupleSpace A)).sep + (fun z => SatisfactionWitness Q B G H A (tupleSpace A) z) = satisfactionSet A := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,satisfactionWitness_spec Q B G H A z hf hb hg (fun p => hh (subformulas p))] + exact ⟨And.right,fun hz => ⟨satisfactionSet_subset_product A hz,hz⟩⟩ + exact heq ▸ hs + +theorem definablePower_mem_of_context (M A : ZFSet.{u}) (C : Context M) (hA : A ∈ M) : definablePower A ∈ M := by + obtain ⟨Q,hQ,_,hf⟩ := internal_family_bound M C.transitive C.pairing C.union C.power C.omega_mem + obtain ⟨B,hB,hb⟩ := internal_support_bound C + obtain ⟨G,hG,hg⟩ := internal_tuple_graph_bound C hA + have ht := tupleSpace_mem_of_context M A C hA + have hz := satisfactionSet_mem_of_context M A C hA + obtain ⟨P,hP,_,hsub⟩ := definablePower_internal_bound M A C.transitive C.separation C.power hA + let e := cons A (cons (tupleSpace A) (cons (satisfactionSet A) (fun _ => ZFSet.omega))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|i + · exact hA + · exact ht + · exact hz + · exact C.omega_mem + have hd := definitionWitness_definable C hQ hB hG 1 2 3 0 + have hs := hd.sep_mem C e he hP + have heq : P.sep (fun S => DefinitionWitness Q B G A (tupleSpace A) (satisfactionSet A) S) = + definablePower A := by + apply ZFSet.ext; intro S + rw [ZFSet.mem_sep,definitionWitness_spec Q B G A S hf hb hg,← mem_definablePower] + exact ⟨And.right,fun h => ⟨hsub h,h⟩⟩ + exact heq ▸ hs + +theorem internal_defSystem_of_context (M : ZFSet.{u}) (C : Context M) + (Q B A : ZFSet.{u}) (hA : A ∈ M) + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) : + ∃ G ∈ M, ∃ T ∈ M, ∃ H ∈ M, ∃ Z ∈ M, + DefSystem Q B A G T H Z (definablePower A) := by + obtain ⟨G,hG,hg⟩ := internal_tuple_graph_bound C hA + obtain ⟨H,hH,_,hh⟩ := internal_certificate_bound_of_context M A C hA + exact ⟨G,hG,tupleSpace A,tupleSpace_mem_of_context M A C hA,H,hH, + satisfactionSet A,satisfactionSet_mem_of_context M A C hA, + defSystem_canonical Q B A G H hQ hB hg (fun p => hh (subformulas p))⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ContextHierarchyGraph.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ContextHierarchyGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e7710e6a2fbf75c2b95a875c5f28fd2a60588a9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ContextHierarchyGraph.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ContextDefinablePower +import OAI.Computability.DegreeRigidity.Constructibility.HierarchyGraph + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u +theorem definablePower_sigmaDefinable_context (M : ZFSet.{u}) (C : Context M) : + SigmaDefinable M (fun e => e 0 = definablePower (e 1)) := by + obtain ⟨Q,hQ,_,hq⟩ := internal_family_bound M C.transitive C.pairing C.union C.power C.omega_mem + obtain ⟨B,hB,hb⟩ := internal_support_bound C + have hc := (defSystem_definable C hQ hB 5 3 2 1 0 4).toSigma C.transitive + have hs := hc.existsSet.existsSet.existsSet.existsSet + apply hs.congr + intro e he + change (∃ G ∈ M, ∃ T ∈ M, ∃ H ∈ M, ∃ Z ∈ M, + DefSystem Q B (e 1) G T H Z (e 0)) ↔ e 0 = definablePower (e 1) + constructor + · rintro ⟨G,_,T,_,H,_,Z,_,h⟩ + exact h.exact hq hb + · intro h + rw [h] + exact internal_defSystem_of_context M C Q B (e 1) (he 1) hq hb + +theorem uniform_definable_successor_context (M : ZFSet.{u}) (C : Context M) : + ∃ p : SigmaFormula, ∃ d : ℕ → ZFSet.{u}, (∀ i, d i ∈ M) ∧ + ∀ A ∈ M, ∀ D ∈ M, p.Realize M (cons D (cons A d)) ↔ D = definablePower A := + (definablePower_sigmaDefinable_context M C).binary definablePower + +theorem stageImage_mem_context (M : ZFSet.{u}) (C : Context M) + {s x f : ZFSet.{u}} (hs : s ∈ M) (hx : x ∈ M) (hf : f ∈ M) : stageImage s x f ∈ M := by + have hr := iterUnion_mem M C.transitive C.union hf 2 + have hd := (((defPairMem C 1 0 4).and (member_definable C 2 0)).existsMem 4).existsMem 1 + let e := cons x (cons f (fun _ => iterUnion 2 f)) + have he : ∀ i, e i ∈ M := by intro i; rcases i with _|_|i; exact hx; exact hf; exact hr + exact binary_union_mem M C.transitive C.pairing C.union hs + (hd.sep_mem C e he (union_mem M C.transitive C.union hr)) + +theorem hierarchyGraph_of_mem_iff_context (M R d f : ZFSet.{u}) (C : Context M) + (hs : seed R ∈ M) (hdM : d ∈ M) (hfM : f ∈ M) (hd : Transitive d) + (hf : ∀ z, z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (definablePower (stage R x))) : + HierarchyGraph M (seed R) d (iterUnion 2 f) f := by + have hpair (x v : ZFSet.{u}) : ZFSet.pair x v ∈ f ↔ x ∈ d ∧ v = definablePower (stage R x) := by + rw [hf] + constructor + · rintro ⟨y,hy,he⟩ + obtain ⟨rfl,hv⟩ := ZFSet.pair_inj.mp he + exact ⟨hy,hv⟩ + · rintro ⟨hx,rfl⟩; exact ⟨x,hx,rfl⟩ + refine ⟨hd,⟨?_,?_⟩,?_⟩ + · intro z hz + obtain ⟨x,hx,rfl⟩ := (hf z).mp hz + exact ⟨x,hx,_,second_mem_doubleUnion hz,rfl⟩ + · intro x hx + have hp := (hpair x _).mpr ⟨hx,rfl⟩ + exact ⟨_,second_mem_doubleUnion hp,hp,fun v _ hv => (hpair x v).mp hv |>.2⟩ + · intro x hx v _ hv + have he := (hpair x v).mp hv |>.2 + subst v + have hA : stageImage (seed R) x f = stage R x := by + apply ZFSet.ext; intro z + rw [mem_stageImage,mem_stage] + apply or_congr_right + constructor + · rintro ⟨y,hy,w,hw,hz⟩ + rw [(hpair y w).mp hw |>.2] at hz + exact ⟨y,hy,hz⟩ + · rintro ⟨y,hy,hz⟩ + exact ⟨y,hy,_,(hpair y _).mpr ⟨hd x hx y hy,rfl⟩,hz⟩ + refine ⟨stage R x,hA ▸ stageImage_mem_context M C hs (C.transitive d hdM x hx) hfM,?_,rfl⟩ + refine ⟨seed_subset_stage R x,?_,?_⟩ + · intro z hz + rcases (mem_stage R x z).mp hz with hz|⟨y,hy,hz⟩ + · exact Or.inl hz + · have hp := (hpair y _).mpr ⟨hd x hx y hy,rfl⟩ + exact Or.inr ⟨y,hy,_,second_mem_doubleUnion hp,hp,hz⟩ + · intro y hy w _ hw + rw [(hpair y w).mp hw |>.2] + exact definablePower_subset_stage R hy + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/DecodedConstructionSyntax.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/DecodedConstructionSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1058bfc8f1b9e94edb18f263bfc17ae6ef560c5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/DecodedConstructionSyntax.lean @@ -0,0 +1,111 @@ +import OAI.Computability.DegreeRigidity.SetModels.CofinalPaddedDecoder + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel OrdinalCoding +universe u +attribute [local irreducible] Construction.ownRealsMembership SentenceForm.bound + +noncomputable def Construction.ordinalVector (t : Construction.{u}) : + Fin t.ownRealsMembership.bound → Ordinal.{u} := fun k => (t.ordinalData k).getD 0 + +theorem Construction.ordinalVector_internal (t : Construction.{u}) (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (hi : t.Indexed M) : + ∀ k, (t.ordinalVector k).toZFSet ∈ M := by + intro k + cases ho : t.ordinalData k with + | none => simpa only [Construction.ordinalVector,ho,Option.getD_none] using internal_ordinal_zero M hM hT + | some o => simpa only [Construction.ordinalVector,ho,Option.getD_some] using t.ordinalData_mem M hi k o ho + +noncomputable def Construction.decodedOrdinalInput (t : Construction.{u}) (k : ℕ) : SentenceForm := + if hk : k < t.ownRealsMembership.bound then + match t.ordinalData k with + | none => .equal 0 2 + | some _ => largestPaddedEntrySentence t.ownRealsMembership.bound ⟨k,hk⟩ + else .equal 0 2 + +noncomputable def Construction.decodedOrdinalBody (t : Construction.{u}) (q : SentenceForm) : SentenceForm := + bindComputed t.ownRealsMembership.bound t.decodedOrdinalInput + (q.rename (ordinalBodySlots t.ownRealsMembership.bound)) + +theorem bindComputed_bound (n m : ℕ) (f : ℕ → SentenceForm) (p : SentenceForm) + (hp : p.bound ≤ n+m) (hf : ∀ i < n, (f i).bound ≤ m+1) : + (bindComputed n f p).bound ≤ m := by + induction n generalizing m f with + | zero => simpa only [bindComputed,zero_add] using hp + | succ n ih => + have hinner := ih (m+1) (fun i => (f i).rename skipValue) (by omega) (by + intro i hi + apply code_rename_bound (f i) skipValue (m+2) + intro j hj + cases j with + | zero => change 0 < m+2; omega + | succ j => change j+2 < m+2; have h := hf i (by omega); omega) + have hn := hf n (by omega) + simpa only [bindComputed,SentenceForm.bound] using + (show max (f n).bound (bindComputed n (fun i => (f i).rename skipValue) p).bound - 1 ≤ m by omega) + +theorem Construction.decodedOrdinalBody_bound (t : Construction.{u}) (q : SentenceForm) : + (t.decodedOrdinalBody q).bound ≤ 2 := by + apply bindComputed_bound + · apply code_rename_bound + intro i _ + rcases i with _|_|i + · change t.ownRealsMembership.bound < t.ownRealsMembership.bound+2; omega + · change t.ownRealsMembership.bound+1 < t.ownRealsMembership.bound+2; omega + · dsimp only [ordinalBodySlots]; split <;> omega + · intro i _ + by_cases hi : i < t.ownRealsMembership.bound + · rw [Construction.decodedOrdinalInput,dite_eq_left hi] + cases t.ordinalData i with + | none => simp only [SentenceForm.bound]; omega + | some o => exact (largestPaddedEntrySentence_bound _ _).trans (by omega) + · rw [Construction.decodedOrdinalInput,dite_eq_right hi] + simp only [SentenceForm.bound]; omega + +theorem Construction.decodedOrdinalBody_spec (t : Construction.{u}) (q : SentenceForm) + (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) (P : Oracle) + (β : Ordinal.{u}) (hoff : realSeedOffset ≤ β) + (hcert : PaddedCodeCertificates + (level (groundReals M) (heightDomainIndex (paddedCode t.ordinalVector β))) t.ordinalVector β) + (he : ∀ i, t.ordinalInputs P i ∈ + level (groundReals M) (heightDomainIndex (paddedCode t.ordinalVector β))) + (z : ZFSet.{u}) : + (t.decodedOrdinalBody q).Sat + (level (groundReals M) (heightDomainIndex (paddedCode t.ordinalVector β)) : Set ZFSet) + (cons z (fun _ => realCode P)) ↔ + q.Sat (level (groundReals M) (heightDomainIndex (paddedCode t.ordinalVector β)) : Set ZFSet) + (cons z (t.ordinalInputs P)) := by + let n := t.ownRealsMembership.bound + let w := fun k => t.ordinalInputs P (k+1) + let A := level (groundReals M) (heightDomainIndex (paddedCode t.ordinalVector β)) + have hf (k : ℕ) (hk : k < n) (x : ZFSet.{u}) (hx : x ∈ A) : + (t.decodedOrdinalInput k).Sat (A : Set ZFSet) (cons x (cons z (fun _ => realCode P))) ↔ x = w k := by + have hk' : k < t.ownRealsMembership.bound := hk + rw [Construction.decodedOrdinalInput,dite_eq_left hk'] + cases ho : t.ordinalData k with + | none => simp only [SentenceForm.Sat,w,Construction.ordinalInputs,cons_succ,cons_zero,ite_eq_left hk',ho] + | some o => + have h := largestPaddedEntrySentence_of_certificates M hM hT n ⟨k,hk⟩ t.ordinalVector β hoff + (cons x (cons z (fun _ => realCode P))) hx hcert + simpa only [cons_zero,w,Construction.ordinalInputs,cons_succ,ite_eq_left hk', + Construction.ordinalVector,ho,Option.getD_some] using h + rw [Construction.decodedOrdinalBody,bindComputed_spec A n t.decodedOrdinalInput _ + (cons z (fun _ => realCode P)) w (fun i _ => he (i+1)) hf,SentenceForm.sat_rename] + have henv : (fun i => prependValues w n (cons z (fun _ => realCode P)) (ordinalBodySlots n i)) = + cons z (t.ordinalInputs P) := by + funext i + rcases i with _|_|k + · exact prependValues_tail w n _ 0 + · exact prependValues_tail w n _ 1 + · by_cases hk : k < n + · simpa only [ordinalBodySlots,ite_eq_left hk,cons_succ,w] using prependValues_lt w n _ k hk + · have hk' : ¬ k < t.ownRealsMembership.bound := hk + simp only [ordinalBodySlots,ite_eq_right hk,cons_succ,Construction.ordinalInputs,ite_eq_right hk'] + exact prependValues_tail w n _ 1 + rw [henv] + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/DefSystemCertificate.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/DefSystemCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..b751b51b359a4ece56fa7db71ebc3027130fc7d8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/DefSystemCertificate.lean @@ -0,0 +1,72 @@ +import OAI.Computability.DegreeRigidity.Syntax.SatisfactionSystemCertificate + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +def DefSystem (Q B A G T H Z D : ZFSet.{u}) : Prop := + SatisfactionSystem Q B A G T H Z ∧ + (∀ S ∈ D, DefinitionWitness Q B G A T Z S) ∧ + ∀ c ∈ ZFSet.omega, ∀ t ∈ T, ParameterAdequate Q B G c t → + ∃ S ∈ D, DefinesSubset A G T Z c t S + +theorem defSystem_definable {M : ZFSet.{u}} (C : Context M) + {Q B : ZFSet.{u}} (hQ : Q ∈ M) (hB : B ∈ M) (a G T H Z D : ℕ) : + Definable M (fun e => DefSystem Q B (e a) (e G) (e T) (e H) (e Z) (e D)) := by + have hn := defAllMem (definitionWitness_variable C hQ hB (a+1) (G+1) (T+1) (Z+1) 0) D + have hc := defAllParam (defAllMem (defImp (parameterAdequate_variable C hQ hB (G+2) 1 0) + ((definesSubset_variable C (a+3) (G+3) (T+3) (Z+3) 2 1 0).existsMem (D+2))) (T+1)) C.omega_mem + exact (satisfactionSystem_definable C hQ hB a G T H Z).and (hn.and hc) + +theorem DefSystem.exact {Q B A G T H Z D : ZFSet.{u}} + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) + (h : DefSystem Q B A G T H Z D) : D = definablePower A := by + obtain ⟨ht,hz,hg,_⟩ := h.1.exact hQ hB + subst T; subst Z + apply ZFSet.ext; intro S + rw [mem_definablePower] + constructor + · intro hS + exact (definitionWitness_spec Q B G A S hQ hB hg).mp (h.2.1 S hS) + · rintro ⟨n,p,v,hp,hv,rfl⟩ + obtain ⟨S,hS,hs⟩ := h.2.2 _ ((mem_omega _).mpr ⟨Encodable.encode p,rfl⟩) + _ ((mem_tupleSpace A _).mpr ⟨n,v,hv,rfl⟩) + ((parameterAdequate_spec Q B G _ hQ hB v (hg n v hv)).mpr ⟨p,rfl,hp⟩) + exact (definesSubset_spec A G S hg p v hv hp).mp hs ▸ hS + +theorem defSystem_canonical (Q B A G H : ZFSet.{u}) + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) + (hG : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → tupleGraph v ∈ G) + (hH : ∀ p : SentenceForm, finiteSatisfaction A (subformulas p) ∈ H) : + DefSystem Q B A G (tupleSpace A) H (satisfactionSet A) (definablePower A) := by + refine ⟨satisfactionSystem_canonical Q B A G H hQ hB hG hH,?_,?_⟩ + · intro S hS + exact (definitionWitness_spec Q B G A S hQ hB hG).mpr ((mem_definablePower A S).mp hS) + · intro c _ t ht ha + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp ht + obtain ⟨p,rfl,hp⟩ := (parameterAdequate_spec Q B G c hQ hB v (hG n v hv)).mp ha + exact ⟨definedSubset A p v,(mem_definablePower A _).mpr ⟨n,p,v,hp,hv,rfl⟩, + (definesSubset_spec A G _ hG p v hv hp).mpr rfl⟩ + +theorem internal_defSystem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (Q B A : ZFSet.{u}) (hA : A ∈ M) + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) : + ∃ G ∈ M, ∃ T ∈ M, ∃ H ∈ M, ∃ Z ∈ M, + DefSystem Q B A G T H Z (definablePower A) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + obtain ⟨G,hG,hg⟩ := internal_tuple_graph_bound C hA + obtain ⟨H,hH,_,hh⟩ := internal_certificate_bound M A hM hT hA + exact ⟨G,hG,tupleSpace A,tupleSpace_mem M A hM hT hA,H,hH, + satisfactionSet A,satisfactionSet_mem M A hM hT hA, + defSystem_canonical Q B A G H hQ hB hg (fun p => hh (subformulas p))⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/DomainParameterizedSyntax.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/DomainParameterizedSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..3389356d92140b163335409cc9ec382af6184f2b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/DomainParameterizedSyntax.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.Constructibility.HierarchyCertificatePower +import OAI.Computability.DegreeRigidity.Representation.AmbientDegreeSyntax + +namespace OAI + +namespace TuringRigidity.BoundedDefinability +open ElementaryModel BoundedSetTheory TransitiveNameModel SetModelFunctions RelativeConstructible +universe u + +def DomainDefinable (M : ZFSet.{u}) + (P : ZFSet.{u} → (ℕ → ZFSet.{u}) → Prop) : Prop := + ∃ p : SentenceForm, ∃ d : ℕ → ZFSet.{u}, ∃ k : ℕ, + (∀ i, ∃ j, j < k ∧ d i = d j) ∧ (∀ i, d i ∈ M) ∧ + ∀ N : ZFSet.{u}, Transitive N → (∀ i, d i ∈ N) → + ∀ e, (∀ i, e i ∈ N) → (p.Sat (N : Set ZFSet) (mix e d) ↔ P N e) + +variable {M : ZFSet.{u}} {P Q : ZFSet.{u} → (ℕ → ZFSet.{u}) → Prop} + +theorem Definable.toDomain {P : (ℕ → ZFSet.{u}) → Prop} (h : Definable M P) : + DomainDefinable M (fun _ e => P e) := by + obtain ⟨p,d,hd,hp⟩ := h + let b := (fromBounded p).bound + 1 + let d' : ℕ → ZFSet.{u} := fun i => d (if i < b then i else 0) + have hn (i : ℕ) : ∃ j, j < b ∧ d' i = d' j := by + by_cases hi : i < b + · exact ⟨i,hi,rfl⟩ + · exact ⟨0,by dsimp [b]; omega,by simp [d',hi,show 0 < b by dsimp [b]; omega]⟩ + have heq (e : ℕ → ZFSet.{u}) : p.Eval (mix e d') ↔ p.Eval (mix e d) := by + rw [← bounded_univ,← bounded_univ] + apply (fromBounded p).finite_support + intro i hi + unfold mix + split + · rfl + · dsimp [d'] + rw [ite_eq_left (show i / 2 < b by dsimp [b]; omega)] + refine ⟨fromBounded p,d',b,hn,fun i => hd _,?_⟩ + intro N hN hdN e he + rw [bounded_sat,Formula.absolute p N hN _ (by + intro i; unfold mix; split <;> first | exact he _ | exact hdN _)] + exact (heq e).trans (hp e) + +theorem DomainDefinable.congr (h : DomainDefinable M P) + (heq : ∀ N e, P N e ↔ Q N e) : DomainDefinable M Q := by + obtain ⟨p,d,k,hk,hd,hp⟩ := h + exact ⟨p,d,k,hk,hd,fun N hN hdN e he => (hp N hN hdN e he).trans (heq N e)⟩ + +theorem DomainDefinable.and (hP : DomainDefinable M P) (hQ : DomainDefinable M Q) : + DomainDefinable M (fun N e => P N e ∧ Q N e) := by + obtain ⟨p,d,k,hk,hd,hp⟩ := hP + obtain ⟨q,c,l,hl,hc,hq⟩ := hQ + refine ⟨.conj (p.rename (slotMap id (fun i => 2*i))) + (q.rename (slotMap id (fun i => 2*i+1))),mix d c,2 * max k l,?_,?_,?_⟩ + · intro i + by_cases hi : i % 2 = 0 + · obtain ⟨j,hj,heq⟩ := hk (i/2) + refine ⟨2*j,by omega,?_⟩ + rw [mix_even] + simpa only [mix,ite_eq_left hi] using heq + · obtain ⟨j,hj,heq⟩ := hl (i/2) + refine ⟨2*j+1,by omega,?_⟩ + rw [mix_odd] + simpa only [mix,ite_eq_right hi] using heq + · intro i; unfold mix; split <;> first | exact hd _ | exact hc _ + · intro N hN hdc e he + have hdN (i : ℕ) : d i ∈ N := by simpa only [mix_even] using hdc (2*i) + have hcN (i : ℕ) : c i ∈ N := by simpa only [mix_odd] using hdc (2*i+1) + have hd' : mix d c ∘ (fun i => 2*i) = d := by funext i; simp + have hc' : mix d c ∘ (fun i => 2*i+1) = c := by funext i; simp + change (p.rename _).Sat _ _ ∧ (q.rename _).Sat _ _ ↔ _ + simp only [SentenceForm.sat_rename] + change p.Sat _ (mix e (mix d c) ∘ slotMap id (fun i => 2*i)) ∧ + q.Sat _ (mix e (mix d c) ∘ slotMap id (fun i => 2*i+1)) ↔ _ + rw [mix_slotMap,mix_slotMap,Function.comp_id,hd',hc',hp N hN hdN e he,hq N hN hcN e he] + +theorem DomainDefinable.existsSet (h : DomainDefinable M P) : + DomainDefinable M (fun N e => ∃ x ∈ N, P N (cons x e)) := by + obtain ⟨p,d,k,hk,hd,hp⟩ := h + refine ⟨.ex (p.rename bindSlots),d,k,hk,hd,?_⟩ + intro N hN hdN e he + change (∃ x ∈ N, (p.rename bindSlots).Sat _ (cons x (mix e d))) ↔ _ + apply exists_congr; intro x + apply and_congr_right; intro hx + rw [SentenceForm.sat_rename] + change p.Sat _ (cons x (mix e d) ∘ bindSlots) ↔ _ + rw [bind_mix] + exact hp N hN hdN (cons x e) (by intro i; cases i; exact hx; exact he _) + +theorem powerBound_domainDefinable (C : Context M) (a q : ℕ) : + DomainDefinable M (fun N e => PowerBound N (e a) (e q)) := by + refine ⟨FullSetForcing.ownPower (2*a) (2*q),fun _ => ZFSet.omega,1, + fun _ => ⟨0,by decide,rfl⟩,fun _ => C.omega_mem,?_⟩ + intro N hN hd e he + rw [FullSetForcing.ownPower_spec N hN _ _ _ (by + intro i; unfold mix; split <;> first | exact he _ | exact hd 0)] + simp only [mix_even,PowerBound] + +end TuringRigidity.BoundedDefinability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/DomainSyntaxClosure.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/DomainSyntaxClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ba8e55ba6495728859e7a26ff9c6f4b0e5d9566 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/DomainSyntaxClosure.lean @@ -0,0 +1,49 @@ +import OAI.Computability.DegreeRigidity.Constructibility.DomainParameterizedSyntax + +namespace OAI + +namespace TuringRigidity.BoundedDefinability +open ElementaryModel BoundedSetTheory TransitiveNameModel SetModelFunctions +universe u +variable {M : ZFSet.{u}} {P Q : ZFSet.{u} → (ℕ → ZFSet.{u}) → Prop} + +theorem DomainDefinable.neg (h : DomainDefinable M P) : + DomainDefinable M (fun N e => ¬ P N e) := by + obtain ⟨p,d,k,hk,hd,hp⟩ := h + exact ⟨.neg p,d,k,hk,hd,fun N hN hdN e he => not_congr (hp N hN hdN e he)⟩ + +theorem DomainDefinable.imp (hP : DomainDefinable M P) (hQ : DomainDefinable M Q) : + DomainDefinable M (fun N e => P N e → Q N e) := by + apply (hP.and hQ.neg).neg.congr + intro N e + classical + tauto + +theorem DomainDefinable.subst (h : DomainDefinable M P) (r : ℕ → ℕ) : + DomainDefinable M (fun N e => P N (e ∘ r)) := by + obtain ⟨p,d,k,hk,hd,hp⟩ := h + refine ⟨p.rename (slotMap r id),d,k,hk,hd,?_⟩ + intro N hN hdN e he + rw [SentenceForm.sat_rename] + change p.Sat _ (mix e d ∘ slotMap r id) ↔ _ + rw [mix_slotMap,Function.comp_id] + exact hp N hN hdN (e ∘ r) (fun i => he (r i)) + +theorem DomainDefinable.allMem (C : Context M) (h : DomainDefinable M P) (a : ℕ) : + DomainDefinable M (fun N e => ∀ x ∈ e a, P N (cons x e)) := by + obtain ⟨p,d,k,hk,hd,hp⟩ := ((member_definable C 0 (a+1)).toDomain.and h.neg).existsSet.neg + refine ⟨p,d,k,hk,hd,?_⟩ + intro N hN hdN e he + rw [hp N hN hdN e he] + change (¬ ∃ x ∈ N, x ∈ e a ∧ ¬ P N (cons x e)) ↔ _ + classical + constructor + · intro h x hx + by_contra hn + exact h ⟨x,hN _ (he a) x hx,hx,hn⟩ + · intro h ⟨x,_,hx,hn⟩ + exact hn (h x hx) + +end TuringRigidity.BoundedDefinability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/FiniteDefinitionTransfer.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/FiniteDefinitionTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..380e3abd8a9d60f85d7969acf601546a05319d9c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/FiniteDefinitionTransfer.lean @@ -0,0 +1,42 @@ +import OAI.Computability.DegreeRigidity.Syntax.SentenceInlining + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +theorem finite_real_tail (p : SentenceForm) (D : Set ZFSet.{u}) + (z P : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + p.Sat D (cons z (cons P (tupleEnv (fun i : Fin p.bound => e i)))) ↔ + p.Sat D (cons z (cons P e)) := by + apply p.finite_support + intro i hi + rcases i with _|_|i + · rfl + · rfl + · simp only [cons_succ,tupleEnv,dite_eq_left (show i < p.bound by omega)] + +theorem definedSubset_of_membership (M V : ZFSet.{u}) (hM : Transitive M) + (hV : V ∈ M) (p : SentenceForm) (e : ℕ → ZFSet.{u}) + (hp : ∀ z ∈ M, p.Sat (M : Set ZFSet) (cons z e) ↔ z ∈ V) : + V = definedSubset M p (fun i : Fin p.bound => e i) := by + apply ZFSet.ext; intro z + rw [mem_definedSubset] + have hs := p.finite_support (M : Set ZFSet) (cons z e) + (cons z (tupleEnv (fun i : Fin p.bound => e i))) + (by + intro i hin + cases i with + | zero => rfl + | succ i => simp only [cons_succ,tupleEnv,dite_eq_left (show i < p.bound by omega)]) + constructor + · intro hz + have hzM := hM V hV z hz + exact ⟨hzM,hs.mp ((hp z hzM).mpr hz)⟩ + · rintro ⟨hzM,hz⟩ + exact (hp z hzM).mp (hs.mpr hz) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/FiniteStageDefinition.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/FiniteStageDefinition.lean new file mode 100644 index 0000000000000000000000000000000000000000..efe6e2319a98defea5527796c80a8886a91172f0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/FiniteStageDefinition.lean @@ -0,0 +1,69 @@ +import OAI.Computability.DegreeRigidity.Constructibility.SingleRealConstruction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SetModelArithmetic +universe u + +noncomputable def Construction.ordinalData (t : Construction.{u}) (k : ℕ) : Option Ordinal.{u} := + match t.inputData k with + | .stage o => some o + | _ => none + +noncomputable def stageParameter (R : ZFSet.{u}) : Option Ordinal.{u} → ZFSet.{u} + | none => R + | some o => level R o + +theorem Construction.stageInputs_eq (t : Construction.{u}) (R : ZFSet.{u}) (k : ℕ) : + t.stageInputs R k = stageParameter R (t.ordinalData k) := by + unfold Construction.stageInputs Construction.ordinalData + cases t.inputData k <;> rfl + +theorem Construction.ordinalData_mem (t : Construction.{u}) (M : ZFSet.{u}) + (hi : t.Indexed M) (k : ℕ) (o : Ordinal.{u}) (ho : t.ordinalData k = some o) : + o.toZFSet ∈ M := by + have hk := t.inputData_indexed M hi k + unfold Construction.ordinalData at ho + cases hd : t.inputData k with + | reals => simp [hd] at ho + | realPath path => simp [hd] at ho + | stage a => + rw [hd] at hk + simp only [hd] at ho + have he : a = o := Option.some.inj ho + exact he ▸ hk + +theorem Construction.finite_stage_definition (t : Construction.{u}) : + ∃ (n : ℕ) (p : SentenceForm) (o : Fin n → Option Ordinal.{u}), + p.bound ≤ n+6 ∧ + ∀ (M R : ZFSet.{u}) (_hM : Transitive M) (_hT : SourceT M) (_hR : R ∈ M) + (P : Oracle) (_hP : P ∈ modelReals M) (_ht : t.Certified R P) (_hi : t.Indexed M), + (∀ i a, o i = some a → a.toZFSet ∈ M) ∧ + (∀ i, stageParameter R (o i) ∈ M) ∧ + ∀ z ∈ M, p.Sat (M : Set ZFSet) + (cons z (cons R (cons (realCode P) (cons ZFSet.omega (cons additionSet + (cons pairNumbers (tupleEnv (fun i => stageParameter R (o i))))))))) ↔ + z ∈ t.value R P := by + let p := t.singleMembership + refine ⟨p.bound,p,fun i => t.ordinalData i,by omega,?_⟩ + intro M R hM hT hR P hP ht hi + refine ⟨fun i a ha => t.ordinalData_mem M hi i a ha,?_,?_⟩ + · intro i + rw [← t.stageInputs_eq] + exact t.stageInputs_mem M R hM hT hR hi i + · intro z hz + have hf : p.Sat (M : Set ZFSet) + (cons z (cons R (cons (realCode P) (cons ZFSet.omega (cons additionSet + (cons pairNumbers (tupleEnv (fun i : Fin p.bound => stageParameter R (t.ordinalData i))))))))) ↔ + p.Sat (M : Set ZFSet) (cons z (t.singleInputs R P)) := by + apply p.finite_support + intro i hin + rcases i with _|_|_|_|_|_|i <;> simp only [Construction.singleInputs,cons_zero,cons_succ] + rw [tupleEnv,dite_eq_left (show i < p.bound by omega)] + exact (t.stageInputs_eq R i).symm + exact hf.trans (t.singleMembership_spec M R hM hT hR P hP ht hi z hz) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/FiniteStageSetBounds.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/FiniteStageSetBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..3014baf332224fb724767e741d98540e997454fe --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/FiniteStageSetBounds.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleClosure + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel +universe u + +theorem pair_mem_level_succ (R : ZFSet.{u}) (a : Ordinal.{u}) + {x y : ZFSet.{u}} (hx : x ∈ level R a) (hy : y ∈ level R a) : + ({x,y} : ZFSet.{u}) ∈ level R (a+1) := by + rw [level_succ] + exact pair_mem_definablePower _ _ _ hx hy + +theorem orderedPair_mem_level_add_two (R : ZFSet.{u}) (a : Ordinal.{u}) + {x y : ZFSet.{u}} (hx : x ∈ level R a) (hy : y ∈ level R a) : + ZFSet.pair x y ∈ level R (a+2) := by + have hs : ({x} : ZFSet.{u}) ∈ level R (a+1) := by + simpa using pair_mem_level_succ R a hx hx + simpa only [ZFSet.pair,add_assoc,one_add_one_eq_two] using + pair_mem_level_succ R (a+1) hs (pair_mem_level_succ R a hx hy) + +theorem union_mem_level_succ (R : ZFSet.{u}) (a : Ordinal.{u}) + {x : ZFSet.{u}} (hx : x ∈ level R a) : ZFSet.sUnion x ∈ level R (a+1) := by + rw [level_succ] + exact union_mem_definablePower _ _ (level_transitive R a) hx + +theorem iterUnion_mem_level_add (R : ZFSet.{u}) (a : Ordinal.{u}) + {x : ZFSet.{u}} (hx : x ∈ level R a) (n : ℕ) : + iterUnion n x ∈ level R (a+n) := by + induction n with + | zero => simpa only [iterUnion,Nat.cast_zero,add_zero] using hx + | succ n ih => + simpa only [iterUnion,Nat.cast_add,Nat.cast_one,add_assoc] using + union_mem_level_succ R (a+n) ih + +theorem orderedPair_mem_level_limit (R : ZFSet.{u}) (a : Ordinal.{u}) + (ha : Order.IsSuccLimit a) {x y : ZFSet.{u}} + (hx : x ∈ level R a) (hy : y ∈ level R a) : ZFSet.pair x y ∈ level R a := by + obtain ⟨i,hi,hx⟩ := (mem_level_limit R x a ha).mp hx + obtain ⟨j,hj,hy⟩ := (mem_level_limit R y a ha).mp hy + have h := orderedPair_mem_level_add_two R (max i j) + (level_mono R (le_max_left i j) hx) (level_mono R (le_max_right i j) hy) + have hlt := ha.succ_lt (ha.succ_lt (max_lt hi hj)) + apply level_mono R (show max i j + 2 ≤ a from ?_) h + simpa only [Order.succ_eq_add_one,add_assoc,one_add_one_eq_two] using hlt.le + +theorem insert_mem_level_succ (R : ZFSet.{u}) (a : Ordinal.{u}) + {x y : ZFSet.{u}} (hx : x ∈ level R a) (hy : y ∈ level R a) : + insert x y ∈ level R (a+1) := by + let A := level R a + let p : ElementaryModel.SentenceForm := .disj (.equal 0 1) (.member 0 2) + let e := BoundedSetTheory.cons x (fun _ => y) + have h := separation_mem_definablePower A p e (fun i _ => by + cases i; exact hx; exact hy) + have heq : A.sep (fun z => p.Sat (A : Set ZFSet) (BoundedSetTheory.cons z e)) = insert x y := by + apply ZFSet.ext; intro z + simp only [ZFSet.mem_sep,ZFSet.mem_insert_iff,p,ElementaryModel.SentenceForm.sat_disj, + ElementaryModel.SentenceForm.Sat,e,BoundedSetTheory.cons_zero,BoundedSetTheory.cons_succ] + exact ⟨And.right,fun h => ⟨h.elim (fun h => h ▸ hx) + (fun h => level_transitive R a y hy z h),h⟩⟩ + rw [heq] at h + rwa [level_succ] + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/FixedRelativeGround.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/FixedRelativeGround.lean new file mode 100644 index 0000000000000000000000000000000000000000..25a22a9889b90e4346b3381588e62387be5f413f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/FixedRelativeGround.lean @@ -0,0 +1,30 @@ +import OAI.Computability.DegreeRigidity.SetModels.NoNewOrdinals +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModelComparison +import OAI.Computability.DegreeRigidity.Representation.SourceTGenericPersistence + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing +universe u + +theorem relativeModel_generic_fixed_parameter (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) {R c o : ZFSet.{u}} + [Preorder (Conditions c)] [OrderTop (Conditions c)] (hR : R ∈ M) + (hc : c ∈ M) (ho : o ∈ M) + (hos : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + relativeModel (genericExtensionSet M c G.carrier) R = relativeModel M R := by + obtain ⟨p,hp⟩ := G.nonempty + have ht := G.upper le_top hp + have hME := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht + apply relativeModel_eq_of_same_ordinals _ M R + (genericExtensionSet_transitive M c hM G.carrier) + (extension_sourceT M hM hT hc ho hos G hG ht) (hME hR) hM hT hR + intro δ + exact ⟨extension_ordinal_ground M c hM hT G.carrier δ,fun hδ => hME hδ⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/HierarchyCertificatePower.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/HierarchyCertificatePower.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f876bfca8cbb2218423afcae82cc02c6395665e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/HierarchyCertificatePower.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.Constructibility.DefSystemCertificate +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModelPower + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding BoundedDefinability SetModelFunctions +universe u + +def PowerBound (M a Q : ZFSet.{u}) : Prop := + ∀ x, x ∈ Q ↔ x ∈ M ∧ x ⊆ a + +def CertificateBounds (M Q B : ZFSet.{u}) : Prop := + PowerBound M ZFSet.omega Q ∧ PowerBound M (ZFSet.prod ZFSet.omega ZFSet.omega) B + +theorem PowerBound.between {M N a Q : ZFSet.{u}} (h : PowerBound M a Q) + (hN : Transitive N) (hNM : N ⊆ M) (hQ : Q ∈ N) : PowerBound N a Q := by + intro x + exact ⟨fun hx => ⟨hN Q hQ x hx,(h x).mp hx |>.2⟩, + fun hx => (h x).mpr ⟨hNM hx.1,hx.2⟩⟩ + +theorem CertificateBounds.coverage {M Q B : ZFSet.{u}} (C : Context M) + (h : CertificateBounds M Q B) : + (∀ p : SentenceForm, family p ∈ Q) ∧ (∀ p : SentenceForm, supportGraph p ∈ B) := by + exact ⟨fun p => (h.1 _).mpr ⟨family_mem M C.transitive C.pairing C.union C.omega_mem p, + family_subset_omega p⟩, + fun p => (h.2 _).mpr ⟨supportGraph_mem M C.transitive C.pairing C.union C.omega_mem p, + supportGraph_subset p⟩⟩ + +theorem CertificateBounds.between {M N Q B : ZFSet.{u}} (h : CertificateBounds M Q B) + (hN : Transitive N) (hNM : N ⊆ M) (hQ : Q ∈ N) (hB : B ∈ N) : + CertificateBounds N Q B := + ⟨h.1.between hN hNM hQ,h.2.between hN hNM hB⟩ + +theorem relative_certificate_bounds (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ∃ B ∈ relativeModel M (groundReals M), + CertificateBounds (relativeModel M (groundReals M)) (groundReals M) B ∧ + (∀ p : SentenceForm, family p ∈ groundReals M) ∧ + (∀ p : SentenceForm, supportGraph p ∈ B) := by + let R := groundReals M + let N := relativeModel M R + have hR := groundReals_mem M hM hT + let C : Context N := ⟨relativeModel_transitive M R hM, + relativeModel_pairing M R hM hT hR,relativeModel_union M R hM hT hR, + relativeModel_power_set M R hM hT hR,relativeModel_bounded_separation M R hM hT hR, + ground_relativeModel_infinity M hM hT⟩ + obtain ⟨B,hB,hb⟩ := internal_power N C.transitive C.power (C.prod_mem C.omega_mem C.omega_mem) + have hq : PowerBound N ZFSet.omega R := by + intro x + rw [mem_groundReals] + exact ⟨fun hx => ⟨(relativeModel_ground_reals M hM hT x hx.2).mpr hx.1,hx.2⟩, + fun hx => ⟨relativeModel_subset M R hx.1,hx.2⟩⟩ + have h : CertificateBounds N R B := ⟨hq,hb⟩ + exact ⟨B,hB,h,h.coverage C⟩ + +theorem certificate_bounds_at_level (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ∃ (B : ZFSet.{u}) (γ : Ordinal.{u}), γ.toZFSet ∈ M ∧ + (∀ p : SentenceForm, family p ∈ groundReals M) ∧ + (∀ p : SentenceForm, supportGraph p ∈ B) ∧ + ∀ δ : Ordinal.{u}, δ.toZFSet ∈ M → γ ≤ δ → + ZFSet.omega ∈ level (groundReals M) δ ∧ + ZFSet.prod ZFSet.omega ZFSet.omega ∈ level (groundReals M) δ ∧ + groundReals M ∈ level (groundReals M) δ ∧ B ∈ level (groundReals M) δ ∧ + CertificateBounds (level (groundReals M) δ) (groundReals M) B := by + let R := groundReals M + let N := relativeModel M R + have hR := groundReals_mem M hM hT + let C : Context N := ⟨relativeModel_transitive M R hM, + relativeModel_pairing M R hM hT hR,relativeModel_union M R hM hT hR, + relativeModel_power_set M R hM hT hR,relativeModel_bounded_separation M R hM hT hR, + ground_relativeModel_infinity M hM hT⟩ + obtain ⟨B,hB,hbounds,hq,hb⟩ := relative_certificate_bounds M hM hT + let e := cons ZFSet.omega (cons (ZFSet.prod ZFSet.omega ZFSet.omega) (cons R (fun _ => B))) + have he (i : ℕ) (_hi : i < 4) : InRelativeModel M R (e i) := by + apply (mem_relativeModel M R _ hM hT hR).mp + rcases i with _|_|_|i + · exact C.omega_mem + · exact C.prod_mem C.omega_mem C.omega_mem + · exact (mem_relativeModel M R R hM hT hR).mpr (parameter_in_relativeModel M R hM hT) + · exact hB + obtain ⟨γ,hγ,hγe⟩ := finite_parameters_in_relative_level M R hM hT e 4 he + refine ⟨B,γ,hγ,hq,hb,?_⟩ + intro δ hδ hγδ + have hin (i : ℕ) (hi : i < 4) : e i ∈ level R δ := level_mono R hγδ (hγe i hi) + have hsub : level R δ ⊆ N := fun x hx => + (mem_relativeModel M R x hM hT hR).mpr ⟨δ,hδ,hx⟩ + exact ⟨hin 0 (by decide),hin 1 (by decide),hin 2 (by decide),hin 3 (by decide), + hbounds.between (level_transitive R δ) hsub (hin 2 (by decide)) (hin 3 (by decide))⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/HierarchyGraph.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/HierarchyGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..48c68d023508ea5f4c8677e3ef016cd8cbb4ac0e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/HierarchyGraph.lean @@ -0,0 +1,130 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformDefSuccessor +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleStages +import OAI.Computability.DegreeRigidity.Syntax.CheckGraphConstruction + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +def StageStep (s f r x A : ZFSet.{u}) : Prop := + s ⊆ A ∧ + (∀ z ∈ A, z ∈ s ∨ ∃ y ∈ x, ∃ w ∈ r, ZFSet.pair y w ∈ f ∧ z ∈ w) ∧ + ∀ y ∈ x, ∀ w ∈ r, ZFSet.pair y w ∈ f → w ⊆ A + +def HierarchyGraph (M s d r f : ZFSet.{u}) : Prop := + Transitive d ∧ FunctionGraph d r f ∧ + ∀ x ∈ d, ∀ v ∈ r, ZFSet.pair x v ∈ f → + ∃ A ∈ M, StageStep s f r x A ∧ v = definablePower A + +theorem HierarchyGraph.correct {M R d r f : ZFSet.{u}} + (h : HierarchyGraph M (seed R) d r f) (x : ZFSet.{u}) (hx : x ∈ d) + (v : ZFSet.{u}) (hv : v ∈ r) (hfv : ZFSet.pair x v ∈ f) : + v = definablePower (stage R x) := by + induction x using ZFSet.inductionOn generalizing v with + | h x ih => + obtain ⟨A,_,hs,rfl⟩ := h.2.2 x hx v hv hfv + congr 1 + apply ZFSet.ext; intro z + rw [mem_stage] + constructor + · intro hz + rcases hs.2.1 z hz with hz|⟨y,hy,w,hw,hfw,hz⟩ + · exact Or.inl hz + · rw [ih y hy (h.1 x hx y hy) w hw hfw] at hz + exact Or.inr ⟨y,hy,hz⟩ + · rintro (hz|⟨y,hy,hz⟩) + · exact hs.1 hz + · obtain ⟨w,hw,hfw,_⟩ := h.2.1.2 y (h.1 x hx y hy) + rw [← ih y hy (h.1 x hx y hy) w hw hfw] at hz + exact hs.2.2 y hy w hw hfw hz + +theorem HierarchyGraph.mem_iff {M R d r f : ZFSet.{u}} + (h : HierarchyGraph M (seed R) d r f) (z : ZFSet.{u}) : + z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (definablePower (stage R x)) := by + constructor + · intro hz + obtain ⟨x,hx,v,hv,rfl⟩ := h.2.1.1 z hz + exact ⟨x,hx,by rw [h.correct x hx v hv hz]⟩ + · rintro ⟨x,hx,rfl⟩ + obtain ⟨v,hv,hfv,_⟩ := h.2.1.2 x hx + rw [← h.correct x hx v hv hfv] + exact hfv + +theorem HierarchyGraph.unique {M N R d r t f g : ZFSet.{u}} + (hf : HierarchyGraph M (seed R) d r f) (hg : HierarchyGraph N (seed R) d t g) : f = g := by + apply ZFSet.ext; intro z + exact (hf.mem_iff z).trans (hg.mem_iff z).symm + +noncomputable def stageImage (s x f : ZFSet.{u}) : ZFSet.{u} := + s ∪ (ZFSet.sUnion (iterUnion 2 f)).sep + (fun z => ∃ y ∈ x, ∃ w ∈ iterUnion 2 f, ZFSet.pair y w ∈ f ∧ z ∈ w) + +theorem mem_stageImage (s x f z : ZFSet.{u}) : + z ∈ stageImage s x f ↔ z ∈ s ∨ ∃ y ∈ x, ∃ w, ZFSet.pair y w ∈ f ∧ z ∈ w := by + rw [stageImage,ZFSet.mem_union,ZFSet.mem_sep] + apply or_congr_right + constructor + · rintro ⟨_,y,hy,w,_,hf,hz⟩; exact ⟨y,hy,w,hf,hz⟩ + · rintro ⟨y,hy,w,hf,hz⟩ + have hw := second_mem_doubleUnion hf + exact ⟨ZFSet.mem_sUnion.mpr ⟨w,hw,hz⟩,y,hy,w,hw,hf,hz⟩ + +theorem stageImage_mem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {s x f : ZFSet.{u}} (hs : s ∈ M) (hx : x ∈ M) (hf : f ∈ M) : stageImage s x f ∈ M := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + have hr := iterUnion_mem M hM hT.union hf 2 + have hd := (((defPairMem C 1 0 4).and (member_definable C 2 0)).existsMem 4).existsMem 1 + let e := cons x (cons f (fun _ => iterUnion 2 f)) + have he : ∀ i, e i ∈ M := by intro i; rcases i with _|_|i; exact hx; exact hf; exact hr + exact binary_union_mem M hM hT.pairing hT.union hs + (hd.sep_mem C e he (union_mem M hM hT.union hr)) + +theorem hierarchyGraph_of_mem_iff (M R d f : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hs : seed R ∈ M) (hdM : d ∈ M) (hfM : f ∈ M) (hd : Transitive d) + (hf : ∀ z, z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (definablePower (stage R x))) : + HierarchyGraph M (seed R) d (iterUnion 2 f) f := by + have hpair (x v : ZFSet.{u}) : ZFSet.pair x v ∈ f ↔ x ∈ d ∧ v = definablePower (stage R x) := by + rw [hf] + constructor + · rintro ⟨y,hy,he⟩ + obtain ⟨rfl,hv⟩ := ZFSet.pair_inj.mp he + exact ⟨hy,hv⟩ + · rintro ⟨hx,rfl⟩; exact ⟨x,hx,rfl⟩ + refine ⟨hd,⟨?_,?_⟩,?_⟩ + · intro z hz + obtain ⟨x,hx,rfl⟩ := (hf z).mp hz + exact ⟨x,hx,_,second_mem_doubleUnion hz,rfl⟩ + · intro x hx + have hp := (hpair x _).mpr ⟨hx,rfl⟩ + exact ⟨_,second_mem_doubleUnion hp,hp,fun v _ hv => (hpair x v).mp hv |>.2⟩ + · intro x hx v _ hv + have he := (hpair x v).mp hv |>.2 + subst v + have hA : stageImage (seed R) x f = stage R x := by + apply ZFSet.ext; intro z + rw [mem_stageImage,mem_stage] + apply or_congr_right + constructor + · rintro ⟨y,hy,w,hw,hz⟩ + rw [(hpair y w).mp hw |>.2] at hz + exact ⟨y,hy,hz⟩ + · rintro ⟨y,hy,hz⟩ + exact ⟨y,hy,_,(hpair y _).mpr ⟨hd x hx y hy,rfl⟩,hz⟩ + refine ⟨stage R x,hA ▸ stageImage_mem M hM hT hs (hM d hdM x hx) hfM,?_,rfl⟩ + refine ⟨seed_subset_stage R x,?_,?_⟩ + · intro z hz + rcases (mem_stage R x z).mp hz with hz|⟨y,hy,hz⟩ + · exact Or.inl hz + · have hp := (hpair y _).mpr ⟨hd x hx y hy,rfl⟩ + exact Or.inr ⟨y,hy,_,second_mem_doubleUnion hp,hp,hz⟩ + · intro y hy w _ hw + rw [(hpair y w).mp hw |>.2] + exact definablePower_subset_stage R hy + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/HierarchySyntax.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/HierarchySyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae564f938d02fd7727ce2d69fa52eb23069168a3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/HierarchySyntax.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DegreeRigidity.Constructibility.HierarchyGraph +import OAI.Computability.DegreeRigidity.Syntax.SigmaParameterizedClosure +import OAI.Computability.DegreeRigidity.SetModels.InternalHull + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u +variable {M : ZFSet.{u}} + +theorem stageStep_definable (C : Context M) (s f r x A : ℕ) : + Definable M (fun e => StageStep (e s) (e f) (e r) (e x) (e A)) := by + have hn := defAllMem (defOr (member_definable C 0 (s+1)) + ((((defPairMem C 1 0 (f+3)).and (member_definable C 2 0)).existsMem (r+2)).existsMem (x+1))) A + have hc := defAllMem (defAllMem (defImp (defPairMem C 1 0 (f+2)) + (defSubset C 0 (A+2))) (r+1)) x + exact (defSubset C s A).and (hn.and hc) + +theorem functionGraph_definable (C : Context M) (d r f : ℕ) : + Definable M (fun e => FunctionGraph (e d) (e r) (e f)) := by + refine ⟨.functionGraph (2*f) (2*d) (2*r),fun _ => ZFSet.omega, + fun _ => C.omega_mem,?_⟩ + intro e + simp only [Formula.eval_functionGraph,mix_even,FunctionGraph] + +theorem hierarchyGraph_sigmaDefinable (hM : Transitive M) (hT : SourceT M) (s d r f : ℕ) : + SigmaDefinable M (fun e => HierarchyGraph M (e s) (e d) (e r) (e f)) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + have hd := (defAllMem (defSubset C 0 (d+1)) d).toSigma hM + have hf := (functionGraph_definable C d r f).toSigma hM + have hv : SigmaDefinable M (fun e => e 1 = definablePower (e 0)) := + (definablePower_sigmaDefinable M hM hT).subst (fun i => if i = 0 then 1 else 0) + have hs := ((stageStep_definable C (s+3) (f+3) (r+3) 2 0).toSigma hM).and hv + have hi := SigmaDefinable.impBounded C (defPairMem C 1 0 (f+2)) hs.existsSet + exact hd.and (hf.and ((hi.allMem hM hT (r+1)).allMem hM hT d)) + +theorem sigma_binary_relation (P : ZFSet.{u} → ZFSet.{u} → Prop) + (h : SigmaDefinable M (fun e => P (e 1) (e 0))) : + ∃ p : SigmaFormula, ∃ a : ℕ → ZFSet.{u}, (∀ i, a i ∈ M) ∧ + ∀ x ∈ M, ∀ y ∈ M, p.Realize M (cons y (cons x a)) ↔ P x y := by + obtain ⟨p,a,ha,hp⟩ := h + let r : ℕ → ℕ := fun i => if i % 2 = 0 then (if i / 2 = 0 then 0 else 1) else i/2+2 + refine ⟨p.rename r,a,ha,?_⟩ + intro x hx y hy + rw [SigmaFormula.realize_rename] + have he : cons y (cons x a) ∘ r = mix (cons y (fun _ => x)) a := by + apply parity_ext + · intro n + cases n with + | zero => rfl + | succ n => simp [r,show ¬ 2 * (n+1) ≤ 1 by omega] + · intro n; simp [r,Nat.add_div] + change p.Realize M (cons y (cons x a) ∘ r) ↔ _ + rw [he] + exact hp (cons y (fun _ => x)) (by intro i; cases i; exact hy; exact hx) + +theorem uniform_hierarchy_certificate (M R d q : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hs : seed R ∈ M) (hdM : d ∈ M) (hqM : q ∈ M) + (hd : Transitive d) (hq : ∀ c, c ∈ q ↔ c ∈ M ∧ c ⊆ d) : + ∃ p : SigmaFormula, ∃ a : ℕ → ZFSet.{u}, (∀ i, a i ∈ M) ∧ + ∀ x ∈ d, ∀ f ∈ M, p.Realize M (cons f (cons x a)) ↔ + ∃ r ∈ M, HierarchyGraph M (seed R) (hull d q x) r f := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + have hh : Definable M (fun e => e 1 ∈ q ∧ Transitive (e 1) ∧ e 3 ∈ e 1 ∧ + ∀ b ∈ q, Transitive b → e 3 ∈ b → e 1 ⊆ b) := by + refine ⟨.isHull 2 6 1 3,cons d (fun _ => q),?_,?_⟩ + · intro i; cases i; exact hdM; exact hqM + · intro e + simp [Formula.eval_isHull,mix,cons] + have hg : SigmaDefinable M (fun e => HierarchyGraph M (seed R) (e 1) (e 0) (e 2)) := by + have h := hierarchyGraph_sigmaDefinable hM hT 0 2 1 3 + have eq := (equal_param hs 0).toSigma hM + + have hx := (eq.and h).existsSet + exact hx.congr (fun e _ => by simp [hs]) + have hc := (hh.toSigma hM).and hg + obtain ⟨p,a,ha,hp⟩ := sigma_binary_relation (fun x f => + ∃ c ∈ M, ∃ r ∈ M, (c ∈ q ∧ Transitive c ∧ x ∈ c ∧ + ∀ b ∈ q, Transitive b → x ∈ b → c ⊆ b) ∧ HierarchyGraph M (seed R) c r f) + hc.existsSet.existsSet + refine ⟨p,a,ha,?_⟩ + intro x hx f hf + rw [hp x (hM d hdM x hx) f hf] + constructor + · rintro ⟨c,hc,r,hr,hh,hg⟩ + have he := (isHull_iff M d q hM C.separation hdM hqM hd hq hx hc).mp hh + subst c + exact ⟨r,hr,hg⟩ + · rintro ⟨r,hr,hg⟩ + have hc := hull_mem M d q hM C.separation hdM hqM (hM d hdM x hx) + exact ⟨_,hc,r,hr,(isHull_iff M d q hM C.separation hdM hqM hd hq hx hc).mpr rfl,hg⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/HierarchyWitnessCollection.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/HierarchyWitnessCollection.lean new file mode 100644 index 0000000000000000000000000000000000000000..21a8dbd19c6ed0d7e020a695f578a039b48fdbd3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/HierarchyWitnessCollection.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeHierarchyInternal + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +def HierarchyRequest (Q B s f r x c : ZFSet.{u}) : Prop := + ∃ A ∈ c, ∃ v ∈ r, ∃ G ∈ c, ∃ T ∈ c, ∃ H ∈ c, ∃ Z ∈ c, + ZFSet.pair x v ∈ f ∧ StageStep s f r x A ∧ DefSystem Q B A G T H Z v + +theorem hierarchyRequest_definable {M Q B : ZFSet.{u}} (C : Context M) + (hQ : Q ∈ M) (hB : B ∈ M) (s f r x c : ℕ) : + Definable M (fun e => HierarchyRequest Q B (e s) (e f) (e r) (e x) (e c)) := by + have h := (defPairMem C (x+6) 4 (f+6)).and + ((stageStep_definable C (s+6) (f+6) (r+6) (x+6) 5).and + (defSystem_definable C hQ hB 5 3 2 1 0 4)) + exact (((((h.existsMem (c+5)).existsMem (c+4)).existsMem (c+3)).existsMem (c+2)).existsMem (r+1)).existsMem c + +theorem hierarchyRequest_binary {M Q B s f r : ZFSet.{u}} (C : Context M) + (hQ : Q ∈ M) (hB : B ∈ M) (hs : s ∈ M) (hf : f ∈ M) (hr : r ∈ M) : + ∃ p : SigmaFormula, ∃ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ M) ∧ + ∀ x ∈ M, ∀ c ∈ M, p.Realize M (cons c (cons x e)) ↔ + HierarchyRequest Q B s f r x c := by + have h := (hierarchyRequest_definable C hQ hB 2 1 0 4 3).toSigma C.transitive + have eq := ((equal_param hr 0).and ((equal_param hf 1).and (equal_param hs 2))).toSigma C.transitive + have hc := (eq.and h).existsSet.existsSet.existsSet + apply sigma_binary_relation _ (hc.congr ?_) + intro e _ + simp only [cons_zero,cons_succ] + constructor + · rintro ⟨s',_,f',_,r',_,⟨rfl,rfl,rfl⟩,h⟩ + exact h + · intro h + exact ⟨s,hs,f,hf,r,hr,⟨rfl,rfl,rfl⟩,h⟩ + +theorem hierarchy_witness_collection {M Q B s d r f : ZFSet.{u}} (C : Context M) + (hColl : SigmaCollection M) (hQ : Q ∈ M) (hB : B ∈ M) + (hq : ∀ p : SentenceForm, family p ∈ Q) + (hb : ∀ p : SentenceForm, supportGraph p ∈ B) + (hs : s ∈ M) (hd : d ∈ M) (hr : r ∈ M) (hf : f ∈ M) + (hg : HierarchyGraph M s d r f) : + ∃ W ∈ M, ∀ x ∈ d, ∃ c ∈ W, HierarchyRequest Q B s f r x c := by + obtain ⟨p,e,he,hp⟩ := hierarchyRequest_binary C hQ hB hs hf hr + obtain ⟨W,hW,hw⟩ := hColl p e he d hd (by + intro x hx + obtain ⟨v,hv,hfv,_⟩ := hg.2.1.2 x hx + obtain ⟨A,hA,hstep,hvA⟩ := hg.2.2 x hx v hv hfv + obtain ⟨G,hG,T,hT,H,hH,Z,hZ,hdef⟩ := internal_defSystem_of_context M C Q B A hA hq hb + let a : Fin 5 → ZFSet.{u} := fun i => match i.val with + | 0 => A | 1 => G | 2 => T | 3 => H | _ => Z + have ha : ∀ i, a i ∈ M := by + intro i; dsimp [a]; split <;> assumption + have hc := finite_range_mem M C.transitive C.pairing C.union (C.nat_mem 0) 5 a ha + refine ⟨ZFSet.range a,hc,(hp x (C.transitive d hd x hx) _ hc).mpr ?_⟩ + refine ⟨A,ZFSet.mem_range.mpr ⟨⟨0,by decide⟩,rfl⟩,v,hv, + G,ZFSet.mem_range.mpr ⟨⟨1,by decide⟩,rfl⟩, + T,ZFSet.mem_range.mpr ⟨⟨2,by decide⟩,rfl⟩, + H,ZFSet.mem_range.mpr ⟨⟨3,by decide⟩,rfl⟩, + Z,ZFSet.mem_range.mpr ⟨⟨4,by decide⟩,rfl⟩,hfv,hstep,?_⟩ + rwa [hvA]) + exact ⟨W,hW,fun x hx => by + obtain ⟨c,hc,h⟩ := hw x hx + exact ⟨c,hc,(hp x (C.transitive d hd x hx) c (C.transitive W hW c hc)).mp h⟩⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalConstructibleHierarchy.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalConstructibleHierarchy.lean new file mode 100644 index 0000000000000000000000000000000000000000..053cd7e8d18e8b523971bd5914b6be51f422110d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalConstructibleHierarchy.lean @@ -0,0 +1,72 @@ +import OAI.Computability.DegreeRigidity.Constructibility.InternalHierarchyRecursion +import OAI.Computability.DegreeRigidity.SetModels.InternalContainer +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleGroundReals + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +theorem seed_mem (M R : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) (hR : R ∈ M) : + seed R ∈ M := by + obtain ⟨b,hb,hdef⟩ := collect_unionIterates M hM hT.pairing hT.union + hT.replacement.finitePrefix (sourceT_omega_mem M hM hT) + (singleton_mem M hM hT.pairing hR) + have he : ZFSet.sUnion b = seed R := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sUnion,mem_seed] + constructor + · rintro ⟨a,ha,hz⟩ + obtain ⟨n,rfl⟩ := (hdef a).mp ha + exact ⟨n,hz⟩ + · rintro ⟨n,hz⟩ + exact ⟨_,(hdef _).mpr ⟨n,rfl⟩,hz⟩ + exact he ▸ union_mem M hM hT.union hb + +theorem internal_hierarchy_cover (M R o : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hR : R ∈ M) (ho : o ∈ M) : + ∃ d ∈ M, ∃ f ∈ M, o ∈ d ∧ + HierarchyGraph M (seed R) d (iterUnion 2 f) f := by + obtain ⟨c,hc,hct,hoc⟩ := internal_transitive_container M hM hT.pairing hT.union + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity ho + obtain ⟨q,hq,hqdef⟩ := internal_power M hM hT.powerSet hc + obtain ⟨f,hf,hfg⟩ := internal_hierarchyGraph M R c q hM hT (seed_mem M R hM hT hR) + hc hq hct hqdef o hoc + exact ⟨hull c q o,hull_mem M c q hM hT.separation.finitePrefix.bounded hc hq ho, + f,hf,self_mem_hull c q hoc,hfg⟩ + +theorem stage_mem (M R o : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hR : R ∈ M) (ho : o ∈ M) : stage R o ∈ M := by + obtain ⟨d,_,f,hf,hod,hfg⟩ := internal_hierarchy_cover M R o hM hT hR ho + obtain ⟨v,hv,hfv,_⟩ := hfg.2.1.2 o hod + have hvM : v ∈ M := hM _ (iterUnion_mem M hM hT.union hf 2) v hv + rw [hfg.correct o hod v hv hfv] at hvM + exact hM _ hvM _ (self_mem_definablePower (stage R o)) + +theorem level_mem (M R : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hR : R ∈ M) (o : Ordinal.{u}) (ho : o.toZFSet ∈ M) : level R o ∈ M := + stage_mem M R o.toZFSet hM hT hR ho + +theorem level_subset_model (M R : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hR : R ∈ M) (o : Ordinal.{u}) (ho : o.toZFSet ∈ M) : level R o ⊆ M := + fun x hx => hM _ (level_mem M R hM hT hR o ho) x hx + +theorem internally_indexed_ground_reals (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (x : ZFSet.{u}) (hx : x ⊆ ZFSet.omega) : + (∃ o : Ordinal.{u}, o.toZFSet ∈ M ∧ x ∈ level (groundReals M) o) ↔ x ∈ M := by + constructor + · rintro ⟨o,ho,hxl⟩ + exact level_subset_model M (groundReals M) hM hT (groundReals_mem M hM hT) o ho hxl + · intro hxM + have hω := sourceT_omega_mem M hM hT + refine ⟨0,?_,?_⟩ + · simpa only [Ordinal.toZFSet_zero] using hM _ hω _ ZFSet.omega_zero + · rw [level_zero] + exact parameter_subset_seed (groundReals M) ((mem_groundReals M x).mpr ⟨hxM,hx⟩) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalHeightDomains.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalHeightDomains.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b78fd1794951fbe1d1730a15396fabb007980b7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalHeightDomains.lean @@ -0,0 +1,57 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.LargestOrdinalSyntax + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +theorem ordinalCut_mem_model (M A : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hA : A ∈ M) : ordinalCut A ∈ M := by + have hs := sep_mem M hM hS (ordinalFormula 0) (fun _ => A) (fun _ => hA) hA + have heq : A.sep (fun x => (ordinalFormula 0).Eval (cons x (fun _ => A))) = ordinalCut A := by + apply ZFSet.ext; intro x + simp only [ZFSet.mem_sep,mem_ordinalCut,eval_ordinalFormula,cons_zero] + exact heq ▸ hs + +theorem ordinalHeight_mem_model (M A : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hA : A ∈ M) (hAt : Transitive A) : + (ordinalHeight A).toZFSet ∈ M := by + rw [ordinalHeight_toZFSet A hAt] + exact ordinalCut_mem_model M A hM hS hA + +theorem internal_ordinal_downward (M : ZFSet.{u}) (hM : Transitive M) + {a b : Ordinal.{u}} (hb : b.toZFSet ∈ M) (hab : a ≤ b) : a.toZFSet ∈ M := by + rcases lt_or_eq_of_le hab with h|rfl + · exact hM _ hb _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr h) + · exact hb + +theorem internal_difference_successor (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (a b : Ordinal.{u}) (ha : a.toZFSet ∈ M) : + (a-b+1).toZFSet ∈ M := + internal_ordinal_succ M hM hT _ + (internal_ordinal_downward M hM ha (Ordinal.sub_le_self a b)) + +theorem internal_domains_with_largest_ordinal (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) (γ : Ordinal.{u}) (hγ : γ.toZFSet ∈ M) : + ∃ β : Ordinal.{u}, β.toZFSet ∈ M ∧ ∀ a : Ordinal.{u}, a.toZFSet ∈ M → β ≤ a → + let δ := a - ordinalHeight (seed R) + 1 + δ.toZFSet ∈ M ∧ γ ≤ δ ∧ a.toZFSet ∈ level R δ ∧ + ∀ e : ℕ → ZFSet.{u}, e 0 ∈ level R δ → + (largestOrdinalSentence.Sat (level R δ : Set ZFSet) e ↔ e 0 = a.toZFSet) := by + refine ⟨ordinalHeight (level R γ),ordinalHeight_mem_model M _ hM + hT.separation.finitePrefix.bounded (level_mem M R hM hT hR γ hγ) (level_transitive R γ),?_⟩ + intro a ha hle + rw [ordinalHeight_level] at hle + have hoff : ordinalHeight (seed R) ≤ a := (show ordinalHeight (seed R) ≤ ordinalHeight (seed R) + γ from le_self_add).trans hle + have hγδ : γ ≤ a - ordinalHeight (seed R) + 1 := + (Ordinal.le_sub_of_add_le hle).trans (le_of_lt (lt_add_one _)) + have hm := largest_ordinal_at_difference R a hoff + refine ⟨internal_difference_successor M hM hT a _ ha,hγδ,hm.1,?_⟩ + intro e he + exact largestOrdinalSentence_unique _ (level_transitive R _) a hm.1 + (fun b hb => (hm.2 b).mp hb) e he + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalHierarchyRecursion.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalHierarchyRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8069ecce5da5ad03366e0a372fd907c6b1528ff --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalHierarchyRecursion.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.Constructibility.HierarchySyntax + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +theorem internal_hierarchyGraph (M R d q : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hs : seed R ∈ M) (hdM : d ∈ M) (hqM : q ∈ M) (hd : Transitive d) + (hq : ∀ c, c ∈ q ↔ c ∈ M ∧ c ⊆ d) (x : ZFSet.{u}) (hx : x ∈ d) : + ∃ f ∈ M, HierarchyGraph M (seed R) (hull d q x) (iterUnion 2 f) f := by + let hP := hT.pairing + let hU := hT.union + let hS := hT.separation.finitePrefix.bounded + let hR := hT.replacement.finitePrefix + obtain ⟨p,e,he,hp⟩ := uniform_hierarchy_certificate M R d q hM hT hs hdM hqM hd hq + induction x using ZFSet.inductionOn with + | h x ih => + have hxM := hM d hdM x hx + have cert (y f : ZFSet.{u}) (hy : y ∈ x) (hf : f ∈ M) : + p.Realize M (cons f (cons y e)) ↔ + ∃ r ∈ M, HierarchyGraph M (seed R) (hull d q y) r f := + hp y (hd x hx y hy) f hf + obtain ⟨b,hb,hbdef⟩ := hR p e he x hxM (by + intro y hy + obtain ⟨f,hf,hfg⟩ := ih y hy (hd x hx y hy) + refine ⟨f,hf,(cert y f hy hf).mpr + ⟨_,iterUnion_mem M hM hU hf 2,hfg⟩,?_⟩ + intro g hg hcg + obtain ⟨r,_,hgg⟩ := (cert y g hy hg).mp hcg + exact hgg.unique hfg) + have hbg (f : ZFSet.{u}) : f ∈ b ↔ + ∃ y ∈ x, ∃ r ∈ M, HierarchyGraph M (seed R) (hull d q y) r f := by + constructor + · intro hf + have hfM := hM b hb f hf + obtain ⟨y,hy,hc⟩ := (hbdef f hfM).mp hf + exact ⟨y,hy,(cert y f hy hfM).mp hc⟩ + · rintro ⟨y,hy,r,hr,hg⟩ + obtain ⟨f',hf',hg'⟩ := ih y hy (hd x hx y hy) + have heq := hg.unique hg' + have hfM : f ∈ M := heq ▸ hf' + exact (hbdef f hfM).mpr ⟨y,hy,(cert y f hy hfM).mpr ⟨r,hr,hg⟩⟩ + let g := ZFSet.sUnion b + have hgM : g ∈ M := union_mem M hM hU hb + have hg (z : ZFSet.{u}) : z ∈ g ↔ + ∃ y ∈ x, ∃ w ∈ hull d q y, z = ZFSet.pair w (definablePower (stage R w)) := by + constructor + · intro hz + obtain ⟨f,hf,hzf⟩ := ZFSet.mem_sUnion.mp hz + obtain ⟨y,hy,r,_,hfg⟩ := (hbg f).mp hf + exact ⟨y,hy,(hfg.mem_iff z).mp hzf⟩ + · rintro ⟨y,hy,w,hw,hz⟩ + obtain ⟨f,hf,hfg⟩ := ih y hy (hd x hx y hy) + exact ZFSet.mem_sUnion.mpr ⟨f,(hbg f).mpr + ⟨y,hy,_,iterUnion_mem M hM hU hf 2,hfg⟩,(hfg.mem_iff z).mpr ⟨w,hw,hz⟩⟩ + have hvalue : stageImage (seed R) x g = stage R x := by + apply ZFSet.ext; intro z + rw [mem_stageImage,mem_stage] + apply or_congr_right + constructor + · rintro ⟨y,hy,w,hw,hz⟩ + obtain ⟨a,_,v,_,hp⟩ := (hg _).mp hw + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact ⟨y,hy,hz⟩ + · rintro ⟨y,hy,hz⟩ + exact ⟨y,hy,_,(hg _).mpr + ⟨y,hy,y,self_mem_hull d q (hd x hx y hy),rfl⟩,hz⟩ + have hvM : definablePower (stage R x) ∈ M := definablePower_mem M _ hM hT + (hvalue ▸ stageImage_mem M hM hT hs hxM hgM) + let f := g ∪ ({ZFSet.pair x (definablePower (stage R x))} : ZFSet.{u}) + have hfM : f ∈ M := binary_union_mem M hM hP hU hgM + (singleton_mem M hM hP (orderedPair_mem M hM hP hxM hvM)) + refine ⟨f,hfM,hierarchyGraph_of_mem_iff M R _ f hM hT hs + (hull_mem M d q hM hS hdM hqM hxM) hfM (hull_transitive d q x hd) ?_⟩ + intro z + change z ∈ g ∪ ({ZFSet.pair x (definablePower (stage R x))} : ZFSet.{u}) ↔ _ + rw [ZFSet.mem_union,ZFSet.mem_singleton,hg] + constructor + · rintro (⟨y,hy,w,hw,hz⟩|hz) + · exact ⟨w,(hull_unfold M d q hM hP hU hS hR hdM hqM hd hq hx w).mpr + (Or.inr ⟨y,hy,hw⟩),hz⟩ + · exact ⟨x,self_mem_hull d q hx,hz⟩ + · rintro ⟨w,hw,hz⟩ + rcases (hull_unfold M d q hM hP hU hS hR hdM hqM hd hq hx w).mp hw with rfl|⟨y,hy,hw⟩ + · exact Or.inr hz + · exact Or.inl ⟨y,hy,w,hw,hz⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalOmegaFixedPoint.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalOmegaFixedPoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8cf38ba2039d922133834d6ed280f3be4c940e6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalOmegaFixedPoint.lean @@ -0,0 +1,57 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalSigmaSequence +import Mathlib.SetTheory.Ordinal.FixedPoint + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory BoundedDefinability RelationCollapse ElementaryModel RelativeConstructible +universe u + +theorem omega_fixed_point_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (θ : Ordinal.{u}) (hθ : θ.toZFSet ∈ M) : + (Ordinal.nfp (fun a : Ordinal.{u} => Ordinal.omega0 ^ a) θ).toZFSet ∈ M := by + let F : Ordinal.{u} → Ordinal.{u} := fun a => Ordinal.omega0 ^ a + let s : ℕ → ZFSet.{u} := fun n => (F^[n] θ).toZFSet + let S : ZFSet.{u} → ZFSet.{u} → Prop := fun x y => + x.IsOrdinal ∧ y = (Ordinal.omega0 ^ x.rank).toZFSet + have hs (n : ℕ) : s n ∈ M := by + induction n with + | zero => exact hθ + | succ n ih => + simpa only [s,Function.iterate_succ_apply',F] using + ordinal_omega_opow_internal M hM hT (F^[n] θ) ih + have hstep (n : ℕ) : S (s n) (s (n+1)) := by + refine ⟨ZFSet.isOrdinal_toZFSet _,?_⟩ + simp only [s,Function.iterate_succ_apply',F,Ordinal.rank_toZFSet] + have hu (n : ℕ) (y : ZFSet.{u}) (h : S (s n) y) : y = s (n+1) := by + simpa only [s,Function.iterate_succ_apply',F,Ordinal.rank_toZFSet] using h.2 + obtain ⟨B,hB,hdef⟩ := sigma_sequence_range_internal M hM hT S + (omegaPower_sigmaDefinable M hM hT) s hs hstep hu + have heq : (Ordinal.nfp F θ).toZFSet = ZFSet.sUnion B := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sUnion] + constructor + · intro hz + obtain ⟨a,ha,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hz + obtain ⟨n,hn⟩ := Ordinal.lt_nfp_iff.mp ha + exact ⟨s n,(hdef _).mpr ⟨n,rfl⟩,Ordinal.toZFSet_mem_toZFSet_iff.mpr hn⟩ + · rintro ⟨t,ht,hz⟩ + obtain ⟨n,rfl⟩ := (hdef t).mp ht + exact Ordinal.toZFSet_monotone (Ordinal.iterate_le_nfp F θ n) hz + rw [heq] + exact union_mem M hM hT.union hB + +theorem cofinal_internal_omega_fixed_points (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (θ : Ordinal.{u}) (hθ : θ.toZFSet ∈ M) : + ∃ β : Ordinal.{u}, β.toZFSet ∈ M ∧ θ < β ∧ Order.IsSuccLimit β ∧ Ordinal.omega0 ^ β = β := by + let F : Ordinal.{u} → Ordinal.{u} := fun a => Ordinal.omega0 ^ a + let β := Ordinal.nfp F (θ+1) + have hb : θ < β := (lt_add_one θ).trans_le (Ordinal.le_nfp F (θ+1)) + have hfix : Ordinal.omega0 ^ β = β := Ordinal.nfp_fp (Ordinal.isNormal_opow Ordinal.one_lt_omega0) (θ+1) + refine ⟨β,omega_fixed_point_internal M hM hT (θ+1) (internal_ordinal_succ M hM hT θ hθ),hb,?_,hfix⟩ + rw [← hfix] + exact Ordinal.isSuccLimit_opow_left Ordinal.isSuccLimit_omega0 (ne_of_gt (lt_of_le_of_lt zero_le hb)) + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalOmegaPower.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalOmegaPower.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc9821219929c0ec69766c90dfa4b5e86f4d91bf --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalOmegaPower.lean @@ -0,0 +1,105 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaPowerGraph + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open BoundedDefinability SetModelFunctions +universe u + +theorem internal_omegaGraph (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (x : ZFSet.{u}) (hxM : x ∈ M) (hxo : x.IsOrdinal) : + ∃ f ∈ M, OmegaGraph M (insert x x) (iterUnion 2 f) f := by + have h1 : (1 : Ordinal.{u}).toZFSet ∈ M := by + rw [← Nat.cast_one,toZFSet_nat] + exact hM _ (omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity) _ ((mem_omega _).mpr ⟨1,rfl⟩) + obtain ⟨p,e,he,hp⟩ := uniform_omega_certificate M hM hT + induction x using ZFSet.inductionOn with + | h x ih => + have cert (y f : ZFSet.{u}) (hy : y ∈ x) (hf : f ∈ M) := hp y (hM x hxM y hy) f hf + obtain ⟨b,hb,hbdef⟩ := hT.replacement.finitePrefix p e he x hxM (by + intro y hy + obtain ⟨f,hf,hfg⟩ := ih y hy (hM x hxM y hy) (hxo.mem hy) + refine ⟨f,hf,(cert y f hy hf).mpr + ⟨_,iterUnion_mem M hM hT.union hf 2,hfg⟩,?_⟩ + intro g hg hcg + obtain ⟨r,_,hgg⟩ := (cert y g hy hg).mp hcg + exact hgg.unique hfg) + have hbg (f : ZFSet.{u}) : f ∈ b ↔ + ∃ y ∈ x, ∃ r ∈ M, OmegaGraph M (insert y y) r f := by + constructor + · intro hf + have hfM := hM b hb f hf + obtain ⟨y,hy,hc⟩ := (hbdef f hfM).mp hf + exact ⟨y,hy,(cert y f hy hfM).mp hc⟩ + · rintro ⟨y,hy,r,hr,hg⟩ + obtain ⟨f',hf',hg'⟩ := ih y hy (hM x hxM y hy) (hxo.mem hy) + have heq := hg.unique hg' + have hfM : f ∈ M := heq ▸ hf' + exact (hbdef f hfM).mpr ⟨y,hy,(cert y f hy hfM).mpr ⟨r,hr,hg⟩⟩ + let g := ZFSet.sUnion b + have hgM : g ∈ M := union_mem M hM hT.union hb + have hg (z : ZFSet.{u}) : z ∈ g ↔ ∃ y ∈ x, z = ZFSet.pair y (omegaNext y) := by + constructor + · intro hz + obtain ⟨f,hf,hzf⟩ := ZFSet.mem_sUnion.mp hz + obtain ⟨y,hy,r,_,hfg⟩ := (hbg f).mp hf + obtain ⟨w,hw,hz⟩ := (hfg.mem_iff z).mp hzf + rcases ZFSet.mem_insert_iff.mp hw with rfl|hw + · exact ⟨w,hy,hz⟩ + · exact ⟨w,hxo.subset_of_mem hy hw,hz⟩ + · rintro ⟨y,hy,hz⟩ + obtain ⟨f,hf,hfg⟩ := ih y hy (hM x hxM y hy) (hxo.mem hy) + exact ZFSet.mem_sUnion.mpr ⟨f,(hbg f).mpr + ⟨y,hy,_,iterUnion_mem M hM hT.union hf 2,hfg⟩, + (hfg.mem_iff z).mpr ⟨y,ZFSet.mem_insert_iff.mpr (Or.inl rfl),hz⟩⟩ + have hvalue : stageImage (1 : Ordinal.{u}).toZFSet x g = + (Ordinal.omega0 ^ x.rank).toZFSet := by + apply ZFSet.ext; intro z + rw [mem_stageImage,omegaPower_members,hxo.toZFSet_rank_eq] + apply or_congr_right + constructor + · rintro ⟨y,hy,w,hfw,hz⟩ + obtain ⟨v,_,hp⟩ := (hg _).mp hfw + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact ⟨y,hy,hz⟩ + · rintro ⟨y,hy,hz⟩ + exact ⟨y,hy,_,(hg _).mpr ⟨y,hy,rfl⟩,hz⟩ + have hpow : (Ordinal.omega0 ^ x.rank).toZFSet ∈ M := + hvalue ▸ stageImage_mem M hM hT h1 hxM hgM + have hvM : omegaNext x ∈ M := by + rw [omegaNext,Ordinal.opow_add_one] + exact ordinal_mul_omega_internal M hM hT _ hpow + let f := g ∪ ({ZFSet.pair x (omegaNext x)} : ZFSet.{u}) + have hfM : f ∈ M := binary_union_mem M hM hT.pairing hT.union hgM + (singleton_mem M hM hT.pairing (orderedPair_mem M hM hT.pairing hxM hvM)) + have hsucc : (insert x x).IsOrdinal := by + rw [← hxo.toZFSet_rank_eq,← Ordinal.toZFSet_add_one] + exact ZFSet.isOrdinal_toZFSet _ + refine ⟨f,hfM,omegaGraph_of_mem_iff M _ f hM hT + (insert_self_mem M hM hT.pairing hT.union hxM) hfM hsucc ?_⟩ + intro z + change z ∈ g ∪ ({ZFSet.pair x (omegaNext x)} : ZFSet.{u}) ↔ _ + rw [ZFSet.mem_union,ZFSet.mem_singleton,hg] + constructor + · rintro (⟨y,hy,hz⟩|hz) + · exact ⟨y,ZFSet.mem_insert_of_mem _ hy,hz⟩ + · exact ⟨x,ZFSet.mem_insert_iff.mpr (Or.inl rfl),hz⟩ + · rintro ⟨y,hy,hz⟩ + rcases ZFSet.mem_insert_iff.mp hy with rfl|hy + · exact Or.inr hz + · exact Or.inl ⟨y,hy,hz⟩ + +theorem ordinal_omega_opow_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) : (Ordinal.omega0 ^ a).toZFSet ∈ M := by + obtain ⟨f,hf,hg⟩ := internal_omegaGraph M hM hT a.toZFSet ha (ZFSet.isOrdinal_toZFSet a) + have h1 : (1 : Ordinal.{u}).toZFSet ∈ M := by + rw [← Nat.cast_one,toZFSet_nat] + exact hM _ (omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity) _ ((mem_omega _).mpr ⟨1,rfl⟩) + have hv := omegaStageImage _ f a.toZFSet hg.1 (ZFSet.mem_insert_iff.mpr (Or.inl rfl)) hg.mem_iff + rw [Ordinal.rank_toZFSet] at hv + exact hv ▸ stageImage_mem M hM hT h1 ha hf + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalRankRecursion.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalRankRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..029f1bc7a5a189546353ed4e9352123e8630d3e0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/InternalRankRecursion.lean @@ -0,0 +1,144 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalHull +import OAI.Computability.DegreeRigidity.OrdinalCodes.RankGraphConstruction + +namespace OAI + + +namespace TuringRigidity.InternalRank +open TransitiveNameModel BoundedSetTheory +universe u + +def rankCertificate : SigmaFormula := .existsSet (.existsSet (.bounded + (.conj (.isHull 1 3 4 5) (Code.graph 1 0 2)))) + +theorem realize_rankCertificate (M d q : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hdM : d ∈ M) (hqM : q ∈ M) + (hd : Transitive d) (hq : ∀ c, c ∈ q ↔ c ∈ M ∧ c ⊆ d) + {x f : ZFSet.{u}} (hx : x ∈ d) (hf : f ∈ M) : + rankCertificate.Realize M (cons f (cons x (cons d (cons q (fun _ => d))))) ↔ + ∃ r ∈ M, Graph (hull d q x) r f := by + have hxM := hM d hdM x hx + have matrix (c r : ZFSet.{u}) (hc : c ∈ M) (hr : r ∈ M) : + (Formula.conj (.isHull 1 3 4 5) (Code.graph 1 0 2)).Realize M + (cons r (cons c (cons f (cons x (cons d (cons q (fun _ => d))))))) ↔ + c = hull d q x ∧ Graph c r f := by + have he : ∀ i, (cons r (cons c (cons f (cons x + (cons d (cons q (fun _ => d))))))) i ∈ M := by + intro i + rcases i with _|i; exact hr + rcases i with _|i; exact hc + rcases i with _|i; exact hf + rcases i with _|i; exact hxM + rcases i with _|i; exact hdM + rcases i with _|i; exact hqM + exact hdM + rw [Formula.absolute _ M hM _ he] + simp only [Formula.Eval,Formula.eval_isHull,Code.eval_graph,cons_zero,cons_succ] + exact and_congr (isHull_iff M d q hM hS hdM hqM hd hq hx hc) Iff.rfl + change (∃ c ∈ M, ∃ r ∈ M, _) ↔ _ + constructor + · rintro ⟨c,hc,r,hr,h⟩ + obtain ⟨rfl,hg⟩ := (matrix c r hc hr).mp h + exact ⟨r,hr,hg⟩ + · rintro ⟨r,hr,hg⟩ + have hc := hull_mem M d q hM hS hdM hqM hxM + exact ⟨_,hc,r,hr,(matrix _ r hc hr).mpr ⟨rfl,hg⟩⟩ + +theorem internal_rankGraph (M d q : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hS : Separation M) (hR : SigmaReplacement M) + (hdM : d ∈ M) (hqM : q ∈ M) (hd : Transitive d) + (hq : ∀ c, c ∈ q ↔ c ∈ M ∧ c ⊆ d) (x : ZFSet.{u}) (hx : x ∈ d) : + ∃ f ∈ M, Graph (hull d q x) (iterUnion 2 f) f := by + induction x using ZFSet.inductionOn with + | h x ih => + have hxM := hM d hdM x hx + let e := cons d (cons q (fun _ => d)) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hdM + rcases i with _|i; exact hqM + exact hdM + have cert (y f : ZFSet.{u}) (hy : y ∈ x) (hf : f ∈ M) : + rankCertificate.Realize M (cons f (cons y e)) ↔ + ∃ r ∈ M, Graph (hull d q y) r f := + realize_rankCertificate M d q hM hS hdM hqM hd hq (hd x hx y hy) hf + obtain ⟨b,hb,hbdef⟩ := hR rankCertificate e he x hxM (by + intro y hy + obtain ⟨f,hf,hfg⟩ := ih y hy (hd x hx y hy) + refine ⟨f,hf,(cert y f hy hf).mpr + ⟨_,iterUnion_mem M hM hU hf 2,hfg⟩,?_⟩ + intro g hg hcg + obtain ⟨r,_,hgg⟩ := (cert y g hy hg).mp hcg + exact hgg.unique hfg) + have hbg (f : ZFSet.{u}) : f ∈ b ↔ + ∃ y ∈ x, ∃ r ∈ M, Graph (hull d q y) r f := by + constructor + · intro hf + have hfM := hM b hb f hf + obtain ⟨y,hy,hc⟩ := (hbdef f hfM).mp hf + exact ⟨y,hy,(cert y f hy hfM).mp hc⟩ + · rintro ⟨y,hy,r,hr,hg⟩ + obtain ⟨f',hf',hg'⟩ := ih y hy (hd x hx y hy) + have heq := hg.unique hg' + have hfM : f ∈ M := heq ▸ hf' + exact (hbdef f hfM).mpr ⟨y,hy,(cert y f hy hfM).mpr ⟨r,hr,hg⟩⟩ + let g := ZFSet.sUnion b + have hgM : g ∈ M := union_mem M hM hU hb + have hg (z : ZFSet.{u}) : z ∈ g ↔ + ∃ y ∈ x, ∃ w ∈ hull d q y, z = ZFSet.pair w (rankSet w) := by + constructor + · intro hz + obtain ⟨f,hf,hzf⟩ := ZFSet.mem_sUnion.mp hz + obtain ⟨y,hy,r,_,hfg⟩ := (hbg f).mp hf + exact ⟨y,hy,(hfg.mem_iff z).mp hzf⟩ + · rintro ⟨y,hy,w,hw,hz⟩ + obtain ⟨f,hf,hfg⟩ := ih y hy (hd x hx y hy) + exact ZFSet.mem_sUnion.mpr ⟨f,(hbg f).mpr + ⟨y,hy,_,iterUnion_mem M hM hU hf 2,hfg⟩,(hfg.mem_iff z).mpr ⟨w,hw,hz⟩⟩ + have hvalue : rankImage x g = rankSet x := by + apply ZFSet.ext + intro z + rw [mem_rankImage,mem_rankSet] + constructor + · rintro ⟨y,hy,w,hw,hz⟩ + obtain ⟨a,_,v,_,hp⟩ := (hg _).mp hw + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact ⟨y,hy,hz⟩ + · rintro ⟨y,hy,hz⟩ + exact ⟨y,hy,_,(hg _).mpr + ⟨y,hy,y,self_mem_hull d q (hd x hx y hy),rfl⟩,hz⟩ + have hvM : rankSet x ∈ M := hvalue ▸ + rankImage_mem M hM hP hU hS hxM hgM + let f := g ∪ ({ZFSet.pair x (rankSet x)} : ZFSet.{u}) + have hfM : f ∈ M := binary_union_mem M hM hP hU hgM + (singleton_mem M hM hP (orderedPair_mem M hM hP hxM hvM)) + refine ⟨f,hfM,graph_of_mem_iff _ f (hull_transitive d q x hd) ?_⟩ + intro z + change z ∈ g ∪ ({ZFSet.pair x (rankSet x)} : ZFSet.{u}) ↔ _ + rw [ZFSet.mem_union,ZFSet.mem_singleton,hg] + constructor + · rintro (⟨y,hy,w,hw,hz⟩|hz) + · exact ⟨w,(hull_unfold M d q hM hP hU hS hR hdM hqM hd hq hx w).mpr + (Or.inr ⟨y,hy,hw⟩),hz⟩ + · exact ⟨x,self_mem_hull d q hx,hz⟩ + · rintro ⟨w,hw,hz⟩ + rcases (hull_unfold M d q hM hP hU hS hR hdM hqM hd hq hx w).mp hw with rfl|⟨y,hy,hw⟩ + · exact Or.inr hz + · exact Or.inl ⟨y,hy,w,hw,hz⟩ + +theorem rankSet_mem_of_container (M d : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) + (hdM : d ∈ M) (hd : Transitive d) + {x : ZFSet.{u}} (hx : x ∈ d) : rankSet x ∈ M := by + obtain ⟨q,hqM,hq⟩ := internal_power M hM hPow hdM + obtain ⟨f,hf,hfg⟩ := internal_rankGraph M d q hM hP hU hS hR + hdM hqM hd hq x hx + obtain ⟨v,hv,hfv,_⟩ := hfg.2.2.1 x (self_mem_hull d q hx) + rw [←hfg.correct x (self_mem_hull d q hx) v hv hfv] + exact hM _ (iterUnion_mem M hM hU hf 2) v hv + +end TuringRigidity.InternalRank + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/OneRealConstructionDefinition.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/OneRealConstructionDefinition.lean new file mode 100644 index 0000000000000000000000000000000000000000..28f8fef0a3ca8bb098bb2d603c572b992661ed18 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/OneRealConstructionDefinition.lean @@ -0,0 +1,42 @@ +import OAI.Computability.DegreeRigidity.Constructibility.DecodedConstructionSyntax + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel OrdinalCoding +universe u +attribute [local irreducible] Construction.ownRealsMembership SentenceForm.bound + +theorem Construction.cofinal_one_real_definition (t : Construction.{u}) : + ∃ p : SentenceForm, p.bound ≤ 2 ∧ + ∀ M : ZFSet.{u}, Transitive M → SourceT M → + ∀ P : Oracle, P ∈ modelReals M → t.Certified (groundReals M) P → t.Indexed M → + ∀ θ : Ordinal.{u}, θ.toZFSet ∈ M → + ∃ β : Ordinal.{u}, β.toZFSet ∈ M ∧ θ < β ∧ realSeedOffset < β ∧ + (heightDomainIndex (paddedCode t.ordinalVector β)).toZFSet ∈ M ∧ + (realCode P ∈ level (groundReals M) (heightDomainIndex (paddedCode t.ordinalVector β))) ∧ + t.value (groundReals M) P = definedSubset + (level (groundReals M) (heightDomainIndex (paddedCode t.ordinalVector β))) p + (fun _ : Fin p.bound => realCode P) := by + obtain ⟨q,hq⟩ := t.largest_domain_definition + refine ⟨t.decodedOrdinalBody q,t.decodedOrdinalBody_bound q,?_⟩ + intro M hM hT P hP ht hi θ hθ + obtain ⟨γ,hγ,hbody⟩ := hq M hM hT P hP ht hi + have hv := t.ordinalVector_internal M hM hT hi + obtain ⟨β,hβ,hmaxβ,hoff,hidx,hcert⟩ := cofinal_padded_code_certificates M hM hT + t.ordinalVector hv (max θ γ) (internal_ordinal_max M hθ hγ) + have hθβ : θ < β := (le_max_left _ _).trans_lt hmaxβ + have hγcode : γ ≤ paddedCode t.ordinalVector β := + ((le_max_right _ _).trans hmaxβ.le).trans (padding_lt_paddedCode t.ordinalVector β).le + have hcode := paddedCode_internal M hM hT t.ordinalVector β hv hβ + obtain ⟨_,hvalue,henv,_,hmem⟩ := hbody (paddedCode t.ordinalVector β) hcode hγcode + rw [ground_seed_offset M hM hT] at hvalue henv hmem + refine ⟨β,hβ,hθβ,hoff,hidx,henv 0,?_⟩ + apply definedSubset_of_membership _ _ (level_transitive _ _) hvalue (t.decodedOrdinalBody q) + (fun _ => realCode P) + intro z hz + exact (t.decodedOrdinalBody_spec q M hM hT P β hoff.le hcert henv z).trans (hmem z hz) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/OneRealDefinitionSentence.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/OneRealDefinitionSentence.lean new file mode 100644 index 0000000000000000000000000000000000000000..caa12f2c863fa3c9f7022f91c8a634703061dc4d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/OneRealDefinitionSentence.lean @@ -0,0 +1,96 @@ +import OAI.Computability.DegreeRigidity.Representation.OwnStageSourceTheory +import OAI.Computability.DegreeRigidity.Syntax.SetSatisfactionBounded + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceForm +universe u + +noncomputable def modelRealSentence (i : ℕ) : SentenceForm := + .ex (.conj (canonicalReals 0) (.member (i+1) 0)) + +theorem modelRealSentence_spec (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (i : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ j, e j ∈ M) : + (modelRealSentence i).Sat (M : Set ZFSet) e ↔ e i ∈ groundReals M := by + have hR := groundReals_mem M hM hT + have hf (r : ZFSet.{u}) (hr : r ∈ M) := canonicalReals_spec M hM + (sourceT_omega_mem M hM hT) 0 (cons r e) + (by intro j; cases j; exact hr; exact he _) + change (∃ r ∈ M, (canonicalReals 0).Sat _ (cons r e) ∧ e i ∈ r) ↔ _ + constructor + · rintro ⟨r,hr,h,hx⟩ + obtain rfl := (hf r hr).mp h + exact hx + · intro h + exact ⟨_,hR,(hf _ hR).mpr rfl,h⟩ + +noncomputable def oneRealGraphSentence (s p : SentenceForm) : SentenceForm := + .ex (.conj (s.rename (fun i => if i = 0 then 0 else 2)) + (.conj (.member 3 0) + (FullSetForcing.definedSet 1 (.conj (.member 0 1) + (setBounded p 1 (fun i => if i = 0 then 0 else 4)))))) + +theorem oneRealGraphSentence_spec (s p : SentenceForm) (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) + (hs : ∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ M) → + (s.Sat (M : Set ZFSet) e ↔ e 0 = stage (groundReals M) (e 1))) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (oneRealGraphSentence s p).Sat (M : Set ZFSet) e ↔ + e 2 ∈ stage (groundReals M) (e 1) ∧ + e 0 = definedSubset (stage (groundReals M) (e 1)) p + (fun _ : Fin p.bound => e 2) := by + have hc (A : ZFSet.{u}) (hA : A ∈ M) : ∀ i, cons A e i ∈ M := by + intro i; cases i; exact hA; exact he _ + have hstage (A : ZFSet.{u}) (hA : A ∈ M) : + (s.rename (fun i => if i = 0 then 0 else 2)).Sat (M : Set ZFSet) (cons A e) ↔ + A = stage (groundReals M) (e 1) := by + rw [sat_rename,hs _ (fun i => hc A hA _)]; rfl + have hdef (A : ZFSet.{u}) (hA : A ∈ M) (hP : e 2 ∈ A) : + (FullSetForcing.definedSet 1 (.conj (.member 0 1) + (setBounded p 1 (fun i => if i = 0 then 0 else 4)))).Sat + (M : Set ZFSet) (cons A e) ↔ + e 0 = definedSubset A p (fun _ : Fin p.bound => e 2) := by + apply FullSetForcing.definedSet_unique M hM _ _ _ (hc A hA) _ + (definedSubset_mem M A hM hT.separation.finitePrefix.bounded hA p + (fun _ => e 2) (fun _ => hP) (by omega)) + intro x _ + rw [Formula.Eval,setBounded_eval,mem_definedSubset] + apply and_congr_right; intro _ + apply p.finite_support + intro i hi + rcases i with _|i + · rfl + · change e 2 = tupleEnv (fun _ : Fin p.bound => e 2) i + simp only [tupleEnv,dite_eq_left (show i < p.bound by omega)] + change (∃ A ∈ M, (s.rename _).Sat _ (cons A e) ∧ e 2 ∈ A ∧ + (FullSetForcing.definedSet _ _).Sat _ (cons A e)) ↔ _ + constructor + · rintro ⟨A,hA,h,hP,hf⟩ + obtain rfl := (hstage A hA).mp h + exact ⟨hP,(hdef _ hA hP).mp hf⟩ + · rintro ⟨hP,hf⟩ + have hA := stage_mem M _ _ hM hT (groundReals_mem M hM hT) (he 1) + exact ⟨_,hA,(hstage _ hA).mpr rfl,hP,(hdef _ hA hP).mpr hf⟩ + +noncomputable def oneRealSentence (s p : SentenceForm) : SentenceForm := + .conj (fromBounded (ordinalFormula 1)) + (.conj (modelRealSentence 2) (oneRealGraphSentence s p)) + +theorem oneRealSentence_spec (s p : SentenceForm) (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) + (hs : ∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ M) → + (s.Sat (M : Set ZFSet) e ↔ e 0 = stage (groundReals M) (e 1))) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (oneRealSentence s p).Sat (M : Set ZFSet) e ↔ + (e 1).IsOrdinal ∧ e 2 ∈ groundReals M ∧ + e 2 ∈ stage (groundReals M) (e 1) ∧ + e 0 = definedSubset (stage (groundReals M) (e 1)) p + (fun _ : Fin p.bound => e 2) := by + change (_ ∧ _ ∧ _) ↔ _ + rw [bounded_sat,Formula.absolute _ M hM e he,eval_ordinalFormula, + modelRealSentence_spec M hM hT 2 e he,oneRealGraphSentence_spec s p M hM hT hs e he] + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ParameterFreeOrdinalStage.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ParameterFreeOrdinalStage.lean new file mode 100644 index 0000000000000000000000000000000000000000..7948bc39542cfd842ffe683380e2e3c082f412ca --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ParameterFreeOrdinalStage.lean @@ -0,0 +1,62 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericStage + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SetModelFunctions +universe u + +theorem parameter_free_ordinal_stage : + ∃ p : SentenceForm, ∀ M : ZFSet.{u}, Transitive M → SourceT M → + ∀ o : Ordinal.{u}, o.toZFSet ∈ M → + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ + ∀ δ : Ordinal.{u}, δ.toZFSet ∈ M → γ ≤ δ → + o.toZFSet ∈ level (groundReals M) δ ∧ level (groundReals M) o ∈ level (groundReals M) δ ∧ + groundReals M ∈ level (groundReals M) δ ∧ + ∀ A ∈ level (groundReals M) δ, + p.Sat (level (groundReals M) δ : Set ZFSet) + (cons A (cons o.toZFSet (fun _ => groundReals M))) ↔ A = level (groundReals M) o := by + obtain ⟨p,hp⟩ := NumericSyntax.stage_formula.{u} + refine ⟨p,?_⟩ + intro M hM hT o ho + let R := groundReals M + let N := relativeModel M R + have hR := groundReals_mem M hM hT + have C := ground_relative_context M hM hT + obtain ⟨B,hBN,hB,hcover⟩ := internal_finite_natural_graph_bound N C.transitive C.pairing C.union + C.power C.separation C.omega_mem + let e := cons ZFSet.omega (cons (ZFSet.prod ZFSet.omega ZFSet.omega) (cons B (fun _ => R))) + have he (i : ℕ) (_hi : i < 4) : InRelativeModel M R (e i) := by + apply (mem_relativeModel M R _ hM hT hR).mp + rcases i with _|_|_|i + · exact C.omega_mem + · exact C.prod_mem C.omega_mem C.omega_mem + · exact hBN + · exact (mem_relativeModel M R R hM hT hR).mpr (parameter_in_relativeModel M R hM hT) + obtain ⟨β,hβ,hβe⟩ := finite_parameters_in_relative_level M R hM hT e 4 he + obtain ⟨α,hα,hαspec⟩ := seed_bound_stage_at_levels M o.toZFSet hM hT + ((ground_relativeModel_ordinal_iff M hM hT o).mpr ho) + refine ⟨max α β,internal_ordinal_max M hα hβ,?_⟩ + intro δ hδ hle + have hin (i : ℕ) (hi : i < 4) : e i ∈ level R δ := + level_mono R ((le_max_right α β).trans hle) (hβe i hi) + have hL := level_transitive R δ + have hsub : level R δ ⊆ N := fun x hx => (mem_relativeModel M R x hM hT hR).mpr ⟨δ,hδ,hx⟩ + have hBL : PowerBound (level R δ) (ZFSet.prod ZFSet.omega ZFSet.omega) B := + PowerBound.between hB hL hsub (hin 2 (by decide)) + have hfin (f : ℕ → ℕ) (k : ℕ) : finiteNaturalGraph f k ∈ level R δ := + hL B (hin 2 (by decide)) _ (hcover f k) + obtain ⟨hoL,hAL,hstage⟩ := hαspec δ hδ ((le_max_left α β).trans hle) + refine ⟨hoL,hAL,hin 3 (by decide),?_⟩ + intro A hA + have hv : ∀ i, cons A (cons o.toZFSet (fun _ => R)) i ∈ level R δ := by + intro i; rcases i with _|_|i + · exact hA + · exact hoL + · exact hin 3 (by decide) + exact (hp (level R δ) hL (hin 0 (by decide)) (hin 1 (by decide)) hfin + ⟨B,hin 2 (by decide),hBL⟩ _ hv).trans (hstage A) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/ParameterPersistentCollapse.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/ParameterPersistentCollapse.lean new file mode 100644 index 0000000000000000000000000000000000000000..f35510d448ea69ad3b79ad6ea41819d54f596ea8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/ParameterPersistentCollapse.lean @@ -0,0 +1,42 @@ +import OAI.Computability.DegreeRigidity.Representation.ParameterCoveringModels +import OAI.Computability.DegreeRigidity.Representation.GroundDegreeCollapse + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel PersistentRestrictions PersistentPresentation PersistentCountability OracleJump +open CountableForcing ElementaryModel +universe u +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem parameter_persistent_collapse (π : Degree ≃o Degree) (A : ℕ → Oracle) : + ∃ M : ZFSet.{u}, Transitive M ∧ SourceT M ∧ Countable (Conditions M) ∧ + (∀ n, A n ∈ modelReals M) ∧ + ∃ c ∈ M, ∃ G : GenericFilter (Conditions c), AtomicForcing.GroundGeneric M G ∧ + let N := genericExtensionSet M c G.carrier + M ⊆ N ∧ Transitive N ∧ SourceT N ∧ + ∃ I : CountableIdeal, ∃ H ∈ modelReals N, ∃ hH : Presented I H, + (∀ a : Degree, a ∈ I.carrier ↔ ∃ X ∈ modelReals M, degree X = a) ∧ + (∀ n, degree (A n) ∈ I.carrier) ∧ + ∃ ρ : I ≃o I, RestrictsTo π I ρ ∧ Persistent I ρ ∧ + graphOracle hH ρ ∈ modelReals N ∧ + ∃ S ∈ N, degreeUniverse S ∈ N ∧ degreeOrder S ∈ N ∧ + presentationGraph S H (graphOracle hH ρ) ∈ N ∧ + (LevySigma.persistent 0 1 2 3 4).Realize N + (modelDegreeEnv S (presentationSet S H) (presentationGraph S H (graphOracle hH ρ))) := by + obtain ⟨X,hX⟩ := degree_surjective (π (degree (jump FixedArithmetic.zero))) + obtain ⟨Y,hY⟩ := degree_surjective (π.symm (degree (jump FixedArithmetic.zero))) + let B : ℕ → Oracle | 0 => X | 1 => Y | n+2 => A n + obtain ⟨M,hM,hT,hcount,hB⟩ := parameter_covering_models.{u} B + let : Countable (Conditions M) := hcount + obtain ⟨c,hc,G,hG,hMN,hN,hTN,I,H,hHN,hH,hI,ρ,hρ,hp,hRN,S,hSN,hU,hO,hgraph⟩ := + ground_degree_persistent_collapse M hM hT π X Y (hB 0) (hB 1) hX hY + refine ⟨M,hM,hT,hcount,(fun n => hB (n+2)),c,hc,G,hG,hMN,hN,hTN, + I,H,hHN,hH,hI,?_,ρ,hρ,hp,hRN,S,hSN,hU,hO,hgraph⟩ + intro n + exact (hI _).mpr ⟨A n,hB (n+2),rfl⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistenceCriterion.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistenceCriterion.lean new file mode 100644 index 0000000000000000000000000000000000000000..23343dd512ff068b03534b3a21fdef44d62696be --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistenceCriterion.lean @@ -0,0 +1,66 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericalExtension + +namespace OAI + +namespace TuringRigidity.PersistenceCriterion +open EncodedForcing OracleJump ArithmeticHierarchy PersistentRestrictions PersistentLocality +open PersistentPresentation PersistentCountability NumericalAutomorphism NumericalIdeal NumericalExtension +noncomputable section + +def ProgramGraph (Y : Oracle) (p : OracleCode) (v : ℕ) : Prop := + 1 ∈ OracleCode.eval (oracleFunction Y) p v + +def Criterion (A : Oracle) (R : ℕ → Prop) : Prop := + ∀ H : Oracle, JumpCode H → Includes A H → + ∃ p : OracleCode, Action H (ProgramGraph (iterate H 11) p) ∧ + Compatible A H R (ProgramGraph (iterate H 11) p) + +theorem action_congr {H : Oracle} {P Q : ℕ → Prop} (h : ∀ v, P v ↔ Q v) : + Action H P ↔ Action H Q := by + have he : P = Q := funext (fun v => propext (h v)) + rw [he] + +theorem program_graph {I : CountableIdeal} {H Y : Oracle} (hpres : Presented I H) + (ρ : I ≃o I) (hr : RecursivePred Y (PersistentPresentation.Graph ρ hpres)) : + ∃ p : OracleCode, ∀ v, ProgramGraph Y p v ↔ PersistentPresentation.Graph ρ hpres v := by + obtain ⟨p,hp⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp + (graphOracle_reduces hpres ρ hr) + refine ⟨p,fun v => ?_⟩ + simp only [ProgramGraph,hp,oracleFunction,graphOracle] + by_cases hg : PersistentPresentation.Graph ρ hpres v <;> simp [hg] + +theorem persistent_iff {I : CountableIdeal} {A : Oracle} (hA : Presented I A) + (ρ : I ≃o I) (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) : + Persistent I ρ ↔ Criterion A (PersistentPresentation.Graph ρ hA) := by + constructor + · intro hp H hc hi + let J := decode H hc + have hH : Presented J H := decoded_presentation H hc + have hIJ : I.carrier ⊆ J.carrier := (includes_iff hA hH).mp hi + obtain ⟨σ,he,hpσ⟩ := PersistentExtension.source_4_1_10 I J ρ hp hz hIJ (decoded_closed H hc) + obtain ⟨p,hpgraph⟩ := program_graph hH σ (source_4_1_8 σ hpσ (hIJ hz) hH).2 + refine ⟨p,(action_congr hpgraph).mpr (action_of_automorphism hH σ),?_⟩ + exact (compatible_congr hpgraph).mpr ((compatible_iff hA hH hIJ ρ σ).mpr he) + · intro hc x + let J := JumpIdeal.generated (degree A ⊔ x) + have hIJ : I.carrier ⊆ J.carrier := by + intro y hy + obtain ⟨n,rfl⟩ := (hA y).mp hy + exact J.lower (le_trans (show degree (columns A n) ≤ degree A from CodingExtraction.column_projection_reduces A n) le_sup_left) + (JumpIdeal.includes _) + have hx : x ∈ J.carrier := J.lower le_sup_right (JumpIdeal.includes _) + obtain ⟨H,hH⟩ := presentation_exists J + have hjcode : JumpCode H := code_of_ideal hH (JumpIdeal.closed _) + have hi : Includes A H := (includes_iff hA hH).mpr hIJ + obtain ⟨p,ha,hcompat⟩ := hc H hjcode hi + let K := decode H hjcode + have hK : Presented K H := decoded_presentation H hjcode + have hIK : I.carrier ⊆ K.carrier := (includes_iff hA hK).mp hi + obtain ⟨σ,hσ⟩ := reconstruct hK ha + refine ⟨K,hIK,σ,(hK x).mpr ((hH x).mp hx),?_⟩ + exact (compatible_iff hA hK hIK ρ σ).mp ((compatible_congr hσ).mp hcompat) + +end +end TuringRigidity.PersistenceCriterion + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistenceExtensionAbsoluteness.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistenceExtensionAbsoluteness.lean new file mode 100644 index 0000000000000000000000000000000000000000..54a3dff4f56672a336082576c80561b655f40d8e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistenceExtensionAbsoluteness.lean @@ -0,0 +1,74 @@ +import OAI.Computability.DegreeRigidity.Syntax.PiOneOneSatisfaction + +namespace OAI + + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic BoundedSetTheory TransitiveNameModel ArithmeticPersistence +universe u + +theorem arithmetic_real_between_models (M N : ZFSet.{u}) + (hM : Transitive M) (hN : Transitive N) (hTM : SourceT M) (hTN : SourceT N) + {Q : Predicate} (hQ : Arith Q) (A R : Oracle) + (hAM : A ∈ modelReals M) (hRM : R ∈ modelReals M) + (hAN : A ∈ modelReals N) (hRN : R ∈ modelReals N) (v : ℕ) : + (∀ H ∈ modelReals M, Q (parameters A R H) v) ↔ + ∀ H ∈ modelReals N, Q (parameters A R H) v := + (sourceT_forall_arithmetic_real M hM hTM hQ A R hAM hRM v).trans + (sourceT_forall_arithmetic_real N hN hTN hQ A R hAN hRN v).symm + +theorem persistence_between_models (M N : ZFSet.{u}) + (hM : Transitive M) (hN : Transitive N) (hTM : SourceT M) (hTN : SourceT N) + (A R : Oracle) (hAM : A ∈ modelReals M) (hRM : R ∈ modelReals M) + (hAN : A ∈ modelReals N) (hRN : R ∈ modelReals N) : + (∀ H ∈ modelReals M, Base A R ∧ Matrix (parameters A R H) 0) ↔ + ∀ H ∈ modelReals N, Base A R ∧ Matrix (parameters A R H) 0 := + (sourceT_persistence_presentation M hM hTM A R hAM hRM).trans + (sourceT_persistence_presentation N hN hTN A R hAN hRN).symm + +theorem persistence_in_generic_extension (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : CountableForcing.GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) + (htop : ⊤ ∈ G.carrier) (A R : Oracle) (hA : A ∈ modelReals M) (hR : R ∈ modelReals M) : + (∀ H ∈ modelReals M, Base A R ∧ Matrix (parameters A R H) 0) ↔ + ∀ H ∈ modelReals (genericExtensionSet M c G.carrier), + Base A R ∧ Matrix (parameters A R H) 0 := by + have hi := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier htop + have hAE : A ∈ modelReals (genericExtensionSet M c G.carrier) := by + change realCode A ∈ genericExtensionSet M c G.carrier + exact hi hA + have hRE : R ∈ modelReals (genericExtensionSet M c G.carrier) := by + change realCode R ∈ genericExtensionSet M c G.carrier + exact hi hR + exact persistence_between_models M _ hM (genericExtensionSet_transitive M c hM G.carrier) + hT (extension_sourceT M hM hT hc hoM ho G hG htop) A R hA hR hAE hRE + +theorem piOneOne_formula {P : Oracle → Oracle → Prop} (hp : PiOneOne P) : + ∃ φ : Formula, ∀ M : ZFSet.{u}, Transitive M → SourceT M → + ∃ S Q : ZFSet.{u}, S ∈ M ∧ Q ∈ M ∧ + ∀ A R : Oracle, A ∈ modelReals M → R ∈ modelReals M → + ((Formula.piOneOneMatrix φ).Realize M (piOneOneEnv S Q A R 0) ↔ P A R) := by + obtain ⟨P',hP,hiff⟩ := hp + obtain ⟨φ,hφ⟩ := arithmetic_bounded_definition.{u} hP + refine ⟨φ,fun M hM hT => ?_⟩ + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded (sourceT_omega_mem M hM hT) + obtain ⟨S,hSM,hS,hSd⟩ := internal_real_power M hM hT + have hd : ∀ x ∈ S, ∃ H : Oracle, realCode H = x := by + intro x hx; obtain ⟨H,_,hH⟩ := hSd x hx; exact ⟨H,hH⟩ + exact ⟨S,Q,hSM,hQM,fun A R hA hR => + (sourceT_piOneOne_satisfaction M hM hT hφ hP S Q hSM hQM hS hd hQ A R hA hR 0).trans + (hiff A R).symm⟩ + +theorem nonidentity_presentation_formula : + ∃ φ : Formula, ∀ M : ZFSet.{u}, Transitive M → SourceT M → + ∃ S Q : ZFSet.{u}, S ∈ M ∧ Q ∈ M ∧ + ∀ A R : Oracle, A ∈ modelReals M → R ∈ modelReals M → + ((Formula.piOneOneMatrix φ).Realize M (piOneOneEnv S Q A R 0) ↔ + Property A R ∧ Moved A R) := piOneOne_formula nonidentity_piOneOne + +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistenceRealClosure.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistenceRealClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..92629f23c6d5993c3c7d7610fe302334c8efd03c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistenceRealClosure.lean @@ -0,0 +1,74 @@ +import OAI.Computability.DegreeRigidity.Computability.JumpIdealPresentation + +namespace OAI + +namespace TuringRigidity.PersistenceRealClosure +open EncodedForcing OracleJump ArithmeticHierarchy UniformArithmetic JumpIdealPresentation +open PersistentRestrictions PersistentPresentation PersistentCountability NumericalIdeal +open NumericalAutomorphism NumericalExtension +noncomputable section + +structure Closed (M : Set Oracle) : Prop where + lower : ∀ {A B}, B ∈ M → Reduces A B → A ∈ M + join : ∀ {A B}, A ∈ M → B ∈ M → TuringRigidity.join A B ∈ M + omega : ∀ {A}, A ∈ M → omegaJump A ∈ M + +theorem Closed.jump {M : Set Oracle} (hM : Closed M) {A : Oracle} (hA : A ∈ M) : jump A ∈ M := by + have h := hM.lower (hM.omega hA) (CodingExtraction.column_projection_reduces (omegaJump A) 1) + change columns (omegaJump A) 1 ∈ M at h + simpa only [omegaJump_column,OracleJump.iterate] using h + +theorem Closed.iterate {M : Set Oracle} (hM : Closed M) {A : Oracle} (hA : A ∈ M) (n : ℕ) : + OracleJump.iterate A n ∈ M := by + induction n with + | zero => exact hA + | succ n ih => exact hM.jump ih + +theorem Closed.presentation {M : Set Oracle} (hM : Closed M) {A : Oracle} (hA : A ∈ M) : + JumpIdealPresentation.presentation A ∈ M := by + obtain ⟨k,hk⟩ := presentation_bounded A + exact hM.lower (hM.iterate (hM.omega hA) k) hk + +theorem graph_mem {M : Set Oracle} (hM : Closed M) {I : CountableIdeal} {A : Oracle} + (hA : Presented I A) (hAM : A ∈ M) (ρ : I ≃o I) + (hp : Persistent I ρ) (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) : + graphOracle hA ρ ∈ M := + hM.lower (hM.iterate hAM 11) (graphOracle_reduces hA ρ (source_4_1_8 ρ hp hz hA).2) + +theorem extension_witnesses {M : Set Oracle} (hM : Closed M) + {I : CountableIdeal} {A R : Oracle} (hA : Presented I A) (hAM : A ∈ M) + (ρ : I ≃o I) (hp : Persistent I ρ) + (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (hR : ∀ v, R v = true ↔ Graph ρ hA v) + {X : Oracle} (hX : X ∈ M) : + ∃ H ∈ M, ∃ S ∈ M, JumpCode H ∧ Includes A H ∧ + (∃ n, degree X = degree (columns H n)) ∧ + Action H (fun v => S v = true) ∧ + Compatible A H (fun v => R v = true) (fun v => S v = true) := by + let B := join A X + let J := JumpIdeal.generated (degree B) + let H := JumpIdealPresentation.presentation B + have hH : Presented J H := presents B + have hHM : H ∈ M := hM.presentation (hM.join hAM hX) + have hIJ : I.carrier ⊆ J.carrier := by + intro y hy + obtain ⟨n,rfl⟩ := (hA y).mp hy + exact J.lower ((CodingExtraction.column_projection_reduces A n).trans + (reduces_join_left A X)) (JumpIdeal.includes _) + have hXJ : degree X ∈ J.carrier := J.lower (reduces_join_right A X) (JumpIdeal.includes _) + obtain ⟨σ,he,hpσ⟩ := PersistentExtension.source_4_1_10 I J ρ hp hz hIJ (JumpIdeal.closed _) + let S := graphOracle hH σ + have hSM : S ∈ M := graph_mem hM hH hHM σ hpσ (hIJ hz) + have hS : ∀ v, S v = true ↔ Graph σ hH v := fun v => by simp [S,graphOracle] + obtain ⟨n,hn⟩ := (hH _).mp hXJ + refine ⟨H,hHM,S,hSM,code_of_ideal hH (JumpIdeal.closed _), + (includes_iff hA hH).mpr hIJ,⟨n,hn.symm⟩, + (PersistenceCriterion.action_congr hS).mpr (action_of_automorphism hH σ),?_⟩ + intro i j n m hr hs hin + exact ((compatible_iff hA hH hIJ ρ σ).mpr he) i j n m + ((hR _).mp hr) ((hS _).mp hs) hin + +end +end TuringRigidity.PersistenceRealClosure + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistenceWitnessTree.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistenceWitnessTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..db548e17a3bf45d3a04c4b44455084990a79bd6f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistenceWitnessTree.lean @@ -0,0 +1,105 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticSkolem +import OAI.Computability.DegreeRigidity.Computability.ArithmeticWitnessTree +import OAI.Computability.DegreeRigidity.Constructibility.PersistentNonidentity + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic ArithmeticPersistence +noncomputable section +attribute [local instance] Classical.propDecidable + +namespace Test + +def bindOracle (q : ℕ → Term → Test) : Test → Test + | .pure P hP t => .pure P hP t + | .query i t => q i t + | .neg t => .neg (t.bindOracle q) + | .and t s => .and (t.bindOracle q) (s.bindOracle q) + +theorem eval_bindOracle (t : Test) (q : ℕ → Term → Test) + (O U : Oracles) (f : ℕ → ℕ) (v : ℕ) + (hq : ∀ i s, (q i s).eval O f v ↔ U i (s.eval f v) = true) : + (t.bindOracle q).eval O f v ↔ t.eval U f v := by + induction t with + | pure P hP t => rfl + | query i t => exact hq i t + | neg t ih => exact not_congr ih + | and t s ih ik => exact and_congr ih ik + +private def realQuery : ℕ → Term → Test + | 0, t => .query 0 t + | 1, t => .query 1 t + | _+2, t => .pure (fun n => n = 1) + (Primrec.eq.comp Primrec.id (Primrec.const 1)) (.witness (.pair (.const 0) t)) + +def mergeReal (t : Test) : Test := + (t.subst .input (fun s => .witness (.pair (.const 1) s))).bindOracle realQuery + +def realPart (f : ℕ → ℕ) : Oracle := fun n => decide (f (Nat.pair 0 n) = 1) +def witnessPart (f : ℕ → ℕ) : ℕ → ℕ := fun n => f (Nat.pair 1 n) + +theorem mergeReal_eval (t : Test) (A R : Oracle) (f : ℕ → ℕ) (v : ℕ) : + t.mergeReal.eval (parameters A R (fun _ => false)) f v ↔ + t.eval (parameters A R (realPart f)) (witnessPart f) v := by + unfold mergeReal + apply Iff.trans (t.subst _ _ |>.eval_bindOracle realQuery _ + (parameters A R (realPart f)) f v ?_) + · exact t.eval_subst _ _ _ f _ v (fun _ => rfl) + · intro i s + cases i with + | zero => rfl + | succ i => + cases i with + | zero => rfl + | succ i => simp [realQuery,eval,Term.eval,parameters,realPart] + +private def joinWitness (H : Oracle) (f : ℕ → ℕ) : ℕ → ℕ := fun n => + if (Nat.unpair n).1 = 0 then (if H (Nat.unpair n).2 then 1 else 0) else f (Nat.unpair n).2 + +private theorem realPart_join (H : Oracle) (f : ℕ → ℕ) : + realPart (joinWitness H f) = H := by + funext n + cases hn : H n <;> simp [realPart,joinWitness,hn] + +private theorem witnessPart_join (H : Oracle) (f : ℕ → ℕ) : + witnessPart (joinWitness H f) = f := by + funext n + simp [witnessPart,joinWitness] + +theorem exists_mergeReal (t : Test) (A R : Oracle) (v : ℕ) : + (∃ H : Oracle, ∃ f : ℕ → ℕ, ∀ n, t.eval (parameters A R H) f (Nat.pair v n)) ↔ + ∃ f : ℕ → ℕ, ∀ n, t.mergeReal.eval (parameters A R (fun _ => false)) f (Nat.pair v n) := by + constructor + · rintro ⟨H,f,hf⟩ + refine ⟨joinWitness H f,fun n => (t.mergeReal_eval _ _ _ _).mpr ?_⟩ + simpa only [realPart_join,witnessPart_join] using hf n + · rintro ⟨f,hf⟩ + exact ⟨realPart f,witnessPart f,fun n => (t.mergeReal_eval _ _ _ _).mp (hf n)⟩ +end Test + +theorem piOneOne_tree {P : Oracle → Oracle → Prop} (hP : PiOneOne P) : + ∃ t : Test, ∀ A R, P A R ↔ + WellFounded (t.Child (parameters A R (fun _ => false)) 0) := by + obtain ⟨Q,hQ,hiff⟩ := hP + obtain ⟨t,ht⟩ := (arithmetic_tests hQ).2 + refine ⟨t.mergeReal,fun A R => ?_⟩ + rw [t.mergeReal.wellFounded_iff,← t.exists_mergeReal] + rw [hiff] + simp only [not_exists] + apply forall_congr' + intro H + have he := ht (parameters A R H) 0 + simpa only [not_not,not_exists] using not_congr he + +theorem persistence_trees : + (∃ t : Test, ∀ A R, Property A R ↔ + WellFounded (t.Child (parameters A R (fun _ => false)) 0)) ∧ + (∃ t : Test, ∀ A R, (Property A R ∧ Moved A R) ↔ + WellFounded (t.Child (parameters A R (fun _ => false)) 0)) := + ⟨piOneOne_tree source_4_2_1,piOneOne_tree nonidentity_piOneOne⟩ + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentConstruction.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca5336cee5ba1f242fe249c8cac4c7542a105816 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentConstruction.lean @@ -0,0 +1,51 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructionDefinition +import OAI.Computability.DegreeRigidity.Constructibility.RelativePersistentExtension + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel SetDegreeDecoding PersistentRestrictions +universe u + +theorem persistent_graph_construction (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) + (hρ : Persistent (modelIdeal M hM hT) ρ) : + ∃ t : Construction.{u}, ∃ P : Oracle, P ∈ modelReals M ∧ + t.Indexed M ∧ t.Certified (groundReals M) P ∧ + t.value (groundReals M) P = automorphismSet ρ := + construction_of_relativeModel M hM hT _ + (persistent_modelIdeal_graph_mem_relativeModel M hM hT ρ hρ) + +theorem persistent_extension_construction (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) + (I : CountableIdeal) (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (hIM : I.carrier ⊆ (modelIdeal M hM hT).carrier) : + ∃ σ : modelIdeal M hM hT ≃o modelIdeal M hM hT, + Extends hIM ρ σ ∧ Persistent (modelIdeal M hM hT) σ ∧ + ∃ t : Construction.{u}, ∃ P : Oracle, P ∈ modelReals M ∧ + t.Indexed M ∧ t.Certified (groundReals M) P ∧ + t.value (groundReals M) P = automorphismSet σ := by + obtain ⟨σ,he,hσ,hm⟩ := persistent_extension_in_relativeModel M hM hT I ρ hρ hz hIM + exact ⟨σ,he,hσ,construction_of_relativeModel M hM hT _ hm⟩ + +theorem persistent_graph_definition (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) + (hρ : Persistent (modelIdeal M hM hT) ρ) : + ∃ (o : Ordinal.{u}) (n : ℕ) (p : SentenceForm) + (c : Fin n → Construction.{u}) (P : Oracle), + o.toZFSet ∈ M ∧ P ∈ modelReals M ∧ + (Construction.define o n p c).Indexed M ∧ + (Construction.define o n p c).Certified (groundReals M) P ∧ + satisfactionSet (level (groundReals M) o) ∈ M ∧ + ∀ z, z ∈ automorphismSet ρ ↔ z ∈ level (groundReals M) o ∧ + p.Sat (level (groundReals M) o : Set ZFSet) + (cons z (tupleEnv (fun i => (c i).value (groundReals M) (realPart P i)))) := + construction_definition_of_relativeModel M hM hT _ + (persistent_modelIdeal_graph_mem_relativeModel M hM hT ρ hρ) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentCountability.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentCountability.lean new file mode 100644 index 0000000000000000000000000000000000000000..d7334b40a768fe97226667b7a2be1a6b40e486bc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentCountability.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.Constructibility.PersistentPresentation + +namespace OAI + +namespace TuringRigidity.PersistentCountability +open EncodedForcing OracleJump ArithmeticHierarchy PersistentRestrictions PersistentPresentation +noncomputable section +attribute [local instance] Classical.propDecidable + +theorem presentation_exists (I : CountableIdeal) : ∃ H, Presented I H := by + obtain ⟨f,hf⟩ := I.countable.exists_eq_range I.nonempty + choose A hA using (fun n => degree_surjective (f n)) + refine ⟨CountableBound.sum A,fun x => ?_⟩ + have hc (k : ℕ) : columns (CountableBound.sum A) k = A k := by + funext n + simp only [columns,CountableBound.sum,Nat.unpair_pair] + simp only [hc,hA,hf,Set.mem_range] + +def graphOracle {I : CountableIdeal} {H : Oracle} (hpres : Presented I H) + (ρ : I ≃o I) : Oracle := fun n => decide (Graph ρ hpres n) + +theorem graphOracle_injective {I : CountableIdeal} {H : Oracle} + (hpres : Presented I H) : Function.Injective (graphOracle hpres) := by + intro ρ σ he + apply OrderIso.ext + funext x + obtain ⟨n,hn⟩ := (hpres x.val).mp x.property + obtain ⟨j,hj⟩ := (hpres (ρ x).val).mp (ρ x).property + have hx : entry hpres n = x := Subtype.ext hn + have hp : Graph ρ hpres (Nat.pair n j) := by + simp only [PersistentPresentation.Graph,Nat.unpair_pair,hx,hj] + have hq : Graph σ hpres (Nat.pair n j) := by + by_contra hn + have hh := congrFun he (Nat.pair n j) + simp only [graphOracle,decide_eq_true hp,decide_eq_false hn] at hh + cases hh + apply Subtype.ext + simpa only [PersistentPresentation.Graph,Nat.unpair_pair,hx,hj] using hq.symm + +theorem graphOracle_reduces {I : CountableIdeal} {H Y : Oracle} + (hpres : Presented I H) (ρ : I ≃o I) (h : RecursivePred Y (Graph ρ hpres)) : + Reduces (graphOracle hpres ρ) Y := by + apply RecursiveIn.iff_nat.mpr + exact h.of_eq (fun n => by simp [oracleFunction,graphOracle]) + +theorem arithmetic_maps_countable {I : CountableIdeal} {H : Oracle} + (hpres : Presented I H) (Y : Oracle) : + {ρ : I ≃o I | RecursivePred Y (Graph ρ hpres)}.Countable := by + apply ((countable_reduces Y).preimage (graphOracle_injective hpres)).mono + intro ρ hρ + exact graphOracle_reduces hpres ρ hρ + +theorem source_4_1_9 (I : CountableIdeal) + (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) : + {ρ : I ≃o I | Persistent I ρ}.Countable := by + obtain ⟨H,hpres⟩ := presentation_exists I + apply (arithmetic_maps_countable hpres (iterate H 11)).mono + intro ρ hp + exact (source_4_1_8 ρ hp hz hpres).2 + +end +end TuringRigidity.PersistentCountability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentExtension.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe4e26cf1c0b1277378d6fae1d6a72dc02660d5a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentExtension.lean @@ -0,0 +1,55 @@ +import OAI.Computability.DegreeRigidity.Constructibility.PersistentRestrictionCode + +namespace OAI + +namespace TuringRigidity.PersistentExtension +open EncodedForcing OracleJump ArithmeticHierarchy IdealInterpretation IdealLocality +open PersistentRestrictions PersistentLocality PersistentPresentation PersistentCountability +noncomputable section + +theorem nonpersistent_witness {J : CountableIdeal} {σ : J ≃o J} + (h : ¬ Persistent J σ) : + ∃ x, ∀ (K : CountableIdeal) (hJK : J.carrier ⊆ K.carrier) (τ : K ≃o K), + x ∈ K.carrier → ¬ Extends hJK σ τ := by + simpa only [Persistent,not_forall,not_exists,not_and] using h + +theorem source_4_1_10 (I J : CountableIdeal) (ρ : I ≃o I) + (hp : Persistent I ρ) (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (hIJ : I.carrier ⊆ J.carrier) (hj : JumpClosed (ideal J)) : + ∃ σ : J ≃o J, Extends hIJ ρ σ ∧ Persistent J σ := by + classical + by_contra hn + have hnot (σ : J ≃o J) (he : Extends hIJ ρ σ) : ¬ Persistent J σ := + fun hpσ => hn ⟨σ,he,hpσ⟩ + obtain ⟨H,hpres⟩ := presentation_exists J + let S : Set (J ≃o J) := {σ | RecursivePred (iterate H 11) (Graph σ hpres)} + have hS : S.Countable := arithmetic_maps_countable hpres _ + have : Countable S := hS.to_subtype + have hwitness (σ : S) : ∃ x, Extends hIJ ρ σ.val → + ∀ (K : CountableIdeal) (hJK : J.carrier ⊆ K.carrier) (τ : K ≃o K), + x ∈ K.carrier → ¬ Extends hJK σ.val τ := by + by_cases he : Extends hIJ ρ σ.val + · obtain ⟨x,hx⟩ := nonpersistent_witness (hnot σ.val he) + exact ⟨x,fun _ => hx⟩ + · exact ⟨⊥,fun h => (he h).elim⟩ + choose w hw using hwitness + let L := JumpIdeal.generated (degree H) + have hJL : J.carrier ⊆ L.carrier := by + intro x hx + obtain ⟨n,rfl⟩ := (hpres x).mp hx + exact L.lower (CodingExtraction.column_projection_reduces H n) (JumpIdeal.includes _) + obtain ⟨b,hb⟩ := CountableBound.countable_bounded (Set.range w ∪ L.carrier) + ((Set.countable_range w).union L.countable) + obtain ⟨K,hIK,τ,hbK,he⟩ := hp b + have hLK : L.carrier ⊆ K.carrier := fun x hx => K.lower (hb x (Or.inr hx)) hbK + have hJK : J.carrier ⊆ K.carrier := fun x hx => hLK (hJL hx) + obtain ⟨σ,hρ,hτ,hr⟩ := PersistentRestrictionCode.restriction ρ τ hIK he hz + hIJ hJK hj hpres hLK + let s : S := ⟨σ,hr⟩ + have hwK : w s ∈ K.carrier := K.lower (hb (w s) (Or.inl ⟨s,rfl⟩)) hbK + exact hw s hρ K hJK τ hwK hτ + +end +end TuringRigidity.PersistentExtension + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentExtensionName.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentExtensionName.lean new file mode 100644 index 0000000000000000000000000000000000000000..8012a4bf8630c4ae34e281dd87733aba5e522183 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentExtensionName.lean @@ -0,0 +1,55 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativePersistentExtension +import OAI.Computability.DegreeRigidity.Representation.CommonGenericModels + +namespace OAI + +namespace TuringRigidity.FullSetForcing +open TransitiveNameModel BoundedSetTheory ElementaryModel SetDegreeDecoding +open PersistentRestrictions RecursiveNames CountableForcing AtomicForcing +universe u + +theorem persistent_extension_name (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) (htop : ⊤ ∈ G.carrier) + (I : CountableIdeal) (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (hIM : I.carrier ⊆ (modelIdeal M hM hT).carrier) : + let E := genericExtensionSet M c G.carrier + let hE := genericExtensionSet_transitive M c hM G.carrier + let hTE := extension_sourceT M hM hT hc hoM ho G hG htop + let J := modelIdeal E hE hTE + ∃ hIJ : I.carrier ⊆ J.carrier, ∃ σ : J ≃o J, + Extends hIJ ρ σ ∧ Persistent J σ ∧ + ∃ t : Name (Conditions c), t.encode (label c) ∈ M ∧ t.val G.carrier = automorphismSet σ := by + intro E hE hTE J + have hME := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier htop + have hIJ : I.carrier ⊆ J.carrier := by + intro d hd + obtain ⟨A,hA,rfl⟩ := hIM hd + refine ⟨A,?_,rfl⟩ + change realCode A ∈ E + exact hME hA + obtain ⟨σ,he,hσ,hσE⟩ := RelativeConstructible.persistent_extension_in_model E hE hTE I ρ hρ hz hIJ + obtain ⟨t,ht,hval⟩ := (mem_extensionSet M c G.carrier _).mp hσE + exact ⟨hIJ,σ,he,hσ,t,ht,hval⟩ + +theorem model_automorphism_output_name (M c : ZFSet.{u}) [Countable (Conditions M)] + (G : Set (Conditions c)) + (hE : Transitive (genericExtensionSet M c G)) (hTE : SourceT (genericExtensionSet M c G)) + (σ : modelIdeal (genericExtensionSet M c G) hE hTE ≃o + modelIdeal (genericExtensionSet M c G) hE hTE) + (A : Oracle) (hA : A ∈ modelReals (genericExtensionSet M c G)) : + ∃ B : Oracle, ∃ t : Name (Conditions c), + t.encode (label c) ∈ M ∧ t.val G = realCode B ∧ + degree B = (σ ⟨degree A,⟨A,hA,rfl⟩⟩).val := by + obtain ⟨B,hB,hdegree⟩ := (σ ⟨degree A,⟨A,hA,rfl⟩⟩).property + obtain ⟨t,ht,hval⟩ := (mem_extensionSet M c G (realCode B)).mp hB + exact ⟨B,t,ht,hval,hdegree⟩ + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentLocality.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentLocality.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b8c4f0f1fdae6039af996b8113d30fffbfade44 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentLocality.lean @@ -0,0 +1,62 @@ +import OAI.Computability.DegreeRigidity.SetModels.IdealLocality +import OAI.Computability.DegreeRigidity.Constructibility.PersistentRestrictions +import OAI.Computability.DegreeRigidity.SetModels.CountableBound + +namespace OAI + +namespace TuringRigidity.PersistentLocality +open IdealInterpretation IdealLocality PersistentRestrictions OracleJump +noncomputable section + +def ideal (I : CountableIdeal) : DegreeIdeal := + ⟨I.carrier,I.nonempty,fun {_ _} h hmem => I.lower h hmem, + fun {_ _} h₁ h₂ => I.join_mem h₁ h₂⟩ + +def bridge (I : CountableIdeal) : I ≃o ideal I where + toFun x := ⟨x.val,x.property⟩ + invFun x := ⟨x.val,x.property⟩ + left_inv _ := rfl + right_inv _ := rfl + map_rel_iff' := Iff.rfl + +def lift {I : CountableIdeal} (ρ : I ≃o I) : ideal I ≃o ideal I := + (bridge I).symm.trans (ρ.trans (bridge I)) + +def unlift {I : CountableIdeal} (ρ : ideal I ≃o ideal I) : I ≃o I := + (bridge I).trans (ρ.trans (bridge I).symm) + +theorem extends_symm {I K : CountableIdeal} {hIK : I.carrier ⊆ K.carrier} + {ρ : I ≃o I} {σ : K ≃o K} (he : Extends hIK ρ σ) : + Extends hIK ρ.symm σ.symm := by + intro x + have h : σ ⟨(ρ.symm x).val,hIK (ρ.symm x).property⟩ = ⟨x.val,hIK x.property⟩ := by + apply Subtype.ext + exact (he (ρ.symm x)).trans (congrArg Subtype.val (ρ.apply_symm_apply x)) + have hh := congrArg (fun y => (σ.symm y).val) h + simpa only [σ.symm_apply_apply] using hh.symm + +theorem source_4_1_5 (I J : CountableIdeal) (ρ : I ≃o I) + (hp : Persistent I ρ) (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (hIJ : I.carrier ⊆ J.carrier) (hjump : JumpClosed (ideal J)) : + ∃ σ : J ≃o J, Extends hIJ ρ σ := by + obtain ⟨b,hb⟩ := CountableBound.countable_bounded J.carrier J.countable + obtain ⟨K,hIK,τ,hbK,he⟩ := hp b + have hJK : J.carrier ⊆ K.carrier := fun x hx => K.lower (hb x hx) hbK + let z : I := ⟨degree (jump FixedArithmetic.zero),hz⟩ + let zK : ideal K := ⟨z.val,hIK z.property⟩ + have hforward : ((lift τ) zK).val ∈ J.carrier := by + change (τ ⟨z.val,hIK z.property⟩).val ∈ J.carrier + rw [he z] + exact hIJ (ρ z).property + have hback : ((lift τ).symm zK).val ∈ J.carrier := by + change (τ.symm ⟨z.val,hIK z.property⟩).val ∈ J.carrier + rw [extends_symm he z] + exact hIJ (ρ.symm z).property + obtain ⟨σ,hσ⟩ := source_4_1_4 (lift τ) zK rfl hJK hjump (J.join_mem hforward hback) + refine ⟨unlift σ,fun x => ?_⟩ + exact (hσ ⟨x.val,hIJ x.property⟩).trans (he x) + +end +end TuringRigidity.PersistentLocality + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentNonidentity.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentNonidentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..b71eef4b328dd9e9249f36a05b1348004d3a7b3b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentNonidentity.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticCoanalytic + +namespace OAI + +namespace TuringRigidity.ArithmeticPersistence +open EncodedForcing OracleJump UniformArithmetic PersistentRestrictions +open PersistentPresentation PersistentCountability NumericalAutomorphism +noncomputable section + +def Moved (A R : Oracle) : Prop := + ∃ n m, R (Nat.pair n m) = true ∧ degree (columns A n) ≠ degree (columns A m) + +theorem moved_iff {I : CountableIdeal} {A R : Oracle} (hA : Presented I A) + (ρ : I ≃o I) (hR : ∀ v, R v = true ↔ Graph ρ hA v) : + Moved A R ↔ ∃ x : I, ρ x ≠ x := by + constructor + · rintro ⟨n,m,hr,hne⟩ + refine ⟨entry hA n,fun he => ?_⟩ + have hg := (hR (Nat.pair n m)).mp hr + simp only [PersistentPresentation.Graph,Nat.unpair_pair] at hg + exact hne ((congrArg Subtype.val he).symm.trans hg) + · rintro ⟨x,hx⟩ + obtain ⟨n,hn⟩ := (hA x.val).mp x.property + obtain ⟨m,hm⟩ := (hA (ρ x).val).mp (ρ x).property + have he : entry hA n = x := Subtype.ext hn + refine ⟨n,m,(hR _).mpr ?_,?_⟩ + · simp only [PersistentPresentation.Graph,Nat.unpair_pair] + rw [he,hm] + · intro hh + apply hx + apply Subtype.ext + exact hm.symm.trans (hh.symm.trans hn) + +theorem moved_arith : Arith (fun O (_ : ℕ) => Moved (O 0) (O 1)) := by + have hp := query_at (parameter_arith 1) (Primrec.const 0) + (Primrec₂.natPair.comp (UniformArithmetic.right_primrec.comp UniformArithmetic.left_primrec) + UniformArithmetic.right_primrec) + have he := degree_equal_arith + (column_arith (parameter_arith 0) (UniformArithmetic.right_primrec.comp UniformArithmetic.left_primrec)) + (column_arith (parameter_arith 0) UniformArithmetic.right_primrec) + exact (hp.and he.neg).ex.ex.congr + (fun _ _ => by simp only [Moved,UniformArithmetic.left,UniformArithmetic.right,Nat.unpair_pair]) + +theorem nonidentity_piOneOne : PiOneOne (fun A R => Property A R ∧ Moved A R) := by + obtain ⟨Q,hQ,hiff⟩ := source_4_2_1 + refine ⟨fun O v => Q O v ∧ Moved (O 0) (O 1),hQ.and moved_arith,fun A R => ?_⟩ + dsimp only + rw [hiff] + change ((∀ H, Q (parameters A R H) 0) ∧ Moved A R) ↔ + ∀ H, Q (parameters A R H) 0 ∧ Moved A R + exact ⟨fun h H => ⟨h.1 H,h.2⟩,fun h => ⟨fun H => (h H).1,(h FixedArithmetic.zero).2⟩⟩ + +theorem nonidentity_coanalytic : MeasureTheory.AnalyticSet + ({x : Oracle × Oracle | Property x.1 x.2 ∧ Moved x.1 x.2}ᶜ) := + nonidentity_piOneOne.coanalytic + +theorem nonrigidity_witness (h : ¬ MainTheorem) : + ∃ A R : Oracle, Property A R ∧ Moved A R := by + classical + simp only [MainTheorem,not_forall] at h + obtain ⟨π,x,hx⟩ := h + let z := degree (jump FixedArithmetic.zero) + obtain ⟨I,hi,hf,hb⟩ := countable_invariant_hull π {x,z} (Set.toFinite _).countable + let ρ := restrict π I hf hb + have hρ : RestrictsTo π I ρ := fun _ => rfl + have hp : Persistent I ρ := persistent_of_global_restriction π I ρ hρ + have hz : z ∈ I.carrier := hi (by simp) + have hxi : x ∈ I.carrier := hi (by simp) + have hn : ∃ a : I, ρ a ≠ a := by + refine ⟨⟨x,hxi⟩,fun he => ?_⟩ + exact hx (congrArg Subtype.val he) + obtain ⟨A,hA⟩ := presentation_exists I + let R := graphOracle hA ρ + have hR : ∀ v, R v = true ↔ Graph ρ hA v := fun v => by simp [R,graphOracle] + exact ⟨A,R,⟨I,hA,hz,ρ,hR,hp⟩,(moved_iff hA ρ hR).mpr hn⟩ + +end +end TuringRigidity.ArithmeticPersistence + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentOneRealDefinition.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentOneRealDefinition.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8ce82360ccd0c5e68bee4c8fee7c29b16f55b2c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentOneRealDefinition.lean @@ -0,0 +1,41 @@ +import OAI.Computability.DegreeRigidity.Constructibility.OneRealConstructionDefinition +import OAI.Computability.DegreeRigidity.Constructibility.PersistentConstruction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel SetDegreeDecoding PersistentRestrictions OrdinalCoding +universe u + +theorem persistent_graph_one_real_definition (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) + (hρ : Persistent (modelIdeal M hM hT) ρ) : + ∃ (δ : Ordinal.{u}) (P : Oracle) (p : SentenceForm), + δ.toZFSet ∈ M ∧ P ∈ modelReals M ∧ p.bound ≤ 2 ∧ + realCode P ∈ level (groundReals M) δ ∧ + automorphismSet ρ = definedSubset (level (groundReals M) δ) p + (fun _ : Fin p.bound => realCode P) := by + obtain ⟨t,P,hP,hi,ht,hval⟩ := persistent_graph_construction M hM hT ρ hρ + obtain ⟨p,hbound,hdef⟩ := t.cofinal_one_real_definition + obtain ⟨β,_,_,_,hidx,hreal,hset⟩ := hdef M hM hT P hP ht hi 0 (internal_ordinal_zero M hM hT) + exact ⟨heightDomainIndex (paddedCode t.ordinalVector β),P,p,hidx,hP,hbound,hreal,hval ▸ hset⟩ + +theorem persistent_extension_one_real_definition (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) + (I : CountableIdeal) (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (hIM : I.carrier ⊆ (modelIdeal M hM hT).carrier) : + ∃ σ : modelIdeal M hM hT ≃o modelIdeal M hM hT, + Extends hIM ρ σ ∧ Persistent (modelIdeal M hM hT) σ ∧ + ∃ (δ : Ordinal.{u}) (P : Oracle) (p : SentenceForm), + δ.toZFSet ∈ M ∧ P ∈ modelReals M ∧ p.bound ≤ 2 ∧ + realCode P ∈ level (groundReals M) δ ∧ + automorphismSet σ = definedSubset (level (groundReals M) δ) p + (fun _ : Fin p.bound => realCode P) := by + obtain ⟨σ,he,hσ,_⟩ := persistent_extension_construction M hM hT I ρ hρ hz hIM + exact ⟨σ,he,hσ,persistent_graph_one_real_definition M hM hT σ hσ⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentPresentation.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..36fe41268d763d801b7a7f989b7af2c37258d2a2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentPresentation.lean @@ -0,0 +1,58 @@ +import OAI.Computability.DegreeRigidity.Computability.JumpIdeal +import OAI.Computability.DegreeRigidity.SetModels.IdealPresentation + +namespace OAI + +namespace TuringRigidity.PersistentPresentation +open EncodedForcing OracleJump ArithmeticHierarchy IdealInterpretation IdealLocality PersistentRestrictions PersistentLocality +noncomputable section + +def Presented (I : CountableIdeal) (H : Oracle) : Prop := + ∀ x, x ∈ I.carrier ↔ ∃ k, degree (columns H k) = x + +def entry {I : CountableIdeal} {H : Oracle} (hpres : Presented I H) (n : ℕ) : I := + ⟨degree (columns H n),(hpres _).mpr ⟨n,rfl⟩⟩ + +def Graph {I : CountableIdeal} (ρ : I ≃o I) {H : Oracle} (hpres : Presented I H) (v : ℕ) : Prop := + (ρ (entry hpres (Nat.unpair v).1)).val = degree (columns H (Nat.unpair v).2) + +theorem source_4_1_8 {I : CountableIdeal} (ρ : I ≃o I) (hp : Persistent I ρ) + (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + {H : Oracle} (hpres : Presented I H) : + Sigma (iterate H 6) 5 (Graph ρ hpres) ∧ RecursivePred (iterate H 11) (Graph ρ hpres) := by + let J := JumpIdeal.generated (degree H) + have hH : degree H ∈ J.carrier := JumpIdeal.includes _ + have hIJ : I.carrier ⊆ J.carrier := by + intro x hx + obtain ⟨k,rfl⟩ := (hpres x).mp hx + exact J.lower (CodingExtraction.column_projection_reduces H k) hH + obtain ⟨σ,he⟩ := source_4_1_5 I J ρ hp hz hIJ (JumpIdeal.closed _) + have hinv : ∀ x : ideal J, ((lift σ) x).val ∈ I.carrier ↔ x.val ∈ I.carrier := by + intro x + constructor + · intro hx + let y : I := ⟨((lift σ) x).val,hx⟩ + have hh := extends_symm he y + have hh' : (σ.symm (σ ((bridge J).symm x))).val = (ρ.symm y).val := hh + rw [σ.symm_apply_apply] at hh' + change x.val = (ρ.symm y).val at hh' + rw [hh'] + exact (ρ.symm y).property + · intro hx + have hh := he ⟨x.val,hx⟩ + change ((lift σ) x).val = (ρ ⟨x.val,hx⟩).val at hh + rw [hh] + exact (ρ ⟨x.val,hx⟩).property + have hg := (IdealPresentation.source_4_1_7 (ideal I) (ideal J) H (lift σ) + hpres hz hH (JumpIdeal.closed _) hinv).1 + have hh : Sigma (iterate H 6) 5 (Graph ρ hpres) := hg.congr (fun v => by + change (σ ⟨degree (columns H (Nat.unpair v).1),_⟩).val = _ ↔ _ + exact Iff.of_eq (congrArg (fun x : Degree => x = degree (columns H (Nat.unpair v).2)) + (he (entry hpres (Nat.unpair v).1)))) + have hr := form_recursive hh + exact ⟨hh,hr⟩ + +end +end TuringRigidity.PersistentPresentation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentRestrictionCode.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentRestrictionCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..e92398fafdd3f58d0305d8c50ad46e333aef325a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentRestrictionCode.lean @@ -0,0 +1,59 @@ +import OAI.Computability.DegreeRigidity.Constructibility.PersistentCountability + +namespace OAI + +namespace TuringRigidity.PersistentRestrictionCode +open EncodedForcing OracleJump ArithmeticHierarchy IdealInterpretation IdealLocality +open PersistentRestrictions PersistentLocality PersistentPresentation +noncomputable section + +theorem restriction {I J K : CountableIdeal} (ρ : I ≃o I) (τ : K ≃o K) + (hIK : I.carrier ⊆ K.carrier) (he : Extends hIK ρ τ) + (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (hIJ : I.carrier ⊆ J.carrier) (hJK : J.carrier ⊆ K.carrier) + (hj : JumpClosed (ideal J)) {H : Oracle} (hpres : Presented J H) + (hLK : (JumpIdeal.generated (degree H)).carrier ⊆ K.carrier) : + ∃ σ : J ≃o J, Extends hIJ ρ σ ∧ Extends hJK σ τ ∧ + RecursivePred (iterate H 11) (Graph σ hpres) := by + let L := JumpIdeal.generated (degree H) + have hH : degree H ∈ L.carrier := JumpIdeal.includes _ + have hJL : J.carrier ⊆ L.carrier := by + intro x hx + obtain ⟨n,rfl⟩ := (hpres x).mp hx + exact L.lower (CodingExtraction.column_projection_reduces H n) hH + let z : I := ⟨degree (jump FixedArithmetic.zero),hz⟩ + let zK : ideal K := ⟨z.val,hIK z.property⟩ + have hforward : ((lift τ) zK).val ∈ J.carrier := by + change (τ ⟨z.val,hIK z.property⟩).val ∈ J.carrier + rw [he z] + exact hIJ (ρ z).property + have hback : ((lift τ).symm zK).val ∈ J.carrier := by + change (τ.symm ⟨z.val,hIK z.property⟩).val ∈ J.carrier + rw [extends_symm he z] + exact hIJ (ρ.symm z).property + have himages := J.join_mem hforward hback + obtain ⟨σJ,hσJ⟩ := source_4_1_4 (lift τ) zK rfl hJK hj himages + obtain ⟨σL,hσL⟩ := source_4_1_4 (lift τ) zK rfl hLK (JumpIdeal.closed _) (hJL himages) + let σ := unlift σJ + have hτ : Extends hJK σ τ := fun x => (hσJ ((bridge J) x)).symm + have hρ : Extends hIJ ρ σ := by + intro x + exact (hσJ ⟨x.val,hIJ x.property⟩).trans (he x) + have hinv : ∀ x : ideal L, (σL x).val ∈ J.carrier ↔ x.val ∈ J.carrier := by + intro x + rw [hσL x] + exact invariant (lift τ) zK rfl hj himages ⟨x.val,hLK x.property⟩ + have hg := (IdealPresentation.source_4_1_7 (ideal J) (ideal L) H σL hpres + (hIJ hz) hH (JumpIdeal.closed _) hinv).1 + have hh : Sigma (iterate H 6) 5 (Graph σ hpres) := hg.congr (fun v => by + have ha := hσL (IdealPresentation.entry H hH (Nat.unpair v).1) + have hb := hτ (entry hpres (Nat.unpair v).1) + exact Iff.of_eq (congrArg (fun x : Degree => x = degree (columns H (Nat.unpair v).2)) + (ha.trans hb))) + have hr := form_recursive hh + exact ⟨σ,hρ,hτ,hr⟩ + +end +end TuringRigidity.PersistentRestrictionCode + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentRestrictions.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentRestrictions.lean new file mode 100644 index 0000000000000000000000000000000000000000..c887c1520c874440c2c8d4cd639924a3737bf7c7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/PersistentRestrictions.lean @@ -0,0 +1,167 @@ +import OAI.Computability.DegreeRigidity.Computability.Joins + +namespace OAI + +namespace TuringRigidity.PersistentRestrictions +open Set + +theorem countable_principal_lower (a : Degree) : (Set.Iic a).Countable := by + obtain ⟨A, rfl⟩ := degree_surjective a + apply ((countable_reduces A).image degree).mono + intro b hb + obtain ⟨B, rfl⟩ := degree_surjective b + exact ⟨B, (degree_le_iff B A).mp hb, rfl⟩ + +structure CountableIdeal where + carrier : Set Degree + nonempty : carrier.Nonempty + countable : carrier.Countable + lower : ∀ ⦃a b : Degree⦄, a ≤ b → b ∈ carrier → a ∈ carrier + join_mem : ∀ ⦃a b : Degree⦄, a ∈ carrier → b ∈ carrier → a ⊔ b ∈ carrier + +instance : CoeSort CountableIdeal Type := ⟨fun I => {a : Degree // a ∈ I.carrier}⟩ + +def closureStep (π : Degree ≃o Degree) (S : Set Degree) : Set Degree := + S ∪ (π '' S ∪ (π.symm '' S ∪ + (Set.image2 (· ⊔ ·) S S ∪ ⋃ a ∈ S, Set.Iic a))) + +theorem countable_closureStep (π : Degree ≃o Degree) {S : Set Degree} + (hS : S.Countable) : (closureStep π S).Countable := + hS.union ((hS.image π).union ((hS.image π.symm).union + ((hS.image2 hS (· ⊔ ·)).union (hS.biUnion fun a _ => countable_principal_lower a)))) + +def stage (π : Degree ≃o Degree) (S : Set Degree) : ℕ → Set Degree + | 0 => insert ⊥ S + | n + 1 => closureStep π (stage π S n) + +theorem countable_stage (π : Degree ≃o Degree) {S : Set Degree} + (hS : S.Countable) : ∀ n, (stage π S n).Countable + | 0 => hS.insert ⊥ + | n + 1 => countable_closureStep π (countable_stage π hS n) + +theorem stage_mono (π : Degree ≃o Degree) (S : Set Degree) : Monotone (stage π S) := by + apply monotone_nat_of_le_succ + intro n a ha + exact Or.inl ha + +def hullSet (π : Degree ≃o Degree) (S : Set Degree) : Set Degree := ⋃ n, stage π S n + +theorem subset_hullSet (π : Degree ≃o Degree) (S : Set Degree) : S ⊆ hullSet π S := by + intro a ha + exact Set.mem_iUnion.mpr ⟨0, Or.inr ha⟩ + +theorem hullSet_lower (π : Degree ≃o Degree) (S : Set Degree) + {a b : Degree} (hab : a ≤ b) (hb : b ∈ hullSet π S) : a ∈ hullSet π S := by + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp hb + apply Set.mem_iUnion.mpr + refine ⟨n + 1, Or.inr (Or.inr (Or.inr (Or.inr ?_)))⟩ + exact Set.mem_iUnion.mpr ⟨b, Set.mem_iUnion.mpr ⟨hn, hab⟩⟩ + +theorem hullSet_join (π : Degree ≃o Degree) (S : Set Degree) + {a b : Degree} (ha : a ∈ hullSet π S) (hb : b ∈ hullSet π S) : + a ⊔ b ∈ hullSet π S := by + obtain ⟨m, hm⟩ := Set.mem_iUnion.mp ha + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp hb + apply Set.mem_iUnion.mpr + refine ⟨max m n + 1, Or.inr (Or.inr (Or.inr (Or.inl ?_)))⟩ + exact ⟨a, stage_mono π S (le_max_left m n) hm, + b, stage_mono π S (le_max_right m n) hn, rfl⟩ + +theorem hullSet_forward (π : Degree ≃o Degree) (S : Set Degree) + {a : Degree} (ha : a ∈ hullSet π S) : π a ∈ hullSet π S := by + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp ha + exact Set.mem_iUnion.mpr ⟨n + 1, Or.inr (Or.inl ⟨a, hn, rfl⟩)⟩ + +theorem hullSet_backward (π : Degree ≃o Degree) (S : Set Degree) + {a : Degree} (ha : a ∈ hullSet π S) : π.symm a ∈ hullSet π S := by + obtain ⟨n, hn⟩ := Set.mem_iUnion.mp ha + exact Set.mem_iUnion.mpr ⟨n + 1, Or.inr (Or.inr (Or.inl ⟨a, hn, rfl⟩))⟩ + +def invariantHull (π : Degree ≃o Degree) (S : Set Degree) (hS : S.Countable) : + CountableIdeal where + carrier := hullSet π S + nonempty := ⟨⊥, Set.mem_iUnion.mpr ⟨0, Or.inl rfl⟩⟩ + countable := Set.countable_iUnion (countable_stage π hS) + lower := fun {_ _} hab hb => hullSet_lower π S hab hb + join_mem := fun {_ _} ha hb => hullSet_join π S ha hb + +theorem countable_invariant_hull (π : Degree ≃o Degree) (S : Set Degree) + (hS : S.Countable) : ∃ J : CountableIdeal, S ⊆ J.carrier ∧ + (∀ a ∈ J.carrier, π a ∈ J.carrier) ∧ + (∀ a ∈ J.carrier, π.symm a ∈ J.carrier) := by + exact ⟨invariantHull π S hS, subset_hullSet π S, + fun _ ha => hullSet_forward π S ha, fun _ ha => hullSet_backward π S ha⟩ + +def restrict (π : Degree ≃o Degree) (I : CountableIdeal) + (hf : ∀ a ∈ I.carrier, π a ∈ I.carrier) + (hb : ∀ a ∈ I.carrier, π.symm a ∈ I.carrier) : I ≃o I where + toFun a := ⟨π a.val, hf a.val a.property⟩ + invFun a := ⟨π.symm a.val, hb a.val a.property⟩ + left_inv a := Subtype.ext (π.symm_apply_apply a.val) + right_inv a := Subtype.ext (π.apply_symm_apply a.val) + map_rel_iff' := π.map_rel_iff + +def Extends {I J : CountableIdeal} (hIJ : I.carrier ⊆ J.carrier) + (ρ : I ≃o I) (σ : J ≃o J) : Prop := + ∀ a : I, (σ ⟨a.val, hIJ a.property⟩).val = (ρ a).val + +def Persistent (I : CountableIdeal) (ρ : I ≃o I) : Prop := + ∀ x : Degree, ∃ (J : CountableIdeal) (hIJ : I.carrier ⊆ J.carrier) + (σ : J ≃o J), x ∈ J.carrier ∧ Extends hIJ ρ σ + +def RestrictsTo (π : Degree ≃o Degree) (I : CountableIdeal) (ρ : I ≃o I) : Prop := + ∀ a : I, π a.val = (ρ a).val + +theorem persistent_of_global_restriction (π : Degree ≃o Degree) + (I : CountableIdeal) (ρ : I ≃o I) (hρ : RestrictsTo π I ρ) : Persistent I ρ := by + intro x + obtain ⟨J, hS, hf, hb⟩ := countable_invariant_hull π (insert x I.carrier) + (I.countable.insert x) + let hIJ : I.carrier ⊆ J.carrier := fun _ ha => hS (Or.inr ha) + refine ⟨J, hIJ, restrict π J hf hb, hS (Or.inl rfl), ?_⟩ + intro a + exact hρ a + +theorem global_restriction_set_extension (π : Degree ≃o Degree) + (S : Set Degree) (hS : S.Countable) (ρ : S ≃o S) + (hρ : ∀ a : S, π a.val = (ρ a).val) (x : Degree) : + ∃ (J : CountableIdeal) (hSJ : S ⊆ J.carrier) (σ : J ≃o J), + x ∈ J.carrier ∧ ∀ a : S, (σ ⟨a.val, hSJ a.property⟩).val = (ρ a).val := by + obtain ⟨J, h, hf, hb⟩ := countable_invariant_hull π (insert x S) (hS.insert x) + exact ⟨J, fun _ ha => h (Or.inr ha), restrict π J hf hb, h (Or.inl rfl), hρ⟩ + +theorem persistent_countable_extension (π : Degree ≃o Degree) + (I : CountableIdeal) (ρ : I ≃o I) (hρ : RestrictsTo π I ρ) + (S : Set Degree) (hS : S.Countable) : + ∃ (J : CountableIdeal) (hIJ : I.carrier ⊆ J.carrier) (σ : J ≃o J), + S ⊆ J.carrier ∧ Extends hIJ ρ σ ∧ RestrictsTo π J σ ∧ Persistent J σ := by + obtain ⟨J, h, hf, hb⟩ := countable_invariant_hull π (I.carrier ∪ S) + (I.countable.union hS) + let σ := restrict π J hf hb + have hσ : RestrictsTo π J σ := fun _ => rfl + exact ⟨J, fun _ ha => h (Or.inl ha), σ, fun _ ha => h (Or.inr ha), + hρ, hσ, persistent_of_global_restriction π J σ hσ⟩ + +theorem nontrivial_persistent_restriction (π : Degree ≃o Degree) + (x : Degree) (hx : π x ≠ x) : + ∃ (I : CountableIdeal) (ρ : I ≃o I), + RestrictsTo π I ρ ∧ Persistent I ρ ∧ ∃ a : I, ρ a ≠ a := by + obtain ⟨I, h, hf, hb⟩ := countable_invariant_hull π {x} (Set.countable_singleton x) + let ρ := restrict π I hf hb + have hρ : RestrictsTo π I ρ := fun _ => rfl + refine ⟨I, ρ, hρ, persistent_of_global_restriction π I ρ hρ, + ⟨x, h (Set.mem_singleton x)⟩, ?_⟩ + intro heq + exact hx (congrArg Subtype.val heq) + +theorem nonrigidity_has_nontrivial_persistent (h : ¬ MainTheorem) : + ∃ (I : CountableIdeal) (ρ : I ≃o I), Persistent I ρ ∧ ∃ a : I, ρ a ≠ a := by + classical + simp only [MainTheorem, not_forall] at h + obtain ⟨π, x, hx⟩ := h + obtain ⟨I, ρ, _, hp, hn⟩ := nontrivial_persistent_restriction π x hx + exact ⟨I, ρ, hp, hn⟩ + +end TuringRigidity.PersistentRestrictions + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeCohenJump.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeCohenJump.lean new file mode 100644 index 0000000000000000000000000000000000000000..350a3c28c56b59cd648f49bf6f4e99f621d4825a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeCohenJump.lean @@ -0,0 +1,75 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.CohenLowness + +namespace OAI + +namespace TuringRigidity.RelativeCohenJump +open Encodable UniformOracle CommonIdeal ArithmeticHierarchy OracleJump EncodedForcing +open CohenHalting EffectiveCohen EffectiveWitness CohenLowness + +theorem deciding_recursive_join (Y G : Oracle) : + RecursivePred (join (jump Y) G) (Deciding Y G) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hp := recursive_comp (recursive_transfer (CohenLowness.prefix_recursive G) (reduces_join_right (jump Y) G)) r + have hh := recursive_comp (recursive_transfer (form_recursive (openHalts_sigma Y)) (reduces_join_left (jump Y) G)) + (Primrec₂.natPair.comp f (Primrec.encode.comp (word_primrec.comp r))) + have hn := recursive_not (recursive_transfer (form_recursive (extension_sigma Y)) (reduces_join_left (jump Y) G)) + unfold Deciding + simpa only [Nat.unpair_pair] using recursive_and hp (Form.or (n := 0) (s := true) hh hn) + +theorem oneGeneric_jump_reduces {Y G : Oracle} (hgen : OneGeneric Y G) : + Reduces (jump (join Y G)) (join (jump Y) G) := by + let D := Deciding Y G + let ht := deciding_total hgen + let pick : ℕ → ℕ := least D ht + have hpick : Nat.RecursiveIn {oracleFunction (join (jump Y) G)} (fun x => Part.some (pick x)) := + least_recursive (deciding_recursive_join Y G) ht + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hin := total_pair (total_primrec Primrec.id) + (total_comp (total_primrec (Primrec.encode.comp word_primrec)) hpick) + have hh := recursive_comp_total (recursive_transfer (form_recursive (openHalts_sigma Y)) + (reduces_join_left (jump Y) G)) hin + apply RecursiveIn.iff_nat.mpr + apply hh.of_eq + intro x + have he := deciding_correct (least_spec D ht x) + classical + simp only [Nat.unpair_pair] + change Part.some (if OpenHalts Y x (encode (word (pick x))) then 1 else 0) = _ + simp only [pick,he,oracleFunction,jump,Bool.decide_iff] + +theorem oneGeneric_jump_degree (Y G : Oracle) (hgen : OneGeneric Y G) : + degree (jump (join Y G)) = degree (join (jump Y) G) := by + apply (degree_eq_iff _ _).mpr + exact ⟨oneGeneric_jump_reduces hgen,join_reduces + (jump_mono (reduces_join_left Y G)) + (reduces_trans (reduces_join_right Y G) (reduces_jump (join Y G)))⟩ + +theorem iterate_join_degree (Y G : Oracle) (k : ℕ) + (hgen : ∀ j < k, OneGeneric (iterate Y j) G) : + degree (iterate (join Y G) k) = degree (join (iterate Y k) G) := by + induction k with + | zero => rfl + | succ k ih => + have hk := ih (fun j hj => hgen j (Nat.lt_succ_of_lt hj)) + calc + degree (iterate (join Y G) (k+1)) = degree (jump (join (iterate Y k) G)) := + congrArg degreeJump hk + _ = degree (join (iterate Y (k+1)) G) := + oneGeneric_jump_degree (iterate Y k) G (hgen k (Nat.lt_succ_self k)) + +theorem iterate_generic_join_degree (G Y : Oracle) (k : ℕ) + (hgen : ∀ j < k, OneGeneric (iterate Y j) G) : + degree (iterate (join G Y) k) = degree (join G (iterate Y k)) := by + have hswap : degree (join G Y) = degree (join Y G) := sup_comm (degree G) (degree Y) + obtain ⟨h₁,h₂⟩ := (degree_eq_iff _ _).mp hswap + calc + degree (iterate (join G Y) k) = degree (iterate (join Y G) k) := + (degree_eq_iff _ _).mpr ⟨iterate_mono h₁ k,iterate_mono h₂ k⟩ + _ = degree (join (iterate Y k) G) := iterate_join_degree Y G k hgen + _ = degree (join G (iterate Y k)) := sup_comm (degree (iterate Y k)) (degree G) + +end TuringRigidity.RelativeCohenJump + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeConstruction.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..341307bd28ac9b2b3e840810f6f38d319db7590e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeConstruction.lean @@ -0,0 +1,116 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteRealPacking +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModel + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel +universe u + +inductive Construction : Type (u+1) + | reals : Construction + | parameter : Construction + | define (o : Ordinal.{u}) (n : ℕ) (p : SentenceForm) + (children : Fin n → Construction) : Construction + +noncomputable def Construction.value (R : ZFSet.{u}) (P : Oracle) : Construction.{u} → ZFSet.{u} + | .reals => R + | .parameter => realCode P + | .define o n p c => definedSubset (level R o) p + (fun i : Fin n => (c i).value R (realPart P i)) + +def Construction.Certified (R : ZFSet.{u}) (P : Oracle) : Construction.{u} → Prop + | .reals => True + | .parameter => realCode P ∈ R + | .define o n p c => p.bound ≤ n+1 ∧ + ∀ i, (c i).Certified R (realPart P i) ∧ (c i).value R (realPart P i) ∈ level R o + +def Construction.Indexed (M : ZFSet.{u}) : Construction.{u} → Prop + | .reals => True + | .parameter => True + | .define o _ _ c => o.toZFSet ∈ M ∧ ∀ i, (c i).Indexed M + +theorem Construction.value_in_relativeL (t : Construction.{u}) (R : ZFSet.{u}) (P : Oracle) + (ht : t.Certified R P) : InRelativeL R (t.value R P) := by + cases t with + | reals => exact parameter_in_relativeL R + | parameter => exact relativeL_transitive R (parameter_in_relativeL R) ht + | define o n p c => + refine ⟨o+1,?_⟩ + rw [level_succ,mem_definablePower] + exact ⟨n,p,_,ht.1,fun i => (ht.2 i).2,rfl⟩ + +theorem Construction.value_in_relativeModel (t : Construction.{u}) (M R : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (P : Oracle) + (ht : t.Certified R P) (hi : t.Indexed M) : InRelativeModel M R (t.value R P) := by + cases t with + | reals => exact parameter_in_relativeModel M R hM hT + | parameter => exact (parameter_in_relativeModel M R hM hT).transitive ht + | define o n p c => + refine ⟨o+1,internal_ordinal_succ M hM hT o hi.1,?_⟩ + rw [level_succ,mem_definablePower] + exact ⟨n,p,_,ht.1,fun i => (ht.2 i).2,rfl⟩ + +theorem ground_seed_shape (M : ZFSet.{u}) (hM : Transitive M) : + seed (groundReals M) = insert (groundReals M) (groundReals M) := by + let R := groundReals M + have htrans : Transitive (insert R R) := by + intro a ha b hb + rcases ZFSet.mem_insert_iff.mp ha with rfl|ha + · exact ZFSet.mem_insert_iff.mpr (Or.inr hb) + · obtain ⟨haM,haω⟩ := (mem_groundReals M a).mp ha + have hbω := haω hb + have hbsub : b ⊆ ZFSet.omega := fun z hz => omega_transitive b hbω z hz + exact ZFSet.mem_insert_iff.mpr (Or.inr ((mem_groundReals M b).mpr ⟨hM a haM b hb,hbsub⟩)) + apply ZFSet.ext; intro x + constructor + · exact fun hx => seed_minimal R _ htrans (ZFSet.mem_insert R R) hx + · intro hx + rcases ZFSet.mem_insert_iff.mp hx with rfl|hx + · exact parameter_mem_seed R + · exact parameter_subset_seed R hx + +theorem construction_of_level (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (o : Ordinal.{u}) (ho : o.toZFSet ∈ M) (x : ZFSet.{u}) + (hx : x ∈ level (groundReals M) o) : + ∃ t : Construction.{u}, ∃ P : Oracle, P ∈ modelReals M ∧ + t.Indexed M ∧ t.Certified (groundReals M) P ∧ t.value (groundReals M) P = x := by + induction o using WellFoundedLT.induction generalizing x with + | ind o ih => + rcases (mem_stage (groundReals M) o.toZFSet x).mp hx with hx|⟨a,ha,hx⟩ + · rw [ground_seed_shape M hM] at hx + rcases ZFSet.mem_insert_iff.mp hx with rfl|hx + · exact ⟨.reals,FixedArithmetic.zero,sourceT_zero_real M hM hT,trivial,trivial,rfl⟩ + · obtain ⟨hxM,hxω⟩ := (mem_groundReals M x).mp hx + have he := realCode_decodeReal hxω + refine ⟨.parameter,decodeReal x,?_,trivial,?_,he⟩ + · change realCode (decodeReal x) ∈ M + rwa [he] + · change realCode (decodeReal x) ∈ groundReals M + rwa [he] + · obtain ⟨a,hao,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ha + obtain ⟨n,p,v,hb,hv,rfl⟩ := (mem_definablePower _ x).mp hx + have hc (i : Fin n) := ih a hao (hM _ ho _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hao)) + (v i) (hv i) + choose c Q hQ hi ht he using hc + refine ⟨.define a n p c,packedReal Q,packedReal_internal M hM hT Q hQ, + ⟨hM _ ho _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hao),hi⟩,?_,?_⟩ + · refine ⟨hb,fun i => ?_⟩ + rw [realPart_packed] + exact ⟨ht i,(he i).symm ▸ hv i⟩ + · change definedSubset _ p _ = definedSubset _ p v + congr 1 + funext i + rw [realPart_packed,he] + +theorem construction_of_relativeModel (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (x : ZFSet.{u}) (hx : x ∈ relativeModel M (groundReals M)) : + ∃ t : Construction.{u}, ∃ P : Oracle, P ∈ modelReals M ∧ + t.Indexed M ∧ t.Certified (groundReals M) P ∧ t.value (groundReals M) P = x := by + obtain ⟨_,o,ho,hx⟩ := ZFSet.mem_sep.mp hx + exact construction_of_level M hM hT o ho x hx + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeDefCertificates.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeDefCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..deeb4b598cde819caf85573638d9c1439c5c52a3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeDefCertificates.lean @@ -0,0 +1,63 @@ +import OAI.Computability.DegreeRigidity.Syntax.CheckedDefSuccessor + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +theorem ground_relative_context (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + Context (relativeModel M (groundReals M)) := by + have hR := groundReals_mem M hM hT + exact ⟨relativeModel_transitive M _ hM,relativeModel_pairing M _ hM hT hR, + relativeModel_union M _ hM hT hR,relativeModel_power_set M _ hM hT hR, + relativeModel_bounded_separation M _ hM hT hR,ground_relativeModel_infinity M hM hT⟩ + +theorem checked_successor_at_level (M A : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ relativeModel M (groundReals M)) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ + ∀ δ : Ordinal.{u}, δ.toZFSet ∈ M → γ ≤ δ → + A ∈ level (groundReals M) δ ∧ definablePower A ∈ level (groundReals M) δ ∧ + ∀ D : ZFSet.{u}, CheckedDefSuccessor (level (groundReals M) δ) ZFSet.omega + (ZFSet.prod ZFSet.omega ZFSet.omega) A D ↔ D = definablePower A := by + let R := groundReals M + let N := relativeModel M R + have hR := groundReals_mem M hM hT + have C := ground_relative_context M hM hT + obtain ⟨B,hB,hbounds,hq,hb⟩ := relative_certificate_bounds M hM hT + obtain ⟨G,hG,T,hTT,H,hH,Z,hZ,hd⟩ := internal_defSystem_of_context N C R B A hA hq hb + have hD := definablePower_mem_of_context N A C hA + let e := cons R (cons B (cons A (cons (definablePower A) + (cons G (cons T (cons H (fun _ => Z))))))) + have he (i : ℕ) (_hi : i < 8) : InRelativeModel M R (e i) := by + apply (mem_relativeModel M R _ hM hT hR).mp + rcases i with _|_|_|_|_|_|_|i + · exact (mem_relativeModel M R R hM hT hR).mpr (parameter_in_relativeModel M R hM hT) + · exact hB + · exact hA + · exact hD + · exact hG + · exact hTT + · exact hH + · exact hZ + obtain ⟨γ,hγ,hγe⟩ := finite_parameters_in_relative_level M R hM hT e 8 he + refine ⟨γ,hγ,?_⟩ + intro δ hδ hγδ + have hin (i : ℕ) (hi : i < 8) : e i ∈ level R δ := level_mono R hγδ (hγe i hi) + have hsub : level R δ ⊆ N := fun x hx => + (mem_relativeModel M R x hM hT hR).mpr ⟨δ,hδ,hx⟩ + have hbound := hbounds.between (level_transitive R δ) hsub (hin 0 (by decide)) (hin 1 (by decide)) + refine ⟨hin 2 (by decide),hin 3 (by decide),?_⟩ + intro D + constructor + · exact CheckedDefSuccessor.sound + (fun p => level_transitive R δ R (hin 0 (by decide)) _ (hq p)) + (fun p => level_transitive R δ B (hin 1 (by decide)) _ (hb p)) + · rintro rfl + exact ⟨R,hin 0 (by decide),B,hin 1 (by decide),hbound, + G,hin 4 (by decide),T,hin 5 (by decide),H,hin 6 (by decide),Z,hin 7 (by decide),hd⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeDegreeIdeal.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeDegreeIdeal.lean new file mode 100644 index 0000000000000000000000000000000000000000..0517c981d56203d86bedf6ac4f2dcfef4b4a4dcc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeDegreeIdeal.lean @@ -0,0 +1,50 @@ +import OAI.Computability.DegreeRigidity.SetModels.DegreeUniverseWithoutChoice +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModelComparison +import OAI.Computability.DegreeRigidity.SetModels.ElementaryModelIdeal +import OAI.Computability.DegreeRigidity.Representation.NativeModelCompatibility + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel SetDegreeDecoding +universe u + +theorem ground_degreeUniverse_eq_idealSet (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) : + degreeUniverse (groundReals M) = idealSet (modelIdeal M hM hT) := by + have eq (A : Oracle) (hA : A ∈ modelReals M) := + degreeCode_eq_degreeSet M hM hT (groundReals M) (realCode_mem_groundReals M) hA + apply ZFSet.ext; intro x + rw [mem_degreeUniverse,mem_idealSet] + constructor + · rintro ⟨A,hA,rfl⟩ + have hAM := (realCode_mem_groundReals M A).mp hA + exact ⟨degree A,⟨A,hAM,rfl⟩,eq A hAM⟩ + · rintro ⟨d,⟨A,hA,rfl⟩,rfl⟩ + exact ⟨A,(realCode_mem_groundReals M A).mpr hA,(eq A hA).symm⟩ + +theorem ground_degreeUniverse_mem_relativeModel (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) : + degreeUniverse (groundReals M) ∈ relativeModel M (groundReals M) := by + let R := groundReals M + let N := relativeModel M R + have hR := groundReals_mem M hM hT + have hRN : R ∈ N := (mem_relativeModel M R R hM hT hR).mpr (parameter_in_relativeModel M R hM hT) + have hr (w : ZFSet.{u}) (hw : w ∈ R) : ∃ B : Oracle, realCode B = w := + ⟨decodeReal w,realCode_decodeReal ((mem_groundReals M w).mp hw).2⟩ + exact internal_degreeUniverse_without_choice N (relativeModel_transitive M R hM) + (relativeModel_pairing M R hM hT hR) (relativeModel_union M R hM hT hR) + (relativeModel_power_set M R hM hT hR) + (relativeModel_bounded_separation M R hM hT hR) + (ground_relativeModel_omega M hM hT) R hRN hr + +theorem ground_idealSet_mem_relativeModel (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) : + idealSet (modelIdeal M hM hT) ∈ relativeModel M (groundReals M) := by + rw [←ground_degreeUniverse_eq_idealSet M hM hT] + exact ground_degreeUniverse_mem_relativeModel M hM hT + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeHierarchyInternal.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeHierarchyInternal.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b47610121cab2010c5d55306021a8aeb48505c4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeHierarchyInternal.lean @@ -0,0 +1,38 @@ +import OAI.Computability.DegreeRigidity.Syntax.CheckedHierarchySyntax +import OAI.Computability.DegreeRigidity.Constructibility.CollectionHierarchyInternal +import OAI.Computability.DegreeRigidity.Constructibility.RelativeDefCertificates +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModelOrdinals + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +theorem relative_internal_hierarchy_cover (M x : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) + (hx : x ∈ relativeModel M (groundReals M)) : + ∃ d ∈ relativeModel M (groundReals M), ∃ f ∈ relativeModel M (groundReals M), + x ∈ d ∧ HierarchyGraph (relativeModel M (groundReals M)) (seed (groundReals M)) + d (iterUnion 2 f) f := by + have hR := groundReals_mem M hM hT + exact internal_hierarchy_cover_collection _ _ x (ground_relative_context M hM hT) + (relativeModel_sigma_replacement M _ hM hT hR) + (relativeModel_sigma_collection M _ hM hT hR) + ((mem_relativeModel M _ _ hM hT hR).mpr (parameter_in_relativeModel M _ hM hT)) hx + +theorem relative_internal_ordinal_hierarchy (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (o : Ordinal.{u}) (ho : o.toZFSet ∈ M) : + ∃ d ∈ relativeModel M (groundReals M), ∃ f ∈ relativeModel M (groundReals M), + o.toZFSet ∈ d ∧ CheckedHierarchyGraph (relativeModel M (groundReals M)) + ZFSet.omega (ZFSet.prod ZFSet.omega ZFSet.omega) (seed (groundReals M)) + d (iterUnion 2 f) f := by + obtain ⟨d,hd,f,hf,ho,hg⟩ := relative_internal_hierarchy_cover M o.toZFSet hM hT + ((ground_relativeModel_ordinal_iff M hM hT o).mpr ho) + exact ⟨d,hd,f,hf,ho,(checkedHierarchyGraph_of_context _ _ _ _ _ + (ground_relative_context M hM hT)).mpr hg⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeLevySchemas.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeLevySchemas.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ef6491c60ffc4fd88942ae692f8d3361e16a991 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeLevySchemas.lean @@ -0,0 +1,62 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeSigmaSchemas + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open BoundedSetTheory TransitiveNameModel +universe u + +theorem ground_relativeModel_levy_schemas (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) : + LevySigmaSeparation (relativeModel M (groundReals M)) ∧ + LevySigmaReplacement (relativeModel M (groundReals M)) := by + let N := relativeModel M (groundReals M) + have hR := groundReals_mem M hM hT + have hN := relativeModel_transitive M (groundReals M) hM + have hS := relativeModel_sigma_separation M (groundReals M) hM hT hR + have hRep := relativeModel_sigma_replacement M (groundReals M) hM hT hR + have correct := LevySigma.normalize_correct N hN + (relativeModel_pairing M _ hM hT hR) (relativeModel_union M _ hM hT hR) + hS.bounded hRep (ground_relativeModel_infinity M hM hT) + (relativeModel_sigma_collection M _ hM hT hR) + constructor + · intro φ e he a ha + obtain ⟨b,hb,hbdef⟩ := hS φ.normalize e he a ha + refine ⟨b,hb,?_⟩ + intro x hx + rw [hbdef x hx,correct φ (cons x e) (by intro i; cases i; exact hx; exact he _)] + · intro φ e he a ha htotal + have eq (x y : ZFSet.{u}) (hx : x ∈ N) (hy : y ∈ N) : + φ.normalize.Realize N (cons y (cons x e)) ↔ φ.Realize N (cons y (cons x e)) := + correct φ _ (by + intro i; rcases i with _|i; exact hy + rcases i with _|i; exact hx + exact he i) + obtain ⟨b,hb,hbdef⟩ := hRep φ.normalize e he a ha (by + intro x hx + have hxN := hN a ha x hx + obtain ⟨y,hy,hφ,hu⟩ := htotal x hx + exact ⟨y,hy,(eq x y hxN hy).mpr hφ,fun z hz h => hu z hz ((eq x z hxN hz).mp h)⟩) + refine ⟨b,hb,?_⟩ + intro y hy + rw [hbdef y hy] + apply exists_congr; intro x + exact and_congr_right (fun hx => eq x y (hN a ha x hx) hy) + +theorem relativeModel_empty_set (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) : BasicAxioms.EmptySet (relativeModel M R) := + ⟨∅,(mem_relativeModel M R _ hM hT hR).mpr (empty_in_relativeModel M R hM hT), + fun x _ => ZFSet.notMem_empty x⟩ + +theorem relativeModel_extensionality (M R : ZFSet.{u}) (hM : Transitive M) : + BasicAxioms.Extensionality (relativeModel M R) := + BasicAxioms.extensionality _ (relativeModel_transitive M R hM) + +theorem relativeModel_foundation (M R : ZFSet.{u}) (hM : Transitive M) : + BasicAxioms.Foundation (relativeModel M R) := + BasicAxioms.foundation _ (relativeModel_transitive M R hM) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModel.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..fcba3614f3ee4a53accb919add627ec4036b41b8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModel.lean @@ -0,0 +1,96 @@ +import OAI.Computability.DegreeRigidity.Constructibility.InternalConstructibleHierarchy + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open BoundedSetTheory TransitiveNameModel +universe u + +def InRelativeModel (M R x : ZFSet.{u}) : Prop := + ∃ o : Ordinal.{u}, o.toZFSet ∈ M ∧ x ∈ level R o + +noncomputable def relativeModel (M R : ZFSet.{u}) : ZFSet.{u} := + M.sep (InRelativeModel M R) + +theorem relativeModel_subset (M R : ZFSet.{u}) : relativeModel M R ⊆ M := + fun _ hx => (ZFSet.mem_sep.mp hx).1 + +theorem InRelativeModel.mem_ground {M R x : ZFSet.{u}} + (hM : Transitive M) (hT : SourceT M) (hR : R ∈ M) + (hx : InRelativeModel M R x) : x ∈ M := by + obtain ⟨o,ho,hx⟩ := hx + exact level_subset_model M R hM hT hR o ho hx + +theorem mem_relativeModel (M R x : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) : + x ∈ relativeModel M R ↔ InRelativeModel M R x := by + rw [relativeModel,ZFSet.mem_sep] + exact ⟨And.right,fun hx => ⟨hx.mem_ground hM hT hR,hx⟩⟩ + +theorem InRelativeModel.external {M R x : ZFSet.{u}} + (hx : InRelativeModel M R x) : InRelativeL R x := by + obtain ⟨o,_,hx⟩ := hx + exact ⟨o,hx⟩ + +theorem InRelativeModel.transitive {M R x y : ZFSet.{u}} + (hx : InRelativeModel M R x) (hy : y ∈ x) : InRelativeModel M R y := by + obtain ⟨o,ho,hx⟩ := hx + exact ⟨o,ho,level_transitive R o x hx y hy⟩ + +theorem relativeModel_transitive (M R : ZFSet.{u}) (hM : Transitive M) : + Transitive (relativeModel M R) := by + intro x hx y hy + obtain ⟨hxM,hx⟩ := ZFSet.mem_sep.mp hx + exact ZFSet.mem_sep.mpr ⟨hM x hxM y hy,hx.transitive hy⟩ + +theorem internal_ordinal_zero (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + (0 : Ordinal.{u}).toZFSet ∈ M := by + rw [Ordinal.toZFSet_zero] + exact hM _ (sourceT_omega_mem M hM hT) _ ZFSet.omega_zero + +theorem internal_ordinal_succ (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (o : Ordinal.{u}) (ho : o.toZFSet ∈ M) : (o+1).toZFSet ∈ M := by + rw [Ordinal.toZFSet_add_one] + have eq : insert o.toZFSet o.toZFSet = ({o.toZFSet} : ZFSet.{u}) ∪ o.toZFSet := by + apply ZFSet.ext; intro z + simp only [ZFSet.mem_insert_iff,ZFSet.mem_union,ZFSet.mem_singleton] + rw [eq] + exact binary_union_mem M hM hT.pairing hT.union + (singleton_mem M hM hT.pairing ho) ho + +theorem internal_ordinal_max (M : ZFSet.{u}) {i j : Ordinal.{u}} + (hi : i.toZFSet ∈ M) (hj : j.toZFSet ∈ M) : (max i j).toZFSet ∈ M := by + rcases le_total i j with h|h + · simpa only [max_eq_right h] using hj + · simpa only [max_eq_left h] using hi + +theorem parameter_in_relativeModel (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) : InRelativeModel M R R := + ⟨0,internal_ordinal_zero M hM hT,level_zero R ▸ parameter_mem_seed R⟩ + +theorem level_in_relativeModel (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (o : Ordinal.{u}) (ho : o.toZFSet ∈ M) : + InRelativeModel M R (level R o) := + ⟨o+1,internal_ordinal_succ M hM hT o ho, + level_mem_level R (lt_add_one o)⟩ + +theorem relativeModel_ground_reals (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (x : ZFSet.{u}) (hx : x ⊆ ZFSet.omega) : + x ∈ relativeModel M (groundReals M) ↔ x ∈ M := by + rw [mem_relativeModel M _ x hM hT (groundReals_mem M hM hT)] + exact internally_indexed_ground_reals M hM hT x hx + +theorem relativeModel_monotone {M N R : ZFSet.{u}} (hMN : M ⊆ N) : + relativeModel M R ⊆ relativeModel N R := by + intro x hx + obtain ⟨hxM,o,ho,hx⟩ := ZFSet.mem_sep.mp hx + exact ZFSet.mem_sep.mpr ⟨hMN hxM,o,hMN ho,hx⟩ + +theorem relativeModel_external (M R : ZFSet.{u}) {x : ZFSet.{u}} + (hx : x ∈ relativeModel M R) : InRelativeL R x := + (ZFSet.mem_sep.mp hx).2.external + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelBounds.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc5c779aa2fad42f0cc234439ca0fff0e810436c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelBounds.lean @@ -0,0 +1,77 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModelSyntax +import OAI.Computability.DegreeRigidity.OrdinalCodes.RankOrdinal + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open BoundedSetTheory TransitiveNameModel BoundedDefinability SetModelFunctions InternalRank +universe u + +theorem relative_level_bound (M R a : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) (ha : a ∈ M) + (h : ∀ x ∈ a, InRelativeModel M R x) : + ∃ o : Ordinal.{u}, o.toZFSet ∈ M ∧ a ⊆ level R o := by + obtain ⟨p,e,he,hp⟩ := sigma_binary_relation + (fun x o : ZFSet.{u} => o.IsOrdinal ∧ x ∈ stage R o) + (relativeLevel_sigmaDefinable M R hM hT hR) + obtain ⟨W,hW,hbound⟩ := sigma_collection M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix hT.replacement.finitePrefix hT.infinity hT.choice + p e he a ha (by + intro x hx + obtain ⟨o,ho,hxo⟩ := h x hx + exact ⟨o.toZFSet,ho,(hp x (hM a ha x hx) o.toZFSet ho).mpr + ⟨ZFSet.isOrdinal_toZFSet o,hxo⟩⟩) + have hr : W.rank.toZFSet ∈ M := by + rw [← rankSet_eq_ordinal] + exact rankSet_mem_ground M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hW + refine ⟨W.rank,hr,?_⟩ + intro x hx + obtain ⟨o,ho,hxo⟩ := hbound x hx + obtain ⟨hord,hxo⟩ := (hp x (hM a ha x hx) o (hM W hW o ho)).mp hxo + have hxl : x ∈ level R o.rank := by + change x ∈ stage R o.rank.toZFSet + rwa [hord.toZFSet_rank_eq] + exact level_mono R (ZFSet.rank_lt_of_mem ho).le hxl + +theorem SigmaDefinable.internal_separation {M : ZFSet.{u}} + {P : (ℕ → ZFSet.{u}) → Prop} (h : SigmaDefinable M P) + (hM : Transitive M) (hT : SourceT M) (e : ℕ → ZFSet.{u}) + (he : ∀ i, e i ∈ M) {a : ZFSet.{u}} (ha : a ∈ M) : + a.sep (fun x => P (cons x e)) ∈ M := by + obtain ⟨p,d,hd,hp⟩ := h + have hm : ∀ i, mix e d i ∈ M := by + intro i; unfold mix; split <;> first | exact he _ | exact hd _ + have hs := sigma_sep_mem M hM hT.separation.finitePrefix + (p.rename bindSlots) (mix e d) hm ha + have eq : a.sep (fun x => (p.rename bindSlots).Realize M (cons x (mix e d))) = + a.sep (fun x => P (cons x e)) := by + apply ZFSet.ext; intro x + simp only [ZFSet.mem_sep] + apply and_congr_right; intro hx + rw [SigmaFormula.realize_rename] + change p.Realize M (cons x (mix e d) ∘ bindSlots) ↔ _ + rw [bind_mix] + exact hp _ (by intro i; cases i; exact hM a ha x hx; exact he _) + exact eq ▸ hs + +theorem relative_part_mem (M R a : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) (ha : a ∈ M) : + a.sep (InRelativeModel M R) ∈ M := by + exact SigmaDefinable.internal_separation (relativeModel_sigmaDefinable M R hM hT hR) + hM hT (fun _ => R) (fun _ => hR) ha + +theorem relative_part_bounded (M R a : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) (ha : a ∈ M) : + ∃ o : Ordinal.{u}, o.toZFSet ∈ M ∧ + ∀ x ∈ a, InRelativeModel M R x ↔ x ∈ level R o := by + obtain ⟨o,ho,hbound⟩ := relative_level_bound M R (a.sep (InRelativeModel M R)) + hM hT hR (relative_part_mem M R a hM hT hR ha) + (fun _ hx => (ZFSet.mem_sep.mp hx).2) + exact ⟨o,ho,fun x hx => ⟨fun h => hbound (ZFSet.mem_sep.mpr ⟨hx,h⟩), + fun h => ⟨o,ho,h⟩⟩⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelClosure.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..129eab26e1987cfd87ee78d79f0d5ab57c2061f8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelClosure.lean @@ -0,0 +1,129 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModel + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open BoundedSetTheory TransitiveNameModel ElementaryModel SentenceForm +universe u + +theorem finite_parameters_in_relative_level (M R : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (e : ℕ → ZFSet.{u}) (n : ℕ) + (he : ∀ i, i < n → InRelativeModel M R (e i)) : + ∃ o : Ordinal.{u}, o.toZFSet ∈ M ∧ ∀ i, i < n → e i ∈ level R o := by + induction n with + | zero => exact ⟨0,internal_ordinal_zero M hM hT,fun _ hi => (Nat.not_lt_zero _ hi).elim⟩ + | succ n ih => + obtain ⟨o,ho,hoe⟩ := ih (fun i hi => he i (Nat.lt_succ_of_lt hi)) + obtain ⟨p,hp,hpe⟩ := he n (Nat.lt_succ_self n) + refine ⟨max o p,internal_ordinal_max M ho hp,fun i hi => ?_⟩ + rcases Nat.lt_succ_iff_lt_or_eq.mp hi with hi|rfl + · exact level_mono R (le_max_left o p) (hoe i hi) + · exact level_mono R (le_max_right o p) hpe + +theorem empty_in_relativeModel (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) : InRelativeModel M R ∅ := by + refine ⟨0+1,internal_ordinal_succ M hM hT 0 (internal_ordinal_zero M hM hT),?_⟩ + rw [level_succ] + exact empty_mem_definablePower _ + +theorem pair_in_relativeModel (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) {a b : ZFSet.{u}} + (ha : InRelativeModel M R a) (hb : InRelativeModel M R b) : + InRelativeModel M R ({a,b} : ZFSet.{u}) := by + obtain ⟨i,hi,hia⟩ := ha + obtain ⟨j,hj,hjb⟩ := hb + refine ⟨max i j+1,internal_ordinal_succ M hM hT _ (internal_ordinal_max M hi hj),?_⟩ + rw [level_succ] + exact pair_mem_definablePower _ a b (level_mono R (le_max_left i j) hia) + (level_mono R (le_max_right i j) hjb) + +theorem union_in_relativeModel (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) {a : ZFSet.{u}} (ha : InRelativeModel M R a) : + InRelativeModel M R (ZFSet.sUnion a) := by + obtain ⟨i,hi,hia⟩ := ha + refine ⟨i+1,internal_ordinal_succ M hM hT i hi,?_⟩ + rw [level_succ] + exact union_mem_definablePower _ a (level_transitive R i) hia + +theorem bounded_separation_in_relativeModel (M R a : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (ha : InRelativeModel M R a) + (φ : Formula) (e : ℕ → ZFSet.{u}) + (he : ∀ i, i < (fromBounded φ).bound → InRelativeModel M R (e i)) : + InRelativeModel M R (a.sep (fun x => φ.Eval (cons x e))) := by + obtain ⟨i,hi,hia⟩ := ha + obtain ⟨j,hj,hje⟩ := finite_parameters_in_relative_level M R hM hT e _ he + let A := level R (max i j) + have haA : a ∈ A := level_mono R (le_max_left i j) hia + let e' : ℕ → ZFSet.{u} := fun n => if n < (fromBounded φ).bound then e n else a + have heA : ∀ n, e' n ∈ A := by + intro n + dsimp [e']; split + next hn => exact level_mono R (le_max_right i j) (hje n hn) + next => exact haA + have heval (x : ZFSet.{u}) : φ.Eval (cons x e') ↔ φ.Eval (cons x e) := by + rw [← bounded_univ,← bounded_univ] + apply (fromBounded φ).finite_support + intro k hk + cases k with + | zero => rfl + | succ k => + change e' k = e k + simp [e',show k < (fromBounded φ).bound by omega] + have heq : a.sep (fun x => φ.Eval (cons x e')) = a.sep (fun x => φ.Eval (cons x e)) := by + apply ZFSet.ext; intro x + simp only [ZFSet.mem_sep,heval] + refine ⟨max i j+1,internal_ordinal_succ M hM hT _ (internal_ordinal_max M hi hj),?_⟩ + rw [level_succ,← heq] + exact bounded_separation_mem_definablePower A a (level_transitive R _) haA φ e' heA + +theorem relativeModel_pairing (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) : Pairing (relativeModel M R) := by + intro a ha b hb + have mem := mem_relativeModel M R + refine ⟨{a,b},(mem _ hM hT hR).mpr (pair_in_relativeModel M R hM hT + ((mem _ hM hT hR).mp ha) ((mem _ hM hT hR).mp hb)),?_⟩ + intro x _; exact ZFSet.mem_pair + +theorem relativeModel_union (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) : BoundedSetTheory.Union (relativeModel M R) := by + intro a ha + refine ⟨ZFSet.sUnion a,(mem_relativeModel M R _ hM hT hR).mpr + (union_in_relativeModel M R hM hT ((mem_relativeModel M R a hM hT hR).mp ha)),?_⟩ + intro x _ + rw [ZFSet.mem_sUnion] + constructor + · rintro ⟨y,hy,hx⟩ + exact ⟨y,relativeModel_transitive M R hM a ha y hy,hy,hx⟩ + · rintro ⟨y,_,hy,hx⟩; exact ⟨y,hy,hx⟩ + +theorem relativeModel_bounded_separation (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) : Separation (relativeModel M R) := by + intro φ e he a ha + have mem := mem_relativeModel M R + refine ⟨a.sep (fun x => φ.Eval (cons x e)),(mem _ hM hT hR).mpr + (bounded_separation_in_relativeModel M R a hM hT ((mem _ hM hT hR).mp ha) + φ e (fun i _ => (mem _ hM hT hR).mp (he i))),?_⟩ + intro x hx + rw [ZFSet.mem_sep,Formula.absolute φ _ (relativeModel_transitive M R hM) _ (by + intro i; cases i; exact hx; exact he _)] + +theorem ground_relativeModel_omega (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) : ZFSet.omega ∈ relativeModel M (groundReals M) := by + exact (relativeModel_ground_reals M hM hT _ (fun _ hx => hx)).mpr + (sourceT_omega_mem M hM hT) + +theorem ground_relativeModel_infinity (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) : Infinity (relativeModel M (groundReals M)) := by + have hω := ground_relativeModel_omega M hM hT + have ht := relativeModel_transitive M (groundReals M) hM + refine ⟨ZFSet.omega,hω,⟨∅,ht _ hω _ ZFSet.omega_zero,ZFSet.omega_zero, + fun z _ => ZFSet.notMem_empty z⟩,?_⟩ + intro x _ hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + have hs := (mem_omega _).mpr ⟨n+1,rfl⟩ + exact ⟨natSet (n+1),ht _ hω _ hs,hs,fun _ _ => ZFSet.mem_insert_iff⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelComparison.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b39ac1aedf0b095f7d15ff24cfa8e49c336d1ad --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelComparison.lean @@ -0,0 +1,47 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModelOrdinals + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open BoundedSetTheory TransitiveNameModel +universe u + +theorem relativeModel_eq_of_same_ordinals (M N R : ZFSet.{u}) + (hM : Transitive M) (hTM : SourceT M) (hRM : R ∈ M) + (hN : Transitive N) (hTN : SourceT N) (hRN : R ∈ N) + (hord : ∀ o : Ordinal.{u}, o.toZFSet ∈ M ↔ o.toZFSet ∈ N) : + relativeModel M R = relativeModel N R := by + apply ZFSet.ext; intro x + rw [mem_relativeModel M R x hM hTM hRM,mem_relativeModel N R x hN hTN hRN] + unfold InRelativeModel + apply exists_congr; intro o + exact and_congr (hord o) Iff.rfl + +theorem relativeModel_countable (M R : ZFSet.{u}) [Countable (Conditions M)] : + Countable (Conditions (relativeModel M R)) := by + let _ : Countable M := Countable.of_equiv (Conditions M) (equivShrink M).symm + let f : relativeModel M R → M := fun x => ⟨x.val,relativeModel_subset M R x.property⟩ + have hf : Function.Injective f := by + intro x y h + apply Subtype.ext + exact congrArg (fun z : M => z.val) h + let _ : Countable (relativeModel M R) := Function.Injective.countable hf + exact Countable.of_equiv (relativeModel M R) (equivShrink (relativeModel M R)) + +theorem ground_relativeModel_sourceT_iff_choice (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) : + SourceT (relativeModel M (groundReals M)) ↔ Choice (relativeModel M (groundReals M)) := by + constructor + · exact SourceT.choice + · intro hAC + have hR := groundReals_mem M hM hT + obtain ⟨hS,hRep⟩ := ground_relativeModel_levy_schemas M hM hT + exact ⟨relativeModel_extensionality M _ hM,relativeModel_empty_set M _ hM hT hR, + relativeModel_pairing M _ hM hT hR,relativeModel_union M _ hM hT hR, + relativeModel_power_set M _ hM hT hR,ground_relativeModel_infinity M hM hT, + relativeModel_foundation M _ hM,hAC,hS,hRep⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelOrdinals.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelOrdinals.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f20d6ef963c7d516245bc0654d9ce3d06b36f2e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelOrdinals.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeLevySchemas + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open BoundedSetTheory TransitiveNameModel InternalRank +universe u + +theorem level_rank_lower_bound (R : ZFSet.{u}) (o : Ordinal.{u}) : o ≤ (level R o).rank := by + induction o using Ordinal.lt_wf.induction with + | ind o ih => + by_contra h + have hlt : (level R o).rank < o := lt_of_not_ge h + have hmem := level_mem_level R hlt + exact (not_le_of_gt (ZFSet.rank_lt_of_mem hmem)) (ih _ hlt) + +theorem ground_relativeModel_ordinal_iff (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (o : Ordinal.{u}) : + o.toZFSet ∈ relativeModel M (groundReals M) ↔ o.toZFSet ∈ M := by + constructor + · intro ho; exact relativeModel_subset M (groundReals M) ho + · intro ho + let R := groundReals M + let N := relativeModel M R + have hR := groundReals_mem M hM hT + have hN := relativeModel_transitive M R hM + have hs := internal_ordinal_succ M hM hT o ho + have hlevel : level R (o+1) ∈ N := (mem_relativeModel M R _ hM hT hR).mpr + (level_in_relativeModel M R hM hT (o+1) hs) + have hr := rankSet_mem_ground N hN (relativeModel_pairing M R hM hT hR) + (relativeModel_union M R hM hT hR) (relativeModel_power_set M R hM hT hR) + (relativeModel_bounded_separation M R hM hT hR) + (relativeModel_sigma_replacement M R hM hT hR) + (ground_relativeModel_infinity M hM hT) hlevel + rw [rankSet_eq_ordinal] at hr + exact hN _ hr _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr + ((lt_add_one o).trans_le (level_rank_lower_bound R (o+1)))) + +theorem ground_relativeModel_same_indices (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (x : ZFSet.{u}) : + InRelativeModel (relativeModel M (groundReals M)) (groundReals M) x ↔ + InRelativeModel M (groundReals M) x := by + unfold InRelativeModel + apply exists_congr; intro o + exact and_congr (ground_relativeModel_ordinal_iff M hM hT o) Iff.rfl + +theorem ground_relativeModel_idempotent (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) : + relativeModel (relativeModel M (groundReals M)) (groundReals M) = + relativeModel M (groundReals M) := by + apply ZFSet.ext; intro x + change x ∈ (relativeModel M (groundReals M)).sep + (InRelativeModel (relativeModel M (groundReals M)) (groundReals M)) ↔ _ + rw [ZFSet.mem_sep,ground_relativeModel_same_indices M hM hT x] + exact ⟨And.left,fun hx => ⟨hx,(mem_relativeModel M _ x hM hT (groundReals_mem M hM hT)).mp hx⟩⟩ + +theorem groundReals_relativeModel (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + groundReals (relativeModel M (groundReals M)) = groundReals M := by + apply ZFSet.ext; intro x + rw [mem_groundReals,mem_groundReals] + constructor + · rintro ⟨hx,hsub⟩; exact ⟨relativeModel_subset M _ hx,hsub⟩ + · rintro ⟨hx,hsub⟩; exact ⟨(relativeModel_ground_reals M hM hT x hsub).mpr hx,hsub⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelPower.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelPower.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6d4472222217e610e0556be2285f251fc921375 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelPower.lean @@ -0,0 +1,59 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModelBounds +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModelClosure + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open BoundedSetTheory TransitiveNameModel ElementaryModel SentenceForm +universe u + +theorem subsets_mem_definablePower (A a : ZFSet.{u}) (hA : Transitive A) (ha : a ∈ A) : + A.sep (fun x => x ⊆ a) ∈ definablePower A := by + have hs := separation_mem_definablePower A (fromBounded (.subset 0 1)) + (fun _ => a) (fun _ _ => ha) + have eq : A.sep (fun x => (fromBounded (.subset 0 1)).Sat (A : Set ZFSet) + (cons x (fun _ => a))) = A.sep (fun x => x ⊆ a) := by + apply ZFSet.ext; intro x + simp only [ZFSet.mem_sep] + apply and_congr_right; intro hx + rw [bounded_sat,Formula.absolute _ A hA _ (by + intro i; cases i; exact hx; exact ha)] + exact Formula.eval_subset 0 1 _ + exact eq ▸ hs + +theorem relativeModel_power_set (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) : PowerSet (relativeModel M R) := by + intro a ha + have haM := relativeModel_subset M R ha + obtain ⟨q,hq,hqdef⟩ := internal_power M hM hT.powerSet haM + obtain ⟨i,hi,hbound⟩ := relative_part_bounded M R q hM hT hR hq + obtain ⟨j,hj,hja⟩ := (mem_relativeModel M R a hM hT hR).mp ha + let o := max i j + let A := level R o + let b := A.sep (fun x => x ⊆ a) + have haA : a ∈ A := level_mono R (le_max_right i j) hja + have ho : o.toZFSet ∈ M := internal_ordinal_max M hi hj + have hb : b ∈ relativeModel M R := by + apply (mem_relativeModel M R b hM hT hR).mpr + refine ⟨o+1,internal_ordinal_succ M hM hT o ho,?_⟩ + rw [level_succ] + exact subsets_mem_definablePower A a (level_transitive R o) haA + refine ⟨b,hb,?_⟩ + intro x hx + have hsub : (∀ y ∈ relativeModel M R, y ∈ x → y ∈ a) ↔ x ⊆ a := + ⟨fun h y hy => h y (relativeModel_transitive M R hM x hx y hy) hy, + fun h _ _ hy => h hy⟩ + rw [hsub] + change x ∈ A.sep (fun x => x ⊆ a) ↔ x ⊆ a + rw [ZFSet.mem_sep] + constructor + · exact And.right + · intro hxa + have hxq := (hqdef x).mpr ⟨relativeModel_subset M R hx,hxa⟩ + have hxi := (hbound x hxq).mp ((mem_relativeModel M R x hM hT hR).mp hx) + exact ⟨level_mono R (le_max_left i j) hxi,hxa⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelSyntax.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b072c1f3d85451daf2ae92ee1cf9ab29febd8f7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeModelSyntax.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModel +import OAI.Computability.DegreeRigidity.Constructibility.UniformHierarchyStage + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open BoundedSetTheory TransitiveNameModel BoundedDefinability SetModelFunctions +universe u + +def ordinalFormula (i : ℕ) : Formula := + .conj (.transitive i) (Formula.allMem i (.transitive 0)) + +theorem eval_ordinalFormula (i : ℕ) (e : ℕ → ZFSet.{u}) : + (ordinalFormula i).Eval e ↔ (e i).IsOrdinal := by + rw [ZFSet.isOrdinal_iff_forall_mem_isTransitive] + simp only [ordinalFormula,Formula.Eval,Formula.eval_transitive, + Formula.eval_allMem,cons_zero] + rfl + +theorem ordinal_definable {M : ZFSet.{u}} (C : Context M) (i : ℕ) : + Definable M (fun e => (e i).IsOrdinal) := + ⟨ordinalFormula (2*i),fun _ => ZFSet.omega,fun _ => C.omega_mem, + fun e => by rw [eval_ordinalFormula,mix_even]⟩ + +theorem relativeLevel_sigmaDefinable (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) : + SigmaDefinable M (fun e => (e 0).IsOrdinal ∧ e 1 ∈ stage R (e 0)) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet, + hT.separation.finitePrefix.bounded,hT.infinity⟩ + have h := (stage_sigmaDefinable M R hM hT hR).and + (((ordinal_definable C 1).toSigma hM).and ((member_definable C 2 0).toSigma hM)) + apply h.existsSet.congr + intro e he + change (∃ A ∈ M, A = stage R (e 0) ∧ (e 0).IsOrdinal ∧ e 1 ∈ A) ↔ _ + constructor + · rintro ⟨A,_,rfl,ho,hx⟩; exact ⟨ho,hx⟩ + · rintro ⟨ho,hx⟩ + exact ⟨_,stage_mem M R (e 0) hM hT hR (he 0),rfl,ho,hx⟩ + +theorem relativeModel_sigmaDefinable (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) : + SigmaDefinable M (fun e => InRelativeModel M R (e 0)) := by + apply (relativeLevel_sigmaDefinable M R hM hT hR).existsSet.congr + intro e _ + change (∃ o ∈ M, o.IsOrdinal ∧ e 0 ∈ stage R o) ↔ _ + constructor + · rintro ⟨o,ho,hord,hx⟩ + refine ⟨o.rank,?_,?_⟩ + · rwa [hord.toZFSet_rank_eq] + · change e 0 ∈ stage R o.rank.toZFSet + rwa [hord.toZFSet_rank_eq] + · rintro ⟨o,ho,hx⟩ + exact ⟨o.toZFSet,ho,ZFSet.isOrdinal_toZFSet o,hx⟩ + +theorem relativeModel_mem_sigmaDefinable (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) : + SigmaDefinable M (fun e => e 0 ∈ relativeModel M R) := + (relativeModel_sigmaDefinable M R hM hT hR).congr + (fun e _ => (mem_relativeModel M R (e 0) hM hT hR).symm) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeOmegaCertificates.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeOmegaCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..c21123ca80c0e20242df211f63772bcc927910ca --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeOmegaCertificates.lean @@ -0,0 +1,72 @@ +import OAI.Computability.DegreeRigidity.SetModels.RestrictedOmegaRecursion +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaPowerCertificates +import OAI.Computability.DegreeRigidity.Constructibility.RelativeDefCertificates +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModelOrdinals + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open BoundedDefinability SetModelFunctions SentenceCoding +universe u + +theorem internal_omegaGraph_below_schemas (M : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) (hColl : SigmaCollection M) + (x : ZFSet.{u}) (hx : x ∈ M) (ho : x.IsOrdinal) : + ∃ f ∈ M, OmegaGraph M x (iterUnion 2 f) f := by + obtain ⟨f,hf,hg⟩ := internal_omegaGraph_schemas M C hRep hColl x hx ho + let p : Formula := .existsMem 1 (.existsMem 3 (.orderedPair 2 1 0)) + let e : ℕ → ZFSet.{u} := cons x (fun _ => iterUnion 2 f) + let g := ZFSet.sep (fun z => p.Eval (cons z e)) f + have hgM : g ∈ M := sep_mem M C.transitive C.separation p e + (by intro i; cases i; exact hx; exact iterUnion_mem M C.transitive C.union hf 2) hf + have hm (z : ZFSet.{u}) : z ∈ g ↔ ∃ t ∈ x, z = ZFSet.pair t (omegaNext t) := by + change z ∈ ZFSet.sep _ f ↔ _ + simp only [ZFSet.mem_sep,p,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ] + change (z ∈ f ∧ ∃ t ∈ x, ∃ v ∈ iterUnion 2 f, z = ZFSet.pair t v) ↔ _ + constructor + · rintro ⟨hz,t,ht,v,hv,rfl⟩ + exact ⟨t,ht,by rw [hg.correct t (ZFSet.mem_insert_of_mem x ht) v hv hz]⟩ + · rintro ⟨t,ht,rfl⟩ + have hp := (hg.mem_iff _).mpr ⟨t,ZFSet.mem_insert_of_mem x ht,rfl⟩ + exact ⟨hp,t,ht,_,second_mem_doubleUnion hp,rfl⟩ + exact ⟨g,hgM,omegaGraph_of_mem_iff_context M x g C hx hgM ho hm⟩ + +theorem ProductCertificates.context (M : ZFSet.{u}) (C : Context M) + (hRep : SigmaReplacement M) (a b : Ordinal.{u}) + (ha : a.toZFSet ∈ M) (hb : b.toZFSet ∈ M) : ProductCertificates M a b := by + obtain ⟨_,f,hf,hc⟩ := ordinal_mul_internal_schemas M C.transitive C.pairing C.union + C.power C.separation hRep a b ha hb + exact ⟨product_mem M C.transitive C.pairing C.union C.power C.separation hb ha, + productRelation_mem M _ _ C.transitive C.pairing C.union C.power C.separation ha hb, + f,hf,hc⟩ + +theorem OmegaPowerCertificates.schemas (M : ZFSet.{u}) (C : Context M) + (hRep : SigmaReplacement M) (hColl : SigmaCollection M) + (x : ZFSet.{u}) (hx : x ∈ M) (ho : x.IsOrdinal) : OmegaPowerCertificates M x := by + obtain ⟨f,hf,hg⟩ := internal_omegaGraph_below_schemas M C hRep hColl x hx ho + refine ⟨hx,f,hf,_,iterUnion_mem M C.transitive C.union hf 2,hg,?_⟩ + intro t ht + have htM := C.transitive _ hx t ht + exact ProductCertificates.context M C hRep _ _ + (ordinal_omega_opow_schemas M C hRep hColl t.rank + ((hg.1.mem ht).toZFSet_rank_eq.symm ▸ htM)) (toZFSet_omega.symm ▸ C.omega_mem) + +theorem relative_omega_power_certificates (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) : + OmegaPowerCertificates (relativeModel M (groundReals M)) a.toZFSet := + OmegaPowerCertificates.schemas _ (ground_relative_context M hM hT) + (relativeModel_sigma_replacement M _ hM hT (groundReals_mem M hM hT)) + (relativeModel_sigma_collection M _ hM hT (groundReals_mem M hM hT)) + a.toZFSet ((ground_relativeModel_ordinal_iff M hM hT a).mpr ha) (ZFSet.isOrdinal_toZFSet a) + +theorem relative_omega_power_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) : + (Ordinal.omega0 ^ a).toZFSet ∈ relativeModel M (groundReals M) := + ordinal_omega_opow_schemas _ (ground_relative_context M hM hT) + (relativeModel_sigma_replacement M _ hM hT (groundReals_mem M hM hT)) + (relativeModel_sigma_collection M _ hM hT (groundReals_mem M hM hT)) + a ((ground_relativeModel_ordinal_iff M hM hT a).mpr ha) + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeOmegaLevels.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeOmegaLevels.lean new file mode 100644 index 0000000000000000000000000000000000000000..16f06e927a38e02ebbe5aaccca919304e6ccc704 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeOmegaLevels.lean @@ -0,0 +1,75 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.ProductCertificateCollection +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalDecoderDomains + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open BoundedDefinability SetModelFunctions SentenceCoding +universe u + +theorem OmegaGraph.relocate {M N d r f : ZFSet.{u}} (hg : OmegaGraph M d r f) + (hval : ∀ t ∈ d, (Ordinal.omega0 ^ t.rank).toZFSet ∈ N) : OmegaGraph N d r f := by + refine ⟨hg.1,hg.2.1,?_⟩ + intro t ht v hv hp + obtain ⟨A,_,hs,ho,he⟩ := hg.2.2 t ht v hv hp + exact ⟨A,(omegaStageStep_exact hg ht hs).symm ▸ hval t ht,hs,ho,he⟩ + +theorem omega_certificates_at_levels (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ ∀ δ : Ordinal.{u}, γ ≤ δ → + a.toZFSet ∈ level (groundReals M) δ ∧ + (Ordinal.omega0 ^ a).toZFSet ∈ level (groundReals M) δ ∧ + OmegaPowerCertificates (level (groundReals M) δ) a.toZFSet ∧ + ∀ z ∈ level (groundReals M) δ, + omegaPowerSentence.Sat (level (groundReals M) δ : Set ZFSet) + (cons z (fun _ => a.toZFSet)) ↔ z = (Ordinal.omega0 ^ a).toZFSet := by + let R := groundReals M + let N := relativeModel M R + have hR := groundReals_mem M hM hT + have C := ground_relative_context M hM hT + have hRep := relativeModel_sigma_replacement M R hM hT hR + have hColl := relativeModel_sigma_collection M R hM hT hR + have haN : a.toZFSet ∈ N := (ground_relativeModel_ordinal_iff M hM hT a).mpr ha + have hyN := relative_omega_power_internal M hM hT a ha + obtain ⟨_,f,hf,r,hr,hg,_⟩ := relative_omega_power_certificates M hM hT a ha + obtain ⟨U,hU,hprod⟩ := product_certificate_collection N C hRep hColl + (Ordinal.omega0 ^ a) Ordinal.omega0 hyN (toZFSet_omega.symm ▸ C.omega_mem) + let e := cons a.toZFSet (cons (Ordinal.omega0 ^ a).toZFSet (cons f (cons r (fun _ => U)))) + have he (i : ℕ) : e i ∈ N := by + rcases i with _|_|_|_|i + exact haN; exact hyN; exact hf; exact hr; exact hU + obtain ⟨γ,hγ,hγe⟩ := finite_parameters_in_relative_level M R hM hT e 5 + (fun i _ => (mem_relativeModel M R _ hM hT hR).mp (he i)) + refine ⟨γ,hγ,?_⟩ + intro δ hδ + have hL (i : ℕ) (hi : i < 5) : e i ∈ level R δ := level_mono R hδ (hγe i hi) + have hlt (t : ZFSet.{u}) (ht : t ∈ a.toZFSet) : + Ordinal.omega0 ^ t.rank < Ordinal.omega0 ^ a := by + obtain ⟨b,hb,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ht + rw [Ordinal.rank_toZFSet] + exact (Ordinal.opow_lt_opow_iff_right (by exact Ordinal.one_lt_omega0)).mpr hb + have hc : OmegaPowerCertificates (level R δ) a.toZFSet := by + refine ⟨hL 0 (by omega),f,hL 2 (by omega),r,hL 3 (by omega), + hg.relocate (fun t ht => level_transitive R δ _ (hL 1 (by omega)) _ + (Ordinal.toZFSet_mem_toZFSet_iff.mpr (hlt t ht))),?_⟩ + intro t ht + obtain ⟨hd,hr,f',hf',hcert,_⟩ := hprod _ (hlt t ht) + have hsub : U ⊆ level R δ := level_transitive R δ U (hL 4 (by omega)) + exact ⟨hsub hd,hsub hr,f',hsub hf',hcert⟩ + refine ⟨hL 0 (by omega),hL 1 (by omega),hc,?_⟩ + intro z hz + have henv : ∀ i, cons z (fun _ => a.toZFSet) i ∈ level R δ := by + intro i; cases i; exact hz; exact hL 0 (by omega) + have hω := OrdinalCoding.ground_level_omega_mem M hM hT δ + constructor + · intro h + have hval := (omegaPowerSentence_sound _ (level_transitive R δ) hω _ henv h).2 + simpa only [cons_succ,cons_zero,Ordinal.rank_toZFSet] using hval + · intro h + apply omegaPowerSentence_of_certificates _ (level_transitive R δ) hω _ henv hc + simpa only [cons_succ,cons_zero,Ordinal.rank_toZFSet] using h + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativePersistentDescent.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativePersistentDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..4338cd362afce0f7cb8cbec39c62c22c46e696a7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativePersistentDescent.lean @@ -0,0 +1,48 @@ +import OAI.Computability.DegreeRigidity.SetModels.WeakRealDescent +import OAI.Computability.DegreeRigidity.Constructibility.RelativeDegreeIdeal + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel SetDegreeDecoding +open PersistentRestrictions +universe u + +theorem persistent_modelIdeal_graph_mem_relativeModel (M : ZFSet.{u}) + [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) + (hρ : Persistent (modelIdeal M hM hT) ρ) : + automorphismSet ρ ∈ relativeModel M (groundReals M) := by + let R := groundReals M + let N := relativeModel M R + have hR := groundReals_mem M hM hT + have hRN : R ∈ N := (mem_relativeModel M R R hM hT hR).mpr + (parameter_in_relativeModel M R hM hT) + have hreal (x : ZFSet.{u}) (hx : x ∈ R) : ∃ B : Oracle, SetModelReals.realSet B = x := + ⟨decodeReal x,realCode_decodeReal ((mem_groundReals M x).mp hx).2⟩ + have hIR (d : Degree) : d ∈ (modelIdeal M hM hT).carrier ↔ + ∃ B : Oracle, SetModelReals.realSet B ∈ R ∧ degree B = d := by + change (∃ B ∈ modelReals M, degree B = d) ↔ _ + exact exists_congr (fun B => and_congr (realCode_mem_groundReals M B).symm Iff.rfl) + have hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ (modelIdeal M hM hT).carrier := + ⟨_,sourceT_real_jump M hM hT (sourceT_zero_real M hM hT),rfl⟩ + exact FullSetForcing.persistent_graph_mem_of_real_family N M + (relativeModel_transitive M R hM) (relativeModel_pairing M R hM hT hR) + (relativeModel_union M R hM hT hR) (relativeModel_power_set M R hM hT hR) + (relativeModel_sigma_separation M R hM hT hR) + (relativeModel_sigma_replacement M R hM hT hR) + (ground_relativeModel_infinity M hM hT) (relativeModel_subset M R) + hRN hreal (modelIdeal M hM hT) (ground_idealSet_mem_relativeModel M hM hT) + hIR ρ hρ hz + +theorem persistent_modelIdeal_graph_in_relativeL (M : ZFSet.{u}) + [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) + (hρ : Persistent (modelIdeal M hM hT) ρ) : + InRelativeL (groundReals M) (automorphismSet ρ) := + relativeModel_external M _ (persistent_modelIdeal_graph_mem_relativeModel M hM hT ρ hρ) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativePersistentExtension.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativePersistentExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fafbb51c1f8f8623fd1df814707771a924737bb --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativePersistentExtension.lean @@ -0,0 +1,35 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativePersistentDescent +import OAI.Computability.DegreeRigidity.Constructibility.PersistentExtension + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel SetDegreeDecoding +open PersistentRestrictions +universe u + +theorem persistent_extension_in_relativeModel (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) + (I : CountableIdeal) (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (hIM : I.carrier ⊆ (modelIdeal M hM hT).carrier) : + ∃ σ : modelIdeal M hM hT ≃o modelIdeal M hM hT, + Extends hIM ρ σ ∧ Persistent (modelIdeal M hM hT) σ ∧ + automorphismSet σ ∈ relativeModel M (groundReals M) := by + obtain ⟨σ,he,hσ⟩ := PersistentExtension.source_4_1_10 I (modelIdeal M hM hT) ρ hρ hz hIM + (modelIdeal_jump M hM hT) + exact ⟨σ,he,hσ,persistent_modelIdeal_graph_mem_relativeModel M hM hT σ hσ⟩ + +theorem persistent_extension_in_model (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) + (I : CountableIdeal) (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (hIM : I.carrier ⊆ (modelIdeal M hM hT).carrier) : + ∃ σ : modelIdeal M hM hT ≃o modelIdeal M hM hT, + Extends hIM ρ σ ∧ Persistent (modelIdeal M hM hT) σ ∧ automorphismSet σ ∈ M := by + obtain ⟨σ,he,hσ,hmem⟩ := persistent_extension_in_relativeModel M hM hT I ρ hρ hz hIM + exact ⟨σ,he,hσ,relativeModel_subset M _ hmem⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeSigmaReflection.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeSigmaReflection.lean new file mode 100644 index 0000000000000000000000000000000000000000..7520018a7f91b45a4cf657e031f223d9769d1bcc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeSigmaReflection.lean @@ -0,0 +1,102 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeSigmaWitness + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open BoundedSetTheory TransitiveNameModel InternalRank +universe u + +theorem relative_sigma_reflection (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) (i : Ordinal.{u}) (hi : i.toZFSet ∈ M) + (φ : SigmaFormula) (e : ℕ → ZFSet.{u}) (he : ∀ n, e n ∈ level R i) + (a : ZFSet.{u}) (ha : a ∈ level R i) : + ∃ o : Ordinal.{u}, o.toZFSet ∈ M ∧ level R i ⊆ level R o ∧ + ∀ x ∈ a, φ.Realize (relativeModel M R) (cons x e) ↔ + φ.Realize (level R o) (cons x e) := by + have ht := level_mem M R hM hT hR i hi + have haM := hM _ ht a ha + have heM : ∀ n, cons (level R i) e n ∈ M := by + intro n; cases n; exact ht; exact hM _ ht _ (he _) + obtain ⟨W,hW,hw⟩ := sigmaDefinable_request_bound + (relative_sigma_request_definable M R hM hT hR φ) hM hT (cons (level R i) e) heM haM + have hr : W.rank.toZFSet ∈ M := by + rw [← rankSet_eq_ordinal] + exact rankSet_mem_ground M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hW + let o := max i W.rank + have ho : o.toZFSet ∈ M := internal_ordinal_max M hi hr + have hio : level R i ⊆ level R o := level_mono R (le_max_left i W.rank) + refine ⟨o,ho,hio,?_⟩ + intro x hx + have heI : ∀ n, cons x e n ∈ level R i := by + intro n; cases n; exact level_transitive R i a ha x hx; exact he _ + constructor + · intro hφ + obtain ⟨j,hj,hij,hφj⟩ := relative_sigma_level_witness M R hM hT hR i hi φ (cons x e) heI hφ + obtain ⟨z,hz,hord,htz,hφz⟩ := hw x hx ⟨j.toZFSet,hj,ZFSet.isOrdinal_toZFSet j,hij,hφj⟩ + change z.IsOrdinal at hord + change level R i ⊆ stage R z at htz + change φ.Realize (stage R z) (cons x e) at hφz + have heq : stage R z = level R z.rank := by + change stage R z = stage R z.rank.toZFSet + rw [hord.toZFSet_rank_eq] + rw [heq] at htz hφz + exact φ.transitive_upward (level_transitive R _) (level_transitive R _) + (level_mono R ((ZFSet.rank_lt_of_mem hz).le.trans (le_max_right i W.rank))) + (cons x e) (fun n => htz (heI n)) hφz + · intro hφ + exact φ.transitive_upward (level_transitive R o) (relativeModel_transitive M R hM) + (relative_level_subset M R hM hT hR ho) (cons x e) (fun n => hio (heI n)) hφ + +theorem relative_sigma_parameter_bound (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (φ : SigmaFormula) (e : ℕ → ZFSet.{u}) + (he : ∀ n, InRelativeModel M R (e n)) (a : ZFSet.{u}) + (ha : InRelativeModel M R a) : + ∃ i : Ordinal.{u}, i.toZFSet ∈ M ∧ a ∈ level R i ∧ + ∃ e' : ℕ → ZFSet.{u}, (∀ n, e' n ∈ level R i) ∧ (∀ n, n < φ.scope → e' n = e n) ∧ + ∀ N x : ZFSet.{u}, φ.Realize N (cons x e') ↔ φ.Realize N (cons x e) := by + obtain ⟨i,hi,hia⟩ := ha + obtain ⟨j,hj,hje⟩ := finite_parameters_in_relative_level M R hM hT e φ.scope (fun n _ => he n) + let e' := fun n => if n < φ.scope then e n else a + have haL : a ∈ level R (max i j) := level_mono R (le_max_left i j) hia + refine ⟨max i j,internal_ordinal_max M hi hj,haL,e',?_,?_,?_⟩ + · intro n + dsimp [e']; split + next hn => exact level_mono R (le_max_right i j) (hje n hn) + next => exact haL + · intro n hn; exact ite_eq_left hn + · intro N x + apply φ.realize_congr; intro n hn + cases n with + | zero => rfl + | succ n => exact ite_eq_left (show n < φ.scope by omega) + +theorem relativeModel_sigma_collection (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) : SigmaCollection (relativeModel M R) := by + intro φ e he a ha htotal + obtain ⟨i,hi,hia,e',he',heq,hcongr⟩ := relative_sigma_parameter_bound M R hM hT + (.existsSet φ) e (fun n => (mem_relativeModel M R _ hM hT hR).mp (he n)) a + ((mem_relativeModel M R _ hM hT hR).mp ha) + obtain ⟨o,ho,hio,hφ⟩ := relative_sigma_reflection M R hM hT hR i hi (.existsSet φ) e' he' a hia + have hlevel := relative_level_subset M R hM hT hR ho + refine ⟨level R o,(mem_relativeModel M R _ hM hT hR).mpr + (level_in_relativeModel M R hM hT o ho),?_⟩ + intro x hx + obtain ⟨y,hy,hxy⟩ := (hφ x hx).mp ((hcongr _ x).mpr (htotal x hx)) + have hup : φ.Realize (relativeModel M R) (cons y (cons x e')) := + φ.transitive_upward (level_transitive R o) (relativeModel_transitive M R hM) + hlevel (cons y (cons x e')) (by + intro n; rcases n with _|n; exact hy + rcases n with _|n; exact hio (level_transitive R i a hia x hx) + exact hio (he' n)) hxy + refine ⟨y,hy,?_⟩ + apply (φ.realize_congr (relativeModel M R) (cons y (cons x e')) (cons y (cons x e)) ?_).mp hup + intro n hn + rcases n with _|n; rfl + rcases n with _|n; rfl + exact heq n (by change n < φ.scope-1; omega) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeSigmaSchemas.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeSigmaSchemas.lean new file mode 100644 index 0000000000000000000000000000000000000000..16459f04929d8f733bc2e3a7060960a521dcfcb5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeSigmaSchemas.lean @@ -0,0 +1,83 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeSigmaReflection + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open BoundedSetTheory TransitiveNameModel ElementaryModel SentenceForm +universe u + +theorem relativeModel_sigma_separation (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) : SigmaSeparation (relativeModel M R) := by + intro φ e he a ha + let N := relativeModel M R + obtain ⟨i,hi,hia,e',he',_,hcongr⟩ := relative_sigma_parameter_bound M R hM hT φ e + (fun n => (mem_relativeModel M R _ hM hT hR).mp (he n)) a + ((mem_relativeModel M R _ hM hT hR).mp ha) + obtain ⟨o,ho,hio,hφ⟩ := relative_sigma_reflection M R hM hT hR i hi φ e' he' a hia + let A := level R o + let ψ := SentenceForm.conj (.member 0 1) ((fromSigma φ).rename parameterShift) + have haA : a ∈ A := hio hia + have hψ := separation_mem_definablePower A ψ (cons a e') (by + intro n _; cases n; exact haA; exact hio (he' _)) + let b := a.sep (fun x => φ.Realize N (cons x e)) + have eq : A.sep (fun x => ψ.Sat (A : Set ZFSet) (cons x (cons a e'))) = b := by + apply ZFSet.ext; intro x + simp only [b,ZFSet.mem_sep,ψ,Sat,cons_zero,cons_succ,shifted_parameters,sigma_sat] + constructor + · rintro ⟨_,hxa,hψ⟩ + exact ⟨hxa,(hcongr N x).mp ((hφ x hxa).mpr hψ)⟩ + · rintro ⟨hxa,hψ⟩ + exact ⟨level_transitive R o a haA x hxa,hxa,(hφ x hxa).mp ((hcongr N x).mpr hψ)⟩ + have hb : b ∈ N := by + apply (mem_relativeModel M R b hM hT hR).mpr + refine ⟨o+1,internal_ordinal_succ M hM hT o ho,?_⟩ + rw [level_succ,← eq] + exact hψ + exact ⟨b,hb,fun _ _ => ZFSet.mem_sep⟩ + +def replacementImageVars : ℕ → ℕ + | 0 => 1 + | 1 => 0 + | n+2 => n+3 + +def replacementImageFormula (φ : SigmaFormula) : SigmaFormula := + .existsSet (SigmaFormula.andBounded (.member 0 2) (φ.rename replacementImageVars)) + +theorem replacementImageFormula_spec (φ : SigmaFormula) (N a y : ZFSet.{u}) + (hN : Transitive N) (ha : a ∈ N) (e : ℕ → ZFSet.{u}) : + (replacementImageFormula φ).Realize N (cons y (cons a e)) ↔ + ∃ x ∈ a, φ.Realize N (cons y (cons x e)) := by + simp only [replacementImageFormula,SigmaFormula.Realize,SigmaFormula.realize_andBounded, + Formula.Realize,cons_zero,cons_succ,SigmaFormula.realize_rename] + have eq (x : ZFSet.{u}) : (fun i => cons x (cons y (cons a e)) (replacementImageVars i)) = + cons y (cons x e) := by + funext i; rcases i with _|i; rfl + rcases i with _|i <;> rfl + simp only [eq] + exact ⟨fun ⟨x,_,hx,hφ⟩ => ⟨x,hx,hφ⟩, + fun ⟨x,hx,hφ⟩ => ⟨x,hN a ha x hx,hx,hφ⟩⟩ + +theorem relativeModel_sigma_replacement (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) : SigmaReplacement (relativeModel M R) := by + intro φ e he a ha htotal + let N := relativeModel M R + have hN := relativeModel_transitive M R hM + obtain ⟨W,hW,hw⟩ := relativeModel_sigma_collection M R hM hT hR φ e he a ha + (fun x hx => by obtain ⟨y,hy,hφ,_⟩ := htotal x hx; exact ⟨y,hy,hφ⟩) + obtain ⟨b,hb,hbdef⟩ := relativeModel_sigma_separation M R hM hT hR + (replacementImageFormula φ) (cons a e) (by intro n; cases n; exact ha; exact he _) W hW + refine ⟨b,hb,?_⟩ + intro y hy + rw [hbdef y hy,replacementImageFormula_spec φ N a y hN ha e] + constructor + · exact And.right + · rintro ⟨x,hx,hφ⟩ + obtain ⟨z,hz,hφz⟩ := hw x hx + obtain ⟨w,hw,_,hu⟩ := htotal x hx + have hyz : y = z := (hu y hy hφ).trans (hu z (hN W hW z hz) hφz).symm + exact ⟨hyz ▸ hz,x,hx,hφ⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeSigmaWitness.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeSigmaWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..75363f59558b7d06044be2b7f4b910dfb785192c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/RelativeSigmaWitness.lean @@ -0,0 +1,107 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModelPower + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open BoundedSetTheory TransitiveNameModel BoundedDefinability SetModelFunctions +open ElementaryModel SentenceForm +universe u + +theorem relative_level_subset (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) {o : Ordinal.{u}} (ho : o.toZFSet ∈ M) : + level R o ⊆ relativeModel M R := + fun x hx => (mem_relativeModel M R x hM hT hR).mpr ⟨o,ho,hx⟩ + +theorem relative_sigma_level_witness (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) (i : Ordinal.{u}) (hi : i.toZFSet ∈ M) + (φ : SigmaFormula) (e : ℕ → ZFSet.{u}) (he : ∀ n, e n ∈ level R i) + (hφ : φ.Realize (relativeModel M R) e) : + ∃ o : Ordinal.{u}, o.toZFSet ∈ M ∧ level R i ⊆ level R o ∧ + φ.Realize (level R o) e := by + obtain ⟨xs,hlen,hxs,hmat⟩ := (φ.realize_iff_prefix _ e).mp hφ + have hsM := FiniteTuple.elements_mem M hM hT.pairing hT.union + (by simpa only [Ordinal.toZFSet_zero] using internal_ordinal_zero M hM hT) xs + (fun x hx => relativeModel_subset M R (hxs x hx)) + obtain ⟨j,hj,hjs⟩ := relative_level_bound M R (FiniteTuple.elements xs) hM hT hR hsM + (fun x hx => (mem_relativeModel M R x hM hT hR).mp + (hxs x ((FiniteTuple.mem_elements x xs).mp hx))) + have hlist : ∀ x ∈ xs, x ∈ level R (max i j) := fun x hx => + level_mono R (le_max_right i j) (hjs ((FiniteTuple.mem_elements x xs).mpr hx)) + have heL : ∀ n, e n ∈ level R (max i j) := fun n => level_mono R (le_max_left i j) (he n) + have heN := fun n => relative_level_subset M R hM hT hR hi (he n) + refine ⟨max i j,internal_ordinal_max M hi hj,level_mono R (le_max_left i j), + (φ.realize_iff_prefix _ e).mpr ⟨xs,hlen,hlist,?_⟩⟩ + exact (φ.matrix.absolute _ (level_transitive R _) _ (SigmaFormula.feed_mem xs e _ hlist heL)).mpr + ((φ.matrix.absolute _ (relativeModel_transitive M R hM) _ + (SigmaFormula.feed_mem xs e _ hxs heN)).mp hmat) + +theorem sigmaDefinable_request_bound {M : ZFSet.{u}} + {P : (ℕ → ZFSet.{u}) → Prop} (h : SigmaDefinable M P) + (hM : Transitive M) (hT : SourceT M) (e : ℕ → ZFSet.{u}) + (he : ∀ i, e i ∈ M) {a : ZFSet.{u}} (ha : a ∈ M) : + ∃ W ∈ M, ∀ x ∈ a, (∃ y ∈ M, P (cons y (cons x e))) → + ∃ y ∈ W, P (cons y (cons x e)) := by + obtain ⟨p,d,hd,hp⟩ := h + let q := (p.rename bindSlots).rename (liftMap bindSlots) + have hm : ∀ i, mix e d i ∈ M := by + intro i; unfold mix; split <;> first | exact he _ | exact hd _ + have hq (x y : ZFSet.{u}) (hx : x ∈ M) (hy : y ∈ M) : + q.Realize M (cons y (cons x (mix e d))) ↔ P (cons y (cons x e)) := by + dsimp only [q] + rw [SigmaFormula.realize_rename] + have eq : (fun n => cons y (cons x (mix e d)) (liftMap bindSlots n)) = + cons y (mix (cons x e) d) := by + funext n; cases n with + | zero => rfl + | succ n => exact congrFun (bind_mix x e d) n + rw [eq,SigmaFormula.realize_rename] + change p.Realize M (cons y (mix (cons x e) d) ∘ bindSlots) ↔ _ + rw [bind_mix] + exact hp _ (by + intro i + rcases i with _|i; exact hy + rcases i with _|i; exact hx + exact he i) + obtain ⟨W,hW,hw⟩ := internal_sigma_request_bound M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix hT.replacement.finitePrefix hT.infinity hT.choice q (mix e d) hm ha + refine ⟨W,hW,?_⟩ + intro x hx hxy + have hxM := hM a ha x hx + obtain ⟨y,hy,hqxy⟩ := hw x hx (by + obtain ⟨y,hy,hxy⟩ := hxy + exact ⟨y,hy,(hq x y hxM hy).mpr hxy⟩) + exact ⟨y,hy,(hq x y hxM (hM W hW y hy)).mp hqxy⟩ + +theorem relative_sigma_request_definable (M R : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) (φ : SigmaFormula) : + SigmaDefinable M (fun e => (e 0).IsOrdinal ∧ e 2 ⊆ stage R (e 0) ∧ + φ.Realize (stage R (e 0)) (cons (e 1) (fun i => e (i+3)))) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet, + hT.separation.finitePrefix.bounded,hT.infinity⟩ + let v : ℕ → ℕ := fun n => match n with | 0 => 4 | k+1 => 2*(k+4) + have hs : Definable M (fun e => φ.Realize (e 0) (cons (e 2) (fun i => e (i+4)))) := by + refine ⟨setBounded (fromSigma φ) 0 v,fun _ => ZFSet.omega,fun _ => C.omega_mem,?_⟩ + intro e + rw [setBounded_eval,show mix e (fun _ => ZFSet.omega) 0 = e 0 from rfl,sigma_sat] + have eq : (fun i => mix e (fun _ => ZFSet.omega) (v i)) = + cons (e 2) (fun i => e (i+4)) := by + funext i; cases i with + | zero => exact mix_even e (fun _ => ZFSet.omega) 2 + | succ i => simp [v] + rw [eq] + have h := (stage_sigmaDefinable M R hM hT hR).and + (((ordinal_definable C 1).toSigma hM).and + (((SentenceCoding.defSubset C 3 0).toSigma hM).and (hs.toSigma hM))) + apply h.existsSet.congr + intro e he + change (∃ A ∈ M, A = stage R (e 0) ∧ (e 0).IsOrdinal ∧ e 2 ⊆ A ∧ + φ.Realize A (cons (e 1) (fun i => e (i+3)))) ↔ _ + constructor + · rintro ⟨A,_,rfl,ho,ht,hφ⟩; exact ⟨ho,ht,hφ⟩ + · rintro ⟨ho,ht,hφ⟩ + exact ⟨_,stage_mem M R (e 0) hM hT hR (he 0),rfl,ho,ht,hφ⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/SeedBoundStageSyntax.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/SeedBoundStageSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..017b0920d8b9395e030e95d499e10f235d459bdc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/SeedBoundStageSyntax.lean @@ -0,0 +1,84 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedHierarchyCertificates +import OAI.Computability.DegreeRigidity.Constructibility.RelativeConstruction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +theorem insertedSelf_definable {M : ZFSet.{u}} (C : Context M) (s R : ℕ) : + Definable M (fun e => e s = insert (e R) (e R)) := by + have h := (member_definable C R s).and ((defSubset C R s).and + (defAllMem (defOr (equal_definable C 0 (R+1)) (member_definable C 0 (R+1))) s)) + apply h.congr + intro e + constructor + · rintro ⟨hR,hsub,hall⟩ + apply ZFSet.ext; intro z + rw [ZFSet.mem_insert_iff] + exact ⟨fun hz => hall z hz,fun h => h.elim (fun he => he ▸ hR) (fun hz => hsub hz)⟩ + · rintro he + rw [he] + exact ⟨ZFSet.mem_insert_iff.mpr (Or.inl rfl), + fun _ hz => ZFSet.mem_insert_iff.mpr (Or.inr hz),fun _ hz => ZFSet.mem_insert_iff.mp hz⟩ + +def SeedBoundStage (N w sq R x A : ZFSet.{u}) : Prop := + ∃ s ∈ N, ∃ d ∈ N, ∃ f ∈ N, ∃ r ∈ N, + s = insert R R ∧ x ∈ d ∧ CheckedHierarchyGraph N w sq s d r f ∧ StageStep s f r x A + +theorem seedBoundStage_domainDefinable {M : ZFSet.{u}} (C : Context M) : + DomainDefinable M (fun N e => SeedBoundStage N (e 3) (e 4) (e 2) (e 1) (e 0)) := by + have h := (insertedSelf_definable C 3 6).toDomain.and + ((member_definable C 5 2).toDomain.and + ((checkedHierarchyGraph_domainDefinable C 7 8 3 2 0 1).and + (stageStep_definable C 3 1 0 5 4).toDomain)) + exact h.existsSet.existsSet.existsSet.existsSet + +theorem SeedBoundStage.sound {M N x A : ZFSet.{u}} (hM : Transitive M) + (hf : ∀ p : SentenceForm, family p ∈ N) + (hs : ∀ p : SentenceForm, supportGraph p ∈ N) + (h : SeedBoundStage N ZFSet.omega (ZFSet.prod ZFSet.omega ZFSet.omega) + (groundReals M) x A) : A = stage (groundReals M) x := by + obtain ⟨s,_,d,_,f,_,r,_,he,hx,hg,hstep⟩ := h + have heq : s = seed (groundReals M) := he.trans (ground_seed_shape M hM).symm + rw [heq] at hg hstep + exact hg.stage_exact hf hs hx hstep + +theorem seed_bound_stage_at_levels (M x : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hx : x ∈ relativeModel M (groundReals M)) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ + ∀ δ : Ordinal.{u}, δ.toZFSet ∈ M → γ ≤ δ → + x ∈ level (groundReals M) δ ∧ stage (groundReals M) x ∈ level (groundReals M) δ ∧ + ∀ A : ZFSet.{u}, SeedBoundStage (level (groundReals M) δ) ZFSet.omega + (ZFSet.prod ZFSet.omega ZFSet.omega) (groundReals M) x A ↔ A = stage (groundReals M) x := by + let R := groundReals M + have hR := groundReals_mem M hM hT + have C := ground_relative_context M hM hT + have hRep := relativeModel_sigma_replacement M R hM hT hR + have hColl := relativeModel_sigma_collection M R hM hT hR + have hRN : R ∈ relativeModel M R := + (mem_relativeModel M R R hM hT hR).mpr (parameter_in_relativeModel M R hM hT) + have hs := seed_mem_collection _ R C hRep hRN + obtain ⟨d,hd,f,hf,hxd,hg⟩ := relative_internal_hierarchy_cover M x hM hT hx + have hr := iterUnion_mem _ C.transitive C.union hf 2 + obtain ⟨α,hα,hαspec⟩ := hierarchy_checked_at_levels M (seed R) d _ f hM hT hs hd hr hf hg + have hA := stage_mem_collection _ R x C hRep hColl hRN hx + obtain ⟨β,hβ,hβA⟩ := (mem_relativeModel M R _ hM hT hR).mp hA + refine ⟨max α β,internal_ordinal_max M hα hβ,?_⟩ + intro δ hδ hle + obtain ⟨hsL,hdL,hrL,hfL,_,_,hfamily,hsupport,hchecked⟩ := + hαspec δ hδ ((le_max_left α β).trans hle) + have hxL := level_transitive R δ d hdL x hxd + refine ⟨hxL,level_mono R ((le_max_right α β).trans hle) hβA,?_⟩ + intro A + constructor + · exact SeedBoundStage.sound hM hfamily hsupport + · rintro rfl + exact ⟨seed R,hsL,d,hdL,f,hfL,_,hrL,ground_seed_shape M hM,hxd,hchecked, + (hg.stageStep_iff x hxd _).mpr rfl⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/SingleRealConstruction.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/SingleRealConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b5780c9d8a02ae2a3a8b22cee42620e954f6a0a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/SingleRealConstruction.lean @@ -0,0 +1,168 @@ +import OAI.Computability.DegreeRigidity.Computability.RealProjectionSyntax + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SetModelArithmetic +universe u + +def bitOracle (P : Oracle) (bs : List Bool) : Oracle := fun n => P (bitIndex bs n) + +theorem bitOracle_part (P : Oracle) (bs : List Bool) (i : ℕ) : + realPart (bitOracle P bs) i = bitOracle P (bs ++ partBits i) := by + funext n + rw [realPart_bits] + simp only [bitOracle,bitIndex_append] + +noncomputable def Construction.stageInputs (R : ZFSet.{u}) (t : Construction.{u}) (k : ℕ) : ZFSet.{u} := + match t.inputData k with + | .stage o => level R o + | _ => R + +theorem Construction.stageInputs_child (R : ZFSet.{u}) + (o : Ordinal.{u}) (n : ℕ) (p : SentenceForm) (c : Fin n → Construction.{u}) + (i : Fin n) (k : ℕ) : + (Construction.define o n p c).stageInputs R (Nat.pair i k+1) = (c i).stageInputs R k := by + simp only [Construction.stageInputs,Construction.inputData,Nat.unpair_pair] + rw [dite_eq_left i.isLt] + cases (c i).inputData k <;> rfl + +theorem Construction.stageInputs_mem (t : Construction.{u}) (M R : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (hR : R ∈ M) (hi : t.Indexed M) : + ∀ k, t.stageInputs R k ∈ M := by + intro k + have hk := t.inputData_indexed M hi k + unfold Construction.stageInputs + cases hd : t.inputData k with + | reals => exact hR + | realPath path => exact hR + | stage o => + rw [hd] at hk + exact level_mem M R hM hT hR o hk + +noncomputable def Construction.singleFormula : Construction.{u} → List Bool → + ℕ → ℕ → ℕ → ℕ → ℕ → ℕ → (ℕ → ℕ) → SentenceForm + | .reals, _, out, R, _, _, _, _, _ => .equal out R + | .parameter, bs, out, _, P, w, a, d, _ => projectionFormula bs out w a d P + | .define _ n p c, bs, out, R, P, w, a, d, r => bindComputed n + (fun i => if h : i < n then + (c ⟨i,h⟩).singleFormula (bs ++ partBits i) 0 (R+1) (P+1) (w+1) (a+1) (d+1) + (fun k => r (Nat.pair i k+1)+1) + else .equal 0 0) + (subsetBody n out (r 0) p) + +theorem Construction.singleFormula_spec (t : Construction.{u}) (M R : ZFSet.{u}) + (hM : Transitive M) (P : Oracle) (bs : List Bool) + (ht : t.Certified R (bitOracle P bs)) + (out rR rP w a d : ℕ) (r : ℕ → ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hRR : e rR = R) (hPP : e rP = realCode P) (hw : e w = ZFSet.omega) + (ha : e a = additionSet) (hd : e d = pairNumbers) + (hr : ∀ k, e (r k) = t.stageInputs R k) : + (t.singleFormula bs out rR rP w a d r).Sat (M : Set ZFSet) e ↔ + e out = t.value R (bitOracle P bs) := by + induction t generalizing bs out rR rP w a d r e with + | reals => exact Iff.of_eq (congrArg (e out = ·) hRR) + | parameter => exact projectionFormula_spec M hM bs out w a d rP e he hw ha hd P hPP + | define o n p c ih => + let v : ℕ → ZFSet.{u} := fun i => if h : i < n then + (c ⟨i,h⟩).value R (realPart (bitOracle P bs) i) else R + have hv (i : ℕ) (hin : i < n) : v i ∈ M := by + dsimp [v]; rw [dite_eq_left hin] + exact hM _ (show level R o ∈ M from (show e (r 0) = level R o from hr 0) ▸ he (r 0)) _ (ht.2 ⟨i,hin⟩).2 + have hf (i : ℕ) (hin : i < n) (x : ZFSet.{u}) (hx : x ∈ M) : + (if h : i < n then + (c ⟨i,h⟩).singleFormula (bs ++ partBits i) 0 (rR+1) (rP+1) (w+1) (a+1) (d+1) + (fun k => r (Nat.pair i k+1)+1) else .equal 0 0).Sat + (M : Set ZFSet) (cons x e) ↔ x = v i := by + rw [dite_eq_left hin,show v i = (c ⟨i,hin⟩).value R (realPart (bitOracle P bs) i) from dite_eq_left hin, + bitOracle_part] + have hc : (c ⟨i,hin⟩).Certified R (bitOracle P (bs ++ partBits i)) := by + rw [← bitOracle_part]; exact (ht.2 ⟨i,hin⟩).1 + apply ih ⟨i,hin⟩ _ hc 0 (rR+1) (rP+1) (w+1) (a+1) (d+1) + (fun k => r (Nat.pair i k+1)+1) (cons x e) + (by intro k; cases k; exact hx; exact he _) hRR hPP hw ha hd + intro k + change e (r (Nat.pair i k+1)) = _ + rw [hr,Construction.stageInputs_child R o n p c ⟨i,hin⟩ k] + rw [Construction.singleFormula,bindComputed_spec M n _ _ e v hv hf, + subsetBody_spec M hM n out (r 0) p ht.1 e v he hv] + have hA : e (r 0) = level R o := hr 0 + rw [hA] + have hvs : (fun i : Fin n => v i) = + (fun i : Fin n => (c i).value R (realPart (bitOracle P bs) i)) := by + funext i; exact dite_eq_left i.isLt + rw [hvs] + rfl + +noncomputable def Construction.singleMembership (t : Construction.{u}) : SentenceForm := + .ex (.conj (t.singleFormula [] 0 2 3 4 5 6 (fun k => k+7)) (.member 1 0)) + +noncomputable def Construction.singleInputs (t : Construction.{u}) (R : ZFSet.{u}) (P : Oracle) : ℕ → ZFSet.{u} := + cons R (cons (realCode P) (cons ZFSet.omega (cons additionSet + (cons pairNumbers (t.stageInputs R))))) + +theorem Construction.singleInputs_mem (t : Construction.{u}) (M R : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (hR : R ∈ M) (P : Oracle) + (hP : P ∈ modelReals M) (hi : t.Indexed M) : ∀ i, t.singleInputs R P i ∈ M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + intro i + rcases i with _|_|_|_|_|i + · exact hR + · exact hP + · exact hω + · exact additionSet_mem M hM hT.pairing hT.union hT.powerSet hS hT.infinity + · exact product_mem M hM hT.pairing hT.union hT.powerSet hS hω hω + · exact t.stageInputs_mem M R hM hT hR hi i + +theorem Construction.singleMembership_of_inputs (t : Construction.{u}) (M R : ZFSet.{u}) + (hM : Transitive M) (P : Oracle) (ht : t.Certified R P) + (hinputs : ∀ i, t.singleInputs R P i ∈ M) (hvalue : t.value R P ∈ M) + (z : ZFSet.{u}) (hz : z ∈ M) : + t.singleMembership.Sat (M : Set ZFSet) (cons z (t.singleInputs R P)) ↔ + z ∈ t.value R P := by + have hs (x : ZFSet.{u}) (hx : x ∈ M) : + (t.singleFormula [] 0 2 3 4 5 6 (fun k => k+7)).Sat (M : Set ZFSet) + (cons x (cons z (t.singleInputs R P))) ↔ x = t.value R P := by + apply t.singleFormula_spec M R hM P [] ht + · intro i + rcases i with _|_|i + · exact hx + · exact hz + · exact hinputs i + all_goals first | rfl | exact fun _ => rfl + change (∃ x ∈ M, (t.singleFormula [] 0 2 3 4 5 6 (fun k => k+7)).Sat + (M : Set ZFSet) (cons x (cons z (t.singleInputs R P))) ∧ z ∈ x) ↔ _ + constructor + · rintro ⟨x,hx,hf,hzx⟩; exact (hs x hx).mp hf ▸ hzx + · intro hzv + have hv := hvalue + exact ⟨_,hv,(hs _ hv).mpr rfl,hzv⟩ + +theorem Construction.singleMembership_spec (t : Construction.{u}) (M R : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (hR : R ∈ M) (P : Oracle) + (hP : P ∈ modelReals M) (ht : t.Certified R P) (hi : t.Indexed M) + (z : ZFSet.{u}) (hz : z ∈ M) : + t.singleMembership.Sat (M : Set ZFSet) (cons z (t.singleInputs R P)) ↔ + z ∈ t.value R P := by + have hs (x : ZFSet.{u}) (hx : x ∈ M) : + (t.singleFormula [] 0 2 3 4 5 6 (fun k => k+7)).Sat (M : Set ZFSet) + (cons x (cons z (t.singleInputs R P))) ↔ x = t.value R P := by + apply t.singleFormula_spec M R hM P [] ht + · intro i + rcases i with _|_|i + · exact hx + · exact hz + · exact t.singleInputs_mem M R hM hT hR P hP hi i + all_goals first | rfl | exact fun _ => rfl + change (∃ x ∈ M, (t.singleFormula [] 0 2 3 4 5 6 (fun k => k+7)).Sat + (M : Set ZFSet) (cons x (cons z (t.singleInputs R P))) ∧ z ∈ x) ↔ _ + constructor + · rintro ⟨x,hx,hf,hzx⟩; exact (hs x hx).mp hf ▸ hzx + · intro hzv + have hv := t.value_mem M R hM hT hR P ht hi + exact ⟨_,hv,(hs _ hv).mpr rfl,hzv⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformDefSuccessor.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformDefSuccessor.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9c65c67f5744c794ea6326a94652115647bcfec --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformDefSuccessor.lean @@ -0,0 +1,45 @@ +import OAI.Computability.DegreeRigidity.Constructibility.DefSystemCertificate +import OAI.Computability.DegreeRigidity.Syntax.SigmaParameterized + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +theorem definablePower_sigmaDefinable (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + SigmaDefinable M (fun e => e 0 = definablePower (e 1)) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + obtain ⟨Q,hQ,_,hq⟩ := internal_family_bound M hM C.pairing C.union C.power C.omega_mem + obtain ⟨B,hB,hb⟩ := internal_support_bound C + have hc := (defSystem_definable C hQ hB 5 3 2 1 0 4).toSigma hM + have hs := hc.existsSet.existsSet.existsSet.existsSet + apply hs.congr + intro e he + change (∃ G ∈ M, ∃ T ∈ M, ∃ H ∈ M, ∃ Z ∈ M, + DefSystem Q B (e 1) G T H Z (e 0)) ↔ e 0 = definablePower (e 1) + constructor + · rintro ⟨G,_,T,_,H,_,Z,_,h⟩ + exact h.exact hq hb + · intro h + rw [h] + exact internal_defSystem M hM hT Q B (e 1) (he 1) hq hb + +theorem uniform_definable_successor (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ∃ p : SigmaFormula, ∃ d : ℕ → ZFSet.{u}, (∀ i, d i ∈ M) ∧ + ∀ A ∈ M, ∀ D ∈ M, p.Realize M (cons D (cons A d)) ↔ D = definablePower A := + (definablePower_sigmaDefinable M hM hT).binary definablePower + +theorem definablePower_image_mem (M a : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (ha : a ∈ M) : + ∃ b ∈ M, ∀ y, y ∈ b ↔ ∃ x ∈ a, definablePower x = y := by + obtain ⟨p,d,hd,hp⟩ := uniform_definable_successor M hM hT + exact replacement_image M hM hT.replacement.finitePrefix p d hd ha definablePower + (fun x hx => definablePower_mem M x hM hT (hM a ha x hx)) + (fun x hx y hy => hp x (hM a ha x hx) y hy) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformDefinedSubsetName.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformDefinedSubsetName.lean new file mode 100644 index 0000000000000000000000000000000000000000..626d3eab40fdc972698f8f5def251f563ef3a304 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformDefinedSubsetName.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformSeparationName +import OAI.Computability.DegreeRigidity.Syntax.SetSatisfactionBounded +import OAI.Computability.DegreeRigidity.Representation.GroundInclusion +import OAI.Computability.DegreeRigidity.Representation.SourceTheory + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel RecursiveNames +open BoundedForcing AtomicForcing CountableForcing +universe u + +theorem uniform_definedSubset_name (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r t : Conditions c, ZFSet.pair (label c r) (label c t) ∈ o ↔ r ≤ t) + (A a : Name (Conditions c)) (hA : A.encode (label c) ∈ M) + (ha : a.encode (label c) ∈ M) (φ : SentenceForm) : + ∃ f : Name (Conditions c), f.encode (label c) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → + f.val G.carrier = definedSubset (A.val G.carrier) φ + (fun _ : Fin φ.bound => a.val G.carrier) := by + let e := push A (fun _ => a) + have he (i : ℕ) : (e i).encode (label c) ∈ M := by + cases i; exact hA; exact ha + let ψ := setBounded φ 1 (fun i => if i = 0 then 0 else 2) + obtain ⟨B,hB,hBS,hval⟩ := uniform_separation_name M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity + hc hoM ho ψ A hA e he + refine ⟨A.restrict (label c) B,?_,?_⟩ + · rw [Name.encode_restrict _ _ _ hBS]; exact hB + · intro G hG + apply ZFSet.ext; intro x + rw [hval G hG x,mem_definedSubset] + apply and_congr_right; intro _ + rw [setBounded_eval] + apply φ.finite_support + intro i hi + cases i with + | zero => rfl + | succ i => + change a.val G.carrier = tupleEnv (fun _ : Fin φ.bound => a.val G.carrier) i + simp only [tupleEnv,dite_eq_left (show i < φ.bound by omega)] + +theorem uniform_checked_definition_name (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r t : Conditions c, ZFSet.pair (label c r) (label c t) ∈ o ↔ r ≤ t) + (A : Name (Conditions c)) (hA : A.encode (label c) ∈ M) + (X : ZFSet.{u}) (hX : X ∈ M) (φ : SentenceForm) : + ∃ f : Name (Conditions c), f.encode (label c) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ⊤ ∈ G.carrier → + f.val G.carrier = definedSubset (A.val G.carrier) φ + (fun _ : Fin φ.bound => X) := by + have hcX := encoded_check_mem M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc hX + obtain ⟨f,hf,hval⟩ := uniform_definedSubset_name M hM hT hc hoM ho + A (Name.check X) hA hcX φ + refine ⟨f,hf,?_⟩ + intro G hG ht + simpa only [Name.val_check G.carrier ht X] using hval G hG + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformDefinitionSymmetry.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformDefinitionSymmetry.lean new file mode 100644 index 0000000000000000000000000000000000000000..263accf25372c32d4f0d8c4b7dae8a4ca6eaa4b9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformDefinitionSymmetry.lean @@ -0,0 +1,38 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformOrdinalDefinitionName +import OAI.Computability.DegreeRigidity.SetModels.InternalOrderIsoTransport + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem uniform_ordinal_definition_symmetric (M c : ZFSet.{0}) + [OrderTop (Conditions c)] (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) + (δ : Ordinal.{0}) (hδ : δ.toZFSet ∈ M) (X : ZFSet.{0}) (hX : X ∈ M) + (φ : ElementaryModel.SentenceForm) : + ∃ f : Name (Conditions c), f.encode (label c) ∈ M ∧ + (∀ G : GenericFilter (Conditions c), GroundGeneric M G → + f.val G.carrier = definedSubset + (level (groundReals (genericExtensionSet M c G.carrier)) δ) + φ (fun _ : Fin φ.bound => X)) ∧ + ∀ w ∈ M, ∀ e : Conditions c ≃o Conditions c, + (∀ p q, ZFSet.pair (label c p) (label c q) ∈ w ↔ q = e p) → + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → + f.val (AutomorphismName.mapFilter e G).carrier = f.val G.carrier := by + obtain ⟨f,hf,hfv⟩ := uniform_ordinal_definition_name M hM hT hc + (InternalCollapse.orderSet_mem M hM hT hc) (InternalCollapse.orderSet_pair c) δ hδ X hX φ + have hall (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) : + f.val G.carrier = definedSubset + (level (groundReals (genericExtensionSet M c G.carrier)) δ) + φ (fun _ : Fin φ.bound => X) := by + obtain ⟨p,hp⟩ := G.nonempty + exact hfv G hG (G.upper le_top hp) + refine ⟨f,hf,hall,?_⟩ + intro w hw e he G hG + have hGe := InternalOrderIsoTransport.map_ground_generic M c c w hM hT hc hc hw e he G hG + rw [hall _ hGe,hall G hG,InternalOrderIsoTransport.extension_eq M c c w hM hT hc hc hw e he G hG] + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformExtensionWitnessCover.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformExtensionWitnessCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bb37aba1dced36f0d88775a168a6d50062bd83d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformExtensionWitnessCover.lean @@ -0,0 +1,55 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformNameValueCover +import OAI.Computability.DegreeRigidity.SetModels.ExtensionWitnessCover + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem uniform_extension_witness_cover (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (φ : SigmaFormula) (e : ℕ → Name (Conditions c)) (he : ∀ i, (e i).encode (label c) ∈ M) + (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) [Top (Conditions c)] : + ∃ N : Name (Conditions c), N.encode (label c) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ⊤ ∈ G.carrier → + ∀ x ∈ a.val G.carrier, + (∃ y ∈ genericExtensionSet M c G.carrier, + φ.Realize (genericExtensionSet M c G.carrier) (cons y (cons x (fun i => (e i).val G.carrier)))) → + ∃ y ∈ N.val G.carrier, + φ.Realize (genericExtensionSet M c G.carrier) (cons y (cons x (fun i => (e i).val G.carrier))) := by + obtain ⟨d,hd,hdt,had⟩ := internal_transitive_container M hM hP hU hS.bounded hR hI ha + obtain ⟨W,hW,hbound⟩ := forcing_witness_bound M hM hP hU hPow hS hR hI hAC hc hoM ho φ e he hd + obtain ⟨N,hN,hcover⟩ := uniform_name_value_cover M hM hP hU hPow hS hR hI hc hW + refine ⟨N,hN,?_⟩ + intro G hG ht x hx hw + obtain ⟨b,hbd,rfl⟩ := name_of_value_member d hdt a had G.carrier x hx + have hb := hM d hd _ hbd + obtain ⟨y,hy,hφ⟩ := hw + obtain ⟨v,hv,rfl⟩ := (mem_extensionSet M c G.carrier y).mp hy + have env (v : Name (Conditions c)) (hv : v.encode (label c) ∈ M) : + ∀ i, (push v (push b e) i).encode (label c) ∈ M := by + intro i; rcases i with _|i; exact hv + rcases i with _|i; exact hb + exact he i + have values (v : Name (Conditions c)) : (fun i => (push v (push b e) i).val G.carrier) = + cons (v.val G.carrier) (cons (b.val G.carrier) (fun i => (e i).val G.carrier)) := by + funext i; rcases i with _|i; rfl + rcases i with _|i <;> rfl + rw [← values v] at hφ + obtain ⟨p,hp,hforce⟩ := (internal_sigma_truth M hM hP hU hPow hS.bounded hR hI hc hoM ho G hG + φ (push v (push b e)) (env v hv)).mp hφ + obtain ⟨w,hw,hforcew⟩ := hbound b hbd p ⟨v,hv,hforce⟩ + have hwM := hM W hW _ hw + have hφw := (internal_sigma_truth M hM hP hU hPow hS.bounded hR hI hc hoM ho G hG + φ (push w (push b e)) (env w hwM)).mpr ⟨p,hp,hforcew⟩ + rw [values w] at hφw + exact ⟨w.val G.carrier,hcover G.carrier ht w hw,hφw⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformFragmentHull.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformFragmentHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..92a6ea775a16a5b24b38a88cf0b5678586e8a1d5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformFragmentHull.lean @@ -0,0 +1,76 @@ +import OAI.Computability.DegreeRigidity.SetModels.GeneratedHull + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse +universe u +namespace FiniteTuple + +theorem uniform_internal_fragment_hull (M t : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) + (ht : t ∈ M) (h0t : (∅ : ZFSet.{u}) ∈ t) : + ∃ K ∈ M, ∀ xs : List ZFSet.{u}, (∀ x ∈ xs, x ∈ M) → + ∀ d ∈ M, Transitive d → (t ∪ elements xs) ⊆ d → ∀ φ : Formula, + ∃ h ∈ M, (t ∪ elements xs) ⊆ h ∧ h ⊆ d ∧ StructureExtensional h ∧ + (∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ h) → (φ.Realize h e ↔ φ.Realize d e)) ∧ + ∃ f ∈ M, ∃ j : ZFSet.{u} → ZFSet.{u}, Presents h f j ∧ + (∀ x ∈ h, j x ∈ K) ∧ (∀ x ∈ h, ∀ y ∈ h, j x = j y → x = y) := by + have hω := omega_mem M hM hS.bounded hI + have hA := indexSpace_mem M hM hP hU hPow hS.bounded hω ht + obtain ⟨T,hT,hTT,hpair⟩ := internal_transitive_container M hM hP hU hS.bounded hR hI + (pair_mem M hM hP hA hω) + have hAT : indexSpace t ⊆ T := fun x hx => hTT _ + (hTT _ hpair _ (ZFSet.mem_pair.mpr (Or.inl rfl))) x hx + have hωT : ZFSet.omega.{u} ⊆ T := fun x hx => hTT _ + (hTT _ hpair _ (ZFSet.mem_pair.mpr (Or.inr rfl))) x hx + have hnT : ∀ n, natSet.{u} n ∈ T := fun n => hωT ((mem_omega _).mpr ⟨n,rfl⟩) + obtain ⟨K,hK,hgraphs⟩ := FiniteTerm.uniform_internal_evaluation_graph M T hM hP hU hPow hS hR hI hT hTT hnT + refine ⟨K,hK,?_⟩ + intro xs hxs d hd hdt hsd φ + let n := max 2 φ.width + have hspace := space_mem M hM hP hU hPow hS.bounded hd n + obtain ⟨V,hV,hVT,hpairV⟩ := internal_transitive_container M hM hP hU hS.bounded hR hI + (pair_mem M hM hP hd hspace) + have hdV : d ⊆ V := fun x hx => hVT _ + (hVT _ hpairV _ (ZFSet.mem_pair.mpr (Or.inl rfl))) x hx + have hspaceV : space d n ⊆ V := fun x hx => hVT _ + (hVT _ hpairV _ (ZFSet.mem_pair.mpr (Or.inr rfl))) x hx + obtain ⟨L,hL,hLf,hLc⟩ := FiniteTerm.internal_leaf_graph M hM hP hU hPow hS.bounded hR hω ht xs hxs + obtain ⟨O,hO,hOf,_,hOps⟩ := FiniteTerm.internal_skolem_operations M hM hP hU hPow hS.bounded hR hI hAC + hd n (differenceBody :: fragment n φ) 0 + obtain ⟨E,hE,hEsub,hEgraph⟩ := hgraphs (indexSpace t) hA hAT ZFSet.omega hω hωT L hL O hO V hV + let h := FiniteTerm.generatedRange d K E + have hh : h ∈ M := FiniteTerm.generatedRange_mem M hM hS.bounded hd hK hE + have hevalSeed (x : ZFSet.{u}) (hx : x ∈ t ∪ elements xs) : + ∃ c, FiniteTerm.Eval (indexSpace t) ZFSet.omega L O V c x := by + obtain ⟨a,ha,hax⟩ := hLc x hx + exact ⟨_,FiniteTerm.Eval.leaf ha (hdV (hsd hx)) hax⟩ + have hsh : t ∪ elements xs ⊆ h := fun x hx => + (FiniteTerm.mem_generatedRange hEgraph hEsub x).mpr ⟨hsd hx,hevalSeed x hx⟩ + have hhd : h ⊆ d := fun x hx => ((FiniteTerm.mem_generatedRange hEgraph hEsub x).mp hx).1 + have hzero := hevalSeed ∅ (ZFSet.mem_union.mpr (Or.inl h0t)) + have hclosed (ψ : Formula) (hψ : ψ ∈ differenceBody :: fragment n φ) : + ∃ g, SkolemGraph d n ψ (fun _ => d) g ∧ Closed n g h := by + obtain ⟨i,g,_,hgs,hgo⟩ := hOps ψ hψ + exact ⟨g,hgs,FiniteTerm.generatedRange_closed n hVT hdV hspaceV hEgraph hEsub hzero + (fun z hz => (ZFSet.mem_sep.mp (hgs.1 hz)).1) i hgo⟩ + have hext : StructureExtensional h := by + obtain ⟨g,hgs,hcl⟩ := hclosed differenceBody List.mem_cons_self + exact closed_extensional d h g n (Nat.le_max_left _ _) hdt hhd hcl ⟨g,fun _ hx => hx,hgs⟩ + have htransfer : ∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ h) → (φ.Realize h e ↔ φ.Realize d e) := by + intro e he + exact realize_of_witnesses d h hhd φ + (witnesses_of_closed_graphs d h n φ (Nat.le_max_right _ _) hhd + (fun ψ hψ => hclosed ψ (List.mem_cons_of_mem _ hψ))) e he + obtain ⟨f,hf,j,hfj,hj,hi⟩ := FiniteTerm.internal_evaluated_injection M hM hP hU hPow hS.bounded hAC + hh hK hE hLf hOf hEsub hEgraph + (fun x hx => ((FiniteTerm.mem_generatedRange hEgraph hEsub x).mp hx).2) + exact ⟨h,hh,hsh,hhd,hext,htransfer,f,hf,j,hfj,hj,hi⟩ + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformHeightDomains.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformHeightDomains.lean new file mode 100644 index 0000000000000000000000000000000000000000..ccff3146d656ffbbd0f13a5aac01275a51ab5b0a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformHeightDomains.lean @@ -0,0 +1,76 @@ +import OAI.Computability.DegreeRigidity.Representation.GroundSeedOrdinalHeight +import OAI.Computability.DegreeRigidity.Constructibility.ConstructionHeightDomains + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u +attribute [local irreducible] Construction.ownRealsMembership SentenceForm.bound + +noncomputable def realSeedOffset : Ordinal.{u} := + (insert ZFSet.omega ZFSet.omega : ZFSet.{u}).rank + +noncomputable def heightDomainIndex (a : Ordinal.{u}) : Ordinal.{u} := a - realSeedOffset + 1 + +theorem ground_seed_offset (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ordinalHeight (seed (groundReals M)) = realSeedOffset := ordinalHeight_ground_seed M hM hT + +theorem heightDomainIndex_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) : (heightDomainIndex a).toZFSet ∈ M := + internal_difference_successor M hM hT a realSeedOffset ha + +theorem largestOrdinal_ground_domain (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a : Ordinal.{u}) (ha : realSeedOffset ≤ a) : + a.toZFSet ∈ level (groundReals M) (heightDomainIndex a) ∧ + ∀ e : ℕ → ZFSet.{u}, e 0 ∈ level (groundReals M) (heightDomainIndex a) → + (largestOrdinalSentence.Sat (level (groundReals M) (heightDomainIndex a) : Set ZFSet) e ↔ + e 0 = a.toZFSet) := by + have hoff := ground_seed_offset M hM hT + have hm := largest_ordinal_at_difference (groundReals M) a (hoff ▸ ha) + rw [hoff] at hm + refine ⟨hm.1,?_⟩ + intro e he + exact largestOrdinalSentence_unique _ (level_transitive _ _) a hm.1 + (fun b hb => (hm.2 b).mp hb) e he + +theorem bindLargestOrdinal_ground_domain (p : SentenceForm) (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (a : Ordinal.{u}) (ha : realSeedOffset ≤ a) + (e : ℕ → ZFSet.{u}) : + (bindLargestOrdinal p).Sat (level (groundReals M) (heightDomainIndex a) : Set ZFSet) e ↔ + p.Sat (level (groundReals M) (heightDomainIndex a) : Set ZFSet) (cons a.toZFSet e) := by + have h := bindLargestOrdinal_level p (groundReals M) (a-realSeedOffset) e + rw [ground_seed_offset M hM hT,Ordinal.add_sub_cancel_of_le ha] at h + exact h + +theorem Construction.height_domain_subset (t : Construction.{u}) : + ∃ q : SentenceForm, ∀ M : ZFSet.{u}, Transitive M → SourceT M → + ∀ P : Oracle, P ∈ modelReals M → t.Certified (groundReals M) P → t.Indexed M → + ∃ β : Ordinal.{u}, β.toZFSet ∈ M ∧ realSeedOffset ≤ β ∧ + ∀ a : Ordinal.{u}, a.toZFSet ∈ M → β ≤ a → + (heightDomainIndex a).toZFSet ∈ M ∧ + (∀ i, t.ordinalInputs P i ∈ level (groundReals M) (heightDomainIndex a)) ∧ + (∀ e : ℕ → ZFSet.{u}, e 0 ∈ level (groundReals M) (heightDomainIndex a) → + (largestOrdinalSentence.Sat (level (groundReals M) (heightDomainIndex a) : Set ZFSet) e ↔ + e 0 = a.toZFSet)) ∧ + t.value (groundReals M) P = definedSubset + (level (groundReals M) (heightDomainIndex a)) q + (fun i : Fin q.bound => t.ordinalInputs P i) := by + obtain ⟨q,hq⟩ := t.largest_domain_definition + refine ⟨q,?_⟩ + intro M hM hT P hP ht hi + obtain ⟨β,hβ,hβspec⟩ := hq M hM hT P hP ht hi + have hoff : realSeedOffset.toZFSet ∈ M := by + rw [← ground_seed_offset M hM hT] + exact ordinalHeight_mem_model M _ hM hT.separation.finitePrefix.bounded + (seed_mem M _ hM hT (groundReals_mem M hM hT)) (seed_transitive _) + refine ⟨max β realSeedOffset,internal_ordinal_max M hβ hoff,le_max_right _ _,?_⟩ + intro a ha hle + obtain ⟨hδ,hv,he,hm,hdef⟩ := hβspec a ha ((le_max_left _ _).trans hle) + rw [ground_seed_offset M hM hT] at hδ hv he hm hdef + exact ⟨hδ,he,hm,definedSubset_of_membership _ _ (level_transitive _ _) hv q + (t.ordinalInputs P) hdef⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformHierarchyStage.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformHierarchyStage.lean new file mode 100644 index 0000000000000000000000000000000000000000..087d7ae64cca61a0b350e5c944e415a150a8746e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformHierarchyStage.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DegreeRigidity.Constructibility.InternalConstructibleHierarchy + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +theorem HierarchyGraph.stageStep_iff {M R d r f : ZFSet.{u}} + (h : HierarchyGraph M (seed R) d r f) (x : ZFSet.{u}) (hx : x ∈ d) (A : ZFSet.{u}) : + StageStep (seed R) f r x A ↔ A = stage R x := by + constructor + · intro hs + apply ZFSet.ext; intro z + rw [mem_stage] + constructor + · intro hz + rcases hs.2.1 z hz with hz|⟨y,hy,w,hw,hfw,hz⟩ + · exact Or.inl hz + · rw [h.correct y (h.1 x hx y hy) w hw hfw] at hz + exact Or.inr ⟨y,hy,hz⟩ + · rintro (hz|⟨y,hy,hz⟩) + · exact hs.1 hz + · obtain ⟨w,hw,hfw,_⟩ := h.2.1.2 y (h.1 x hx y hy) + rw [← h.correct y (h.1 x hx y hy) w hw hfw] at hz + exact hs.2.2 y hy w hw hfw hz + · rintro rfl + refine ⟨seed_subset_stage R x,?_,?_⟩ + · intro z hz + rcases (mem_stage R x z).mp hz with hz|⟨y,hy,hz⟩ + · exact Or.inl hz + · obtain ⟨w,hw,hfw,_⟩ := h.2.1.2 y (h.1 x hx y hy) + rw [← h.correct y (h.1 x hx y hy) w hw hfw] at hz + exact Or.inr ⟨y,hy,w,hw,hfw,hz⟩ + · intro y hy w hw hfw + rw [h.correct y (h.1 x hx y hy) w hw hfw] + exact definablePower_subset_stage R hy + +theorem stage_sigmaDefinable (M R : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hR : R ∈ M) : SigmaDefinable M (fun e => e 0 = stage R (e 1)) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + have hg : SigmaDefinable M (fun e => HierarchyGraph M (seed R) (e 2) (e 0) (e 1)) := by + have h := hierarchyGraph_sigmaDefinable hM hT 0 3 1 2 + have eq := (equal_param (seed_mem M R hM hT hR) 0).toSigma hM + exact (eq.and h).existsSet.congr (fun e _ => by simp [seed_mem M R hM hT hR]) + have hs : SigmaDefinable M (fun e => StageStep (seed R) (e 1) (e 0) (e 4) (e 3)) := by + have h := (stageStep_definable C 0 2 1 5 4).toSigma hM + have eq := (equal_param (seed_mem M R hM hT hR) 0).toSigma hM + exact (eq.and h).existsSet.congr (fun e _ => by simp [seed_mem M R hM hT hR]) + have hc := ((member_definable C 4 2).toSigma hM).and (hg.and hs) + apply hc.existsSet.existsSet.existsSet.congr + intro e he + change (∃ d ∈ M, ∃ f ∈ M, ∃ r ∈ M, e 1 ∈ d ∧ + HierarchyGraph M (seed R) d r f ∧ StageStep (seed R) f r (e 1) (e 0)) ↔ _ + constructor + · rintro ⟨d,_,f,_,r,_,hx,hg,hs⟩ + exact (hg.stageStep_iff (e 1) hx (e 0)).mp hs + · intro hv + obtain ⟨d,hd,f,hf,hx,hg⟩ := internal_hierarchy_cover M R (e 1) hM hT hR (he 1) + exact ⟨d,hd,f,hf,_,iterUnion_mem M hM hT.union hf 2,hx,hg, + (hg.stageStep_iff (e 1) hx (e 0)).mpr hv⟩ + +theorem uniform_stage_definition (M R : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hR : R ∈ M) : + ∃ p : SigmaFormula, ∃ a : ℕ → ZFSet.{u}, (∀ i, a i ∈ M) ∧ + ∀ x ∈ M, ∀ A ∈ M, p.Realize M (cons A (cons x a)) ↔ A = stage R x := + (stage_sigmaDefinable M R hM hT hR).binary (stage R) + +theorem stage_image_mem (M R a : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hR : R ∈ M) (ha : a ∈ M) : + ∃ b ∈ M, ∀ y, y ∈ b ↔ ∃ x ∈ a, stage R x = y := by + obtain ⟨p,e,he,hp⟩ := uniform_stage_definition M R hM hT hR + exact replacement_image M hM hT.replacement.finitePrefix p e he ha (stage R) + (fun x hx => stage_mem M R x hM hT hR (hM a ha x hx)) + (fun x hx y hy => hp x (hM a ha x hx) y hy) + +theorem hierarchy_stage_agreement {M N R d e r t f g A B x : ZFSet.{u}} + (hf : HierarchyGraph M (seed R) d r f) (hg : HierarchyGraph N (seed R) e t g) + (hx : x ∈ d) (hy : x ∈ e) + (hA : StageStep (seed R) f r x A) (hB : StageStep (seed R) g t x B) : A = B := + ((hf.stageStep_iff x hx A).mp hA).trans ((hg.stageStep_iff x hy B).mp hB).symm + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformInternalSatisfaction.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformInternalSatisfaction.lean new file mode 100644 index 0000000000000000000000000000000000000000..38e7db3be0e19a99030a64ea23410372faeab388 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformInternalSatisfaction.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformTruthRecursion +import OAI.Computability.DegreeRigidity.Syntax.SatisfactionCertificateBound + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +variable {M : ZFSet.{u}} + +def SatisfactionWitness (Q B G H A T z : ZFSet.{u}) : Prop := + ∃ c ∈ ZFSet.omega, ∃ t ∈ T, ∃ S ∈ H, + TruthWitness Q B G A T c S ∧ ZFSet.pair c t ∈ S ∧ z = ZFSet.pair c t + +theorem satisfactionWitness_definable (C : Context M) {Q B G H : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (hG : G ∈ M) (hH : H ∈ M) (a T z : ℕ) : + Definable M (fun e => SatisfactionWitness Q B G H (e a) (e T) (e z)) := + ((((truthWitness_definable C hQ hB hG (a+3) (T+3) 2 0).and + ((defPairMem C 2 1 0).and (defOrderedPair C (z+3) 2 1))).existsParam hH).existsMem + (T+1)).existsParam C.omega_mem + +theorem satisfactionWitness_spec (Q B G H A z : ZFSet.{u}) + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) + (hG : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → tupleGraph v ∈ G) + (hH : ∀ p : SentenceForm, finiteSatisfaction A (subformulas p) ∈ H) : + SatisfactionWitness Q B G H A (tupleSpace A) z ↔ z ∈ satisfactionSet A := by + constructor + · rintro ⟨c,_,t,ht,S,_,hw,hs,rfl⟩ + obtain ⟨p,rfl,hr⟩ := (truthWitness_spec Q B G A c S hQ hB hG).mp hw + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp ht + have he := hr.unique (finiteSatisfaction_recursion A p) + rw [he] at hs + exact (finiteSatisfaction_covers A p v hv).mp hs + · intro hz + obtain ⟨⟨⟨n,p,w⟩,hb,hp⟩,rfl⟩ := ZFSet.mem_range.mp hz + let v : Fin n → ZFSet.{u} := fun i => label A (w i) + have hv : ∀ i, v i ∈ A := fun i => label_mem A (w i) + refine ⟨_,(mem_omega _).mpr ⟨Encodable.encode p,rfl⟩, + tupleCode v,(mem_tupleSpace A _).mpr ⟨n,v,hv,rfl⟩, + finiteSatisfaction A (subformulas p),hH p,?_,?_,rfl⟩ + · exact (truthWitness_spec Q B G A _ _ hQ hB hG).mpr + ⟨p,rfl,finiteSatisfaction_recursion A p⟩ + · exact (certificate_correct A p p (self_mem_subformulas p) v hv hb).mpr hp + +theorem satisfactionSet_mem (M A : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) : satisfactionSet A ∈ M := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + obtain ⟨Q,hQ,_,hf⟩ := internal_family_bound M hM C.pairing C.union C.power C.omega_mem + obtain ⟨B,hB,hb⟩ := internal_support_bound C + obtain ⟨G,hG,hg⟩ := internal_tuple_graph_bound C hA + obtain ⟨H,hH,_,hh⟩ := internal_certificate_bound M A hM hT hA + have ht := tupleSpace_mem M A hM hT hA + let e := cons A (cons (tupleSpace A) (fun _ => ZFSet.omega)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i + · exact hA + · exact ht + · exact C.omega_mem + have hd := satisfactionWitness_definable C hQ hB hG hH 1 2 0 + have hs := hd.sep_mem C e he (C.prod_mem C.omega_mem ht) + have heq : (ZFSet.prod ZFSet.omega (tupleSpace A)).sep + (fun z => SatisfactionWitness Q B G H A (tupleSpace A) z) = satisfactionSet A := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,satisfactionWitness_spec Q B G H A z hf hb hg (fun p => hh (subformulas p))] + exact ⟨And.right,fun hz => ⟨satisfactionSet_subset_product A hz,hz⟩⟩ + exact heq ▸ hs + +theorem satisfactionMembership_definable (M A : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) (c t : ℕ) : + Definable M (fun e => ZFSet.pair (e c) (e t) ∈ satisfactionSet A) := + pairMem_param (satisfactionSet_mem M A hM hT hA) c t + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformNameDescent.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformNameDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c6bb8a52dba40fd2178fe380f153ca9a8fd7d86 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformNameDescent.lean @@ -0,0 +1,83 @@ +import OAI.Computability.DegreeRigidity.Syntax.CheckedMembershipSeparation +import OAI.Computability.DegreeRigidity.Representation.CountableGroundGeneric + +namespace OAI + + +namespace TuringRigidity.FullSetForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] [OrderTop (Conditions c)] + +theorem checked_mem_iff_all_outer_generic (M N : ZFSet.{u}) [Countable (Conditions N)] + (hM : Transitive M) (hT : SourceT M) (hMN : M ⊆ N) + (hc : c ∈ M) {o x : ZFSet.{u}} (hoM : o ∈ M) (hx : x ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (t : Name (Conditions c)) (ht : t.encode (label c) ∈ M) (p : Conditions c) : + MemForces (Name.check x) t p ↔ ∀ G : GenericFilter (Conditions c), + GroundGeneric N G → p ∈ G.carrier → x ∈ t.val G.carrier := by + have hS := hT.separation.finitePrefix.bounded + have hR := hT.replacement.finitePrefix + have hcheck := encoded_check_mem M c hM hT.pairing hT.union hT.powerSet hS hR hT.infinity hc hx + have truth (G : GenericFilter (Conditions c)) (hG : GroundGeneric N G) : + x ∈ t.val G.carrier ↔ ∃ q ∈ G.carrier, MemForces (Name.check x) t q := by + have hGM : GroundGeneric M G := fun D hD hd => hG D (hMN hD) hd + obtain ⟨q,hq⟩ := G.nonempty + have htop : ⊤ ∈ G.carrier := G.upper le_top hq + have h := (internal_atomic_truth M hM hT.pairing hT.union hT.powerSet hS hR hT.infinity + hc hoM ho G hGM (Name.check x) t hcheck ht).2 + simpa only [Name.val_check G.carrier htop] using h + constructor + · intro hf G hG hp + exact (truth G hG).mpr ⟨p,hp,hf⟩ + · intro h + apply mem_of_dense + intro q hqp + obtain ⟨G,hq,hG⟩ := countable_ground_generic N ⟨c,hMN hc⟩ q + obtain ⟨r,hr,hrf⟩ := (truth G hG).mp (h G hG (G.upper hqp hq)) + obtain ⟨s,_,hsq,hsr⟩ := G.directed hq hr + exact ⟨s,hsq,mem_mono _ _ hsr hrf⟩ + +theorem uniform_value_mem_iff (M N : ZFSet.{u}) [Countable (Conditions N)] + (hM : Transitive M) (hT : SourceT M) (hMN : M ⊆ N) + (hc : c ∈ M) {o x S : ZFSet.{u}} (hoM : o ∈ M) (hx : x ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (t : Name (Conditions c)) (ht : t.encode (label c) ∈ M) (p : Conditions c) + (hval : ∀ G : GenericFilter (Conditions c), GroundGeneric N G → p ∈ G.carrier → + t.val G.carrier = S) : + MemForces (Name.check x) t p ↔ x ∈ S := by + rw [checked_mem_iff_all_outer_generic M N hM hT hMN hc hoM hx ho t ht p] + constructor + · intro h + obtain ⟨G,hp,hG⟩ := countable_ground_generic N ⟨c,hMN hc⟩ p + rw [←hval G hG hp] + exact h G hG hp + · intro hxS G hG hp + rw [hval G hG hp] + exact hxS + +theorem uniform_name_subset_descent (M N : ZFSet.{u}) [Countable (Conditions N)] + (hM : Transitive M) (hT : SourceT M) (hMN : M ⊆ N) + (hc : c ∈ M) {o a S : ZFSet.{u}} (hoM : o ∈ M) (ha : a ∈ M) (hSa : S ⊆ a) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (t : Name (Conditions c)) (ht : t.encode (label c) ∈ M) (p : Conditions c) + (hval : ∀ G : GenericFilter (Conditions c), GroundGeneric N G → p ∈ G.carrier → + t.val G.carrier = S) : S ∈ M := by + obtain ⟨b,hb,hdef⟩ := internal_forced_members M hM hT hc hoM ha ho t ht p + have hSb : S = b := by + apply ZFSet.ext + intro x + rw [hdef x] + constructor + · intro hx + have hxa := hSa hx + exact ⟨hxa,(uniform_value_mem_iff M N hM hT hMN hc hoM (hM a ha x hxa) ho + t ht p hval).mpr hx⟩ + · rintro ⟨hxa,hf⟩ + exact (uniform_value_mem_iff M N hM hT hMN hc hoM (hM a ha x hxa) ho + t ht p hval).mp hf + exact hSb ▸ hb + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformNameValueCover.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformNameValueCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..78f5459e05836920acf4d5d645036eb0ca6442e3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformNameValueCover.lean @@ -0,0 +1,38 @@ +import OAI.Computability.DegreeRigidity.SetModels.NameValueCover + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} + +theorem uniform_name_value_cover (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {W : ZFSet.{u}} (hW : W ∈ M) [Top (Conditions c)] : + ∃ N : Name (Conditions c), N.encode (label c) ∈ M ∧ + ∀ g : Set (Conditions c), ⊤ ∈ g → ∀ b : Name (Conditions c), + b.encode (label c) ∈ W → b.val g ∈ N.val g := by + let V := ZFSet.sep (fun x => (NameValidity.Code.valid 1 0).Realize M (cons x (fun _ => c))) W + have hV : V ∈ M := sigma_sep_mem M hM hS (NameValidity.Code.valid 1 0) (fun _ => c) (fun _ => hc) hW + have valid (x : ZFSet.{u}) (hx : x ∈ M) : + (NameValidity.Code.valid 1 0).Realize M (cons x (fun _ => c)) ↔ + ∃ a : Name (Conditions c), a.encode (label c) = x := + NameValidity.realize_valid M hM hP hU hPow hS.bounded hR hI _ + (by intro i; cases i <;> assumption) 1 0 + have hvalid (x : ZFSet.{u}) (hx : x ∈ V) : ∃ a : Name (Conditions c), a.encode (label c) = x := + (valid x (hM V hV x hx)).mp (ZFSet.mem_sep.mp hx).2 + let p : Conditions c := ⊤ + have hN : (coverName V hvalid p).encode (label c) ∈ M := by + rw [encode_coverName] + exact product_mem M hM hP hU hPow hS.bounded hV + (singleton_mem M hM hP (hM c hc _ (label_mem c p))) + refine ⟨coverName V hvalid p,hN,?_⟩ + intro g ht b hb + apply val_mem_coverName V hvalid g p ht b + exact ZFSet.mem_sep.mpr ⟨hb,(valid _ (hM W hW _ hb)).mpr ⟨b,rfl⟩⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformOmegaLevels.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformOmegaLevels.lean new file mode 100644 index 0000000000000000000000000000000000000000..cfb0b59c2d34581da80d45a90ffa13ffb31972ae --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformOmegaLevels.lean @@ -0,0 +1,78 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaCertificateCollection + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open BoundedDefinability SetModelFunctions SentenceCoding +universe u + +theorem ordinal_le_internal {M : ZFSet.{u}} (hM : Transitive M) + {a b : Ordinal.{u}} (ha : a.toZFSet ∈ M) (hb : b ≤ a) : b.toZFSet ∈ M := by + rcases hb.eq_or_lt with rfl|hb + · exact ha + · exact hM _ ha _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hb) + +theorem uniform_omega_certificates_at_levels (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ ∀ δ : Ordinal.{u}, γ ≤ δ → + ∀ c ≤ a, c.toZFSet ∈ level (groundReals M) δ ∧ + (Ordinal.omega0 ^ c).toZFSet ∈ level (groundReals M) δ ∧ + OmegaPowerCertificates (level (groundReals M) δ) c.toZFSet ∧ + ∀ z ∈ level (groundReals M) δ, + omegaPowerSentence.Sat (level (groundReals M) δ : Set ZFSet) + (cons z (fun _ => c.toZFSet)) ↔ z = (Ordinal.omega0 ^ c).toZFSet := by + let R := groundReals M + let N := relativeModel M R + have hR := groundReals_mem M hM hT + have C := ground_relative_context M hM hT + have hRep := relativeModel_sigma_replacement M R hM hT hR + have hColl := relativeModel_sigma_collection M R hM hT hR + have haN : a.toZFSet ∈ N := (ground_relativeModel_ordinal_iff M hM hT a).mpr ha + have hyN := relative_omega_power_internal M hM hT a ha + obtain ⟨G,hG,hgraphs⟩ := omega_graph_collection N C hRep hColl a haN + obtain ⟨U,hU,hprod⟩ := product_certificate_collection N C hRep hColl + (Ordinal.omega0 ^ a) Ordinal.omega0 hyN (toZFSet_omega.symm ▸ C.omega_mem) + let e := cons a.toZFSet (cons (Ordinal.omega0 ^ a).toZFSet (cons G (fun _ => U))) + have he (i : ℕ) : e i ∈ N := by + rcases i with _|_|_|i + exact haN; exact hyN; exact hG; exact hU + obtain ⟨γ,hγ,hγe⟩ := finite_parameters_in_relative_level M R hM hT e 4 + (fun i _ => (mem_relativeModel M R _ hM hT hR).mp (he i)) + refine ⟨γ,hγ,?_⟩ + intro δ hδ c hca + have hL (i : ℕ) (hi : i < 4) : e i ∈ level R δ := level_mono R hδ (hγe i hi) + have hcL := ordinal_le_internal (level_transitive R δ) (hL 0 (by omega)) hca + have hyL := ordinal_le_internal (level_transitive R δ) (hL 1 (by omega)) + (Ordinal.opow_le_opow_right Ordinal.omega0_pos hca) + obtain ⟨f,hf,r,hr,hg⟩ := hgraphs c hca + have hlt (t : ZFSet.{u}) (ht : t ∈ c.toZFSet) : + Ordinal.omega0 ^ t.rank < Ordinal.omega0 ^ a := by + obtain ⟨b,hb,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ht + rw [Ordinal.rank_toZFSet] + exact (Ordinal.opow_lt_opow_iff_right Ordinal.one_lt_omega0).mpr (hb.trans_le hca) + have hc : OmegaPowerCertificates (level R δ) c.toZFSet := by + have hGsub : G ⊆ level R δ := level_transitive R δ G (hL 2 (by omega)) + refine ⟨hcL,f,hGsub hf,r,hGsub hr, + hg.relocate (fun t ht => level_transitive R δ _ (hL 1 (by omega)) _ + (Ordinal.toZFSet_mem_toZFSet_iff.mpr (hlt t ht))),?_⟩ + intro t ht + obtain ⟨hd,hr,f',hf',hcert,_⟩ := hprod _ (hlt t ht) + have hsub : U ⊆ level R δ := level_transitive R δ U (hL 3 (by omega)) + exact ⟨hsub hd,hsub hr,f',hsub hf',hcert⟩ + refine ⟨hcL,hyL,hc,?_⟩ + intro z hz + have henv : ∀ i, cons z (fun _ => c.toZFSet) i ∈ level R δ := by + intro i; cases i; exact hz; exact hcL + have hω := OrdinalCoding.ground_level_omega_mem M hM hT δ + constructor + · intro h + have hval := (omegaPowerSentence_sound _ (level_transitive R δ) hω _ henv h).2 + simpa only [cons_succ,cons_zero,Ordinal.rank_toZFSet] using hval + · intro h + apply omegaPowerSentence_of_certificates _ (level_transitive R δ) hω _ henv hc + simpa only [cons_succ,cons_zero,Ordinal.rank_toZFSet] using h + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformOrdinalDefinitionName.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformOrdinalDefinitionName.lean new file mode 100644 index 0000000000000000000000000000000000000000..089afa0dfa02a0ed41d952f14975eb1d0f011b99 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformOrdinalDefinitionName.lean @@ -0,0 +1,27 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformOrdinalStageName +import OAI.Computability.DegreeRigidity.Constructibility.UniformDefinedSubsetName + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing +open AtomicForcing BoundedForcing +universe u + +theorem uniform_ordinal_definition_name (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (δ : Ordinal.{u}) (hδ : δ.toZFSet ∈ M) (X : ZFSet.{u}) (hX : X ∈ M) (φ : SentenceForm) : + ∃ f : Name (Conditions c), f.encode (label c) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ⊤ ∈ G.carrier → + f.val G.carrier = definedSubset + (level (groundReals (genericExtensionSet M c G.carrier)) δ) + φ (fun _ : Fin φ.bound => X) := by + obtain ⟨A,hA,hAv⟩ := uniform_ordinal_level_name M hM hT hc hoM ho δ hδ + obtain ⟨f,hf,hfv⟩ := uniform_checked_definition_name M hM hT hc hoM ho A hA X hX φ + exact ⟨f,hf,fun G hG ht => by rw [hfv G hG ht,hAv G hG ht]⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformOrdinalStageName.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformOrdinalStageName.lean new file mode 100644 index 0000000000000000000000000000000000000000..f6926acdc0b2f39f961b9aa00edae3d119ad4a09 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformOrdinalStageName.lean @@ -0,0 +1,86 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformSigmaHierarchy +import OAI.Computability.DegreeRigidity.Constructibility.UniformSigmaUniqueName +import OAI.Computability.DegreeRigidity.Constructibility.UniformOwnRealsName + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing +open AtomicForcing BoundedForcing BoundedDefinability SetModelFunctions +universe u + +theorem uniform_named_stage (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) : + ∃ A : Name (Conditions c), A.encode (label c) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ⊤ ∈ G.carrier → + A.val G.carrier = stage (groundReals (genericExtensionSet M c G.carrier)) + (a.val G.carrier) := by + obtain ⟨p,d,hd,hp⟩ := stageCertificate_uniformSigma M hM hT + obtain ⟨S,hS,hSv⟩ := uniform_zero_stage_name M hM hT hc hoM ho + let e : ℕ → Name (Conditions c) := push S (fun n => Name.check (d n)) + have he (i : ℕ) : (e i).encode (label c) ∈ M := by + cases i with + | zero => exact hS + | succ i => + exact encoded_check_mem M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc (hd i) + let r : ℕ → ℕ := fun i => if i % 2 = 0 then + (if i / 2 = 0 then 0 else if i / 2 = 1 then 1 else 2) else i/2+3 + apply uniform_sigma_unique_name M hM hT hc hoM ho (p.rename r) a ha e he + (fun g => stage (groundReals (genericExtensionSet M c g)) (a.val g)) + intro G hG ht + let E := genericExtensionSet M c G.carrier + have hE := genericExtensionSet_transitive M c hM G.carrier + have hTE := extension_sourceT M hM hT hc hoM ho G hG ht + have hME := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht + have hR := groundReals_mem E hE hTE + have haE : a.val G.carrier ∈ E := (mem_extensionSet M c G.carrier _).mpr ⟨a,ha,rfl⟩ + have hSE : S.val G.carrier ∈ E := (mem_extensionSet M c G.carrier _).mpr ⟨S,hS,rfl⟩ + refine ⟨stage_mem E _ _ hE hTE hR haE,?_⟩ + intro y hy + have heval : (fun i => (e i).val G.carrier) = cons (S.val G.carrier) d := by + funext i; cases i with + | zero => rfl + | succ i => exact Name.val_check G.carrier ht (d i) + rw [heval,SigmaFormula.realize_rename] + let v := cons y (cons (a.val G.carrier) (fun _ => S.val G.carrier)) + have hv : ∀ i, v i ∈ E := by + intro i; rcases i with _|_|i; exact hy; exact haE; exact hSE + have hr : cons y (cons (a.val G.carrier) (cons (S.val G.carrier) d)) ∘ r = mix v d := by + apply parity_ext + · intro n + rcases n with _|_|n + · rfl + · rfl + · simp [r,v,Function.comp_apply,mix,cons,show ¬ 2 * (n+1+1) ≤ 1 by omega] + · intro n; simp [r,Function.comp_apply,mix,Nat.add_div] + change p.Realize E (cons y (cons (a.val G.carrier) (cons (S.val G.carrier) d)) ∘ r) ↔ _ + rw [hr,hp E hE hTE hME v hv] + change (∃ d' ∈ E, ∃ f ∈ E, ∃ t ∈ E, a.val G.carrier ∈ d' ∧ + HierarchyGraph E (S.val G.carrier) d' t f ∧ + StageStep (S.val G.carrier) f t (a.val G.carrier) y) ↔ _ + rw [hSv G hG ht,stage_zero] + exact stageCertificate_iff E _ _ y hE hTE hR haE + +theorem uniform_ordinal_level_name (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (δ : Ordinal.{u}) (hδ : δ.toZFSet ∈ M) : + ∃ A : Name (Conditions c), A.encode (label c) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ⊤ ∈ G.carrier → + A.val G.carrier = level (groundReals (genericExtensionSet M c G.carrier)) δ := by + have ha := encoded_check_mem M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc hδ + obtain ⟨A,hA,hAv⟩ := uniform_named_stage M hM hT hc hoM ho (Name.check δ.toZFSet) ha + refine ⟨A,hA,?_⟩ + intro G hG ht + simpa only [Name.val_check G.carrier ht,level] using hAv G hG ht + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformOwnRealsName.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformOwnRealsName.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad898e5c9aeb5cd34c7c69b9c481f3d9a6daf8a9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformOwnRealsName.lean @@ -0,0 +1,60 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformPowerName +import OAI.Computability.DegreeRigidity.Representation.GroundInclusion +import OAI.Computability.DegreeRigidity.Constructibility.RelativeConstruction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u + +theorem uniform_ownReals_name (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) : + ∃ R : Name (Conditions c), R.encode (label c) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ⊤ ∈ G.carrier → + R.val G.carrier = groundReals (genericExtensionSet M c G.carrier) := by + have hω := encoded_check_mem M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc + (sourceT_omega_mem M hM hT) + obtain ⟨R,hR,hval⟩ := uniform_power_name M hM hT hc hoM ho (Name.check ZFSet.omega) hω + refine ⟨R,hR,?_⟩ + intro G hG ht + apply ZFSet.ext; intro x + rw [hval G hG ht x,mem_groundReals,Name.val_check G.carrier ht] + +theorem uniform_zero_stage_name (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) : + ∃ A : Name (Conditions c), A.encode (label c) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ⊤ ∈ G.carrier → + A.val G.carrier = stage (groundReals (genericExtensionSet M c G.carrier)) ∅ := by + obtain ⟨R,hR,hval⟩ := uniform_ownReals_name M hM hT hc hoM ho + let P := Name.pair (Name.pair R R) R + have hRR := names_pair_closed M c hM hT.pairing hc hR hR + have hP : P.encode (label c) ∈ M := names_pair_closed M c hM hT.pairing hc hRR hR + have hA : (Name.union P).encode (label c) ∈ M := by + rw [encode_union c o ho] + exact unionCode_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hP hc hoM + refine ⟨Name.union P,hA,?_⟩ + intro G hG ht + rw [Name.val_union,stage_zero,ground_seed_shape _ (genericExtensionSet_transitive M c hM G.carrier)] + dsimp only [P] + rw [Name.val_pair G.carrier ht,Name.val_pair G.carrier ht,hval G hG ht] + apply ZFSet.ext; intro x + simp only [ZFSet.mem_sUnion,ZFSet.mem_insert_iff,ZFSet.mem_singleton] + constructor + · rintro ⟨y,hy,hx⟩ + rcases hy with rfl|rfl + · exact Or.inl (by simpa only [ZFSet.mem_insert_iff,ZFSet.mem_singleton,or_self] using hx) + · exact Or.inr hx + · rintro (rfl|hx) + · exact ⟨_,Or.inl rfl,ZFSet.mem_insert _ _⟩ + · exact ⟨_,Or.inr rfl,hx⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformPowerName.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformPowerName.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2aa11914dae19414c27457b043f122bee0c2166 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformPowerName.lean @@ -0,0 +1,49 @@ +import OAI.Computability.DegreeRigidity.SetModels.ExtensionPowerSet +import OAI.Computability.DegreeRigidity.Representation.SourceTheory + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing +universe u + +theorem uniform_power_name (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) : + ∃ b : Name (Conditions c), b.encode (label c) ∈ M ∧ + ∀ (G : GenericFilter (Conditions c)), GroundGeneric M G → ⊤ ∈ G.carrier → + ∀ x, x ∈ b.val G.carrier ↔ + x ∈ genericExtensionSet M c G.carrier ∧ x ⊆ a.val G.carrier := by + have hS := hT.separation.finitePrefix.bounded + have hsupport := support_mem M hM hT.pairing hT.union hT.powerSet hS hc hoM ho a ha + obtain ⟨W,hW,hWdef⟩ := internal_power M hM hT.powerSet hsupport + have hWsub : ∀ B ∈ W, B ⊆ a.support (label c) := fun B hB => ((hWdef B).mp hB).2 + have hpower : (powerName a W).encode (label c) ∈ M := by + rw [encode_powerName a W hWsub] + exact product_mem M hM hT.pairing hT.union hT.powerSet hS hW + (singleton_mem M hM hT.pairing (hM c hc _ (label_mem c ⊤))) + refine ⟨powerName a W,hpower,?_⟩ + intro G hG ht x + constructor + · intro hx + obtain ⟨B,hB,hBx⟩ := (mem_val_powerName a W G.carrier ht x).mp hx + have hcode : (a.restrict (label c) B).encode (label c) ∈ M := by + rw [Name.encode_restrict _ _ _ (hWsub B hB)] + exact ((hWdef B).mp hB).1 + exact ⟨(mem_extensionSet M c G.carrier x).mpr ⟨_,hcode,hBx⟩, + hBx ▸ a.val_restrict_subset (label c) B G⟩ + · rintro ⟨hx,hsub⟩ + obtain ⟨b,hb,rfl⟩ := (mem_extensionSet M c G.carrier x).mp hx + obtain ⟨B,hBM,hBS,hBval⟩ := internal_intersection_name M hM hT.pairing hT.union + hT.powerSet hS hT.replacement.finitePrefix hT.infinity hc hoM ho G hG a b ha hb + apply (mem_val_powerName a W G.carrier ht _).mpr + refine ⟨B,(hWdef B).mpr ⟨hBM,hBS⟩,hBval.trans ?_⟩ + apply ZFSet.ext; intro y + rw [ZFSet.mem_inter] + exact ⟨And.right,fun hy => ⟨hsub hy,hy⟩⟩ + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformProductName.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformProductName.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f1630049aaea1159011b164fd14737af3a26487 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformProductName.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformPowerName +import OAI.Computability.DegreeRigidity.Constructibility.UniformSeparationName + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing BoundedForcing +universe u + +theorem uniform_product_name (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (a b : Name (Conditions c)) (ha : a.encode (label c) ∈ M) + (hb : b.encode (label c) ∈ M) : + ∃ d : Name (Conditions c), d.encode (label c) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ⊤ ∈ G.carrier → + d.val G.carrier = ZFSet.prod (a.val G.carrier) (b.val G.carrier) := by + have hS := hT.separation.finitePrefix.bounded + let U := Name.union (Name.pair a b) + have hU : U.encode (label c) ∈ M := names_union_closed M c o hM hT.pairing hT.union + hT.powerSet hS hc hoM ho (names_pair_closed M c hM hT.pairing hc ha hb) + obtain ⟨P,hP,hPv⟩ := uniform_power_name M hM hT hc hoM ho U hU + obtain ⟨Q,hQ,hQv⟩ := uniform_power_name M hM hT hc hoM ho P hP + let e := push a (push b (fun _ => b)) + have he (i : ℕ) : (e i).encode (label c) ∈ M := by + rcases i with _|_|i; exact ha; exact hb; exact hb + obtain ⟨B,hB,hBS,hBv⟩ := uniform_separation_name M hM hT.pairing hT.union hT.powerSet + hS hT.replacement.finitePrefix hT.infinity hc hoM ho productFormula Q hQ e he + refine ⟨Q.restrict (label c) B,?_,?_⟩ + · rw [Name.encode_restrict _ _ _ hBS]; exact hB + · intro G hG ht + let E := genericExtensionSet M c G.carrier + have hE := genericExtensionSet_transitive M c hM G.carrier + have hTE := extension_sourceT M hM hT hc hoM ho G hG ht + have haE : a.val G.carrier ∈ E := (mem_extensionSet M c G.carrier _).mpr ⟨a,ha,rfl⟩ + have hbE : b.val G.carrier ∈ E := (mem_extensionSet M c G.carrier _).mpr ⟨b,hb,rfl⟩ + have hUv : U.val G.carrier = a.val G.carrier ∪ b.val G.carrier := by + rw [Name.val_union,Name.val_pair G.carrier ht,ZFSet.sUnion_pair] + have hbound : ZFSet.prod (a.val G.carrier) (b.val G.carrier) ⊆ Q.val G.carrier := by + intro z hz + obtain ⟨x,hx,y,hy,rfl⟩ := ZFSet.mem_prod.mp hz + have hxE := hE _ haE x hx + have hyE := hE _ hbE y hy + apply (hQv G hG ht _).mpr + refine ⟨orderedPair_mem E hE hTE.pairing hxE hyE,?_⟩ + intro t htz + change t ∈ ({({x} : ZFSet.{u}),({x,y} : ZFSet.{u})} : ZFSet.{u}) at htz + rcases ZFSet.mem_pair.mp htz with rfl|rfl + · apply (hPv G hG ht _).mpr + refine ⟨singleton_mem E hE hTE.pairing hxE,?_⟩ + intro w hw + obtain rfl := ZFSet.mem_singleton.mp hw + rw [hUv]; exact ZFSet.mem_union.mpr (Or.inl hx) + · apply (hPv G hG ht _).mpr + refine ⟨pair_mem E hE hTE.pairing hxE hyE,?_⟩ + intro w hw + rw [hUv] + rcases ZFSet.mem_pair.mp hw with rfl|rfl + · exact ZFSet.mem_union.mpr (Or.inl hx) + · exact ZFSet.mem_union.mpr (Or.inr hy) + apply ZFSet.ext; intro z + rw [hBv G hG z] + change (_ ∧ productFormula.Eval (cons z (cons (a.val G.carrier) + (cons (b.val G.carrier) (fun _ => b.val G.carrier))))) ↔ _ + rw [eval_productFormula] + exact ⟨And.right,fun hz => ⟨hbound hz,hz⟩⟩ + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSentenceSupport.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSentenceSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..194c9068e5eafcd193e651fb41b1d65b64bd841a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSentenceSupport.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.Syntax.SentenceSupportFormula + +namespace OAI + + +namespace TuringRigidity.SentenceCoding +open ElementaryModel RelativeConstructible BoundedSetTheory TransitiveNameModel +open BoundedDefinability SetModelFunctions +universe u + +variable {M : ZFSet.{u}} + +theorem leastFamily_param (C : Context M) {Q : ZFSet.{u}} (hQ : Q ∈ M) (c s : ℕ) : + Definable M (fun e => LeastFamily Q (e c) (e s)) := by + have hs : ({Q} : ZFSet.{u}) ∈ M := singleton_mem M C.transitive C.pairing hQ + exact (((equal_param hQ 0).and (leastFamily_definable C 0 (c+1) (s+1))).existsParam hs).congr + (fun e => by simp only [ZFSet.mem_singleton,cons_zero,cons_succ]; simp) + +def BoundWitness (Q B c b : ZFSet.{u}) : Prop := + ∃ F ∈ Q, ∃ G ∈ B, LeastFamily Q c F ∧ SetSupportRecursion F G ∧ ZFSet.pair c b ∈ G + +theorem boundWitness_definable (C : Context M) {Q B : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (c b : ℕ) : + Definable M (fun e => BoundWitness Q B (e c) (e b)) := + (((leastFamily_param C hQ (c+2) 1).and ((setSupportRecursion_definable C 1 0).and + (defPairMem C (c+2) (b+2) 0))).existsParam hB).existsParam hQ + +theorem boundWitness_spec (Q B c b : ZFSet.{u}) + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) : + BoundWitness Q B c b ↔ + ∃ p : SentenceForm, c = natSet (Encodable.encode p) ∧ b = natSet p.bound := by + constructor + · rintro ⟨F,_,G,_,hf,hg,hcb⟩ + obtain ⟨p,rfl⟩ := setClosed_valid F hf.2.1 c hf.1 + have hF := (leastFamily_spec Q F p (hQ p)).mp hf + subst F + have hG := ((setSupportRecursion_spec p G).mp hg).unique + rw [hG] at hcb + obtain ⟨q,_,he⟩ := (mem_supportGraph p _).mp hcb + obtain ⟨hc,hb⟩ := ZFSet.pair_inj.mp he + have hpq : p = q := Encodable.encode_injective (natSet_injective hc) + subst q + exact ⟨p,rfl,hb⟩ + · rintro ⟨p,rfl,rfl⟩ + exact ⟨family p,hQ p,supportGraph p,hB p, + (leastFamily_spec Q (family p) p (hQ p)).mpr rfl, + (setSupportRecursion_spec p _).mpr (supportGraph_recursion p), + (supportGraph_bound p p p.bound).mpr ⟨self_mem_subformulas p,rfl⟩⟩ + +theorem internal_support_bound (C : Context M) : + ∃ B ∈ M, ∀ p : SentenceForm, supportGraph p ∈ B := by + obtain ⟨B,hB,hdef⟩ := internal_power M C.transitive C.power (C.prod_mem C.omega_mem C.omega_mem) + exact ⟨B,hB,fun p => (hdef _).mpr + ⟨supportGraph_mem M C.transitive C.pairing C.union C.omega_mem p,supportGraph_subset p⟩⟩ + +theorem uniform_support_definition (C : Context M) : + ∃ p : Formula, ∃ d : ℕ → ZFSet.{u}, (∀ i, d i ∈ M) ∧ + ∀ c b, p.Eval (mix (cons c (fun _ => b)) d) ↔ + ∃ root : SentenceForm, c = natSet (Encodable.encode root) ∧ b = natSet root.bound := by + obtain ⟨Q,hQ,_,hf⟩ := internal_family_bound M C.transitive C.pairing C.union C.power C.omega_mem + obtain ⟨B,hB,hb⟩ := internal_support_bound C + obtain ⟨p,d,hd,hdef⟩ := boundWitness_definable C hQ hB 0 1 + exact ⟨p,d,hd,fun c b => (hdef _).trans (boundWitness_spec Q B c b hf hb)⟩ + +end TuringRigidity.SentenceCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSeparationName.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSeparationName.lean new file mode 100644 index 0000000000000000000000000000000000000000..f47955301466aad025654a99b7b5a2dd7c0e53f6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSeparationName.lean @@ -0,0 +1,107 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBoundedTruth +import OAI.Computability.DegreeRigidity.SetModels.NameSupport + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem uniform_separation_name (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (φ : BoundedSetTheory.Formula) (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) + (e : ℕ → Name (Conditions c)) (he : ∀ i, (e i).encode (label c) ∈ M) : + ∃ B ∈ M, B ⊆ a.support (label c) ∧ + ∀ (G : GenericFilter (Conditions c)), GroundGeneric M G → ∀ x, + x ∈ (a.restrict (label c) B).val G.carrier ↔ x ∈ a.val G.carrier ∧ + φ.Eval (cons x (fun i => (e i).val G.carrier)) := by + obtain ⟨d,hd,hdT,had,hnd⟩ := finite_container M hM hP hU hS hR hI + (fun i => (push a e i).encode (label c)) + (by intro i; cases i <;> simp only [push_zero,push_succ]; exact ha; exact he _) (bound φ+2) + let e' := truncate (bound φ) e + have he' (i) : (e' i).encode (label c) ∈ d := by + dsimp only [e',truncate] + split + · exact hnd (i+1) (by omega) + · exact hnd 1 (by omega) + have hai (i) : (a.child i).encode (label c) ∈ d := + names_childClosed d c hdT a had _ (child_relation a i) + have hpush (i) (n) : (push (a.child i) e' n).encode (label c) ∈ d := by + cases n with + | zero => exact hai i + | succ n => exact he' n + obtain ⟨f,hf,hfG⟩ := internal_atomic_graph M hM hP hU hPow hS hd hc hoM + let k := ZFSet.prod d d + have hk : k ∈ M := product_mem M hM hP hU hPow hS hd hd + let env := cons d (cons c (cons k (cons o (cons f (fun i => (e' i).encode (label c)))))) + have henv : ∀ i, env i ∈ M := by + intro i + rcases i with _|i; exact hd + rcases i with _|i; exact hc + rcases i with _|i; exact hk + rcases i with _|i; exact hoM + rcases i with _|i; exact hf + exact hM d hd _ (he' i) + let ψ := Formula.existsMem 1 (.existsMem 3 (.conj (Formula.orderedPair 2 1 0) + (code φ 3 4 5 6 7 (push 1 (fun i => i+8)) 0))) + let B := ZFSet.sep (fun z => ψ.Eval (cons z env)) (a.support (label c)) + have hBM : B ∈ M := sep_mem M hM hS ψ env henv + (support_mem M hM hP hU hPow hS hc hoM ho a ha) + have hBsub : B ⊆ a.support (label c) := fun z hz => (ZFSet.mem_sep.mp hz).1 + have query (i : a.arity) (q : Conditions c) (z : ZFSet.{u}) := + eval_code φ hdT ho hfG (push (a.child i) e') (hpush i) q + (cons (label c q) (cons ((a.child i).encode (label c)) (cons z env))) + 3 4 5 6 7 (push 1 (fun n => n+8)) 0 ⟨rfl,rfl,rfl,rfl,rfl,rfl⟩ + (by intro n; cases n <;> rfl) + have hB (i : a.arity) (q : Conditions c) (hq : q ≤ a.tag i) : + ZFSet.pair ((a.child i).encode (label c)) (label c q) ∈ B ↔ Forces (push (a.child i) e') φ q := by + have hs : ZFSet.pair ((a.child i).encode (label c)) (label c q) ∈ a.support (label c) := + ZFSet.mem_range.mpr ⟨⟨i,⟨q,hq⟩⟩,rfl⟩ + change _ ∈ ZFSet.sep _ _ ↔ _ + rw [ZFSet.mem_sep,and_iff_right hs] + change (Formula.existsMem 1 _).Eval _ ↔ _ + simp only [Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,env] + constructor + · rintro ⟨x,hx,r,hr,hxr,hφ⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hxr + exact (query i q _).mp hφ + · intro hφ + exact ⟨_,hai i,_,label_mem c q,rfl,(query i q _).mpr hφ⟩ + refine ⟨B,hBM,hBsub,?_⟩ + intro G hG + have ht (i : a.arity) : + φ.Eval (cons ((a.child i).val G.carrier) (fun n => (e n).val G.carrier)) ↔ + ∃ p ∈ G.carrier, Forces (push (a.child i) e') φ p := by + have hfinite : φ.Eval (cons ((a.child i).val G.carrier) (fun n => (e n).val G.carrier)) ↔ + φ.Eval (fun n => (push (a.child i) e' n).val G.carrier) := by + apply eval_congr + intro n hn + cases n with + | zero => rfl + | succ n => + simp only [cons_succ,push_succ] + dsimp only [e',truncate] + rw [ite_eq_left (by omega)] + exact hfinite.trans (internal_bounded_truth M hM hP hU hPow hS hR hI hc hoM ho G hG φ _ + (fun n => hM d hd _ (hpush i n))) + intro x + constructor + · intro hx + have hxa := a.val_restrict_subset (label c) B G hx + obtain ⟨i,q,hqi,hqb,hqG,hix⟩ := (a.mem_val_restrict (label c) B G.carrier x).mp hx + have hφ := (ht i).mpr ⟨q,hqG,(hB i q hqi).mp hqb⟩ + exact ⟨hxa,hix ▸ hφ⟩ + · rintro ⟨hxa,hφ⟩ + obtain ⟨i,hi,hix⟩ := (a.mem_val_children G.carrier x).mp hxa + obtain ⟨p,hp,hf⟩ := (ht i).mp (hix ▸ hφ) + obtain ⟨q,hq,hqp,hqi⟩ := G.directed hp hi + exact (a.mem_val_restrict (label c) B G.carrier x).mpr + ⟨i,q,hqi,(hB i q hqi).mpr (forces_mono φ _ hqp hf),hq,hix⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaDefinability.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaDefinability.lean new file mode 100644 index 0000000000000000000000000000000000000000..e020b8c100f81c2fd0edac8ab2fdf96d4ac07d22 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaDefinability.lean @@ -0,0 +1,115 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaParameterizedClosure + +namespace OAI + +namespace TuringRigidity.BoundedDefinability +open BoundedSetTheory TransitiveNameModel SetModelFunctions +universe u + +def UniformSigmaDefinable (M : ZFSet.{u}) + (P : ZFSet.{u} → (ℕ → ZFSet.{u}) → Prop) : Prop := + ∃ p : SigmaFormula, ∃ d : ℕ → ZFSet.{u}, (∀ i, d i ∈ M) ∧ + ∀ E : ZFSet.{u}, Transitive E → SourceT E → M ⊆ E → + ∀ e, (∀ i, e i ∈ E) → (p.Realize E (mix e d) ↔ P E e) + +variable {M : ZFSet.{u}} {P Q : ZFSet.{u} → (ℕ → ZFSet.{u}) → Prop} + +theorem Definable.toUniformSigma {R : (ℕ → ZFSet.{u}) → Prop} (h : Definable M R) : + UniformSigmaDefinable M (fun _ e => R e) := by + obtain ⟨p,d,hd,hp⟩ := h + refine ⟨.bounded p,d,hd,?_⟩ + intro E hE _ hME e he + exact (p.absolute E hE (mix e d) (by + intro i; unfold mix; split <;> first | exact he _ | exact hME (hd _))).trans (hp e) + +theorem UniformSigmaDefinable.existsSet (h : UniformSigmaDefinable M P) : + UniformSigmaDefinable M (fun E e => ∃ x ∈ E, P E (cons x e)) := by + obtain ⟨p,d,hd,hp⟩ := h + refine ⟨.existsSet (p.rename bindSlots),d,hd,?_⟩ + intro E hE hTE hME e he + simp only [SigmaFormula.Realize,SigmaFormula.realize_rename] + apply exists_congr; intro x + apply and_congr_right; intro hx + change (p.Realize E (cons x (mix e d) ∘ bindSlots)) ↔ _ + rw [bind_mix] + exact hp E hE hTE hME (cons x e) (by intro i; cases i; exact hx; exact he _) + +theorem UniformSigmaDefinable.congr (h : UniformSigmaDefinable M P) + (hPQ : ∀ E : ZFSet.{u}, Transitive E → SourceT E → M ⊆ E → + ∀ e, (∀ i, e i ∈ E) → (P E e ↔ Q E e)) : UniformSigmaDefinable M Q := by + obtain ⟨p,d,hd,hp⟩ := h + exact ⟨p,d,hd,fun E hE hTE hME e he => + (hp E hE hTE hME e he).trans (hPQ E hE hTE hME e he)⟩ + +theorem UniformSigmaDefinable.subst (h : UniformSigmaDefinable M P) (r : ℕ → ℕ) : + UniformSigmaDefinable M (fun E e => P E (e ∘ r)) := by + obtain ⟨p,d,hd,hp⟩ := h + refine ⟨p.rename (slotMap r id),d,hd,?_⟩ + intro E hE hTE hME e he + rw [SigmaFormula.realize_rename] + change p.Realize E (mix e d ∘ slotMap r id) ↔ _ + simpa only [mix_slotMap,Function.comp_id] using + hp E hE hTE hME (e ∘ r) (fun i => he (r i)) + +theorem UniformSigmaDefinable.and (hP : UniformSigmaDefinable M P) + (hQ : UniformSigmaDefinable M Q) : + UniformSigmaDefinable M (fun E e => P E e ∧ Q E e) := by + obtain ⟨p,d,hd,hp⟩ := hP + obtain ⟨q,c,hc,hq⟩ := hQ + refine ⟨.conj (p.rename (slotMap id (fun i => 2*i))) + (q.rename (slotMap id (fun i => 2*i+1))),mix d c,?_,?_⟩ + · intro i; unfold mix; split <;> first | exact hd _ | exact hc _ + · intro E hE hTE hME e he + rw [SigmaFormula.realize_conj,SigmaFormula.realize_rename,SigmaFormula.realize_rename] + have hd' : mix d c ∘ (fun i => 2*i) = d := by funext i; simp + have hc' : mix d c ∘ (fun i => 2*i+1) = c := by funext i; simp + change p.Realize E (mix e (mix d c) ∘ slotMap id (fun i => 2*i)) ∧ + q.Realize E (mix e (mix d c) ∘ slotMap id (fun i => 2*i+1)) ↔ _ + rw [mix_slotMap,mix_slotMap,Function.comp_id,hd',hc', + hp E hE hTE hME e he,hq E hE hTE hME e he] + +theorem UniformSigmaDefinable.or (h0 : (∅ : ZFSet.{u}) ∈ M) + (hP : UniformSigmaDefinable M P) (hQ : UniformSigmaDefinable M Q) : + UniformSigmaDefinable M (fun E e => P E e ∨ Q E e) := by + obtain ⟨p,d,hd,hp⟩ := hP + obtain ⟨q,c,hc,hq⟩ := hQ + refine ⟨.disj (p.rename (slotMap id (fun i => 2*i))) + (q.rename (slotMap id (fun i => 2*i+1))),mix d c,?_,?_⟩ + · intro i; unfold mix; split <;> first | exact hd _ | exact hc _ + · intro E hE hTE hME e he + rw [SigmaFormula.realize_disj E (hME h0),SigmaFormula.realize_rename,SigmaFormula.realize_rename] + have hd' : mix d c ∘ (fun i => 2*i) = d := by funext i; simp + have hc' : mix d c ∘ (fun i => 2*i+1) = c := by funext i; simp + change p.Realize E (mix e (mix d c) ∘ slotMap id (fun i => 2*i)) ∨ + q.Realize E (mix e (mix d c) ∘ slotMap id (fun i => 2*i+1)) ↔ _ + rw [mix_slotMap,mix_slotMap,Function.comp_id,hd',hc', + hp E hE hTE hME e he,hq E hE hTE hME e he] + +theorem UniformSigmaDefinable.impBounded (C : Context M) + {R : (ℕ → ZFSet.{u}) → Prop} (hR : Definable M R) (hQ : UniformSigmaDefinable M Q) : + UniformSigmaDefinable M (fun E e => R e → Q E e) := by + apply (hR.neg.toUniformSigma.or (C.nat_mem 0) hQ).congr + intro E _ _ _ e _ + classical + tauto + +theorem UniformSigmaDefinable.allMem (h : UniformSigmaDefinable M P) (a : ℕ) : + UniformSigmaDefinable M (fun E e => ∀ x ∈ e a, P E (cons x e)) := by + obtain ⟨p,d,hd,hp⟩ := h + refine ⟨.allMem (2*a) (p.rename bindSlots),d,hd,?_⟩ + intro E hE hTE hME e he + have hC := sigma_collection E hE hTE.pairing hTE.union hTE.powerSet + hTE.separation.finitePrefix hTE.replacement.finitePrefix hTE.infinity hTE.choice + rw [SigmaFormula.realize_allMem E hE hTE.pairing hTE.union hTE.separation.finitePrefix.bounded + hTE.replacement.finitePrefix hTE.infinity hC _ _ _ (by + intro i; unfold mix; split <;> first | exact he _ | exact hME (hd _)),mix_even] + apply forall_congr'; intro x + apply forall_congr'; intro hx + rw [SigmaFormula.realize_rename] + change p.Realize E (cons x (mix e d) ∘ bindSlots) ↔ _ + rw [bind_mix] + exact hp E hE hTE hME (cons x e) (by intro i; cases i; exact hE _ (he a) x hx; exact he _) + +end TuringRigidity.BoundedDefinability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaHierarchy.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaHierarchy.lean new file mode 100644 index 0000000000000000000000000000000000000000..eea51d28d7d93b82e4358d9925800707d4413cf6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaHierarchy.lean @@ -0,0 +1,65 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformSigmaDefinability +import OAI.Computability.DegreeRigidity.Constructibility.UniformHierarchyStage + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +theorem definablePower_uniformSigma (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + UniformSigmaDefinable M (fun _ e => e 0 = definablePower (e 1)) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet, + hT.separation.finitePrefix.bounded,hT.infinity⟩ + obtain ⟨Q,hQ,_,hq⟩ := internal_family_bound M hM C.pairing C.union C.power C.omega_mem + obtain ⟨B,hB,hb⟩ := internal_support_bound C + have hc := (defSystem_definable C hQ hB 5 3 2 1 0 4).toUniformSigma + apply hc.existsSet.existsSet.existsSet.existsSet.congr + intro E hE hTE _ e he + change (∃ G ∈ E, ∃ T ∈ E, ∃ H ∈ E, ∃ Z ∈ E, + DefSystem Q B (e 1) G T H Z (e 0)) ↔ e 0 = definablePower (e 1) + constructor + · rintro ⟨G,_,T,_,H,_,Z,_,h⟩; exact h.exact hq hb + · intro h; rw [h] + exact internal_defSystem E hE hTE Q B (e 1) (he 1) hq hb + +theorem hierarchyGraph_uniformSigma (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (s d r f : ℕ) : + UniformSigmaDefinable M (fun E e => HierarchyGraph E (e s) (e d) (e r) (e f)) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet, + hT.separation.finitePrefix.bounded,hT.infinity⟩ + have hd := (defAllMem (defSubset C 0 (d+1)) d).toUniformSigma + have hf := (functionGraph_definable C d r f).toUniformSigma + have hv : UniformSigmaDefinable M (fun _ e => e 1 = definablePower (e 0)) := + (definablePower_uniformSigma M hM hT).subst (fun i => if i = 0 then 1 else 0) + have hs := (stageStep_definable C (s+3) (f+3) (r+3) 2 0).toUniformSigma.and hv + have hi := UniformSigmaDefinable.impBounded C (defPairMem C 1 0 (f+2)) hs.existsSet + exact hd.and (hf.and ((hi.allMem (r+1)).allMem d)) + +theorem stageCertificate_uniformSigma (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + UniformSigmaDefinable M (fun E e => + ∃ d ∈ E, ∃ f ∈ E, ∃ r ∈ E, e 1 ∈ d ∧ + HierarchyGraph E (e 2) d r f ∧ StageStep (e 2) f r (e 1) (e 0)) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet, + hT.separation.finitePrefix.bounded,hT.infinity⟩ + have hg := hierarchyGraph_uniformSigma M hM hT 5 2 0 1 + have hs := (stageStep_definable C 5 1 0 4 3).toUniformSigma + have hx := (member_definable C 4 2).toUniformSigma + exact (hx.and (hg.and hs)).existsSet.existsSet.existsSet + +theorem stageCertificate_iff (E R x A : ZFSet.{u}) (hE : Transitive E) (hTE : SourceT E) + (hR : R ∈ E) (hx : x ∈ E) : + (∃ d ∈ E, ∃ f ∈ E, ∃ r ∈ E, x ∈ d ∧ + HierarchyGraph E (seed R) d r f ∧ StageStep (seed R) f r x A) ↔ A = stage R x := by + constructor + · rintro ⟨d,_,f,_,r,_,hxd,hg,hs⟩ + exact (hg.stageStep_iff x hxd A).mp hs + · intro h + obtain ⟨d,hd,f,hf,hxd,hg⟩ := internal_hierarchy_cover E R x hE hTE hR hx + exact ⟨d,hd,f,hf,_,iterUnion_mem E hE hTE.union hf 2,hxd,hg, + (hg.stageStep_iff x hxd A).mpr h⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaHull.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..e16d2ca02af372c3bace2e477811020712c9f016 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaHull.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformFragmentHull +import OAI.Computability.DegreeRigidity.SetModels.SmallWitnessBound + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse +universe u +namespace FiniteTuple + +theorem uniform_internal_sigma_hull (M t : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) + (ht : t ∈ M) (h0t : (∅ : ZFSet.{u}) ∈ t) : + ∃ K ∈ M, ∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ t) → ∀ φ : SigmaFormula, + ∀ x ∈ M, φ.Realize M (cons x e) → + ∃ h ∈ M, t ⊆ h ∧ x ∈ h ∧ StructureExtensional h ∧ φ.Realize h (cons x e) ∧ + ∃ f ∈ M, ∃ j : ZFSet.{u} → ZFSet.{u}, Presents h f j ∧ + (∀ x ∈ h, j x ∈ K) ∧ (∀ x ∈ h, ∀ y ∈ h, j x = j y → x = y) := by + obtain ⟨K,hK,hsmall⟩ := uniform_internal_fragment_hull M t hM hP hU hPow hS hR hI hAC ht h0t + refine ⟨K,hK,?_⟩ + intro e he φ x hx hφ + obtain ⟨xs,hlen,hxs,hmat⟩ := (φ.realize_iff_prefix M (cons x e)).mp hφ + have h0 : (∅ : ZFSet.{u}) ∈ M := hM t ht _ h0t + let s := t ∪ elements (x::xs) + have hxsM : ∀ y ∈ x::xs, y ∈ M := by + intro y hy; rcases List.mem_cons.mp hy with rfl|hy + · exact hx + · exact hxs y hy + have hs : s ∈ M := binary_union_mem M hM hP hU ht (elements_mem M hM hP hU h0 (x::xs) hxsM) + have hts : t ⊆ s := fun _ hy => ZFSet.mem_union.mpr (Or.inl hy) + have hxsS : ∀ y ∈ x::xs, y ∈ s := + fun y hy => ZFSet.mem_union.mpr (Or.inr ((mem_elements y (x::xs)).mpr hy)) + obtain ⟨d,hd,hdt,hsd⟩ := internal_transitive_container M hM hP hU hS.bounded hR hI hs + have hsd' : s ⊆ d := fun y hy => hdt _ hsd y hy + have henvS : ∀ i, cons x e i ∈ s := by + intro i; cases i with + | zero => exact hxsS x List.mem_cons_self + | succ i => exact hts (he i) + have hfeedS := SigmaFormula.feed_mem xs (cons x e) s + (fun y hy => hxsS y (List.mem_cons_of_mem _ hy)) henvS + have hfeedM : ∀ i, SigmaFormula.feed xs (cons x e) i ∈ M := fun i => hM s hs _ (hfeedS i) + have hfeedD : ∀ i, SigmaFormula.feed xs (cons x e) i ∈ d := fun i => hsd' (hfeedS i) + have hmatD : φ.matrix.Realize d (SigmaFormula.feed xs (cons x e)) := + (φ.matrix.absolute d hdt _ hfeedD).mpr ((φ.matrix.absolute M hM _ hfeedM).mp hmat) + obtain ⟨h,hh,hsh,_,hext,htransfer,f,hf,j,hfj,hj,hi⟩ := hsmall (x::xs) hxsM d hd hdt hsd' φ.matrix + refine ⟨h,hh,fun y hy => hsh (hts hy),hsh (hxsS x List.mem_cons_self),hext,?_,f,hf,j,hfj,hj,hi⟩ + apply (φ.realize_iff_prefix h (cons x e)).mpr + exact ⟨xs,hlen,fun y hy => hsh (hxsS y (List.mem_cons_of_mem _ hy)), + (htransfer _ (fun i => hsh (hfeedS i))).mpr hmatD⟩ + +theorem internal_uniform_sigma_witness_bound (M t : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) + (ht : t ∈ M) (htt : Transitive t) (h0t : (∅ : ZFSet.{u}) ∈ t) : + ∃ W ∈ M, ∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ t) → ∀ φ : SigmaFormula, + (∃ x ∈ M, φ.Realize M (cons x e)) → ∃ y ∈ W, φ.Realize M (cons y e) := by + obtain ⟨K,hK,hsmall⟩ := uniform_internal_sigma_hull M t hM hP hU hPow hS hR hI hAC ht h0t + obtain ⟨W,hW,hbound⟩ := internal_small_witness_bound M K hM hP hU hPow hS hR hK + refine ⟨W,hW,?_⟩ + intro e he φ hφ + obtain ⟨x,hx,hφ⟩ := hφ + obtain ⟨h,hh,hth,hxh,hext,hφh,f,hf,j,hfj,hj,hi⟩ := hsmall e he φ x hx hφ + exact hbound h hh hext f hf j hfj hj hi t htt hth e he φ x hxh hφh + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaSeparationName.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaSeparationName.lean new file mode 100644 index 0000000000000000000000000000000000000000..333e7f7b73f04881023136f44f9f38ff698daf7b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaSeparationName.lean @@ -0,0 +1,101 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaSeparationName + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem uniform_sigma_separation_name (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : SigmaSeparation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (φ : SigmaFormula) (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) + (e : ℕ → Name (Conditions c)) (he : ∀ i, (e i).encode (label c) ∈ M) : + ∃ B ∈ M, B ⊆ a.support (label c) ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ∀ x, + x ∈ (a.restrict (label c) B).val G.carrier ↔ x ∈ a.val G.carrier ∧ + φ.Realize (genericExtensionSet M c G.carrier) + (cons x (fun i => (e i).val G.carrier)) := by + let env := cons c (cons o (fun i => (e i).encode (label c))) + have henv : ∀ i, env i ∈ M := by + intro i; rcases i with _|i; exact hc + rcases i with _|i; exact hoM + exact he i + let ψ := SigmaFormula.existsSet (.existsSet + (SigmaFormula.andBounded (.orderedPair 2 1 0) + (SigmaCode.forcing φ 3 4 0 (push 1 (fun i => i+5))))) + let B := ZFSet.sep (fun z => ψ.Realize M (cons z env)) (a.support (label c)) + have hBM : B ∈ M := sigma_sep_mem M hM hS ψ env henv + (support_mem M hM hP hU hPow hS.bounded hc hoM ho a ha) + have hBsub : B ⊆ a.support (label c) := fun z hz => (ZFSet.mem_sep.mp hz).1 + have hai (i) : (a.child i).encode (label c) ∈ M := + names_childClosed M c hM a ha _ (child_relation a i) + have hpush (i) (n) : (push (a.child i) e n).encode (label c) ∈ M := by + cases n with + | zero => exact hai i + | succ n => exact he n + have hpair (z x q : ZFSet.{u}) (hz : z ∈ M) (hx : x ∈ M) (hq : q ∈ M) : + (Formula.orderedPair 2 1 0).Realize M (cons q (cons x (cons z env))) ↔ z = ZFSet.pair x q := by + rw [Formula.absolute _ M hM _ (by + intro n; rcases n with _|n; exact hq + rcases n with _|n; exact hx + rcases n with _|n; exact hz + exact henv n)] + exact Formula.eval_orderedPair 2 1 0 _ + have hB (i : a.arity) (q : Conditions c) (hq : q ≤ a.tag i) : + ZFSet.pair ((a.child i).encode (label c)) (label c q) ∈ B ↔ + SigmaForces M (push (a.child i) e) φ q := by + let z := ZFSet.pair ((a.child i).encode (label c)) (label c q) + have hqM := hM c hc _ (label_mem c q) + have hz : z ∈ M := orderedPair_mem M hM hP (hai i) hqM + have query := realize_sigmaForcing M hM hP hU hPow hS.bounded hR hI ho φ + (push (a.child i) e) q + (cons (label c q) (cons ((a.child i).encode (label c)) (cons z env))) + (by + intro n; rcases n with _|n; exact hqM + rcases n with _|n; exact hai i + rcases n with _|n; exact hz + exact henv n) + 3 4 0 (push 1 (fun n => n+5)) rfl rfl rfl + (by intro n; cases n <;> rfl) + have hs : z ∈ a.support (label c) := ZFSet.mem_range.mpr ⟨⟨i,⟨q,hq⟩⟩,rfl⟩ + change z ∈ ZFSet.sep _ _ ↔ _ + rw [ZFSet.mem_sep,and_iff_right hs] + simp only [ψ,SigmaFormula.Realize,SigmaFormula.realize_andBounded] + constructor + · rintro ⟨x,hx,r,hr,hxr,hφ⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp ((hpair z x r hz hx hr).mp hxr) + exact query.mp hφ + · intro hφ + exact ⟨_,hai i,_,hqM,(hpair z _ _ hz (hai i) hqM).mpr rfl,query.mpr hφ⟩ + refine ⟨B,hBM,hBsub,?_⟩ + intro G hG + have ht (i : a.arity) : + φ.Realize (genericExtensionSet M c G.carrier) + (cons ((a.child i).val G.carrier) (fun n => (e n).val G.carrier)) ↔ + ∃ p ∈ G.carrier, SigmaForces M (push (a.child i) e) φ p := by + have hev : (fun n => (push (a.child i) e n).val G.carrier) = + cons ((a.child i).val G.carrier) (fun n => (e n).val G.carrier) := by + funext n; cases n <;> rfl + rw [←hev] + exact internal_sigma_truth M hM hP hU hPow hS.bounded hR hI hc hoM ho G hG φ _ (hpush i) + intro x + constructor + · intro hx + have hxa := a.val_restrict_subset (label c) B G hx + obtain ⟨i,q,hqi,hqb,hqG,hix⟩ := (a.mem_val_restrict (label c) B G.carrier x).mp hx + have hφ := (ht i).mpr ⟨q,hqG,(hB i q hqi).mp hqb⟩ + exact ⟨hxa,hix ▸ hφ⟩ + · rintro ⟨hxa,hφ⟩ + obtain ⟨i,hi,hix⟩ := (a.mem_val_children G.carrier x).mp hxa + obtain ⟨p,hp,hf⟩ := (ht i).mp (hix ▸ hφ) + obtain ⟨q,hq,hqp,hqi⟩ := G.directed hp hi + exact (a.mem_val_restrict (label c) B G.carrier x).mpr + ⟨i,q,hqi,(hB i q hqi).mpr (sigma_mono M φ _ hqp hf),hq,hix⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaUniqueName.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaUniqueName.lean new file mode 100644 index 0000000000000000000000000000000000000000..e040f436dd90f98e1febd907436537898b5d0925 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformSigmaUniqueName.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformExtensionWitnessCover +import OAI.Computability.DegreeRigidity.Constructibility.UniformSigmaSeparationName +import OAI.Computability.DegreeRigidity.Representation.SourceTheory + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u + +theorem uniform_sigma_unique_name (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (φ : SigmaFormula) (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) + (e : ℕ → Name (Conditions c)) (he : ∀ i, (e i).encode (label c) ∈ M) + (F : Set (Conditions c) → ZFSet.{u}) + (hF : ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ⊤ ∈ G.carrier → + F G.carrier ∈ genericExtensionSet M c G.carrier ∧ + ∀ y ∈ genericExtensionSet M c G.carrier, + φ.Realize (genericExtensionSet M c G.carrier) + (cons y (cons (a.val G.carrier) (fun i => (e i).val G.carrier))) ↔ y = F G.carrier) : + ∃ A : Name (Conditions c), A.encode (label c) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ⊤ ∈ G.carrier → + A.val G.carrier = F G.carrier := by + have hp := names_pair_closed M c hM hT.pairing hc ha ha + obtain ⟨N,hN,hNv⟩ := uniform_extension_witness_cover M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix hT.replacement.finitePrefix hT.infinity hT.choice + hc hoM ho φ e he (Name.pair a a) hp + have hep (i : ℕ) : (push a e i).encode (label c) ∈ M := by + cases i; exact ha; exact he _ + obtain ⟨B,hB,hBS,hBv⟩ := uniform_sigma_separation_name M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix hT.replacement.finitePrefix hT.infinity hc hoM ho φ N hN (push a e) hep + let S := N.restrict (label c) B + have hS : S.encode (label c) ∈ M := by + dsimp only [S]; rw [Name.encode_restrict _ _ _ hBS]; exact hB + refine ⟨Name.union S,names_union_closed M c o hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hc hoM ho hS,?_⟩ + intro G hG ht + obtain ⟨hFm,hFv⟩ := hF G hG ht + have hE := genericExtensionSet_transitive M c hM G.carrier + have hNE := (mem_extensionSet M c G.carrier _).mpr ⟨N,hN,rfl⟩ + have haV : a.val G.carrier ∈ (Name.pair a a).val G.carrier := by + rw [Name.val_pair G.carrier ht] + exact ZFSet.mem_pair.mpr (Or.inl rfl) + obtain ⟨y,hy,hφ⟩ := hNv G hG ht _ haV ⟨_,hFm,(hFv _ hFm).mpr rfl⟩ + have hyF : y = F G.carrier := (hFv y (hE _ hNE y hy)).mp hφ + have hsval : S.val G.carrier = ({F G.carrier} : ZFSet.{u}) := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_singleton] + have hv := hBv G hG z + have heval : (fun i => (push a e i).val G.carrier) = + cons (a.val G.carrier) (fun i => (e i).val G.carrier) := by + funext i; cases i <;> rfl + rw [heval] at hv + rw [hv] + constructor + · rintro ⟨hz,hφz⟩; exact (hFv z (hE _ hNE z hz)).mp hφz + · rintro rfl; exact ⟨hyF ▸ hy,(hFv _ hFm).mpr rfl⟩ + rw [Name.val_union,hsval,ZFSet.sUnion_singleton] + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformTruthRecursion.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformTruthRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..46615270711db74d325cf0d9d91a56272086893d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformTruthRecursion.lean @@ -0,0 +1,86 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformTruthStep + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +variable {M : ZFSet.{u}} + +def SetTruthRecursion (Q B G A T F S : ZFSet.{u}) : Prop := + (∀ z ∈ S, ∃ c ∈ F, ∃ t ∈ T, TupleAdequate Q B G c t ∧ z = ZFSet.pair c t) ∧ + ∀ c ∈ F, ∀ t ∈ T, TupleAdequate Q B G c t → + (ZFSet.pair c t ∈ S ↔ SetTruthStep A G T S c t) + +theorem setTruthRecursion_definable (C : Context M) {Q B G : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (hG : G ∈ M) (a T f s : ℕ) : + Definable M (fun e => SetTruthRecursion Q B G (e a) (e T) (e f) (e s)) := by + have hn := defAllMem ((((tupleAdequate_definable C hQ hB hG 1 0).and + (defOrderedPair C 2 1 0)).existsMem (T+2)).existsMem (f+1)) s + have hr := defAllMem (defAllMem (defImp (tupleAdequate_definable C hQ hB hG 1 0) + (defIff (defPairMem C 1 0 (s+2)) + (setTruthStep_definable C hG (a+2) (T+2) (s+2) 1 0))) (T+1)) f + exact hn.and hr + +theorem setTruthRecursion_spec (Q B G A S : ZFSet.{u}) + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) + (hG : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → tupleGraph v ∈ G) + (root : SentenceForm) : + SetTruthRecursion Q B G A (tupleSpace A) (family root) S ↔ TruthRecursion A root S := by + constructor + · rintro ⟨hn,hr⟩ + constructor + · intro z hz + obtain ⟨c,hc,t,ht,ha,rfl⟩ := hn z hz + obtain ⟨p,hp,rfl⟩ := (mem_family root c).mp hc + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp ht + exact ⟨p,hp,n,v,hv,(tupleAdequate_spec Q B G hQ hB p v (hG n v hv)).mp ha,rfl⟩ + · intro p hp n v hv hb + have ht := (mem_tupleSpace A _).mpr ⟨n,v,hv,rfl⟩ + have ha := (tupleAdequate_spec Q B G hQ hB p v (hG n v hv)).mpr hb + exact (hr _ ((code_mem_family root p).mpr hp) _ ht ha).trans + (setTruthStep_encode A G S hG p v hv hb) + · rintro ⟨hn,hr⟩ + constructor + · intro z hz + obtain ⟨p,hp,n,v,hv,hb,rfl⟩ := hn z hz + exact ⟨_,(code_mem_family root p).mpr hp,_,(mem_tupleSpace A _).mpr ⟨n,v,hv,rfl⟩, + (tupleAdequate_spec Q B G hQ hB p v (hG n v hv)).mpr hb,rfl⟩ + · intro c hc t ht ha + obtain ⟨p,hp,rfl⟩ := (mem_family root c).mp hc + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp ht + have hb := (tupleAdequate_spec Q B G hQ hB p v (hG n v hv)).mp ha + exact (hr p hp n v hv hb).trans (setTruthStep_encode A G S hG p v hv hb).symm + +def TruthWitness (Q B G A T c S : ZFSet.{u}) : Prop := + ∃ F ∈ Q, LeastFamily Q c F ∧ SetTruthRecursion Q B G A T F S + +theorem truthWitness_definable (C : Context M) {Q B G : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (hG : G ∈ M) (a T c s : ℕ) : + Definable M (fun e => TruthWitness Q B G (e a) (e T) (e c) (e s)) := + ((leastFamily_param C hQ (c+1) 0).and + (setTruthRecursion_definable C hQ hB hG (a+1) (T+1) 0 (s+1))).existsParam hQ + +theorem truthWitness_spec (Q B G A c S : ZFSet.{u}) + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) + (hG : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → tupleGraph v ∈ G) : + TruthWitness Q B G A (tupleSpace A) c S ↔ + ∃ root : SentenceForm, c = natSet (Encodable.encode root) ∧ TruthRecursion A root S := by + constructor + · rintro ⟨F,_,hf,hr⟩ + obtain ⟨root,rfl⟩ := setClosed_valid F hf.2.1 c hf.1 + have he := (leastFamily_spec Q F root (hQ root)).mp hf + subst F + exact ⟨root,rfl,(setTruthRecursion_spec Q B G A S hQ hB hG root).mp hr⟩ + · rintro ⟨root,rfl,hr⟩ + exact ⟨family root,hQ root,(leastFamily_spec Q _ root (hQ root)).mpr rfl, + (setTruthRecursion_spec Q B G A S hQ hB hG root).mpr hr⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformTruthStep.lean b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformTruthStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..7eaf166ccdd45137f4be9df569b1a6f4ae0739eb --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Constructibility/UniformTruthStep.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.Effective.TupleLookupAdequacy +import OAI.Computability.DegreeRigidity.Syntax.SatisfactionRecursion + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions SetModelReals +universe u + +variable {M : ZFSet.{u}} + +def SetTruthStep (A G T S c t : ZFSet.{u}) : Prop := + (∃ i ∈ ZFSet.omega, ∃ j ∈ ZFSet.omega, ∃ x ∈ A, ∃ y ∈ A, + BinaryGraph (fun i j => binary 0 (atom i) (atom j)) i j c ∧ + TupleLookup G t i x ∧ TupleLookup G t j y ∧ x = y) ∨ + (∃ i ∈ ZFSet.omega, ∃ j ∈ ZFSet.omega, ∃ x ∈ A, ∃ y ∈ A, + BinaryGraph (fun i j => binary 1 (atom i) (atom j)) i j c ∧ + TupleLookup G t i x ∧ TupleLookup G t j y ∧ x ∈ y) ∨ + (∃ i ∈ ZFSet.omega, ∃ j ∈ ZFSet.omega, + BinaryGraph (binary 2) i j c ∧ ZFSet.pair i t ∈ S ∧ ZFSet.pair j t ∈ S) ∨ + (∃ i ∈ ZFSet.omega, UnaryGraph (unary 3) i c ∧ ¬ ZFSet.pair i t ∈ S) ∨ + (∃ i ∈ ZFSet.omega, UnaryGraph (unary 4) i c ∧ + ∃ x ∈ A, ∃ s ∈ T, TuplePrefix A G t x s ∧ ZFSet.pair i s ∈ S) + +theorem setTruthStep_definable (C : Context M) {G : ZFSet.{u}} + (hG : G ∈ M) (a T S c t : ℕ) : + Definable M (fun e => SetTruthStep (e a) G (e T) (e S) (e c) (e t)) := by + have ha (tag : ℕ) (hr : Definable M (fun e => e 1 = e 0)) := + (((((binaryGraph_definable C _ (atomic_primrec tag) 3 2 (c+4)).and + ((tupleLookup_definable C hG (t+4) 3 1).and + ((tupleLookup_definable C hG (t+4) 2 0).and hr))).existsMem (a+3)).existsMem (a+2)).existsParam + C.omega_mem).existsParam C.omega_mem + have he := ha 0 (equal_definable C 1 0) + have hm := (((((binaryGraph_definable C _ (atomic_primrec 1) 3 2 (c+4)).and + ((tupleLookup_definable C hG (t+4) 3 1).and + ((tupleLookup_definable C hG (t+4) 2 0).and (member_definable C 1 0)))).existsMem (a+3)).existsMem + (a+2)).existsParam C.omega_mem).existsParam C.omega_mem + have hc := (((binaryGraph_definable C _ (binary_primrec 2) 1 0 (c+2)).and + ((defPairMem C 1 (t+2) (S+2)).and (defPairMem C 0 (t+2) (S+2)))).existsParam + C.omega_mem).existsParam C.omega_mem + have hn := ((unaryGraph_definable C _ (unary_primrec 3) 0 (c+1)).and + (defPairMem C 0 (t+1) (S+1)).neg).existsParam C.omega_mem + have hbody := (((tuplePrefix_definable C hG (a+3) (t+3) 1 0).and + (defPairMem C 2 0 (S+3))).existsMem (T+2)).existsMem (a+1) + have hx := ((unaryGraph_definable C _ (unary_primrec 4) 0 (c+1)).and hbody).existsParam C.omega_mem + exact defOr he (defOr hm (defOr hc (defOr hn hx))) + +theorem setTruthStep_encode (A G S : ZFSet.{u}) + (hG : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → tupleGraph v ∈ G) + (p : SentenceForm) {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) + (hb : p.bound ≤ n) : + SetTruthStep A G (tupleSpace A) S (natSet (Encodable.encode p)) (tupleCode v) ↔ + truthStep A S v p := by + unfold SetTruthStep + simp_rw [omega_exists] + simp only [BinaryGraph,UnaryGraph,natSet_injective.eq_iff] + cases p with + | equal i j => + have hi : i < n := by simp only [SentenceForm.bound] at hb; omega + have hj : j < n := by simp only [SentenceForm.bound] at hb; omega + simp [encode_equal,binary,unary,cell,atom,Nat.pair_eq_pair, + tupleLookup_nat G v (hG n v hv),hi,hj,truthStep,eq_comm, + show tupleEnv v j ∈ A from by simpa [tupleEnv,hj] using hv ⟨j,hj⟩] + | member i j => + have hi : i < n := by simp only [SentenceForm.bound] at hb; omega + have hj : j < n := by simp only [SentenceForm.bound] at hb; omega + simp [encode_member,binary,unary,cell,atom,Nat.pair_eq_pair, + tupleLookup_nat G v (hG n v hv),hi,hj,truthStep, + show tupleEnv v i ∈ A from by simpa [tupleEnv,hi] using hv ⟨i,hi⟩, + show tupleEnv v j ∈ A from by simpa [tupleEnv,hj] using hv ⟨j,hj⟩] + | conj p q => + simp [encode_conj,binary,unary,cell,atom,Nat.pair_eq_pair,truthStep,accepts] + | neg p => + simp [encode_neg,binary,unary,cell,atom,Nat.pair_eq_pair,truthStep,accepts] + | ex p => + simp [encode_ex,binary,unary,cell,atom,Nat.pair_eq_pair] + apply exists_congr; intro x + apply and_congr_right; intro hx + simp only [tuplePrefix_spec A G hG v hv x _ hx] + change (∃ s ∈ tupleSpace A, s = tupleCode (Fin.cases x v) ∧ + ZFSet.pair (natSet (Encodable.encode p)) s ∈ S) ↔ _ + constructor + · rintro ⟨s,_,rfl,hs⟩; exact hs + · intro hs + let w : Fin (n+1) → ZFSet.{u} := Fin.cases (motive := fun _ => ZFSet.{u}) x v + have hw : ∀ i : Fin (n+1), w i ∈ A := fun i => Fin.cases hx hv i + have ht : tupleCode w ∈ tupleSpace A := (mem_tupleSpace A (tupleCode w)).mpr ⟨n+1,w,hw,rfl⟩ + exact ⟨tupleCode w,ht,rfl,hs⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/AntichainCoding.lean b/lean/OAI/Computability/DegreeRigidity/Effective/AntichainCoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5752738e41696be9d654f749945e49694fa76ed --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/AntichainCoding.lean @@ -0,0 +1,124 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingGeneric +import OAI.Computability.DegreeRigidity.Effective.CodingRequirements + +namespace OAI + +namespace TuringRigidity.AntichainCoding +open CodingForcing CodingColumns CodingDiagonal CodingGeneric CodingRequirements + +abbrev Index := (ℕ × ℕ × OracleCode) ⊕ (OracleCode × OracleCode × OracleCode) + +def requirements (A : ℕ → Oracle) (hA : ∀ k, {a | A k a = true}.Infinite) + (B : Oracle) (n : ℕ) (p : Condition) : Prop := + match Encodable.decode (α := Index) n with + | none => True + | some (.inl (k, cutoff, e)) => Diagonal A hA k cutoff e p + | some (.inr (c, e₀, e₁)) => GoodForCode A B c e₀ e₁ p + +theorem requirements_dense (A : ℕ → Oracle) (hA : ∀ k, {a | A k a = true}.Infinite) + (hIntro : ∀ k Z, (∀ a, Z a = true → A k a = true) → + {a | Z a = true}.Infinite → Reduces (A k) Z) (B : Oracle) (n : ℕ) : + Dense A (requirements A hA B n) := by + intro p + unfold requirements + cases hd : Encodable.decode (α := Index) n with + | none => exact ⟨p, extends_refl A p, trivial⟩ + | some x => + cases x with + | inl v => exact diagonal_dense A hA v.1 v.2.1 v.2.2 p + | inr v => exact goodForCode_dense A hIntro B v.1 v.2.1 v.2.2 p + +theorem swap_join_reduces (G Y : Oracle) : Reduces (join G Y) (join Y G) := + join_reduces (reduces_join_right Y G) (reduces_join_left Y G) + +theorem normalized_coding (A : ℕ → Oracle) (hA : ∀ k, {a | A k a = true}.Infinite) + (hIntro : ∀ k Z, (∀ a, Z a = true → A k a = true) → + {a | Z a = true}.Infinite → Reduces (A k) Z) (B : Oracle) : + ∃ G₀ G₁ : Oracle, + (∀ k, ∃ C : Oracle, Reduces C (join G₀ (A k)) ∧ Reduces C (join G₁ (A k)) ∧ ¬ Reduces C (A k)) ∧ + ∀ Y : Oracle, Reduces Y B → + (∀ Z : Oracle, Reduces Z (join G₀ Y) → Reduces Z (join G₁ Y) → Reduces Z Y) ∨ + ∃ k, Reduces (A k) Y := by + let R := requirements A hA B + let hR := requirements_dense A hA hIntro B + let G₀ := leftReal A R hR + let G₁ := rightReal A R hR + have hnot : ∀ k cutoff, ¬ Reduces (readColumn (A k) (hA k) k cutoff G₀) (A k) := by + intro k cutoff h + obtain ⟨e, he⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h + let i := Encodable.encode (Sum.inl (k, cutoff, e) : Index) + have hd : Diagonal A hA k cutoff e (stage A R hR (i+1)) := by + simpa only [R, requirements, i, Encodable.encodek] using (stage_spec A R hR i).2.1 + obtain ⟨n, hn, hne⟩ := hd + apply hne + rw [he] + change Part.some (if G₀ (location (A k) (hA k) k cutoff n) then 1 else 0) = _ + rw [show G₀ (location (A k) (hA k) k cutoff n) = + (stage A R hR (i+1)).left.getD (location (A k) (hA k) k cutoff n) false from + leftReal_extends A R hR (i+1) _ hn] + refine ⟨G₀, G₁, ?_, ?_⟩ + · intro k + let cutoff := (stage A R hR (k+1)).left.length + let C := readColumn (A k) (hA k) k cutoff G₀ + have heq : C = readColumn (A k) (hA k) k cutoff G₁ := by + funext n + apply coding_agreement A R hR (k+1) + have hm := location_mem (A k) (hA k) k cutoff n + simp only [column] at hm + split at hm + next h => + refine ⟨h.1, ?_, ?_⟩ + · rw [h.2]; exact (stage_spec A R hR k).2.2.1 + · simpa only [h.2] using hm + next h => simp at hm + exact ⟨C, readColumn_reduces _ _ _ _ _, heq ▸ readColumn_reduces _ _ _ _ _, hnot k cutoff⟩ + · intro Y hY + by_cases hk : ∃ k, Reduces (A k) Y + · exact Or.inr hk + · left + intro Z h₀ h₁ + obtain ⟨c, hc⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp hY + obtain ⟨e₀, he₀⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp + (reduces_trans h₀ (swap_join_reduces G₀ Y)) + obtain ⟨e₁, he₁⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp + (reduces_trans h₁ (swap_join_reduces G₁ Y)) + let i := Encodable.encode (Sum.inr (c, e₀, e₁) : Index) + have hg : GoodForCode A B c e₀ e₁ (stage A R hR (i+1)) := by + simpa only [R, requirements, i, Encodable.encodek] using (stage_spec A R hR i).2.1 + have hleft : CommonIdeal.Extends G₀ (stage A R hR (i+1)).left := + fun n hn => leftReal_extends A R hR (i+1) n hn + have hright : CommonIdeal.Extends G₁ (stage A R hR (i+1)).right := by + intro n hn + exact rightReal_extends A R hR (i+1) n (by simpa [← Condition.sameLength] using hn) + exact (good_common_output hleft hright he₀ he₁ (hg Y hc)).resolve_right hk + +theorem antichain_coding (A : ℕ → Oracle) (B : Oracle) : + ∃ G₀ G₁ : Oracle, + (∀ k, ∃ C : Oracle, Reduces C (join G₀ (A k)) ∧ Reduces C (join G₁ (A k)) ∧ ¬ Reduces C (A k)) ∧ + ∀ Y : Oracle, Reduces Y B → + (∀ Z : Oracle, Reduces Z (join G₀ Y) → Reduces Z (join G₁ Y) → Reduces Z Y) ∨ + ∃ k, Reduces (A k) Y := by + let F := fun k => Introreducible.prefixSet (A k) + have hF : ∀ k, {a | F k a = true}.Infinite := fun k => Introreducible.prefixSet_infinite (A k) + have hIntro : ∀ k Z, (∀ a, Z a = true → F k a = true) → + {a | Z a = true}.Infinite → Reduces (F k) Z := by + intro k Z hsub hinf + exact reduces_trans (Introreducible.prefixSet_reduces (A k)) + (Introreducible.reduces_of_infinite_subset hsub hinf) + obtain ⟨G₀, G₁, hfirst, hsecond⟩ := normalized_coding F hF hIntro B + refine ⟨G₀, G₁, ?_, ?_⟩ + · intro k + obtain ⟨C, h₀, h₁, hn⟩ := hfirst k + have hFA := Introreducible.prefixSet_reduces (A k) + have hAF := ((degree_eq_iff _ _).mp (Introreducible.prefixSet_degree (A k))).2 + exact ⟨C, reduces_trans h₀ (join_mono (reduces_refl G₀) hFA), + reduces_trans h₁ (join_mono (reduces_refl G₁) hFA), fun hCA => hn (reduces_trans hCA hAF)⟩ + · intro Y hY + rcases hsecond Y hY with h | ⟨k, hk⟩ + · exact Or.inl h + · exact Or.inr ⟨k, reduces_trans + (((degree_eq_iff _ _).mp (Introreducible.prefixSet_degree (A k))).2) hk⟩ + +end TuringRigidity.AntichainCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/AntichainDecoding.lean b/lean/OAI/Computability/DegreeRigidity/Effective/AntichainDecoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d70e3332048dd566049ac9ad677e3575d6c77be --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/AntichainDecoding.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticAtoms +import OAI.Computability.DegreeRigidity.Syntax.BoundedDecoding + +namespace OAI + +namespace TuringRigidity.AntichainDecoding +open IndexPresentation ArithmeticHierarchy SetCoding BoundedDecoding + +def Nontrivial (Y : Oracle) (b l r x : ℕ) : Prop := + LE Y x b ∧ ∃ z, Dom Y z ∧ LE Y z (joinIndex l x) ∧ + LE Y z (joinIndex r x) ∧ ¬ LE Y z x + +def Minimal (Y : Oracle) (b l r x : ℕ) : Prop := + ∀ w, Dom Y w → Nontrivial Y b l r w → LE Y w x → LE Y x w + +def Antichain (Y : Oracle) (b l r x : ℕ) : Prop := + Nontrivial Y b l r x ∧ Minimal Y b l r x + +theorem nontrivial_sigma (Y : Oracle) {b l r x : ℕ → ℕ} + (hb : Primrec b) (hl : Primrec l) (hr : Primrec r) (hx : Primrec x) : + Sigma Y 4 (fun v => Nontrivial Y (b v) (l v) (r v) (x v)) := by + let f := Primrec.fst.comp Primrec.unpair + let s := Primrec.snd.comp Primrec.unpair + have hdom : Sigma Y 4 (fun v => Dom Y (Nat.unpair v).2) := (dom_pi Y s).switch.raise + have h₀ := (le_sigma Y s (joinIndex_primrec.comp (hl.comp f) (hx.comp f))).raise + have h₁ := (le_sigma Y s (joinIndex_primrec.comp (hr.comp f) (hx.comp f))).raise + have hn : Sigma Y 4 (fun v => ¬ LE Y (Nat.unpair v).2 (x (Nat.unpair v).1)) := + (le_sigma Y s (hx.comp f)).neg.switch + have hw := (hdom.and (h₀.and (h₁.and hn))).ex + exact ((le_sigma Y hx hb).raise.and hw).congr (fun v => by + simp only [Nat.unpair_pair]; rfl) + +theorem minimal_pi (Y : Oracle) {b l r x : ℕ → ℕ} + (hb : Primrec b) (hl : Primrec l) (hr : Primrec r) (hx : Primrec x) : + Pi Y 4 (fun v => Minimal Y (b v) (l v) (r v) (x v)) := by + let f := Primrec.fst.comp Primrec.unpair + let s := Primrec.snd.comp Primrec.unpair + have hd : Pi Y 4 (fun v => ¬ Dom Y (Nat.unpair v).2) := (dom_pi Y s).neg.switch.raise + have hn := (nontrivial_sigma Y (hb.comp f) (hl.comp f) (hr.comp f) s).neg + have hw : Pi Y 4 (fun v => ¬ LE Y (Nat.unpair v).2 (x (Nat.unpair v).1)) := + (le_sigma Y s (hx.comp f)).neg.raise + have hxw : Pi Y 4 (fun v => LE Y (x (Nat.unpair v).1) (Nat.unpair v).2) := + (le_sigma Y (hx.comp f) s).switch + exact ((hd.or (hn.or (hw.or hxw))).all).congr (fun v => by + simp only [Nat.unpair_pair, Minimal, imp_iff_not_or]) + +theorem antichain_sigma (Y : Oracle) {b l r x : ℕ → ℕ} + (hb : Primrec b) (hl : Primrec l) (hr : Primrec r) (hx : Primrec x) : + Sigma Y 5 (fun v => Antichain Y (b v) (l v) (r v) (x v)) := + (nontrivial_sigma Y hb hl hr hx).raise.and (minimal_pi Y hb hl hr hx).switch + +theorem nontrivial_iff {Y : Oracle} {b l r x : ℕ} + (hb : Dom Y b) (hl : Dom Y l) (hr : Dom Y r) (hx : Dom Y x) : + Nontrivial Y b l r x ↔ LocalNontrivial (degree Y) + (value Y b) (value Y l) (value Y r) (value Y x) := by + unfold Nontrivial LocalNontrivial + rw [le_iff hx hb] + apply and_congr_right + intro _ + constructor + · rintro ⟨z, hz, h₀, h₁, hn⟩ + refine ⟨value Y z, value_below Y z, ?_, ?_, ?_⟩ + · simpa only [join_value hl hx] using (le_iff hz (join_dom hl hx)).mp h₀ + · simpa only [join_value hr hx] using (le_iff hz (join_dom hr hx)).mp h₁ + · exact fun he => hn ((le_iff hz hx).mpr he) + · rintro ⟨z, hz, h₀, h₁, hn⟩ + obtain ⟨w, hw, rfl⟩ := value_surjective Y z hz + exact ⟨w, hw, (le_iff hw (join_dom hl hx)).mpr (by simpa only [join_value hl hx] using h₀), + (le_iff hw (join_dom hr hx)).mpr (by simpa only [join_value hr hx] using h₁), + fun he => hn ((le_iff hw hx).mp he)⟩ + +theorem antichain_iff {Y : Oracle} {b l r x : ℕ} + (hb : Dom Y b) (hl : Dom Y l) (hr : Dom Y r) (hx : Dom Y x) : + Antichain Y b l r x ↔ (AntichainCode.mk (value Y b) (value Y l) (value Y r)).Holds + (value Y x) := by + rw [← local_antichain_iff (degree Y) _ ⟨value_below Y b, value_below Y l, value_below Y r⟩] + unfold Antichain LocalAntichain + rw [nontrivial_iff hb hl hr hx] + apply and_congr_right + intro _ + constructor + · intro hm w hw hn hle + obtain ⟨i, hi, rfl⟩ := value_surjective Y w hw + exact (le_iff hx hi).mp (hm i hi ((nontrivial_iff hb hl hr hi).mpr hn) + ((le_iff hi hx).mpr hle)) + · intro hm w hw hn hle + exact (le_iff hx hw).mpr (hm (value Y w) (value_below Y w) + ((nontrivial_iff hb hl hr hw).mp hn) ((le_iff hw hx).mp hle)) + +end TuringRigidity.AntichainDecoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/AntichainParameters.lean b/lean/OAI/Computability/DegreeRigidity/Effective/AntichainParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..318a63944b274ba41509975d1116e33dce254076 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/AntichainParameters.lean @@ -0,0 +1,82 @@ +import OAI.Computability.DegreeRigidity.Effective.AntichainCoding + +namespace OAI + +namespace TuringRigidity.AntichainParameters + +def NontrivialCommonLower (b g₀ g₁ x : Degree) : Prop := + x ≤ b ∧ ∃ z : Degree, z ≤ g₀ ⊔ x ∧ z ≤ g₁ ⊔ x ∧ ¬ z ≤ x + +def CodedAntichain (b g₀ g₁ x : Degree) : Prop := + NontrivialCommonLower b g₀ g₁ x ∧ + ∀ y : Degree, NontrivialCommonLower b g₀ g₁ y → y ≤ x → x ≤ y + +theorem coding_degree_properties (A : ℕ → Oracle) (B : Oracle) + (hB : ∀ k, Reduces (A k) B) : + ∃ g₀ g₁ : Degree, + (∀ k, NontrivialCommonLower (degree B) g₀ g₁ (degree (A k))) ∧ + ∀ x : Degree, NontrivialCommonLower (degree B) g₀ g₁ x → ∃ k, degree (A k) ≤ x := by + obtain ⟨G₀, G₁, hfirst, hsecond⟩ := AntichainCoding.antichain_coding A B + refine ⟨degree G₀, degree G₁, ?_, ?_⟩ + · intro k + obtain ⟨C, h₀, h₁, hn⟩ := hfirst k + exact ⟨hB k, degree C, h₀, h₁, hn⟩ + · intro x hx + obtain ⟨Y, rfl⟩ := degree_surjective x + obtain ⟨z, h₀, h₁, hn⟩ := hx.2 + obtain ⟨Z, rfl⟩ := degree_surjective z + rcases hsecond Y hx.1 with h | hk + · exact False.elim (hn (h Z h₀ h₁)) + · exact hk + +theorem antichain_parameters (A : ℕ → Oracle) (B : Oracle) + (hB : ∀ k, Reduces (A k) B) + (hAnti : ∀ i j, degree (A i) ≤ degree (A j) → degree (A i) = degree (A j)) : + ∃ g₀ g₁ : Degree, ∀ x : Degree, + CodedAntichain (degree B) g₀ g₁ x ↔ ∃ k, degree (A k) = x := by + obtain ⟨g₀, g₁, hmember, hcover⟩ := coding_degree_properties A B hB + refine ⟨g₀, g₁, ?_⟩ + intro x + constructor + · intro hx + obtain ⟨k, hk⟩ := hcover x hx.1 + exact ⟨k, le_antisymm hk (hx.2 _ (hmember k) hk)⟩ + · rintro ⟨k, rfl⟩ + refine ⟨hmember k, ?_⟩ + intro y hy hyk + obtain ⟨j, hj⟩ := hcover y hy + have he := hAnti j k (hj.trans hyk) + exact he ▸ hj + +theorem countable_antichain_parameters (S : Set Degree) (b : Degree) + (hS : S.Countable) (hB : ∀ x ∈ S, x ≤ b) + (hAnti : ∀ x ∈ S, ∀ y ∈ S, x ≤ y → x = y) : + ∃ g₀ g₁ : Degree, ∀ x : Degree, CodedAntichain b g₀ g₁ x ↔ x ∈ S := by + by_cases hne : S.Nonempty + · obtain ⟨f, hf⟩ := hS.exists_eq_range hne + choose A hA using (fun k => degree_surjective (f k)) + obtain ⟨B, rfl⟩ := degree_surjective b + have hbound : ∀ k, Reduces (A k) B := by + intro k + change degree (A k) ≤ degree B + rw [hA k] + exact hB (f k) (by rw [hf]; exact Set.mem_range_self k) + have hanti : ∀ i j, degree (A i) ≤ degree (A j) → degree (A i) = degree (A j) := by + intro i j hij + rw [hA i, hA j] at hij ⊢ + exact hAnti (f i) (by rw [hf]; exact Set.mem_range_self i) + (f j) (by rw [hf]; exact Set.mem_range_self j) hij + obtain ⟨g₀, g₁, hg⟩ := antichain_parameters A B hbound hanti + refine ⟨g₀, g₁, ?_⟩ + intro x + rw [hg x, hf] + exact ⟨fun ⟨k, hk⟩ => ⟨k, (hA k).symm.trans hk⟩, + fun ⟨k, hk⟩ => ⟨k, (hA k).trans hk⟩⟩ + · have he : S = ∅ := Set.not_nonempty_iff_eq_empty.mp hne + refine ⟨⊥, ⊥, ?_⟩ + intro x + simp [CodedAntichain, NontrivialCommonLower, he] + +end TuringRigidity.AntichainParameters + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/CodingAgreement.lean b/lean/OAI/Computability/DegreeRigidity/Effective/CodingAgreement.lean new file mode 100644 index 0000000000000000000000000000000000000000..84f7d09141cd155ef012ceb5f185d8226ed4dac1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/CodingAgreement.lean @@ -0,0 +1,86 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingForcing +import OAI.Computability.DegreeRigidity.Representation.CommonIdealSearch + +namespace OAI + +namespace TuringRigidity.CodingAgreement +open CodingForcing + +def Disagreement (Y : Oracle) (e₀ e₁ : OracleCode) (p : Condition) : Prop := + ∃ n a b, a ≠ b ∧ a ∈ CommonIdeal.run Y e₀ p.left n ∧ b ∈ CommonIdeal.run Y e₁ p.right n + +def NoDisagreement (A : ℕ → Oracle) (Y : Oracle) (e₀ e₁ : OracleCode) (p : Condition) : Prop := + ∀ q, Extends A p q → ¬ Disagreement Y e₀ e₁ q + +theorem disagreement_mono {A : ℕ → Oracle} {Y : Oracle} {e₀ e₁ : OracleCode} + {p q : Condition} (h : Extends A p q) (hd : Disagreement Y e₀ e₁ p) : + Disagreement Y e₀ e₁ q := by + obtain ⟨n, a, b, hab, ha, hb⟩ := hd + exact ⟨n, a, b, hab, CommonIdeal.run_mono h.1 n a ha, CommonIdeal.run_mono h.2.1 n b hb⟩ + +theorem disagreement_decision_dense (A : ℕ → Oracle) (Y : Oracle) (e₀ e₁ : OracleCode) + (p : Condition) : + ∃ q, Extends A p q ∧ (Disagreement Y e₀ e₁ q ∨ NoDisagreement A Y e₀ e₁ q) := by + by_cases h : ∃ q, Extends A p q ∧ Disagreement Y e₀ e₁ q + · obtain ⟨q, hpq, hd⟩ := h + exact ⟨q, hpq, Or.inl hd⟩ + · exact ⟨p, extends_refl A p, Or.inr (fun q hpq hd => h ⟨q, hpq, hd⟩)⟩ + +theorem noDisagreement_of_common_output {A : ℕ → Oracle} {Y G₀ G₁ Z : Oracle} + {e₀ e₁ : OracleCode} {p : Condition} + (h₀ : CommonIdeal.Extends G₀ p.left) (h₁ : CommonIdeal.Extends G₁ p.right) + (he₀ : OracleCode.eval (oracleFunction (join Y G₀)) e₀ = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y G₁)) e₁ = oracleFunction Z) + (h : Disagreement Y e₀ e₁ p ∨ NoDisagreement A Y e₀ e₁ p) : + NoDisagreement A Y e₀ e₁ p := by + rcases h with hd | hn + · obtain ⟨n, a, b, hab, ha, hb⟩ := hd + have hta := CommonIdeal.run_total h₀ n a ha + have htb := CommonIdeal.run_total h₁ n b hb + rw [he₀] at hta + rw [he₁] at htb + exact False.elim (hab (Part.mem_unique hta htb)) + · exact hn + +def UniqueValues (A : ℕ → Oracle) (Y : Oracle) (e : OracleCode) (p : Condition) : Prop := + ∀ q r, Extends A p q → Extends A p r → ∀ n a b, + a ∈ CommonIdeal.run Y e q.left n → b ∈ CommonIdeal.run Y e r.left n → a = b + +theorem unique_search_sound {A : ℕ → Oracle} {Y G Z : Oracle} {e : OracleCode} + {p : Condition} (hu : UniqueValues A Y e p) (hG : CommonIdeal.Extends G p.left) + (he : OracleCode.eval (oracleFunction (join Y G)) e = oracleFunction Z) + (w : List Bool) (n a : ℕ) (ha : a ∈ CommonIdeal.run Y e (p.left ++ w) n) : + a = CommonIdeal.bit (Z n) := by + obtain ⟨q, hpq, hq⟩ := arbitrary_left_extension A p (p.left ++ w) (List.prefix_append _ _) + obtain ⟨s, hs, hb⟩ := CommonIdeal.run_finite_extension hG n (CommonIdeal.bit (Z n)) (by + rw [he] + exact Part.mem_some _) + obtain ⟨r, hpr, hr⟩ := arbitrary_left_extension A p s hs + exact hu q r hpq hpr n a (CommonIdeal.bit (Z n)) (hq ▸ ha) (hr ▸ hb) + +theorem case1_reduces {A : ℕ → Oracle} {Y G Z : Oracle} {e : OracleCode} {p : Condition} + (hu : UniqueValues A Y e p) (hG : CommonIdeal.Extends G p.left) + (he : OracleCode.eval (oracleFunction (join Y G)) e = oracleFunction Z) : Reduces Z Y := by + obtain ⟨d, hd⟩ := CommonIdeal.finiteRun_code e p.left + apply RecursiveIn.iff_nat.mpr + apply UniformOracle.total_search (CommonIdeal.searchTrial_recursive Y d) (fun n => CommonIdeal.bit (Z n)) + · intro n z a ha + have hf := Nat.Partrec.Code.evaln_sound ha + rw [hd] at hf + have hr := (CommonIdeal.finiteRun_approximates Y e p.left + (Nat.unpair (Nat.unpair z).2).1 n).1 (Nat.unpair z).1 a hf + exact unique_search_sound hu hG he _ n a hr + · intro n + obtain ⟨w, a, ha⟩ := CommonIdeal.agreeing_search_complete hG he n + obtain ⟨wcode, hw⟩ := BorelGeneric.word_surjective w + rw [← hw] at ha + obtain ⟨m, hm⟩ := (CommonIdeal.finiteRun_approximates Y e p.left wcode n).2 a ha + have hf := hm m le_rfl + dsimp only at hf + rw [← hd] at hf + obtain ⟨t, ht⟩ := Nat.Partrec.Code.evaln_complete.mp hf + exact ⟨Nat.pair m (Nat.pair wcode t), a, by simpa [CommonIdeal.searchTrial] using ht⟩ + +end TuringRigidity.CodingAgreement + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/CodingBounds.lean b/lean/OAI/Computability/DegreeRigidity/Effective/CodingBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..68f00a97ab14d81d1b0d6caff2f0d8903a6633c1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/CodingBounds.lean @@ -0,0 +1,35 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticModelDecoding + +namespace OAI + +namespace TuringRigidity.BoundedDecoding +open SetCoding RelationCoding ArithmeticModelDecoding + +theorem AntichainBelow.mono {p : AntichainCode} {x y : Degree} (hp : AntichainBelow p x) (h : x ≤ y) : + AntichainBelow p y := ⟨hp.1.trans h,hp.2.1.trans h,hp.2.2.trans h⟩ + +theorem SetBelow.mono {p : SetCode} {x y : Degree} (hp : SetBelow p x) (h : x ≤ y) : + SetBelow p y := ⟨hp.1.trans h,hp.2.1.mono h,hp.2.2.mono h⟩ + +theorem RelationBelow.mono {n : ℕ} {p : RelationCode n} {x y : Degree} + (hp : RelationBelow p x) (h : x ≤ y) : RelationBelow p y := + ⟨fun i => (hp.1 i).mono h,hp.2.mono h⟩ + +def unary (p : SetCode) : RelationCode 1 := ⟨fun _ => p,p.tags⟩ + +theorem unary_below {p : SetCode} {y : Degree} (hp : SetBelow p y) : RelationBelow (unary p) y := + ⟨fun _ => hp,hp.2.1⟩ + +theorem unary_holds (p : SetCode) (x : Degree) : (unary p).Holds (one x) ↔ p.Holds x := by + constructor + · rintro ⟨c,hc,_⟩ + exact ⟨c 0,hc 0⟩ + · rintro ⟨c,hc⟩ + refine ⟨fun _ => c,fun i => ?_,?_⟩ + · fin_cases i + exact hc + · simpa only [Finset.sup_const,Finset.univ_nonempty,ite_eq_left,unary] using hc.2.1 + +end TuringRigidity.BoundedDecoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/CodingColumns.lean b/lean/OAI/Computability/DegreeRigidity/Effective/CodingColumns.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d72adc21a24d68b794521ee4b5fe32fa54ac0e8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/CodingColumns.lean @@ -0,0 +1,82 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingForcing +import OAI.Computability.DegreeRigidity.Computability.OracleEnumeration +import OAI.Computability.DegreeRigidity.Computability.Joins + +namespace OAI + +namespace TuringRigidity.CodingColumns +open PrefixComputability OracleEnumeration + +def column (A : Oracle) (k cutoff : ℕ) (m : ℕ) : Bool := + if cutoff ≤ m ∧ (Nat.unpair m).1 = k then A (Nat.unpair m).2 else false + +@[simp] theorem column_pair (A : Oracle) (k cutoff a : ℕ) : + column A k cutoff (Nat.pair k a) = (if cutoff ≤ Nat.pair k a then A a else false) := by + simp [column] + +theorem column_infinite (A : Oracle) (hA : {a | A a = true}.Infinite) (k cutoff : ℕ) : + {m | column A k cutoff m = true}.Infinite := by + have hi : (Nat.pair k '' {a | A a = true}).Infinite := + hA.image (fun a _ b _ h => (Nat.pair_eq_pair.mp h).2) + apply (hi.sdiff (Set.finite_le_nat cutoff)).mono + rintro m ⟨⟨a, ha, rfl⟩, hm⟩ + have hc : cutoff ≤ Nat.pair k a := Nat.le_of_lt (Nat.lt_of_not_ge hm) + change A a = true at ha + simp [hc, ha] + +private def columnStep (k cutoff : ℕ) (p : ℕ) : ℕ := + if cutoff ≤ (Nat.unpair p).1 ∧ (Nat.unpair (Nat.unpair p).1).1 = k + then (Nat.unpair p).2 else 0 + +private theorem columnStep_primrec (k cutoff : ℕ) : Primrec (columnStep k cutoff) := + Primrec.ite ((Primrec.nat_le.comp (Primrec.const cutoff) (Primrec.fst.comp Primrec.unpair)).and + (Primrec.eq.comp (Primrec.fst.comp (Primrec.unpair.comp (Primrec.fst.comp Primrec.unpair))) + (Primrec.const k))) (Primrec.snd.comp Primrec.unpair) (Primrec.const 0) + +theorem column_reduces (A : Oracle) (k cutoff : ℕ) : Reduces (column A k cutoff) A := by + apply RecursiveIn.iff_nat.mpr + have hq : Nat.RecursiveIn {oracleFunction A} (oracleFunction A) := + .oracle _ (Set.mem_singleton _) + have hm := total_primrec (O := {oracleFunction A}) Primrec.id + have ha := total_primrec (O := {oracleFunction A}) (Primrec.snd.comp Primrec.unpair) + have hh := total_comp (total_primrec (columnStep_primrec k cutoff)) + (total_pair hm (total_comp hq ha)) + apply hh.of_eq + intro m + by_cases hc : cutoff ≤ m ∧ (Nat.unpair m).1 = k <;> + simp [columnStep, column, oracleFunction, hc] + +noncomputable def location (A : Oracle) (hA : {a | A a = true}.Infinite) + (k cutoff : ℕ) : ℕ → ℕ := enumerate (column A k cutoff) (column_infinite A hA k cutoff) + +theorem location_mem (A : Oracle) (hA : {a | A a = true}.Infinite) (k cutoff n : ℕ) : + column A k cutoff (location A hA k cutoff n) = true := enumerate_mem _ _ _ + +theorem le_location (A : Oracle) (hA : {a | A a = true}.Infinite) (k cutoff n : ℕ) : + n ≤ location A hA k cutoff n := le_enumerate _ _ _ + +theorem location_recursive (A : Oracle) (hA : {a | A a = true}.Infinite) (k cutoff : ℕ) : + Nat.RecursiveIn {oracleFunction A} (fun n => Part.some (location A hA k cutoff n)) := by + apply (enumerate_recursive (column A k cutoff) (column_infinite A hA k cutoff)).subst + intro f hf + have he : f = oracleFunction (column A k cutoff) := Set.mem_singleton_iff.mp hf + subst f + exact RecursiveIn.iff_nat.mp (column_reduces A k cutoff) + +noncomputable def readColumn (A : Oracle) (hA : {a | A a = true}.Infinite) + (k cutoff : ℕ) (G : Oracle) : Oracle := fun n => G (location A hA k cutoff n) + +theorem readColumn_reduces (A : Oracle) (hA : {a | A a = true}.Infinite) + (k cutoff : ℕ) (G : Oracle) : Reduces (readColumn A hA k cutoff G) (join G A) := by + apply RecursiveIn.iff_nat.mpr + have hloc := (location_recursive A hA k cutoff).subst (O' := {oracleFunction (join G A)}) + (fun f hf => by + have he : f = oracleFunction A := Set.mem_singleton_iff.mp hf + subst f + exact RecursiveIn.iff_nat.mp (reduces_join_right G A)) + have hG := RecursiveIn.iff_nat.mp (reduces_join_left G A) + exact total_comp hG hloc + +end TuringRigidity.CodingColumns + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/CodingDiagonal.lean b/lean/OAI/Computability/DegreeRigidity/Effective/CodingDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..a80f3c903393f48f992179447f6f61f2754984ec --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/CodingDiagonal.lean @@ -0,0 +1,49 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingColumns + +namespace OAI + +namespace TuringRigidity.CodingDiagonal +open CodingForcing CodingColumns Introreducible + +def Diagonal (A : ℕ → Oracle) (hA : ∀ k, {a | A k a = true}.Infinite) + (k cutoff : ℕ) (e : OracleCode) (p : Condition) : Prop := + ∃ n, location (A k) (hA k) k cutoff n < p.left.length ∧ + OracleCode.eval (oracleFunction (A k)) e n ≠ + Part.some (if p.left.getD (location (A k) (hA k) k cutoff n) false then 1 else 0) + +theorem diagonal_mono {A : ℕ → Oracle} {hA : ∀ k, {a | A k a = true}.Infinite} + {k cutoff : ℕ} {e : OracleCode} {p q : Condition} + (hpq : Extends A p q) (hp : Diagonal A hA k cutoff e p) : + Diagonal A hA k cutoff e q := by + obtain ⟨n, hn, he⟩ := hp + exact ⟨n, hn.trans_le hpq.1.length_le, by rwa [getD_of_prefix hpq.1 hn]⟩ + +theorem exists_different_bit (v : Part ℕ) : + ∃ b : Bool, v ≠ Part.some (if b then 1 else 0) := by + by_cases h : v = Part.some 0 + · exact ⟨true, by simp [h]⟩ + · exact ⟨false, h⟩ + +theorem prescribe (A : ℕ → Oracle) (p : Condition) (m : ℕ) + (hm : p.left.length ≤ m) (b : Bool) : + ∃ q, Extends A p q ∧ m < q.left.length ∧ q.left.getD m false = b := by + refine ⟨append p (List.replicate (m - p.left.length + 1) b), append_extends A p _, ?_, ?_⟩ + · simp only [append, List.length_append, List.length_replicate] + omega + · simp only [append, List.getD_eq_getElem?_getD, List.getElem?_append, + ite_eq_right (Nat.not_lt.mpr hm)] + simp + +theorem diagonal_dense (A : ℕ → Oracle) (hA : ∀ k, {a | A k a = true}.Infinite) + (k cutoff : ℕ) (e : OracleCode) (p : Condition) : + ∃ q, Extends A p q ∧ Diagonal A hA k cutoff e q := by + let n := p.left.length + let m := location (A k) (hA k) k cutoff n + obtain ⟨b, hb⟩ := exists_different_bit (OracleCode.eval (oracleFunction (A k)) e n) + obtain ⟨q, hpq, hmq, hqb⟩ := prescribe A p m (le_location _ _ _ _ _) b + refine ⟨q, hpq, n, hmq, ?_⟩ + simpa only [← hqb] using hb + +end TuringRigidity.CodingDiagonal + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/CodingExtraction.lean b/lean/OAI/Computability/DegreeRigidity/Effective/CodingExtraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d4f8ead0090d803e8c29c69ee43359419b81d68 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/CodingExtraction.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingSplitSearch +import OAI.Computability.DegreeRigidity.Effective.RecursiveInfiniteSubset + +namespace OAI + +namespace TuringRigidity.CodingExtraction +open CodingForcing CodingAgreement CodingLocations CodingSplitSearch PrefixComputability + +theorem recursive_coding_locations {A : ℕ → Oracle} {Y : Oracle} {e₀ e₁ : OracleCode} + {p : Condition} (hn : NoDisagreement A Y e₀ e₁ p) + (hL : DenseLeft A Y e₀ p) (hR : DenseRight A Y e₁ p) + (hU : ∀ q, Extends A p q → ¬ UniqueValues A Y e₀ q) : + ∃ C : Oracle, Reduces C Y ∧ {m | C m = true}.Infinite ∧ + ∀ m, C m = true → CodingLocation A p m := by + obtain ⟨E, hE, hEq⟩ := splittingLocations_enumerable Y e₀ p.left + have hu : RecursiveInfiniteSubset.Unbounded E := by + intro N + obtain ⟨m, hm, hs⟩ := splittingLocation_unbounded hL hU N + obtain ⟨z, hz⟩ := (hEq m).mp hs + exact ⟨z, m, hm, hz⟩ + obtain ⟨C, hCY, hCinf, hC⟩ := RecursiveInfiniteSubset.infinite_recursive_subset Y E hu hE + refine ⟨C, hCY, hCinf, ?_⟩ + intro m hm + exact splittingLocation_sound hn hR ((hEq m).mpr (hC m hm)) + +theorem column_projection_reduces (C : Oracle) (k : ℕ) : + Reduces (fun a => C (Nat.pair k a)) C := by + apply RecursiveIn.iff_nat.mpr + have hq : Nat.RecursiveIn {oracleFunction C} (oracleFunction C) := .oracle _ (Set.mem_singleton _) + exact total_comp hq (total_primrec (Primrec₂.natPair.comp (Primrec.const k) Primrec.id)) + +theorem infinite_column {A : ℕ → Oracle} {Y C : Oracle} {p : Condition} + (hCY : Reduces C Y) (hinf : {m | C m = true}.Infinite) + (hC : ∀ m, C m = true → CodingLocation A p m) : + ∃ k, k < p.active ∧ ∃ Z : Oracle, Reduces Z Y ∧ {a | Z a = true}.Infinite ∧ + ∀ a, Z a = true → A k a = true := by + let F := fun k : Fin p.active => {m : ℕ | C m = true ∧ (Nat.unpair m).1 = k.val} + have hex : ∃ k : Fin p.active, (F k).Infinite := by + by_contra h + have hf : ∀ k : Fin p.active, (F k).Finite := by + intro k + by_contra hi + exact h ⟨k, hi⟩ + apply hinf + apply (Set.finite_iUnion hf).subset + intro m hm + refine Set.mem_iUnion.mpr ⟨⟨(Nat.unpair m).1, (hC m hm).2.1⟩, ?_⟩ + exact ⟨hm, rfl⟩ + obtain ⟨k, hk⟩ := hex + let Z : Oracle := fun a => C (Nat.pair k.val a) + refine ⟨k.val, k.isLt, Z, reduces_trans (column_projection_reduces C k.val) hCY, ?_, ?_⟩ + · intro hZ + apply hk + apply (hZ.image (Nat.pair k.val)).subset + intro m hm + refine ⟨(Nat.unpair m).2, ?_, ?_⟩ + · change C (Nat.pair k.val (Nat.unpair m).2) = true + rw [← hm.2, Nat.pair_unpair] + exact hm.1 + · rw [← hm.2, Nat.pair_unpair] + · intro a ha + have hc := (hC (Nat.pair k.val a) ha).2.2 + simpa only [Nat.unpair_pair] using hc + +theorem case2_computes_member {A : ℕ → Oracle} {Y : Oracle} {e₀ e₁ : OracleCode} + {p : Condition} + (hIntro : ∀ k Z, (∀ a, Z a = true → A k a = true) → + {a | Z a = true}.Infinite → Reduces (A k) Z) + (hn : NoDisagreement A Y e₀ e₁ p) + (hL : DenseLeft A Y e₀ p) (hR : DenseRight A Y e₁ p) + (hU : ∀ q, Extends A p q → ¬ UniqueValues A Y e₀ q) : + ∃ k, k < p.active ∧ Reduces (A k) Y := by + obtain ⟨C, hCY, hCinf, hC⟩ := recursive_coding_locations hn hL hR hU + obtain ⟨k, hk, Z, hZY, hZinf, hZ⟩ := infinite_column hCY hCinf hC + exact ⟨k, hk, reduces_trans (hIntro k Z hZ hZinf) hZY⟩ + +end TuringRigidity.CodingExtraction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/CodingForcing.lean b/lean/OAI/Computability/DegreeRigidity/Effective/CodingForcing.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e86e44aedcd54186578f1ca4c37679e5eb12f9e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/CodingForcing.lean @@ -0,0 +1,110 @@ +import OAI.Computability.DegreeRigidity.Computability.Introreducible + +namespace OAI + +namespace TuringRigidity.CodingForcing + +structure Condition where + left : List Bool + right : List Bool + sameLength : left.length = right.length + active : ℕ + +def CodingLocation (A : ℕ → Oracle) (p : Condition) (m : ℕ) : Prop := + p.left.length ≤ m ∧ (Nat.unpair m).1 < p.active ∧ + A (Nat.unpair m).1 (Nat.unpair m).2 = true + +def Extends (A : ℕ → Oracle) (p q : Condition) : Prop := + p.left <+: q.left ∧ p.right <+: q.right ∧ p.active ≤ q.active ∧ + ∀ m, CodingLocation A p m → m < q.left.length → + q.left.getD m false = q.right.getD m false + +theorem extends_refl (A : ℕ → Oracle) (p : Condition) : Extends A p p := by + refine ⟨List.prefix_rfl, List.prefix_rfl, le_rfl, ?_⟩ + intro m hm hlt + exact False.elim (Nat.not_lt_of_ge hm.1 hlt) + +theorem getD_of_prefix {s t : List Bool} (h : s <+: t) {m : ℕ} + (hm : m < s.length) : t.getD m false = s.getD m false := by + obtain ⟨u, rfl⟩ := h + simp [List.getD_eq_getElem?_getD, List.getElem?_append, hm] + +theorem extends_trans {A : ℕ → Oracle} {p q r : Condition} + (hpq : Extends A p q) (hqr : Extends A q r) : Extends A p r := by + refine ⟨hpq.1.trans hqr.1, hpq.2.1.trans hqr.2.1, + hpq.2.2.1.trans hqr.2.2.1, ?_⟩ + intro m hm hmr + by_cases hmq : m < q.left.length + · rw [getD_of_prefix hqr.1 hmq, + getD_of_prefix hqr.2.1 (by simpa [← q.sameLength] using hmq)] + exact hpq.2.2.2 m hm hmq + · exact hqr.2.2.2 m ⟨Nat.le_of_not_gt hmq, hm.2.1.trans_le hpq.2.2.1, hm.2.2⟩ hmr + +theorem extends_antisymm {A : ℕ → Oracle} {p q : Condition} + (hpq : Extends A p q) (hqp : Extends A q p) : p = q := by + have hl := hpq.1.eq_of_length (Nat.le_antisymm hpq.1.length_le hqp.1.length_le) + have hr := hpq.2.1.eq_of_length (Nat.le_antisymm hpq.2.1.length_le hqp.2.1.length_le) + have ha := Nat.le_antisymm hpq.2.2.1 hqp.2.2.1 + cases p + cases q + simp_all + +def activate (p : Condition) (k : ℕ) : Condition := + ⟨p.left, p.right, p.sameLength, max p.active k⟩ + +theorem activate_extends (A : ℕ → Oracle) (p : Condition) (k : ℕ) : + Extends A p (activate p k) := by + refine ⟨List.prefix_rfl, List.prefix_rfl, Nat.le_max_left _ _, ?_⟩ + intro m hm hlt + exact False.elim (Nat.not_lt_of_ge hm.1 hlt) + +theorem active_dense (A : ℕ → Oracle) (p : Condition) (k : ℕ) : + ∃ q, Extends A p q ∧ k < q.active := + ⟨activate p (k+1), activate_extends A p (k+1), + Nat.lt_of_lt_of_le (Nat.lt_succ_self k) (Nat.le_max_right _ _)⟩ + +def append (p : Condition) (s : List Bool) : Condition where + left := p.left ++ s + right := p.right ++ s + sameLength := by simp [p.sameLength] + active := p.active + +theorem append_extends (A : ℕ → Oracle) (p : Condition) (s : List Bool) : + Extends A p (append p s) := by + refine ⟨List.prefix_append _ _, List.prefix_append _ _, le_rfl, ?_⟩ + intro m hm _ + simp only [append, List.getD_eq_getElem?_getD, List.getElem?_append] + rw [ite_eq_right (Nat.not_lt.mpr hm.1), + ite_eq_right (by simpa [← p.sameLength] using Nat.not_lt.mpr hm.1), p.sameLength] + +theorem arbitrary_left_extension (A : ℕ → Oracle) (p : Condition) + (s : List Bool) (hs : p.left <+: s) : + ∃ q, Extends A p q ∧ q.left = s := by + obtain ⟨u, rfl⟩ := hs + exact ⟨append p u, append_extends A p u, rfl⟩ + +theorem length_dense (A : ℕ → Oracle) (p : Condition) (n : ℕ) : + ∃ q, Extends A p q ∧ n ≤ q.left.length := by + refine ⟨append p (List.replicate n false), append_extends A p _, ?_⟩ + simp [append] + +theorem codingLocation_unbounded (A : ℕ → Oracle) (p : Condition) (k : ℕ) + (hk : k < p.active) (hinf : {a | A k a = true}.Infinite) (n : ℕ) : + ∃ a, A k a = true ∧ max n p.left.length ≤ Nat.pair k a ∧ + CodingLocation A p (Nat.pair k a) := by + have hi : (Nat.pair k '' {a | A k a = true}).Infinite := + hinf.image (fun a _ b _ h => (Nat.pair_eq_pair.mp h).2) + have hex : ∃ m ∈ Nat.pair k '' {a | A k a = true}, max n p.left.length < m := by + by_contra h + apply hi + apply (Set.finite_le_nat (max n p.left.length)).subset + intro m hm + exact Nat.le_of_not_gt (fun hgt => h ⟨m, hm, hgt⟩) + obtain ⟨m, ⟨a, ha, rfl⟩, hm⟩ := hex + refine ⟨a, ha, Nat.le_of_lt hm, ?_⟩ + simp only [CodingLocation, Nat.unpair_pair] + exact ⟨le_trans (Nat.le_max_right _ _) (Nat.le_of_lt hm), hk, ha⟩ + +end TuringRigidity.CodingForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/CodingGeneric.lean b/lean/OAI/Computability/DegreeRigidity/Effective/CodingGeneric.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b8155f5006def830d498b084617a7be7ca87555 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/CodingGeneric.lean @@ -0,0 +1,153 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingDiagonal + +namespace OAI + +namespace TuringRigidity.CodingGeneric +open CodingForcing CodingColumns CodingDiagonal + +def Dense (A : ℕ → Oracle) (R : Condition → Prop) : Prop := + ∀ p, ∃ q, Extends A p q ∧ R q + +private theorem extend_dense (A : ℕ → Oracle) (R : Condition → Prop) + (hR : Dense A R) (p : Condition) (n : ℕ) : + ∃ q, Extends A p q ∧ R q ∧ n < q.active ∧ n < q.left.length := by + obtain ⟨r, hpr, hn⟩ := length_dense A p (n+1) + obtain ⟨s, hrs, ha⟩ := active_dense A r n + obtain ⟨q, hsq, hRq⟩ := hR s + exact ⟨q, extends_trans hpr (extends_trans hrs hsq), hRq, + ha.trans_le hsq.2.2.1, + (Nat.lt_succ_self n).trans_le (hn.trans (hrs.1.length_le.trans hsq.1.length_le))⟩ + +noncomputable def stage (A : ℕ → Oracle) (R : ℕ → Condition → Prop) + (hR : ∀ n, Dense A (R n)) : ℕ → Condition + | 0 => ⟨[], [], rfl, 0⟩ + | n+1 => Classical.choose (extend_dense A (R n) (hR n) (stage A R hR n) n) + +theorem stage_spec (A : ℕ → Oracle) (R : ℕ → Condition → Prop) + (hR : ∀ n, Dense A (R n)) (n : ℕ) : + Extends A (stage A R hR n) (stage A R hR (n+1)) ∧ + R n (stage A R hR (n+1)) ∧ n < (stage A R hR (n+1)).active ∧ + n < (stage A R hR (n+1)).left.length := + Classical.choose_spec (extend_dense A (R n) (hR n) (stage A R hR n) n) + +theorem stage_mono (A : ℕ → Oracle) (R : ℕ → Condition → Prop) + (hR : ∀ n, Dense A (R n)) {m n : ℕ} (h : m ≤ n) : + Extends A (stage A R hR m) (stage A R hR n) := by + induction h with + | refl => exact extends_refl A _ + | step h ih => exact extends_trans ih (stage_spec A R hR _).1 + +noncomputable def leftReal (A : ℕ → Oracle) (R : ℕ → Condition → Prop) + (hR : ∀ n, Dense A (R n)) : Oracle := fun n => (stage A R hR (n+1)).left.getD n false +noncomputable def rightReal (A : ℕ → Oracle) (R : ℕ → Condition → Prop) + (hR : ∀ n, Dense A (R n)) : Oracle := fun n => (stage A R hR (n+1)).right.getD n false + +theorem leftReal_extends (A : ℕ → Oracle) (R : ℕ → Condition → Prop) + (hR : ∀ n, Dense A (R n)) (s n : ℕ) (hn : n < (stage A R hR s).left.length) : + leftReal A R hR n = (stage A R hR s).left.getD n false := by + unfold leftReal + by_cases h : s ≤ n+1 + · exact getD_of_prefix (stage_mono A R hR h).1 hn + · exact (getD_of_prefix (stage_mono A R hR (Nat.le_of_not_ge h)).1 + (stage_spec A R hR n).2.2.2).symm + +theorem rightReal_extends (A : ℕ → Oracle) (R : ℕ → Condition → Prop) + (hR : ∀ n, Dense A (R n)) (s n : ℕ) (hn : n < (stage A R hR s).left.length) : + rightReal A R hR n = (stage A R hR s).right.getD n false := by + unfold rightReal + by_cases h : s ≤ n+1 + · exact getD_of_prefix (stage_mono A R hR h).2.1 (by simpa [← Condition.sameLength] using hn) + · exact (getD_of_prefix (stage_mono A R hR (Nat.le_of_not_ge h)).2.1 + (by simpa [← Condition.sameLength] using (stage_spec A R hR n).2.2.2)).symm + +theorem coding_agreement (A : ℕ → Oracle) (R : ℕ → Condition → Prop) + (hR : ∀ n, Dense A (R n)) (s m : ℕ) + (hm : CodingLocation A (stage A R hR s) m) : + leftReal A R hR m = rightReal A R hR m := by + let t := max s (m+1) + have hst := stage_mono A R hR (Nat.le_max_left s (m+1)) + have hmt := stage_mono A R hR (Nat.le_max_right s (m+1)) + have hlen : m < (stage A R hR t).left.length := + (stage_spec A R hR m).2.2.2.trans_le hmt.1.length_le + rw [leftReal_extends A R hR t m hlen, rightReal_extends A R hR t m hlen] + exact hst.2.2.2 m hm hlen + +abbrev RequirementIndex := ℕ × ℕ × OracleCode + +def requirements (A : ℕ → Oracle) (hA : ∀ k, {a | A k a = true}.Infinite) + (n : ℕ) (p : Condition) : Prop := + match Encodable.decode (α := RequirementIndex) n with + | none => True + | some (k, cutoff, e) => Diagonal A hA k cutoff e p + +theorem requirements_dense (A : ℕ → Oracle) (hA : ∀ k, {a | A k a = true}.Infinite) + (n : ℕ) : Dense A (requirements A hA n) := by + intro p + unfold requirements + cases hd : Encodable.decode (α := RequirementIndex) n with + | none => exact ⟨p, extends_refl A p, trivial⟩ + | some v => exact diagonal_dense A hA v.1 v.2.1 v.2.2 p + +theorem readColumn_not_reduces (A : ℕ → Oracle) (hA : ∀ k, {a | A k a = true}.Infinite) + (k cutoff : ℕ) : + ¬ Reduces (readColumn (A k) (hA k) k cutoff + (leftReal A (requirements A hA) (requirements_dense A hA))) (A k) := by + intro h + obtain ⟨e, he⟩ := OracleCode.turingReducible_iff_exists_code _ _ |>.mp h + let i := Encodable.encode (k, cutoff, e) + have hd := (stage_spec A (requirements A hA) (requirements_dense A hA) i).2.1 + have hd' : Diagonal A hA k cutoff e + (stage A (requirements A hA) (requirements_dense A hA) (i+1)) := by + simpa [requirements, i] using hd + obtain ⟨n, hn, hne⟩ := hd' + apply hne + rw [he] + change Part.some (if leftReal A (requirements A hA) (requirements_dense A hA) + (location (A k) (hA k) k cutoff n) then 1 else 0) = _ + rw [leftReal_extends A (requirements A hA) (requirements_dense A hA) (i+1) _ hn] + +theorem common_noncomputable_columns (A : ℕ → Oracle) + (hA : ∀ k, {a | A k a = true}.Infinite) : + ∃ G₀ G₁ : Oracle, ∀ k, ∃ C : Oracle, + Reduces C (join G₀ (A k)) ∧ Reduces C (join G₁ (A k)) ∧ ¬ Reduces C (A k) := by + let R := requirements A hA + let hR := requirements_dense A hA + let G₀ := leftReal A R hR + let G₁ := rightReal A R hR + refine ⟨G₀, G₁, ?_⟩ + intro k + let p := stage A R hR (k+1) + let cutoff := p.left.length + let C := readColumn (A k) (hA k) k cutoff G₀ + have heq : C = readColumn (A k) (hA k) k cutoff G₁ := by + funext n + apply coding_agreement A R hR (k+1) + have hm := location_mem (A k) (hA k) k cutoff n + simp only [column] at hm + split at hm + next h => + refine ⟨h.1, ?_, ?_⟩ + · rw [h.2] + exact (stage_spec A R hR k).2.2.1 + · simpa only [h.2] using hm + next h => simp at hm + exact ⟨C, readColumn_reduces _ _ _ _ _, heq ▸ readColumn_reduces _ _ _ _ _, + readColumn_not_reduces A hA k cutoff⟩ + +theorem coding_first_clause (A : ℕ → Oracle) : + ∃ G₀ G₁ : Oracle, ∀ k, ∃ C : Oracle, + Reduces C (join G₀ (A k)) ∧ Reduces C (join G₁ (A k)) ∧ ¬ Reduces C (A k) := by + let B := fun k => Introreducible.prefixSet (A k) + obtain ⟨G₀, G₁, h⟩ := common_noncomputable_columns B + (fun k => Introreducible.prefixSet_infinite (A k)) + refine ⟨G₀, G₁, ?_⟩ + intro k + obtain ⟨C, h₀, h₁, hn⟩ := h k + have hBA := Introreducible.prefixSet_reduces (A k) + have hAB := ((degree_eq_iff _ _).mp (Introreducible.prefixSet_degree (A k))).2 + exact ⟨C, reduces_trans h₀ (join_mono (reduces_refl G₀) hBA), + reduces_trans h₁ (join_mono (reduces_refl G₁) hBA), fun hCA => hn (reduces_trans hCA hAB)⟩ + +end TuringRigidity.CodingGeneric + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/CodingLocations.lean b/lean/OAI/Computability/DegreeRigidity/Effective/CodingLocations.lean new file mode 100644 index 0000000000000000000000000000000000000000..0889160b821de7190c8a99040be348e8ef5b6726 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/CodingLocations.lean @@ -0,0 +1,63 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingSplitting + +namespace OAI + +namespace TuringRigidity.CodingLocations +open CodingForcing CodingAgreement CodingOnePoint CodingSplitting + +def DenseLeft (A : ℕ → Oracle) (Y : Oracle) (e : OracleCode) (p : Condition) : Prop := + ∀ q, Extends A p q → ∀ n, ∃ r v, Extends A q r ∧ v ∈ CommonIdeal.run Y e r.left n + +def DenseRight (A : ℕ → Oracle) (Y : Oracle) (e : OracleCode) (p : Condition) : Prop := + ∀ q, Extends A p q → ∀ n, ∃ r v, Extends A q r ∧ v ∈ CommonIdeal.run Y e r.right n + +def SplittingLocation (Y : Oracle) (e : OracleCode) (base : List Bool) (m : ℕ) : Prop := + ∃ s b n v w, base <+: s ∧ base.length ≤ m ∧ m < s.length ∧ v ≠ w ∧ + v ∈ CommonIdeal.run Y e s n ∧ w ∈ CommonIdeal.run Y e (s.set m b) n + +theorem splittingLocation_sound {A : ℕ → Oracle} {Y : Oracle} {e₀ e₁ : OracleCode} + {p : Condition} (hn : NoDisagreement A Y e₀ e₁ p) (hR : DenseRight A Y e₁ p) + {m : ℕ} (hm : SplittingLocation Y e₀ p.left m) : CodingLocation A p m := by + obtain ⟨s, b, n, v, w, hs, hmp, hms, hvw, hv, hw⟩ := hm + obtain ⟨r, hpr, hr⟩ := arbitrary_left_extension A p s hs + have hms' : m < r.left.length := by simpa only [hr] using hms + rcases split_coding_or_divergence hn hpr m hmp hms' b n v w hvw + (hr ▸ hv) (hr ▸ hw) with hc | hd + · exact hc + · obtain ⟨q, c, hrq, hc⟩ := hR r hpr n + exact False.elim (hd q hrq c hc) + +theorem splittingLocation_unbounded {A : ℕ → Oracle} {Y : Oracle} {e : OracleCode} + {p : Condition} (hL : DenseLeft A Y e p) + (hU : ∀ q, Extends A p q → ¬ UniqueValues A Y e q) (N : ℕ) : + ∃ m, N ≤ m ∧ SplittingLocation Y e p.left m := by + obtain ⟨q, hpq, hNq⟩ := length_dense A p N + have hu := hU q hpq + simp only [UniqueValues] at hu + push Not at hu + obtain ⟨r, s, hqr, hqs, n, a, b, ha, hb, hab⟩ := hu + rcases split_or_divergent_word hqr.1 hqs.1 n a b ha hb hab with hsplit | hdiv + · obtain ⟨w, m, c, v, z, hqw, hqm, hmw, hvz, hv, hz⟩ := hsplit + exact ⟨m, hNq.trans hqm, w, c, n, v, z, hpq.1.trans hqw, + hpq.1.length_le.trans hqm, hmw, hvz, hv, hz⟩ + · obtain ⟨w, hqw, hd⟩ := hdiv + obtain ⟨t, hqt, ht⟩ := arbitrary_left_extension A q w hqw + obtain ⟨u, v, htu, hv⟩ := hL t (extends_trans hpq hqt) n + have hwu : w <+: u.left := by simpa only [ht] using htu.1 + obtain ⟨extra, hleft⟩ := hwu + exact False.elim (hd extra v (hleft ▸ hv)) + +theorem splittingLocations_infinite {A : ℕ → Oracle} {Y : Oracle} {e : OracleCode} + {p : Condition} (hL : DenseLeft A Y e p) + (hU : ∀ q, Extends A p q → ¬ UniqueValues A Y e q) : + {m | SplittingLocation Y e p.left m}.Infinite := by + intro hf + have hb := hf.bddAbove + obtain ⟨b, hb⟩ := hb + obtain ⟨m, hm, hs⟩ := splittingLocation_unbounded hL hU (b+1) + have hmb := hb hs + omega + +end TuringRigidity.CodingLocations + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/CodingOnePoint.lean b/lean/OAI/Computability/DegreeRigidity/Effective/CodingOnePoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9058de3eef412262b8bd62beb3ecfcf5fa22540 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/CodingOnePoint.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingAgreement + +namespace OAI + +namespace TuringRigidity.CodingOnePoint +open CodingForcing CodingAgreement + +theorem prefix_set_of_le {s t : List Bool} (h : s <+: t) (m : ℕ) + (hm : s.length ≤ m) (b : Bool) : s <+: t.set m b := by + obtain ⟨u, rfl⟩ := h + rw [List.set_append_right _ _ hm] + exact List.prefix_append _ _ + +theorem set_prefix_set {s t : List Bool} (h : s <+: t) (m : ℕ) + (hm : m < s.length) (b : Bool) : s.set m b <+: t.set m b := by + obtain ⟨u, rfl⟩ := h + rw [List.set_append_left _ _ hm] + exact List.prefix_append _ _ + +def changeLeft (q : Condition) (m : ℕ) (b : Bool) : Condition where + left := q.left.set m b + right := q.right + sameLength := by simpa using q.sameLength + active := q.active + +theorem changeLeft_extends {A : ℕ → Oracle} {p q : Condition} (hpq : Extends A p q) + (m : ℕ) (hm : p.left.length ≤ m) (hnc : ¬ CodingLocation A p m) (b : Bool) : + Extends A p (changeLeft q m b) := by + refine ⟨prefix_set_of_le hpq.1 m hm b, hpq.2.1, hpq.2.2.1, ?_⟩ + intro j hj hjlen + have hne : m ≠ j := by + intro h + subst j + exact hnc hj + have heq := hpq.2.2.2 j hj (by simpa [changeLeft] using hjlen) + simpa [changeLeft, List.getD_eq_getElem?_getD, List.getElem?_set_ne hne] using heq + +theorem split_coding_or_divergence {A : ℕ → Oracle} {Y : Oracle} {e₀ e₁ : OracleCode} + {p r : Condition} (hn : NoDisagreement A Y e₀ e₁ p) (hpr : Extends A p r) + (m : ℕ) (hm : p.left.length ≤ m) (hmr : m < r.left.length) (b : Bool) + (n v w : ℕ) (hvw : v ≠ w) + (hv : v ∈ CommonIdeal.run Y e₀ r.left n) + (hw : w ∈ CommonIdeal.run Y e₀ (r.left.set m b) n) : + CodingLocation A p m ∨ + ∀ q, Extends A r q → ∀ c, c ∉ CommonIdeal.run Y e₁ q.right n := by + by_cases hc : CodingLocation A p m + · exact Or.inl hc + · right + intro q hrq c hvc + have hpq := extends_trans hpr hrq + have hpc := changeLeft_extends hpq m hm hc b + have hvq := CommonIdeal.run_mono hrq.1 n v hv + have hwq := CommonIdeal.run_mono (set_prefix_set hrq.1 m hmr b) n w hw + have hveq : v = c := by + by_contra hne + exact hn q hpq ⟨n, v, c, hne, hvq, hvc⟩ + have hweq : w = c := by + by_contra hne + exact hn (changeLeft q m b) hpc ⟨n, w, c, hne, hwq, hvc⟩ + exact hvw (hveq.trans hweq.symm) + +end TuringRigidity.CodingOnePoint + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/CodingRequirements.lean b/lean/OAI/Computability/DegreeRigidity/Effective/CodingRequirements.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc96a20ea8bebd2a629426bc2e14cbaa9809d3dd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/CodingRequirements.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingExtraction + +namespace OAI + +namespace TuringRigidity.CodingRequirements +open CodingForcing CodingAgreement CodingLocations CodingExtraction + +def Good (A : ℕ → Oracle) (Y : Oracle) (e₀ e₁ : OracleCode) (p : Condition) : Prop := + Disagreement Y e₀ e₁ p ∨ + (∃ n, ∀ q, Extends A p q → ∀ v, v ∉ CommonIdeal.run Y e₀ q.left n) ∨ + (∃ n, ∀ q, Extends A p q → ∀ v, v ∉ CommonIdeal.run Y e₁ q.right n) ∨ + UniqueValues A Y e₀ p ∨ ∃ k, Reduces (A k) Y + +theorem good_dense (A : ℕ → Oracle) + (hIntro : ∀ k Z, (∀ a, Z a = true → A k a = true) → + {a | Z a = true}.Infinite → Reduces (A k) Z) + (Y : Oracle) (e₀ e₁ : OracleCode) (p : Condition) : + ∃ q, Extends A p q ∧ Good A Y e₀ e₁ q := by + obtain ⟨q, hpq, hd | hn⟩ := disagreement_decision_dense A Y e₀ e₁ p + · exact ⟨q, hpq, Or.inl hd⟩ + · by_cases hl : ∃ r, Extends A q r ∧ ∃ n, ∀ s, Extends A r s → ∀ v, v ∉ CommonIdeal.run Y e₀ s.left n + · obtain ⟨r, hqr, hdiv⟩ := hl + exact ⟨r, extends_trans hpq hqr, Or.inr (Or.inl hdiv)⟩ + · by_cases hr : ∃ r, Extends A q r ∧ ∃ n, ∀ s, Extends A r s → ∀ v, v ∉ CommonIdeal.run Y e₁ s.right n + · obtain ⟨r, hqr, hdiv⟩ := hr + exact ⟨r, extends_trans hpq hqr, Or.inr (Or.inr (Or.inl hdiv))⟩ + · by_cases hu : ∃ r, Extends A q r ∧ UniqueValues A Y e₀ r + · obtain ⟨r, hqr, hu⟩ := hu + exact ⟨r, extends_trans hpq hqr, Or.inr (Or.inr (Or.inr (Or.inl hu)))⟩ + · have hL : DenseLeft A Y e₀ q := by + intro r hqr n + by_contra h + push Not at h + exact hl ⟨r, hqr, n, fun s hrs v => h s v hrs⟩ + have hR : DenseRight A Y e₁ q := by + intro r hqr n + by_contra h + push Not at h + exact hr ⟨r, hqr, n, fun s hrs v => h s v hrs⟩ + have hU : ∀ r, Extends A q r → ¬ UniqueValues A Y e₀ r := + fun r hqr huni => hu ⟨r, hqr, huni⟩ + obtain ⟨k, _, hk⟩ := case2_computes_member hIntro hn hL hR hU + exact ⟨q, hpq, Or.inr (Or.inr (Or.inr (Or.inr ⟨k, hk⟩)))⟩ + +theorem arbitrary_right_extension (A : ℕ → Oracle) (p : Condition) + (s : List Bool) (hs : p.right <+: s) : ∃ q, Extends A p q ∧ q.right = s := by + obtain ⟨u, rfl⟩ := hs + exact ⟨append p u, append_extends A p u, rfl⟩ + +theorem good_common_output {A : ℕ → Oracle} {Y G₀ G₁ Z : Oracle} + {e₀ e₁ : OracleCode} {p : Condition} + (h₀ : CommonIdeal.Extends G₀ p.left) (h₁ : CommonIdeal.Extends G₁ p.right) + (he₀ : OracleCode.eval (oracleFunction (join Y G₀)) e₀ = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y G₁)) e₁ = oracleFunction Z) + (h : Good A Y e₀ e₁ p) : Reduces Z Y ∨ ∃ k, Reduces (A k) Y := by + rcases h with hd | hl | hr | hu | ha + · obtain ⟨n, a, b, hab, hva, hvb⟩ := hd + have hta := CommonIdeal.run_total h₀ n a hva + have htb := CommonIdeal.run_total h₁ n b hvb + rw [he₀] at hta + rw [he₁] at htb + exact False.elim (hab (Part.mem_unique hta htb)) + · obtain ⟨n, hn⟩ := hl + obtain ⟨s, hs, hv⟩ := CommonIdeal.run_finite_extension h₀ n (CommonIdeal.bit (Z n)) (by + rw [he₀]; exact Part.mem_some _) + obtain ⟨q, hpq, hq⟩ := arbitrary_left_extension A p s hs + exact False.elim (hn q hpq _ (hq ▸ hv)) + · obtain ⟨n, hn⟩ := hr + obtain ⟨s, hs, hv⟩ := CommonIdeal.run_finite_extension h₁ n (CommonIdeal.bit (Z n)) (by + rw [he₁]; exact Part.mem_some _) + obtain ⟨q, hpq, hq⟩ := arbitrary_right_extension A p s hs + exact False.elim (hn q hpq _ (hq ▸ hv)) + · exact Or.inl (case1_reduces hu h₀ he₀) + · exact Or.inr ha + +def GoodForCode (A : ℕ → Oracle) (B : Oracle) (c e₀ e₁ : OracleCode) (p : Condition) : Prop := + ∀ Y : Oracle, OracleCode.eval (oracleFunction B) c = oracleFunction Y → Good A Y e₀ e₁ p + +theorem goodForCode_dense (A : ℕ → Oracle) + (hIntro : ∀ k Z, (∀ a, Z a = true → A k a = true) → + {a | Z a = true}.Infinite → Reduces (A k) Z) + (B : Oracle) (c e₀ e₁ : OracleCode) (p : Condition) : + ∃ q, Extends A p q ∧ GoodForCode A B c e₀ e₁ q := by + by_cases h : ∃ Y : Oracle, OracleCode.eval (oracleFunction B) c = oracleFunction Y + · obtain ⟨Y, hY⟩ := h + obtain ⟨q, hpq, hg⟩ := good_dense A hIntro Y e₀ e₁ p + refine ⟨q, hpq, ?_⟩ + intro Z hZ + have he : Y = Z := oracleFunction_injective (hY.symm.trans hZ) + exact he ▸ hg + · exact ⟨p, extends_refl A p, fun Y hY => False.elim (h ⟨Y, hY⟩)⟩ + +end TuringRigidity.CodingRequirements + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/CodingSplitSearch.lean b/lean/OAI/Computability/DegreeRigidity/Effective/CodingSplitSearch.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c4dfd8b6c3e262a0ffbf048f7241708c3aafdd5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/CodingSplitSearch.lean @@ -0,0 +1,130 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingLocations + +namespace OAI + +namespace TuringRigidity.CodingSplitSearch +open Encodable PrefixComputability CodingLocations + +abbrev Witness := (List Bool × (ℕ × Bool)) × (ℕ × (ℕ × ℕ)) + +def finiteTrial (d : Nat.Partrec.Code) (base : List Bool) (L : List ℕ) (w : Witness) : Option ℕ := + let a := d.evaln w.2.2.1 (Nat.pair (encode L) (Nat.pair (encode w.1.1) w.2.1)) + let b := d.evaln w.2.2.2 (Nat.pair (encode L) (Nat.pair (encode (w.1.1.set w.1.2.1 w.1.2.2)) w.2.1)) + if w.1.2.1 < w.1.1.length ∧ a ≠ none ∧ b ≠ none ∧ a.getD 0 ≠ b.getD 0 + then some (base.length + w.1.2.1) else none + +theorem finiteTrial_primrec (d : Nat.Partrec.Code) (base : List Bool) : Primrec₂ (finiteTrial d base) := by + let hL : Primrec (fun z : List ℕ × Witness => z.1) := Primrec.fst + let hu : Primrec (fun z : List ℕ × Witness => z.2.1.1) := Primrec.fst.comp (Primrec.fst.comp Primrec.snd) + let hi : Primrec (fun z : List ℕ × Witness => z.2.1.2.1) := Primrec.fst.comp (Primrec.snd.comp (Primrec.fst.comp Primrec.snd)) + let hb : Primrec (fun z : List ℕ × Witness => z.2.1.2.2) := Primrec.snd.comp (Primrec.snd.comp (Primrec.fst.comp Primrec.snd)) + let hn : Primrec (fun z : List ℕ × Witness => z.2.2.1) := Primrec.fst.comp (Primrec.snd.comp Primrec.snd) + let ht₀ : Primrec (fun z : List ℕ × Witness => z.2.2.2.1) := Primrec.fst.comp (Primrec.snd.comp (Primrec.snd.comp Primrec.snd)) + let ht₁ : Primrec (fun z : List ℕ × Witness => z.2.2.2.2) := Primrec.snd.comp (Primrec.snd.comp (Primrec.snd.comp Primrec.snd)) + let hu' := Primrec.list_set.comp hu (hi.pair hb) + let ha₀ := Nat.Partrec.Code.primrec_evaln.comp + ((ht₀.pair (Primrec.const d)).pair + (Primrec₂.natPair.comp (Primrec.encode.comp hL) (Primrec₂.natPair.comp (Primrec.encode.comp hu) hn))) + let ha₁ := Nat.Partrec.Code.primrec_evaln.comp + ((ht₁.pair (Primrec.const d)).pair + (Primrec₂.natPair.comp (Primrec.encode.comp hL) (Primrec₂.natPair.comp (Primrec.encode.comp hu') hn))) + exact Primrec.ite ((Primrec.nat_lt.comp hi (Primrec.list_length.comp hu)).and + (((Primrec.eq.comp ha₀ (Primrec.const none)).not).and + (((Primrec.eq.comp ha₁ (Primrec.const none)).not).and + (Primrec.eq.comp (Primrec.option_getD_default.comp ha₀) + (Primrec.option_getD_default.comp ha₁)).not))) + (Primrec.option_some.comp (Primrec.nat_add.comp (Primrec.const base.length) hi)) + (Primrec.const none) + +def trial (Y : Oracle) (d : Nat.Partrec.Code) (base : List Bool) (z : ℕ) : Option ℕ := + finiteTrial d base (oraclePrefix (fun n => CommonIdeal.bit (Y n)) (Nat.unpair z).1) + ((decode (α := Witness) (Nat.unpair z).2).getD default) + +theorem trial_recursive (Y : Oracle) (d : Nat.Partrec.Code) (base : List Bool) : + Nat.RecursiveIn {oracleFunction Y} (fun z => Part.some (encode (trial Y d base z))) := by + have hpre := total_comp (prefix_recursive (fun n => CommonIdeal.bit (Y n))) + (total_primrec (Primrec.fst.comp Primrec.unpair)) + have hw := total_primrec (O := {oracleFunction Y}) (Primrec.snd.comp Primrec.unpair) + have hrun := total_primrec (O := {oracleFunction Y}) (Primrec.encode.comp + ((finiteTrial_primrec d base).comp + (Primrec.option_getD_default.comp (Primrec.decode.comp (Primrec.fst.comp Primrec.unpair))) + (Primrec.option_getD_default.comp (Primrec.decode.comp (Primrec.snd.comp Primrec.unpair))))) + exact (total_comp hrun (total_pair hpre hw)).of_eq (fun z => by simp [trial]) + +theorem trial_sound (Y : Oracle) (e : OracleCode) (base : List Bool) + (d : Nat.Partrec.Code) + (hd : ∀ L w, d.eval (Nat.pair (encode L) w) = CommonIdeal.finiteRun e base L w) + (z m : ℕ) (h : m ∈ trial Y d base z) : SplittingLocation Y e base m := by + let L := oraclePrefix (fun n => CommonIdeal.bit (Y n)) (Nat.unpair z).1 + let w := ((decode (α := Witness) (Nat.unpair z).2).getD default) + change m ∈ finiteTrial d base L w at h + dsimp only [finiteTrial] at h + split at h + next hg => + have hm : m = base.length + w.1.2.1 := (Option.mem_some_iff.mp h).symm + let a := d.evaln w.2.2.1 (Nat.pair (encode L) (Nat.pair (encode w.1.1) w.2.1)) + let b := d.evaln w.2.2.2 (Nat.pair (encode L) (Nat.pair (encode (w.1.1.set w.1.2.1 w.1.2.2)) w.2.1)) + have ha : a.getD 0 ∈ a := by + cases ha' : a with + | none => exact False.elim (hg.2.1 ha') + | some v => simp + have hb : b.getD 0 ∈ b := by + cases hb' : b with + | none => exact False.elim (hg.2.2.1 hb') + | some v => simp + have hva := Nat.Partrec.Code.evaln_sound ha + have hvb := Nat.Partrec.Code.evaln_sound hb + rw [hd] at hva hvb + have hA := (CommonIdeal.finiteRun_approximates Y e base (encode w.1.1) w.2.1).1 + (Nat.unpair z).1 (a.getD 0) hva + have hB := (CommonIdeal.finiteRun_approximates Y e base + (encode (w.1.1.set w.1.2.1 w.1.2.2)) w.2.1).1 (Nat.unpair z).1 (b.getD 0) hvb + rw [hm] + refine ⟨base ++ w.1.1, w.1.2.2, w.2.1, a.getD 0, b.getD 0, + List.prefix_append _ _, by omega, by simp; omega, hg.2.2.2, ?_, ?_⟩ + · simpa [BorelGeneric.word] using hA + · simpa [BorelGeneric.word, List.set_append_right] using hB + next hg => simp at h + +theorem trial_complete (Y : Oracle) (e : OracleCode) (base : List Bool) + (d : Nat.Partrec.Code) + (hd : ∀ L w, d.eval (Nat.pair (encode L) w) = CommonIdeal.finiteRun e base L w) + {m : ℕ} (hm : SplittingLocation Y e base m) : ∃ z, m ∈ trial Y d base z := by + obtain ⟨s, b, n, a, c, ⟨u, rfl⟩, hbase, hms, hac, ha, hc⟩ := hm + let i := m - base.length + have hmi : m = base.length + i := by omega + have hi : i < u.length := by simp only [List.length_append] at hms; omega + have hc' : c ∈ CommonIdeal.run Y e (base ++ u.set i b) n := by + simpa [List.set_append_right _ _ hbase] using hc + have hau : a ∈ CommonIdeal.run Y e (base ++ BorelGeneric.word (encode u)) n := by + simpa [BorelGeneric.word] using ha + have hcu : c ∈ CommonIdeal.run Y e (base ++ BorelGeneric.word (encode (u.set i b))) n := by + simpa [BorelGeneric.word] using hc' + obtain ⟨M₀, hM₀⟩ := (CommonIdeal.finiteRun_approximates Y e base (encode u) n).2 a hau + obtain ⟨M₁, hM₁⟩ := (CommonIdeal.finiteRun_approximates Y e base (encode (u.set i b)) n).2 c hcu + let M := max M₀ M₁ + have hfa := hM₀ M (Nat.le_max_left _ _) + have hfc := hM₁ M (Nat.le_max_right _ _) + dsimp only at hfa hfc + rw [← hd] at hfa hfc + obtain ⟨t₀, ht₀⟩ := Nat.Partrec.Code.evaln_complete.mp hfa + obtain ⟨t₁, ht₁⟩ := Nat.Partrec.Code.evaln_complete.mp hfc + let w : Witness := ((u, i, b), (n, t₀, t₁)) + refine ⟨Nat.pair M (encode w), ?_⟩ + have ht₀' := Option.mem_def.mp ht₀ + have ht₁' := Option.mem_def.mp ht₁ + simp only [UniformOracle.oraclePrefix] at ht₀' ht₁' + simp [trial, finiteTrial, oraclePrefix, w, ht₀', ht₁', hi, hac, hmi] + +theorem splittingLocations_enumerable (Y : Oracle) (e : OracleCode) (base : List Bool) : + ∃ E : ℕ → Option ℕ, + Nat.RecursiveIn {oracleFunction Y} (fun z => Part.some (encode (E z))) ∧ + ∀ m, SplittingLocation Y e base m ↔ ∃ z, m ∈ E z := by + obtain ⟨d, hd⟩ := CommonIdeal.finiteRun_code e base + refine ⟨trial Y d base, trial_recursive Y d base, ?_⟩ + intro m + exact ⟨trial_complete Y e base d hd, fun ⟨z, hz⟩ => trial_sound Y e base d hd z m hz⟩ + +end TuringRigidity.CodingSplitSearch + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/CodingSplitting.lean b/lean/OAI/Computability/DegreeRigidity/Effective/CodingSplitting.lean new file mode 100644 index 0000000000000000000000000000000000000000..80c7493cdd92a8cf1d804ba09abab3fba33fba49 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/CodingSplitting.lean @@ -0,0 +1,88 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingOnePoint + +namespace OAI + +namespace TuringRigidity.CodingSplitting +open CodingForcing + +def OnePoint (base : List Bool) (f : List Bool → Part ℕ) : Prop := + ∃ s m b v w, base <+: s ∧ base.length ≤ m ∧ m < s.length ∧ v ≠ w ∧ + v ∈ f s ∧ w ∈ f (s.set m b) + +private theorem interpolate (base : List Bool) (f : List Bool → Part ℕ) + (hmono : ∀ {s t}, s <+: t → ∀ v, v ∈ f s → v ∈ f t) + (hdense : ∀ s, base <+: s → ∃ u v, v ∈ f (s ++ u)) + (u : List Bool) : ∀ v : List Bool, u.length = v.length → + ∀ pre tail, base <+: pre → ∀ a b, + a ∈ f (pre ++ u ++ tail) → b ∈ f (pre ++ v ++ tail) → a ≠ b → OnePoint base f := by + induction u with + | nil => + intro v hlen pre tail hpre a b ha hb hab + have hv : v = [] := List.length_eq_zero_iff.mp hlen.symm + subst v + exact False.elim (hab (Part.mem_unique ha hb)) + | cons x u ih => + intro v hlen pre tail hpre a b ha hb hab + cases v with + | nil => simp at hlen + | cons y v => + have hlen' : u.length = v.length := Nat.succ.inj hlen + let mid := pre ++ (x :: v) ++ tail + have hmid : base <+: mid := by + simpa only [mid, List.append_assoc] using hpre.trans (List.prefix_append pre ((x :: v) ++ tail)) + obtain ⟨extra, c, hc⟩ := hdense mid hmid + have ha' : a ∈ f ((pre ++ (x :: u) ++ tail) ++ extra) := + hmono (List.prefix_append _ _) a ha + have hb' : b ∈ f ((pre ++ (y :: v) ++ tail) ++ extra) := + hmono (List.prefix_append _ _) b hb + by_cases hcb : c = b + · apply ih v hlen' (pre ++ [x]) (tail ++ extra) + (hpre.trans (List.prefix_append _ _)) a c + · simpa only [List.append_assoc, List.cons_append, List.nil_append] using ha' + · simpa only [mid, List.append_assoc, List.cons_append, List.nil_append] using hc + · simpa only [hcb] using hab + · refine ⟨mid ++ extra, pre.length, y, c, b, + hmid.trans (List.prefix_append _ _), hpre.length_le, ?_, hcb, hc, ?_⟩ + · simp [mid] + · have heq : (mid ++ extra).set pre.length y = + (pre ++ (y :: v) ++ tail) ++ extra := by + simp [mid, List.append_assoc, List.set_append_right] + rw [heq] + exact hb' + +theorem onePoint_of_dense {base s t : List Bool} {f : List Bool → Part ℕ} + (hmono : ∀ {s t}, s <+: t → ∀ v, v ∈ f s → v ∈ f t) + (hdense : ∀ s, base <+: s → ∃ u v, v ∈ f (s ++ u)) + (hs : base <+: s) (ht : base <+: t) (a b : ℕ) + (ha : a ∈ f s) (hb : b ∈ f t) (hab : a ≠ b) : OnePoint base f := by + obtain ⟨u, rfl⟩ := hs + obtain ⟨v, rfl⟩ := ht + let L := max u.length v.length + let u' := u ++ List.replicate (L - u.length) false + let v' := v ++ List.replicate (L - v.length) false + have hlu : u'.length = L := by simp only [u', List.length_append, List.length_replicate]; omega + have hlv : v'.length = L := by simp only [v', List.length_append, List.length_replicate]; omega + have ha' : a ∈ f (base ++ u') := by + apply hmono (show base ++ u <+: base ++ u' from ?_) a ha + exact ⟨List.replicate (L-u.length) false, by simp [u', List.append_assoc]⟩ + have hb' : b ∈ f (base ++ v') := by + apply hmono (show base ++ v <+: base ++ v' from ?_) b hb + exact ⟨List.replicate (L-v.length) false, by simp [v', List.append_assoc]⟩ + exact interpolate base f hmono hdense u' v' (hlu.trans hlv.symm) + base [] List.prefix_rfl a b (by simpa using ha') (by simpa using hb') hab + +theorem split_or_divergent_word {Y : Oracle} {e : OracleCode} {base s t : List Bool} + (hs : base <+: s) (ht : base <+: t) (n a b : ℕ) + (ha : a ∈ CommonIdeal.run Y e s n) (hb : b ∈ CommonIdeal.run Y e t n) (hab : a ≠ b) : + OnePoint base (fun w => CommonIdeal.run Y e w n) ∨ + ∃ w, base <+: w ∧ ∀ u v, v ∉ CommonIdeal.run Y e (w ++ u) n := by + by_cases hd : ∀ w, base <+: w → ∃ u v, v ∈ CommonIdeal.run Y e (w ++ u) n + · exact Or.inl (onePoint_of_dense (fun h v hv => CommonIdeal.run_mono h n v hv) + hd hs ht a b ha hb hab) + · right + push Not at hd + exact hd + +end TuringRigidity.CodingSplitting + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveCohen.lean b/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveCohen.lean new file mode 100644 index 0000000000000000000000000000000000000000..281b9917b902008778db6bb9737731383b71d9d1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveCohen.lean @@ -0,0 +1,142 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.EncodedForcing +import OAI.Computability.DegreeRigidity.Effective.EffectiveWitness + +namespace OAI + +namespace TuringRigidity.EffectiveCohen +open Encodable UniformOracle ArithmeticHierarchy OracleJump EffectiveWitness EncodedForcing + +theorem word_decision (Y : Oracle) : + ∃ step : ℕ → ℕ, Nat.RecursiveIn {oracleFunction (jump Y)} (fun x => Part.some (step x)) ∧ + ∀ e p, word p <+: word (step (Nat.pair e p)) ∧ + (Halts Y e (encode (word (step (Nat.pair e p)))) ∨ + ∀ q : List Bool, word (step (Nat.pair e p)) <+: q → ¬ Halts Y e (encode q)) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let P : ℕ → Prop := fun v => + word (Nat.unpair (Nat.unpair v).1).2 <+: word (Nat.unpair v).2 ∧ + Halts Y (Nat.unpair (Nat.unpair v).1).1 (encode (word (Nat.unpair v).2)) + have hp := EncodedForcing.prefix_recursive Y (word_primrec.comp (r.comp f)) (word_primrec.comp r) + have hh := (halts_sigma Y).comp (Primrec₂.natPair.comp (f.comp f) + (Primrec.encode.comp (word_primrec.comp r))) + have hP : Sigma Y 1 P := by + simpa only [P,Nat.unpair_pair] using (Form.raise (n := 0) (s := true) hp).and hh + obtain ⟨g,hg,hs⟩ := sigma1_choice hP + let a : ℕ → ℕ := fun v => if (Nat.unpair v).2 = 0 then (Nat.unpair v).1 else (Nat.unpair v).2-1 + have ha : Primrec a := Primrec.ite + (Primrec.eq.comp r (Primrec.const 0)) f (Primrec.nat_sub.comp r (Primrec.const 1)) + let step : ℕ → ℕ := fun x => a (Nat.pair (Nat.unpair x).2 (g x)) + have hstep := total_comp (total_primrec (O := {oracleFunction (jump Y)}) ha) + (total_pair (total_primrec r) hg) + refine ⟨step,hstep,fun e p => ?_⟩ + rcases hs (Nat.pair e p) with ⟨hz,hn⟩ | ⟨hp,hw⟩ + · have he : step (Nat.pair e p) = p := by simp [step,a,hz] + rw [he] + refine ⟨List.prefix_rfl,Or.inr (fun q hq hhalt => ?_)⟩ + exact hn ⟨encode q,by simpa [P,word] using And.intro hq hhalt⟩ + · have hz : g (Nat.pair e p) ≠ 0 := by omega + have he : step (Nat.pair e p) = g (Nat.pair e p)-1 := by simp [step,a,hz] + rw [he] + have hh : word p <+: word (g (Nat.pair e p)-1) ∧ + Halts Y e (encode (word (g (Nat.pair e p)-1))) := by simpa [P] using hw + exact ⟨hh.1,Or.inl hh.2⟩ + +noncomputable def decider (Y : Oracle) : ℕ → ℕ := Classical.choose (word_decision Y) + +theorem decider_recursive (Y : Oracle) : + Nat.RecursiveIn {oracleFunction (jump Y)} (fun x => Part.some (decider Y x)) := + (Classical.choose_spec (word_decision Y)).1 + +theorem decider_spec (Y : Oracle) (e p : ℕ) : + word p <+: word (decider Y (Nat.pair e p)) ∧ + (Halts Y e (encode (word (decider Y (Nat.pair e p)))) ∨ + ∀ q : List Bool, word (decider Y (Nat.pair e p)) <+: q → ¬ Halts Y e (encode q)) := + (Classical.choose_spec (word_decision Y)).2 e p + +def grow (p : ℕ) : ℕ := encode (word p ++ [false]) + +theorem grow_primrec : Primrec grow := Primrec.encode.comp + (Primrec.list_append.comp word_primrec (Primrec.const [false])) + +noncomputable def stage (Y : Oracle) : ℕ → ℕ + | 0 => encode ([] : List Bool) + | s+1 => grow (decider Y (Nat.pair s (stage Y s))) + +theorem stage_recursive (Y : Oracle) : + Nat.RecursiveIn {oracleFunction (jump Y)} (fun s => Part.some (stage Y s)) := by + let r := Primrec.snd.comp Primrec.unpair + have hstep := total_comp (total_primrec grow_primrec) + (total_comp (decider_recursive Y) (total_primrec r)) + have hr := Nat.RecursiveIn.prec (total_primrec (O := {oracleFunction (jump Y)}) (Primrec.const (encode ([] : List Bool)))) hstep + have h := Nat.RecursiveIn.comp hr + (total_pair (total_primrec (Primrec.const 0)) (total_primrec Primrec.id)) + apply h.of_eq + intro n + change (Part.some (Nat.pair 0 n)).bind _ = _ + rw [Part.bind_some] + simp only [Nat.unpair_pair] + induction n with + | zero => rfl + | succ n ih => + simp only [ih] + change (Part.some (stage Y n)).bind _ = _ + rw [Part.bind_some] + rfl + +theorem stage_prefix (Y : Oracle) (s : ℕ) : word (stage Y s) <+: word (stage Y (s+1)) := by + have h := (decider_spec Y s (stage Y s)).1 + simpa only [stage,grow,word,encodek,Option.getD_some] using + h.trans (List.prefix_append _ [false]) + +theorem stage_length (Y : Oracle) (s : ℕ) : s ≤ (word (stage Y s)).length := by + induction s with + | zero => exact Nat.zero_le _ + | succ s ih => + have hh := (decider_spec Y s (stage Y s)).1.length_le + simp only [stage,grow,word,encodek,Option.getD_some,List.length_append,List.length_cons,List.length_nil] + simp only [word] at hh ih + omega + +theorem stage_prefix_of_le (Y : Oracle) {s t : ℕ} (h : s ≤ t) : word (stage Y s) <+: word (stage Y t) := by + induction t,h using Nat.le_induction with + | base => exact List.prefix_rfl + | succ t ht ih => exact ih.trans (stage_prefix Y t) + +noncomputable def generic (Y : Oracle) : Oracle := fun n => (word (stage Y (n+1))).getD n false + +theorem generic_extends (Y : Oracle) (s : ℕ) : + ∀ n < (word (stage Y s)).length, generic Y n = (word (stage Y s)).getD n false := by + intro n hn + let t := max s (n+1) + have h0 := stage_prefix_of_le Y (show s ≤ t from le_max_left _ _) + have h1 := stage_prefix_of_le Y (show n+1 ≤ t from le_max_right _ _) + have hn1 : n < (word (stage Y (n+1))).length := (Nat.lt_succ_self n).trans_le (stage_length Y _) + exact (CodingForcing.getD_of_prefix h1 hn1).symm.trans (CodingForcing.getD_of_prefix h0 hn) + +theorem generic_reduces (Y : Oracle) : Reduces (generic Y) (jump Y) := by + have hs := total_comp (stage_recursive Y) (total_primrec Primrec.succ) + have hv := total_comp (total_primrec (CommonIdeal.bit_primrec.comp + ((Primrec.list_getD false).comp (word_primrec.comp (Primrec.fst.comp Primrec.unpair)) + (Primrec.snd.comp Primrec.unpair)))) (total_pair hs (total_primrec Primrec.id)) + apply RecursiveIn.iff_nat.mpr + exact hv.of_eq (fun n => by simp [oracleFunction,generic,CommonIdeal.bit]) + +def OneGeneric (Y G : Oracle) : Prop := ∀ e, ∃ p : List Bool, + (∀ n < p.length, G n = p.getD n false) ∧ + (Halts Y e (encode p) ∨ ∀ q : List Bool, p <+: q → ¬ Halts Y e (encode q)) + +theorem generic_oneGeneric (Y : Oracle) : OneGeneric Y (generic Y) := by + intro e + let w := word (decider Y (Nat.pair e (stage Y e))) + refine ⟨w,?_,(decider_spec Y e (stage Y e)).2⟩ + intro n hn + have hw : w <+: word (stage Y (e+1)) := by + simpa only [w,stage,grow,word,encodek,Option.getD_some] using List.prefix_append w [false] + exact (generic_extends Y (e+1) n (hn.trans_le hw.length_le)).trans (CodingForcing.getD_of_prefix hw hn) + +theorem relative_generic (Y : Oracle) : ∃ G : Oracle, Reduces G (jump Y) ∧ OneGeneric Y G := + ⟨generic Y,generic_reduces Y,generic_oneGeneric Y⟩ + +end TuringRigidity.EffectiveCohen + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveFamilies.lean b/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveFamilies.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8997d1ce524258c679804abf5c859fb7e3a3869 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveFamilies.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DegreeRigidity.Effective.GuardedCoding +import OAI.Computability.DegreeRigidity.CohenForcing.CohenColumns +import OAI.Computability.DegreeRigidity.Syntax.BoundedDecoding + +namespace OAI + +namespace TuringRigidity.EffectiveFamilies +open Encodable EncodedForcing UniformOracle SetCoding BoundedDecoding + +theorem reindex_reduces (A : Oracle) {f : ℕ → ℕ} (hf : Primrec f) : + Reduces (fun n => A (f n)) A := by + apply RecursiveIn.iff_nat.mpr + have hq : Nat.RecursiveIn {oracleFunction A} (oracleFunction A) := .oracle _ (Set.mem_singleton _) + exact total_comp hq (total_primrec hf) + +def slice (A : Oracle) (i : ℕ) : Oracle := fun m => + A (Nat.pair (Nat.pair i (Nat.unpair m).1) (Nat.unpair m).2) + +@[simp] theorem slice_column (A : Oracle) (i j : ℕ) : + columns (slice A i) j = columns A (Nat.pair i j) := by + funext n + simp [slice,columns] + +theorem slice_reduces (A : Oracle) (i : ℕ) : Reduces (slice A i) A := + reindex_reduces A (Primrec₂.natPair.comp + (Primrec₂.natPair.comp (Primrec.const i) (Primrec.fst.comp Primrec.unpair)) + (Primrec.snd.comp Primrec.unpair)) + +def mix (A B : Oracle) : Oracle := fun m => + join (columns A (Nat.unpair m).1) (columns B (Nat.unpair m).1) (Nat.unpair m).2 + +@[simp] theorem mix_column (A B : Oracle) (j : ℕ) : + columns (mix A B) j = join (columns A j) (columns B j) := by + funext n + simp [mix,columns] + +theorem mix_reduces (A B : Oracle) : Reduces (mix A B) (join A B) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let q := Primrec₂.natPair.comp f (Primrec.nat_div.comp r (Primrec.const 2)) + have hp := Primrec.cond (Primrec.nat_bodd.comp r) + (Primrec.nat_add.comp (Primrec.nat_mul.comp (Primrec.const 2) q) (Primrec.const 1)) + (Primrec.nat_mul.comp (Primrec.const 2) q) + have hh := reindex_reduces (join A B) hp + convert hh using 1 + funext m + cases hb : (Nat.unpair m).2.bodd <;> simp [mix,join,columns,hb] + congr 1 + omega + +def tuples (G : Oracle) : ℕ → Oracle + | 0 => fun _ => false + | n+1 => mix (tuples G n) (slice G n) + +theorem tuples_reduces (G : Oracle) (n : ℕ) : Reduces (tuples G n) G := by + induction n with + | zero => exact RecursiveIn.iff_nat.mpr .zero + | succ n ih => + exact reduces_trans (mix_reduces _ _) (join_reduces ih (slice_reduces G n)) + +theorem tuples_degree (G : Oracle) (n j : ℕ) : + degree (columns (tuples G n) j) = (Finset.range n).sup (fun i => degree (columns G (Nat.pair i j))) := by + induction n with + | zero => rfl + | succ n ih => + rw [tuples,mix_column] + change degree (columns (tuples G n) j) ⊔ degree (columns (slice G n) j) = _ + rw [ih,slice_column,Finset.range_add_one,Finset.sup_insert] + exact sup_comm _ _ + +theorem antichainCode_below {F H : Oracle} (hF : Reduces F H) + (hAnti : ∀ i j, degree (columns F i) ≤ degree (columns F j) → + degree (columns F i) = degree (columns F j)) : + ∃ p : AntichainCode, AntichainBelow p (degree (OracleJump.jump H)) ∧ + ∀ x, p.Holds x ↔ ∃ k, degree (columns F k) = x := by + obtain ⟨g₀,g₁,hg,hcode⟩ := GuardedCoding.effective_antichain_parameters F hAnti + have hj : OracleJump.degreeJump (degree F) ≤ degree (OracleJump.jump H) := OracleJump.jump_mono hF + have hb : degree F ≤ degree (OracleJump.jump H) := + (show degree F ≤ degree H from hF).trans (OracleJump.degree_le_jump _) + exact ⟨⟨degree F,g₀,g₁⟩,⟨hb,(le_sup_left.trans hg).trans hj, + (le_sup_right.trans hg).trans hj⟩,hcode⟩ + +end TuringRigidity.EffectiveFamilies + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/EffectivePresentation.lean b/lean/OAI/Computability/DegreeRigidity/Effective/EffectivePresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..586a25c9ef15218b5f79954760e3cd89199938f7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/EffectivePresentation.lean @@ -0,0 +1,86 @@ +import OAI.Computability.DegreeRigidity.Effective.EffectiveRelations + +namespace OAI + +namespace TuringRigidity.EffectivePresentation +open EncodedForcing UniformOracle ArithmeticHierarchy EffectiveFamilies EffectiveRelations +open SetCoding RelationCoding BoundedDecoding AntichainParameters +noncomputable section +attribute [local instance] Classical.propDecidable + +def pick (P : ℕ → Prop) (j₀ j : ℕ) : ℕ := if P j then j else j₀ + +theorem pick_recursive {A : Oracle} {P : ℕ → Prop} (hP : RecursivePred A P) (j₀ : ℕ) : + Nat.RecursiveIn {oracleFunction A} (fun j => Part.some (pick P j₀ j)) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hp := Primrec.ite (Primrec.eq.comp r (Primrec.const 1)) f (Primrec.const j₀) + exact (total_comp (total_primrec hp) (total_pair (total_primrec Primrec.id) hP)).of_eq + (fun j => by by_cases h : P j <;> simp [pick,h]) + +def selected (A : Oracle) (P : ℕ → Prop) (j₀ : ℕ) : Oracle := fun v => + A (Nat.pair (Nat.pair (Nat.unpair (Nat.unpair v).1).1 + (pick P j₀ (Nat.unpair (Nat.unpair v).1).2)) (Nat.unpair v).2) + +theorem selected_reduces {A : Oracle} {P : ℕ → Prop} (hP : RecursivePred A P) (j₀ : ℕ) : + Reduces (selected A P j₀) A := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hp := total_comp (pick_recursive hP j₀) (total_primrec (r.comp f)) + have hidx := total_pair (total_pair (total_primrec (f.comp f)) hp) (total_primrec r) + have hq : Nat.RecursiveIn {oracleFunction A} (oracleFunction A) := .oracle _ (Set.mem_singleton _) + exact RecursiveIn.iff_nat.mpr (total_comp hq hidx) + +@[simp] theorem selected_column (A : Oracle) (P : ℕ → Prop) (j₀ i j : ℕ) : + columns (selected A P j₀) (Nat.pair i j) = columns A (Nat.pair i (pick P j₀ j)) := by + funext n + simp [selected,columns] + +def emptyAntichain : AntichainCode := ⟨⊥,⊥,⊥⟩ + +theorem emptyAntichain_holds (x : Degree) : ¬ emptyAntichain.Holds x := by + simp [emptyAntichain,AntichainCode.Holds,CodedAntichain,NontrivialCommonLower] + +def emptyRelation (n : ℕ) : RelationCode n := + ⟨fun _ => ⟨⊥,emptyAntichain,emptyAntichain⟩,emptyAntichain⟩ + +theorem emptyRelation_below (n : ℕ) (y : Degree) : RelationBelow (emptyRelation n) y := by + exact ⟨fun _ => ⟨bot_le,⟨bot_le,bot_le,bot_le⟩,⟨bot_le,bot_le,bot_le⟩⟩,⟨bot_le,bot_le,bot_le⟩⟩ + +theorem emptyRelation_holds (n : ℕ) (v : Fin n → Degree) : ¬ (emptyRelation n).Holds v := by + rintro ⟨c,_,hc⟩ + exact emptyAntichain_holds _ hc + +theorem effective_coding (A : Oracle) (P : ℕ → Prop) (hP : RecursivePred A P) (n : ℕ) : + ∃ p : RelationCode n, RelationBelow p (degree (OracleJump.jump A)) ∧ + ∀ v, p.Holds v ↔ ∃ j, P j ∧ ∀ i : Fin n, degree (columns A (Nat.pair i.val j)) = v i := by + by_cases hne : ∃ j, P j + · obtain ⟨j₀,hj₀⟩ := hne + let F := selected A P j₀ + obtain ⟨p,hp,hcode⟩ := effective_relation_sequence F n + have hbound := OracleJump.jump_mono (selected_reduces hP j₀) + have hp' : RelationBelow p (degree (OracleJump.jump A)) := by + refine ⟨fun i => ?_,?_⟩ + · exact ⟨(hp.1 i).1.trans hbound, + ⟨(hp.1 i).2.1.1.trans hbound,(hp.1 i).2.1.2.1.trans hbound,(hp.1 i).2.1.2.2.trans hbound⟩, + ⟨(hp.1 i).2.2.1.trans hbound,(hp.1 i).2.2.2.1.trans hbound,(hp.1 i).2.2.2.2.trans hbound⟩⟩ + · exact ⟨hp.2.1.trans hbound,hp.2.2.1.trans hbound,hp.2.2.2.trans hbound⟩ + refine ⟨p,hp',fun v => ?_⟩ + rw [hcode] + constructor + · rintro ⟨j,hj⟩ + have hvalid : P (pick P j₀ j) := by by_cases h : P j <;> simp [pick,h,hj₀] + exact ⟨pick P j₀ j,hvalid,fun i => by simpa only [F,selected_column] using hj i⟩ + · rintro ⟨j,hj,hv⟩ + exact ⟨j,fun i => by simpa only [F,selected_column,pick,ite_eq_left hj] using hv i⟩ + · refine ⟨emptyRelation n,emptyRelation_below _ _,fun v => ?_⟩ + constructor + · intro h + exact False.elim (emptyRelation_holds n v h) + · rintro ⟨j,hj,_⟩ + exact False.elim (hne ⟨j,hj⟩) + +end +end TuringRigidity.EffectivePresentation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveRelations.lean b/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveRelations.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2f78a076a029192f9d57db8260cb46d0bbbd6f8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveRelations.lean @@ -0,0 +1,120 @@ +import OAI.Computability.DegreeRigidity.Effective.EffectiveFamilies + +namespace OAI + +namespace TuringRigidity.EffectiveRelations +open EncodedForcing EffectiveFamilies CohenColumns EffectiveCohen SetCoding RelationCoding BoundedDecoding + +private theorem data_below {A B : Oracle} (hA : Reduces A B) (i j : ℕ) : + degree (columns A (Nat.pair i j)) ≤ degree B := + reduces_trans (CodingExtraction.column_projection_reduces A _) hA + +theorem coordinate_code {A B G : Oracle} (hA : Reduces A B) (hg : OneGeneric B G) (i : ℕ) : + ∃ p : SetCode, p.bound = degree B ∧ SetBelow p (degree (OracleJump.jump (join B G))) ∧ + ∀ x c, p.Graph x c ↔ ∃ j, degree (columns A (Nat.pair i j)) = x ∧ + degree (columns G (Nat.pair i j)) = c := by + have htag (x y : Degree) (hx : x ≤ degree B) (hy : y ≤ degree B) (j k : ℕ) : + x ⊔ degree (columns G (Nat.pair i j)) ≤ y ⊔ degree (columns G (Nat.pair i k)) ↔ + x ≤ y ∧ j = k := by + simpa using independence hg x y hx hy (Nat.pair i j) {Nat.pair i k} + have hanti : ∀ j k, degree (columns (slice G i) j) ≤ degree (columns (slice G i) k) → + degree (columns (slice G i) j) = degree (columns (slice G i) k) := by + intro j k hjk + have he := (htag ⊥ ⊥ bot_le bot_le j k).mp (by simpa using hjk) + rw [he.2] + have had : ∀ j k, degree (columns (mix (slice A i) (slice G i)) j) ≤ + degree (columns (mix (slice A i) (slice G i)) k) → + degree (columns (mix (slice A i) (slice G i)) j) = degree (columns (mix (slice A i) (slice G i)) k) := by + intro j k hjk + have he := (htag _ _ (data_below hA i j) (data_below hA i k) j k).mp (by + simp only [mix_column,slice_column] at hjk + exact hjk) + rw [he.2] + have htagBound : Reduces (slice G i) (join B G) := + reduces_trans (slice_reduces G i) (reduces_join_right B G) + have hdecBound : Reduces (mix (slice A i) (slice G i)) (join B G) := + reduces_trans (mix_reduces _ _) (join_reduces + (reduces_trans (slice_reduces A i) (reduces_trans hA (reduces_join_left B G))) htagBound) + obtain ⟨pc,hpcBound,hpc⟩ := antichainCode_below htagBound hanti + obtain ⟨pa,hpaBound,hpa⟩ := antichainCode_below hdecBound had + refine ⟨⟨degree B,pc,pa⟩,rfl,?_,fun x c => ?_⟩ + · exact ⟨(le_sup_left : degree B ≤ degree B ⊔ degree G).trans (OracleJump.degree_le_jump _),hpcBound,hpaBound⟩ + · change (x ≤ degree B ∧ pc.Holds c ∧ pa.Holds (x ⊔ c)) ↔ _ + rw [hpc,hpa] + simp only [slice_column,mix_column] + constructor + · rintro ⟨hx,⟨j,rfl⟩,⟨k,hk⟩⟩ + have hl := (htag _ x (data_below hA i k) hx k j).mp hk.le + have hr := (htag x _ hx (data_below hA i k) j k).mp hk.ge + have he := hl.2 + subst k + exact ⟨j,le_antisymm hl.1 hr.1,rfl⟩ + · rintro ⟨j,rfl,rfl⟩ + exact ⟨data_below hA i j,⟨j,rfl⟩,⟨j,rfl⟩⟩ + +private theorem fin_sup (n : ℕ) (f : ℕ → Degree) : + Finset.univ.sup (fun i : Fin n => f i.val) = (Finset.range n).sup f := by + classical + have he : (Finset.univ : Finset (Fin n)).image Fin.val = Finset.range n := by + ext m + simp only [Finset.mem_image,Finset.mem_univ,true_and,Finset.mem_range] + exact ⟨fun ⟨a,ha⟩ => ha ▸ a.isLt,fun hm => ⟨⟨m,hm⟩,rfl⟩⟩ + simpa only [Finset.sup_image,Function.comp_def] using congrArg (fun F : Finset ℕ => F.sup f) he + +theorem tag_below_tuple {B G : Oracle} (hg : OneGeneric B G) {n i j k : ℕ} + (h : degree (columns G (Nat.pair i j)) ≤ degree (columns (tuples G n) k)) : j = k := by + classical + let F := (Finset.range n).image (fun l => Nat.pair l k) + have hh : degree (columns G (Nat.pair i j)) ≤ F.sup (fun l => degree (columns G l)) := by + simpa only [tuples_degree,F,Finset.sup_image,Function.comp_def] using h + have hm := (independence hg ⊥ ⊥ bot_le bot_le (Nat.pair i j) F).mp (by simpa using hh) + obtain ⟨l,_,hl⟩ := Finset.mem_image.mp hm.2 + simpa only [Nat.unpair_pair] using (congrArg (fun m => (Nat.unpair m).2) hl).symm + +theorem tuples_antichain {B G : Oracle} (hg : OneGeneric B G) (n : ℕ) : + ∀ j k, degree (columns (tuples G n) j) ≤ degree (columns (tuples G n) k) → + degree (columns (tuples G n) j) = degree (columns (tuples G n) k) := by + intro j k hjk + cases n with + | zero => rfl + | succ n => + have htag : degree (columns G (Nat.pair 0 j)) ≤ degree (columns (tuples G (n+1)) j) := by + rw [tuples_degree] + exact Finset.le_sup (f := fun i => degree (columns G (Nat.pair i j))) (by simp) + have he := tag_below_tuple hg (htag.trans hjk) + rw [he] + +theorem relation_code {A B G : Oracle} (hA : Reduces A B) (hg : OneGeneric B G) (n : ℕ) : + ∃ p : RelationCode n, RelationBelow p (degree (OracleJump.jump (join B G))) ∧ + ∀ v, p.Holds v ↔ ∃ j, ∀ i : Fin n, degree (columns A (Nat.pair i.val j)) = v i := by + classical + choose pc hbound hpBound hp using fun i : Fin n => coordinate_code hA hg i.val + obtain ⟨pt,htBound,ht⟩ := antichainCode_below + (reduces_trans (tuples_reduces G n) (reduces_join_right B G)) (tuples_antichain hg n) + refine ⟨⟨pc,pt⟩,⟨hpBound,htBound⟩,fun v => ?_⟩ + constructor + · rintro ⟨c,hc,hT⟩ + obtain ⟨j,hj⟩ := (ht _).mp hT + refine ⟨j,fun i => ?_⟩ + obtain ⟨k,hkv,hkc⟩ := (hp i _ _).mp (hc i) + have hle : degree (columns G (Nat.pair i.val k)) ≤ degree (columns (tuples G n) j) := by + rw [hkc,hj] + exact Finset.le_sup (f := c) (Finset.mem_univ i) + have he := tag_below_tuple hg hle + simpa only [he] using hkv + · rintro ⟨j,hj⟩ + let c := fun i : Fin n => degree (columns G (Nat.pair i.val j)) + refine ⟨c,fun i => (hp i _ _).mpr ⟨j,hj i,rfl⟩,(ht _).mpr ⟨j,?_⟩⟩ + rw [tuples_degree] + exact (fin_sup n (fun i => degree (columns G (Nat.pair i j)))).symm + +theorem effective_relation_sequence (A : Oracle) (n : ℕ) : + ∃ p : RelationCode n, RelationBelow p (degree (OracleJump.jump A)) ∧ + ∀ v, p.Holds v ↔ ∃ j, ∀ i : Fin n, degree (columns A (Nat.pair i.val j)) = v i := by + obtain ⟨G,hG,hgen,hlow⟩ := CohenLowness.relative_low_generic A + obtain ⟨p,hp,hcode⟩ := relation_code (reduces_refl A) hgen n + exact ⟨p,hlow ▸ hp,hcode⟩ + +end TuringRigidity.EffectiveRelations + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveSplit.lean b/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveSplit.lean new file mode 100644 index 0000000000000000000000000000000000000000..eab1d30db8411792fa045f0de28c85a211e00245 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveSplit.lean @@ -0,0 +1,139 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.CohenRun +import OAI.Computability.DegreeRigidity.Effective.CodingSplitting + +namespace OAI + +namespace TuringRigidity.EffectiveSplit +open Encodable UniformOracle CommonIdeal ArithmeticHierarchy OracleJump EncodedForcing +open CohenRun EffectiveWitness CodingSplitting + +def SplitCert (Y : Oracle) (e : OracleCode) (v : ℕ) : Prop := + let p := word (Nat.unpair v).1 + let w := (Nat.unpair v).2 + p <+: word (item w 1) ∧ p <+: word (item w 2) ∧ item w 3 ≠ item w 4 ∧ + item w 3 ∈ CommonIdeal.run Y e (word (item w 1)) (item w 0) ∧ + item w 4 ∈ CommonIdeal.run Y e (word (item w 2)) (item w 0) + +theorem splitCert_sigma (Y : Oracle) (e : OracleCode) : Sigma Y 1 (SplitCert Y e) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let a (i : ℕ) := item_primrec.comp r (Primrec.const i) + have hp := EncodedForcing.prefix_recursive Y (word_primrec.comp f) (word_primrec.comp (a 1)) + have hq := EncodedForcing.prefix_recursive Y (word_primrec.comp f) (word_primrec.comp (a 2)) + have hn := recursive_primrecPred Y ((Primrec.eq.comp (a 3) (a 4)).not) + have hl := (run_mem_sigma Y e).comp + (Primrec₂.natPair.comp (a 1) (Primrec₂.natPair.comp (a 0) (a 3))) + have hr := (run_mem_sigma Y e).comp + (Primrec₂.natPair.comp (a 2) (Primrec₂.natPair.comp (a 0) (a 4))) + unfold SplitCert + simpa only [Nat.unpair_pair] using (Form.raise (n := 0) (s := true) hp).and + ((Form.raise (n := 0) (s := true) hq).and ((Form.raise (n := 0) (s := true) hn).and (hl.and hr))) + +def PointCert (Y : Oracle) (e : OracleCode) (v : ℕ) : Prop := + let p := word (Nat.unpair v).1 + let w := (Nat.unpair v).2 + let q := word (item w 1) + p <+: q ∧ p.length ≤ item w 2 ∧ item w 2 < q.length ∧ item w 4 ≠ item w 5 ∧ + item w 4 ∈ CommonIdeal.run Y e q (item w 0) ∧ + item w 5 ∈ CommonIdeal.run Y e (q.set (item w 2) (item w 3).bodd) (item w 0) + +theorem pointCert_sigma (Y : Oracle) (e : OracleCode) : Sigma Y 1 (PointCert Y e) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let a (i : ℕ) := item_primrec.comp r (Primrec.const i) + let p := word_primrec.comp f + let q := word_primrec.comp (a 1) + have hp := EncodedForcing.prefix_recursive Y p q + have hlo := recursive_primrecPred Y (Primrec.nat_le.comp (Primrec.list_length.comp p) (a 2)) + have hhi := recursive_primrecPred Y (Primrec.nat_lt.comp (a 2) (Primrec.list_length.comp q)) + have hn := recursive_primrecPred Y ((Primrec.eq.comp (a 4) (a 5)).not) + have hl := (run_mem_sigma Y e).comp + (Primrec₂.natPair.comp (a 1) (Primrec₂.natPair.comp (a 0) (a 4))) + have hr := (run_mem_sigma Y e).comp + (Primrec₂.natPair.comp (Primrec.encode.comp + (Primrec.list_set.comp q ((a 2).pair (Primrec.nat_bodd.comp (a 3))))) + (Primrec₂.natPair.comp (a 0) (a 5))) + unfold PointCert + simpa only [Nat.unpair_pair,word,encodek,Option.getD_some] using + (Form.raise (n := 0) (s := true) hp).and ((Form.raise (n := 0) (s := true) hlo).and + ((Form.raise (n := 0) (s := true) hhi).and ((Form.raise (n := 0) (s := true) hn).and (hl.and hr)))) + +def ConvergesAbove (Y : Oracle) (e : OracleCode) (v : ℕ) : Prop := + ∃ q, word (item v 1) <+: word q ∧ (CommonIdeal.run Y e (word q) (item v 0)).Dom + +theorem convergesAbove_sigma (Y : Oracle) (e : OracleCode) : Sigma Y 1 (ConvergesAbove Y e) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hp := EncodedForcing.prefix_recursive Y (word_primrec.comp (item_primrec.comp f (Primrec.const 1))) (word_primrec.comp r) + have hh := (run_dom_sigma Y e).comp + (Primrec₂.natPair.comp r (item_primrec.comp f (Primrec.const 0))) + unfold ConvergesAbove + simpa only [Nat.unpair_pair] using ((Form.raise (n := 0) (s := true) hp).and hh).ex + +def DivCert (Y : Oracle) (e : OracleCode) (v : ℕ) : Prop := + word (Nat.unpair v).1 <+: word (item (Nat.unpair v).2 1) ∧ + ¬ ConvergesAbove Y e (Nat.unpair v).2 + +theorem divCert_recursive (Y : Oracle) (e : OracleCode) : RecursivePred (jump Y) (DivCert Y e) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hp := EncodedForcing.prefix_recursive (jump Y) (word_primrec.comp f) + (word_primrec.comp (item_primrec.comp r (Primrec.const 1))) + exact recursive_and hp (recursive_comp (recursive_not (form_recursive (convergesAbove_sigma Y e))) r) + +def Accept (Y : Oracle) (e : OracleCode) (v : ℕ) : Prop := + let p := (Nat.unpair v).1 + let tag := (Nat.unpair (Nat.unpair v).2).1 + let w := (Nat.unpair (Nat.unpair v).2).2 + (tag = 0 ∧ ¬ ∃ z, SplitCert Y e (Nat.pair p z)) ∨ + (tag = 1 ∧ PointCert Y e (Nat.pair p w)) ∨ + (tag = 2 ∧ DivCert Y e (Nat.pair p w)) + +theorem accept_recursive (Y : Oracle) (e : OracleCode) : RecursivePred (jump Y) (Accept Y e) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have ht (i : ℕ) := recursive_primrecPred (jump Y) (Primrec.eq.comp (f.comp r) (Primrec.const i)) + have hn := recursive_comp (recursive_not (form_recursive (splitCert_sigma Y e).ex)) f + have hp := recursive_comp (form_recursive (pointCert_sigma Y e)) (Primrec₂.natPair.comp f (r.comp r)) + have hd := recursive_comp (divCert_recursive Y e) (Primrec₂.natPair.comp f (r.comp r)) + unfold Accept + apply Form.congr (n := 0) (s := true) (Form.or (n := 0) (s := true) (recursive_and (ht 0) hn) + (Form.or (n := 0) (s := true) (recursive_and (ht 1) hp) (recursive_and (ht 2) hd))) + intro v + rfl + +theorem accept_total (Y : Oracle) (e : OracleCode) : ∀ p, ∃ w, Accept Y e (Nat.pair p w) := by + intro p + by_cases hs : ∃ z, SplitCert Y e (Nat.pair p z) + · obtain ⟨z,hp,hq,hab,ha,hb⟩ := hs + simp only [Nat.unpair_pair] at hp hq hab ha hb + rcases split_or_divergent_word hp hq (item z 0) (item z 3) (item z 4) ha hb hab with hs | hd + · obtain ⟨q,m,b,a,c,hpq,hlo,hhi,hac,ha,hc⟩ := hs + refine ⟨Nat.pair 1 (encode [item z 0,encode q,m,bit b,a,c]),Or.inr (Or.inl ⟨by simp,?_⟩)⟩ + have hbit : (bit b).bodd = b := by cases b <;> rfl + simpa [PointCert,item,word,hbit] using + And.intro hpq (And.intro hlo (And.intro hhi (And.intro hac (And.intro ha hc)))) + · obtain ⟨q,hpq,hd⟩ := hd + refine ⟨Nat.pair 2 (encode [item z 0,encode q]),Or.inr (Or.inr ⟨by simp,?_,?_⟩)⟩ + · simpa [item,word] using hpq + · simp only [Nat.unpair_pair,item] + rintro ⟨r,hr,hh⟩ + simp only [item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ,word] at hr hh + obtain ⟨u,hu⟩ := hr + obtain ⟨a,ha⟩ := Part.dom_iff_mem.mp hh + exact hd u a (hu ▸ ha) + · exact ⟨Nat.pair 0 0,Or.inl ⟨by simp,by simpa using hs⟩⟩ + +noncomputable def step (Y : Oracle) (e : OracleCode) : ℕ → ℕ := + least (Accept Y e) (accept_total Y e) + +theorem step_recursive (Y : Oracle) (e : OracleCode) : + Nat.RecursiveIn {oracleFunction (jump Y)} (fun p => Part.some (step Y e p)) := + least_recursive (accept_recursive Y e) (accept_total Y e) + +theorem step_spec (Y : Oracle) (e : OracleCode) (p : ℕ) : Accept Y e (Nat.pair p (step Y e p)) := + least_spec (Accept Y e) (accept_total Y e) p + +end TuringRigidity.EffectiveSplit + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveSplitConditions.lean b/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveSplitConditions.lean new file mode 100644 index 0000000000000000000000000000000000000000..84d82f8eb245d26e5dad578b60c0a65babb839e2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveSplitConditions.lean @@ -0,0 +1,99 @@ +import OAI.Computability.DegreeRigidity.Effective.EffectiveSplit +import OAI.Computability.DegreeRigidity.Effective.CodingLocations + +namespace OAI + +namespace TuringRigidity.EffectiveSplitConditions +open Encodable UniformOracle ArithmeticHierarchy EncodedForcing OracleJump EffectiveSplit +open CodingForcing CodingAgreement CodingLocations + +def update (p w : ℕ) : ℕ := + if (Nat.unpair w).1 = 2 then + code (append (condition p) ((word (item (Nat.unpair w).2 1)).drop (left p).length)) + else code (condition p) + +theorem update_primrec : Primrec₂ update := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hc : Primrec (fun p : ℕ => code (condition p)) := Primrec₂.natPair.comp + (Primrec.encode.comp left_primrec) + (Primrec₂.natPair.comp (Primrec.encode.comp right_primrec) active_primrec) + let l : Primrec (fun z : ℕ × ℕ => left z.1) := left_primrec.comp Primrec.fst + let rr : Primrec (fun z : ℕ × ℕ => right z.1) := right_primrec.comp Primrec.fst + let tail := Primrec.list_drop.comp (Primrec.list_length.comp l) + (word_primrec.comp (item_primrec.comp (r.comp Primrec.snd) (Primrec.const 1))) + have ha := Primrec₂.natPair.comp (Primrec.encode.comp (Primrec.list_append.comp l tail)) + (Primrec₂.natPair.comp (Primrec.encode.comp (Primrec.list_append.comp rr tail)) + (active_primrec.comp Primrec.fst)) + exact Primrec.ite (Primrec.eq.comp (f.comp Primrec.snd) (Primrec.const 2)) ha (hc.comp Primrec.fst) + +noncomputable def next (Y : Oracle) (e : OracleCode) (p : ℕ) : ℕ := + update p (step Y e (encode (left p))) + +theorem next_recursive (Y : Oracle) (e : OracleCode) : + Nat.RecursiveIn {oracleFunction (jump Y)} (fun p => Part.some (next Y e p)) := by + have hs := total_comp (step_recursive Y e) (total_primrec (Primrec.encode.comp left_primrec)) + have hu : Primrec (fun v : ℕ => update (Nat.unpair v).1 (Nat.unpair v).2) := + update_primrec.comp (Primrec.fst.comp Primrec.unpair) (Primrec.snd.comp Primrec.unpair) + exact (total_comp (total_primrec hu) (total_pair (total_primrec Primrec.id) hs)).of_eq + (fun p => by simp [next]) + +theorem noSplit_unique {A : ℕ → Oracle} {Y : Oracle} {e : OracleCode} {p : Condition} + (h : ¬ ∃ w, SplitCert Y e (Nat.pair (encode p.left) w)) : UniqueValues A Y e p := by + intro r s hpr hps n a b ha hb + by_contra hn + apply h + refine ⟨encode [n,encode r.left,encode s.left,a,b],?_⟩ + simpa [SplitCert,item,word] using + And.intro hpr.1 (And.intro hps.1 (And.intro hn (And.intro ha hb))) + +theorem next_spec (A : ℕ → Oracle) (Y : Oracle) (e : OracleCode) (p : ℕ) : + Extends A (condition p) (condition (next Y e p)) ∧ + (condition (next Y e p)).active = (condition p).active ∧ + (UniqueValues A Y e (condition p) ∨ + (∃ m, SplittingLocation Y e (condition p).left m) ∨ + ∃ n, ∀ q, Extends A (condition (next Y e p)) q → + ∀ a, a ∉ CommonIdeal.run Y e q.left n) := by + let out := step Y e (encode (left p)) + have hs := step_spec Y e (encode (left p)) + change Accept Y e (Nat.pair (encode (left p)) out) at hs + simp only [Accept,Nat.unpair_pair] at hs + rcases hs with ⟨ht,hn⟩ | ⟨ht,hpoint⟩ | ⟨ht,hdiv⟩ + · have htag : (Nat.unpair out).1 ≠ 2 := by omega + have he : condition (next Y e p) = condition p := by + simp only [next,← show out = step Y e (encode (left p)) from rfl,update,ite_eq_right htag,condition_code] + rw [he] + exact ⟨extends_refl A _,rfl,Or.inl (noSplit_unique hn)⟩ + · have htag : (Nat.unpair out).1 ≠ 2 := by omega + have he : condition (next Y e p) = condition p := by + simp only [next,← show out = step Y e (encode (left p)) from rfl,update,ite_eq_right htag,condition_code] + rw [he] + let w := (Nat.unpair out).2 + simp only [PointCert,Nat.unpair_pair,word,encodek,Option.getD_some] at hpoint + refine ⟨extends_refl A _,rfl,Or.inr (Or.inl ⟨item w 2,?_⟩)⟩ + exact ⟨word (item w 1),(item w 3).bodd,item w 0,item w 4,item w 5,hpoint⟩ + · let w := (Nat.unpair out).2 + let q := word (item w 1) + have hpq : left p <+: q := by simpa [q,w,DivCert,word] using hdiv.1 + have heq : left p ++ q.drop (left p).length = q := by + rw [List.prefix_iff_eq_take] at hpq + conv_lhs => lhs; rw [hpq] + exact List.take_append_drop _ _ + let r := append (condition p) (q.drop (left p).length) + have he : condition (next Y e p) = r := by + simp only [next,← show out = step Y e (encode (left p)) from rfl,update,ite_eq_left ht,condition_code] + rfl + have hleft : r.left = q := heq + rw [he] + refine ⟨append_extends A _ _,rfl,Or.inr (Or.inr ⟨item w 0,?_⟩)⟩ + intro t hrt a ha + have hn : ¬ ConvergesAbove Y e w := by simpa only [Nat.unpair_pair] using hdiv.2 + apply hn + refine ⟨encode t.left,?_,?_⟩ + · change q <+: word (encode t.left) + simpa only [word,encodek,Option.getD_some,← hleft] using hrt.1 + · simpa only [word,encodek,Option.getD_some] using ha.1 + +end TuringRigidity.EffectiveSplitConditions + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveWitness.lean b/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..70f6489f1e6d5aa5a70950733fa43c723c91aab9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/EffectiveWitness.lean @@ -0,0 +1,101 @@ +import OAI.Computability.DegreeRigidity.Computability.JumpProperties + +namespace OAI + +namespace TuringRigidity.EffectiveWitness +open UniformOracle ArithmeticHierarchy OracleJump + +noncomputable def least (P : ℕ → Prop) (ht : ∀ x, ∃ a, P (Nat.pair x a)) (x : ℕ) : ℕ := + by + classical + exact Nat.find (ht x) + +theorem least_spec (P : ℕ → Prop) (ht : ∀ x, ∃ a, P (Nat.pair x a)) (x : ℕ) : + P (Nat.pair x (least P ht x)) := by + classical + exact Nat.find_spec (ht x) + +theorem least_recursive {Y : Oracle} {P : ℕ → Prop} (hP : RecursivePred Y P) + (ht : ∀ x, ∃ a, P (Nat.pair x a)) : + Nat.RecursiveIn {oracleFunction Y} (fun x => Part.some (least P ht x)) := by + classical + have hr := Nat.RecursiveIn.rfind (recursive_not hP) + apply hr.of_eq_tot + intro x + apply Nat.mem_rfind.mpr + constructor + · simp [least_spec P ht x] + · intro a ha + have hn := Nat.find_min (ht x) (show a < Nat.find (ht x) from ha) + simp [hn] + +def Accept (P : ℕ → Prop) (v : ℕ) : Prop := + ((Nat.unpair v).2 = 0 ∧ ¬ ∃ a, P (Nat.pair (Nat.unpair v).1 a)) ∨ + (0 < (Nat.unpair v).2 ∧ P (Nat.pair (Nat.unpair v).1 ((Nat.unpair v).2 - 1))) + +theorem accept_total (P : ℕ → Prop) : ∀ x, ∃ a, Accept P (Nat.pair x a) := by + intro x + by_cases h : ∃ a, P (Nat.pair x a) + · obtain ⟨a,ha⟩ := h + exact ⟨a+1, Or.inr ⟨by simp, by simpa using ha⟩⟩ + · exact ⟨0, Or.inl ⟨by simp, by simpa using h⟩⟩ + +theorem accept_recursive {Y : Oracle} {P : ℕ → Prop} (hP : RecursivePred Y P) : + RecursivePred (jump Y) (Accept P) := by + classical + let f := Primrec.fst.comp Primrec.unpair + let s := Primrec.snd.comp Primrec.unpair + have hz : RecursivePred (jump Y) (fun v => (Nat.unpair v).2 = 0) := + (total_primrec (Primrec.ite (Primrec.eq.comp s (Primrec.const 0)) (Primrec.const 1) (Primrec.const 0))).of_eq + (fun v => by by_cases h : (Nat.unpair v).2 = 0 <;> simp [h]) + have hp : RecursivePred (jump Y) (fun v => 0 < (Nat.unpair v).2) := + (total_primrec (Primrec.ite (Primrec.nat_lt.comp (Primrec.const 0) s) (Primrec.const 1) (Primrec.const 0))).of_eq + (fun v => by by_cases h : 0 < (Nat.unpair v).2 <;> simp [h]) + have hn := recursive_comp (recursive_not (exists_recursive_jump hP)) f + have hy := recursive_comp (recursive_lift hP) + (Primrec₂.natPair.comp f (Primrec.nat_sub.comp s (Primrec.const 1))) + exact Form.or (n := 0) (s := true) (recursive_and hz hn) (recursive_and hp hy) + +noncomputable def witness (P : ℕ → Prop) (x : ℕ) : ℕ := + least (Accept P) (accept_total P) x + +theorem witness_recursive {Y : Oracle} {P : ℕ → Prop} (hP : RecursivePred Y P) : + Nat.RecursiveIn {oracleFunction (jump Y)} (fun x => Part.some (witness P x)) := + least_recursive (accept_recursive hP) (accept_total P) + +theorem witness_spec (P : ℕ → Prop) (x : ℕ) : + (witness P x = 0 ∧ ¬ ∃ a, P (Nat.pair x a)) ∨ + (0 < witness P x ∧ P (Nat.pair x (witness P x - 1))) := by + simpa only [Accept, Nat.unpair_pair, witness] using least_spec (Accept P) (accept_total P) x + +theorem sigma1_choice {Y : Oracle} {P : ℕ → Prop} (hP : Sigma Y 1 P) : + ∃ f : ℕ → ℕ, Nat.RecursiveIn {oracleFunction (jump Y)} (fun x => Part.some (f x)) ∧ + ∀ x, (f x = 0 ∧ ¬ ∃ a, P (Nat.pair x a)) ∨ + (0 < f x ∧ P (Nat.pair x (f x - 1))) := by + obtain ⟨Q,hQ,he⟩ := hP + let Q' : ℕ → Prop := fun v => Q + (Nat.pair (Nat.pair (Nat.unpair v).1 (Nat.unpair (Nat.unpair v).2).1) + (Nat.unpair (Nat.unpair v).2).2) + let fst := Primrec.fst.comp Primrec.unpair + let snd := Primrec.snd.comp Primrec.unpair + have hQ' : RecursivePred Y Q' := recursive_comp hQ + (Primrec₂.natPair.comp (Primrec₂.natPair.comp fst (fst.comp snd)) (snd.comp snd)) + let f : ℕ → ℕ := fun x => if witness Q' x = 0 then 0 else (Nat.unpair (witness Q' x - 1)).1 + 1 + have hf : Primrec (fun v : ℕ => if v = 0 then 0 else (Nat.unpair (v-1)).1+1) := + Primrec.ite (Primrec.eq.comp Primrec.id (Primrec.const 0)) (Primrec.const 0) + (Primrec.succ.comp (fst.comp (Primrec.nat_sub.comp Primrec.id (Primrec.const 1)))) + have hrec := total_comp (total_primrec (O := {oracleFunction (jump Y)}) hf) (witness_recursive hQ') + refine ⟨f, hrec.of_eq (fun x => rfl), fun x => ?_⟩ + rcases witness_spec Q' x with ⟨hz,hn⟩ | ⟨hp,hy⟩ + · refine Or.inl ⟨by simp [f,hz], ?_⟩ + rintro ⟨a,ha⟩ + obtain ⟨b,hb⟩ := (he _).mp ha + exact hn ⟨Nat.pair a b, by simpa [Q'] using hb⟩ + · have hn : witness Q' x ≠ 0 := by omega + refine Or.inr ⟨by simp [f,hn], ?_⟩ + simp only [f, ite_eq_right hn, Nat.add_sub_cancel] + exact (he _).mpr ⟨(Nat.unpair (witness Q' x - 1)).2, by simpa [Q'] using hy⟩ + +end TuringRigidity.EffectiveWitness + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteApproximation.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteApproximation.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a6ef507428d0dc06e72cca9dc7d84d5dc3d4f39 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteApproximation.lean @@ -0,0 +1,99 @@ +import OAI.Computability.DegreeRigidity.Computability.OracleCode + +namespace OAI + +namespace TuringRigidity + +def Approximates {α : Type*} (p : Part α) (ps : ℕ → Part α) : Prop := + (∀ m a, a ∈ ps m → a ∈ p) ∧ + (∀ a, a ∈ p → ∃ M, ∀ m, M ≤ m → a ∈ ps m) + +namespace Approximates +variable {α β : Type*} + +theorem const (p : Part α) : Approximates p (fun _ => p) := + ⟨fun _ _ h => h, fun _ h => ⟨0,fun _ _ => h⟩⟩ + +theorem bind {p : Part α} {ps : ℕ → Part α} {f : α → Part β} + {fs : ℕ → α → Part β} (hp : Approximates p ps) + (hf : ∀ a, Approximates (f a) (fun m => fs m a)) : + Approximates (p.bind f) (fun m => (ps m).bind (fs m)) := by + constructor + · intro m b hb + obtain ⟨a,ha,hb⟩ := Part.mem_bind_iff.mp hb + exact Part.mem_bind_iff.mpr ⟨a,hp.1 m a ha,(hf a).1 m b hb⟩ + · intro b hb + obtain ⟨a,ha,hb⟩ := Part.mem_bind_iff.mp hb + obtain ⟨M,hM⟩ := hp.2 a ha + obtain ⟨N,hN⟩ := (hf a).2 b hb + exact ⟨max M N,fun m hm => Part.mem_bind_iff.mpr + ⟨a,hM m ((le_max_left _ _).trans hm),hN m ((le_max_right _ _).trans hm)⟩⟩ + +theorem map {p : Part α} {ps : ℕ → Part α} (hp : Approximates p ps) (f : α → β) : + Approximates (p.map f) (fun m => (ps m).map f) := by + simpa only [Part.bind_some_eq_map] using hp.bind (fun a => const (Part.some (f a))) + +theorem finite_bounds (P : ℕ → ℕ → Prop) (n : ℕ) + (h : ∀ i, i < n → ∃ M, ∀ m, M ≤ m → P i m) : + ∃ M, ∀ m, M ≤ m → ∀ i, i < n → P i m := by + induction n with + | zero => exact ⟨0,by simp⟩ + | succ n ih => + obtain ⟨M,hM⟩ := ih (fun i hi => h i (Nat.lt_succ_of_lt hi)) + obtain ⟨N,hN⟩ := h n (Nat.lt_succ_self n) + refine ⟨max M N, fun m hm i hi => ?_⟩ + rcases Nat.lt_succ_iff_lt_or_eq.mp hi with hi | rfl + · exact hM m ((le_max_left _ _).trans hm) i hi + · exact hN m ((le_max_right _ _).trans hm) + +theorem rfind {p : ℕ → Part Bool} {ps : ℕ → ℕ → Part Bool} + (hp : ∀ n, Approximates (p n) (fun m => ps m n)) : + Approximates (Nat.rfind p) (fun m => Nat.rfind (ps m)) := by + constructor + · intro m n hn + obtain ⟨ht,hf⟩ := Nat.mem_rfind.mp hn + exact Nat.mem_rfind.mpr ⟨(hp n).1 m true ht,fun {k} hk => (hp k).1 m false (hf hk)⟩ + · intro n hn + obtain ⟨ht,hf⟩ := Nat.mem_rfind.mp hn + obtain ⟨M,hM⟩ := (hp n).2 true ht + obtain ⟨N,hN⟩ := finite_bounds (fun k m => false ∈ ps m k) n + (fun k hk => (hp k).2 false (hf hk)) + exact ⟨max M N, fun m hm => Nat.mem_rfind.mpr + ⟨hM m ((le_max_left _ _).trans hm),fun {k} hk => hN m ((le_max_right _ _).trans hm) k hk⟩⟩ +end Approximates + +namespace OracleCode + +theorem eval_approximates {g : ℕ →. ℕ} {gs : ℕ → ℕ →. ℕ} + (hg : ∀ n, Approximates (g n) (fun m => gs m n)) (c : OracleCode) : + ∀ n, Approximates (eval g c n) (fun m => eval (gs m) c n) := by + induction c with + | zero => intro n; exact Approximates.const _ + | succ => intro n; exact Approximates.const _ + | left => intro n; exact Approximates.const _ + | right => intro n; exact Approximates.const _ + | query => exact hg + | pair c d hc hd => + intro n + exact (hc n).bind (fun a => (hd n).map (Nat.pair a)) + | comp c d hc hd => intro n; exact (hd n).bind hc + | prec c d hc hd => + intro p + have hr : ∀ k, Approximates + (Nat.rec (eval g c (Nat.unpair p).1) + (fun y ih => ih.bind (fun i => eval g d (Nat.pair (Nat.unpair p).1 (Nat.pair y i)))) k) + (fun m => Nat.rec (eval (gs m) c (Nat.unpair p).1) + (fun y ih => ih.bind (fun i => eval (gs m) d (Nat.pair (Nat.unpair p).1 (Nat.pair y i)))) k) := by + intro k + induction k with + | zero => exact hc _ + | succ k ih => exact ih.bind (fun i => hd _) + exact hr _ + | find c hc => + intro n + exact Approximates.rfind (fun k => (hc (Nat.pair n k)).map (fun m => decide (m=0))) + +end OracleCode +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteBlockProducts.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteBlockProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..825e2d8748876cdf1c12607dfb507c657a0c8b1e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteBlockProducts.lean @@ -0,0 +1,116 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteSumPowerBound + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalCoding +universe u + +theorem finite_block_product_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (β : Ordinal.{u}) (hβ : 0 < β) (n : ℕ) : + ProductCertificates + (level (groundReals M) (Ordinal.omega0 ^ β * (n+2)+1)) + (Ordinal.omega0 ^ β) n := by + induction n using Nat.strong_induction_on with + | h n ih => + let R := groundReals M + let a := Ordinal.omega0 ^ β + let γ := a*(n+2) + have ha0 : 0 < a := Ordinal.opow_pos β Ordinal.omega0_pos + have haLim : Order.IsSuccLimit a := Ordinal.isSuccLimit_opow_left + Ordinal.isSuccLimit_omega0 (ne_of_gt hβ) + have hn2 : (0 : Ordinal.{u}) < n+2 := by exact_mod_cast (show 0 < n+2 by omega) + have hγ : Order.IsSuccLimit γ := Ordinal.isSuccLimit_mul_left haLim hn2 + have haγ : a < γ := by + have h : (1 : Ordinal.{u}) < n+2 := by exact_mod_cast (show 1 < n+2 by omega) + simpa only [mul_one] using mul_lt_mul_of_pos_left h ha0 + have hmem (c : Ordinal.{u}) (hc : c < γ) : c.toZFSet ∈ level R γ := by + rw [ordinal_mem_level_iff] + exact hc.trans_le le_add_self + apply product_certificates_at_limit_successor R γ a n hγ + (ground_level_omega_mem M hM hT γ) (hmem a haγ) + (hmem n ((Ordinal.natCast_lt_of_isSuccLimit haLim n).trans haγ)) + intro s hsn + obtain ⟨m,rfl⟩ := Ordinal.lt_omega0.mp (hsn.trans (Ordinal.natCast_lt_omega0 n)) + have hmn : m < n := by exact_mod_cast hsn + have hm2 : (m : Ordinal.{u})+2 < n+2 := by exact_mod_cast (show m+2 < n+2 by omega) + have hpγ : a*(m+2) < γ := mul_lt_mul_of_pos_left hm2 ha0 + have hp : ProductCertificates (level R γ) a m := + (ih m hmn).mono (level_mono R (Order.add_one_le_iff.mpr hpγ)) + have hmγ : a*m < γ := mul_lt_mul_of_pos_left + (hsn.trans (by exact_mod_cast (show n < n+2 by omega))) ha0 + refine ⟨hmem _ hmγ,hp,?_⟩ + intro t ht + have htmargin := finite_sum_margin_lt_power β t hβ ht + have hbound : a*m+8*t+8 < a*(m+1) := by + rw [add_assoc,mul_add_one] + exact (add_lt_add_iff_left (a*m)).mpr htmargin + have hm1 : (m : Ordinal.{u})+1 ≤ n+2 := by exact_mod_cast (show m+1 ≤ n+2 by omega) + have hboundγ := hbound.trans_le (mul_le_mul_right hm1 a) + have hvγ : a*m+t < γ := by + have hv : a*m+t < a*m+a := (add_lt_add_iff_left (a*m)).mpr ht + rw [← mul_add_one] at hv + exact hv.trans_le (mul_le_mul_right hm1 a) + exact ⟨hmem _ hvγ,(sum_certificates_finite_bound M hM hT (a*m) t).mono + (level_mono R hboundγ.le)⟩ + +theorem finite_products_below_omega_boundary (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (β : Ordinal.{u}) (hβ : 0 < β) : + ∀ s < Ordinal.omega0, ProductCertificates + (level (groundReals M) (Ordinal.omega0 ^ (β+1))) (Ordinal.omega0 ^ β) s := by + intro s hs + obtain ⟨n,rfl⟩ := Ordinal.lt_omega0.mp hs + have h := finite_block_product_certificates M hM hT β hβ n + apply h.mono (level_mono _ ?_) + apply Order.add_one_le_iff.mpr + rw [Ordinal.opow_add_one] + apply mul_lt_mul_of_pos_left _ (Ordinal.opow_pos β Ordinal.omega0_pos) + exact_mod_cast Ordinal.natCast_lt_omega0 (n+2) + +theorem partial_sums_below_omega_boundary (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (β : Ordinal.{u}) (hβ : 0 < β) : + ∀ s < Ordinal.omega0, ∀ t < Ordinal.omega0 ^ β, SumCertificates + (level (groundReals M) (Ordinal.omega0 ^ (β+1))) (Ordinal.omega0 ^ β*s) t := by + intro s hs t ht + have hc := sum_certificates_below_power_cut M hM hT (Ordinal.omega0 ^ β*s) β t hβ ht + apply hc.mono (level_mono _ ?_) + rw [← mul_add_one,Ordinal.opow_add_one] + exact mul_le_mul_right (Order.add_one_le_iff.mpr hs) _ + +theorem omega_boundary_product_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (β : Ordinal.{u}) (hβ : 0 < β) + (hoff : realSeedOffset+β=β) : + ProductCertificates + (level (groundReals M) (Ordinal.omega0 ^ (β+1)+1)) (Ordinal.omega0 ^ β) Ordinal.omega0 := + omega_boundary_product_of_smaller_certificates M hM hT β hβ hoff + (finite_products_below_omega_boundary M hM hT β hβ) + (partial_sums_below_omega_boundary M hM hT β hβ) + +theorem omega_boundary_product_without_offset (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (β : Ordinal.{u}) (hβ : 0 < β) : + ProductCertificates + (level (groundReals M) (Ordinal.omega0 ^ (β+1)+1)) (Ordinal.omega0 ^ β) Ordinal.omega0 := by + let R := groundReals M + let a := Ordinal.omega0 ^ β + let b := Ordinal.omega0 ^ (β+1) + have hab : a*Ordinal.omega0=b := (Ordinal.opow_add_one Ordinal.omega0 β).symm + have ha0 : 0 < a := Ordinal.opow_pos β Ordinal.omega0_pos + have hmem (c : Ordinal.{u}) (hc : c < b) : c.toZFSet ∈ level R b := by + rw [ordinal_mem_level_iff] + exact hc.trans_le le_add_self + have hl : Order.IsSuccLimit b := Ordinal.isSuccLimit_opow_left + Ordinal.isSuccLimit_omega0 (ne_of_gt (hβ.trans (lt_add_one β))) + have hω := ground_level_omega_mem M hM hT b + apply product_certificates_at_limit_successor R b a Ordinal.omega0 hl hω + (hmem a ((Ordinal.opow_lt_opow_iff_right Ordinal.one_lt_omega0).mpr (lt_add_one β))) + (toZFSet_omega.symm ▸ hω) + intro s hs + have hv : a*s < b := hab ▸ mul_lt_mul_of_pos_left hs ha0 + refine ⟨hmem _ hv,finite_products_below_omega_boundary M hM hT β hβ s hs,?_⟩ + intro t ht + have hv' : a*s+t < b := hab ▸ Ordinal.lt_mul_iff.mpr ⟨s,hs,t,ht,rfl⟩ + exact ⟨hmem _ hv',partial_sums_below_omega_boundary M hM hT β hβ s hs t ht⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteCodeBound.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteCodeBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..40469dcbe9f956fcef23973343691aeba6545898 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteCodeBound.lean @@ -0,0 +1,113 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteExtensionCode + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse +universe u +namespace FiniteTuple + +inductive FiniteCode (t : ZFSet.{u}) : ZFSet.{u} → Prop + | atom (x : ZFSet.{u}) (hx : x ∈ t) : FiniteCode t x + | empty : FiniteCode t ∅ + | pair {x y : ZFSet.{u}} : FiniteCode t x → FiniteCode t y → FiniteCode t {x,y} + +theorem FiniteCode.orderedPair {t x y : ZFSet.{u}} (hx : FiniteCode t x) (hy : FiniteCode t y) : + FiniteCode t (ZFSet.pair x y) := by + have hs : FiniteCode t ({x} : ZFSet.{u}) := by simpa using hx.pair hx + exact hs.pair (hx.pair hy) + +theorem FiniteCode.mem_model (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + (h0 : (∅ : ZFSet.{u}) ∈ M) {t x : ZFSet.{u}} (ht : t ∈ M) (hx : FiniteCode t x) : x ∈ M := by + induction hx with + | atom x hx => exact hM t ht x hx + | empty => exact h0 + | pair _ _ ihx ihy => exact pair_mem M hM hP ihx ihy + +theorem transitive_union {a b : ZFSet.{u}} (ha : Transitive a) (hb : Transitive b) : + Transitive (a ∪ b) := by + intro x hx y hy + rcases ZFSet.mem_union.mp hx with hx|hx + · exact ZFSet.mem_union.mpr (Or.inl (ha x hx y hy)) + · exact ZFSet.mem_union.mpr (Or.inr (hb x hx y hy)) + +theorem transitive_adjoin {a z : ZFSet.{u}} (ha : Transitive a) (hz : z ⊆ a) : + Transitive (a ∪ ({z} : ZFSet.{u})) := by + intro x hx y hy + rcases ZFSet.mem_union.mp hx with hx|hx + · exact ZFSet.mem_union.mpr (Or.inl (ha x hx y hy)) + · obtain rfl := ZFSet.mem_singleton.mp hx + exact ZFSet.mem_union.mpr (Or.inl (hz hy)) + +theorem FiniteCode.finite_transitive_extension (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (h0 : (∅ : ZFSet.{u}) ∈ M) + {t x : ZFSet.{u}} (ht : t ∈ M) (htt : Transitive t) (hx : FiniteCode t x) : + ∃ xs : List ZFSet.{u}, (∀ y ∈ xs, y ∈ M) ∧ x ∈ t ∪ elements xs ∧ + Transitive (t ∪ elements xs) := by + induction hx with + | atom x hx => + refine ⟨[],by simp,?_,?_⟩ + · exact ZFSet.mem_union.mpr (Or.inl hx) + · have heq : t ∪ elements [] = t := by + apply ZFSet.ext; intro z; simp [ZFSet.mem_union,elements] + exact heq.symm ▸ htt + | empty => + refine ⟨[∅],?_,?_,?_⟩ + · intro y hy; obtain rfl := List.mem_singleton.mp hy; exact h0 + · exact ZFSet.mem_union.mpr (Or.inr ((mem_elements _ _).mpr List.mem_cons_self)) + · have heq : t ∪ elements [∅] = t ∪ ({∅} : ZFSet.{u}) := by + apply ZFSet.ext; intro z; simp [ZFSet.mem_union,elements] + rw [heq] + exact transitive_adjoin htt (by simp) + | @pair x y hx hy ihx ihy => + obtain ⟨xs,hxs,hxxs,htxs⟩ := ihx + obtain ⟨ys,hys,hyys,htys⟩ := ihy + let zs := xs ++ ys + have hb : t ∪ elements zs = (t ∪ elements xs) ∪ (t ∪ elements ys) := by + apply ZFSet.ext; intro z + simp only [ZFSet.mem_union,mem_elements,List.mem_append,zs] + tauto + have hbt : Transitive (t ∪ elements zs) := hb.symm ▸ transitive_union htxs htys + have hxb : x ∈ t ∪ elements zs := hb.symm ▸ ZFSet.mem_union.mpr (Or.inl hxxs) + have hyb : y ∈ t ∪ elements zs := hb.symm ▸ ZFSet.mem_union.mpr (Or.inr hyys) + have hp : ({x,y} : ZFSet.{u}) ⊆ t ∪ elements zs := by + intro z hz; rcases ZFSet.mem_pair.mp hz with rfl|rfl + · exact hxb + · exact hyb + refine ⟨({x,y} : ZFSet.{u}) :: zs,?_,?_,?_⟩ + · intro z hz; rcases List.mem_cons.mp hz with rfl|hz + · exact pair_mem M hM hP (hx.mem_model M hM hP h0 ht) (hy.mem_model M hM hP h0 ht) + · rcases List.mem_append.mp hz with hz|hz + · exact hxs z hz + · exact hys z hz + · exact ZFSet.mem_union.mpr (Or.inr ((mem_elements _ _).mpr List.mem_cons_self)) + · have heq : t ∪ elements (({x,y} : ZFSet.{u})::zs) = + (t ∪ elements zs) ∪ ({({x,y} : ZFSet.{u})} : ZFSet.{u}) := by + apply ZFSet.ext; intro z + simp only [ZFSet.mem_union,mem_elements,List.mem_cons,ZFSet.mem_singleton] + tauto + rw [heq] + exact transitive_adjoin hbt hp + +theorem internal_finite_code_bound (M t : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) + (ht : t ∈ M) (htt : Transitive t) : + ∃ K ∈ M, ∀ x, FiniteCode t x → x ∈ K := by + have hω := omega_mem M hM hS.bounded hI + have h0 : (∅ : ZFSet.{u}) ∈ M := hM _ hω _ ZFSet.omega_zero + have hk := indexSpace_mem M hM hP hU hPow hS.bounded hω ht + obtain ⟨K,hK,hbound⟩ := internal_small_transitive_bound M (indexSpace t) hM hP hU hPow hS hR hk + refine ⟨K,hK,?_⟩ + intro x hx + obtain ⟨xs,hxs,hxD,hDT⟩ := hx.finite_transitive_extension M hM hP h0 ht htt + have hD := binary_union_mem M hM hP hU ht (elements_mem M hM hP hU h0 xs hxs) + obtain ⟨f,hf,hfg⟩ := internal_finite_extension_injection M hM hP hU hPow hS.bounded hR hω ht xs hxs + exact hbound _ hD hDT f hf (finiteIndex t xs) hfg + (fun y _ => finiteIndex_mem t xs y) (finiteIndex_injective t xs) hxD + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteExtensionCode.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteExtensionCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd87b1465659a5ce41aadb9a9019d1c50b75fee8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteExtensionCode.lean @@ -0,0 +1,115 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaHull +import OAI.Computability.DegreeRigidity.SetModels.CollapseCoding +import Mathlib.Data.List.Basic + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse +universe u +namespace FiniteTuple + +noncomputable def indexSpace (t : ZFSet.{u}) : ZFSet.{u} := + ZFSet.prod {natSet 0} t ∪ ZFSet.prod {natSet 1} ZFSet.omega + +noncomputable def finiteIndex (t : ZFSet.{u}) (xs : List ZFSet.{u}) (x : ZFSet.{u}) : ZFSet.{u} := by + classical + exact if x ∈ t then ZFSet.pair (natSet 0) x else ZFSet.pair (natSet 1) (natSet (xs.idxOf x)) + +theorem indexSpace_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hω : ZFSet.omega.{u} ∈ M) {t : ZFSet.{u}} (ht : t ∈ M) : indexSpace t ∈ M := by + have hn (n : ℕ) : natSet.{u} n ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩) + exact binary_union_mem M hM hP hU + (product_mem M hM hP hU hPow hS (singleton_mem M hM hP (hn 0)) ht) + (product_mem M hM hP hU hPow hS (singleton_mem M hM hP (hn 1)) hω) + +theorem finiteIndex_mem (t : ZFSet.{u}) (xs : List ZFSet.{u}) (x : ZFSet.{u}) : + finiteIndex t xs x ∈ indexSpace t := by + classical + unfold finiteIndex + by_cases hx : x ∈ t + · rw [ite_eq_left hx] + exact ZFSet.mem_union.mpr (Or.inl (ZFSet.mem_prod.mpr + ⟨_,ZFSet.mem_singleton.mpr rfl,x,hx,rfl⟩)) + · rw [ite_eq_right hx] + exact ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_prod.mpr + ⟨_,ZFSet.mem_singleton.mpr rfl,_,(mem_omega _).mpr ⟨xs.idxOf x,rfl⟩,rfl⟩)) + +theorem finiteIndex_injective (t : ZFSet.{u}) (xs : List ZFSet.{u}) + (x : ZFSet.{u}) (hx : x ∈ t ∪ elements xs) (y : ZFSet.{u}) (_hy : y ∈ t ∪ elements xs) + (he : finiteIndex t xs x = finiteIndex t xs y) : x = y := by + classical + unfold finiteIndex at he + by_cases hxt : x ∈ t <;> by_cases hyt : y ∈ t + · rw [ite_eq_left hxt,ite_eq_left hyt] at he + exact (ZFSet.pair_inj.mp he).2 + · rw [ite_eq_left hxt,ite_eq_right hyt] at he + have hf := natSet_injective (ZFSet.pair_inj.mp he).1 + omega + · rw [ite_eq_right hxt,ite_eq_left hyt] at he + have hf := natSet_injective (ZFSet.pair_inj.mp he).1 + omega + · rw [ite_eq_right hxt,ite_eq_right hyt] at he + have hidx := natSet_injective (ZFSet.pair_inj.mp he).2 + have hxl : x ∈ xs := (mem_elements x xs).mp ((ZFSet.mem_union.mp hx).resolve_left hxt) + exact (List.idxOf_inj hxl).mp hidx + +theorem internal_finite_extension_injection (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hω : ZFSet.omega.{u} ∈ M) + {t : ZFSet.{u}} (ht : t ∈ M) (xs : List ZFSet.{u}) (hxs : ∀ x ∈ xs, x ∈ M) : + ∃ f ∈ M, Presents (t ∪ elements xs) f (finiteIndex t xs) := by + classical + have hn (n : ℕ) : natSet.{u} n ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩) + have hk := indexSpace_mem M hM hP hU hPow hS hω ht + let j := finiteIndex t xs + have hj (x : ZFSet.{u}) : j x ∈ M := hM _ hk _ (finiteIndex_mem t xs x) + let φ : Formula := .existsMem 2 (.conj (.orderedPair 1 2 0) (.orderedPair 0 4 2)) + let e := cons (indexSpace t) (fun _ => natSet 0) + have he : ∀ i, e i ∈ M := by intro i; cases i with + | zero => exact hk + | succ => exact hn 0 + obtain ⟨b,hb,hbdef⟩ := replacement_image M hM hR (.bounded φ) e he ht + (fun x => ZFSet.pair x (ZFSet.pair (natSet 0) x)) + (fun x hx => orderedPair_mem M hM hP (hM t ht x hx) + (orderedPair_mem M hM hP (hn 0) (hM t ht x hx))) (by + intro x hx y hy + change φ.Realize M (cons y (cons x e)) ↔ _ + rw [Formula.absolute _ M hM _ (by + intro i; rcases i with _|i; exact hy + rcases i with _|i; exact hM t ht x hx + exact he i)] + simp only [φ,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,e] + constructor + · rintro ⟨v,_,hy,rfl⟩; exact hy + · intro hy + have hjx := finiteIndex_mem t xs x + rw [finiteIndex,ite_eq_left hx] at hjx + exact ⟨_,hjx,hy,rfl⟩) + let f := b ∪ elements (xs.map (fun x => ZFSet.pair x (j x))) + have hf : f ∈ M := binary_union_mem M hM hP hU hb + (elements_mem M hM hP hU (hn 0) _ (by + intro z hz + obtain ⟨x,hx,rfl⟩ := List.mem_map.mp hz + exact orderedPair_mem M hM hP (hxs x hx) (hj x))) + refine ⟨f,hf,?_⟩ + intro z + change z ∈ b ∪ elements (xs.map (fun x => ZFSet.pair x (j x))) ↔ _ + rw [ZFSet.mem_union,hbdef,mem_elements,List.mem_map] + constructor + · rintro (⟨x,hx,rfl⟩|⟨x,hx,rfl⟩) + · refine ⟨x,ZFSet.mem_union.mpr (Or.inl hx),?_⟩ + simp only [finiteIndex,ite_eq_left hx] + · exact ⟨x,ZFSet.mem_union.mpr (Or.inr ((mem_elements x xs).mpr hx)),rfl⟩ + · rintro ⟨x,hx,rfl⟩ + rcases ZFSet.mem_union.mp hx with hx|hx + · apply Or.inl + exact ⟨x,hx,by simp only [finiteIndex,ite_eq_left hx]⟩ + · exact Or.inr ⟨x,(mem_elements x xs).mp hx,rfl⟩ + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteInjury.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteInjury.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c14e2a00ed5b652587d4417d8eca677b3f40b40 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteInjury.lean @@ -0,0 +1,123 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingForcing +import Mathlib.Data.Finset.Filter + +namespace OAI + +namespace TuringRigidity.FiniteInjury + +def accept (done : Finset ℕ) (proposal : Option ℕ) : Option ℕ := + proposal.bind (fun t => if t ∈ done then none else some t) + +def update (done : Finset ℕ) (action : Option ℕ) : Finset ℕ := + match action with + | none => done + | some t => insert t (done.filter (fun i => i < t)) + +def state (proposal : ℕ → Finset ℕ → Option ℕ) : ℕ → Finset ℕ + | 0 => ∅ + | s+1 => update (state proposal s) (accept (state proposal s) (proposal s (state proposal s))) + +def action (proposal : ℕ → Finset ℕ → Option ℕ) (s : ℕ) : Option ℕ := + accept (state proposal s) (proposal s (state proposal s)) + +theorem state_succ (proposal : ℕ → Finset ℕ → Option ℕ) (s : ℕ) : + state proposal (s+1) = update (state proposal s) (action proposal s) := rfl + +theorem action_not_done {proposal : ℕ → Finset ℕ → Option ℕ} {s t : ℕ} + (h : action proposal s = some t) : t ∉ state proposal s := by + unfold action accept at h + cases hp : proposal s (state proposal s) with + | none => simp [hp] at h + | some i => + simp only [hp, Option.bind_some] at h + split at h + · simp at h + · rename_i hi + have he := Option.some.inj h + exact he ▸ hi + +theorem done_after_action {proposal : ℕ → Finset ℕ → Option ℕ} {s t : ℕ} + (h : action proposal s = some t) : t ∈ state proposal (s+1) := by + simp [state_succ, h, update] + +theorem done_persists {proposal : ℕ → Finset ℕ → Option ℕ} {s t : ℕ} + (h : t ∈ state proposal s) + (hsmall : ∀ i < t, action proposal s ≠ some i) : t ∈ state proposal (s+1) := by + rw [state_succ] + cases ha : action proposal s with + | none => simpa [ha, update] using h + | some i => + have hle : t ≤ i := by + by_contra hn + exact hsmall i (by omega) ha + simp only [update, Finset.mem_insert, Finset.mem_filter] + rcases eq_or_lt_of_le hle with he | he + · exact Or.inl he + · exact Or.inr ⟨h, he⟩ + +theorem done_persists_from {proposal : ℕ → Finset ℕ → Option ℕ} {S t : ℕ} + (h : t ∈ state proposal S) + (hsmall : ∀ s, S ≤ s → ∀ i < t, action proposal s ≠ some i) : + ∀ s, S ≤ s → t ∈ state proposal s := by + intro s hs + induction s, hs using Nat.le_induction with + | base => exact h + | succ s hs ih => exact done_persists ih (hsmall s hs) + +theorem finite_injury (proposal : ℕ → Finset ℕ → Option ℕ) (t : ℕ) : + ∃ S, ∀ s, S ≤ s → ∀ i < t, action proposal s ≠ some i := by + induction t with + | zero => exact ⟨0, fun _ _ _ hi => by omega⟩ + | succ t ih => + obtain ⟨S, hS⟩ := ih + by_cases hact : ∃ s, S ≤ s ∧ action proposal s = some t + · obtain ⟨s, hs, ha⟩ := hact + have hdone := done_after_action ha + have hpersist := done_persists_from hdone + (fun u hu => hS u (hs.trans (Nat.le_succ s |>.trans hu))) + refine ⟨s+1, ?_⟩ + intro u hu i hi he + by_cases hit : i = t + · subst i + exact action_not_done he (hpersist u hu) + · exact hS u (hs.trans (Nat.le_succ s |>.trans hu)) i (by omega) he + · refine ⟨S, ?_⟩ + intro s hs i hi he + by_cases hit : i = t + · exact hact ⟨s, hs, hit ▸ he⟩ + · exact hS s hs i (by omega) he + +open CodingForcing + +def atLevel (p : Condition) (t : ℕ) : Condition := + ⟨p.left, p.right, p.sameLength, t⟩ + +theorem level_mono {A : ℕ → Oracle} {p q : Condition} {t k : ℕ} + (h : Extends A (atLevel p t) (atLevel q t)) (hk : k ≤ t) : + Extends A (atLevel p k) (atLevel q k) := by + refine ⟨h.1, h.2.1, le_rfl, ?_⟩ + intro m hm hlen + exact h.2.2.2 m ⟨hm.1, hm.2.1.trans_le hk, hm.2.2⟩ hlen + +theorem eventual_level_chain (A : ℕ → Oracle) + (proposal : ℕ → Finset ℕ → Option ℕ) (p : ℕ → Condition) + (hstep : ∀ s k, k ≤ s → + (∀ t, action proposal s = some t → k ≤ t) → + Extends A (atLevel (p s) k) (atLevel (p (s+1)) k)) (k : ℕ) : + ∃ S, ∀ s, S ≤ s → ∀ u, s ≤ u → + Extends A (atLevel (p s) k) (atLevel (p u) k) := by + obtain ⟨S, hS⟩ := finite_injury proposal k + refine ⟨max S k, ?_⟩ + intro s hs u hu + induction u, hu using Nat.le_induction with + | base => exact extends_refl A _ + | succ u hu ih => + apply extends_trans ih + apply hstep u k ((le_max_right S k).trans (hs.trans hu)) + intro t ht + by_contra hn + exact hS u ((le_max_left S k).trans (hs.trans hu)) t (by omega) ht + +end TuringRigidity.FiniteInjury + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteInjuryLimits.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteInjuryLimits.lean new file mode 100644 index 0000000000000000000000000000000000000000..305ce0b76f5b6da4236d049ab61a1001fe3dd054 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteInjuryLimits.lean @@ -0,0 +1,56 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteInjury + +namespace OAI + +namespace TuringRigidity.FiniteInjury +open CodingForcing + +def leftLimit (p : ℕ → Condition) : Oracle := fun n => (p (n+1)).left.getD n false + +def rightLimit (p : ℕ → Condition) : Oracle := fun n => (p (n+1)).right.getD n false + +theorem word_prefix {p : ℕ → Condition} + (h : ∀ s, (p s).left <+: (p (s+1)).left ∧ (p s).right <+: (p (s+1)).right) + {s u : ℕ} (hsu : s ≤ u) : (p s).left <+: (p u).left ∧ (p s).right <+: (p u).right := by + induction u, hsu using Nat.le_induction with + | base => exact ⟨List.prefix_rfl, List.prefix_rfl⟩ + | succ u hu ih => exact ⟨ih.1.trans (h u).1, ih.2.trans (h u).2⟩ + +theorem limits_extend {p : ℕ → Condition} + (h : ∀ s, (p s).left <+: (p (s+1)).left ∧ (p s).right <+: (p (s+1)).right) + (hlen : ∀ s, s ≤ (p s).left.length) (s m : ℕ) (hm : m < (p s).left.length) : + leftLimit p m = (p s).left.getD m false ∧ + rightLimit p m = (p s).right.getD m false := by + unfold leftLimit rightLimit + by_cases hs : s ≤ m+1 + · have hp := word_prefix h hs + exact ⟨getD_of_prefix hp.1 hm, + getD_of_prefix hp.2 (by simpa [← (p s).sameLength] using hm)⟩ + · have hp := word_prefix h (Nat.le_of_not_ge hs) + have hml : m < (p (m+1)).left.length := (Nat.lt_succ_self m).trans_le (hlen (m+1)) + exact ⟨(getD_of_prefix hp.1 hml).symm, + (getD_of_prefix hp.2 (by simpa [← (p (m+1)).sameLength] using hml)).symm⟩ + +theorem eventual_column_agreement (A : ℕ → Oracle) + (proposal : ℕ → Finset ℕ → Option ℕ) (p : ℕ → Condition) + (hwords : ∀ s, (p s).left <+: (p (s+1)).left ∧ (p s).right <+: (p (s+1)).right) + (hlen : ∀ s, s ≤ (p s).left.length) + (hstep : ∀ s k, k ≤ s → + (∀ t, action proposal s = some t → k ≤ t) → + Extends A (atLevel (p s) k) (atLevel (p (s+1)) k)) (k : ℕ) : + ∃ S, ∀ m, (p S).left.length ≤ m → (Nat.unpair m).1 < k → + A (Nat.unpair m).1 (Nat.unpair m).2 = true → leftLimit p m = rightLimit p m := by + obtain ⟨S, hS⟩ := eventual_level_chain A proposal p hstep k + refine ⟨S, ?_⟩ + intro m hm hk ha + let u := max S (m+1) + have hlen' : m < (p u).left.length := + (Nat.lt_succ_self m).trans_le ((le_max_right _ _).trans (hlen u)) + have hext := hS S le_rfl u (le_max_left _ _) + have heq := hext.2.2.2 m ⟨hm, hk, ha⟩ hlen' + have hlim := limits_extend hwords hlen u m hlen' + exact hlim.1.trans (heq.trans hlim.2.symm) + +end TuringRigidity.FiniteInjury + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteInjurySchedule.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteInjurySchedule.lean new file mode 100644 index 0000000000000000000000000000000000000000..3632e1b1c50a4322637404c1dda9319bb9406032 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteInjurySchedule.lean @@ -0,0 +1,131 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteInjury +import Mathlib.Data.Finset.Lattice.Fold + +namespace OAI + +namespace TuringRigidity.FiniteInjurySchedule +open FiniteInjury + +theorem exists_missing (seen : Finset ℕ) : ∃ t, t ∉ seen := by + refine ⟨seen.sup id + 1,?_⟩ + intro h + have hh : seen.sup id + 1 ≤ seen.sup id := Finset.le_sup (f := id) h + omega + +noncomputable def visit (seen : Finset ℕ) : ℕ := Nat.find (exists_missing seen) + +theorem visit_missing (seen : Finset ℕ) : visit seen ∉ seen := Nat.find_spec (exists_missing seen) + +theorem before_visit (seen : Finset ℕ) {t : ℕ} (h : t < visit seen) : t ∈ seen := by + have hh := Nat.find_min (exists_missing seen) h + simpa using hh + +def reset (seen : Finset ℕ) (a : Option ℕ) : Finset ℕ := match a with + | none => seen + | some t => seen.filter (fun i => i ≤ t) + +noncomputable def seen (proposal : ℕ → Finset ℕ → Option ℕ) : ℕ → Finset ℕ + | 0 => ∅ + | s+1 => reset (insert (visit (seen proposal s)) (seen proposal s)) (action proposal s) + +noncomputable def scheduled (proposal : ℕ → Finset ℕ → Option ℕ) (s : ℕ) : ℕ := + visit (seen proposal s) + +theorem reset_preserves {S : Finset ℕ} {a : Option ℕ} {t : ℕ} + (h : t ∈ S) (ha : ∀ i < t, a ≠ some i) : t ∈ reset S a := by + cases he : a with + | none => exact h + | some i => + have hti : t ≤ i := by + by_contra hn + exact ha i (by omega) he + exact Finset.mem_filter.mpr ⟨h,hti⟩ + +theorem seen_persists {proposal : ℕ → Finset ℕ → Option ℕ} {s t : ℕ} + (h : t ∈ seen proposal s) (ha : ∀ i < t, action proposal s ≠ some i) : + t ∈ seen proposal (s+1) := + reset_preserves (Finset.mem_insert_of_mem h) ha + +theorem visit_recorded {proposal : ℕ → Finset ℕ → Option ℕ} {s : ℕ} + (ha : ∀ i < scheduled proposal s, action proposal s ≠ some i) : + scheduled proposal s ∈ seen proposal (s+1) := + reset_preserves (Finset.mem_insert_self _ _) ha + +theorem fill_prefix {proposal : ℕ → Finset ℕ → Option ℕ} {S t : ℕ} + (hS : ∀ s, S ≤ s → ∀ i < t, action proposal s ≠ some i) : + ∀ n, n ≤ t+1 → ∀ j < n, j ∈ seen proposal (S+n) := by + intro n + induction n with + | zero => intro hn j hj; omega + | succ n ih => + intro hn j hj + have hn' : n ≤ t+1 := by omega + have hjt : j ≤ t := by omega + have ha : ∀ i < j, action proposal (S+n) ≠ some i := + fun i hi => hS (S+n) (Nat.le_add_right _ _) i (hi.trans_le hjt) + by_cases hmem : j ∈ seen proposal (S+n) + · exact seen_persists hmem ha + · have hjn : j = n := by + by_contra hne + exact hmem (ih hn' j (by omega)) + have hvis : scheduled proposal (S+n) = j := by + apply Nat.le_antisymm + · exact Nat.find_min' (exists_missing _) hmem + · by_contra hlt + have hvlt : visit (seen proposal (S+n)) < n := by + change ¬ j ≤ scheduled proposal (S+n) at hlt + dsimp only [scheduled] at hlt + omega + exact visit_missing _ (ih hn' _ hvlt) + have hv := visit_recorded (proposal := proposal) (s := S+n) (by simpa [hvis] using ha) + simpa [hvis,Nat.add_assoc] using hv + +theorem eventually_seen (proposal : ℕ → Finset ℕ → Option ℕ) (t : ℕ) : + ∃ S, ∀ s, S ≤ s → t ∈ seen proposal s := by + obtain ⟨S,hS⟩ := finite_injury proposal t + have ht := fill_prefix hS (t+1) le_rfl t (Nat.lt_succ_self t) + refine ⟨S+(t+1),fun s hs => ?_⟩ + induction s,hs using Nat.le_induction with + | base => exact ht + | succ s hs ih => exact seen_persists ih (hS s ((Nat.le_add_right S (t+1)).trans hs)) + +theorem seen_witness {proposal : ℕ → Finset ℕ → Option ℕ} {s t : ℕ} + (h : t ∈ seen proposal s) : ∃ v, v < s ∧ scheduled proposal v = t ∧ + ∀ u, v ≤ u → u < s → ∀ i < t, action proposal u ≠ some i := by + induction s with + | zero => simp [seen] at h + | succ s ih => + have hmem : t ∈ insert (scheduled proposal s) (seen proposal s) := by + cases ha : action proposal s with + | none => simpa [seen,ha,reset,scheduled] using h + | some i => exact (Finset.mem_filter.mp (show t ∈ (insert (scheduled proposal s) + (seen proposal s)).filter (fun j => j ≤ i) by simpa [seen,ha,reset,scheduled] using h)).1 + have hsafe : ∀ i < t, action proposal s ≠ some i := by + intro i hi he + have hh : t ≤ i := (Finset.mem_filter.mp (show t ∈ (insert (scheduled proposal s) + (seen proposal s)).filter (fun j => j ≤ i) by simpa [seen,he,reset,scheduled] using h)).2 + omega + rcases Finset.mem_insert.mp hmem with he | hm + · refine ⟨s,Nat.lt_succ_self s,he.symm,fun u hu hus i hi => ?_⟩ + have hue : u = s := by omega + exact hue ▸ hsafe i hi + · obtain ⟨v,hv,he,hkeep⟩ := ih hm + refine ⟨v,hv.trans (Nat.lt_succ_self s),he,fun u hu hus i hi => ?_⟩ + by_cases hue : u = s + · exact hue ▸ hsafe i hi + · exact hkeep u hu (by omega) i hi + +theorem surviving_visit (proposal : ℕ → Finset ℕ → Option ℕ) (t : ℕ) : + ∃ v, scheduled proposal v = t ∧ + ∀ u, v ≤ u → ∀ i < t, action proposal u ≠ some i := by + obtain ⟨S,hS⟩ := finite_injury proposal t + have ht := fill_prefix hS (t+1) le_rfl t (Nat.lt_succ_self t) + obtain ⟨v,hv,he,hkeep⟩ := seen_witness ht + refine ⟨v,he,fun u hu i hi => ?_⟩ + by_cases hus : u < S+(t+1) + · exact hkeep u hu hus i hi + · exact hS u (by omega) i hi + +end TuringRigidity.FiniteInjurySchedule + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteJoinSections.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteJoinSections.lean new file mode 100644 index 0000000000000000000000000000000000000000..023fbfed79c7842eeeab4cdf61ee81b15402e8b4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteJoinSections.lean @@ -0,0 +1,108 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticPrefixForcing + +namespace OAI + + +namespace TuringRigidity.FiniteJoinSections +open FiniteShuffle ShuffleRequirements ArithmeticPrefixForcing + +def Cover (s t u : List Bool) : Prop := + u.length ≤ 2 * s.length ∧ u.length ≤ 2 * t.length ∧ + Realizes u (join (fun i => s.getD i false) (fun i => t.getD i false)) + +theorem cover_realizes {s t u : List Bool} {A B : Oracle} + (h : Cover s t u) (hs : Realizes s A) (ht : Realizes t B) : + Realizes u (join A B) := by + have hlenS := h.1 + have hlenT := h.2.1 + intro i hi + rw [h.2.2 i hi] + simp only [join] + split + · exact ht (i / 2) (by omega) + · exact hs (i / 2) (by omega) + +theorem cover_mono {s t u s' t' : List Bool} (h : Cover s t u) + (hs : s <+: s') (ht : t <+: t') : Cover s' t' u := by + have hlenS := h.1 + have hlenT := h.2.1 + refine ⟨by have := hs.length_le; omega, by have := ht.length_le; omega, ?_⟩ + exact cover_realizes h (realizes_mono hs (realizes_default s')) + (realizes_mono ht (realizes_default t')) + +def Product (D : List Bool → Prop) (s t : List Bool) : Prop := + ∃ u, D u ∧ Cover s t u + +theorem product_mono {D : List Bool → Prop} {s t s' t' : List Bool} + (h : Product D s t) (hs : s <+: s') (ht : t <+: t') : Product D s' t' := by + obtain ⟨u,hu,hc⟩ := h + exact ⟨u,hu,cover_mono hc hs ht⟩ + +theorem product_realizes {D : List Bool → Prop} {s t : List Bool} {A B : Oracle} + (h : Product D s t) (hs : Realizes s A) (ht : Realizes t B) : + join A B ∈ OpenSet D := by + obtain ⟨u,hu,hc⟩ := h + exact ⟨u,hu,cover_realizes hc hs ht⟩ + +theorem product_dense {D : List Bool → Prop} (hD : DenseOpen D) + (s t : List Bool) : + ∃ s' t', s <+: s' ∧ t <+: t' ∧ Product D s' t' := by + let A : Oracle := fun i => s.getD i false + let B : Oracle := fun i => t.getD i false + let n := max s.length t.length + obtain ⟨u,hu,hDu⟩ := hD.1 (initial (join A B) (2 * n)) + let C : Oracle := fun i => u.getD i false + let A' : Oracle := fun i => C (2 * i) + let B' : Oracle := fun i => C (2 * i + 1) + have hc : Agree (2 * n) (join A B) C := agree_of_prefix hu + have hlen : 2 * n ≤ u.length := by simpa using hu.length_le + have hjoin : join A' B' = C := by + funext i + rcases Nat.mod_two_eq_zero_or_one i with hi | hi + · have he : i = 2 * (i / 2) := by omega + rw [he, join_even] + · have he : i = 2 * (i / 2) + 1 := by omega + rw [he, join_odd] + refine ⟨initial A' u.length, initial B' u.length, ?_, ?_, u, hDu, ?_⟩ + · rw [←prefix_default s] + apply initial_prefix (by dsimp [n] at hlen; omega) + intro i hi + exact (join_even A B i).symm.trans (hc (2 * i) (by dsimp [n]; omega)) + · rw [←prefix_default t] + apply initial_prefix (by dsimp [n] at hlen; omega) + intro i hi + exact (join_odd A B i).symm.trans (hc (2 * i + 1) (by dsimp [n]; omega)) + · refine ⟨by simp; omega, by simp; omega, ?_⟩ + have hr : Realizes u (join A' B') := hjoin ▸ realizes_default u + intro i hi + rw [hr i hi] + simp only [join] + split <;> exact (prefix_getD _ _ _ (by omega)).symm + +def Section (D : List Bool → Prop) (t s : List Bool) : Prop := + ∃ t', t <+: t' ∧ Product D s t' + +theorem section_dense {D : List Bool → Prop} (hD : DenseOpen D) (t : List Bool) : + DenseOpen (Section D t) := by + constructor + · intro s + obtain ⟨s',t',hs,ht,h⟩ := product_dense hD s t + exact ⟨s',hs,t',ht,h⟩ + · rintro s s' hs ⟨t',ht,h⟩ + exact ⟨t',ht,product_mono h hs List.prefix_rfl⟩ + +def Fiber (D : List Bool → Prop) (A : Oracle) (t : List Bool) : Prop := + ∃ s, Realizes s A ∧ Product D s t + +theorem fiber_dense {D : List Bool → Prop} {A : Oracle} + (hA : ∀ t, A ∈ OpenSet (Section D t)) : DenseOpen (Fiber D A) := by + constructor + · intro t + obtain ⟨s,⟨t',ht,h⟩,hs⟩ := hA t + exact ⟨t',ht,s,hs,h⟩ + · rintro t t' ht ⟨s,hs,h⟩ + exact ⟨s,hs,product_mono h List.prefix_rfl ht⟩ + +end TuringRigidity.FiniteJoinSections + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteNaturalGraph.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteNaturalGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..383e585cc8ce0778e1798e3941b807dbad82938b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteNaturalGraph.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelNaturalNumbers + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +noncomputable def finiteNaturalGraph (f : ℕ → ℕ) : ℕ → ZFSet.{u} + | 0 => {ZFSet.pair (natSet 0) (natSet (f 0))} + | n+1 => finiteNaturalGraph f n ∪ ({ZFSet.pair (natSet (n+1)) (natSet (f (n+1)))} : ZFSet.{u}) + +theorem mem_finiteNaturalGraph (f : ℕ → ℕ) (n : ℕ) (z : ZFSet.{u}) : + z ∈ finiteNaturalGraph f n ↔ ∃ i, i ≤ n ∧ z = ZFSet.pair (natSet i) (natSet (f i)) := by + induction n with + | zero => + rw [finiteNaturalGraph,ZFSet.mem_singleton] + constructor + · intro h; exact ⟨0,le_rfl,h⟩ + · rintro ⟨i,hi,h⟩ + have he : i = 0 := Nat.eq_zero_of_le_zero hi + simpa only [he] using h + | succ n ih => + rw [finiteNaturalGraph,ZFSet.mem_union,ZFSet.mem_singleton,ih] + constructor + · rintro (⟨i,hi,hz⟩|hz) + · exact ⟨i,Nat.le_succ_of_le hi,hz⟩ + · exact ⟨n+1,le_rfl,hz⟩ + · rintro ⟨i,hi,hz⟩ + by_cases hin : i ≤ n + · exact Or.inl ⟨i,hin,hz⟩ + · have he : i = n+1 := by omega + exact Or.inr (he ▸ hz) + +theorem finiteNaturalGraph_pair (f : ℕ → ℕ) (n i : ℕ) (y : ZFSet.{u}) : + ZFSet.pair (natSet i) y ∈ finiteNaturalGraph f n ↔ i ≤ n ∧ y = natSet (f i) := by + rw [mem_finiteNaturalGraph] + constructor + · rintro ⟨j,hj,he⟩ + obtain ⟨hij,hy⟩ := ZFSet.pair_inj.mp he + have heq := natSet_injective hij + subst j + exact ⟨hj,hy⟩ + · rintro ⟨hi,rfl⟩ + exact ⟨i,hi,rfl⟩ + +theorem finiteNaturalGraph_function (f : ℕ → ℕ) (n : ℕ) : + TransitiveNameModel.FunctionGraph (natSet (n+1)) ZFSet.omega (finiteNaturalGraph.{u} f n) := by + constructor + · intro z hz + obtain ⟨i,hi,rfl⟩ := (mem_finiteNaturalGraph f n z).mp hz + exact ⟨natSet i,(natSet_mem_natSet i (n+1)).mpr (by omega),natSet (f i), + (mem_omega _).mpr ⟨f i,rfl⟩,rfl⟩ + · intro x hx + obtain ⟨i,hi,rfl⟩ := (mem_natSet (n+1) x).mp hx + have hin : i ≤ n := by omega + refine ⟨natSet (f i),(mem_omega _).mpr ⟨f i,rfl⟩, + (finiteNaturalGraph_pair f n i _).mpr ⟨hin,rfl⟩,?_⟩ + intro y _ hy + exact ((finiteNaturalGraph_pair f n i y).mp hy).2 + +theorem finiteNaturalGraph_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hω : ZFSet.omega.{u} ∈ M) + (f : ℕ → ℕ) (n : ℕ) : finiteNaturalGraph f n ∈ M := by + have hn (i : ℕ) : natSet.{u} i ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨i,rfl⟩) + induction n with + | zero => exact singleton_mem M hM hP (orderedPair_mem M hM hP (hn 0) (hn (f 0))) + | succ n ih => + exact binary_union_mem M hM hP hU ih + (singleton_mem M hM hP (orderedPair_mem M hM hP (hn (n+1)) (hn (f (n+1))))) + +theorem internal_finite_natural_graph_bound (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hω : ZFSet.omega.{u} ∈ M) : + ∃ Q ∈ M, (∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ ZFSet.prod ZFSet.omega ZFSet.omega) ∧ + ∀ f : ℕ → ℕ, ∀ n, finiteNaturalGraph f n ∈ Q := by + obtain ⟨Q,hQ,hQdef⟩ := internal_power M hM hPow (product_mem M hM hP hU hPow hS hω hω) + refine ⟨Q,hQ,hQdef,?_⟩ + intro f n + apply (hQdef _).mpr + refine ⟨finiteNaturalGraph_mem M hM hP hU hω f n,?_⟩ + intro z hz + obtain ⟨i,_,rfl⟩ := (mem_finiteNaturalGraph f n z).mp hz + exact ZFSet.mem_prod.mpr ⟨_,(mem_omega _).mpr ⟨i,rfl⟩,_,(mem_omega _).mpr ⟨f i,rfl⟩,rfl⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteOverwrite.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteOverwrite.lean new file mode 100644 index 0000000000000000000000000000000000000000..e16741c65efe6940e8420b8358aa079949ea8721 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteOverwrite.lean @@ -0,0 +1,75 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformOracleSimulation +import OAI.Computability.DegreeRigidity.Effective.FiniteShuffle + +namespace OAI + + +namespace TuringRigidity.FiniteOverwrite +open UniformPrograms + +def overwrite (s : List Bool) (A : Oracle) (n : ℕ) : Bool := + if n < s.length then s.getD n false else A n + +theorem overwrite_below (s : List Bool) (A : Oracle) (n : ℕ) (hn : n < s.length) : + overwrite s A n = s.getD n false := by simp [overwrite,hn] + +theorem overwrite_above (s : List Bool) (A : Oracle) (n : ℕ) (hn : s.length ≤ n) : + overwrite s A n = A n := by simp [overwrite,Nat.not_lt.mpr hn] + +theorem overwrite_program (s : List Bool) : + Runs oracleFunction (fun A => oracleFunction (overwrite s A)) := by + have hp : Primrec (fun z : ℕ => + if (Nat.unpair z).1 < s.length then + (if s.getD (Nat.unpair z).1 false then 1 else 0) else (Nat.unpair z).2) := + Primrec.ite (Primrec.nat_lt.comp (Primrec.fst.comp Primrec.unpair) (Primrec.const s.length)) + (Primrec.ite (Primrec.eq.comp ((Primrec.list_getD false).comp (Primrec.const s) + (Primrec.fst.comp Primrec.unpair)) (Primrec.const true)) (Primrec.const 1) (Primrec.const 0)) + (Primrec.snd.comp Primrec.unpair) + have hq : Runs oracleFunction (fun A n => Part.some (if A n then 1 else 0)) := query + apply (total_comp (primrec hp) (total_pair (primrec Primrec.id) hq)).of_eq + intro A n + simp only [Nat.unpair_pair,oracleFunction,overwrite,id_eq] + split <;> rfl + +theorem overwrite_reduces (s : List Bool) (A : Oracle) : Reduces (overwrite s A) A := by + obtain ⟨p,hp⟩ := overwrite_program s + exact (OracleCode.turingReducible_iff_exists_code _ _).mpr ⟨p,hp A⟩ + +theorem restore_initial (s : List Bool) (A : Oracle) : + overwrite (FiniteShuffle.initial A s.length) (overwrite s A) = A := by + funext n + by_cases hn : n < s.length + · rw [overwrite_below _ _ _ (by simpa using hn),FiniteShuffle.prefix_getD _ _ _ hn] + · simp [overwrite,hn] + +theorem degree_overwrite (s : List Bool) (A : Oracle) : degree (overwrite s A) = degree A := by + apply (degree_eq_iff _ _).mpr + exact ⟨overwrite_reduces s A,by + simpa only [restore_initial] using + overwrite_reduces (FiniteShuffle.initial A s.length) (overwrite s A)⟩ + +theorem overwrite_join_program (s : List Bool) (R : Oracle) : + Runs (fun A => oracleFunction (join A R)) + (fun A => oracleFunction (join (overwrite s A) R)) := by + have hp : Primrec (fun z : ℕ => + if (Nat.unpair z).1.bodd = false ∧ (Nat.unpair z).1 / 2 < s.length then + (if s.getD ((Nat.unpair z).1 / 2) false then 1 else 0) else (Nat.unpair z).2) := + Primrec.ite + ((Primrec.eq.comp (Primrec.nat_bodd.comp (Primrec.fst.comp Primrec.unpair)) + (Primrec.const false)).and + (Primrec.nat_lt.comp (Primrec.nat_div.comp (Primrec.fst.comp Primrec.unpair) + (Primrec.const 2)) (Primrec.const s.length))) + (Primrec.ite (Primrec.eq.comp ((Primrec.list_getD false).comp (Primrec.const s) + (Primrec.nat_div.comp (Primrec.fst.comp Primrec.unpair) (Primrec.const 2))) (Primrec.const true)) + (Primrec.const 1) (Primrec.const 0)) + (Primrec.snd.comp Primrec.unpair) + have hq : Runs (fun A => oracleFunction (join A R)) + (fun A n => Part.some (if join A R n then 1 else 0)) := query + apply (total_comp (primrec hp) (total_pair (primrec Primrec.id) hq)).of_eq + intro A n + cases hb : n.bodd <;> by_cases hn : n / 2 < s.length <;> + simp [oracleFunction,join,overwrite,hb,hn] + +end TuringRigidity.FiniteOverwrite + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteOverwriteHull.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteOverwriteHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b0df01c5429b42841390e9d3c5ae85fac3c43d6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteOverwriteHull.lean @@ -0,0 +1,50 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.CohenPrefixHull +import OAI.Computability.DegreeRigidity.Representation.GroundPrefixOverwrite + +namespace OAI + + +namespace TuringRigidity.FiniteOverwriteHull +open TransitiveNameModel BoundedSetTheory RealGeneratedModel FiniteOverwrite +open CountableForcing InternalCohen CohenBorelForcing +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem contains_iff_of_degree (M N : ZFSet.{0}) (A B : Oracle) + (he : degree A = degree B) : Contains M (realCode A) N ↔ Contains M (realCode B) N := by + obtain ⟨hAB,hBA⟩ := (degree_eq_iff A B).mp he + constructor + · rintro ⟨hN,hT,hMN,hA⟩ + exact ⟨hN,hT,hMN,sourceT_real_lower N hN hT hA hBA⟩ + · rintro ⟨hN,hT,hMN,hB⟩ + exact ⟨hN,hT,hMN,sourceT_real_lower N hN hT hB hAB⟩ + +theorem hull_eq_of_degree (M : ZFSet.{0}) (A B : Oracle) + (he : degree A = degree B) : RealGeneratedModel.hull M (realCode A) = RealGeneratedModel.hull M (realCode B) := by + classical + have hc := fun N => contains_iff_of_degree M N A B he + by_cases hA : ∃ N, Contains M (realCode A) N + · have hB : ∃ N, Contains M (realCode B) N := + ⟨hA.choose,(hc _).mp hA.choose_spec⟩ + apply ZFSet.ext + intro z + rw [mem_hull M _ z hA,mem_hull M _ z hB] + exact ⟨fun h N hN => h N ((hc N).mpr hN),fun h N hN => h N ((hc N).mp hN)⟩ + · have hB : ¬ ∃ N, Contains M (realCode B) N := fun h => + hA ⟨h.choose,(hc _).mpr h.choose_spec⟩ + simp only [RealGeneratedModel.hull,dite_eq_right hA,dite_eq_right hB] + +theorem overwrite_hull (M : ZFSet.{0}) (s : List Bool) (A : Oracle) : + RealGeneratedModel.hull M (realCode (overwrite s A)) = RealGeneratedModel.hull M (realCode A) := + hull_eq_of_degree M _ _ (degree_overwrite s A) + +theorem overwrite_extension (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (A : Oracle) (hA : AtomicForcing.GroundGeneric M (pushFilter (realFilter A))) + (s : List Bool) : + genericExtensionSet M conditions (pushFilter (realFilter (overwrite s A))).carrier = + genericExtensionSet M conditions (pushFilter (realFilter A)).carrier := by + exact prefix_extension_eq_of_hull M hM hT _ _ + (GroundPrefixOverwrite.overwrite_generic M hM hT A hA s) hA (overwrite_hull M s A) + +end TuringRigidity.FiniteOverwriteHull + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteRealPacking.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteRealPacking.lean new file mode 100644 index 0000000000000000000000000000000000000000..ffbf153bce5cf107e77412ab1af8de1883e56b8f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteRealPacking.lean @@ -0,0 +1,42 @@ +import OAI.Computability.DegreeRigidity.Representation.GroundDegreePresentation + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory +universe u + +def packedReal : {n : ℕ} → (Fin n → Oracle) → Oracle + | 0, _ => FixedArithmetic.zero + | n+1, v => join (v 0) (packedReal (fun i : Fin n => v i.succ)) + +def realPart (P : Oracle) : ℕ → Oracle + | 0 => fun k => P (2*k) + | i+1 => realPart (fun k => P (2*k+1)) i + +theorem realPart_packed {n : ℕ} (v : Fin n → Oracle) (i : Fin n) : + realPart (packedReal v) i = v i := by + induction n with + | zero => exact Fin.elim0 i + | succ n ih => + refine Fin.cases ?_ (fun j => ?_) i + · funext k + simp [realPart,packedReal,join] + · have ht : (fun k => packedReal v (2*k+1)) = packedReal (fun j : Fin n => v j.succ) := by + funext k + simp [packedReal,join,Nat.add_div] + change realPart (fun k => packedReal v (2*k+1)) j = v j.succ + rw [ht] + exact ih _ j + +theorem packedReal_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {n : ℕ} (v : Fin n → Oracle) (hv : ∀ i, v i ∈ modelReals M) : + packedReal v ∈ modelReals M := by + induction n with + | zero => exact sourceT_zero_real M hM hT + | succ n ih => exact sourceT_real_join M hM hT (hv 0) (ih _ (fun i => hv i.succ)) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteShuffle.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteShuffle.lean new file mode 100644 index 0000000000000000000000000000000000000000..a67883414e3181aca7273ef29deb866a211487a0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteShuffle.lean @@ -0,0 +1,236 @@ +import OAI.Computability.DegreeRigidity.Representation.GenericCoding +import OAI.Computability.DegreeRigidity.Representation.BorelGeneric + +namespace OAI + +namespace TuringRigidity.FiniteShuffle +open GenericCoding UniformOracle BinarySeries + +def Agree (n : ℕ) (A B : Oracle) : Prop := ∀ i, i < n → A i = B i + +theorem Agree.mono {n m : ℕ} {A B : Oracle} (h : Agree n A B) (hm : m ≤ n) : + Agree m A B := fun i hi => h i (by omega) + +theorem Agree.symm {n : ℕ} {A B : Oracle} (h : Agree n A B) : Agree n B A := + fun i hi => (h i hi).symm + +theorem Agree.trans {n : ℕ} {A B C : Oracle} (h : Agree n A B) (h' : Agree n B C) : + Agree n A C := fun i hi => (h i hi).trans (h' i hi) + +def initial (A : Oracle) (n : ℕ) : List Bool := (List.range n).map A + +@[simp] theorem prefix_length (A : Oracle) (n : ℕ) : (initial A n).length = n := by + simp [initial] + +@[simp] theorem prefix_getD (A : Oracle) (n i : ℕ) (hi : i < n) : + (initial A n).getD i false = A i := by + simp [initial,List.getD,hi] + +theorem prefix_default (s : List Bool) : initial (fun i => s.getD i false) s.length = s := by + apply List.ext_getElem + · simp + · intro i hi hj + simp [initial,List.getD,hj] + +theorem prefix_agree {A B : Oracle} {n : ℕ} (h : Agree n A B) : initial A n = initial B n := by + apply List.ext_getElem + · simp + · intro i hi hj + have hi' : i < n := by simpa using hi + simpa [initial] using h i hi' + +def OddBound (n : ℕ) (G : Oracle) : Prop := ∀ i, n ≤ i → G (2*i+1) = false + +theorem count_agree {n : ℕ} {G H : Oracle} (h : ∀ i, i < n → G (2*i+1) = H (2*i+1)) : + count G n = count H n := by + induction n with + | zero => rfl + | succ n ih => + change count G n + bit G (2*n+1) = count H n + bit H (2*n+1) + rw [ih (fun i hi => h i (by omega))] + simp [bit,h n (by omega)] + +theorem count_constant {n : ℕ} {G : Oracle} (h : OddBound n G) {m : ℕ} (hm : n ≤ m) : + count G m = count G n := by + induction m, hm using Nat.le_induction with + | base => rfl + | succ m hm ih => + change count G m + bit G (2*m+1) = count G n + simp [bit,h m hm,ih] + +theorem code_agree {n : ℕ} {A B G H : Oracle} (ha : Agree n A B) (hg : Agree (2*n) G H) : + Agree n (code A G) (code B H) := by + intro i hi + have hc : count G i = count H i := count_agree (fun j hj => hg (2*j+1) (by omega)) + have ho := hg (2*i+1) (by omega) + have hl := count_le G i + simp only [code,←hc,←ho] + split + · exact ha _ (by omega) + · exact hg _ (by omega) + +theorem code_agree_inserted {n : ℕ} {A B G : Oracle} (hg : OddBound n G) (ha : Agree n A B) : + code A G = code B G := by + funext i + unfold code + split + · rename_i hb + have hi : i < n := by + by_contra hi + have := hg i (by omega) + simp_all + exact ha _ (lt_of_le_of_lt (count_le G i) hi) + · rfl + +def freeze (n : ℕ) (G : Oracle) : Oracle := + join (fun i => G (2*i)) (fun i => if i < n then G (2*i+1) else false) + +theorem freeze_bound (n : ℕ) (G : Oracle) : OddBound n (freeze n G) := by + intro i hi + simp [freeze,show ¬i if i < n then G (2*i) else T (i + count G n)) (fun i => G (2*i+1)) + +theorem extendEven_count (n : ℕ) (G T : Oracle) (i : ℕ) : + count (extendEven n G T) i = count G i := + count_agree (fun j hj => by simp [extendEven]) + +theorem extendEven_agree (n : ℕ) (G T : Oracle) : Agree (2*n) G (extendEven n G T) := by + apply agree_of_columns + · intro i hi; simp [extendEven,hi] + · intro i hi; simp [extendEven] + +theorem extendEven_bound {k n : ℕ} {G T : Oracle} (hg : OddBound k G) : + OddBound k (extendEven n G T) := by + intro i hi + simpa [extendEven] using hg i hi + +theorem extendEven_code (n : ℕ) (A G T : Oracle) (hg : OddBound n G) + (ht : Agree (n + count G n) (code A G) T) : code A (extendEven n G T) = T := by + funext i + simp only [code] + rw [extendEven_count] + simp only [extendEven,join_odd,join_even] + have hcn := count_le G n + by_cases hi : i < n + count G n + · rw [←ht i hi] + unfold code + split + · rfl + · have hsub : i - count G i < n := by + by_cases hin : i < n + · omega + · rw [count_constant hg (by omega)] + omega + simp [hsub] + · have hin : n ≤ i := by omega + have hc := count_constant hg hin + rw [hg i hin] + simp only [Bool.false_eq_true,↓reduceIte,hc] + have hl := count_le G n + have hn : ¬i-count G n t.getD i false) := by + obtain ⟨u,hu⟩ := h + intro i hi + rw [←hu] + simpa [List.getD,List.getElem?_append,hi] using (prefix_getD A n i hi).symm + +def DenseOpen (D : List Bool → Prop) : Prop := + (∀ s, ∃ t, s <+: t ∧ D t) ∧ (∀ s t, s <+: t → D s → D t) + +theorem odd_null_extension (D : List Bool → Prop) (hd : DenseOpen D) + (n : ℕ) (A G : Oracle) (hg : OddBound n G) : + ∃ m H, n < m ∧ Agree (2*n) G H ∧ + (∀ i, H (2*i+1) = G (2*i+1)) ∧ D (initial (code A H) m) := by + obtain ⟨t,ht,hD⟩ := hd.1 (initial (code A G) (n + count G n + 1)) + let T : Oracle := fun i => t.getD i false + have ha : Agree (n + count G n) (code A G) T := + (agree_of_prefix ht).mono (by omega) + have he := extendEven_code n A G T hg ha + refine ⟨t.length,extendEven n G T,?_,extendEven_agree n G T,?_,?_⟩ + · have hl := ht.length_le + simp only [prefix_length] at hl + omega + · intro i; simp [extendEven] + · rw [he] + change D (initial (fun i => t.getD i false) t.length) + rw [prefix_default] + exact hD + +theorem finite_extension (D : List Bool → Prop) (hd : DenseOpen D) + (S : Finset Oracle) (n : ℕ) (G : Oracle) (hg : OddBound n G) : + ∃ m H, n ≤ m ∧ Agree (2*n) G H ∧ + (∀ i, H (2*i+1) = G (2*i+1)) ∧ + ∀ A ∈ S, ∃ l, l ≤ m ∧ D (initial (code A H) l) := by + classical + induction S using Finset.induction_on generalizing n G with + | empty => exact ⟨n,G,le_rfl,fun _ _ => rfl,fun _ => rfl,by simp⟩ + | @insert A S hAS ih => + obtain ⟨m,H,hnm,hGH,hoH,hS⟩ := ih n G hg + have hb : OddBound m H := by + intro i hi + rw [hoH i] + exact hg i (by omega) + obtain ⟨k,K,hmk,hHK,hoK,hD⟩ := odd_null_extension D hd m A H hb + refine ⟨k,K,by omega,hGH.trans (hHK.mono (by omega)), + fun i => (hoK i).trans (hoH i),?_⟩ + intro B hB + rcases Finset.mem_insert.mp hB with rfl | hB + · exact ⟨k,le_rfl,hD⟩ + · obtain ⟨l,hl,hDl⟩ := hS B hB + refine ⟨l,by omega,?_⟩ + have hc : Agree l (code B H) (code B K) := + code_agree (fun _ _ => rfl) (hHK.mono (by omega)) + rwa [←prefix_agree hc] + +theorem all_extension (D : List Bool → Prop) (hd : DenseOpen D) (n : ℕ) (G : Oracle) : + ∃ m H, n ≤ m ∧ Agree (2*n) G H ∧ OddBound n H ∧ + ∀ A, ∃ l, l ≤ m ∧ D (initial (code A H) l) := by + classical + let f : (Fin n → Bool) → Oracle := fun s i => if hi : i < n then s ⟨i,hi⟩ else false + let S : Finset Oracle := Finset.univ.image f + obtain ⟨m,H,hnm,hGH,ho,hS⟩ := finite_extension D hd S n (freeze n G) (freeze_bound n G) + have hb : OddBound n H := fun i hi => (ho i).trans (freeze_bound n G i hi) + refine ⟨m,H,hnm,(freeze_agree n G).trans hGH,hb,?_⟩ + intro A + let a : Fin n → Bool := fun i => A i + have ha : f a ∈ S := Finset.mem_image.mpr ⟨a,Finset.mem_univ _,rfl⟩ + obtain ⟨l,hl,hD⟩ := hS (f a) ha + have he : code (f a) H = code A H := code_agree_inserted hb (by + intro i hi + simp [f,a,hi]) + exact ⟨l,hl,by simpa [he] using hD⟩ + +end TuringRigidity.FiniteShuffle + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteShuffleCertificate.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteShuffleCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..262465f27c36d3cf278028563d69e95cc24ce0c5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteShuffleCertificate.lean @@ -0,0 +1,55 @@ +import OAI.Computability.DegreeRigidity.SetModels.ShuffleRequirements + +namespace OAI + + +namespace TuringRigidity.FiniteShuffleCertificate +open FiniteShuffle ShuffleRequirements GenericCoding + +def Certificate (D : List Bool → Prop) (q : List Bool) : Prop := + ∃ k : ℕ, 2*k ≤ q.length ∧ ∀ s : List Bool, s.length = k → + ∃ l ≤ k, D (initial (code (fun i => s.getD i false) (fun i => q.getD i false)) l) + +theorem certificate_transfer (D : List Bool → Prop) (q : List Bool) + (h : Certificate D q) : Transfer D q := by + obtain ⟨k,hk,hs⟩ := h + intro A + obtain ⟨l,hl,hD⟩ := hs (initial A k) (prefix_length A k) + refine ⟨_,hD,fun G hG => ?_⟩ + apply (realizes_initial _ _ _).mpr + apply code_agree + · intro i hi + exact prefix_getD A k i (lt_of_lt_of_le hi hl) + · exact hG.mono (by omega) + +theorem certificate_mono (D : List Bool → Prop) {q r : List Bool} + (hqr : q <+: r) (h : Certificate D q) : Certificate D r := by + obtain ⟨k,hk,hs⟩ := h + refine ⟨k,hk.trans hqr.length_le,fun s hsk => ?_⟩ + obtain ⟨l,hl,hD⟩ := hs s hsk + refine ⟨l,hl,?_⟩ + have he : Agree l (code (fun i => s.getD i false) (fun i => q.getD i false)) + (code (fun i => s.getD i false) (fun i => r.getD i false)) := + code_agree (fun _ _ => rfl) (fun i hi => getD_of_prefix hqr i (by omega)) + rwa [←prefix_agree he] + +theorem certificate_denseOpen (D : List Bool → Prop) (hD : DenseOpen D) : + DenseOpen (Certificate D) := by + refine ⟨?_,fun _ _ hqr h => certificate_mono D hqr h⟩ + intro p + let G : Oracle := fun i => p.getD i false + obtain ⟨m,H,hn,hGH,_,hall⟩ := all_extension D hD (p.length+1) G + let q := initial H (2*m) + refine ⟨q,?_,m,by simp [q],fun s _ => ?_⟩ + · rw [←prefix_default p] + exact initial_prefix (by omega) (hGH.mono (by omega)) + · obtain ⟨l,hl,hDl⟩ := hall (fun i => s.getD i false) + refine ⟨l,hl,?_⟩ + have he : Agree l (code (fun i => s.getD i false) (fun i => q.getD i false)) + (code (fun i => s.getD i false) H) := + code_agree (fun _ _ => rfl) (fun i hi => prefix_getD H (2*m) i (by omega)) + rwa [prefix_agree he] + +end TuringRigidity.FiniteShuffleCertificate + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteShuffleComputation.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteShuffleComputation.lean new file mode 100644 index 0000000000000000000000000000000000000000..29aa4d8f2deee1f29b78413d369ccbcffbada05c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteShuffleComputation.lean @@ -0,0 +1,62 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteShuffleCertificate +import OAI.Computability.DegreeRigidity.CohenForcing.EncodedForcing + +namespace OAI + + +namespace TuringRigidity.FiniteShuffleComputation +open Encodable EncodedForcing GenericCoding FiniteShuffle UniformOracle BinarySeries + +theorem wordCount_primrec : + Primrec₂ (fun (p : List Bool) n => count (fun i => p.getD i false) n) := by + have hs : Primrec (fun z : List Bool × ℕ × ℕ => + z.2.2 + if z.1.getD (2*z.2.1+1) false then 1 else 0) := + Primrec.nat_add.comp (Primrec.snd.comp Primrec.snd) + (Primrec.ite (Primrec.eq.comp ((Primrec.list_getD false).comp Primrec.fst + (Primrec.succ.comp (Primrec.nat_mul.comp (Primrec.const 2) + (Primrec.fst.comp Primrec.snd)))) (Primrec.const true)) + (Primrec.const 1) (Primrec.const 0)) + exact (Primrec.nat_rec (Primrec.const 0) hs.to₂).of_eq (fun p n => by + induction n with + | zero => rfl + | succ n ih => + change _ + _ = count (fun i => p.getD i false) n + bit (fun i => p.getD i false) (2*n+1) + rw [ih] + rfl) + +theorem wordShuffleBit_primrec : + Primrec (fun z : List Bool × List Bool × ℕ => + code (fun i => z.1.getD i false) (fun i => z.2.1.getD i false) z.2.2) := by + let hp : Primrec (fun z : List Bool × List Bool × ℕ => z.2.1) := + Primrec.fst.comp Primrec.snd + let hn : Primrec (fun z : List Bool × List Bool × ℕ => z.2.2) := + Primrec.snd.comp Primrec.snd + have hc := wordCount_primrec.comp hp hn + exact Primrec.ite (Primrec.eq.comp ((Primrec.list_getD false).comp hp + (Primrec.succ.comp (Primrec.nat_mul.comp (Primrec.const 2) hn))) (Primrec.const true)) + ((Primrec.list_getD false).comp Primrec.fst hc) + ((Primrec.list_getD false).comp hp + (Primrec.nat_mul.comp (Primrec.const 2) (Primrec.nat_sub.comp hn hc))) + +def finiteShuffleWord (u v l : ℕ) : ℕ := + encode (initial (code (fun i => (word u).getD i false) + (fun i => (word v).getD i false)) l) + +theorem finiteShuffleWord_primrec : + Primrec (fun z : ℕ => finiteShuffleWord (Nat.unpair z).1 + (Nat.unpair (Nat.unpair z).2).1 (Nat.unpair (Nat.unpair z).2).2) := by + let hu := Primrec.fst.comp Primrec.unpair + let hv := Primrec.fst.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)) + let hl := Primrec.snd.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)) + exact Primrec.encode.comp (Primrec.list_map (Primrec.list_range.comp hl) + (wordShuffleBit_primrec.comp ((word_primrec.comp (hu.comp Primrec.fst)).pair + ((word_primrec.comp (hv.comp Primrec.fst)).pair Primrec.snd))).to₂) + +theorem finiteShuffleWord_encode (s q : List Bool) (l : ℕ) : + finiteShuffleWord (encode s) (encode q) l = + encode (initial (code (fun i => s.getD i false) (fun i => q.getD i false)) l) := by + simp [finiteShuffleWord,word] + +end TuringRigidity.FiniteShuffleComputation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteSumDomains.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteSumDomains.lean new file mode 100644 index 0000000000000000000000000000000000000000..86d42e5022560f644d9ef8a5490b2ff4b90141d8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteSumDomains.lean @@ -0,0 +1,69 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.TrimmedSumDomains + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +theorem sum_domain_at_successor_of_subset (R : ZFSet.{u}) (γ : Ordinal.{u}) + {a b : ZFSet.{u}} + (ha : a ∈ level R γ) (hb : b ∈ level R γ) + (h0 : (∅ : ZFSet.{u}) ∈ level R γ) (h1 : ({∅} : ZFSet.{u}) ∈ level R γ) + (hd : sumDomain a b ⊆ level R γ) : + sumDomain a b ∈ level R (γ+1) := by + let e := cons a (cons b (cons ∅ (fun _ => {∅}))) + have he (i : ℕ) : e i ∈ level R γ := by + rcases i with _|_|_|i; exact ha; exact hb; exact h0; exact h1 + apply defined_set_at_successor R γ trimmedSumDomainSentence e he _ + hd + intro z hz + rw [trimmedSumDomainSentence,bounded_sat,Formula.absolute _ _ (level_transitive R γ) _ + (fun i => by cases i; exact hz; exact he _)] + simp only [Formula.eval_disj,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,e, + mem_sumDomain,leftNode,rightNode] + +theorem sum_relation_at_successor_of_subset (R : ZFSet.{u}) (γ : Ordinal.{u}) + {a b : ZFSet.{u}} + (ha : a ∈ level R γ) (hb : b ∈ level R γ) + (h0 : (∅ : ZFSet.{u}) ∈ level R γ) (h1 : ({∅} : ZFSet.{u}) ∈ level R γ) + (hd : sumDomain a b ⊆ level R γ) + (hsub : sumRelation a b ⊆ level R γ) : + sumRelation a b ∈ level R (γ+1) := by + let A := level R γ + let e := cons a (cons b (cons ∅ (fun _ => {∅}))) + have he (i : ℕ) : e i ∈ A := by + rcases i with _|_|_|i; exact ha; exact hb; exact h0; exact h1 + apply defined_set_at_successor R γ trimmedSumRelationSentence e he _ hsub + intro z hz + change (∃ x ∈ A, ∃ y ∈ A, (fromBounded _).Sat _ (cons y (cons x (cons z e)))) ↔ _ + have hspec (x y : ZFSet.{u}) (hx : x ∈ A) (hy : y ∈ A) : + (fromBounded (.conj (.orderedPair 2 1 0) (sumLessFormula 3 4 5 6 1 0))).Sat + (A : Set ZFSet) (cons y (cons x (cons z e))) ↔ + z = ZFSet.pair x y ∧ SumLess a b x y := by + rw [bounded_sat,Formula.absolute _ A (level_transitive R γ) _ (fun i => by + rcases i with _|_|_|i; exact hy; exact hx; exact hz; exact he i)] + simp only [Formula.Eval,Formula.eval_orderedPair] + rw [sumLessFormula_eval _ _ _ _ _ _ _ rfl rfl] + rfl + constructor + · rintro ⟨x,hx,y,hy,h⟩ + obtain ⟨rfl,hless⟩ := (hspec x y hx hy).mp h + have hkeep := hless + have hxy : x ∈ sumDomain a b ∧ y ∈ sumDomain a b := by + rcases hless with ⟨s,hs,t,ht,rfl,rfl,_⟩|⟨s,hs,t,ht,rfl,rfl⟩|⟨s,hs,t,ht,rfl,rfl,_⟩ + · exact ⟨(mem_sumDomain _ _ _).mpr (Or.inl ⟨s,hs,rfl⟩), + (mem_sumDomain _ _ _).mpr (Or.inl ⟨t,ht,rfl⟩)⟩ + · exact ⟨(mem_sumDomain _ _ _).mpr (Or.inl ⟨s,hs,rfl⟩), + (mem_sumDomain _ _ _).mpr (Or.inr ⟨t,ht,rfl⟩)⟩ + · exact ⟨(mem_sumDomain _ _ _).mpr (Or.inr ⟨s,hs,rfl⟩), + (mem_sumDomain _ _ _).mpr (Or.inr ⟨t,ht,rfl⟩)⟩ + exact (pair_mem_sumRelation a b x y).mpr ⟨hxy.1,hxy.2,hkeep⟩ + · intro h + obtain ⟨x,hx,y,hy,rfl⟩ := ZFSet.mem_prod.mp (sumRelation_on a b h) + exact ⟨x,hd hx,y,hd hy,(hspec x y (hd hx) (hd hy)).mpr + ⟨rfl,((pair_mem_sumRelation a b x y).mp h).2.2⟩⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteSumGraph.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteSumGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..051bd1ac52886183c053c02ba1dae23ee5643c20 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteSumGraph.lean @@ -0,0 +1,65 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.TrimmedSumGraph + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalCoding +universe u + +theorem sum_graph_spec_with_internal_nodes (A : ZFSet.{u}) (hA : Transitive A) (a b : Ordinal.{u}) (hω : ZFSet.omega.{u} ∈ A) + (ha : a.toZFSet ∈ A) (hb : b.toZFSet ∈ A) + (h0 : (∅ : ZFSet.{u}) ∈ A) (h1 : ({∅} : ZFSet.{u}) ∈ A) + (hlocal : ∀ t < b, (a+t).toZFSet ∈ A ∧ SumCertificates (A) a t) + (hnodes : sumDomain a.toZFSet b.toZFSet ⊆ A) + (z : ZFSet.{u}) (hz : z ∈ A) : + trimmedSumGraphSentence.Sat (A : Set ZFSet) + (cons z (cons a.toZFSet (cons b.toZFSet (cons ∅ (fun _ => {∅}))))) ↔ + ∃ x ∈ sumDomain a.toZFSet b.toZFSet, z = ZFSet.pair x (sumValue a x) := by + let e := cons z (cons a.toZFSet (cons b.toZFSet (cons ∅ (fun _ => {∅})))) + have he (i : ℕ) : e i ∈ A := by + rcases i with _|_|_|_|i; exact hz; exact ha; exact hb; exact h0; exact h1 + rw [trimmedSumGraphSentence_semantics A hA e he] + constructor + · rintro ⟨t,ht,x,hx,y,hy,hleft|⟨hright,hq⟩⟩ + · obtain ⟨hta,hxdef,hzdef,hydef⟩ := hleft + change x = leftNode t at hxdef + refine ⟨x,(mem_sumDomain _ _ _).mpr (Or.inl ⟨t,hta,hxdef⟩),?_⟩ + change z = ZFSet.pair x y at hzdef + rw [hzdef,hydef,hxdef,sumValue_left] + · obtain ⟨htb,hxdef,hzdef⟩ := hright + change t ∈ b.toZFSet at htb + obtain ⟨t,htb,rfl⟩ := Ordinal.mem_toZFSet_iff.mp htb + have htb := Ordinal.toZFSet_mem_toZFSet_iff.mp htb + have hE : ∀ i, cons y (cons x (cons t.toZFSet e)) i ∈ A := by + intro i; rcases i with _|_|_|i; exact hy; exact hx; exact ht; exact he i + have hydef := codeSumAt_sound A hA 0 4 2 _ hE a t rfl rfl hq + change x = rightNode t.toZFSet at hxdef + refine ⟨x,(mem_sumDomain _ _ _).mpr (Or.inr + ⟨t.toZFSet,Ordinal.toZFSet_mem_toZFSet_iff.mpr htb,hxdef⟩),?_⟩ + change z = ZFSet.pair x y at hzdef + change y = (a+t).toZFSet at hydef + rw [hzdef,hydef,hxdef,sumValue_right,Ordinal.rank_toZFSet] + · rintro ⟨x,hx,hzdef⟩ + rcases (mem_sumDomain _ _ _).mp hx with ⟨t,ht,rfl⟩|⟨t,ht,rfl⟩ + · have htA := hA _ ha _ ht + have hxA := hnodes ((mem_sumDomain _ _ _).mpr (Or.inl ⟨t,ht,rfl⟩)) + refine ⟨t,htA,_,hxA,t,htA,Or.inl ⟨ht,rfl,?_,rfl⟩⟩ + rw [sumValue_left] at hzdef + simpa only [e,cons_zero,leftNode] using hzdef + · obtain ⟨t,ht,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ht + have ht := Ordinal.toZFSet_mem_toZFSet_iff.mp ht + have htA := hA _ hb _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr ht) + have hxA := hnodes ((mem_sumDomain _ _ _).mpr (Or.inr ⟨t.toZFSet,Ordinal.toZFSet_mem_toZFSet_iff.mpr ht,rfl⟩)) + obtain ⟨hy,hq⟩ := hlocal t ht + let E := cons (a+t).toZFSet (cons (rightNode t.toZFSet) (cons t.toZFSet e)) + have hE (i : ℕ) : E i ∈ A := by + rcases i with _|_|_|i; exact hy; exact hxA; exact htA; exact he i + refine ⟨t.toZFSet,htA,_,hxA,(a+t).toZFSet,hy,Or.inr + ⟨⟨Ordinal.toZFSet_mem_toZFSet_iff.mpr ht,rfl,?_⟩,?_⟩⟩ + · rw [sumValue_right,Ordinal.rank_toZFSet] at hzdef + simpa only [e,cons_zero,rightNode] using hzdef + · exact codeSumAt_of_certificates A hA hω 0 4 2 E hE a t rfl rfl hq rfl + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteSumPowerBound.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteSumPowerBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..63f8d80ae95a001372a24357360428c36e8d580e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteSumPowerBound.lean @@ -0,0 +1,54 @@ +import OAI.Computability.DegreeRigidity.SetModels.RecursiveSumBound +import OAI.Computability.DegreeRigidity.OrdinalCodes.TrimmedPaddedSum + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalCoding +universe u + +theorem finite_left_mul_omega_power (n : ℕ) (hn : 0 < n) (β : Ordinal.{u}) (hβ : 0 < β) : + (n : Ordinal.{u}) * Ordinal.omega0 ^ β = Ordinal.omega0 ^ β := by + have h1 : (1 : Ordinal.{u}) ≤ β := by simpa only [zero_add] using Order.add_one_le_iff.mpr hβ + have hsplit : β = 1+(β-1) := (Ordinal.add_sub_cancel_of_le h1).symm + have hp : Ordinal.omega0 ^ β = Ordinal.omega0 * Ordinal.omega0 ^ (β-1) := by + conv_lhs => rw [hsplit,Ordinal.opow_add,Ordinal.opow_one] + rw [hp,← mul_assoc,Ordinal.natCast_mul_omega0 hn] + +theorem finite_sum_margin_lt_power (β t : Ordinal.{u}) (hβ : 0 < β) + (ht : t < Ordinal.omega0 ^ β) : 8*t+8 < Ordinal.omega0 ^ β := by + have hn : (0 : ℕ) < 8 := by decide + have h8 : (0 : Ordinal.{u}) < 8 := by exact_mod_cast hn + have hmul : 8*t < Ordinal.omega0 ^ β := by + rw [← finite_left_mul_omega_power 8 hn β hβ] + exact mul_lt_mul_of_pos_left ht h8 + have hω : Ordinal.omega0 ≤ Ordinal.omega0 ^ β := by + simpa only [Ordinal.opow_one] using + Ordinal.opow_le_opow_right Ordinal.omega0_pos (show 1 ≤ β from by simpa only [zero_add] using Order.add_one_le_iff.mpr hβ) + exact Ordinal.isPrincipal_add_omega0_opow β hmul + ((Ordinal.natCast_lt_omega0 8).trans_le hω) + +theorem sum_certificates_below_power_cut (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (a β t : Ordinal.{u}) (hβ : 0 < β) + (ht : t < Ordinal.omega0 ^ β) : + SumCertificates (level (groundReals M) (a+Ordinal.omega0 ^ β)) a t := by + apply (sum_certificates_finite_bound M hM hT a t).mono (level_mono _ ?_) + rw [add_assoc] + exact ((add_lt_add_iff_left a).mpr (finite_sum_margin_lt_power β t hβ ht)).le + +theorem padded_final_sum_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hβ : 0 < β) (hoff : realSeedOffset+β=β) (hv : vectorCode v ≤ β) : + SumCertificates (level (groundReals M) (heightDomainIndex (paddedCode v β))) + (Ordinal.omega0 ^ (β+1)) (Ordinal.omega0 ^ vectorCode v) := by + apply padded_final_sum_of_smaller_certificates M hM hT v β hβ hoff hv + intro t ht + have hc : paddedCode v β = Ordinal.omega0 ^ (β+1)+Ordinal.omega0 ^ vectorCode v := by + change pairCode β (vectorCode v) = _ + rw [pairCode,ite_eq_left hv] + rw [hc] + exact sum_certificates_below_power_cut M hM hT _ _ t (vectorCode_pos v) ht + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteSumStep.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteSumStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e0de90543424bee8830dd6e3475ab95ede7053d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteSumStep.lean @@ -0,0 +1,65 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteSumDomains +import OAI.Computability.DegreeRigidity.Effective.FiniteSumGraph +import OAI.Computability.DegreeRigidity.SetModels.FinitePresentation + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalCoding +universe u + +theorem sum_certificates_at_add_five (R : ZFSet.{u}) (γ a b : Ordinal.{u}) + (hω : ZFSet.omega.{u} ∈ level R γ) + (ha : a.toZFSet ∈ level R γ) (hb : b.toZFSet ∈ level R γ) + (hlocal : ∀ t < b, (a+t).toZFSet ∈ level R γ ∧ SumCertificates (level R γ) a t) : + SumCertificates (level R (γ+5)) a b := by + have h0 := level_transitive R γ _ hω _ ZFSet.omega_zero + have h1 : ({∅} : ZFSet.{u}) ∈ level R γ := by + have h := level_transitive R γ _ hω _ ((mem_omega _).mpr ⟨1,rfl⟩) + simpa [natSet] using h + have h02 : γ ≤ γ+2 := le_self_add + have h24 : γ+2 ≤ γ+4 := add_le_add le_rfl (by exact_mod_cast (show (2 : ℕ) ≤ 4 by decide) : (2 : Ordinal.{u}) ≤ 4) + have h04 := h02.trans h24 + have hd2 : sumDomain a.toZFSet b.toZFSet ⊆ level R (γ+2) := by + intro x hx + rcases (mem_sumDomain _ _ _).mp hx with ⟨t,ht,rfl⟩|⟨t,ht,rfl⟩ + · exact orderedPair_mem_level_add_two R γ h0 (level_transitive R γ _ ha _ ht) + · exact orderedPair_mem_level_add_two R γ h1 (level_transitive R γ _ hb _ ht) + have hd4 : sumDomain a.toZFSet b.toZFSet ⊆ level R (γ+4) := + fun _ h => level_mono R h24 (hd2 h) + have hr4 : sumRelation a.toZFSet b.toZFSet ⊆ level R (γ+4) := by + intro z hz + obtain ⟨x,hx,y,hy,rfl⟩ := ZFSet.mem_prod.mp (sumRelation_on _ _ hz) + simpa only [add_assoc,show (2 : Ordinal.{u})+2=4 from by norm_num] using + orderedPair_mem_level_add_two R (γ+2) (hd2 hx) (hd2 hy) + have hv (x : ZFSet.{u}) (hx : x ∈ sumDomain a.toZFSet b.toZFSet) : + sumValue a x ∈ level R γ := by + rcases (mem_sumDomain _ _ _).mp hx with ⟨t,ht,rfl⟩|⟨t,ht,rfl⟩ + · simpa only [sumValue_left] using level_transitive R γ _ ha _ ht + · obtain ⟨t,ht,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ht + simpa only [sumValue_right,Ordinal.rank_toZFSet] using (hlocal t (Ordinal.toZFSet_mem_toZFSet_iff.mp ht)).1 + have hpairs (x : ZFSet.{u}) (hx : x ∈ sumDomain a.toZFSet b.toZFSet) : + ZFSet.pair x (sumValue a x) ∈ level R (γ+4) := by + simpa only [add_assoc,show (2 : Ordinal.{u})+2=4 from by norm_num] using + orderedPair_mem_level_add_two R (γ+2) (hd2 hx) (level_mono R h02 (hv x hx)) + have ha4 := level_mono R h04 ha + have hb4 := level_mono R h04 hb + have hz4 := level_mono R h04 h0 + have ho4 := level_mono R h04 h1 + have hω4 := level_mono R h04 hω + have hc4 (t : Ordinal.{u}) (ht : t < b) : + (a+t).toZFSet ∈ level R (γ+4) ∧ SumCertificates (level R (γ+4)) a t := + ⟨level_mono R h04 (hlocal t ht).1,(hlocal t ht).2.mono (level_mono R h04)⟩ + have hd := sum_domain_at_successor_of_subset R (γ+4) ha4 hb4 hz4 ho4 hd4 + have hr := sum_relation_at_successor_of_subset R (γ+4) ha4 hb4 hz4 ho4 hd4 hr4 + have hf := presentation_graph_at_successor_of_pairs R (γ+4) _ _ (a+b) (sumValue a) + hpairs (sumValue_mem a b) (sumValue_surjective a b) (sumValue_relation a b) + trimmedSumGraphSentence (cons a.toZFSet (cons b.toZFSet (cons ∅ (fun _ => {∅})))) + (fun i => by rcases i with _|_|_|i; exact ha4; exact hb4; exact hz4; exact ho4) + (sum_graph_spec_with_internal_nodes _ (level_transitive R (γ+4)) a b + hω4 ha4 hb4 hz4 ho4 hc4 hd4) + simpa only [SumCertificates,add_assoc,show (4 : Ordinal.{u})+1=5 from by norm_num] using And.intro hd (And.intro hr hf) + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteTranscript.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteTranscript.lean new file mode 100644 index 0000000000000000000000000000000000000000..28dc31334e379113c097c7604b70b568a100c7ea --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteTranscript.lean @@ -0,0 +1,56 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformOracle + +namespace OAI + +namespace TuringRigidity.OracleCode + +theorem eval_mono {g h : ℕ →. ℕ} + (hgh : ∀ n a, a ∈ g n → a ∈ h n) (c : OracleCode) (n a : ℕ) + (ha : a ∈ eval g c n) : a ∈ eval h c n := by + have happrox : ∀ k, Approximates (h k) (fun m => if m = 0 then g k else h k) := by + intro k + constructor + · intro m b hb + dsimp only at hb + split at hb + · exact hgh k b hb + · exact hb + · intro b hb + exact ⟨1, fun m hm => by simpa [show m ≠ 0 by omega] using hb⟩ + exact (eval_approximates happrox c n).1 0 a (by simpa using ha) + +theorem eval_finite_use (g : ℕ → ℕ) (c : OracleCode) (n a : ℕ) + (ha : a ∈ eval (fun k => Part.some (g k)) c n) : + ∃ m, a ∈ eval (BranchMachine.lookup (UniformOracle.oraclePrefix g m)) c n := by + obtain ⟨m,hm⟩ := (eval_approximates (UniformOracle.prefix_approximates g) c n).2 a ha + exact ⟨m,hm m le_rfl⟩ + +theorem eval_prefix_stable (g : ℕ → ℕ) (h : ℕ →. ℕ) (m : ℕ) + (he : ∀ k, k < m → g k ∈ h k) (c : OracleCode) (n a : ℕ) + (ha : a ∈ eval (BranchMachine.lookup (UniformOracle.oraclePrefix g m)) c n) : + a ∈ eval h c n := by + apply eval_mono (c := c) (n := n) (a := a) ?_ ha + intro k b hb + change b ∈ ((UniformOracle.oraclePrefix g m)[k]? : Part ℕ) at hb + have hk : k < m := by + by_contra hn + have hnone : (UniformOracle.oraclePrefix g m)[k]? = none := + List.getElem?_eq_none (by simpa [UniformOracle.oraclePrefix] using Nat.le_of_not_gt hn) + simp [hnone] at hb + have hv : (UniformOracle.oraclePrefix g m)[k]? = some (g k) := by + simp [UniformOracle.oraclePrefix, List.getElem?_range hk] + have heq : b = g k := by simpa [hv] using hb + subst b + exact he k hk + +theorem eval_total_stable (g : ℕ → ℕ) (c : OracleCode) (n a : ℕ) + (ha : a ∈ eval (fun k => Part.some (g k)) c n) : + ∃ m, ∀ h : ℕ → ℕ, (∀ k, k < m → h k = g k) → + a ∈ eval (fun k => Part.some (h k)) c n := by + obtain ⟨m,hm⟩ := eval_finite_use g c n a ha + exact ⟨m,fun h hh => eval_prefix_stable g _ m + (fun k hk => Part.mem_some_iff.mpr (hh k hk).symm) c n a hm⟩ + +end TuringRigidity.OracleCode + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/FiniteTuple.lean b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteTuple.lean new file mode 100644 index 0000000000000000000000000000000000000000..b014952a74311e831dca27ad3766b5c6e7bbd7a8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/FiniteTuple.lean @@ -0,0 +1,140 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaSyntax + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +namespace Formula +theorem eval_rename (φ : Formula) (v : ℕ → ℕ) (e : ℕ → ZFSet.{u}) : + (φ.rename v).Eval e ↔ φ.Eval (fun i => e (v i)) := by + induction φ generalizing v e with + | equal => rfl + | member => rfl + | conj φ ψ ihφ ihψ => exact and_congr (ihφ v e) (ihψ v e) + | neg φ ih => exact not_congr (ih v e) + | existsMem i φ ih => + simp only [rename,Eval] + apply exists_congr + intro x + apply and_congr_right + intro _ + have he : (fun i => cons x e (liftMap v i)) = cons x (fun i => e (v i)) := by + funext i; cases i <;> rfl + exact (ih (liftMap v) (cons x e)).trans (he ▸ Iff.rfl) +end Formula + +namespace FiniteTuple +noncomputable def code : List ZFSet.{u} → ZFSet.{u} + | [] => ∅ + | x :: xs => ZFSet.pair x (code xs) + +noncomputable def space (d : ZFSet.{u}) : ℕ → ZFSet.{u} + | 0 => {∅} + | n+1 => ZFSet.prod d (space d n) + +def prepend (xs : List ZFSet.{u}) (e : ℕ → ZFSet.{u}) : ℕ → ZFSet.{u} := + xs.foldr cons e + +@[simp] theorem prepend_nil (e : ℕ → ZFSet.{u}) : prepend [] e = e := rfl +@[simp] theorem prepend_cons (x : ZFSet.{u}) (xs : List ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + prepend (x :: xs) e = cons x (prepend xs e) := rfl + +theorem space_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) {d : ZFSet.{u}} (hd : d ∈ M) (n : ℕ) : space d n ∈ M := by + have h0 : (∅ : ZFSet.{u}) ∈ M := by + have hs := sep_mem M hM hS (.neg (.equal 0 0)) (fun _ => d) (fun _ => hd) hd + have heq : ZFSet.sep (fun x => (Formula.neg (.equal 0 0)).Eval (cons x (fun _ => d))) d = ∅ := by + apply ZFSet.ext; intro x; simp [ZFSet.mem_sep,Formula.Eval] + exact heq ▸ hs + induction n with + | zero => exact singleton_mem M hM hP h0 + | succ n ih => exact product_mem M hM hP hU hPow hS hd ih + +theorem mem_space (d t : ZFSet.{u}) (n : ℕ) : + t ∈ space d n ↔ ∃ xs : List ZFSet.{u}, xs.length = n ∧ + (∀ x ∈ xs, x ∈ d) ∧ t = code xs := by + induction n generalizing t with + | zero => + simp only [space,ZFSet.mem_singleton,List.length_eq_zero_iff] + constructor + · intro h; exact ⟨[],rfl,by simp,h⟩ + · rintro ⟨xs,rfl,_,h⟩; exact h + | succ n ih => + rw [space,ZFSet.mem_prod] + constructor + · rintro ⟨x,hx,t,ht,rfl⟩ + obtain ⟨xs,hlen,hxs,rfl⟩ := (ih t).mp ht + exact ⟨x::xs,by simp [hlen],by intro y hy; rcases List.mem_cons.mp hy with rfl | hy; exact hx; exact hxs y hy,rfl⟩ + · rintro ⟨xs,hlen,hxs,rfl⟩ + cases xs with + | nil => simp at hlen + | cons x xs => + refine ⟨x,hxs x (by simp),code xs,(ih _).mpr ?_,rfl⟩ + exact ⟨xs,Nat.succ.inj hlen,fun y hy => hxs y (by simp [hy]),rfl⟩ + +theorem code_mem_space (d : ZFSet.{u}) (xs : List ZFSet.{u}) + (hx : ∀ x ∈ xs, x ∈ d) : code xs ∈ space d xs.length := + (mem_space d _ _).mpr ⟨xs,rfl,hx,rfl⟩ + +theorem code_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + (h0 : (∅ : ZFSet.{u}) ∈ M) (xs : List ZFSet.{u}) + (hx : ∀ x ∈ xs, x ∈ M) : code xs ∈ M := by + induction xs with + | nil => exact h0 + | cons x xs ih => + exact orderedPair_mem M hM hP (hx x (by simp)) + (ih (fun y hy => hx y (by simp [hy]))) + +theorem code_injective_length (xs ys : List ZFSet.{u}) (hlen : xs.length = ys.length) + (h : code xs = code ys) : xs = ys := by + induction xs generalizing ys with + | nil => cases ys with + | nil => rfl + | cons => simp at hlen + | cons x xs ih => cases ys with + | nil => simp at hlen + | cons y ys => + obtain ⟨rfl,ht⟩ := ZFSet.pair_inj.mp h + rw [ih ys (Nat.succ.inj hlen) ht] + +theorem prepend_tail (xs : List ZFSet.{u}) (e : ℕ → ZFSet.{u}) (i : ℕ) : + prepend xs e (xs.length+i) = e i := by + induction xs with + | nil => simp only [prepend_nil,List.length_nil,Nat.zero_add] + | cons x xs ih => simpa only [List.length_cons,Nat.succ_add,prepend_cons,cons_succ] using ih + +theorem prepend_congr (xs : List ZFSet.{u}) (e f : ℕ → ZFSet.{u}) + (i : ℕ) (hi : i < xs.length) : prepend xs e i = prepend xs f i := by + induction xs generalizing i with + | nil => simp at hi + | cons x xs ih => cases i with + | zero => rfl + | succ i => exact ih i (Nat.lt_of_succ_lt_succ hi) + +def rotate (n : ℕ) : ℕ → ℕ + | 0 => n+1 + | i+1 => if i < n then i else i+2 + +theorem prepend_rotate (xs : List ZFSet.{u}) (x t : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (fun i => prepend xs (cons t (cons x e)) (rotate xs.length i)) = + cons x (prepend xs e) := by + funext i + cases i with + | zero => exact prepend_tail xs (cons t (cons x e)) 1 + | succ i => + change prepend xs (cons t (cons x e)) (if i < xs.length then i else i+2) = prepend xs e i + by_cases hi : i < xs.length + · rw [ite_eq_left hi]; exact prepend_congr xs _ _ i hi + · rw [ite_eq_right hi] + obtain ⟨j,rfl⟩ := Nat.exists_eq_add_of_le (Nat.le_of_not_gt hi) + rw [Nat.add_assoc,prepend_tail,prepend_tail] + rfl + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/GuardedCoding.lean b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedCoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..725c4c11085c44bddc4279f4487e2cac07443b23 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedCoding.lean @@ -0,0 +1,63 @@ +import OAI.Computability.DegreeRigidity.Effective.GuardedExtraction +import OAI.Computability.DegreeRigidity.Computability.NormalizedRecovery +import OAI.Computability.DegreeRigidity.Effective.AntichainParameters + +namespace OAI + +namespace TuringRigidity.GuardedCoding +open EncodedForcing StageNormalization AntichainParameters + +theorem effective_coding (A : Oracle) : ∃ G₀ G₁ : Oracle, + Reduces (join G₀ G₁) (OracleJump.jump A) ∧ + (∀ k, ∃ C : Oracle, Reduces C (join G₀ (columns A k)) ∧ + Reduces C (join G₁ (columns A k)) ∧ ¬ Reduces C (columns A k)) ∧ + ∀ Y Z : Oracle, Reduces Y A → Reduces Z (join G₀ Y) → + Reduces Z (join G₁ Y) → ¬ Reduces Z Y → ∃ k, Reduces (columns A k) Y := by + let B := normalized A + obtain ⟨hbound,hfirst⟩ := GuardedLimits.effective_first_clause B + (fun k => (normalized_spec A k).2.1) + refine ⟨GuardedLimits.G₀ B,GuardedLimits.G₁ B, + reduces_trans hbound (OracleJump.jump_mono (normalized_reduces A)),?_,?_⟩ + · intro k + obtain ⟨C,h₀,h₁,hn⟩ := hfirst k + obtain ⟨hBA,hAB⟩ := (degree_eq_iff _ _).mp (normalized_spec A k).1 + exact ⟨C,reduces_trans h₀ (join_mono (reduces_refl _) hBA), + reduces_trans h₁ (join_mono (reduces_refl _) hBA),fun h => hn (reduces_trans h hAB)⟩ + · intro Y Z hY h₀ h₁ hn + obtain ⟨k,hk⟩ := GuardedExtraction.common_lower_computes_column + (fun k => (normalized_spec A k).2.2) + (reduces_trans hY (NormalizedRecovery.normalized_inverse A)) + (reduces_trans h₀ (AntichainCoding.swap_join_reduces _ _)) + (reduces_trans h₁ (AntichainCoding.swap_join_reduces _ _)) hn + exact ⟨k,reduces_trans (((degree_eq_iff _ _).mp (normalized_spec A k).1).2) hk⟩ + +theorem effective_antichain_parameters (A : Oracle) + (hAnti : ∀ i j, degree (columns A i) ≤ degree (columns A j) → + degree (columns A i) = degree (columns A j)) : + ∃ g₀ g₁ : Degree, g₀ ⊔ g₁ ≤ OracleJump.degreeJump (degree A) ∧ + ∀ x : Degree, CodedAntichain (degree A) g₀ g₁ x ↔ ∃ k, degree (columns A k) = x := by + obtain ⟨G₀,G₁,hbound,hfirst,hsecond⟩ := effective_coding A + have hm : ∀ k, NontrivialCommonLower (degree A) (degree G₀) (degree G₁) (degree (columns A k)) := by + intro k + obtain ⟨C,h₀,h₁,hn⟩ := hfirst k + exact ⟨CodingExtraction.column_projection_reduces A k,degree C,h₀,h₁,hn⟩ + have hc : ∀ x, NontrivialCommonLower (degree A) (degree G₀) (degree G₁) x → + ∃ k, degree (columns A k) ≤ x := by + intro x hx + obtain ⟨Y,rfl⟩ := degree_surjective x + obtain ⟨z,h₀,h₁,hn⟩ := hx.2 + obtain ⟨Z,rfl⟩ := degree_surjective z + exact hsecond Y Z hx.1 h₀ h₁ hn + refine ⟨degree G₀,degree G₁,hbound,fun x => ?_⟩ + constructor + · intro hx + obtain ⟨k,hk⟩ := hc x hx.1 + exact ⟨k,le_antisymm hk (hx.2 _ (hm k) hk)⟩ + · rintro ⟨k,rfl⟩ + refine ⟨hm k,fun y hy hyk => ?_⟩ + obtain ⟨j,hj⟩ := hc y hy + exact hAnti j k (hj.trans hyk) ▸ hj + +end TuringRigidity.GuardedCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/GuardedComputability.lean b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedComputability.lean new file mode 100644 index 0000000000000000000000000000000000000000..4543214a90a76bb5a9962c8b25c65197847ea83b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedComputability.lean @@ -0,0 +1,176 @@ +import OAI.Computability.DegreeRigidity.Effective.GuardedScan + +namespace OAI + +namespace TuringRigidity.GuardedComputability +open Encodable UniformOracle EncodedForcing CodingForcing FiniteInjury StageRecords +noncomputable section +attribute [local instance] Classical.propDecidable + +def state (v : ℕ) : GuardedStage.State := + ⟨condition (Nat.unpair v).1,members (Nat.unpair (Nat.unpair v).2).1,members (Nat.unpair (Nat.unpair v).2).2⟩ + +def generic (A : Oracle) (v : ℕ) : ℕ := GuardedStage.openProcedure A + (Nat.pair (nextVisit (Nat.unpair (Nat.unpair v).2).2) (Nat.unpair v).1) + +theorem open_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun v => Part.some (GuardedStage.openProcedure A v)) := + (Classical.choose_spec (EffectiveForcing.uniform_open_decision A A (reduces_refl A))).1 + +def canonical (p : ℕ) : ℕ := levelCode p (active p) +theorem canonical_eq (p : ℕ) : canonical p = code (condition p) := rfl + +def genericCanonical (A : Oracle) (v : ℕ) : ℕ := GuardedStage.openProcedure A + (Nat.pair (nextVisit (Nat.unpair (Nat.unpair v).2).2) (canonical (Nat.unpair v).1)) + +theorem generic_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun v => Part.some (genericCanonical A v)) := by + have hn := total_comp (nextVisit_recursive (O := {oracleFunction (OracleJump.jump A)})) (total_primrec (r.comp r)) + have hp := total_primrec (O := {oracleFunction (OracleJump.jump A)}) ((levelCode_primrec.comp Primrec.id active_primrec).comp f) + have hh := total_comp (open_recursive A) (total_pair hn hp) + exact hh.of_eq (fun v => rfl) + +@[simp] theorem generic_eq (A : Oracle) (v : ℕ) : + condition (genericCanonical A v) = GuardedStage.generic A (state v) := rfl + +def stageAction (A : Oracle) (s v : ℕ) : ℕ := + scan A (genericCanonical A v) (Nat.unpair (Nat.unpair v).2).1 s + +theorem stageAction_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun z => + Part.some (stageAction A (Nat.unpair z).1 (Nat.unpair z).2)) := by + have hg := total_comp (generic_recursive A) (total_primrec r) + have hh := total_comp (scan_recursive A) (total_pair (total_pair hg (total_primrec (f.comp (r.comp r)))) (total_primrec f)) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +@[simp] theorem stageAction_eq (A : Oracle) (s v : ℕ) : + action (stageAction A s v) = GuardedStage.stageAction A s (state v) := by + rw [stageAction,scan_eq,action_actionCode,generic_eq] + rfl + +def stageWord (A : Oracle) (z : ℕ) : ℕ := + let s := (Nat.unpair z).1 + let v := (Nat.unpair z).2 + let a := stageAction A s v + let g := genericCanonical A v + if a = 0 then g else candidate A (Nat.pair (a-1) g) + +theorem stageWord_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun z => Part.some (stageWord A z)) := by + have ha := stageAction_recursive A + have hg := total_comp (generic_recursive A) (total_primrec r) + have hc := total_comp (candidate_recursive A) (total_pair + (total_comp (total_primrec (Primrec.nat_sub.comp Primrec.id (Primrec.const 1))) ha) hg) + have hpost := Primrec.ite (Primrec.eq.comp f (Primrec.const 0)) (f.comp r) (r.comp r) + have hh := total_comp (total_primrec hpost) (total_pair ha (total_pair hg hc)) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +theorem stageWord_eq (A : Oracle) (s v : ℕ) : + condition (stageWord A (Nat.pair s v)) = GuardedStage.stageWord A s (state v) := by + have he := stageAction_eq A s v + unfold stageWord + simp only [Nat.unpair_pair] + by_cases ha : stageAction A s v = 0 + · have hn : GuardedStage.stageAction A s (state v) = none := by simpa only [StageRecords.action,ite_eq_left ha] using he.symm + simp [ha,GuardedStage.stageWord,hn,generic_eq] + · have hn : GuardedStage.stageAction A s (state v) = some (stageAction A s v-1) := by + simpa only [StageRecords.action,ite_eq_right ha] using he.symm + simp [ha,GuardedStage.stageWord,hn,candidate_eq,generic_eq] + +def grow (p s : ℕ) : ℕ := Nat.pair (encode (left p ++ [false])) + (Nat.pair (encode (right p ++ [false])) (s+1)) + +theorem grow_primrec : Primrec₂ grow := Primrec₂.natPair.comp + (Primrec.encode.comp (Primrec.list_append.comp (left_primrec.comp Primrec.fst) (Primrec.const [false]))) + (Primrec₂.natPair.comp + (Primrec.encode.comp (Primrec.list_append.comp (right_primrec.comp Primrec.fst) (Primrec.const [false]))) + (Primrec.succ.comp Primrec.snd)) + +@[simp] theorem condition_grow (p s : ℕ) : + condition (grow p s) = atLevel (append (condition p) [false]) (s+1) := condition_code (atLevel (append (condition p) [false]) (s+1)) + +def advance (A : Oracle) (z : ℕ) : ℕ := + let s := (Nat.unpair z).1 + let v := (Nat.unpair z).2 + let d := (Nat.unpair (Nat.unpair v).2).1 + let seen := (Nat.unpair (Nat.unpair v).2).2 + let a := stageAction A s v + Nat.pair (grow (stageWord A z) s) + (Nat.pair (doneUpdate d a) (seenReset (seenInsert seen (nextVisit seen)) a)) + +theorem advance_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun z => Part.some (advance A z)) := by + have ha := stageAction_recursive A + have hw := total_comp (total_primrec (grow_primrec.comp f r)) + (total_pair (stageWord_recursive A) (total_primrec f)) + have hd := total_comp (total_primrec (doneUpdate_primrec.comp f r)) + (total_pair (total_primrec (f.comp (r.comp r))) ha) + have hs := total_primrec (O := {oracleFunction (OracleJump.jump A)}) (r.comp (r.comp r)) + have hn := total_comp nextVisit_recursive hs + have hi := total_comp (total_primrec (seenInsert_primrec.comp f r)) (total_pair hs hn) + have hreset := total_comp (total_primrec (seenReset_primrec.comp f r)) (total_pair hi ha) + have hh := total_pair hw (total_pair hd hreset) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +theorem advance_eq (A : Oracle) (s v : ℕ) : + state (advance A (Nat.pair s v)) = GuardedStage.advance A s (state v) := by + unfold state advance + simp only [Nat.unpair_pair,condition_grow,stageWord_eq,members_doneUpdate, + members_seenReset,members_seenInsert,stageAction_eq] + rfl + +def initial : ℕ := Nat.pair (code ⟨[],[],rfl,0⟩) (Nat.pair (encode ([] : List ℕ)) (encode ([] : List ℕ))) + +def construction (A : Oracle) : ℕ → ℕ := + recur (fun _ => initial) (fun v => advance A (Nat.unpair v).2) 0 + +theorem construction_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun s => Part.some (construction A s)) := by + have h := recur_recursive (total_primrec (Primrec.const initial)) + (total_comp (advance_recursive A) (total_primrec r)) + have hh := total_comp h (total_primrec (Primrec₂.natPair.comp (Primrec.const 0) Primrec.id)) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +theorem construction_eq (A : Oracle) (s : ℕ) : + state (construction A s) = GuardedStage.construction A s := by + induction s with + | zero => simp [construction,recur,initial,state,condition_code,members,record,GuardedStage.construction] + | succ s ih => + change state (advance A (Nat.unpair (Nat.pair 0 (Nat.pair s (construction A s)))).2) = _ + rw [Nat.unpair_pair,advance_eq,ih] + rfl + +theorem conditions_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} + (fun s => Part.some (code (GuardedStage.conditions A s))) := by + have h := total_comp (total_primrec ((levelCode_primrec.comp Primrec.id active_primrec).comp f)) + (construction_recursive A) + apply h.of_eq + intro s + change Part.some (code (state (construction A s)).condition) = _ + rw [construction_eq] + rfl + +theorem limits_recursive (A : Oracle) : + Reduces (join (leftLimit (GuardedStage.conditions A)) (rightLimit (GuardedStage.conditions A))) + (OracleJump.jump A) := by + have hs := total_comp (conditions_recursive A) (total_primrec (Primrec.succ.comp Primrec.nat_div2)) + have hbit : Primrec (fun v : ℕ => CommonIdeal.bit + ((bif (Nat.unpair v).2.bodd then right (Nat.unpair v).1 else left (Nat.unpair v).1).getD + (Nat.unpair v).2.div2 false)) := CommonIdeal.bit_primrec.comp + ((Primrec.list_getD false).comp + (Primrec.cond (Primrec.nat_bodd.comp r) (right_primrec.comp f) (left_primrec.comp f)) + (Primrec.nat_div2.comp r)) + have h := total_comp (total_primrec hbit) (total_pair hs (total_primrec Primrec.id)) + apply RecursiveIn.iff_nat.mpr + have hl (p : Condition) : left (code p) = p.left := congrArg Condition.left (condition_code p) + have hr (p : Condition) : right (code p) = p.right := congrArg Condition.right (condition_code p) + exact h.of_eq (fun n => by + simp only [Nat.unpair_pair] + cases hb : n.bodd <;> simp [oracleFunction,join,hb,leftLimit,rightLimit,CommonIdeal.bit, + hl,hr,Nat.div2_val]) + +end +end TuringRigidity.GuardedComputability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/GuardedExtraction.lean b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedExtraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f48bd5ed851bfa0ae2387a087e156076b22cec3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedExtraction.lean @@ -0,0 +1,185 @@ +import OAI.Computability.DegreeRigidity.Effective.GuardedOutcomes + +namespace OAI + +namespace TuringRigidity.GuardedExtraction +open ArithmeticHierarchy +open Encodable CodingForcing EncodedForcing UniformProgram IndexMatrix FiniteInjury GuardedStage +noncomputable section + +theorem noSplit_reduces {A Y G Z : Oracle} {t : ℕ} {p : Condition} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (hG : CommonIdeal.Extends G p.left) + (he : OracleCode.eval (oracleFunction (join Y G)) (meaning (machine (item t 1))) = oracleFunction Z) + (hno : ¬ ∃ z, UniformSplit.SplitCert A (Nat.pair (UniformPair.request (Nat.pair t (code p))) z)) : + Reduces Z Y := by + have hrun (w : List Bool) (n : ℕ) : + UniformRun.run A (machine (item t 0)) (machine (item t 1)) w n = + CommonIdeal.run Y (meaning (machine (item t 1))) w n := by + simp only [UniformRun.run,hbase,CommonIdeal.run] + apply CodingAgreement.case1_reduces (A := columns A) (p := p) ?_ hG he + intro q r hpq hpr n a b ha hb + by_contra hab + rw [← hrun] at ha hb + apply hno + refine ⟨encode [n,encode q.left,encode r.left,a,b],?_⟩ + simpa [UniformSplit.SplitCert,UniformSplit.start,UniformSplit.base,UniformSplit.program, + UniformPair.request,item,word, + show left (code p) = p.left from congrArg Condition.left (condition_code p)] using + And.intro hpq.1 (And.intro hpr.1 (And.intro hab (And.intro ha hb))) + +theorem point_splittingLocation {A Y : Oracle} {t w : ℕ} {p : Condition} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (hw : UniformSplit.PointCert A (Nat.pair (UniformPair.request (Nat.pair t (code p))) w)) : + CodingLocations.SplittingLocation Y (meaning (machine (item t 1))) p.left (item w 2) := by + have hrun (v : List Bool) (n : ℕ) : + UniformRun.run A (machine (item t 0)) (machine (item t 1)) v n = + CommonIdeal.run Y (meaning (machine (item t 1))) v n := by + simp only [UniformRun.run,hbase,CommonIdeal.run] + have hh : p.left <+: word (item w 1) ∧ p.left.length ≤ item w 2 ∧ + item w 2 < (word (item w 1)).length ∧ item w 4 ≠ item w 5 ∧ + item w 4 ∈ CommonIdeal.run Y (meaning (machine (item t 1))) (word (item w 1)) (item w 0) ∧ + item w 5 ∈ CommonIdeal.run Y (meaning (machine (item t 1))) + ((word (item w 1)).set (item w 2) (item w 3).bodd) (item w 0) := by + rw [← hrun,← hrun] + simpa [UniformSplit.PointCert,UniformSplit.start,UniformSplit.base,UniformSplit.program, + UniformPair.request,item,word, + show left (code p) = p.left from congrArg Condition.left (condition_code p)] using hw + exact ⟨word (item w 1),(item w 3).bodd,item w 0,item w 4,item w 5,hh⟩ + +theorem common_unbounded_points {A Y Z : Oracle} {t : ℕ} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₀ A))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₁ A))) + (meaning (machine (item t 2))) = oracleFunction Z) + (hn : ¬ Reduces Z Y) : + ∀ N, ∃ m, N ≤ m ∧ (Nat.unpair m).1 < t ∧ columns A (Nat.unpair m).1 (Nat.unpair m).2 = true ∧ + CodingLocations.SplittingLocation Y (meaning (machine (item t 1))) [] m := by + obtain ⟨S,hS⟩ := GuardedOutcomes.common_eventually_outcome hbase he₀ he₁ + intro N + let s := max S N + let p := atLevel (generic A (construction A s)) t + obtain ⟨_,_,hno | ⟨w,hw,hcoding⟩⟩ := hS s (le_max_left _ _) + · exact False.elim (hn (noSplit_reduces (p := p) (t := t) hbase (GuardedLimits.limits_extend_generic A s).1 he₀ hno)) + · have hs : N ≤ p.left.length := by + have hp := (open_extends A (FiniteInjurySchedule.visit (construction A s).seen) (construction A s).condition).1.length_le + exact (le_max_right S N).trans ((length_bound A s).trans hp) + have hpoint := point_splittingLocation (p := p) (t := t) (w := w) hbase hw + obtain ⟨v,b,n,a,c,hpv,hpm,hmv,hac,ha,hc⟩ := hpoint + exact ⟨item w 2,hs.trans hcoding.1,hcoding.2.1,hcoding.2.2, + v,b,n,a,c,List.nil_prefix,Nat.zero_le _,hmv,hac,ha,hc⟩ + +theorem common_lower_unbounded_points {A Y Z : Oracle} + (hY : Reduces Y A) + (h₀ : Reduces Z (join Y (GuardedLimits.G₀ A))) + (h₁ : Reduces Z (join Y (GuardedLimits.G₁ A))) + (hn : ¬ Reduces Z Y) : + ∃ t, ∀ N, ∃ m, N ≤ m ∧ (Nat.unpair m).1 < t ∧ + columns A (Nat.unpair m).1 (Nat.unpair m).2 = true ∧ + CodingLocations.SplittingLocation Y (meaning (machine (item t 1))) [] m := by + obtain ⟨b,hb⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp hY + obtain ⟨e,he⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h₀ + obtain ⟨f,hf⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h₁ + let t := encode [encode (represent b),encode (represent e),encode (represent f)] + have hb' : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y := by + simpa [t,item,machine,represent_correct] using hb + have he' : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₀ A))) + (meaning (machine (item t 1))) = oracleFunction Z := by + simpa [t,item,machine,represent_correct] using he + have hf' : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₁ A))) + (meaning (machine (item t 2))) = oracleFunction Z := by + simpa [t,item,machine,represent_correct] using hf + exact ⟨t,common_unbounded_points hb' he' hf' hn⟩ + +theorem noBad_sound {A Y : Oracle} {t : ℕ} {p : Condition} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (hbad : GuardedPair.NoBad A t p) {m : ℕ} + (hm : CodingLocations.SplittingLocation Y (meaning (machine (item t 1))) p.left m) : + CodingLocation (columns A) p m := by + by_contra hnc + obtain ⟨v,b,n,a,c,hpv,hpm,hmv,hac,ha,hc⟩ := hm + have hrun (w : List Bool) (n : ℕ) : + UniformRun.run A (machine (item t 0)) (machine (item t 1)) w n = + CommonIdeal.run Y (meaning (machine (item t 1))) w n := by + simp only [UniformRun.run,hbase,CommonIdeal.run] + apply hbad + refine ⟨encode [n,encode v,m,CommonIdeal.bit b,a,c],?_,?_⟩ + · have hbit : (CommonIdeal.bit b).bodd = b := by cases b <;> rfl + have hh := And.intro hpv (And.intro hpm (And.intro hmv (And.intro hac + (And.intro (hrun v n ▸ ha) (hrun (v.set m b) n ▸ hc))))) + simpa [UniformSplit.PointCert,UniformSplit.start,UniformSplit.base,UniformSplit.program, + UniformPair.request,item,word,hbit, + show left (code p) = p.left from congrArg Condition.left (condition_code p)] using hh + · simpa [UniformPair.IsCoding,item,condition_code] using hnc + +theorem common_recursive_locations {A Y Z : Oracle} {t : ℕ} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₀ A))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₁ A))) + (meaning (machine (item t 2))) = oracleFunction Z) + (hn : ¬ Reduces Z Y) : + ∃ p : Condition, p.active = t ∧ ∃ C : Oracle, Reduces C Y ∧ + {m | C m = true}.Infinite ∧ ∀ m, C m = true → CodingLocation (columns A) p m := by + obtain ⟨S,hS⟩ := GuardedOutcomes.common_eventually_outcome hbase he₀ he₁ + let p := atLevel (generic A (construction A S)) t + have hbad : GuardedPair.NoBad A t p := (hS S le_rfl).2.1 + obtain ⟨E,hE,hEq⟩ := CodingSplitSearch.splittingLocations_enumerable Y (meaning (machine (item t 1))) p.left + have hu : RecursiveInfiniteSubset.Unbounded E := by + intro N + let s := max (S+1) N + let q := atLevel (generic A (construction A s)) t + have hpq : p.left <+: q.left := by + exact (GuardedLimits.generic_prefix_next A S).1.trans + ((word_prefix (word_growth A) (le_max_left (S+1) N)).1.trans + (open_extends A _ _).1) + obtain ⟨_,_,hno | ⟨w,hw,hcoding⟩⟩ := hS s (by dsimp [s]; omega) + · exact False.elim (hn (noSplit_reduces (p := q) (t := t) hbase + (GuardedLimits.limits_extend_generic A s).1 he₀ hno)) + · have hN : N ≤ q.left.length := by + exact (le_max_right (S+1) N).trans ((length_bound A s).trans (open_extends A _ _).1.length_le) + obtain ⟨v,b,n,a,c,hqv,hqm,hmv,hac,ha,hc⟩ := point_splittingLocation hbase hw + have hpoint : CodingLocations.SplittingLocation Y (meaning (machine (item t 1))) p.left (item w 2) := + ⟨v,b,n,a,c,hpq.trans hqv,hpq.length_le.trans hqm,hmv,hac,ha,hc⟩ + obtain ⟨z,hz⟩ := (hEq (item w 2)).mp hpoint + exact ⟨z,item w 2,hN.trans hqm,hz⟩ + obtain ⟨C,hCY,hCi,hC⟩ := RecursiveInfiniteSubset.infinite_recursive_subset Y E hu hE + exact ⟨p,rfl,C,hCY,hCi,fun m hm => noBad_sound hbase hbad ((hEq m).mpr (hC m hm))⟩ + +theorem common_infinite_column {A Y Z : Oracle} {t : ℕ} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₀ A))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₁ A))) + (meaning (machine (item t 2))) = oracleFunction Z) + (hn : ¬ Reduces Z Y) : + ∃ k, k < t ∧ ∃ C : Oracle, Reduces C Y ∧ {a | C a = true}.Infinite ∧ + ∀ a, C a = true → columns A k a = true := by + obtain ⟨p,hp,C,hCY,hCi,hC⟩ := common_recursive_locations hbase he₀ he₁ hn + simpa only [hp] using CodingExtraction.infinite_column hCY hCi hC + +theorem common_lower_computes_column {A Y Z : Oracle} + (hIntro : ∀ k C, (∀ a, C a = true → columns A k a = true) → + {a | C a = true}.Infinite → Reduces (columns A k) C) + (hY : Reduces Y A) + (h₀ : Reduces Z (join Y (GuardedLimits.G₀ A))) + (h₁ : Reduces Z (join Y (GuardedLimits.G₁ A))) + (hn : ¬ Reduces Z Y) : ∃ k, Reduces (columns A k) Y := by + obtain ⟨b,hb⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp hY + obtain ⟨e,he⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h₀ + obtain ⟨f,hf⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h₁ + let t := encode [encode (represent b),encode (represent e),encode (represent f)] + have hb' : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y := by + simpa [t,item,machine,represent_correct] using hb + have he' : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₀ A))) (meaning (machine (item t 1))) = oracleFunction Z := by + simpa [t,item,machine,represent_correct] using he + have hf' : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₁ A))) (meaning (machine (item t 2))) = oracleFunction Z := by + simpa [t,item,machine,represent_correct] using hf + obtain ⟨k,_,C,hCY,hCi,hC⟩ := common_infinite_column hb' he' hf' hn + exact ⟨k,reduces_trans (hIntro k C hC hCi) hCY⟩ + +end +end TuringRigidity.GuardedExtraction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/GuardedLimits.lean b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedLimits.lean new file mode 100644 index 0000000000000000000000000000000000000000..e962bd02ce714819ef49ab59d9ea44bcaf498ad0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedLimits.lean @@ -0,0 +1,150 @@ +import OAI.Computability.DegreeRigidity.Effective.GuardedComputability +import OAI.Computability.DegreeRigidity.CohenForcing.CohenCompleteness +import OAI.Computability.DegreeRigidity.Effective.CodingDiagonal +import OAI.Computability.DegreeRigidity.Effective.CodingExtraction + +namespace OAI + +namespace TuringRigidity.GuardedLimits +open Encodable UniformOracle ArithmeticHierarchy EncodedForcing CodingForcing FiniteInjury +open GuardedStage +noncomputable section +attribute [local instance] Classical.propDecidable + +def G₀ (A : Oracle) : Oracle := leftLimit (conditions A) +def G₁ (A : Oracle) : Oracle := rightLimit (conditions A) + +theorem generic_prefix_next (A : Oracle) (s : ℕ) : + (generic A (construction A s)).left <+: (conditions A (s+1)).left ∧ + (generic A (construction A s)).right <+: (conditions A (s+1)).right := by + have h : (generic A (construction A s)).left <+: (stageWord A s (construction A s)).left ∧ + (generic A (construction A s)).right <+: (stageWord A s (construction A s)).right := by + cases ha : stageAction A s (construction A s) with + | none => simp [stageWord,ha] + | some t => + have hc := candidate_extends A t (generic A (construction A s)) + exact ⟨by simpa [stageWord,ha,atLevel] using hc.1,by simpa [stageWord,ha,atLevel] using hc.2.1⟩ + exact ⟨h.1.trans (List.prefix_append _ _),h.2.trans (List.prefix_append _ _)⟩ + +theorem limits_extend_generic (A : Oracle) (s : ℕ) : + CommonIdeal.Extends (G₀ A) (generic A (construction A s)).left ∧ + CommonIdeal.Extends (G₁ A) (generic A (construction A s)).right := by + have hp := generic_prefix_next A s + constructor + · intro m hm + have hh := (limits_extend (word_growth A) (length_bound A) (s+1) m (hm.trans_le hp.1.length_le)).1 + exact hh.trans (getD_of_prefix hp.1 hm) + · intro m hm + have hn : m < (conditions A (s+1)).left.length := by + rw [(conditions A (s+1)).sameLength] + exact hm.trans_le hp.2.length_le + have hh := (limits_extend (word_growth A) (length_bound A) (s+1) m hn).2 + exact hh.trans (getD_of_prefix hp.2 hm) + +theorem meets_dense (A : Oracle) {P : ℕ → Prop} (hP : Sigma A 1 P) + (hdense : ∀ p : Condition, ∃ q : ℕ, Extends (columns A) p (condition q) ∧ P q) : + ∃ q : ℕ, P q ∧ CommonIdeal.Extends (G₀ A) (condition q).left ∧ + CommonIdeal.Extends (G₁ A) (condition q).right := by + obtain ⟨e,he⟩ := EffectiveCohen.sigma1_enumeration hP + obtain ⟨s,hs,_⟩ := surviving_generic_visit A e + let p := construction A s + let q := openProcedure A (Nat.pair e (code p.condition)) + have hdec := ((Classical.choose_spec (EffectiveForcing.uniform_open_decision A A (reduces_refl A))).2 + e (code p.condition)).2 + change OracleJump.Halts A e q ∨ + (∀ r, Extends (columns A) (condition q) (condition r) → ¬ OracleJump.Halts A e r) at hdec + have hq : P q := by + rcases hdec with h | h + · exact (he q).mpr h + · obtain ⟨r,hr,hR⟩ := hdense (condition q) + exact False.elim (h r hr ((he r).mp hR)) + refine ⟨q,hq,?_⟩ + have hh := limits_extend_generic A s + simpa only [generic,hs,p,q] using hh + +theorem disagreement_recursive (A X : Oracle) (loc : ℕ → ℕ) + (hloc : Nat.RecursiveIn {oracleFunction A} (fun n => Part.some (loc n))) + (hX : Reduces X A) : RecursivePred A (fun v => + loc (Nat.unpair v).2 < (left (Nat.unpair v).1).length ∧ + (left (Nat.unpair v).1).getD (loc (Nat.unpair v).2) false ≠ X (Nat.unpair v).2) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hm := total_comp hloc (total_primrec r) + have hx := total_comp (RecursiveIn.iff_nat.mp hX) (total_primrec r) + have hp : Primrec (fun v : ℕ => + if (Nat.unpair (Nat.unpair v).2).1 < (left (Nat.unpair v).1).length ∧ + CommonIdeal.bit ((left (Nat.unpair v).1).getD (Nat.unpair (Nat.unpair v).2).1 false) ≠ + (Nat.unpair (Nat.unpair v).2).2 then 1 else 0) := + Primrec.ite ((Primrec.nat_lt.comp (f.comp r) (Primrec.list_length.comp (left_primrec.comp f))).and + ((Primrec.eq.comp (CommonIdeal.bit_primrec.comp ((Primrec.list_getD false).comp + (left_primrec.comp f) (f.comp r))) (r.comp r)).not)) (Primrec.const 1) (Primrec.const 0) + have hh := total_comp (total_primrec hp) (total_pair (total_primrec f) (total_pair hm hx)) + have hbits (b c : Bool) : (CommonIdeal.bit b ≠ (if c then 1 else 0)) ↔ b ≠ c := by + cases b <;> cases c <;> decide + exact hh.of_eq (fun v => by + simp only [Nat.unpair_pair,hbits] + by_cases ht : loc (Nat.unpair v).2 < (left (Nat.unpair v).1).length ∧ + (left (Nat.unpair v).1).getD (loc (Nat.unpair v).2) false ≠ X (Nat.unpair v).2 + · simp only [ite_eq_left ht] + · simp only [ite_eq_right ht]) + +theorem reads_not_reduces (A : Oracle) (loc : ℕ → ℕ) + (hloc : Nat.RecursiveIn {oracleFunction A} (fun n => Part.some (loc n))) + (hunbounded : ∀ N, ∃ n, N ≤ loc n) : ¬ Reduces (fun n => G₀ A (loc n)) A := by + intro hX + let X : Oracle := fun n => G₀ A (loc n) + have hP : Sigma A 1 (fun p => ∃ n, loc n < (left p).length ∧ (left p).getD (loc n) false ≠ X n) := by + simpa only [Nat.unpair_pair] using + (Form.raise (n := 0) (s := true) (disagreement_recursive A X loc hloc hX)).ex + have hdense : ∀ p : Condition, ∃ q : ℕ, Extends (columns A) p (condition q) ∧ + ∃ n, loc n < (left q).length ∧ (left q).getD (loc n) false ≠ X n := by + intro p + obtain ⟨n,hn⟩ := hunbounded p.left.length + obtain ⟨q,hpq,hql,hqb⟩ := CodingDiagonal.prescribe (columns A) p (loc n) hn (!(X n)) + refine ⟨code q,by simpa [condition_code] using hpq,n,?_,?_⟩ + · simpa only [show left (code q) = q.left from congrArg Condition.left (condition_code q)] using hql + · rw [show left (code q) = q.left from congrArg Condition.left (condition_code q),hqb] + cases X n <;> decide + obtain ⟨q,⟨n,hn,hne⟩,hl,_⟩ := meets_dense A hP hdense + exact hne (hl (loc n) hn).symm + +theorem common_noncomputable_columns (A : Oracle) + (hA : ∀ k, {a | columns A k a = true}.Infinite) : + ∀ k, ∃ C : Oracle, Reduces C (join (G₀ A) (columns A k)) ∧ + Reduces C (join (G₁ A) (columns A k)) ∧ ¬ Reduces C (columns A k) := by + intro k + obtain ⟨S,hS⟩ := surviving_columns A (k+1) + let cutoff := (conditions A S).left.length + let loc := CodingColumns.location (columns A k) (hA k) k cutoff + have hcol : Reduces (columns A k) A := CodingExtraction.column_projection_reduces A k + have hloc : Nat.RecursiveIn {oracleFunction A} (fun n => Part.some (loc n)) := + (CodingColumns.location_recursive (columns A k) (hA k) k cutoff).subst (fun f hf => by + have he : f = oracleFunction (columns A k) := Set.mem_singleton_iff.mp hf + subst f + exact RecursiveIn.iff_nat.mp hcol) + have hn := reads_not_reduces A loc hloc (fun N => ⟨N,CodingColumns.le_location _ _ _ _ _⟩) + let C := CodingColumns.readColumn (columns A k) (hA k) k cutoff (G₀ A) + have heq : C = CodingColumns.readColumn (columns A k) (hA k) k cutoff (G₁ A) := by + funext n + have hm := CodingColumns.location_mem (columns A k) (hA k) k cutoff n + simp only [CodingColumns.column] at hm + split at hm + next h => + apply hS _ h.1 + · rw [h.2]; omega + · simpa only [h.2] using hm + next h => simp at hm + exact ⟨C,CodingColumns.readColumn_reduces _ _ _ _ _, + heq ▸ CodingColumns.readColumn_reduces _ _ _ _ _,fun h => hn (reduces_trans h hcol)⟩ + +theorem effective_first_clause (A : Oracle) + (hA : ∀ k, {a | columns A k a = true}.Infinite) : + Reduces (join (G₀ A) (G₁ A)) (OracleJump.jump A) ∧ + ∀ k, ∃ C : Oracle, Reduces C (join (G₀ A) (columns A k)) ∧ + Reduces C (join (G₁ A) (columns A k)) ∧ ¬ Reduces C (columns A k) := + ⟨GuardedComputability.limits_recursive A,common_noncomputable_columns A hA⟩ + +end +end TuringRigidity.GuardedLimits + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/GuardedOutcomes.lean b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedOutcomes.lean new file mode 100644 index 0000000000000000000000000000000000000000..62bf3fc81d9a77123c8c56bece665f42f5241d4c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedOutcomes.lean @@ -0,0 +1,167 @@ +import OAI.Computability.DegreeRigidity.Effective.GuardedLimits + +namespace OAI + +namespace TuringRigidity.GuardedOutcomes +open ArithmeticHierarchy +open Encodable EncodedForcing CodingForcing FiniteInjury GuardedStage +open UniformProgram IndexMatrix +noncomputable section + +theorem candidate_decisive (A : Oracle) (t : ℕ) (p : Condition) + (hc : Changes A t p) : StablePair.Decisive A t (candidate A t p) := by + let p' := atLevel p t + let q := condition (pairProcedure A (Nat.pair t (code p'))) + obtain ⟨_,hdis | ⟨ha,hn,hd | ⟨he,hrest⟩⟩⟩ := + (Classical.choose_spec (GuardedPair.pair_exists A)).2 t (code p') + · exact Or.inl hdis + · have haq : q.active = t := by + change q.active = (condition (code p')).active at ha + simpa only [condition_code,p',atLevel] using ha + have heq : atLevel q t = q := by rw [← haq]; cases q; rfl + change StablePair.Decisive A t (atLevel q t) + rw [heq] + exact hd + · have heq : q = p' := by + change q = condition (code p') at he + simpa only [condition_code] using he + change (atLevel q t).left ≠ p.left ∨ (atLevel q t).right ≠ p.right at hc + rw [heq] at hc + exact False.elim (hc.elim (fun h => h rfl) (fun h => h rfl)) + +theorem limits_extend_action {A : Oracle} {s t : ℕ} + (ha : stageAction A s (construction A s) = some t) : + CommonIdeal.Extends (GuardedLimits.G₀ A) (candidate A t (generic A (construction A s))).left ∧ + CommonIdeal.Extends (GuardedLimits.G₁ A) (candidate A t (generic A (construction A s))).right := by + have hl : (candidate A t (generic A (construction A s))).left <+: (conditions A (s+1)).left := by + change _ <+: (stageWord A s (construction A s)).left ++ [false] + simp only [stageWord,ha] + exact List.prefix_append _ _ + have hr : (candidate A t (generic A (construction A s))).right <+: (conditions A (s+1)).right := by + change _ <+: (stageWord A s (construction A s)).right ++ [false] + simp only [stageWord,ha] + exact List.prefix_append _ _ + constructor + · intro m hm + exact ((limits_extend (word_growth A) (length_bound A) (s+1) m (hm.trans_le hl.length_le)).1).trans + (getD_of_prefix hl hm) + · intro m hm + have hn : m < (conditions A (s+1)).left.length := by + rw [(conditions A (s+1)).sameLength] + exact hm.trans_le hr.length_le + exact ((limits_extend (word_growth A) (length_bound A) (s+1) m hn).2).trans (getD_of_prefix hr hm) + +theorem action_excludes_common {A Y Z : Oracle} {s t : ℕ} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₀ A))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₁ A))) + (meaning (machine (item t 2))) = oracleFunction Z) : + stageAction A s (construction A s) ≠ some t := by + intro ha + have hc := (scan_spec ha).2.2.2 + obtain ⟨h₀,h₁⟩ := limits_extend_action ha + exact StablePair.decisive_excludes_common hbase h₀ h₁ he₀ he₁ (candidate_decisive A t _ hc) + +theorem done_witness (A : Oracle) {s t : ℕ} (ht : t ∈ (construction A s).done) : + ∃ u, u < s ∧ stageAction A u (construction A u) = some t := by + induction s with + | zero => simp [construction] at ht + | succ s ih => + change t ∈ FiniteInjury.update (construction A s).done (stageAction A s (construction A s)) at ht + cases ha : stageAction A s (construction A s) with + | none => + obtain ⟨u,hu,he⟩ := ih (by simpa [ha,FiniteInjury.update] using ht) + exact ⟨u,by omega,he⟩ + | some i => + simp only [ha,FiniteInjury.update,Finset.mem_insert,Finset.mem_filter] at ht + rcases ht with rfl | ⟨ht,_⟩ + · exact ⟨s,by omega,ha⟩ + · obtain ⟨u,hu,he⟩ := ih ht + exact ⟨u,by omega,he⟩ + +theorem common_not_done {A Y Z : Oracle} {s t : ℕ} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₀ A))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₁ A))) + (meaning (machine (item t 2))) = oracleFunction Z) : + t ∉ (construction A s).done := by + intro ht + obtain ⟨u,_,hu⟩ := done_witness A ht + exact action_excludes_common hbase he₀ he₁ hu + +theorem scan_hits {A : Oracle} {p : Condition} {d : Finset ℕ} {start n t : ℕ} + (hlo : start ≤ t) (hhi : t < start+n) (hd : t ∉ d) (hc : Changes A t p) : + ∃ i, i ≤ t ∧ scan A p d start n = some i := by + induction n generalizing start with + | zero => omega + | succ n ih => + by_cases h : start ∉ d ∧ Changes A start p + · exact ⟨start,hlo,by simp only [scan,ite_eq_left h]⟩ + · have hne : start ≠ t := by rintro rfl; exact h ⟨hd,hc⟩ + obtain ⟨i,hi,he⟩ := ih (start := start+1) (by omega) (by omega) + exact ⟨i,hi,by simpa only [scan,ite_eq_right h] using he⟩ + +theorem common_eventually_unchanged {A Y Z : Oracle} {t : ℕ} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₀ A))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₁ A))) + (meaning (machine (item t 2))) = oracleFunction Z) : + ∃ S, ∀ s, S ≤ s → ¬ Changes A t (generic A (construction A s)) := by + obtain ⟨S,hS⟩ := finite_injury (proposal A) (t+1) + refine ⟨max S (t+1),fun s hs hc => ?_⟩ + obtain ⟨i,hi,he⟩ := scan_hits (start := 0) (n := s) (Nat.zero_le t) + (by omega) (common_not_done (s := s) hbase he₀ he₁) hc + apply hS s ((le_max_left _ _).trans hs) i (by omega) + simpa only [action_eq,stageAction] using he + +theorem nonchanging_outcome {A Y Z : Oracle} {s t : ℕ} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₀ A))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₁ A))) + (meaning (machine (item t 2))) = oracleFunction Z) + (hchange : ¬ Changes A t (generic A (construction A s))) : + let p := atLevel (generic A (construction A s)) t + UniformAgreement.NoDisagreement A t p ∧ GuardedPair.NoBad A t p ∧ + ((¬ ∃ z, UniformSplit.SplitCert A (Nat.pair (UniformPair.request (Nat.pair t (code p))) z)) ∨ + ∃ w, UniformSplit.PointCert A (Nat.pair (UniformPair.request (Nat.pair t (code p))) w) ∧ + CodingLocation (columns A) p (item w 2)) := by + let p := atLevel (generic A (construction A s)) t + let q := condition (pairProcedure A (Nat.pair t (code p))) + have hwords : q.left = p.left ∧ q.right = p.right := by + change ¬ (q.left ≠ p.left ∨ q.right ≠ p.right) at hchange + exact ⟨Classical.not_not.mp (fun hn => hchange (Or.inl hn)), + Classical.not_not.mp (fun hn => hchange (Or.inr hn))⟩ + have hq₀ : CommonIdeal.Extends (GuardedLimits.G₀ A) q.left := by + rw [hwords.1]; exact (GuardedLimits.limits_extend_generic A s).1 + have hq₁ : CommonIdeal.Extends (GuardedLimits.G₁ A) q.right := by + rw [hwords.2]; exact (GuardedLimits.limits_extend_generic A s).2 + obtain ⟨_,hd | ⟨ha,hn,hd | ⟨he,hbad,hout⟩⟩⟩ := + (Classical.choose_spec (GuardedPair.pair_exists A)).2 t (code p) + · exact False.elim (StablePair.decisive_excludes_common hbase hq₀ hq₁ he₀ he₁ (Or.inl hd)) + · exact False.elim (StablePair.decisive_excludes_common hbase hq₀ hq₁ he₀ he₁ hd) + · refine ⟨by simpa only [condition_code] using hn,hbad,?_⟩ + simpa only [GuardedPair.Outcome,condition_code] using hout + +theorem common_eventually_outcome {A Y Z : Oracle} {t : ℕ} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₀ A))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (GuardedLimits.G₁ A))) + (meaning (machine (item t 2))) = oracleFunction Z) : + ∃ S, ∀ s, S ≤ s → + let p := atLevel (generic A (construction A s)) t + UniformAgreement.NoDisagreement A t p ∧ GuardedPair.NoBad A t p ∧ + ((¬ ∃ z, UniformSplit.SplitCert A (Nat.pair (UniformPair.request (Nat.pair t (code p))) z)) ∨ + ∃ w, UniformSplit.PointCert A (Nat.pair (UniformPair.request (Nat.pair t (code p))) w) ∧ + CodingLocation (columns A) p (item w 2)) := by + obtain ⟨S,hS⟩ := common_eventually_unchanged hbase he₀ he₁ + exact ⟨S,fun s hs => nonchanging_outcome hbase he₀ he₁ (hS s hs)⟩ + +end +end TuringRigidity.GuardedOutcomes + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/GuardedPair.lean b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..0609d2ea139308737eb7829ef7aa40f6bf2795f4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedPair.lean @@ -0,0 +1,127 @@ +import OAI.Computability.DegreeRigidity.Effective.StablePair + +namespace OAI + +namespace TuringRigidity.GuardedPair +open Encodable UniformOracle ArithmeticHierarchy OracleJump EncodedForcing EffectiveWitness IndexMatrix +open CodingForcing UniformProgram UniformPair +noncomputable section +attribute [local instance] Classical.propDecidable + +def BadCert (A : Oracle) (v : ℕ) : Prop := + UniformSplit.PointCert A (Nat.pair (request (Nat.unpair v).1) (Nat.unpair v).2) ∧ + ¬ IsCoding A (Nat.pair (Nat.unpair (Nat.unpair v).1).2 (Nat.pair 1 (Nat.unpair v).2)) + +def NoBad (A : Oracle) (x : ℕ) (p : Condition) : Prop := + ¬ ∃ w, BadCert A (Nat.pair (Nat.pair x (code p)) w) + +theorem badCert_sigma (A : Oracle) : Sigma A 1 (BadCert A) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hp := (UniformSplit.pointCert_sigma A).comp + (Primrec₂.natPair.comp (request_primrec.comp f) r) + have hc := recursive_comp (recursive_not (coding_recursive A)) + (Primrec₂.natPair.comp (r.comp f) (Primrec₂.natPair.comp (Primrec.const 1) r)) + exact hp.and (Form.raise (n := 0) (s := true) hc) + +theorem bad_decisive (A : Oracle) (x p w : ℕ) + (hn : UniformAgreement.NoDisagreement A x (condition p)) + (hb : BadCert A (Nat.pair (Nat.pair x p) w)) : + StablePair.Decisive A x (condition (EffectiveSplitConditions.update p (Nat.pair 2 w))) := by + obtain ⟨hp,hnc⟩ := hb + have hpq : left p <+: word (item w 1) := by + simpa [UniformSplit.PointCert,UniformSplit.start,request,item,word] using hp.1 + let q := append (condition p) ((word (item w 1)).drop (left p).length) + have hl : q.left = word (item w 1) := by + change left p ++ (word (item w 1)).drop (left p).length = _ + rw [List.prefix_iff_eq_take] at hpq + conv_lhs => lhs; rw [hpq] + exact List.take_append_drop _ _ + have hpoint : (left p).length ≤ item w 2 ∧ item w 2 < (word (item w 1)).length ∧ + item w 4 ≠ item w 5 ∧ + item w 4 ∈ UniformRun.run A (machine (item x 0)) (machine (item x 1)) (word (item w 1)) (item w 0) ∧ + item w 5 ∈ UniformRun.run A (machine (item x 0)) (machine (item x 1)) + ((word (item w 1)).set (item w 2) (item w 3).bodd) (item w 0) := by + simpa [UniformSplit.PointCert,UniformSplit.start,UniformSplit.base,UniformSplit.program, + request,item,word] using hp.2 + have hd := split_coding_or_divergence (r := q) hn (append_extends (columns A) (condition p) + ((word (item w 1)).drop (left p).length)) (item w 2) hpoint.1 + (by simpa [hl] using hpoint.2.1) (item w 3).bodd (item w 0) (item w 4) (item w 5) + hpoint.2.2.1 (by simpa [hl] using hpoint.2.2.2.1) (by simpa [hl] using hpoint.2.2.2.2) + have hnc' : ¬ CodingLocation (columns A) (condition p) (item w 2) := by + simpa only [IsCoding,Nat.unpair_pair] using hnc + have he : condition (EffectiveSplitConditions.update p (Nat.pair 2 w)) = q := by + simp [EffectiveSplitConditions.update,Nat.unpair_pair,condition_code,q] + rw [he] + exact Or.inr ⟨2,item w 0,Or.inr rfl,by simpa using hd.resolve_left hnc'⟩ + +def Outcome (A : Oracle) (x p : ℕ) : Prop := + (¬ ∃ z, UniformSplit.SplitCert A (Nat.pair (request (Nat.pair x p)) z)) ∨ + ∃ w, UniformSplit.PointCert A (Nat.pair (request (Nat.pair x p)) w) ∧ + CodingLocation (columns A) (condition p) (item w 2) + +theorem next_exists (A : Oracle) : ∃ g : ℕ → ℕ, + Nat.RecursiveIn {oracleFunction (jump A)} (fun v => Part.some (g v)) ∧ + (∀ x p, Extends (columns A) (condition p) (condition (g (Nat.pair x p))) ∧ + (condition (g (Nat.pair x p))).active = (condition p).active) ∧ + ∀ x p, UniformAgreement.NoDisagreement A x (condition p) → + StablePair.Decisive A x (condition (g (Nat.pair x p))) ∨ + (condition (g (Nat.pair x p)) = condition p ∧ + (¬ ∃ w, BadCert A (Nat.pair (Nat.pair x p) w)) ∧ Outcome A x p) := by + obtain ⟨search,hs,hsearch⟩ := sigma1_choice (badCert_sigma A) + let g := fun v => if search v = 0 then next A v else + EffectiveSplitConditions.update (Nat.unpair v).2 (Nat.pair 2 (search v-1)) + have hrec : Nat.RecursiveIn {oracleFunction (jump A)} (fun v => Part.some (g v)) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hu := total_comp (total_primrec (EffectiveSplitConditions.update_primrec.comp f r)) + (total_pair (total_primrec r) (total_comp (total_primrec + (Primrec₂.natPair.comp (Primrec.const 2) (Primrec.nat_sub.comp Primrec.id (Primrec.const 1)))) hs)) + have hi := Primrec.ite (Primrec.eq.comp f (Primrec.const 0)) (f.comp r) (r.comp r) + exact (total_comp (total_primrec hi) (total_pair hs (total_pair (next_recursive A) hu))).of_eq + (fun v => by simp only [Nat.unpair_pair]; rfl) + refine ⟨g,hrec,fun x p => ?_,fun x p hn => ?_⟩ + · by_cases hz : search (Nat.pair x p) = 0 + · simpa only [g,ite_eq_left hz,Nat.unpair_pair] using next_extends A (Nat.pair x p) + · simp only [g,ite_eq_right hz,Nat.unpair_pair,EffectiveSplitConditions.update,↓reduceIte,condition_code] + exact ⟨append_extends _ _ _,rfl⟩ + · rcases hsearch (Nat.pair x p) with ⟨hz,hno⟩ | ⟨hpos,hbad⟩ + · simp only [g,ite_eq_left hz] + rcases (StablePair.next_precise A x p hn).2.2 with ⟨he,ho⟩ | hd + · exact Or.inr ⟨he,hno,ho⟩ + · exact Or.inl (Or.inr hd) + · have hz : search (Nat.pair x p) ≠ 0 := by omega + simp only [g,ite_eq_right hz,Nat.unpair_pair] + exact Or.inl (bad_decisive A x p _ hn hbad) + +theorem pair_exists (A : Oracle) : ∃ f : ℕ → ℕ, + Nat.RecursiveIn {oracleFunction (jump A)} (fun v => Part.some (f v)) ∧ + ∀ x p, Extends (columns A) (condition p) (condition (f (Nat.pair x p))) ∧ + (UniformAgreement.Disagreement A x (condition (f (Nat.pair x p))) ∨ + ((condition (f (Nat.pair x p))).active = (condition p).active ∧ + UniformAgreement.NoDisagreement A x (condition p) ∧ + (StablePair.Decisive A x (condition (f (Nat.pair x p))) ∨ + (condition (f (Nat.pair x p)) = condition p ∧ + (¬ ∃ w, BadCert A (Nat.pair (Nat.pair x p) w)) ∧ Outcome A x p)))) := by + obtain ⟨d,hd,hds⟩ := StablePair.decide_stable_exists A + obtain ⟨g,hg,hge,hgs⟩ := next_exists A + let f := fun v => g (Nat.pair (Nat.unpair v).1 (d v)) + refine ⟨f,?_,fun x p => ?_⟩ + · exact (total_comp hg (total_pair (total_primrec (Primrec.fst.comp Primrec.unpair)) hd)).of_eq (fun v => rfl) + · obtain ⟨hp,hm⟩ := hds x p + have hq := hge x (d (Nat.pair x p)) + refine ⟨by simpa only [f,Nat.unpair_pair] using extends_trans hp hq.1,?_⟩ + rcases hm with hm | ⟨he,hn⟩ + · exact Or.inl (by simpa only [f,Nat.unpair_pair] using disagreement_mono hq.1 hm) + · simpa only [f,Nat.unpair_pair,he] using Or.inr ⟨(hge x p).2,hn,hgs x p hn⟩ + +noncomputable def procedure (A : Oracle) : ℕ → ℕ := Classical.choose (pair_exists A) + +theorem procedure_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (jump A)} (fun v => Part.some (procedure A v)) := + (Classical.choose_spec (pair_exists A)).1 + +end +end TuringRigidity.GuardedPair + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/GuardedScan.lean b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedScan.lean new file mode 100644 index 0000000000000000000000000000000000000000..83af063f006fe512f8825f0c5b040d29fb9ef71d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedScan.lean @@ -0,0 +1,113 @@ +import OAI.Computability.DegreeRigidity.Effective.StageRecords +import OAI.Computability.DegreeRigidity.Effective.GuardedStage + +namespace OAI + +namespace TuringRigidity.GuardedComputability +open Encodable UniformOracle EncodedForcing CodingForcing FiniteInjury StageRecords +noncomputable section +attribute [local instance] Classical.propDecidable + +abbrev f := Primrec.fst.comp Primrec.unpair +abbrev r := Primrec.snd.comp Primrec.unpair + +def levelCode (p t : ℕ) : ℕ := Nat.pair (encode (left p)) (Nat.pair (encode (right p)) t) + +theorem levelCode_primrec : Primrec₂ levelCode := Primrec₂.natPair.comp + (Primrec.encode.comp (left_primrec.comp Primrec.fst)) + (Primrec₂.natPair.comp (Primrec.encode.comp (right_primrec.comp Primrec.fst)) Primrec.snd) + +theorem levelCode_eq (p t : ℕ) : levelCode p t = code (atLevel (condition p) t) := rfl + +@[simp] theorem condition_levelCode (p t : ℕ) : condition (levelCode p t) = atLevel (condition p) t := + condition_code (atLevel (condition p) t) + +def candidate (A : Oracle) (v : ℕ) : ℕ := + levelCode (GuardedStage.pairProcedure A (Nat.pair (Nat.unpair v).1 + (levelCode (Nat.unpair v).2 (Nat.unpair v).1))) (Nat.unpair v).1 + +theorem candidate_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun v => Part.some (candidate A v)) := by + have h := total_comp (GuardedStage.pairProcedure_recursive A) + (total_primrec (Primrec₂.natPair.comp f (levelCode_primrec.comp r f))) + have hh := total_comp (total_primrec (levelCode_primrec.comp f r)) (total_pair h (total_primrec f)) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +@[simp] theorem candidate_eq (A : Oracle) (t p : ℕ) : + condition (candidate A (Nat.pair t p)) = GuardedStage.candidate A t (condition p) := by + simp only [candidate,Nat.unpair_pair,levelCode_eq,GuardedStage.candidate,condition_code] + +def scanStep (A : Oracle) (v : ℕ) : ℕ := + let p := (Nat.unpair (Nat.unpair v).1).1 + let d := (Nat.unpair (Nat.unpair v).1).2 + let t := (Nat.unpair (Nat.unpair v).2).1 + let prev := (Nat.unpair (Nat.unpair v).2).2 + let c := candidate A (Nat.pair t p) + if prev = 0 ∧ t ∉ record d ∧ (left c ≠ left p ∨ right c ≠ right p) then t+1 else prev + +theorem scanStep_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun v => Part.some (scanStep A v)) := by + have hc := total_comp (candidate_recursive A) + (total_primrec (Primrec₂.natPair.comp (f.comp r) (f.comp f))) + let v := f + let c := r + let p := f.comp (f.comp v) + let d := r.comp (f.comp v) + let t := f.comp (r.comp v) + let prev := r.comp (r.comp v) + have hm := (mem_primrec.comp d t).not + have hl := (Primrec.eq.comp (left_primrec.comp c) (left_primrec.comp p)).not + have hr := (Primrec.eq.comp (right_primrec.comp c) (right_primrec.comp p)).not + have hpost := Primrec.ite ((Primrec.eq.comp prev (Primrec.const 0)).and (hm.and (hl.or hr))) + (Primrec.succ.comp t) prev + have hh := total_comp (total_primrec hpost) (total_pair (total_primrec Primrec.id) hc) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +def scan (A : Oracle) (p d n : ℕ) : ℕ := recur (fun _ => 0) (scanStep A) (Nat.pair p d) n + +theorem scan_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun v => + Part.some (scan A (Nat.unpair (Nat.unpair v).1).1 (Nat.unpair (Nat.unpair v).1).2 (Nat.unpair v).2)) := by + simpa only [scan,Nat.pair_unpair] using recur_recursive (total_primrec (Primrec.const 0)) (scanStep_recursive A) + +theorem source_scan_succ (A : Oracle) (p : Condition) (d : Finset ℕ) (t n : ℕ) : + GuardedStage.scan A p d t (n+1) = + match GuardedStage.scan A p d t n with + | some i => some i + | none => if t+n ∉ d ∧ GuardedStage.Changes A (t+n) p then some (t+n) else none := by + induction n generalizing t with + | zero => simp [GuardedStage.scan] + | succ n ih => + change (if t ∉ d ∧ GuardedStage.Changes A t p then some t else GuardedStage.scan A p d (t+1) (n+1)) = + match (if t ∉ d ∧ GuardedStage.Changes A t p then some t else GuardedStage.scan A p d (t+1) n) with + | some i => some i + | none => if t+(n+1) ∉ d ∧ GuardedStage.Changes A (t+(n+1)) p then some (t+(n+1)) else none + by_cases ht : t ∉ d ∧ GuardedStage.Changes A t p + · simp only [ite_eq_left ht] + · simpa only [ite_eq_right ht,Nat.add_assoc,Nat.add_comm,Nat.add_left_comm] using ih (t+1) + +theorem scan_eq (A : Oracle) (p d n : ℕ) : + scan A p d n = actionCode (GuardedStage.scan A (condition p) (members d) 0 n) := by + induction n with + | zero => rfl + | succ n ih => + rw [source_scan_succ] + change scanStep A (Nat.pair (Nat.pair p d) (Nat.pair n (scan A p d n))) = _ + simp only [scanStep,Nat.unpair_pair,ih,Nat.zero_add] + have hc : left (candidate A (Nat.pair n p)) ≠ left p ∨ + right (candidate A (Nat.pair n p)) ≠ right p ↔ GuardedStage.Changes A n (condition p) := by + change (condition (candidate A (Nat.pair n p))).left ≠ (condition p).left ∨ + (condition (candidate A (Nat.pair n p))).right ≠ (condition p).right ↔ _ + rw [candidate_eq] + rfl + cases he : GuardedStage.scan A (condition p) (members d) 0 n with + | none => + by_cases hn : n ∉ record d ∧ GuardedStage.Changes A n (condition p) + · simp_all only [actionCode,members,List.mem_toFinset,true_and]; simp + · simp_all only [actionCode,members,List.mem_toFinset,true_and]; simp + | some i => simp [actionCode] + +end +end TuringRigidity.GuardedComputability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/GuardedStage.lean b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedStage.lean new file mode 100644 index 0000000000000000000000000000000000000000..52101f672b40207d5f10f5010e97fa46ad6ebd4e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/GuardedStage.lean @@ -0,0 +1,190 @@ +import OAI.Computability.DegreeRigidity.Effective.GuardedPair +import OAI.Computability.DegreeRigidity.CohenForcing.EffectiveForcing +import OAI.Computability.DegreeRigidity.Effective.FiniteInjuryLimits +import OAI.Computability.DegreeRigidity.Effective.FiniteInjurySchedule + +namespace OAI + +namespace TuringRigidity.GuardedStage +open Encodable CodingForcing EncodedForcing FiniteInjury +noncomputable section +attribute [local instance] Classical.propDecidable + +def pairProcedure (A : Oracle) : ℕ → ℕ := GuardedPair.procedure A + +theorem pairProcedure_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun v => Part.some (pairProcedure A v)) := + (Classical.choose_spec (GuardedPair.pair_exists A)).1 + +def candidate (A : Oracle) (t : ℕ) (p : Condition) : Condition := + atLevel (condition (pairProcedure A (Nat.pair t (code (atLevel p t))))) t + +theorem candidate_extends (A : Oracle) (t : ℕ) (p : Condition) : + Extends (columns A) (atLevel p t) (candidate A t p) := by + have h := ((Classical.choose_spec (GuardedPair.pair_exists A)).2 t (code (atLevel p t))).1 + rw [condition_code] at h + exact ⟨h.1,h.2.1,le_rfl,h.2.2.2⟩ + +def Changes (A : Oracle) (t : ℕ) (p : Condition) : Prop := + (candidate A t p).left ≠ p.left ∨ (candidate A t p).right ≠ p.right + +def scan (A : Oracle) (p : Condition) (done : Finset ℕ) (t : ℕ) : ℕ → Option ℕ + | 0 => none + | n+1 => if t ∉ done ∧ Changes A t p then some t else scan A p done (t+1) n + +theorem scan_spec {A : Oracle} {p : Condition} {done : Finset ℕ} {t n i : ℕ} + (h : scan A p done t n = some i) : + t ≤ i ∧ i < t+n ∧ i ∉ done ∧ Changes A i p := by + induction n generalizing t with + | zero => simp [scan] at h + | succ n ih => + simp only [scan] at h + split at h + · rename_i ht + have he := Option.some.inj h + subst i + exact ⟨le_rfl,by omega,ht⟩ + · obtain ⟨hlo,hhi,hd,hc⟩ := ih h + exact ⟨by omega,by omega,hd,hc⟩ + +def openProcedure (A : Oracle) : ℕ → ℕ := + Classical.choose (EffectiveForcing.uniform_open_decision A A (reduces_refl A)) + +theorem open_extends (A : Oracle) (e : ℕ) (p : Condition) : + Extends (columns A) p (condition (openProcedure A (Nat.pair e (code p)))) := by + have h := ((Classical.choose_spec (EffectiveForcing.uniform_open_decision A A (reduces_refl A))).2 e (code p)).1 + simpa only [condition_code,openProcedure] using h + +structure State where + condition : Condition + done : Finset ℕ + seen : Finset ℕ + +def generic (A : Oracle) (p : State) : Condition := + EncodedForcing.condition (openProcedure A (Nat.pair (FiniteInjurySchedule.visit p.seen) (code p.condition))) + +def stageAction (A : Oracle) (s : ℕ) (p : State) : Option ℕ := scan A (generic A p) p.done 0 s + +def stageWord (A : Oracle) (s : ℕ) (p : State) : Condition := + match stageAction A s p with + | none => generic A p + | some t => candidate A t (generic A p) + +def advance (A : Oracle) (s : ℕ) (p : State) : State where + condition := atLevel (append (stageWord A s p) [false]) (s+1) + done := FiniteInjury.update p.done (stageAction A s p) + seen := FiniteInjurySchedule.reset (insert (FiniteInjurySchedule.visit p.seen) p.seen) (stageAction A s p) + +def construction (A : Oracle) : ℕ → State + | 0 => ⟨⟨[],[],rfl,0⟩,∅,∅⟩ + | s+1 => advance A s (construction A s) + +def conditions (A : Oracle) (s : ℕ) := (construction A s).condition + +def proposal (A : Oracle) (s : ℕ) (_ : Finset ℕ) : Option ℕ := + stageAction A s (construction A s) + +theorem action_not_done (A : Oracle) (s : ℕ) (p : State) (t : ℕ) + (h : stageAction A s p = some t) : t ∉ p.done := (scan_spec h).2.2.1 + +theorem accept_action (A : Oracle) (s : ℕ) (p : State) : + FiniteInjury.accept p.done (stageAction A s p) = stageAction A s p := by + cases ha : stageAction A s p with + | none => simp [FiniteInjury.accept] + | some t => simp [FiniteInjury.accept,action_not_done A s p t ha] + +theorem done_eq (A : Oracle) (s : ℕ) : + (construction A s).done = FiniteInjury.state (proposal A) s := by + induction s with + | zero => rfl + | succ s ih => + change FiniteInjury.update (construction A s).done (stageAction A s (construction A s)) = _ + rw [FiniteInjury.state] + rw [← ih] + simp only [proposal,accept_action] + +theorem action_eq (A : Oracle) (s : ℕ) : + FiniteInjury.action (proposal A) s = stageAction A s (construction A s) := by + rw [FiniteInjury.action,← done_eq] + exact accept_action A s _ + +theorem seen_eq (A : Oracle) (s : ℕ) : + (construction A s).seen = FiniteInjurySchedule.seen (proposal A) s := by + induction s with + | zero => rfl + | succ s ih => + change FiniteInjurySchedule.reset _ _ = _ + rw [FiniteInjurySchedule.seen,action_eq,← ih] + +theorem active_eq (A : Oracle) (s : ℕ) : (conditions A s).active = s := by + cases s <;> rfl + +theorem stage_words (A : Oracle) (s : ℕ) (p : State) : + p.condition.left <+: (stageWord A s p).left ∧ p.condition.right <+: (stageWord A s p).right := by + have ho := open_extends A (FiniteInjurySchedule.visit p.seen) p.condition + cases ha : stageAction A s p with + | none => exact ⟨by simpa [stageWord,ha,generic] using ho.1,by simpa [stageWord,ha,generic] using ho.2.1⟩ + | some t => + have hc := candidate_extends A t (generic A p) + exact ⟨by simpa [stageWord,ha] using ho.1.trans hc.1, + by simpa [stageWord,ha] using ho.2.1.trans hc.2.1⟩ + +theorem word_growth (A : Oracle) (s : ℕ) : + (conditions A s).left <+: (conditions A (s+1)).left ∧ + (conditions A s).right <+: (conditions A (s+1)).right := by + have h := stage_words A s (construction A s) + exact ⟨h.1.trans (List.prefix_append _ _),h.2.trans (List.prefix_append _ _)⟩ + +theorem length_bound (A : Oracle) (s : ℕ) : s ≤ (conditions A s).left.length := by + induction s with + | zero => exact Nat.zero_le _ + | succ s ih => + have h := (stage_words A s (construction A s)).1.length_le + change s+1 ≤ ((stageWord A s (construction A s)).left ++ [false]).length + simp only [List.length_append,List.length_singleton] + exact Nat.add_le_add_right (ih.trans h) 1 + +theorem level_step (A : Oracle) (s k : ℕ) (hk : k ≤ s) + (hact : ∀ t, FiniteInjury.action (proposal A) s = some t → k ≤ t) : + Extends (columns A) (atLevel (conditions A s) k) (atLevel (conditions A (s+1)) k) := by + let p := construction A s + have ho := open_extends A (FiniteInjurySchedule.visit p.seen) p.condition + have hg : Extends (columns A) (atLevel p.condition k) (atLevel (generic A p) k) := by + refine ⟨ho.1,ho.2.1,le_rfl,?_⟩ + intro m hm hlen + apply ho.2.2.2 m ⟨hm.1,?_,hm.2.2⟩ hlen + exact hm.2.1.trans_le (by + change k ≤ (conditions A s).active + rw [active_eq] + exact hk) + have hw : Extends (columns A) (atLevel (generic A p) k) (atLevel (stageWord A s p) k) := by + cases ha : stageAction A s p with + | none => simpa [stageWord,ha] using extends_refl (columns A) (atLevel (generic A p) k) + | some t => + have hkt : k ≤ t := hact t (by simpa [action_eq,p] using ha) + have hc := candidate_extends A t (generic A p) + have hc' : Extends (columns A) (atLevel (generic A p) t) (atLevel (candidate A t (generic A p)) t) := hc + simpa [stageWord,ha] using level_mono hc' hkt + have htail : Extends (columns A) (atLevel (stageWord A s p) k) + (atLevel (conditions A (s+1)) k) := append_extends _ _ [false] + exact extends_trans hg (extends_trans hw htail) + +theorem surviving_columns (A : Oracle) (k : ℕ) : ∃ S, ∀ m, + (conditions A S).left.length ≤ m → (Nat.unpair m).1 < k → + columns A (Nat.unpair m).1 (Nat.unpair m).2 = true → + leftLimit (conditions A) m = rightLimit (conditions A) m := + eventual_column_agreement (columns A) (proposal A) (conditions A) + (word_growth A) (length_bound A) (level_step A) k + +theorem surviving_generic_visit (A : Oracle) (t : ℕ) : ∃ s, + FiniteInjurySchedule.visit (construction A s).seen = t ∧ + ∀ u, s ≤ u → ∀ i < t, stageAction A u (construction A u) ≠ some i := by + obtain ⟨s,hs,hh⟩ := FiniteInjurySchedule.surviving_visit (proposal A) t + refine ⟨s,?_,?_⟩ + · simpa [seen_eq,FiniteInjurySchedule.scheduled] using hs + · simpa only [action_eq] using hh + +end +end TuringRigidity.GuardedStage + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/IndependentFamily.lean b/lean/OAI/Computability/DegreeRigidity/Effective/IndependentFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..744c21c43599c699f54e6d5d3f71ade0ac46cb59 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/IndependentFamily.lean @@ -0,0 +1,127 @@ +import OAI.Computability.DegreeRigidity.SetModels.ConservativeExtension +import Mathlib.Data.Finset.Lattice.Fold + +namespace OAI + +namespace TuringRigidity.IndependentFamily + +noncomputable def fresh (b : Degree) : Degree := + Classical.choose (ConservativeExtension.exists_conservative_degree b) + +theorem fresh_spec (b : Degree) : ¬ fresh b ≤ b ∧ + ∀ a y : Degree, a ≤ b → y ≤ b → y ≤ a ⊔ fresh b → y ≤ a := + Classical.choose_spec (ConservativeExtension.exists_conservative_degree b) + +noncomputable def tower (b : Degree) : ℕ → Degree + | 0 => b + | n+1 => tower b n ⊔ fresh (tower b n) + +noncomputable def column (b : Degree) (n : ℕ) : Degree := fresh (tower b n) + +theorem tower_mono (b : Degree) : Monotone (tower b) := by + apply monotone_nat_of_le_succ + intro n + exact le_sup_left + +theorem base_le (b : Degree) (n : ℕ) : b ≤ tower b n := tower_mono b (Nat.zero_le n) + +theorem column_le {b : Degree} {i n : ℕ} (hi : i < n) : column b i ≤ tower b n := + le_trans (show column b i ≤ tower b (i+1) from le_sup_right) (tower_mono b hi) + +theorem finite_le {b : Degree} {F : Finset ℕ} {n : ℕ} + (hF : ∀ i ∈ F, i < n) : F.sup (column b) ≤ tower b n := by + apply Finset.sup_le + intro i hi + exact column_le (hF i hi) + +theorem finite_conservative (b : Degree) (n : ℕ) (F : Finset ℕ) + (hF : ∀ i ∈ F, i < n) (a y : Degree) (ha : a ≤ b) (hy : y ≤ b) + (h : y ≤ a ⊔ F.sup (column b)) : y ≤ a := by + classical + induction n generalizing F with + | zero => + have he : F = ∅ := Finset.eq_empty_iff_forall_notMem.mpr (fun i hi => by + have := hF i hi; omega) + simpa [he] using h + | succ n ih => + by_cases hn : n ∈ F + · have he : F = insert n (F.erase n) := (Finset.insert_erase hn).symm + have hsmall : ∀ i ∈ F.erase n, i < n := by + intro i hi + have hh := Finset.mem_erase.mp hi + have := hF i hh.2 + omega + have hh : y ≤ (a ⊔ (F.erase n).sup (column b)) ⊔ column b n := by + rw [he, Finset.sup_insert] at h + simpa only [sup_assoc, sup_comm, sup_left_comm] using h + have hd := (fresh_spec (tower b n)).2 _ _ + (sup_le (ha.trans (base_le b n)) (finite_le hsmall)) + (hy.trans (base_le b n)) hh + exact ih (F.erase n) hsmall hd + · apply ih F (fun i hi => ?_) h + have := hF i hi + have : i ≠ n := fun he => hn (he ▸ hi) + omega + +theorem column_membership (b : Degree) (n : ℕ) (F : Finset ℕ) + (hF : ∀ j ∈ F, j < n) (i : ℕ) (hi : i < n) + (h : column b i ≤ b ⊔ F.sup (column b)) : i ∈ F := by + classical + induction n generalizing F i with + | zero => omega + | succ n ih => + by_cases hin : i = n + · subst i + by_contra hn + have hsmall : ∀ j ∈ F, j < n := by + intro j hj + have := hF j hj + have : j ≠ n := fun he => hn (he ▸ hj) + omega + exact (fresh_spec (tower b n)).1 + (h.trans (sup_le (base_le b n) (finite_le hsmall))) + · have hi' : i < n := by omega + by_cases hn : n ∈ F + · have he : F = insert n (F.erase n) := (Finset.insert_erase hn).symm + have hsmall : ∀ j ∈ F.erase n, j < n := by + intro j hj + have hh := Finset.mem_erase.mp hj + have := hF j hh.2 + omega + have hh : column b i ≤ (b ⊔ (F.erase n).sup (column b)) ⊔ column b n := by + rw [he, Finset.sup_insert] at h + simpa only [sup_assoc, sup_comm, sup_left_comm] using h + have hd := (fresh_spec (tower b n)).2 _ _ + (sup_le (base_le b n) (finite_le hsmall)) (column_le hi') hh + exact Finset.mem_of_mem_erase (ih _ hsmall _ hi' hd) + · apply ih F (fun j hj => ?_) i hi' h + have := hF j hj + have : j ≠ n := fun he => hn (he ▸ hj) + omega + +theorem independence (b : Degree) (a₀ a₁ : Degree) (h₀ : a₀ ≤ b) (h₁ : a₁ ≤ b) + (i : ℕ) (F : Finset ℕ) : + a₀ ⊔ column b i ≤ a₁ ⊔ F.sup (column b) ↔ a₀ ≤ a₁ ∧ i ∈ F := by + classical + let n := max (i+1) (F.sup id + 1) + have hi : i < n := lt_of_lt_of_le (Nat.lt_succ_self i) (le_max_left _ _) + have hF : ∀ j ∈ F, j < n := by + intro j hj + have hj' : j ≤ F.sup id := Finset.le_sup (f := id) hj + exact lt_of_lt_of_le (Nat.lt_succ_of_le hj') (le_max_right _ _) + constructor + · intro h + refine ⟨finite_conservative b n F hF a₁ a₀ h₁ h₀ (le_sup_left.trans h), ?_⟩ + exact column_membership b n F hF i hi + (le_sup_right.trans (h.trans (sup_le_sup_right h₁ _))) + · rintro ⟨ha, hi⟩ + exact sup_le_sup ha (Finset.le_sup hi) + +theorem column_injective (b : Degree) : Function.Injective (column b) := by + intro i j hij + have h := (independence b ⊥ ⊥ bot_le bot_le i {j}).mp (by simp [hij]) + simpa using h.2 + +end TuringRigidity.IndependentFamily + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalAgreement.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalAgreement.lean new file mode 100644 index 0000000000000000000000000000000000000000..3db2521065e613d288ce259e59bf3bb8b5e05862 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalAgreement.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalColumnCertificates + +namespace OAI + +namespace TuringRigidity.LocalAgreement +open Encodable UniformOracle ArithmeticHierarchy OracleJump EncodedForcing EffectiveWitness IndexMatrix +open CodingForcing UniformProgram LocalColumnCertificates + +def NoDisagreement (B : Oracle) (F : ℕ → Oracle) (x : ℕ) (p : Condition) : Prop := + ∀ q, Extends F p q → ¬ UniformAgreement.Disagreement B x q + +def Cert (B : Oracle) (v : ℕ) : Prop := + let req := (Nat.unpair v).1 + let x := item req 1 + let p := item req 2 + let w := (Nat.unpair v).2 + Extension B (encode [item req 0,p,item w 0]) ∧ item w 2 ≠ item w 3 ∧ + item w 2 ∈ UniformRun.run B (machine (item x 0)) (machine (item x 1)) (left (item w 0)) (item w 1) ∧ + item w 3 ∈ UniformRun.run B (machine (item x 0)) (machine (item x 2)) (right (item w 0)) (item w 1) + +theorem cert_sigma (B : Oracle) : Sigma B 1 (Cert B) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let req (i : ℕ) := item_primrec.comp f (Primrec.const i) + let x (i : ℕ) := item_primrec.comp (req 1) (Primrec.const i) + let w (i : ℕ) := item_primrec.comp r (Primrec.const i) + have he := (extension_sigma B).comp (Primrec.encode.comp + (Primrec.list_cons.comp (req 0) (Primrec.list_cons.comp (req 2) + (Primrec.list_cons.comp (w 0) (Primrec.const []))))) + have hn := recursive_primrecPred B ((Primrec.eq.comp (w 2) (w 3)).not) + have hl := UniformRun.graph_sigma_of B (x 0) (x 1) (Primrec.encode.comp (left_primrec.comp (w 0))) (w 1) (w 2) + have hr := UniformRun.graph_sigma_of B (x 0) (x 2) (Primrec.encode.comp (right_primrec.comp (w 0))) (w 1) (w 3) + unfold Cert + simpa only [Nat.unpair_pair,word,encodek,Option.getD_some] using + he.and ((Form.raise (n := 0) (s := true) hn).and (hl.and hr)) + +theorem cert_iff {B : Oracle} {F : ℕ → Oracle} {codes p : ℕ} + (h : Presents B F codes (active p)) (x w : ℕ) : + Cert B (Nat.pair (encode [codes,x,p]) w) ↔ + Extends F (condition p) (condition (item w 0)) ∧ item w 2 ≠ item w 3 ∧ + item w 2 ∈ UniformRun.run B (machine (item x 0)) (machine (item x 1)) (left (item w 0)) (item w 1) ∧ + item w 3 ∈ UniformRun.run B (machine (item x 0)) (machine (item x 2)) (right (item w 0)) (item w 1) := by + simp only [Cert,Nat.unpair_pair,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] + exact and_congr (extension_condition_iff h) Iff.rfl + +theorem decide_exists (B : Oracle) : ∃ f : ℕ → ℕ, + Nat.RecursiveIn {oracleFunction (jump B)} (fun v => Part.some (f v)) ∧ + ∀ (F : ℕ → Oracle) codes x p, Presents B F codes (active p) → + Extends F (condition p) (condition (f (encode [codes,x,p]))) ∧ + (UniformAgreement.Disagreement B x (condition (f (encode [codes,x,p]))) ∨ + (f (encode [codes,x,p]) = p ∧ NoDisagreement B F x (condition p))) := by + obtain ⟨search,hs,hsearch⟩ := sigma1_choice (cert_sigma B) + let out : ℕ → ℕ := fun req => if search req = 0 then item req 2 else item (search req-1) 0 + have hmap : Primrec (fun v : ℕ => if (Nat.unpair v).2 = 0 then item (Nat.unpair v).1 2 + else item ((Nat.unpair v).2-1) 0) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + exact Primrec.ite (Primrec.eq.comp r (Primrec.const 0)) (item_primrec.comp f (Primrec.const 2)) + (item_primrec.comp (Primrec.nat_sub.comp r (Primrec.const 1)) (Primrec.const 0)) + refine ⟨out,?_,fun F codes x p h => ?_⟩ + · exact (total_comp (total_primrec hmap) (total_pair (total_primrec Primrec.id) hs)).of_eq + (fun v => by simp only [Nat.unpair_pair]; rfl) + · rcases hsearch (encode [codes,x,p]) with ⟨hz,hn⟩ | ⟨hp,hc⟩ + · have hout : out (encode [codes,x,p]) = p := by simp only [out,ite_eq_left hz,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] + rw [hout] + refine ⟨extends_refl _ _,Or.inr ⟨rfl,fun q hpq hd => ?_⟩⟩ + obtain ⟨n,a,b,hab,ha,hb⟩ := hd + apply hn + refine ⟨encode [code q,n,a,b],(cert_iff h x _).2 ?_⟩ + simpa [item,← show left (code q) = q.left from congrArg Condition.left (condition_code q), + ← show right (code q) = q.right from congrArg Condition.right (condition_code q),condition_code] using + And.intro hpq (And.intro hab (And.intro ha hb)) + · have hz : search (encode [codes,x,p]) ≠ 0 := by omega + simp only [out,ite_eq_right hz] + have hc' := (cert_iff h x _).1 hc + exact ⟨hc'.1,Or.inl ⟨_,_,_,hc'.2⟩⟩ + +end TuringRigidity.LocalAgreement + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalCoding.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalCoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..def3cf939207d682da64206351f1d2222200146d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalCoding.lean @@ -0,0 +1,65 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalExtraction +import OAI.Computability.DegreeRigidity.Effective.StageNormalization +import OAI.Computability.DegreeRigidity.Effective.AntichainParameters + +namespace OAI + +namespace TuringRigidity.LocalCoding +open EncodedForcing StageNormalization AntichainParameters + +theorem selected_coding {A B X : Oracle} (hAB : Reduces A B) (select : ℕ → ℕ) + (hs : Nat.RecursiveIn {oracleFunction X} (fun n => Part.some (select n))) : + ∃ G₀ G₁ : Oracle, Reduces (join G₀ G₁) (join X (OracleJump.jump B)) ∧ + (∀ k, ∃ C : Oracle, Reduces C (join G₀ (columns A (select k))) ∧ + Reduces C (join G₁ (columns A (select k))) ∧ ¬ Reduces C (columns A (select k))) ∧ + ∀ Y Z : Oracle, Reduces Y B → Reduces Z (join G₀ Y) → + Reduces Z (join G₁ Y) → ¬ Reduces Z Y → ∃ k, Reduces (columns A (select k)) Y := by + obtain ⟨codes,hcodes,hvalid⟩ := LocalColumnIndices.selected_prefixes + (reduces_trans (normalized_reduces A) hAB) select hs + let D : LocalInputs.Data := ⟨B,X,fun k => columns (normalized A) (select k),codes,hcodes,hvalid⟩ + obtain ⟨hbound,hfirst⟩ := LocalLimits.effective_first_clause D + (fun k => (normalized_spec A (select k)).2.1) + refine ⟨LocalLimits.G₀ D,LocalLimits.G₁ D,hbound,?_,?_⟩ + · intro k + obtain ⟨C,h₀,h₁,hn⟩ := hfirst k + obtain ⟨hBA,hAB'⟩ := (degree_eq_iff _ _).mp (normalized_spec A (select k)).1 + exact ⟨C,reduces_trans h₀ (join_mono (reduces_refl _) hBA), + reduces_trans h₁ (join_mono (reduces_refl _) hBA),fun h => hn (reduces_trans h hAB')⟩ + · intro Y Z hY h₀ h₁ hn + obtain ⟨k,hk⟩ := LocalExtraction.common_lower_computes_column (D := D) + (fun k => (normalized_spec A (select k)).2.2) hY + (reduces_trans h₀ (AntichainCoding.swap_join_reduces _ _)) + (reduces_trans h₁ (AntichainCoding.swap_join_reduces _ _)) hn + exact ⟨k,reduces_trans (((degree_eq_iff _ _).mp (normalized_spec A (select k)).1).2) hk⟩ + +theorem selected_antichain {A B X : Oracle} (hAB : Reduces A B) (select : ℕ → ℕ) + (hs : Nat.RecursiveIn {oracleFunction X} (fun n => Part.some (select n))) + (hAnti : ∀ i j, degree (columns A (select i)) ≤ degree (columns A (select j)) → + degree (columns A (select i)) = degree (columns A (select j))) : + ∃ g₀ g₁ : Degree, g₀ ⊔ g₁ ≤ degree (join X (OracleJump.jump B)) ∧ + ∀ x : Degree, CodedAntichain (degree B) g₀ g₁ x ↔ ∃ k, degree (columns A (select k)) = x := by + obtain ⟨G₀,G₁,hbound,hfirst,hsecond⟩ := selected_coding hAB select hs + have hm : ∀ k, NontrivialCommonLower (degree B) (degree G₀) (degree G₁) (degree (columns A (select k))) := by + intro k + obtain ⟨C,h₀,h₁,hn⟩ := hfirst k + exact ⟨reduces_trans (CodingExtraction.column_projection_reduces A (select k)) hAB,degree C,h₀,h₁,hn⟩ + have hc : ∀ x, NontrivialCommonLower (degree B) (degree G₀) (degree G₁) x → + ∃ k, degree (columns A (select k)) ≤ x := by + intro x hx + obtain ⟨Y,rfl⟩ := degree_surjective x + obtain ⟨z,h₀,h₁,hn⟩ := hx.2 + obtain ⟨Z,rfl⟩ := degree_surjective z + exact hsecond Y Z hx.1 h₀ h₁ hn + refine ⟨degree G₀,degree G₁,hbound,fun x => ?_⟩ + constructor + · intro hx + obtain ⟨k,hk⟩ := hc x hx.1 + exact ⟨k,le_antisymm hk (hx.2 _ (hm k) hk)⟩ + · rintro ⟨k,rfl⟩ + refine ⟨hm k,fun y hy hyk => ?_⟩ + obtain ⟨j,hj⟩ := hc y hy + exact hAnti j k (hj.trans hyk) ▸ hj + +end TuringRigidity.LocalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalColumnCertificates.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalColumnCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..64f3d8ec724c435ac352725cd7df1a72b9a45702 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalColumnCertificates.lean @@ -0,0 +1,175 @@ +import OAI.Computability.DegreeRigidity.SetModels.FiniteSupport + +namespace OAI + +namespace TuringRigidity.LocalColumnCertificates +open Encodable UniformOracle ArithmeticHierarchy EncodedForcing CodingForcing + +def Output (B : Oracle) (v : ℕ) : Prop := + ∃ z, (Nat.unpair (Nat.unpair v).2).2 ∈ TableIndices.run B + (IndexMatrix.machine (Nat.unpair v).1) (Nat.unpair (Nat.unpair v).2).1 z + +theorem output_sigma (B : Oracle) : Sigma B 1 (Output B) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hr := total_comp (IndexMatrix.run_uniform_recursive B) (total_primrec + (Primrec₂.natPair.comp (f.comp f) (Primrec₂.natPair.comp (f.comp (r.comp f)) r))) + have heq := Primrec.ite (Primrec.eq.comp + (Primrec.option_getD.comp (Primrec.decode.comp f) (Primrec.const none)) + (Primrec.option_some.comp r)) (Primrec.const 1) (Primrec.const 0) + have hh : RecursivePred B (fun v => (Nat.unpair (Nat.unpair (Nat.unpair v).1).2).2 ∈ + TableIndices.run B (IndexMatrix.machine (Nat.unpair (Nat.unpair v).1).1) + (Nat.unpair (Nat.unpair (Nat.unpair v).1).2).1 (Nat.unpair v).2) := by + exact (total_comp (total_primrec heq) (total_pair hr (total_primrec (r.comp (r.comp f))))).of_eq + (fun v => by simp [Option.mem_def]) + apply (exists_form (n := 0) hh).congr + intro v + simp only [Output,Nat.unpair_pair] + +def Presents (B : Oracle) (F : ℕ → Oracle) (codes count : ℕ) : Prop := + ∀ k, k < count → TableIndices.Represents B (IndexMatrix.machine (item codes k)) (F k) + +theorem output_iff {B : Oracle} {F : ℕ → Oracle} {codes count k : ℕ} + (h : Presents B F codes count) (hk : k < count) (a v : ℕ) : + Output B (Nat.pair (item codes k) (Nat.pair a v)) ↔ v = CommonIdeal.bit (F k a) := by + constructor + · rintro ⟨z,hz⟩ + exact (h k hk).1 a z v (by simpa only [Nat.unpair_pair] using hz) + · intro hv + obtain ⟨z,b,hb⟩ := (h k hk).2 a + have he := (h k hk).1 a z b hb + exact ⟨z,by simpa only [Nat.unpair_pair,hv,he] using hb⟩ + +def Noncoding (B : Oracle) (v : ℕ) : Prop := + let codes := (Nat.unpair v).1 + let p := (Nat.unpair (Nat.unpair v).2).1 + let m := (Nat.unpair (Nat.unpair v).2).2 + m < (left p).length ∨ active p ≤ (Nat.unpair m).1 ∨ + Output B (Nat.pair (item codes (Nat.unpair m).1) (Nat.pair (Nat.unpair m).2 0)) + +theorem noncoding_sigma (B : Oracle) : Sigma B 1 (Noncoding B) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let p := f.comp r + let m := r.comp r + have hl := recursive_primrecPred B (Primrec.nat_lt.comp m (Primrec.list_length.comp (left_primrec.comp p))) + have hk := recursive_primrecPred B (Primrec.nat_le.comp (active_primrec.comp p) (f.comp m)) + have ho := (output_sigma B).comp (Primrec₂.natPair.comp (item_primrec.comp f (f.comp m)) + (Primrec₂.natPair.comp (r.comp m) (Primrec.const 0))) + exact (Form.raise (n := 0) (s := true) hl).or ((Form.raise (n := 0) (s := true) hk).or ho) + +theorem noncoding_condition_iff {B : Oracle} {F : ℕ → Oracle} {codes : ℕ} {p : ℕ} + (h : Presents B F codes (active p)) (m : ℕ) : + Noncoding B (Nat.pair codes (Nat.pair p m)) ↔ ¬ CodingLocation F (condition p) m := by + simp only [Noncoding,Nat.unpair_pair,CodingLocation,condition] + by_cases hk : (Nat.unpair m).1 < active p + · rw [output_iff h hk] + cases F (Nat.unpair m).1 (Nat.unpair m).2 <;> simp [CommonIdeal.bit,hk] + · simp [hk,show active p ≤ (Nat.unpair m).1 from Nat.le_of_not_gt hk] + +theorem noncoding_iff {B : Oracle} {F : ℕ → Oracle} {codes : ℕ} {p : Condition} + (h : Presents B F codes p.active) (m : ℕ) : + Noncoding B (Nat.pair codes (Nat.pair (code p) m)) ↔ ¬ CodingLocation F p m := by + have hh : Presents B F codes (active (code p)) := by + change Presents B F codes (condition (code p)).active + simpa only [condition_code] using h + simpa only [condition_code] using noncoding_condition_iff hh m + +def Allowed (B : Oracle) (v : ℕ) : Prop := + let req := (Nat.unpair v).1 + let m := (Nat.unpair v).2 + (left (item req 2)).getD m false = (right (item req 2)).getD m false ∨ + Noncoding B (Nat.pair (item req 0) (Nat.pair (item req 1) m)) + +theorem allowed_sigma (B : Oracle) : Sigma B 1 (Allowed B) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let req (i : ℕ) := item_primrec.comp f (Primrec.const i) + have he := recursive_primrecPred B (Primrec.eq.comp + ((Primrec.list_getD false).comp (left_primrec.comp (req 2)) r) + ((Primrec.list_getD false).comp (right_primrec.comp (req 2)) r)) + have hn := (noncoding_sigma B).comp (Primrec₂.natPair.comp (req 0) (Primrec₂.natPair.comp (req 1) r)) + exact (Form.raise (n := 0) (s := true) he).or hn + +def Extension (B : Oracle) (req : ℕ) : Prop := + left (item req 1) <+: left (item req 2) ∧ right (item req 1) <+: right (item req 2) ∧ + active (item req 1) ≤ active (item req 2) ∧ + ∀ m < (left (item req 2)).length, Allowed B (Nat.pair req m) + +theorem extension_sigma (B : Oracle) : Sigma B 1 (Extension B) := by + let req (i : ℕ) := item_primrec.comp Primrec.id (Primrec.const i) + have hl := prefix_recursive B (left_primrec.comp (req 1)) (left_primrec.comp (req 2)) + have hr := prefix_recursive B (right_primrec.comp (req 1)) (right_primrec.comp (req 2)) + have ha := recursive_primrecPred B (Primrec.nat_le.comp (active_primrec.comp (req 1)) (active_primrec.comp (req 2))) + have hc := (allowed_sigma B).bounded_all (Primrec.list_length.comp (left_primrec.comp (req 2))) + exact (Form.raise (n := 0) (s := true) hl).and ((Form.raise (n := 0) (s := true) hr).and + ((Form.raise (n := 0) (s := true) ha).and hc)) + +theorem extension_condition_iff {B : Oracle} {F : ℕ → Oracle} {codes p q : ℕ} + (h : Presents B F codes (active p)) : + Extension B (encode [codes,p,q]) ↔ Extends F (condition p) (condition q) := by + have hm (m : ℕ) : Allowed B (Nat.pair (encode [codes,p,q]) m) ↔ + (left q).getD m false = (right q).getD m false ∨ ¬ CodingLocation F (condition p) m := by + simp only [Allowed,Nat.unpair_pair,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] + exact or_congr Iff.rfl (noncoding_condition_iff h m) + change (_ ∧ _ ∧ _ ∧ ∀ m < (left (item (encode [codes,p,q]) 2)).length, + Allowed B (Nat.pair (encode [codes,p,q]) m)) ↔ _ + simp only [hm,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] + constructor + · rintro ⟨hl,hr,ha,hc⟩ + exact ⟨hl,hr,ha,fun m hm hlen => (hc m hlen).resolve_right (not_not.mpr hm)⟩ + · rintro ⟨hl,hr,ha,hc⟩ + refine ⟨hl,hr,ha,fun m hlen => ?_⟩ + by_cases hm : CodingLocation F (condition p) m + · exact Or.inl (hc m hm hlen) + · exact Or.inr hm + +theorem extension_iff {B : Oracle} {F : ℕ → Oracle} {codes : ℕ} {p q : Condition} + (h : Presents B F codes p.active) : + Extension B (encode [codes,code p,code q]) ↔ Extends F p q := by + have hh : Presents B F codes (active (code p)) := by + change Presents B F codes (condition (code p)).active + simpa only [condition_code] using h + simpa only [condition_code] using extension_condition_iff (q := code q) hh + +def Bad (B : Oracle) (v : ℕ) : Prop := + let req := (Nat.unpair v).1 + let w := (Nat.unpair v).2 + UniformSplit.PointCert B (Nat.pair (UniformPair.request (Nat.pair (item req 1) (item req 2))) w) ∧ + Noncoding B (Nat.pair (item req 0) (Nat.pair (item req 2) (item w 2))) + +theorem bad_sigma (B : Oracle) : Sigma B 1 (Bad B) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let req (i : ℕ) := item_primrec.comp f (Primrec.const i) + have hp := (UniformSplit.pointCert_sigma B).comp (Primrec₂.natPair.comp + (UniformPair.request_primrec.comp (Primrec₂.natPair.comp (req 1) (req 2))) r) + have hn := (noncoding_sigma B).comp (Primrec₂.natPair.comp (req 0) + (Primrec₂.natPair.comp (req 2) (item_primrec.comp r (Primrec.const 2)))) + exact hp.and hn + +theorem guarded_search (B : Oracle) : ∃ f : ℕ → ℕ, + Nat.RecursiveIn {oracleFunction (OracleJump.jump B)} (fun req => Part.some (f req)) ∧ + ∀ req, (f req = 0 ∧ ¬ ∃ w, Bad B (Nat.pair req w)) ∨ + (0 < f req ∧ Bad B (Nat.pair req (f req-1))) := + EffectiveWitness.sigma1_choice (bad_sigma B) + +theorem bad_condition_iff {B : Oracle} {F : ℕ → Oracle} {codes p : ℕ} + (h : Presents B F codes (active p)) (x w : ℕ) : + Bad B (Nat.pair (encode [codes,x,p]) w) ↔ + UniformSplit.PointCert B (Nat.pair (UniformPair.request (Nat.pair x p)) w) ∧ + ¬ CodingLocation F (condition p) (item w 2) := by + simp only [Bad,Nat.unpair_pair,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] + exact and_congr Iff.rfl (noncoding_condition_iff h _) + +theorem bad_iff {B : Oracle} {F : ℕ → Oracle} {codes : ℕ} {p : Condition} + (h : Presents B F codes p.active) (x w : ℕ) : + Bad B (Nat.pair (encode [codes,x,code p]) w) ↔ + UniformSplit.PointCert B (Nat.pair (UniformPair.request (Nat.pair x (code p))) w) ∧ + ¬ CodingLocation F p (item w 2) := by + simp only [Bad,Nat.unpair_pair,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] + exact and_congr Iff.rfl (noncoding_iff h _) + +end TuringRigidity.LocalColumnCertificates + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalColumnIndices.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalColumnIndices.lean new file mode 100644 index 0000000000000000000000000000000000000000..544f7475246b0eda8d6003962bbbafe1876b2edb --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalColumnIndices.lean @@ -0,0 +1,91 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalColumnCertificates + +namespace OAI + +namespace TuringRigidity.LocalColumnIndices +open Encodable UniformOracle EncodedForcing ArithmeticHierarchy + +def specialized (d : Nat.Partrec.Code) (k : ℕ) : Nat.Partrec.Code := + (Nat.Partrec.Code.comp d (.pair (.comp .left .right) (.pair .left (.comp .right .right)))).curry k + +theorem specialized_eval (d : Nat.Partrec.Code) (k L n : ℕ) : + (specialized d k).eval (Nat.pair L n) = d.eval (Nat.pair L (Nat.pair k n)) := by + simp [specialized,Nat.Partrec.Code.eval_curry,Nat.Partrec.Code.eval,Seq.seq] + change (((Part.some (Nat.pair L n)).bind + (fun input => Part.some (Nat.unpair input).1)).bind + (fun left => Part.map (Nat.pair left) (Part.map (Nat.pair k) + ((Part.some (Nat.pair L n)).bind (fun input => Part.some (Nat.unpair input).2))))).bind + (fun input => d.eval input) = _ + simp + +theorem specialized_primrec (d : Nat.Partrec.Code) : Primrec (fun k => encode (specialized d k)) := + Primrec.encode.comp (Nat.Partrec.Code.primrec₂_curry.comp (Primrec.const _) Primrec.id) + +theorem uniform_indices {B A : Oracle} (h : Reduces A B) : + ∃ index : ℕ → ℕ, Primrec index ∧ + ∀ k, TableIndices.Represents B (IndexMatrix.machine (index k)) (columns A k) := by + obtain ⟨d,hd⟩ := TableIndices.reduces_represents h + refine ⟨fun k => encode (specialized d k),specialized_primrec d,fun k => ?_⟩ + simp only [IndexMatrix.machine_encode] + constructor + · intro n z a hz + have he := Nat.Partrec.Code.evaln_sound hz + change a ∈ (specialized d k).eval + (Nat.pair (encode (oraclePrefix (fun q => CommonIdeal.bit (B q)) (Nat.unpair z).1)) n) at he + rw [specialized_eval] at he + obtain ⟨t,ht⟩ := Nat.Partrec.Code.evaln_complete.mp he + exact hd.1 (Nat.pair k n) (Nat.pair (Nat.unpair z).1 t) a (by + simpa only [TableIndices.run,trial,Nat.unpair_pair] using ht) + · intro n + obtain ⟨z,a,hz⟩ := hd.2 (Nat.pair k n) + have he := Nat.Partrec.Code.evaln_sound hz + change a ∈ d.eval + (Nat.pair (encode (oraclePrefix (fun q => CommonIdeal.bit (B q)) (Nat.unpair z).1)) (Nat.pair k n)) at he + rw [← specialized_eval d k] at he + obtain ⟨t,ht⟩ := Nat.Partrec.Code.evaln_complete.mp he + exact ⟨Nat.pair (Nat.unpair z).1 t,a,by + simpa only [TableIndices.run,trial,Nat.unpair_pair] using ht⟩ + +theorem prefix_recursive_in {O : Set (ℕ →. ℕ)} (g : ℕ → ℕ) + (hg : Nat.RecursiveIn O (fun n => Part.some (g n))) : + Nat.RecursiveIn O (fun m => Part.some (encode (oraclePrefix g m))) := by + have hy := (total_primrec (O := O)) (Primrec.fst.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hi := (total_primrec (O := O)) (Primrec.snd.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hs := total_comp ((total_primrec (O := O)) (appendEncoded_primrec.comp + (Primrec.fst.comp Primrec.unpair) (Primrec.snd.comp Primrec.unpair))) + (total_pair hi (total_comp hg hy)) + have hp := Nat.RecursiveIn.prec ((total_primrec (O := O)) (Primrec.const (encode ([] : List ℕ)))) hs + have hh := Nat.RecursiveIn.comp hp + (total_pair ((total_primrec (O := O)) (Primrec.const 0)) ((total_primrec (O := O)) Primrec.id)) + apply hh.of_eq + intro n + change (Part.some (Nat.pair 0 n)).bind _ = _ + rw [Part.bind_some] + simp only [Nat.unpair_pair] + induction n with + | zero => rfl + | succ n ih => + simp only [ih] + simp [appendEncoded,oraclePrefix,List.range_succ] + +theorem selected_prefixes {B A X : Oracle} (h : Reduces A B) (select : ℕ → ℕ) + (hs : Nat.RecursiveIn {oracleFunction X} (fun n => Part.some (select n))) : + ∃ codes : ℕ → ℕ, + Nat.RecursiveIn {oracleFunction X} (fun n => Part.some (codes n)) ∧ + ∀ n, LocalColumnCertificates.Presents B (fun k => columns A (select k)) (codes n) n := by + obtain ⟨index,hi,hindex⟩ := uniform_indices h + let g := fun k => index (select k) + have hg : Nat.RecursiveIn {oracleFunction X} (fun n => Part.some (g n)) := by + exact total_comp (f := index) (g := select) (total_primrec hi) hs + refine ⟨fun n => encode (oraclePrefix g n),prefix_recursive_in g hg,?_⟩ + intro n k hk + have he : item (encode (oraclePrefix g n)) k = g k := by + simp [item,oraclePrefix,List.getD_eq_getElem?_getD,hk] + rw [he] + exact hindex (select k) + +end TuringRigidity.LocalColumnIndices + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalComputability.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalComputability.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e43a60ff31dd12eb5a847731ee393862df26e08 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalComputability.lean @@ -0,0 +1,176 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalScan + +namespace OAI + +namespace TuringRigidity.LocalComputability +open Encodable UniformOracle EncodedForcing CodingForcing FiniteInjury StageRecords +noncomputable section +attribute [local instance] Classical.propDecidable + +def state (v : ℕ) : LocalStage.State := + ⟨condition (Nat.unpair v).1,members (Nat.unpair (Nat.unpair v).2).1,members (Nat.unpair (Nat.unpair v).2).2⟩ + +def generic (D : LocalInputs.Data) (v : ℕ) : ℕ := LocalStage.openProcedure D + (Nat.pair (nextVisit (Nat.unpair (Nat.unpair v).2).2) (Nat.unpair v).1) + +theorem open_recursive (D : LocalInputs.Data) : + Nat.RecursiveIn {oracleFunction (D.bound)} (fun v => Part.some (LocalStage.openProcedure D v)) := + D.open_recursive + +def canonical (p : ℕ) : ℕ := levelCode p (active p) +theorem canonical_eq (p : ℕ) : canonical p = code (condition p) := rfl + +def genericCanonical (D : LocalInputs.Data) (v : ℕ) : ℕ := LocalStage.openProcedure D + (Nat.pair (nextVisit (Nat.unpair (Nat.unpair v).2).2) (canonical (Nat.unpair v).1)) + +theorem generic_recursive (D : LocalInputs.Data) : + Nat.RecursiveIn {oracleFunction (D.bound)} (fun v => Part.some (genericCanonical D v)) := by + have hn := total_comp (nextVisit_recursive (O := {oracleFunction (D.bound)})) (total_primrec (r.comp r)) + have hp := total_primrec (O := {oracleFunction (D.bound)}) ((levelCode_primrec.comp Primrec.id active_primrec).comp f) + have hh := total_comp (open_recursive D) (total_pair hn hp) + exact hh.of_eq (fun v => rfl) + +@[simp] theorem generic_eq (D : LocalInputs.Data) (v : ℕ) : + condition (genericCanonical D v) = LocalStage.generic D (state v) := rfl + +def stageAction (D : LocalInputs.Data) (s v : ℕ) : ℕ := + scan D (genericCanonical D v) (Nat.unpair (Nat.unpair v).2).1 s + +theorem stageAction_recursive (D : LocalInputs.Data) : + Nat.RecursiveIn {oracleFunction (D.bound)} (fun z => + Part.some (stageAction D (Nat.unpair z).1 (Nat.unpair z).2)) := by + have hg := total_comp (generic_recursive D) (total_primrec r) + have hh := total_comp (scan_recursive D) (total_pair (total_pair hg (total_primrec (f.comp (r.comp r)))) (total_primrec f)) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +@[simp] theorem stageAction_eq (D : LocalInputs.Data) (s v : ℕ) : + action (stageAction D s v) = LocalStage.stageAction D s (state v) := by + rw [stageAction,scan_eq,action_actionCode,generic_eq] + rfl + +def stageWord (D : LocalInputs.Data) (z : ℕ) : ℕ := + let s := (Nat.unpair z).1 + let v := (Nat.unpair z).2 + let a := stageAction D s v + let g := genericCanonical D v + if a = 0 then g else candidate D (Nat.pair (a-1) g) + +theorem stageWord_recursive (D : LocalInputs.Data) : + Nat.RecursiveIn {oracleFunction (D.bound)} (fun z => Part.some (stageWord D z)) := by + have ha := stageAction_recursive D + have hg := total_comp (generic_recursive D) (total_primrec r) + have hc := total_comp (candidate_recursive D) (total_pair + (total_comp (total_primrec (Primrec.nat_sub.comp Primrec.id (Primrec.const 1))) ha) hg) + have hpost := Primrec.ite (Primrec.eq.comp f (Primrec.const 0)) (f.comp r) (r.comp r) + have hh := total_comp (total_primrec hpost) (total_pair ha (total_pair hg hc)) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +theorem stageWord_eq (D : LocalInputs.Data) (s v : ℕ) : + condition (stageWord D (Nat.pair s v)) = LocalStage.stageWord D s (state v) := by + have he := stageAction_eq D s v + unfold stageWord + simp only [Nat.unpair_pair] + by_cases ha : stageAction D s v = 0 + · have hn : LocalStage.stageAction D s (state v) = none := by simpa only [StageRecords.action,ite_eq_left ha] using he.symm + simp [ha,LocalStage.stageWord,hn,generic_eq] + · have hn : LocalStage.stageAction D s (state v) = some (stageAction D s v-1) := by + simpa only [StageRecords.action,ite_eq_right ha] using he.symm + simp [ha,LocalStage.stageWord,hn,candidate_eq,generic_eq] + +def grow (p s : ℕ) : ℕ := Nat.pair (encode (left p ++ [false])) + (Nat.pair (encode (right p ++ [false])) (s+1)) + +theorem grow_primrec : Primrec₂ grow := Primrec₂.natPair.comp + (Primrec.encode.comp (Primrec.list_append.comp (left_primrec.comp Primrec.fst) (Primrec.const [false]))) + (Primrec₂.natPair.comp + (Primrec.encode.comp (Primrec.list_append.comp (right_primrec.comp Primrec.fst) (Primrec.const [false]))) + (Primrec.succ.comp Primrec.snd)) + +@[simp] theorem condition_grow (p s : ℕ) : + condition (grow p s) = atLevel (append (condition p) [false]) (s+1) := condition_code (atLevel (append (condition p) [false]) (s+1)) + +def advance (D : LocalInputs.Data) (z : ℕ) : ℕ := + let s := (Nat.unpair z).1 + let v := (Nat.unpair z).2 + let d := (Nat.unpair (Nat.unpair v).2).1 + let seen := (Nat.unpair (Nat.unpair v).2).2 + let a := stageAction D s v + Nat.pair (grow (stageWord D z) s) + (Nat.pair (doneUpdate d a) (seenReset (seenInsert seen (nextVisit seen)) a)) + +theorem advance_recursive (D : LocalInputs.Data) : + Nat.RecursiveIn {oracleFunction (D.bound)} (fun z => Part.some (advance D z)) := by + have ha := stageAction_recursive D + have hw := total_comp (total_primrec (grow_primrec.comp f r)) + (total_pair (stageWord_recursive D) (total_primrec f)) + have hd := total_comp (total_primrec (doneUpdate_primrec.comp f r)) + (total_pair (total_primrec (f.comp (r.comp r))) ha) + have hs := total_primrec (O := {oracleFunction (D.bound)}) (r.comp (r.comp r)) + have hn := total_comp nextVisit_recursive hs + have hi := total_comp (total_primrec (seenInsert_primrec.comp f r)) (total_pair hs hn) + have hreset := total_comp (total_primrec (seenReset_primrec.comp f r)) (total_pair hi ha) + have hh := total_pair hw (total_pair hd hreset) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +theorem advance_eq (D : LocalInputs.Data) (s v : ℕ) : + state (advance D (Nat.pair s v)) = LocalStage.advance D s (state v) := by + unfold state advance + simp only [Nat.unpair_pair,condition_grow,stageWord_eq,members_doneUpdate, + members_seenReset,members_seenInsert,stageAction_eq] + rfl + +def initial : ℕ := Nat.pair (code ⟨[],[],rfl,0⟩) (Nat.pair (encode ([] : List ℕ)) (encode ([] : List ℕ))) + +def construction (D : LocalInputs.Data) : ℕ → ℕ := + recur (fun _ => initial) (fun v => advance D (Nat.unpair v).2) 0 + +theorem construction_recursive (D : LocalInputs.Data) : + Nat.RecursiveIn {oracleFunction (D.bound)} (fun s => Part.some (construction D s)) := by + have h := recur_recursive (total_primrec (Primrec.const initial)) + (total_comp (advance_recursive D) (total_primrec r)) + have hh := total_comp h (total_primrec (Primrec₂.natPair.comp (Primrec.const 0) Primrec.id)) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +theorem construction_eq (D : LocalInputs.Data) (s : ℕ) : + state (construction D s) = LocalStage.construction D s := by + induction s with + | zero => simp [construction,recur,initial,state,condition_code,members,record,LocalStage.construction] + | succ s ih => + change state (advance D (Nat.unpair (Nat.pair 0 (Nat.pair s (construction D s)))).2) = _ + rw [Nat.unpair_pair,advance_eq,ih] + rfl + +theorem conditions_recursive (D : LocalInputs.Data) : + Nat.RecursiveIn {oracleFunction (D.bound)} + (fun s => Part.some (code (LocalStage.conditions D s))) := by + have h := total_comp (total_primrec ((levelCode_primrec.comp Primrec.id active_primrec).comp f)) + (construction_recursive D) + apply h.of_eq + intro s + change Part.some (code (state (construction D s)).condition) = _ + rw [construction_eq] + rfl + +theorem limits_recursive (D : LocalInputs.Data) : + Reduces (join (leftLimit (LocalStage.conditions D)) (rightLimit (LocalStage.conditions D))) + (D.bound) := by + have hs := total_comp (conditions_recursive D) (total_primrec (Primrec.succ.comp Primrec.nat_div2)) + have hbit : Primrec (fun v : ℕ => CommonIdeal.bit + ((bif (Nat.unpair v).2.bodd then right (Nat.unpair v).1 else left (Nat.unpair v).1).getD + (Nat.unpair v).2.div2 false)) := CommonIdeal.bit_primrec.comp + ((Primrec.list_getD false).comp + (Primrec.cond (Primrec.nat_bodd.comp r) (right_primrec.comp f) (left_primrec.comp f)) + (Primrec.nat_div2.comp r)) + have h := total_comp (total_primrec hbit) (total_pair hs (total_primrec Primrec.id)) + apply RecursiveIn.iff_nat.mpr + have hl (p : Condition) : left (code p) = p.left := congrArg Condition.left (condition_code p) + have hr (p : Condition) : right (code p) = p.right := congrArg Condition.right (condition_code p) + exact h.of_eq (fun n => by + simp only [Nat.unpair_pair] + cases hb : n.bodd <;> simp [oracleFunction,join,hb,leftLimit,rightLimit,CommonIdeal.bit, + hl,hr,Nat.div2_val]) + +end +end TuringRigidity.LocalComputability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalDecisive.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalDecisive.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf48e7adba98ee0c8016ff4e744fbfd4dc131ef9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalDecisive.lean @@ -0,0 +1,41 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalPair + +namespace OAI + +namespace TuringRigidity.LocalPair +open Encodable EncodedForcing CodingForcing UniformProgram IndexMatrix ArithmeticHierarchy + +theorem decisive_excludes_common {B Y G₀ G₁ Z : Oracle} {F : ℕ → Oracle} {x : ℕ} {p : Condition} + (hbase : OracleCode.eval (oracleFunction B) (meaning (machine (item x 0))) = oracleFunction Y) + (h₀ : CommonIdeal.Extends G₀ p.left) (h₁ : CommonIdeal.Extends G₁ p.right) + (he₀ : OracleCode.eval (oracleFunction (join Y G₀)) (meaning (machine (item x 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y G₁)) (meaning (machine (item x 2))) = oracleFunction Z) + (hd : Decisive B F x p) : False := by + have hr (i : ℕ) (s : List Bool) (n : ℕ) : + UniformRun.run B (machine (item x 0)) (machine (item x i)) s n = + CommonIdeal.run Y (meaning (machine (item x i))) s n := by + simp only [UniformRun.run,hbase,CommonIdeal.run] + rcases hd with ⟨n,a,b,hab,ha,hb⟩ | ⟨i,n,hi,hdiv⟩ + · rw [hr] at ha hb + have ha' := CommonIdeal.run_total h₀ n a ha + have hb' := CommonIdeal.run_total h₁ n b hb + rw [he₀] at ha' + rw [he₁] at hb' + exact hab (Part.mem_unique ha' hb') + · rcases hi with rfl | rfl + · obtain ⟨s,hs,hv⟩ := CommonIdeal.run_finite_extension h₀ n (CommonIdeal.bit (Z n)) (by + rw [he₀]; exact Part.mem_some _) + obtain ⟨q,hpq,hq⟩ := CodingForcing.arbitrary_left_extension F p s hs + have hh := hdiv q hpq (CommonIdeal.bit (Z n)) + simp only [↓reduceIte,hr,hq] at hh + exact hh hv + · obtain ⟨s,hs,hv⟩ := CommonIdeal.run_finite_extension h₁ n (CommonIdeal.bit (Z n)) (by + rw [he₁]; exact Part.mem_some _) + obtain ⟨q,hpq,hq⟩ := CodingRequirements.arbitrary_right_extension F p s hs + have hh := hdiv q hpq (CommonIdeal.bit (Z n)) + simp only [show (2 : ℕ) ≠ 1 by decide,↓reduceIte,hr,hq] at hh + exact hh hv + +end TuringRigidity.LocalPair + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalExtraction.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalExtraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..0fecd21a4f4c3ac7262f3e5d4aeb083f8700a0b0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalExtraction.lean @@ -0,0 +1,185 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalOutcomes + +namespace OAI + +namespace TuringRigidity.LocalExtraction +open ArithmeticHierarchy +open Encodable CodingForcing EncodedForcing UniformProgram IndexMatrix FiniteInjury LocalStage +noncomputable section + +theorem noSplit_reduces {A Y G Z : Oracle} {t : ℕ} {p : Condition} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (hG : CommonIdeal.Extends G p.left) + (he : OracleCode.eval (oracleFunction (join Y G)) (meaning (machine (item t 1))) = oracleFunction Z) + (hno : ¬ ∃ z, UniformSplit.SplitCert A (Nat.pair (UniformPair.request (Nat.pair t (code p))) z)) : + Reduces Z Y := by + have hrun (w : List Bool) (n : ℕ) : + UniformRun.run A (machine (item t 0)) (machine (item t 1)) w n = + CommonIdeal.run Y (meaning (machine (item t 1))) w n := by + simp only [UniformRun.run,hbase,CommonIdeal.run] + apply CodingAgreement.case1_reduces (A := columns A) (p := p) ?_ hG he + intro q r hpq hpr n a b ha hb + by_contra hab + rw [← hrun] at ha hb + apply hno + refine ⟨encode [n,encode q.left,encode r.left,a,b],?_⟩ + simpa [UniformSplit.SplitCert,UniformSplit.start,UniformSplit.base,UniformSplit.program, + UniformPair.request,item,word, + show left (code p) = p.left from congrArg Condition.left (condition_code p)] using + And.intro hpq.1 (And.intro hpr.1 (And.intro hab (And.intro ha hb))) + +theorem point_splittingLocation {A Y : Oracle} {t w : ℕ} {p : Condition} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item t 0))) = oracleFunction Y) + (hw : UniformSplit.PointCert A (Nat.pair (UniformPair.request (Nat.pair t (code p))) w)) : + CodingLocations.SplittingLocation Y (meaning (machine (item t 1))) p.left (item w 2) := by + have hrun (v : List Bool) (n : ℕ) : + UniformRun.run A (machine (item t 0)) (machine (item t 1)) v n = + CommonIdeal.run Y (meaning (machine (item t 1))) v n := by + simp only [UniformRun.run,hbase,CommonIdeal.run] + have hh : p.left <+: word (item w 1) ∧ p.left.length ≤ item w 2 ∧ + item w 2 < (word (item w 1)).length ∧ item w 4 ≠ item w 5 ∧ + item w 4 ∈ CommonIdeal.run Y (meaning (machine (item t 1))) (word (item w 1)) (item w 0) ∧ + item w 5 ∈ CommonIdeal.run Y (meaning (machine (item t 1))) + ((word (item w 1)).set (item w 2) (item w 3).bodd) (item w 0) := by + rw [← hrun,← hrun] + simpa [UniformSplit.PointCert,UniformSplit.start,UniformSplit.base,UniformSplit.program, + UniformPair.request,item,word, + show left (code p) = p.left from congrArg Condition.left (condition_code p)] using hw + exact ⟨word (item w 1),(item w 3).bodd,item w 0,item w 4,item w 5,hh⟩ + +theorem common_unbounded_points {D : LocalInputs.Data} {Y Z : Oracle} {t : ℕ} + (hbase : OracleCode.eval (oracleFunction D.B) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₀ D))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₁ D))) + (meaning (machine (item t 2))) = oracleFunction Z) + (hn : ¬ Reduces Z Y) : + ∀ N, ∃ m, N ≤ m ∧ (Nat.unpair m).1 < t ∧ D.F (Nat.unpair m).1 (Nat.unpair m).2 = true ∧ + CodingLocations.SplittingLocation Y (meaning (machine (item t 1))) [] m := by + obtain ⟨S,hS⟩ := LocalOutcomes.common_eventually_outcome hbase he₀ he₁ + intro N + let s := max S N + let p := atLevel (generic D (construction D s)) t + obtain ⟨_,_,hno | ⟨w,hw,hcoding⟩⟩ := hS s (le_max_left _ _) + · exact False.elim (hn (noSplit_reduces (p := p) (t := t) hbase (LocalLimits.limits_extend_generic D s).1 he₀ hno)) + · have hs : N ≤ p.left.length := by + have hp := (open_extends D (FiniteInjurySchedule.visit (construction D s).seen) (construction D s).condition).1.length_le + exact (le_max_right S N).trans ((length_bound D s).trans hp) + have hpoint := point_splittingLocation (p := p) (t := t) (w := w) hbase hw + obtain ⟨v,b,n,a,c,hpv,hpm,hmv,hac,ha,hc⟩ := hpoint + exact ⟨item w 2,hs.trans hcoding.1,hcoding.2.1,hcoding.2.2, + v,b,n,a,c,List.nil_prefix,Nat.zero_le _,hmv,hac,ha,hc⟩ + +theorem common_lower_unbounded_points {D : LocalInputs.Data} {Y Z : Oracle} + (hY : Reduces Y D.B) + (h₀ : Reduces Z (join Y (LocalLimits.G₀ D))) + (h₁ : Reduces Z (join Y (LocalLimits.G₁ D))) + (hn : ¬ Reduces Z Y) : + ∃ t, ∀ N, ∃ m, N ≤ m ∧ (Nat.unpair m).1 < t ∧ + D.F (Nat.unpair m).1 (Nat.unpair m).2 = true ∧ + CodingLocations.SplittingLocation Y (meaning (machine (item t 1))) [] m := by + obtain ⟨b,hb⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp hY + obtain ⟨e,he⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h₀ + obtain ⟨f,hf⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h₁ + let t := encode [encode (represent b),encode (represent e),encode (represent f)] + have hb' : OracleCode.eval (oracleFunction D.B) (meaning (machine (item t 0))) = oracleFunction Y := by + simpa [t,item,machine,represent_correct] using hb + have he' : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₀ D))) + (meaning (machine (item t 1))) = oracleFunction Z := by + simpa [t,item,machine,represent_correct] using he + have hf' : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₁ D))) + (meaning (machine (item t 2))) = oracleFunction Z := by + simpa [t,item,machine,represent_correct] using hf + exact ⟨t,common_unbounded_points hb' he' hf' hn⟩ + +theorem noBad_sound {D : LocalInputs.Data} {Y : Oracle} {t : ℕ} {p : Condition} + (hbase : OracleCode.eval (oracleFunction D.B) (meaning (machine (item t 0))) = oracleFunction Y) + (hbad : LocalPair.NoBad D.B D.F t (code p)) {m : ℕ} + (hm : CodingLocations.SplittingLocation Y (meaning (machine (item t 1))) p.left m) : + CodingLocation D.F p m := by + obtain ⟨v,b,n,a,c,hpv,hpm,hmv,hac,ha,hc⟩ := hm + have hrun (w : List Bool) (n : ℕ) : + UniformRun.run D.B (machine (item t 0)) (machine (item t 1)) w n = + CommonIdeal.run Y (meaning (machine (item t 1))) w n := by + simp only [UniformRun.run,hbase,CommonIdeal.run] + have hw : UniformSplit.PointCert D.B + (Nat.pair (UniformPair.request (Nat.pair t (code p))) (encode [n,encode v,m,CommonIdeal.bit b,a,c])) := by + have hbit : (CommonIdeal.bit b).bodd = b := by cases b <;> rfl + have hh := And.intro hpv (And.intro hpm (And.intro hmv (And.intro hac + (And.intro ((hrun v n).symm ▸ ha) ((hrun (v.set m b) n).symm ▸ hc))))) + simpa [UniformSplit.PointCert,UniformSplit.start,UniformSplit.base,UniformSplit.program, + UniformPair.request,item,word,hbit, + show left (code p) = p.left from congrArg Condition.left (condition_code p)] using hh + have hh := hbad _ hw + simpa only [condition_code,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] using hh + +theorem common_recursive_locations {D : LocalInputs.Data} {Y Z : Oracle} {t : ℕ} + (hbase : OracleCode.eval (oracleFunction D.B) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₀ D))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₁ D))) + (meaning (machine (item t 2))) = oracleFunction Z) + (hn : ¬ Reduces Z Y) : + ∃ p : Condition, p.active = t ∧ ∃ C : Oracle, Reduces C Y ∧ + {m | C m = true}.Infinite ∧ ∀ m, C m = true → CodingLocation D.F p m := by + obtain ⟨S,hS⟩ := LocalOutcomes.common_eventually_outcome hbase he₀ he₁ + let p := atLevel (generic D (construction D S)) t + have hbad : LocalPair.NoBad D.B D.F t (code p) := (hS S le_rfl).2.1 + obtain ⟨E,hE,hEq⟩ := CodingSplitSearch.splittingLocations_enumerable Y (meaning (machine (item t 1))) p.left + have hu : RecursiveInfiniteSubset.Unbounded E := by + intro N + let s := max (S+1) N + let q := atLevel (generic D (construction D s)) t + have hpq : p.left <+: q.left := by + exact (LocalLimits.generic_prefix_next D S).1.trans + ((word_prefix (word_growth D) (le_max_left (S+1) N)).1.trans + (open_extends D _ _).1) + obtain ⟨_,_,hno | ⟨w,hw,hcoding⟩⟩ := hS s (by dsimp [s]; omega) + · exact False.elim (hn (noSplit_reduces (p := q) (t := t) hbase + (LocalLimits.limits_extend_generic D s).1 he₀ hno)) + · have hN : N ≤ q.left.length := by + exact (le_max_right (S+1) N).trans ((length_bound D s).trans (open_extends D _ _).1.length_le) + obtain ⟨v,b,n,a,c,hqv,hqm,hmv,hac,ha,hc⟩ := point_splittingLocation hbase hw + have hpoint : CodingLocations.SplittingLocation Y (meaning (machine (item t 1))) p.left (item w 2) := + ⟨v,b,n,a,c,hpq.trans hqv,hpq.length_le.trans hqm,hmv,hac,ha,hc⟩ + obtain ⟨z,hz⟩ := (hEq (item w 2)).mp hpoint + exact ⟨z,item w 2,hN.trans hqm,hz⟩ + obtain ⟨C,hCY,hCi,hC⟩ := RecursiveInfiniteSubset.infinite_recursive_subset Y E hu hE + exact ⟨p,rfl,C,hCY,hCi,fun m hm => noBad_sound hbase hbad ((hEq m).mpr (hC m hm))⟩ + +theorem common_infinite_column {D : LocalInputs.Data} {Y Z : Oracle} {t : ℕ} + (hbase : OracleCode.eval (oracleFunction D.B) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₀ D))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₁ D))) + (meaning (machine (item t 2))) = oracleFunction Z) + (hn : ¬ Reduces Z Y) : + ∃ k, k < t ∧ ∃ C : Oracle, Reduces C Y ∧ {a | C a = true}.Infinite ∧ + ∀ a, C a = true → D.F k a = true := by + obtain ⟨p,hp,C,hCY,hCi,hC⟩ := common_recursive_locations hbase he₀ he₁ hn + simpa only [hp] using CodingExtraction.infinite_column hCY hCi hC + +theorem common_lower_computes_column {D : LocalInputs.Data} {Y Z : Oracle} + (hIntro : ∀ k C, (∀ a, C a = true → D.F k a = true) → + {a | C a = true}.Infinite → Reduces (D.F k) C) + (hY : Reduces Y D.B) + (h₀ : Reduces Z (join Y (LocalLimits.G₀ D))) + (h₁ : Reduces Z (join Y (LocalLimits.G₁ D))) + (hn : ¬ Reduces Z Y) : ∃ k, Reduces (D.F k) Y := by + obtain ⟨b,hb⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp hY + obtain ⟨e,he⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h₀ + obtain ⟨f,hf⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h₁ + let t := encode [encode (represent b),encode (represent e),encode (represent f)] + have hb' : OracleCode.eval (oracleFunction D.B) (meaning (machine (item t 0))) = oracleFunction Y := by + simpa [t,item,machine,represent_correct] using hb + have he' : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₀ D))) (meaning (machine (item t 1))) = oracleFunction Z := by + simpa [t,item,machine,represent_correct] using he + have hf' : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₁ D))) (meaning (machine (item t 2))) = oracleFunction Z := by + simpa [t,item,machine,represent_correct] using hf + obtain ⟨k,_,C,hCY,hCi,hC⟩ := common_infinite_column hb' he' hf' hn + exact ⟨k,reduces_trans (hIntro k C hC hCi) hCY⟩ + +end +end TuringRigidity.LocalExtraction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalInputs.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalInputs.lean new file mode 100644 index 0000000000000000000000000000000000000000..b499ca39c5cbb13e65b3bfcab4b175f0ab4f16a9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalInputs.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalPair +import OAI.Computability.DegreeRigidity.Effective.LocalOpen +import OAI.Computability.DegreeRigidity.Effective.LocalColumnIndices + +namespace OAI + +namespace TuringRigidity.LocalInputs +open Encodable UniformOracle ArithmeticHierarchy OracleJump EncodedForcing CodingForcing +noncomputable section + +structure Data where + B : Oracle + X : Oracle + F : ℕ → Oracle + codes : ℕ → ℕ + codes_recursive : Nat.RecursiveIn {oracleFunction X} (fun n => Part.some (codes n)) + codes_valid : ∀ n, LocalColumnCertificates.Presents B F (codes n) n + +def Data.bound (D : Data) : Oracle := join D.X (jump D.B) + +theorem total_transfer {Y Z : Oracle} {f : ℕ → ℕ} + (h : Nat.RecursiveIn {oracleFunction Y} (fun n => Part.some (f n))) (hYZ : Reduces Y Z) : + Nat.RecursiveIn {oracleFunction Z} (fun n => Part.some (f n)) := + RecursiveIn.iff_nat.mp (TuringReducible.trans (RecursiveIn.iff_nat.mpr h) hYZ) + +def Data.request (D : Data) (v : ℕ) : ℕ := + encode [D.codes (active (Nat.unpair v).2),(Nat.unpair v).1,(Nat.unpair v).2] + +theorem Data.request_recursive (D : Data) : + Nat.RecursiveIn {oracleFunction D.bound} (fun n => Part.some (D.request n)) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hc := total_comp (total_transfer D.codes_recursive (reduces_join_left D.X (jump D.B))) + (total_primrec (active_primrec.comp r)) + have hm := Primrec.encode.comp (Primrec.list_cons.comp f + (Primrec.list_cons.comp (f.comp r) (Primrec.list_cons.comp (r.comp r) (Primrec.const [])))) + exact (total_comp (total_primrec hm) (total_pair hc (total_primrec Primrec.id))).of_eq + (fun n => by simp only [Nat.unpair_pair]; rfl) + +def Data.pairProcedure (D : Data) (v : ℕ) : ℕ := + Classical.choose (LocalPair.pair_exists D.B) (D.request v) + +theorem Data.pair_recursive (D : Data) : + Nat.RecursiveIn {oracleFunction D.bound} (fun n => Part.some (D.pairProcedure n)) := + total_comp (f := Classical.choose (LocalPair.pair_exists D.B)) (g := D.request) + (total_transfer (Classical.choose_spec (LocalPair.pair_exists D.B)).1 + (reduces_join_right D.X (jump D.B))) D.request_recursive + +theorem Data.pair_spec (D : Data) (x p : ℕ) : + Extends D.F (condition p) (condition (D.pairProcedure (Nat.pair x p))) ∧ + (UniformAgreement.Disagreement D.B x (condition (D.pairProcedure (Nat.pair x p))) ∨ + ((condition (D.pairProcedure (Nat.pair x p))).active = active p ∧ + LocalAgreement.NoDisagreement D.B D.F x (condition p) ∧ + (LocalPair.Decisive D.B D.F x (condition (D.pairProcedure (Nat.pair x p))) ∨ + (condition (D.pairProcedure (Nat.pair x p)) = condition p ∧ + LocalPair.NoBad D.B D.F x p ∧ LocalPair.Outcome D.B D.F x p)))) := by + simpa only [Data.pairProcedure,Data.request,Nat.unpair_pair] using + (Classical.choose_spec (LocalPair.pair_exists D.B)).2 D.F (D.codes (active p)) x p (D.codes_valid _) + +def Data.openProcedure (D : Data) (v : ℕ) : ℕ := + Classical.choose (LocalOpen.uniform_open_decision D.B) (D.request v) + +theorem Data.open_recursive (D : Data) : + Nat.RecursiveIn {oracleFunction D.bound} (fun n => Part.some (D.openProcedure n)) := + total_comp (f := Classical.choose (LocalOpen.uniform_open_decision D.B)) (g := D.request) + (total_transfer (Classical.choose_spec (LocalOpen.uniform_open_decision D.B)).1 + (reduces_join_right D.X (jump D.B))) D.request_recursive + +theorem Data.open_spec (D : Data) (e p : ℕ) : + Extends D.F (condition p) (condition (D.openProcedure (Nat.pair e p))) ∧ + (Halts D.B e (D.openProcedure (Nat.pair e p)) ∨ + (D.openProcedure (Nat.pair e p) = p ∧ + ∀ q, Extends D.F (condition p) (condition q) → ¬ Halts D.B e q)) := by + simpa only [Data.openProcedure,Data.request,Nat.unpair_pair] using + (Classical.choose_spec (LocalOpen.uniform_open_decision D.B)).2 D.F (D.codes (active p)) e p (D.codes_valid _) + +end +end TuringRigidity.LocalInputs + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalLimits.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalLimits.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fcad62c31d610bc258c973339c4aa3b4f8b6a6f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalLimits.lean @@ -0,0 +1,151 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalComputability +import OAI.Computability.DegreeRigidity.CohenForcing.CohenCompleteness +import OAI.Computability.DegreeRigidity.Effective.CodingDiagonal +import OAI.Computability.DegreeRigidity.Effective.CodingExtraction + +namespace OAI + +namespace TuringRigidity.LocalLimits +open Encodable UniformOracle ArithmeticHierarchy EncodedForcing CodingForcing FiniteInjury +open LocalStage +noncomputable section +attribute [local instance] Classical.propDecidable + +def G₀ (D : LocalInputs.Data) : Oracle := leftLimit (conditions D) +def G₁ (D : LocalInputs.Data) : Oracle := rightLimit (conditions D) + +theorem generic_prefix_next (D : LocalInputs.Data) (s : ℕ) : + (generic D (construction D s)).left <+: (conditions D (s+1)).left ∧ + (generic D (construction D s)).right <+: (conditions D (s+1)).right := by + have h : (generic D (construction D s)).left <+: (stageWord D s (construction D s)).left ∧ + (generic D (construction D s)).right <+: (stageWord D s (construction D s)).right := by + cases ha : stageAction D s (construction D s) with + | none => simp [stageWord,ha] + | some t => + have hc := candidate_extends D t (generic D (construction D s)) + exact ⟨by simpa [stageWord,ha,atLevel] using hc.1,by simpa [stageWord,ha,atLevel] using hc.2.1⟩ + exact ⟨h.1.trans (List.prefix_append _ _),h.2.trans (List.prefix_append _ _)⟩ + +theorem limits_extend_generic (D : LocalInputs.Data) (s : ℕ) : + CommonIdeal.Extends (G₀ D) (generic D (construction D s)).left ∧ + CommonIdeal.Extends (G₁ D) (generic D (construction D s)).right := by + have hp := generic_prefix_next D s + constructor + · intro m hm + have hh := (limits_extend (word_growth D) (length_bound D) (s+1) m (hm.trans_le hp.1.length_le)).1 + exact hh.trans (getD_of_prefix hp.1 hm) + · intro m hm + have hn : m < (conditions D (s+1)).left.length := by + rw [(conditions D (s+1)).sameLength] + exact hm.trans_le hp.2.length_le + have hh := (limits_extend (word_growth D) (length_bound D) (s+1) m hn).2 + exact hh.trans (getD_of_prefix hp.2 hm) + +theorem meets_dense (D : LocalInputs.Data) {P : ℕ → Prop} (hP : Sigma D.B 1 P) + (hdense : ∀ p : Condition, ∃ q : ℕ, Extends D.F p (condition q) ∧ P q) : + ∃ q : ℕ, P q ∧ CommonIdeal.Extends (G₀ D) (condition q).left ∧ + CommonIdeal.Extends (G₁ D) (condition q).right := by + obtain ⟨e,he⟩ := EffectiveCohen.sigma1_enumeration hP + obtain ⟨s,hs,_⟩ := surviving_generic_visit D e + let p := construction D s + let q := openProcedure D (Nat.pair e (code p.condition)) + have hdec := (D.open_spec e (code p.condition)).2 + change OracleJump.Halts D.B e q ∨ + (q = code p.condition ∧ + ∀ r, Extends D.F (condition (code p.condition)) (condition r) → ¬ OracleJump.Halts D.B e r) at hdec + have hq : P q := by + rcases hdec with h | ⟨_,h⟩ + · exact (he q).mpr h + · obtain ⟨r,hr,hR⟩ := hdense (condition (code p.condition)) + exact False.elim (h r hr ((he r).mp hR)) + refine ⟨q,hq,?_⟩ + have hh := limits_extend_generic D s + simpa only [generic,hs,p,q] using hh + +theorem disagreement_recursive (A X : Oracle) (loc : ℕ → ℕ) + (hloc : Nat.RecursiveIn {oracleFunction A} (fun n => Part.some (loc n))) + (hX : Reduces X A) : RecursivePred A (fun v => + loc (Nat.unpair v).2 < (left (Nat.unpair v).1).length ∧ + (left (Nat.unpair v).1).getD (loc (Nat.unpair v).2) false ≠ X (Nat.unpair v).2) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hm := total_comp hloc (total_primrec r) + have hx := total_comp (RecursiveIn.iff_nat.mp hX) (total_primrec r) + have hp : Primrec (fun v : ℕ => + if (Nat.unpair (Nat.unpair v).2).1 < (left (Nat.unpair v).1).length ∧ + CommonIdeal.bit ((left (Nat.unpair v).1).getD (Nat.unpair (Nat.unpair v).2).1 false) ≠ + (Nat.unpair (Nat.unpair v).2).2 then 1 else 0) := + Primrec.ite ((Primrec.nat_lt.comp (f.comp r) (Primrec.list_length.comp (left_primrec.comp f))).and + ((Primrec.eq.comp (CommonIdeal.bit_primrec.comp ((Primrec.list_getD false).comp + (left_primrec.comp f) (f.comp r))) (r.comp r)).not)) (Primrec.const 1) (Primrec.const 0) + have hh := total_comp (total_primrec hp) (total_pair (total_primrec f) (total_pair hm hx)) + have hbits (b c : Bool) : (CommonIdeal.bit b ≠ (if c then 1 else 0)) ↔ b ≠ c := by + cases b <;> cases c <;> decide + exact hh.of_eq (fun v => by + simp only [Nat.unpair_pair,hbits] + by_cases ht : loc (Nat.unpair v).2 < (left (Nat.unpair v).1).length ∧ + (left (Nat.unpair v).1).getD (loc (Nat.unpair v).2) false ≠ X (Nat.unpair v).2 + · simp only [ite_eq_left ht] + · simp only [ite_eq_right ht]) + +theorem reads_not_reduces (D : LocalInputs.Data) (loc : ℕ → ℕ) + (hloc : Nat.RecursiveIn {oracleFunction D.B} (fun n => Part.some (loc n))) + (hunbounded : ∀ N, ∃ n, N ≤ loc n) : ¬ Reduces (fun n => G₀ D (loc n)) D.B := by + intro hX + let X : Oracle := fun n => G₀ D (loc n) + have hP : Sigma D.B 1 (fun p => ∃ n, loc n < (left p).length ∧ (left p).getD (loc n) false ≠ X n) := by + simpa only [Nat.unpair_pair] using + (Form.raise (n := 0) (s := true) (disagreement_recursive D.B X loc hloc hX)).ex + have hdense : ∀ p : Condition, ∃ q : ℕ, Extends D.F p (condition q) ∧ + ∃ n, loc n < (left q).length ∧ (left q).getD (loc n) false ≠ X n := by + intro p + obtain ⟨n,hn⟩ := hunbounded p.left.length + obtain ⟨q,hpq,hql,hqb⟩ := CodingDiagonal.prescribe D.F p (loc n) hn (!(X n)) + refine ⟨code q,by simpa [condition_code] using hpq,n,?_,?_⟩ + · simpa only [show left (code q) = q.left from congrArg Condition.left (condition_code q)] using hql + · rw [show left (code q) = q.left from congrArg Condition.left (condition_code q),hqb] + cases X n <;> decide + obtain ⟨q,⟨n,hn,hne⟩,hl,_⟩ := meets_dense D hP hdense + exact hne (hl (loc n) hn).symm + +theorem common_noncomputable_columns (D : LocalInputs.Data) + (hA : ∀ k, {a | D.F k a = true}.Infinite) : + ∀ k, ∃ C : Oracle, Reduces C (join (G₀ D) (D.F k)) ∧ + Reduces C (join (G₁ D) (D.F k)) ∧ ¬ Reduces C (D.F k) := by + intro k + obtain ⟨S,hS⟩ := surviving_columns D (k+1) + let cutoff := (conditions D S).left.length + let loc := CodingColumns.location (D.F k) (hA k) k cutoff + have hcol : Reduces (D.F k) D.B := TableIndices.represents_reduces + (D.codes_valid (k+1) k (Nat.lt_succ_self k)) + have hloc : Nat.RecursiveIn {oracleFunction D.B} (fun n => Part.some (loc n)) := + (CodingColumns.location_recursive (D.F k) (hA k) k cutoff).subst (fun f hf => by + have he : f = oracleFunction (D.F k) := Set.mem_singleton_iff.mp hf + subst f + exact RecursiveIn.iff_nat.mp hcol) + have hn := reads_not_reduces D loc hloc (fun N => ⟨N,CodingColumns.le_location _ _ _ _ _⟩) + let C := CodingColumns.readColumn (D.F k) (hA k) k cutoff (G₀ D) + have heq : C = CodingColumns.readColumn (D.F k) (hA k) k cutoff (G₁ D) := by + funext n + have hm := CodingColumns.location_mem (D.F k) (hA k) k cutoff n + simp only [CodingColumns.column] at hm + split at hm + next h => + apply hS _ h.1 + · rw [h.2]; omega + · simpa only [h.2] using hm + next h => simp at hm + exact ⟨C,CodingColumns.readColumn_reduces _ _ _ _ _, + heq.symm ▸ CodingColumns.readColumn_reduces _ _ _ _ _,fun h => hn (reduces_trans h hcol)⟩ + +theorem effective_first_clause (D : LocalInputs.Data) + (hA : ∀ k, {a | D.F k a = true}.Infinite) : + Reduces (join (G₀ D) (G₁ D)) (D.bound) ∧ + ∀ k, ∃ C : Oracle, Reduces C (join (G₀ D) (D.F k)) ∧ + Reduces C (join (G₁ D) (D.F k)) ∧ ¬ Reduces C (D.F k) := + ⟨LocalComputability.limits_recursive D,common_noncomputable_columns D hA⟩ + +end +end TuringRigidity.LocalLimits + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalOpen.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalOpen.lean new file mode 100644 index 0000000000000000000000000000000000000000..fd2414820087d3cfe5269d99a791681983cff0ee --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalOpen.lean @@ -0,0 +1,52 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalColumnCertificates +import OAI.Computability.DegreeRigidity.CohenForcing.EffectiveForcing + +namespace OAI + +namespace TuringRigidity.LocalOpen +open Encodable UniformOracle ArithmeticHierarchy OracleJump EffectiveWitness EncodedForcing CodingForcing +open LocalColumnCertificates + +theorem uniform_open_decision (B : Oracle) : + ∃ step : ℕ → ℕ, + Nat.RecursiveIn {oracleFunction (jump B)} (fun x => Part.some (step x)) ∧ + ∀ (F : ℕ → Oracle) codes e p, Presents B F codes (active p) → + Extends F (condition p) (condition (step (encode [codes,e,p]))) ∧ + (Halts B e (step (encode [codes,e,p])) ∨ + (step (encode [codes,e,p]) = p ∧ + ∀ q, Extends F (condition p) (condition q) → ¬ Halts B e q)) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let req (i : ℕ) := item_primrec.comp f (Primrec.const i) + let P : ℕ → Prop := fun v => + Extension B (encode [item (Nat.unpair v).1 0,item (Nat.unpair v).1 2,(Nat.unpair v).2]) ∧ + Halts B (item (Nat.unpair v).1 1) (Nat.unpair v).2 + have hext := (extension_sigma B).comp (Primrec.encode.comp + (Primrec.list_cons.comp (req 0) (Primrec.list_cons.comp (req 2) + (Primrec.list_cons.comp r (Primrec.const []))))) + have hhalt := (halts_sigma B).comp (Primrec₂.natPair.comp (req 1) r) + have hP : Sigma B 1 P := by + simpa only [P,Nat.unpair_pair] using hext.and hhalt + obtain ⟨g,hg,hs⟩ := sigma1_choice hP + let step : ℕ → ℕ := fun x => EffectiveForcing.answer (Nat.pair (item x 2) (g x)) + have hstep := total_comp (total_primrec (O := {oracleFunction (jump B)}) EffectiveForcing.answer_primrec) + (total_pair (total_primrec (item_primrec.comp Primrec.id (Primrec.const 2))) hg) + refine ⟨step,hstep,fun F codes e p h => ?_⟩ + rcases hs (encode [codes,e,p]) with ⟨hz,hn⟩ | ⟨hp,hw⟩ + · have he : step (encode [codes,e,p]) = p := by simp only [step,EffectiveForcing.answer,Nat.unpair_pair,ite_eq_left hz,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] + rw [he] + refine ⟨extends_refl _ _,Or.inr ⟨rfl,fun q hq hhalt => ?_⟩⟩ + apply hn + refine ⟨q,?_⟩ + simpa only [P,Nat.unpair_pair,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] using + And.intro ((extension_condition_iff h).2 hq) hhalt + · have hz : g (encode [codes,e,p]) ≠ 0 := by omega + have he : step (encode [codes,e,p]) = g (encode [codes,e,p]) - 1 := by simp only [step,EffectiveForcing.answer,Nat.unpair_pair,ite_eq_right hz] + rw [he] + have hh : Extension B (encode [codes,p,g (encode [codes,e,p])-1]) ∧ Halts B e (g (encode [codes,e,p])-1) := by + simpa only [P,Nat.unpair_pair,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] using hw + exact ⟨(extension_condition_iff h).1 hh.1,Or.inl hh.2⟩ + +end TuringRigidity.LocalOpen + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalOutcomes.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalOutcomes.lean new file mode 100644 index 0000000000000000000000000000000000000000..1944f297051c901a3830d1315e3b937a7acc533c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalOutcomes.lean @@ -0,0 +1,168 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalLimits +import OAI.Computability.DegreeRigidity.Effective.LocalDecisive + +namespace OAI + +namespace TuringRigidity.LocalOutcomes +open ArithmeticHierarchy +open Encodable EncodedForcing CodingForcing FiniteInjury LocalStage +open UniformProgram IndexMatrix +noncomputable section + +theorem candidate_decisive (D : LocalInputs.Data) (t : ℕ) (p : Condition) + (hc : Changes D t p) : LocalPair.Decisive D.B D.F t (candidate D t p) := by + let p' := atLevel p t + let q := condition (pairProcedure D (Nat.pair t (code p'))) + obtain ⟨_,hdis | ⟨ha,hn,hd | ⟨he,hrest⟩⟩⟩ := + D.pair_spec t (code p') + · exact Or.inl hdis + · have haq : q.active = t := by + change q.active = (condition (code p')).active at ha + simpa only [condition_code,p',atLevel] using ha + have heq : atLevel q t = q := by rw [← haq]; cases q; rfl + change LocalPair.Decisive D.B D.F t (atLevel q t) + rw [heq] + exact hd + · have heq : q = p' := by + change q = condition (code p') at he + simpa only [condition_code] using he + change (atLevel q t).left ≠ p.left ∨ (atLevel q t).right ≠ p.right at hc + rw [heq] at hc + exact False.elim (hc.elim (fun h => h rfl) (fun h => h rfl)) + +theorem limits_extend_action {D : LocalInputs.Data} {s t : ℕ} + (ha : stageAction D s (construction D s) = some t) : + CommonIdeal.Extends (LocalLimits.G₀ D) (candidate D t (generic D (construction D s))).left ∧ + CommonIdeal.Extends (LocalLimits.G₁ D) (candidate D t (generic D (construction D s))).right := by + have hl : (candidate D t (generic D (construction D s))).left <+: (conditions D (s+1)).left := by + change _ <+: (stageWord D s (construction D s)).left ++ [false] + simp only [stageWord,ha] + exact List.prefix_append _ _ + have hr : (candidate D t (generic D (construction D s))).right <+: (conditions D (s+1)).right := by + change _ <+: (stageWord D s (construction D s)).right ++ [false] + simp only [stageWord,ha] + exact List.prefix_append _ _ + constructor + · intro m hm + exact ((limits_extend (word_growth D) (length_bound D) (s+1) m (hm.trans_le hl.length_le)).1).trans + (getD_of_prefix hl hm) + · intro m hm + have hn : m < (conditions D (s+1)).left.length := by + rw [(conditions D (s+1)).sameLength] + exact hm.trans_le hr.length_le + exact ((limits_extend (word_growth D) (length_bound D) (s+1) m hn).2).trans (getD_of_prefix hr hm) + +theorem action_excludes_common {D : LocalInputs.Data} {Y Z : Oracle} {s t : ℕ} + (hbase : OracleCode.eval (oracleFunction D.B) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₀ D))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₁ D))) + (meaning (machine (item t 2))) = oracleFunction Z) : + stageAction D s (construction D s) ≠ some t := by + intro ha + have hc := (scan_spec ha).2.2.2 + obtain ⟨h₀,h₁⟩ := limits_extend_action ha + exact LocalPair.decisive_excludes_common (F := D.F) hbase h₀ h₁ he₀ he₁ (candidate_decisive D t _ hc) + +theorem done_witness (D : LocalInputs.Data) {s t : ℕ} (ht : t ∈ (construction D s).done) : + ∃ u, u < s ∧ stageAction D u (construction D u) = some t := by + induction s with + | zero => simp [construction] at ht + | succ s ih => + change t ∈ FiniteInjury.update (construction D s).done (stageAction D s (construction D s)) at ht + cases ha : stageAction D s (construction D s) with + | none => + obtain ⟨u,hu,he⟩ := ih (by simpa [ha,FiniteInjury.update] using ht) + exact ⟨u,by omega,he⟩ + | some i => + simp only [ha,FiniteInjury.update,Finset.mem_insert,Finset.mem_filter] at ht + rcases ht with rfl | ⟨ht,_⟩ + · exact ⟨s,by omega,ha⟩ + · obtain ⟨u,hu,he⟩ := ih ht + exact ⟨u,by omega,he⟩ + +theorem common_not_done {D : LocalInputs.Data} {Y Z : Oracle} {s t : ℕ} + (hbase : OracleCode.eval (oracleFunction D.B) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₀ D))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₁ D))) + (meaning (machine (item t 2))) = oracleFunction Z) : + t ∉ (construction D s).done := by + intro ht + obtain ⟨u,_,hu⟩ := done_witness D ht + exact action_excludes_common hbase he₀ he₁ hu + +theorem scan_hits {D : LocalInputs.Data} {p : Condition} {d : Finset ℕ} {start n t : ℕ} + (hlo : start ≤ t) (hhi : t < start+n) (hd : t ∉ d) (hc : Changes D t p) : + ∃ i, i ≤ t ∧ scan D p d start n = some i := by + induction n generalizing start with + | zero => omega + | succ n ih => + by_cases h : start ∉ d ∧ Changes D start p + · exact ⟨start,hlo,by simp only [scan,ite_eq_left h]⟩ + · have hne : start ≠ t := by rintro rfl; exact h ⟨hd,hc⟩ + obtain ⟨i,hi,he⟩ := ih (start := start+1) (by omega) (by omega) + exact ⟨i,hi,by simpa only [scan,ite_eq_right h] using he⟩ + +theorem common_eventually_unchanged {D : LocalInputs.Data} {Y Z : Oracle} {t : ℕ} + (hbase : OracleCode.eval (oracleFunction D.B) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₀ D))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₁ D))) + (meaning (machine (item t 2))) = oracleFunction Z) : + ∃ S, ∀ s, S ≤ s → ¬ Changes D t (generic D (construction D s)) := by + obtain ⟨S,hS⟩ := finite_injury (proposal D) (t+1) + refine ⟨max S (t+1),fun s hs hc => ?_⟩ + obtain ⟨i,hi,he⟩ := scan_hits (start := 0) (n := s) (Nat.zero_le t) + (by omega) (common_not_done (s := s) hbase he₀ he₁) hc + apply hS s ((le_max_left _ _).trans hs) i (by omega) + simpa only [action_eq,stageAction] using he + +theorem nonchanging_outcome {D : LocalInputs.Data} {Y Z : Oracle} {s t : ℕ} + (hbase : OracleCode.eval (oracleFunction D.B) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₀ D))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₁ D))) + (meaning (machine (item t 2))) = oracleFunction Z) + (hchange : ¬ Changes D t (generic D (construction D s))) : + let p := atLevel (generic D (construction D s)) t + LocalAgreement.NoDisagreement D.B D.F t p ∧ LocalPair.NoBad D.B D.F t (code p) ∧ + ((¬ ∃ z, UniformSplit.SplitCert D.B (Nat.pair (UniformPair.request (Nat.pair t (code p))) z)) ∨ + ∃ w, UniformSplit.PointCert D.B (Nat.pair (UniformPair.request (Nat.pair t (code p))) w) ∧ + CodingLocation D.F p (item w 2)) := by + let p := atLevel (generic D (construction D s)) t + let q := condition (pairProcedure D (Nat.pair t (code p))) + have hwords : q.left = p.left ∧ q.right = p.right := by + change ¬ (q.left ≠ p.left ∨ q.right ≠ p.right) at hchange + exact ⟨Classical.not_not.mp (fun hn => hchange (Or.inl hn)), + Classical.not_not.mp (fun hn => hchange (Or.inr hn))⟩ + have hq₀ : CommonIdeal.Extends (LocalLimits.G₀ D) q.left := by + rw [hwords.1]; exact (LocalLimits.limits_extend_generic D s).1 + have hq₁ : CommonIdeal.Extends (LocalLimits.G₁ D) q.right := by + rw [hwords.2]; exact (LocalLimits.limits_extend_generic D s).2 + obtain ⟨_,hd | ⟨ha,hn,hd | ⟨he,hbad,hout⟩⟩⟩ := + D.pair_spec t (code p) + · exact False.elim (LocalPair.decisive_excludes_common (F := D.F) hbase hq₀ hq₁ he₀ he₁ (Or.inl hd)) + · exact False.elim (LocalPair.decisive_excludes_common (F := D.F) hbase hq₀ hq₁ he₀ he₁ hd) + · refine ⟨by simpa only [condition_code] using hn,hbad,?_⟩ + simpa only [LocalPair.Outcome,condition_code] using hout + +theorem common_eventually_outcome {D : LocalInputs.Data} {Y Z : Oracle} {t : ℕ} + (hbase : OracleCode.eval (oracleFunction D.B) (meaning (machine (item t 0))) = oracleFunction Y) + (he₀ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₀ D))) + (meaning (machine (item t 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y (LocalLimits.G₁ D))) + (meaning (machine (item t 2))) = oracleFunction Z) : + ∃ S, ∀ s, S ≤ s → + let p := atLevel (generic D (construction D s)) t + LocalAgreement.NoDisagreement D.B D.F t p ∧ LocalPair.NoBad D.B D.F t (code p) ∧ + ((¬ ∃ z, UniformSplit.SplitCert D.B (Nat.pair (UniformPair.request (Nat.pair t (code p))) z)) ∨ + ∃ w, UniformSplit.PointCert D.B (Nat.pair (UniformPair.request (Nat.pair t (code p))) w) ∧ + CodingLocation D.F p (item w 2)) := by + obtain ⟨S,hS⟩ := common_eventually_unchanged hbase he₀ he₁ + exact ⟨S,fun s hs => nonchanging_outcome hbase he₀ he₁ (hS s hs)⟩ + +end +end TuringRigidity.LocalOutcomes + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalPair.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fd2f8cf978d01abf831069135faa39d97714481 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalPair.lean @@ -0,0 +1,212 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalAgreement + +namespace OAI + +namespace TuringRigidity.LocalPair +open Encodable UniformOracle ArithmeticHierarchy OracleJump EncodedForcing EffectiveWitness IndexMatrix +open CodingForcing UniformProgram UniformPair LocalColumnCertificates +noncomputable section +attribute [local instance] Classical.propDecidable + +def Decisive (B : Oracle) (F : ℕ → Oracle) (x : ℕ) (p : Condition) : Prop := + UniformAgreement.Disagreement B x p ∨ ∃ i n, (i = 1 ∨ i = 2) ∧ ∀ q, Extends F p q → + ∀ a, a ∉ UniformRun.run B (machine (item x 0)) (machine (item x i)) + (if i = 1 then q.left else q.right) n + +def NoBad (B : Oracle) (F : ℕ → Oracle) (x p : ℕ) : Prop := + ∀ w, UniformSplit.PointCert B (Nat.pair (request (Nat.pair x p)) w) → + CodingLocation F (condition p) (item w 2) + +theorem split_coding_or_divergence {B : Oracle} {F : ℕ → Oracle} {x : ℕ} {p r : Condition} + (hn : LocalAgreement.NoDisagreement B F x p) (hpr : Extends F p r) + (m : ℕ) (hm : p.left.length ≤ m) (hmr : m < r.left.length) (b : Bool) + (n v w : ℕ) (hvw : v ≠ w) + (hv : v ∈ UniformRun.run B (machine (item x 0)) (machine (item x 1)) r.left n) + (hw : w ∈ UniformRun.run B (machine (item x 0)) (machine (item x 1)) (r.left.set m b) n) : + CodingLocation F p m ∨ + ∀ q, Extends F r q → ∀ c, + c ∉ UniformRun.run B (machine (item x 0)) (machine (item x 2)) q.right n := by + by_cases hc : CodingLocation F p m + · exact Or.inl hc + · right + intro q hrq c hvc + have hpq := extends_trans hpr hrq + have hpc := CodingOnePoint.changeLeft_extends hpq m hm hc b + have hvq := UniformRun.run_mono hrq.1 n v hv + have hwq := UniformRun.run_mono (CodingOnePoint.set_prefix_set hrq.1 m hmr b) n w hw + have hveq : v = c := by + by_contra hne + exact hn q hpq ⟨n,v,c,hne,hvq,hvc⟩ + have hweq : w = c := by + by_contra hne + exact hn (CodingOnePoint.changeLeft q m b) hpc ⟨n,w,c,hne,hwq,hvc⟩ + exact hvw (hveq.trans hweq.symm) + +theorem bad_decisive (B : Oracle) (F : ℕ → Oracle) (x p w : ℕ) + (hn : LocalAgreement.NoDisagreement B F x (condition p)) + (hb : UniformSplit.PointCert B (Nat.pair (request (Nat.pair x p)) w) ∧ + ¬ CodingLocation F (condition p) (item w 2)) : + Decisive B F x (condition (EffectiveSplitConditions.update p (Nat.pair 2 w))) := by + obtain ⟨hp,hnc⟩ := hb + have hpq : left p <+: word (item w 1) := by + simpa [UniformSplit.PointCert,UniformSplit.start,request,item,word] using hp.1 + let q := append (condition p) ((word (item w 1)).drop (left p).length) + have hl : q.left = word (item w 1) := by + change left p ++ (word (item w 1)).drop (left p).length = _ + rw [List.prefix_iff_eq_take] at hpq + conv_lhs => lhs; rw [hpq] + exact List.take_append_drop _ _ + have hpoint : (left p).length ≤ item w 2 ∧ item w 2 < (word (item w 1)).length ∧ + item w 4 ≠ item w 5 ∧ + item w 4 ∈ UniformRun.run B (machine (item x 0)) (machine (item x 1)) (word (item w 1)) (item w 0) ∧ + item w 5 ∈ UniformRun.run B (machine (item x 0)) (machine (item x 1)) + ((word (item w 1)).set (item w 2) (item w 3).bodd) (item w 0) := by + simpa [UniformSplit.PointCert,UniformSplit.start,UniformSplit.base,UniformSplit.program, + request,item,word] using hp.2 + have hd := split_coding_or_divergence (r := q) hn (append_extends F (condition p) + ((word (item w 1)).drop (left p).length)) (item w 2) hpoint.1 + (by simpa [hl] using hpoint.2.1) (item w 3).bodd (item w 0) (item w 4) (item w 5) + hpoint.2.2.1 (by simpa [hl] using hpoint.2.2.2.1) (by simpa [hl] using hpoint.2.2.2.2) + have hnc' : ¬ CodingLocation F (condition p) (item w 2) := hnc + have he : condition (EffectiveSplitConditions.update p (Nat.pair 2 w)) = q := by + simp [EffectiveSplitConditions.update,Nat.unpair_pair,condition_code,q] + rw [he] + exact Or.inr ⟨2,item w 0,Or.inr rfl,by simpa using hd.resolve_left hnc'⟩ + +def Outcome (B : Oracle) (F : ℕ → Oracle) (x p : ℕ) : Prop := + (¬ ∃ z, UniformSplit.SplitCert B (Nat.pair (request (Nat.pair x p)) z)) ∨ + ∃ w, UniformSplit.PointCert B (Nat.pair (request (Nat.pair x p)) w) ∧ + CodingLocation F (condition p) (item w 2) + +theorem raw_spec (B : Oracle) (F : ℕ → Oracle) (x p : ℕ) + (hnb : NoBad B F x p) : + let q := condition (EffectiveSplitConditions.update p (UniformSplit.step B (request (Nat.pair x p)))) + Decisive B F x q ∨ (q = condition p ∧ Outcome B F x p) := by + let raw := UniformSplit.step B (request (Nat.pair x p)) + have hs := UniformSplit.step_spec B (request (Nat.pair x p)) + change UniformSplit.Accept B (Nat.pair (request (Nat.pair x p)) raw) at hs + simp only [UniformSplit.Accept,Nat.unpair_pair] at hs + change Decisive B F x (condition (EffectiveSplitConditions.update p raw)) ∨ _ + rcases hs with ⟨ht,hno⟩ | ⟨ht,hpoint⟩ | ⟨ht,hdiv⟩ + · have he : condition (EffectiveSplitConditions.update p raw) = condition p := by + simp [EffectiveSplitConditions.update,ht,condition_code] + exact Or.inr ⟨he,Or.inl hno⟩ + · have he : condition (EffectiveSplitConditions.update p raw) = condition p := by + simp [EffectiveSplitConditions.update,ht,condition_code] + exact Or.inr ⟨he,Or.inr ⟨_,hpoint,hnb _ hpoint⟩⟩ + · let w := (Nat.unpair raw).2 + have hpq : left p <+: word (item w 1) := by + simpa [UniformSplit.DivCert,UniformSplit.start,request,item,word] using hdiv.1 + let r := append (condition p) ((word (item w 1)).drop (left p).length) + have hl : r.left = word (item w 1) := by + change left p ++ (word (item w 1)).drop (left p).length = _ + rw [List.prefix_iff_eq_take] at hpq + conv_lhs => lhs; rw [hpq] + exact List.take_append_drop _ _ + have he : condition (EffectiveSplitConditions.update p raw) = r := by + simp only [EffectiveSplitConditions.update,ite_eq_left ht,condition_code] + rfl + rw [he] + refine Or.inl (Or.inr ⟨1,item w 0,Or.inl rfl,?_⟩) + intro q hrq a ha + simp only [↓reduceIte] at ha + apply hdiv.2 + refine ⟨encode q.left,a,?_,?_⟩ + · simpa [word,w,hl] using hrq.1 + · simpa [UniformSplit.base,UniformSplit.program,request,item,word] using ha + +theorem next_exists (B : Oracle) : ∃ g : ℕ → ℕ, + Nat.RecursiveIn {oracleFunction (jump B)} (fun v => Part.some (g v)) ∧ + (∀ (F : ℕ → Oracle) req, Extends F (condition (item req 2)) (condition (g req)) ∧ + (condition (g req)).active = active (item req 2)) ∧ + ∀ (F : ℕ → Oracle) codes x p, Presents B F codes (active p) → + LocalAgreement.NoDisagreement B F x (condition p) → + Decisive B F x (condition (g (encode [codes,x,p]))) ∨ + (condition (g (encode [codes,x,p])) = condition p ∧ NoBad B F x p ∧ Outcome B F x p) := by + obtain ⟨search,hs,hsearch⟩ := guarded_search B + let raw := fun req => UniformSplit.step B (request (Nat.pair (item req 1) (item req 2))) + let tag := fun req => if search req = 0 then raw req else Nat.pair 2 (search req-1) + let g := fun req => EffectiveSplitConditions.update (item req 2) (tag req) + have hrec : Nat.RecursiveIn {oracleFunction (jump B)} (fun v => Part.some (g v)) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let req (i : ℕ) := item_primrec.comp Primrec.id (Primrec.const i) + have hr := total_comp (UniformSplit.step_recursive B) (total_primrec + (request_primrec.comp (Primrec₂.natPair.comp (req 1) (req 2)))) + have hm := Primrec.ite (Primrec.eq.comp f (Primrec.const 0)) r + (Primrec₂.natPair.comp (Primrec.const 2) (Primrec.nat_sub.comp f (Primrec.const 1))) + have ht := total_comp (total_primrec hm) (total_pair hs hr) + exact (total_comp (total_primrec (EffectiveSplitConditions.update_primrec.comp f r)) + (total_pair (total_primrec (req 2)) ht)).of_eq (fun req => by + simp only [Nat.unpair_pair]; rfl) + refine ⟨g,hrec,fun F req => ?_,fun F codes x p hp hn => ?_⟩ + · unfold g EffectiveSplitConditions.update + split <;> rw [condition_code] + · exact ⟨append_extends _ _ _,rfl⟩ + · exact ⟨extends_refl _ _,rfl⟩ + · rcases hsearch (encode [codes,x,p]) with ⟨hz,hno⟩ | ⟨hpos,hbad⟩ + · have hnb : NoBad B F x p := by + intro w hw + by_contra hnc + exact hno ⟨w,(bad_condition_iff hp x w).2 ⟨hw,hnc⟩⟩ + have he : g (encode [codes,x,p]) = EffectiveSplitConditions.update p + (UniformSplit.step B (request (Nat.pair x p))) := by simp only [g,tag,ite_eq_left hz,raw,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] + rw [he] + rcases raw_spec B F x p hnb with hd | ⟨he,ho⟩ + · exact Or.inl hd + · exact Or.inr ⟨he,hnb,ho⟩ + · have hz : search (encode [codes,x,p]) ≠ 0 := by omega + have he : g (encode [codes,x,p]) = EffectiveSplitConditions.update p + (Nat.pair 2 (search (encode [codes,x,p])-1)) := by simp only [g,tag,ite_eq_right hz,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] + rw [he] + exact Or.inl (bad_decisive B F x p _ hn ((bad_condition_iff hp x _).1 hbad)) + +theorem disagreement_mono {B : Oracle} {F : ℕ → Oracle} {x : ℕ} {p q : Condition} + (hpq : Extends F p q) (h : UniformAgreement.Disagreement B x p) : + UniformAgreement.Disagreement B x q := by + obtain ⟨n,a,b,hab,ha,hb⟩ := h + exact ⟨n,a,b,hab,UniformRun.run_mono hpq.1 n a ha,UniformRun.run_mono hpq.2.1 n b hb⟩ + +theorem pair_exists (B : Oracle) : ∃ f : ℕ → ℕ, + Nat.RecursiveIn {oracleFunction (jump B)} (fun v => Part.some (f v)) ∧ + ∀ (F : ℕ → Oracle) codes x p, Presents B F codes (active p) → + Extends F (condition p) (condition (f (encode [codes,x,p]))) ∧ + (UniformAgreement.Disagreement B x (condition (f (encode [codes,x,p]))) ∨ + ((condition (f (encode [codes,x,p]))).active = active p ∧ + LocalAgreement.NoDisagreement B F x (condition p) ∧ + (Decisive B F x (condition (f (encode [codes,x,p]))) ∨ + (condition (f (encode [codes,x,p])) = condition p ∧ + NoBad B F x p ∧ Outcome B F x p)))) := by + obtain ⟨d,hd,hds⟩ := LocalAgreement.decide_exists B + obtain ⟨g,hg,hge,hgs⟩ := next_exists B + let out := fun req => if d req = item req 2 then g req else d req + have hr : Nat.RecursiveIn {oracleFunction (jump B)} (fun req => Part.some (out req)) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hm := Primrec.ite (Primrec.eq.comp f (f.comp r)) (r.comp r) f + exact (total_comp (total_primrec hm) (total_pair hd + (total_pair (total_primrec (item_primrec.comp Primrec.id (Primrec.const 2))) hg))).of_eq + (fun req => by simp only [Nat.unpair_pair]; rfl) + refine ⟨out,hr,fun F codes x p hp => ?_⟩ + have hdsp := hds F codes x p hp + have hgep := hge F (encode [codes,x,p]) + have hpitem : item (encode [codes,x,p]) 2 = p := by simp [item] + rw [hpitem] at hgep + by_cases he : d (encode [codes,x,p]) = p + · have hout : out (encode [codes,x,p]) = g (encode [codes,x,p]) := by + simp only [out,hpitem,he,↓reduceIte] + rw [hout] + refine ⟨hgep.1,?_⟩ + rcases hdsp.2 with hdis | ⟨_,hn⟩ + · rw [he] at hdis + exact Or.inl (disagreement_mono hgep.1 hdis) + · exact Or.inr ⟨hgep.2,hn,hgs F codes x p hp hn⟩ + · have hout : out (encode [codes,x,p]) = d (encode [codes,x,p]) := by + simp only [out,hpitem,ite_eq_right he] + rw [hout] + exact ⟨hdsp.1,Or.inl (hdsp.2.resolve_right (fun h => he h.1))⟩ + +end +end TuringRigidity.LocalPair + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalPrograms.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalPrograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e4477afd5d125e9d305ef17032e611483b51684 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalPrograms.lean @@ -0,0 +1,77 @@ +import OAI.Computability.DegreeRigidity.Effective.ProgramSelection + +namespace OAI + +open Set Filter Topology +namespace TuringRigidity + +theorem locally_constant_on_restriction {X Y : Type*} [PseudoMetricSpace X] + [TopologicalSpace Y] [DiscreteTopology Y] (f : X → Y) (D : Set X) + (hf : ContinuousOn f D) (x : X) (hx : x ∈ D) : + ∃ ε : ℝ, 0 < ε ∧ ∀ y ∈ D, dist y x < ε → f y = f x := by + have hpre : f ⁻¹' {f x} ∈ nhdsWithin x D := + (hf x hx) ((isOpen_discrete ({f x} : Set Y)).mem_nhds (by simp)) + obtain ⟨ε,hε,hsub⟩ := Metric.mem_nhdsWithin_iff.mp hpre + exact ⟨ε,hε,fun y hy hdist => hsub ⟨hdist,hy⟩⟩ + +theorem fixed_local_indices (t u v : ℝ) (D : Set ℝ) (E : Set (ℝ × ℝ)) + (e : ℝ × ℝ → ℕ) (he : ContinuousOn e E) + (hgood : (u,v) ∈ goodPairs t D E) : + ∃ ρ : ℝ, 0 < ρ ∧ ρ < 1 ∧ + (∀ s ∈ rationalSpan t, ∀ a ∈ rationalSpan t, |s| < ρ → |a| < ρ → + e (u+s,v-u+a) = e (u,v-u)) ∧ + (∀ s ∈ rationalSpan t, |s| < ρ → e (v+s,u-v) = e (v,u-v)) := by + have hz : (0 : ℝ) ∈ rationalSpan t := ⟨0,0,by simp⟩ + have hp : (u,v-u) ∈ E := by simpa using (hgood 0 hz).2.1 0 hz + have hq : (v,u-v) ∈ E := by simpa using (hgood 0 hz).2.2 + obtain ⟨εp,hεp,hpconst⟩ := locally_constant_on_restriction e E he (u,v-u) hp + obtain ⟨εq,hεq,hqconst⟩ := locally_constant_on_restriction e E he (v,u-v) hq + let ρ : ℝ := min 1 (min εp εq) / 2 + have hmin : 0 < min 1 (min εp εq) := lt_min (by norm_num) (lt_min hεp hεq) + have hρ : 0 < ρ := div_pos hmin (by norm_num) + have hρmin : ρ < min 1 (min εp εq) := by dsimp [ρ]; linarith + have hρ1 : ρ < 1 := hρmin.trans_le (min_le_left _ _) + have hρp : ρ ≤ εp := le_trans hρmin.le ((min_le_right _ _).trans (min_le_left _ _)) + have hρq : ρ ≤ εq := le_trans hρmin.le ((min_le_right _ _).trans (min_le_right _ _)) + refine ⟨ρ,hρ,hρ1,?_,?_⟩ + · intro s hs a ha hsr har + apply hpconst _ ((hgood s hs).2.1 a ha) + rw [Prod.dist_eq] + apply max_lt + · simpa [Real.dist_eq, add_sub_cancel_left] using hsr.trans_le hρp + · simpa only [Real.dist_eq, add_sub_cancel_left] using har.trans_le hρp + · intro s hs hsr + apply hqconst _ ((hgood s hs).2.2) + rw [Prod.dist_eq] + apply max_lt + · simpa [Real.dist_eq, add_sub_cancel_left] using hsr.trans_le hρq + · simpa using hεq + +theorem fixed_local_programs (F : ℝ → Oracle) (t u v : ℝ) + (D : Set ℝ) (E : Set (ℝ × ℝ)) (e : ℝ × ℝ → ℕ) + (he : ContinuousOn e E) (hgood : (u,v) ∈ goodPairs t D E) + (hspec : ∀ x y, OracleCode.eval (oracleFunction (join (F x) (F y))) + (codeEnumeration (e (x,y))) = oracleFunction (F (x+y))) : + ∃ (p q : ℕ) (ρ : ℝ), 0 < ρ ∧ ρ < 1 ∧ + (∀ s ∈ rationalSpan t, ∀ a ∈ rationalSpan t, |s| < ρ → |a| < ρ → + OracleCode.eval (oracleFunction (join (F (u+s)) (F (v-u+a)))) + (codeEnumeration p) = oracleFunction (F (v+s+a))) ∧ + (∀ s ∈ rationalSpan t, |s| < ρ → + OracleCode.eval (oracleFunction (join (F (v+s)) (F (u-v)))) + (codeEnumeration q) = oracleFunction (F (u+s))) := by + obtain ⟨ρ,hρ,hρ1,hp,hq⟩ := fixed_local_indices t u v D E e he hgood + refine ⟨e (u,v-u),e (v,u-v),ρ,hρ,hρ1,?_,?_⟩ + · intro s hs a ha hsr har + have heq := hspec (u+s) (v-u+a) + have hsum : (u+s)+(v-u+a) = v+s+a := by ring + rw [hp s hs a ha hsr har, hsum] at heq + exact heq + · intro s hs hsr + have heq := hspec (v+s) (u-v) + have hsum : (v+s)+(u-v) = u+s := by ring + rw [hq s hs hsr, hsum] at heq + exact heq + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalScan.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalScan.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf09fcf0463fc25ca76965f633ab873466adb037 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalScan.lean @@ -0,0 +1,115 @@ +import OAI.Computability.DegreeRigidity.Effective.StageRecords +import OAI.Computability.DegreeRigidity.Effective.LocalStage + +namespace OAI + +namespace TuringRigidity.LocalComputability +open Encodable UniformOracle EncodedForcing CodingForcing FiniteInjury StageRecords +noncomputable section +attribute [local instance] Classical.propDecidable + +abbrev f := Primrec.fst.comp Primrec.unpair +abbrev r := Primrec.snd.comp Primrec.unpair + +def levelCode (p t : ℕ) : ℕ := Nat.pair (encode (left p)) (Nat.pair (encode (right p)) t) + +theorem levelCode_primrec : Primrec₂ levelCode := Primrec₂.natPair.comp + (Primrec.encode.comp (left_primrec.comp Primrec.fst)) + (Primrec₂.natPair.comp (Primrec.encode.comp (right_primrec.comp Primrec.fst)) Primrec.snd) + +theorem levelCode_eq (p t : ℕ) : levelCode p t = code (atLevel (condition p) t) := rfl + +@[simp] theorem condition_levelCode (p t : ℕ) : condition (levelCode p t) = atLevel (condition p) t := + condition_code (atLevel (condition p) t) + +def candidate (D : LocalInputs.Data) (v : ℕ) : ℕ := + levelCode (LocalStage.pairProcedure D (Nat.pair (Nat.unpair v).1 + (levelCode (Nat.unpair v).2 (Nat.unpair v).1))) (Nat.unpair v).1 + +theorem candidate_recursive (D : LocalInputs.Data) : + Nat.RecursiveIn {oracleFunction (D.bound)} (fun v => Part.some (candidate D v)) := by + have h := total_comp (LocalStage.pairProcedure_recursive D) + (total_primrec (Primrec₂.natPair.comp f (levelCode_primrec.comp r f))) + have hh := total_comp (total_primrec (levelCode_primrec.comp f r)) (total_pair h (total_primrec f)) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +@[simp] theorem candidate_eq (D : LocalInputs.Data) (t p : ℕ) : + condition (candidate D (Nat.pair t p)) = LocalStage.candidate D t (condition p) := by + simp only [candidate,Nat.unpair_pair,levelCode_eq,LocalStage.candidate,condition_code] + +def scanStep (D : LocalInputs.Data) (v : ℕ) : ℕ := + let p := (Nat.unpair (Nat.unpair v).1).1 + let d := (Nat.unpair (Nat.unpair v).1).2 + let t := (Nat.unpair (Nat.unpair v).2).1 + let prev := (Nat.unpair (Nat.unpair v).2).2 + let c := candidate D (Nat.pair t p) + if prev = 0 ∧ t ∉ record d ∧ (left c ≠ left p ∨ right c ≠ right p) then t+1 else prev + +theorem scanStep_recursive (D : LocalInputs.Data) : + Nat.RecursiveIn {oracleFunction (D.bound)} (fun v => Part.some (scanStep D v)) := by + have hc := total_comp (candidate_recursive D) + (total_primrec (Primrec₂.natPair.comp (f.comp r) (f.comp f))) + let v := f + let c := r + let p := f.comp (f.comp v) + let d := r.comp (f.comp v) + let t := f.comp (r.comp v) + let prev := r.comp (r.comp v) + have hm := (mem_primrec.comp d t).not + have hl := (Primrec.eq.comp (left_primrec.comp c) (left_primrec.comp p)).not + have hr := (Primrec.eq.comp (right_primrec.comp c) (right_primrec.comp p)).not + have hpost := Primrec.ite ((Primrec.eq.comp prev (Primrec.const 0)).and (hm.and (hl.or hr))) + (Primrec.succ.comp t) prev + have hh := total_comp (total_primrec hpost) (total_pair (total_primrec Primrec.id) hc) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +def scan (D : LocalInputs.Data) (p d n : ℕ) : ℕ := recur (fun _ => 0) (scanStep D) (Nat.pair p d) n + +theorem scan_recursive (D : LocalInputs.Data) : + Nat.RecursiveIn {oracleFunction (D.bound)} (fun v => + Part.some (scan D (Nat.unpair (Nat.unpair v).1).1 (Nat.unpair (Nat.unpair v).1).2 (Nat.unpair v).2)) := by + simpa only [scan,Nat.pair_unpair] using recur_recursive (total_primrec (Primrec.const 0)) (scanStep_recursive D) + +theorem source_scan_succ (D : LocalInputs.Data) (p : Condition) (d : Finset ℕ) (t n : ℕ) : + LocalStage.scan D p d t (n+1) = + match LocalStage.scan D p d t n with + | some i => some i + | none => if t+n ∉ d ∧ LocalStage.Changes D (t+n) p then some (t+n) else none := by + induction n generalizing t with + | zero => simp [LocalStage.scan] + | succ n ih => + change (if t ∉ d ∧ LocalStage.Changes D t p then some t else LocalStage.scan D p d (t+1) (n+1)) = + match (if t ∉ d ∧ LocalStage.Changes D t p then some t else LocalStage.scan D p d (t+1) n) with + | some i => some i + | none => if t+(n+1) ∉ d ∧ LocalStage.Changes D (t+(n+1)) p then some (t+(n+1)) else none + by_cases ht : t ∉ d ∧ LocalStage.Changes D t p + · simp only [ite_eq_left ht] + · simpa only [ite_eq_right ht,Nat.add_assoc,Nat.add_comm,Nat.add_left_comm] using ih (t+1) + +theorem scan_eq (D : LocalInputs.Data) (p d n : ℕ) : + scan D p d n = actionCode (LocalStage.scan D (condition p) (members d) 0 n) := by + induction n with + | zero => rfl + | succ n ih => + rw [source_scan_succ] + change scanStep D (Nat.pair (Nat.pair p d) (Nat.pair n (scan D p d n))) = _ + simp only [scanStep,Nat.unpair_pair,ih,Nat.zero_add] + have hc : left (candidate D (Nat.pair n p)) ≠ left p ∨ + right (candidate D (Nat.pair n p)) ≠ right p ↔ LocalStage.Changes D n (condition p) := by + change (condition (candidate D (Nat.pair n p))).left ≠ (condition p).left ∨ + (condition (candidate D (Nat.pair n p))).right ≠ (condition p).right ↔ _ + rw [candidate_eq] + rfl + cases he : LocalStage.scan D (condition p) (members d) 0 n with + | none => + by_cases hn : n ∉ record d ∧ LocalStage.Changes D n (condition p) + · simp_all only [actionCode,members,List.mem_toFinset,true_and] + simp + · simp_all only [actionCode,members,List.mem_toFinset,true_and] + simp + | some i => simp [actionCode] + +end +end TuringRigidity.LocalComputability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalSourceEquation.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalSourceEquation.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ee469b7e0b1032d5c4fe96d51d98854b979c307 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalSourceEquation.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DegreeRigidity.Representation.AutomorphismName +import OAI.Computability.DegreeRigidity.Representation.GenericIdentity + +namespace OAI + +namespace TuringRigidity.LocalSourceEquation +open Set PersistentRestrictions AutomorphismUnion AutomorphismName GenericIdentity + +instance (I : CountableIdeal) : SemilatticeSup I where + sup a b := ⟨a.val ⊔ b.val,I.join_mem a.property b.property⟩ + le_sup_left a b := (le_sup_left : a.val ≤ a.val ⊔ b.val) + le_sup_right a b := (le_sup_right : b.val ≤ a.val ⊔ b.val) + sup_le a b c h₁ h₂ := (sup_le h₁ h₂ : a.val ⊔ b.val ≤ c.val) + +theorem local_map_join (I : CountableIdeal) (σ : I ≃o I) (a b : I) : + (σ (a ⊔ b)).val = (σ a).val ⊔ (σ b).val := + congrArg Subtype.val (σ.map_sup a b) + +theorem local_intersection (I : CountableIdeal) (σ : I ≃o I) (a l r : I) + (h : ∀ b : Degree, b ≤ a.val ↔ b ≤ l.val ∧ b ≤ r.val) : + ∀ b : Degree, b ≤ (σ a).val ↔ b ≤ (σ l).val ∧ b ≤ (σ r).val := by + intro b + constructor + · intro hb + have ha := (h a.val).mp le_rfl + exact ⟨hb.trans (σ.monotone ha.1),hb.trans (σ.monotone ha.2)⟩ + · rintro ⟨hl,hr⟩ + let bI : I := ⟨b,I.lower hl (σ l).property⟩ + have hl' : σ.symm bI ≤ l := by + apply σ.le_iff_le.mp + simpa only [σ.apply_symm_apply] using (show bI ≤ σ l from hl) + have hr' : σ.symm bI ≤ r := by + apply σ.le_iff_le.mp + simpa only [σ.apply_symm_apply] using (show bI ≤ σ r from hr) + have hba : σ.symm bI ≤ a := (h (σ.symm bI).val).mpr ⟨hl',hr'⟩ + have hh := σ.monotone hba + have hh' : bI ≤ σ a := by simpa only [σ.apply_symm_apply] using hh + exact hh' + +theorem graph_join (G : CountableForcing.GenericFilter Approximation) {a b c d : Degree} + (hab : Graph G a b) (hcd : Graph G c d) : Graph G (a ⊔ c) (b ⊔ d) := by + obtain ⟨p,hp,ha,hab⟩ := hab + obtain ⟨q,hq,hc,hcd⟩ := hcd + obtain ⟨r,hr,hrp,hrq⟩ := G.directed hp hq + obtain ⟨ha',hab'⟩ := graph_mono hrp ha hab + obtain ⟨hc',hcd'⟩ := graph_mono hrq hc hcd + refine ⟨r,hr,r.ideal.join_mem ha' hc',?_⟩ + exact (local_map_join r.ideal r.map ⟨a,ha'⟩ ⟨c,hc'⟩).trans (congrArg₂ (· ⊔ ·) hab' hcd') + +theorem graph_intersection (G : CountableForcing.GenericFilter Approximation) + {a a' l l' r r' : Degree} (ha : Graph G a a') (hl : Graph G l l') (hr : Graph G r r') + (h : ∀ b : Degree, b ≤ a ↔ b ≤ l ∧ b ≤ r) : + ∀ b : Degree, b ≤ a' ↔ b ≤ l' ∧ b ≤ r' := by + intro b + constructor + · intro hb + have ha₀ := (h a).mp le_rfl + exact ⟨hb.trans ((graph_order G ha hl).mp ha₀.1),hb.trans ((graph_order G ha hr).mp ha₀.2)⟩ + · rintro ⟨hbl,hbr⟩ + have hbD := domain_lower G hbl (graph_domain hl).2 + obtain ⟨c,hcb⟩ := graph_surjective G hbD + have hc : c ≤ a := (h c).mpr ⟨(graph_order G hcb hl).mpr hbl,(graph_order G hcb hr).mpr hbr⟩ + exact (graph_order G hcb ha).mp hc + +def Represented (G : CountableForcing.GenericFilter Approximation) + (p : OracleCode) (P A : Oracle) : Prop := + Total p P A ∧ (degree A,degree (GenericIdentity.value p P A)) ∈ interpret graphName G + +theorem sourceEquation_of_graph (G : CountableForcing.GenericFilter Approximation) + (p : OracleCode) (P Y L R : Oracle) + (hL : GenericCoding.InfiniteOdd L) (hR : GenericCoding.InfiniteOdd R) + (hideal : ∀ b : Degree, b ≤ degree Y ↔ b ≤ degree (join Y L) ∧ b ≤ degree (join Y R)) + (hY : Represented G p P Y) (hGL : Represented G p P L) (hGR : Represented G p P R) + (hCL : Represented G p P (GenericCoding.code Y L)) + (hCR : Represented G p P (GenericCoding.code Y R)) : SourceEquation p P (Y,L,R) := by + refine ⟨hY.1,hGL.1,hGR.1,hCL.1,hCR.1,?_⟩ + have hleft := graph_join G hCL.2 hGL.2 + have hright := graph_join G hCR.2 hGR.2 + change Graph G (degree (join (GenericCoding.code Y L) L)) + (degree (join (GenericIdentity.value p P (GenericCoding.code Y L)) (GenericIdentity.value p P L))) at hleft + change Graph G (degree (join (GenericCoding.code Y R) R)) + (degree (join (GenericIdentity.value p P (GenericCoding.code Y R)) (GenericIdentity.value p P R))) at hright + rw [GenericCoding.join_degree_eq Y L hL] at hleft + rw [GenericCoding.join_degree_eq Y R hR] at hright + exact graph_intersection G hY.2 hleft hright hideal + +end TuringRigidity.LocalSourceEquation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalStage.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalStage.lean new file mode 100644 index 0000000000000000000000000000000000000000..e224689a57e661cab65e4269bca353d2d2a25b95 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalStage.lean @@ -0,0 +1,187 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalInputs +import OAI.Computability.DegreeRigidity.CohenForcing.EffectiveForcing +import OAI.Computability.DegreeRigidity.Effective.FiniteInjuryLimits +import OAI.Computability.DegreeRigidity.Effective.FiniteInjurySchedule + +namespace OAI + +namespace TuringRigidity.LocalStage +open Encodable CodingForcing EncodedForcing FiniteInjury +noncomputable section +attribute [local instance] Classical.propDecidable + +def pairProcedure (D : LocalInputs.Data) : ℕ → ℕ := D.pairProcedure + +theorem pairProcedure_recursive (D : LocalInputs.Data) : + Nat.RecursiveIn {oracleFunction D.bound} (fun v => Part.some (pairProcedure D v)) := D.pair_recursive + +def candidate (D : LocalInputs.Data) (t : ℕ) (p : Condition) : Condition := + atLevel (condition (pairProcedure D (Nat.pair t (code (atLevel p t))))) t + +theorem candidate_extends (D : LocalInputs.Data) (t : ℕ) (p : Condition) : + Extends D.F (atLevel p t) (candidate D t p) := by + have h := (D.pair_spec t (code (atLevel p t))).1 + rw [condition_code] at h + exact ⟨h.1,h.2.1,le_rfl,h.2.2.2⟩ + +def Changes (D : LocalInputs.Data) (t : ℕ) (p : Condition) : Prop := + (candidate D t p).left ≠ p.left ∨ (candidate D t p).right ≠ p.right + +def scan (D : LocalInputs.Data) (p : Condition) (done : Finset ℕ) (t : ℕ) : ℕ → Option ℕ + | 0 => none + | n+1 => if t ∉ done ∧ Changes D t p then some t else scan D p done (t+1) n + +theorem scan_spec {D : LocalInputs.Data} {p : Condition} {done : Finset ℕ} {t n i : ℕ} + (h : scan D p done t n = some i) : + t ≤ i ∧ i < t+n ∧ i ∉ done ∧ Changes D i p := by + induction n generalizing t with + | zero => simp [scan] at h + | succ n ih => + simp only [scan] at h + split at h + · rename_i ht + have he := Option.some.inj h + subst i + exact ⟨le_rfl,by omega,ht⟩ + · obtain ⟨hlo,hhi,hd,hc⟩ := ih h + exact ⟨by omega,by omega,hd,hc⟩ + +def openProcedure (D : LocalInputs.Data) : ℕ → ℕ := D.openProcedure + +theorem open_extends (D : LocalInputs.Data) (e : ℕ) (p : Condition) : + Extends D.F p (condition (openProcedure D (Nat.pair e (code p)))) := by + simpa only [condition_code,openProcedure] using (D.open_spec e (code p)).1 + +structure State where + condition : Condition + done : Finset ℕ + seen : Finset ℕ + +def generic (D : LocalInputs.Data) (p : State) : Condition := + EncodedForcing.condition (openProcedure D (Nat.pair (FiniteInjurySchedule.visit p.seen) (code p.condition))) + +def stageAction (D : LocalInputs.Data) (s : ℕ) (p : State) : Option ℕ := scan D (generic D p) p.done 0 s + +def stageWord (D : LocalInputs.Data) (s : ℕ) (p : State) : Condition := + match stageAction D s p with + | none => generic D p + | some t => candidate D t (generic D p) + +def advance (D : LocalInputs.Data) (s : ℕ) (p : State) : State where + condition := atLevel (append (stageWord D s p) [false]) (s+1) + done := FiniteInjury.update p.done (stageAction D s p) + seen := FiniteInjurySchedule.reset (insert (FiniteInjurySchedule.visit p.seen) p.seen) (stageAction D s p) + +def construction (D : LocalInputs.Data) : ℕ → State + | 0 => ⟨⟨[],[],rfl,0⟩,∅,∅⟩ + | s+1 => advance D s (construction D s) + +def conditions (D : LocalInputs.Data) (s : ℕ) := (construction D s).condition + +def proposal (D : LocalInputs.Data) (s : ℕ) (_ : Finset ℕ) : Option ℕ := + stageAction D s (construction D s) + +theorem action_not_done (D : LocalInputs.Data) (s : ℕ) (p : State) (t : ℕ) + (h : stageAction D s p = some t) : t ∉ p.done := (scan_spec h).2.2.1 + +theorem accept_action (D : LocalInputs.Data) (s : ℕ) (p : State) : + FiniteInjury.accept p.done (stageAction D s p) = stageAction D s p := by + cases ha : stageAction D s p with + | none => simp [FiniteInjury.accept] + | some t => simp [FiniteInjury.accept,action_not_done D s p t ha] + +theorem done_eq (D : LocalInputs.Data) (s : ℕ) : + (construction D s).done = FiniteInjury.state (proposal D) s := by + induction s with + | zero => rfl + | succ s ih => + change FiniteInjury.update (construction D s).done (stageAction D s (construction D s)) = _ + rw [FiniteInjury.state] + rw [← ih] + simp only [proposal,accept_action] + +theorem action_eq (D : LocalInputs.Data) (s : ℕ) : + FiniteInjury.action (proposal D) s = stageAction D s (construction D s) := by + rw [FiniteInjury.action,← done_eq] + exact accept_action D s _ + +theorem seen_eq (D : LocalInputs.Data) (s : ℕ) : + (construction D s).seen = FiniteInjurySchedule.seen (proposal D) s := by + induction s with + | zero => rfl + | succ s ih => + change FiniteInjurySchedule.reset _ _ = _ + rw [FiniteInjurySchedule.seen,action_eq,← ih] + +theorem active_eq (D : LocalInputs.Data) (s : ℕ) : (conditions D s).active = s := by + cases s <;> rfl + +theorem stage_words (D : LocalInputs.Data) (s : ℕ) (p : State) : + p.condition.left <+: (stageWord D s p).left ∧ p.condition.right <+: (stageWord D s p).right := by + have ho := open_extends D (FiniteInjurySchedule.visit p.seen) p.condition + cases ha : stageAction D s p with + | none => exact ⟨by simpa [stageWord,ha,generic] using ho.1,by simpa [stageWord,ha,generic] using ho.2.1⟩ + | some t => + have hc := candidate_extends D t (generic D p) + exact ⟨by simpa [stageWord,ha] using ho.1.trans hc.1, + by simpa [stageWord,ha] using ho.2.1.trans hc.2.1⟩ + +theorem word_growth (D : LocalInputs.Data) (s : ℕ) : + (conditions D s).left <+: (conditions D (s+1)).left ∧ + (conditions D s).right <+: (conditions D (s+1)).right := by + have h := stage_words D s (construction D s) + exact ⟨h.1.trans (List.prefix_append _ _),h.2.trans (List.prefix_append _ _)⟩ + +theorem length_bound (D : LocalInputs.Data) (s : ℕ) : s ≤ (conditions D s).left.length := by + induction s with + | zero => exact Nat.zero_le _ + | succ s ih => + have h := (stage_words D s (construction D s)).1.length_le + change s+1 ≤ ((stageWord D s (construction D s)).left ++ [false]).length + simp only [List.length_append,List.length_singleton] + exact Nat.add_le_add_right (ih.trans h) 1 + +theorem level_step (D : LocalInputs.Data) (s k : ℕ) (hk : k ≤ s) + (hact : ∀ t, FiniteInjury.action (proposal D) s = some t → k ≤ t) : + Extends D.F (atLevel (conditions D s) k) (atLevel (conditions D (s+1)) k) := by + let p := construction D s + have ho := open_extends D (FiniteInjurySchedule.visit p.seen) p.condition + have hg : Extends D.F (atLevel p.condition k) (atLevel (generic D p) k) := by + refine ⟨ho.1,ho.2.1,le_rfl,?_⟩ + intro m hm hlen + apply ho.2.2.2 m ⟨hm.1,?_,hm.2.2⟩ hlen + exact hm.2.1.trans_le (by + change k ≤ (conditions D s).active + rw [active_eq] + exact hk) + have hw : Extends D.F (atLevel (generic D p) k) (atLevel (stageWord D s p) k) := by + cases ha : stageAction D s p with + | none => simpa [stageWord,ha] using extends_refl D.F (atLevel (generic D p) k) + | some t => + have hkt : k ≤ t := hact t (by simpa [action_eq,p] using ha) + have hc := candidate_extends D t (generic D p) + have hc' : Extends D.F (atLevel (generic D p) t) (atLevel (candidate D t (generic D p)) t) := hc + simpa [stageWord,ha] using level_mono hc' hkt + have htail : Extends D.F (atLevel (stageWord D s p) k) + (atLevel (conditions D (s+1)) k) := append_extends _ _ [false] + exact extends_trans hg (extends_trans hw htail) + +theorem surviving_columns (D : LocalInputs.Data) (k : ℕ) : ∃ S, ∀ m, + (conditions D S).left.length ≤ m → (Nat.unpair m).1 < k → + D.F (Nat.unpair m).1 (Nat.unpair m).2 = true → + leftLimit (conditions D) m = rightLimit (conditions D) m := + eventual_column_agreement D.F (proposal D) (conditions D) + (word_growth D) (length_bound D) (level_step D) k + +theorem surviving_generic_visit (D : LocalInputs.Data) (t : ℕ) : ∃ s, + FiniteInjurySchedule.visit (construction D s).seen = t ∧ + ∀ u, s ≤ u → ∀ i < t, stageAction D u (construction D u) ≠ some i := by + obtain ⟨s,hs,hh⟩ := FiniteInjurySchedule.surviving_visit (proposal D) t + refine ⟨s,?_,?_⟩ + · simpa [seen_eq,FiniteInjurySchedule.scheduled] using hs + · simpa only [action_eq] using hh + +end +end TuringRigidity.LocalStage + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/LocalUnary.lean b/lean/OAI/Computability/DegreeRigidity/Effective/LocalUnary.lean new file mode 100644 index 0000000000000000000000000000000000000000..1eda5491409ebf32d9255da6620dfb7bb8f997e8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/LocalUnary.lean @@ -0,0 +1,109 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalCoding +import OAI.Computability.DegreeRigidity.SetModels.FixedArithmetic + +namespace OAI + +namespace TuringRigidity.LocalUnary +open Encodable EncodedForcing ArithmeticHierarchy UniformOracle OracleJump +open ArithmeticModelDecoding SetCoding RelationCoding BoundedDecoding +noncomputable section +attribute [local instance] Classical.propDecidable + +theorem predicate_code (C A : Oracle) + (hind : ∀ a₀ a₁ : Degree, a₀ ≤ degree C → a₁ ≤ degree C → ∀ i (F : Finset ℕ), + a₀ ⊔ degree (columns A i) ≤ a₁ ⊔ F.sup (fun j => degree (columns A j)) ↔ + a₀ ≤ a₁ ∧ i ∈ F) + (hlow : Reduces (jump (join C A)) (jump FixedArithmetic.zero)) (X : Oracle) : + ∃ p : RelationCode 1, RelationBelow p (degree (join X (jump FixedArithmetic.zero))) ∧ + ∀ x, p.Holds (one x) ↔ ∃ k, X k = true ∧ x = degree (columns C k) := by + by_cases hne : ∃ k, X k = true + · obtain ⟨k₀,hk₀⟩ := hne + let P := fun k => X k = true + let select := EffectivePresentation.pick P k₀ + have hP : RecursivePred X P := by + have hq : Nat.RecursiveIn {oracleFunction X} (oracleFunction X) := .oracle _ (Set.mem_singleton _) + exact hq.of_eq (fun n => by cases hx : X n <;> simp [oracleFunction,P,hx]) + have hs := EffectivePresentation.pick_recursive hP k₀ + have hsel (k : ℕ) : X (select k) = true := by + by_cases hk : X k = true + · simpa only [select,EffectivePresentation.pick,P,ite_eq_left hk] using hk + · simpa only [select,EffectivePresentation.pick,P,ite_eq_right hk] using hk₀ + have hfix (k : ℕ) (hk : X k = true) : select k = k := by + simp only [select,EffectivePresentation.pick,P,ite_eq_left hk] + let B := join C A + let F := EffectiveFamilies.mix C A + have hF : Reduces F B := EffectiveFamilies.mix_reduces C A + have hcol (k : ℕ) : degree (columns C k) ≤ degree C := CodingExtraction.column_projection_reduces C k + have htag (x y : Degree) (hx : x ≤ degree C) (hy : y ≤ degree C) (i j : ℕ) : + x ⊔ degree (columns A i) ≤ y ⊔ degree (columns A j) ↔ x ≤ y ∧ i = j := by + simpa only [Finset.sup_singleton,Finset.mem_singleton] using hind x y hx hy i {j} + have hAntiA : ∀ i j, degree (columns A i) ≤ degree (columns A j) → + degree (columns A i) = degree (columns A j) := by + intro i j h + have hij := (htag ⊥ ⊥ bot_le bot_le i j).mp (by simpa only [bot_sup_eq] using h) + exact congrArg (fun k => degree (columns A k)) hij.2 + have hAntiF : ∀ i j, degree (columns F (select i)) ≤ degree (columns F (select j)) → + degree (columns F (select i)) = degree (columns F (select j)) := by + intro i j h + have hh : degree (columns C (select i)) ⊔ degree (columns A (select i)) ≤ + degree (columns C (select j)) ⊔ degree (columns A (select j)) := by + rw [show F = EffectiveFamilies.mix C A from rfl,EffectiveFamilies.mix_column,EffectiveFamilies.mix_column] at h + exact h + have hij := (htag _ _ (hcol _) (hcol _) _ _).mp hh + exact congrArg (fun k => degree (columns F k)) hij.2 + obtain ⟨pc,hpc,hpcspec⟩ := EffectiveFamilies.antichainCode_below (reduces_join_right C A) hAntiA + obtain ⟨g₀,g₁,hg,hgspec⟩ := LocalCoding.selected_antichain hF select hs hAntiF + let pt : AntichainCode := ⟨degree B,g₀,g₁⟩ + let ps : SetCode := ⟨degree C,pc,pt⟩ + have hB : degree B ≤ degree (join X (jump FixedArithmetic.zero)) := + (show degree B ≤ degree (jump B) from reduces_jump B).trans (hlow.trans (reduces_join_right _ _)) + have hj : degree (join X (jump B)) ≤ degree (join X (jump FixedArithmetic.zero)) := + join_mono (reduces_refl X) hlow + have hps : SetBelow ps (degree (join X (jump FixedArithmetic.zero))) := + ⟨(show degree C ≤ degree B from reduces_join_left C A).trans hB, + hpc.mono (hlow.trans (reduces_join_right _ _)), + ⟨hB,(le_sup_left.trans hg).trans hj,(le_sup_right.trans hg).trans hj⟩⟩ + refine ⟨unary ps,unary_below hps,fun x => ?_⟩ + rw [unary_holds] + constructor + · rintro ⟨a,hx,ha,ht⟩ + obtain ⟨i,rfl⟩ := (hpcspec a).mp ha + obtain ⟨j,hj⟩ := (hgspec (x ⊔ degree (columns A i))).mp ht + have he : degree (columns C (select j)) ⊔ degree (columns A (select j)) = + x ⊔ degree (columns A i) := by + rw [show F = EffectiveFamilies.mix C A from rfl,EffectiveFamilies.mix_column] at hj + exact hj + have h₀ := (htag _ _ (hcol _) hx _ _).mp he.le + have h₁ := (htag _ _ hx (hcol _) _ _).mp he.ge + exact ⟨select j,hsel j,le_antisymm h₁.1 h₀.1⟩ + · rintro ⟨k,hk,rfl⟩ + refine ⟨degree (columns A k),hcol k,(hpcspec _).mpr ⟨k,rfl⟩,?_⟩ + apply (hgspec _).mpr + refine ⟨k,?_⟩ + rw [hfix k hk,show F = EffectiveFamilies.mix C A from rfl,EffectiveFamilies.mix_column] + rfl + · refine ⟨EffectivePresentation.emptyRelation 1,EffectivePresentation.emptyRelation_below _ _,fun x => ?_⟩ + constructor + · intro h + exact False.elim (EffectivePresentation.emptyRelation_holds 1 _ h) + · rintro ⟨k,hk,_⟩ + exact False.elim (hne ⟨k,hk⟩) + +theorem localized_copy (X : Oracle) : ∃ c : Copy (fun n => X n = true), + RelationBelow c.successor (degree (join X (jump FixedArithmetic.zero))) ∧ + RelationBelow c.predicate (degree (join X (jump FixedArithmetic.zero))) := by + obtain ⟨K⟩ := FixedArithmetic.frame_exists + obtain ⟨A,_,hlow,hind⟩ := CohenColumns.uniform_low_independent K.C + have hlow' : Reduces (jump (join K.C A)) (jump FixedArithmetic.zero) := by + change degree (jump (join K.C A)) ≤ degree (jump FixedArithmetic.zero) + rw [hlow] + exact K.low + obtain ⟨P,hP,hpspec⟩ := predicate_code K.C A hind hlow' X + let c : Copy (fun n => X n = true) := ⟨fun k => degree (columns K.C k),K.injective, + K.successor,P,K.spec,hpspec⟩ + exact ⟨c,K.below.mono (reduces_join_right _ _),hP⟩ + +end +end TuringRigidity.LocalUnary + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/OrderMatrixRecursive.lean b/lean/OAI/Computability/DegreeRigidity/Effective/OrderMatrixRecursive.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e6ef56ddebbbde0ffa9445bb5ff9f94b5568121 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/OrderMatrixRecursive.lean @@ -0,0 +1,82 @@ +import OAI.Computability.DegreeRigidity.Effective.OrderNormalForm + +namespace OAI + +namespace TuringRigidity.OrderNormalForm +open UniformOracle TableIndices IndexMatrix IndexedOrder CertificateMatrix + +private def combine (v : ℕ) : ℕ := + let t := (Nat.unpair v).1 + let h := (Nat.unpair (Nat.unpair v).2).1 + let c₀ := (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).1 + let c₁ := (Nat.unpair (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).2).1 + let a := (Nat.unpair (Nat.unpair (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).2).2).1 + let b := (Nat.unpair (Nat.unpair (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).2).2).2 + if t = 1 ∧ h = 1 ∧ (c₀ ≠ 1 ∨ c₁ ≠ 1 ∨ a = b) then 1 else 0 + +private theorem combine_primrec : Primrec combine := by + let f := Primrec.fst.comp Primrec.unpair + let s := Primrec.snd.comp Primrec.unpair + let t := f + let h := f.comp s + let c₀ := f.comp (s.comp s) + let c₁ := f.comp (s.comp (s.comp s)) + let a := f.comp (s.comp (s.comp (s.comp s))) + let b := s.comp (s.comp (s.comp (s.comp s))) + have hp := (Primrec.eq.comp c₀ (Primrec.const 1)).not.or + ((Primrec.eq.comp c₁ (Primrec.const 1)).not.or (Primrec.eq.comp a b)) + exact Primrec.ite ((Primrec.eq.comp t (Primrec.const 1)).and + ((Primrec.eq.comp h (Primrec.const 1)).and hp)) (Primrec.const 1) (Primrec.const 0) + +theorem orderMatrix_recursive (Y : Oracle) : + Nat.RecursiveIn {oracleFunction Y} (fun v => Part.some + (if orderMatrix Y (Nat.unpair v).1 (Nat.unpair (Nat.unpair v).2).1 + (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).1 + (Nat.unpair (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).2).1 + (Nat.unpair (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).2).2 then 1 else 0)) := by + let O : Set (ℕ →. ℕ) := {oracleFunction Y} + let f := Primrec.fst.comp Primrec.unpair + let s := Primrec.snd.comp Primrec.unpair + let e₀ := f + let e₁ := f.comp s + let d := f.comp (s.comp s) + let q := f.comp (s.comp (s.comp s)) + let r := s.comp (s.comp (s.comp s)) + let n := f.comp q + let challenge := s.comp q + let m := f.comp challenge + let a := f.comp (s.comp challenge) + let b := f.comp (s.comp (s.comp challenge)) + let z := f.comp (s.comp (s.comp (s.comp challenge))) + let w := s.comp (s.comp (s.comp (s.comp challenge))) + let answer := f.comp r + let cert := f.comp (s.comp r) + let trial := s.comp (s.comp r) + have mk : ∀ (fn fa fz : ℕ → ℕ), Primrec fn → Primrec fa → Primrec fz → + Nat.RecursiveIn O (fun v => Part.some + (if Certificate Y (machine (Nat.unpair (Nat.unpair v).2).1) + (machine (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).1) + (fn v) (fa v) (fz v) then 1 else 0)) := by + intro fn fa fz hn ha hz + exact (total_comp (certificate_recursive Y) + (total_pair (total_primrec e₁) (total_pair (total_primrec d) + (total_pair (total_primrec hn) (total_pair (total_primrec ha) (total_primrec hz)))))).of_eq + (fun v => by simp) + have ht := mk _ _ _ n answer cert + have hc₀ := mk _ _ _ m a z + have hc₁ := mk _ _ _ m b w + have hr := total_comp (run_uniform_recursive Y) + (total_pair (total_primrec e₀) (total_pair (total_primrec n) (total_primrec trial))) + have hans := total_primrec (O := O) (Primrec.encode.comp (Primrec.option_some.comp answer)) + have heq := total_primrec (O := O) + (Primrec.ite (Primrec.eq.comp f s) (Primrec.const 1) (Primrec.const 0)) + have hout := total_comp heq (total_pair hr hans) + exact (total_comp (total_primrec combine_primrec) + (total_pair ht (total_pair hout (total_pair hc₀ (total_pair hc₁ + (total_pair (total_primrec a) (total_primrec b))))))).of_eq (fun v => by + simp only [combine, orderMatrix, Nat.unpair_pair, Encodable.encode_injective.eq_iff] + simp [and_assoc, imp_iff_not_or]) + +end TuringRigidity.OrderNormalForm + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/OrderNormalForm.lean b/lean/OAI/Computability/DegreeRigidity/Effective/OrderNormalForm.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a5488261fde14d1c345de2fb01869c42261dc8c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/OrderNormalForm.lean @@ -0,0 +1,60 @@ +import OAI.Computability.DegreeRigidity.Syntax.CertificateMatrix + +namespace OAI + +namespace TuringRigidity.OrderNormalForm +open Encodable TableIndices IndexMatrix IndexedOrder CertificateMatrix + +def orderMatrix (Y : Oracle) (e₀ e₁ d q r : ℕ) : Prop := + let n := (Nat.unpair q).1 + let challenge := (Nat.unpair q).2 + let m := (Nat.unpair challenge).1 + let a := (Nat.unpair (Nat.unpair challenge).2).1 + let b := (Nat.unpair (Nat.unpair (Nat.unpair challenge).2).2).1 + let z := (Nat.unpair (Nat.unpair (Nat.unpair (Nat.unpair challenge).2).2).2).1 + let w := (Nat.unpair (Nat.unpair (Nat.unpair (Nat.unpair challenge).2).2).2).2 + let answer := (Nat.unpair r).1 + let cert := (Nat.unpair (Nat.unpair r).2).1 + let trial := (Nat.unpair (Nat.unpair r).2).2 + (Certificate Y (machine e₁) (machine d) n answer cert ∧ + TableIndices.run Y (machine e₀) n trial = some answer) ∧ + (Certificate Y (machine e₁) (machine d) m a z → + Certificate Y (machine e₁) (machine d) m b w → a = b) + +instance (Y : Oracle) (e₀ e₁ d q r : ℕ) : Decidable (orderMatrix Y e₀ e₁ d q r) := by + unfold orderMatrix + infer_instance + +theorem witness_normal_form (Y : Oracle) (e₀ e₁ d : ℕ) : + OrderWitness Y (machine e₀) (machine e₁) (machine d) ↔ + ∀ q, ∃ r, orderMatrix Y e₀ e₁ d q r := by + constructor + · rintro ⟨hc, ht⟩ q + obtain ⟨a, z, w, hz, hw⟩ := ht (Nat.unpair q).1 + exact ⟨Nat.pair a (Nat.pair z w), ⟨by simpa using hz, by simpa using hw⟩, + hc _ _ _ _ _⟩ + · intro h + refine ⟨?_, ?_⟩ + · intro n a b z w hz hw + obtain ⟨r, _, hc⟩ := h (Nat.pair 0 (Nat.pair n (Nat.pair a (Nat.pair b (Nat.pair z w))))) + simp only [Nat.unpair_pair] at hc + exact hc hz hw + · intro n + obtain ⟨r, ⟨hc, ht⟩, _⟩ := h (Nat.pair n 0) + exact ⟨(Nat.unpair r).1, (Nat.unpair (Nat.unpair r).2).1, + (Nat.unpair (Nat.unpair r).2).2, by simpa using hc, by simpa using ht⟩ + +theorem order_normal_form {Y A₀ A₁ : Oracle} {e₀ e₁ : ℕ} + (h₀ : Represents Y (machine e₀) A₀) (h₁ : Represents Y (machine e₁) A₁) : + Reduces A₀ A₁ ↔ ∃ d : ℕ, ∀ q : ℕ, ∃ r : ℕ, orderMatrix Y e₀ e₁ d q r := by + rw [order_iff_witness h₀ h₁] + constructor + · rintro ⟨d, hd⟩ + refine ⟨encode d, (witness_normal_form Y e₀ e₁ (encode d)).mp ?_⟩ + simpa using hd + · rintro ⟨d, hd⟩ + exact ⟨machine d, (witness_normal_form Y e₀ e₁ d).mpr hd⟩ + +end TuringRigidity.OrderNormalForm + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/PartialComputability.lean b/lean/OAI/Computability/DegreeRigidity/Effective/PartialComputability.lean new file mode 100644 index 0000000000000000000000000000000000000000..4bc6dd9760bb104922335a5b6e6fa4ad1a46663e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/PartialComputability.lean @@ -0,0 +1,37 @@ +import Mathlib.Computability.PartrecCode + +namespace OAI + +namespace TuringRigidity +open Computable + +theorem partrec_code {α : Type*} [Primcodable α] {f : α →. ℕ} (hf : Partrec f) : + ∃ c : Nat.Partrec.Code, ∀ a, c.eval (Encodable.encode a) = f a := by + obtain ⟨c,hc⟩ := Nat.Partrec.Code.exists_code.mp hf + refine ⟨c, fun a => ?_⟩ + simp [hc, Encodable.encodek, Part.map_id'] + +theorem partrec_cond {α : Type*} [Primcodable α] {b : α → Bool} {f g : α →. ℕ} + (hb : Computable b) (hf : Partrec f) (hg : Partrec g) : + Partrec (fun a => if b a then f a else g a) := by + obtain ⟨cf,hcf⟩ := partrec_code hf + obtain ⟨cg,hcg⟩ := partrec_code hg + have hs : Computable (fun a => cond (b a) cf cg) := + Computable.cond hb (Computable.const cf) (Computable.const cg) + exact (Nat.Partrec.Code.eval_part.comp hs Computable.encode).of_eq (fun a => by + cases he : b a <;> simp [hcf,hcg]) + +theorem partrec_fixed_point {α : Type*} [Primcodable α] + {f : Nat.Partrec.Code → α →. ℕ} (hf : Partrec₂ f) : + ∃ c : Nat.Partrec.Code, ∀ a, c.eval (Encodable.encode a) = f c a := by + have hh : Partrec₂ (fun c n => (Encodable.decode (α := α) n : Part α).bind (f c)) := + (Computable.ofOption (Computable.decode.comp snd)).bind + (hf.comp (fst.comp fst) snd) + obtain ⟨c,hc⟩ := Nat.Partrec.Code.fixed_point₂ hh + refine ⟨c,fun a => ?_⟩ + simp [hc, Encodable.encodek] + exact Part.bind_some a (f c) + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/PrefixComputability.lean b/lean/OAI/Computability/DegreeRigidity/Effective/PrefixComputability.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bd2e7515697890d54eb0ec42824a146e09d9c30 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/PrefixComputability.lean @@ -0,0 +1,117 @@ +import OAI.Computability.DegreeRigidity.Computability.OracleCode +import Mathlib.Computability.Primrec.List + +namespace OAI + +namespace TuringRigidity.PrefixComputability +open Encodable + +variable {O : Set (ℕ →. ℕ)} + +theorem total_comp {f g : ℕ → ℕ} + (hf : Nat.RecursiveIn O (fun n => Part.some (f n))) + (hg : Nat.RecursiveIn O (fun n => Part.some (g n))) : + Nat.RecursiveIn O (fun n => Part.some (f (g n))) := by + simpa using Nat.RecursiveIn.comp hf hg + +theorem total_pair {f g : ℕ → ℕ} + (hf : Nat.RecursiveIn O (fun n => Part.some (f n))) + (hg : Nat.RecursiveIn O (fun n => Part.some (g n))) : + Nat.RecursiveIn O (fun n => Part.some (Nat.pair (f n) (g n))) := by + simpa [Seq.seq] using Nat.RecursiveIn.pair hf hg + +theorem total_primrec {f : ℕ → ℕ} (hf : Primrec f) : + Nat.RecursiveIn O (fun n => Part.some (f n)) := + RecursiveIn.iff_nat.mp hf.computableIn + +def oraclePrefix (g : ℕ → ℕ) (m : ℕ) : List ℕ := (List.range m).map g + +def appendEncoded (a b : ℕ) : ℕ := encode ((decode (α := List ℕ) a).getD [] ++ [b]) + +theorem appendEncoded_primrec : Primrec₂ appendEncoded := + Primrec.encode.comp (Primrec.list_append.comp + (Primrec.option_getD_default.comp (Primrec.decode.comp Primrec.fst)) + (Primrec.list_cons.comp Primrec.snd (Primrec.const []))) + +theorem prefix_recursive (g : ℕ → ℕ) : + Nat.RecursiveIn {fun n => Part.some (g n)} (fun m => Part.some (encode (oraclePrefix g m))) := by + have hquery : Nat.RecursiveIn {fun n => Part.some (g n)} (fun n => Part.some (g n)) := + .oracle _ (Set.mem_singleton _) + have hy := (total_primrec (O := {fun n => Part.some (g n)})) (Primrec.fst.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hi := (total_primrec (O := {fun n => Part.some (g n)})) (Primrec.snd.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hs := total_comp ((total_primrec (O := {fun n => Part.some (g n)})) (appendEncoded_primrec.comp + (Primrec.fst.comp Primrec.unpair) (Primrec.snd.comp Primrec.unpair))) + (total_pair hi (total_comp hquery hy)) + have hp := Nat.RecursiveIn.prec ((total_primrec (O := {fun n => Part.some (g n)})) (Primrec.const (encode ([] : List ℕ)))) hs + have hh := Nat.RecursiveIn.comp hp + (total_pair ((total_primrec (O := {fun n => Part.some (g n)})) (Primrec.const 0)) ((total_primrec (O := {fun n => Part.some (g n)})) Primrec.id)) + apply hh.of_eq + intro n + change (Part.some (Nat.pair 0 n)).bind _ = _ + rw [Part.bind_some] + simp only [Nat.unpair_pair] + induction n with + | zero => rfl + | succ n ih => + simp only [ih] + simp [appendEncoded, oraclePrefix, List.range_succ] + +private def flag (e : ℕ) : ℕ := + if ((decode (α := Option ℕ) e).getD none).isSome then 0 else 1 +private def answer (e : ℕ) : ℕ := ((decode (α := Option ℕ) e).getD none).getD 0 + +private theorem flag_primrec : Primrec flag := by + apply (Primrec.cond (Primrec.option_isSome.comp (Primrec.option_getD_default.comp (Primrec.decode (α := Option ℕ)))) + (Primrec.const 0) (Primrec.const 1)).of_eq + intro n + change (cond ((decode (α := Option ℕ) n).getD none).isSome 0 1) = _ + cases hh : ((decode (α := Option ℕ) n).getD none).isSome <;> simp only [flag,hh] <;> rfl +private theorem answer_primrec : Primrec answer := + Primrec.option_getD_default.comp (Primrec.option_getD_default.comp Primrec.decode) + +theorem total_search {E : ℕ → ℕ → Option ℕ} + (hE : Nat.RecursiveIn O (fun z => Part.some (encode (E (Nat.unpair z).1 (Nat.unpair z).2)))) + (f : ℕ → ℕ) (hsound : ∀ n m a, a ∈ E n m → a = f n) + (hcomplete : ∀ n, ∃ m a, a ∈ E n m) : + Nat.RecursiveIn O (fun n => Part.some (f n)) := by + have hflag := total_comp (total_primrec flag_primrec) hE + have hfind := Nat.RecursiveIn.rfind hflag + have hpair := Nat.RecursiveIn.pair (total_primrec Primrec.id) hfind + have hrun := Nat.RecursiveIn.comp (total_primrec answer_primrec) + (Nat.RecursiveIn.comp hE hpair) + apply hrun.of_eq_tot + intro n + have hex : ∃ m, (E n m).isSome = true := by + obtain ⟨m,a,ha⟩ := hcomplete n + exact ⟨m, Option.isSome_iff_exists.mpr ⟨a,ha⟩⟩ + let m := Nat.find hex + have hm := Nat.find_spec hex + obtain ⟨a,ha⟩ := Option.isSome_iff_exists.mp hm + have hval : a = f n := hsound n m a ha + have hmem : m ∈ Nat.rfind (fun k => + (fun v : ℕ => decide (v=0)) <$> Part.some (flag (encode (E n k)))) := by + apply Nat.mem_rfind.mpr + constructor + · simp [flag, m, hm] + · intro k hk + have hk' : (E n k).isSome = false := Bool.eq_false_iff.mpr (Nat.find_min hex hk) + simp [flag, hk'] + apply Part.mem_bind_iff.mpr + refine ⟨encode (E n m), ?_, ?_⟩ + · apply Part.mem_bind_iff.mpr + refine ⟨Nat.pair n m, ?_, ?_⟩ + · simp only [Seq.seq] + apply Part.mem_bind_iff.mpr + refine ⟨Nat.pair n, (Part.mem_map_iff _).mpr ⟨n,Part.mem_some _,rfl⟩, ?_⟩ + exact (Part.mem_map_iff _).mpr ⟨m,by simpa only [Nat.unpair_pair] using hmem,rfl⟩ + · simp + · have hea : E n m = some a := Option.mem_def.mp ha + apply Part.mem_some_iff.mpr + rw [hea] + simpa only [answer, Encodable.encodek, Option.getD_some] using hval.symm + +end TuringRigidity.PrefixComputability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/PrefixSingletonRealization.lean b/lean/OAI/Computability/DegreeRigidity/Effective/PrefixSingletonRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..bfd8d19fc8f81afa6fccce51be6d1e4f78844c9e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/PrefixSingletonRealization.lean @@ -0,0 +1,96 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.CohenPrefixHull +import OAI.Computability.DegreeRigidity.CohenForcing.CohenColumnPrefixGeneric +import OAI.Computability.DegreeRigidity.SetModels.InternalInverseIso + +namespace OAI + + +namespace TuringRigidity.PrefixSingletonRealization +open TransitiveNameModel BoundedSetTheory CountableForcing CohenBorelForcing +open InternalCohen (bitSet wordCode) +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem sparse_realization (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (A : Oracle) (hA : AtomicForcing.GroundGeneric M (InternalCohen.pushFilter (realFilter A))) : + ∃ L : GenericFilter (Conditions SparseCohenRealName.poset), + AtomicForcing.GroundGeneric M L ∧ + genericExtensionSet M SparseCohenRealName.poset L.carrier = RealGeneratedModel.hull M (realCode A) ∧ + ∀ n b, ZFSet.pair (natSet n) (bitSet b) ∈ InternalCollapse.unionGraph L ↔ A n = b := by + let H := InternalCohen.pushFilter (realFilter A) + let L := InternalDenseInclusion.push InternalCohen.conditions SparseCohenRealName.poset + CohenPrefixDensity.conditions_subset H + have hc := InternalCohen.conditions_mem M hM hT + have hs := CohenGroundPoset.conditions_mem M ZFSet.omega hM hT (sourceT_omega_mem M hM hT) + have hL := InternalDenseInclusion.push_ground_generic M _ _ hM hT hc hs + CohenPrefixDensity.conditions_subset CohenPrefixDensity.dense_inclusion H hA + have he := DenseInclusionExtension.extension_eq M _ _ hM hT hc hs + CohenPrefixDensity.conditions_subset CohenPrefixDensity.dense_inclusion H hA + obtain ⟨B,_,hfilter,hbits,_⟩ := SparseCohenRealName.generic_real_value M hM hT L hL + have hBA : B = A := by + funext n + let p := InternalCohen.conditionEquiv (⟨FiniteShuffle.initial A (n+1)⟩ : Condition) + have hp : p ∈ H.carrier := by + change InternalCohen.conditionEquiv.symm p ∈ (realFilter A).carrier + rw [show p = InternalCohen.conditionEquiv ⟨FiniteShuffle.initial A (n+1)⟩ from rfl, + OrderIso.symm_apply_apply] + exact (ShuffleRequirements.realizes_initial A A (n+1)).mpr (fun _ _ => rfl) + let q := InternalDenseInclusion.embed InternalCohen.conditions SparseCohenRealName.poset + CohenPrefixDensity.conditions_subset p + have hq : q ∈ L.carrier := (InternalDenseInclusion.embed_mem_push _ _ _ H p).mpr hp + apply (hfilter q).mp hq n (A n) + rw [InternalDenseInclusion.label_embed, + show label InternalCohen.conditions p = wordCode (FiniteShuffle.initial A (n+1)) from + InternalCohen.label_encodeCondition ⟨FiniteShuffle.initial A (n+1)⟩] + apply (InternalCohen.pair_mem_wordCode _ _ _).mpr + exact ⟨by simp,by simp [FiniteShuffle.initial]⟩ + subst B + exact ⟨L,hL,he.trans (InternalCohen.prefix_extension_eq_hull M hM hT A hA),hbits⟩ + +theorem singleton_realization (M a : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) (A : Oracle) + (hA : AtomicForcing.GroundGeneric M (InternalCohen.pushFilter (realFilter A))) : + ∃ J : GenericFilter (Conditions (CohenColumnRealName.poset {a})), + AtomicForcing.GroundGeneric M J ∧ + genericExtensionSet M (CohenColumnRealName.poset {a}) J.carrier = + RealGeneratedModel.hull M (realCode A) ∧ + (CohenColumnRealName.realName {a} a).val J.carrier = realCode A := by + obtain ⟨L,hL,hLe,hbits⟩ := sparse_realization M hM hT A hA + obtain ⟨e,f,hf,he,hbit⟩ := CohenColumnRealName.singleton_iso_bits M a hM hT ha + have hω := sourceT_omega_mem M hM hT + have hB := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + (singleton_mem M hM hT.pairing ha) hω + have hcB := CohenGroundPoset.conditions_mem M _ hM hT hB + have hcω := CohenGroundPoset.conditions_mem M _ hM hT hω + have hfi := InternalInverseGraph.inverse_mem M _ _ f hM hT hcB hcω hf + have hfie : ∀ condition image, + ZFSet.pair (label SparseCohenRealName.poset condition) + (label (CohenColumnRealName.poset {a}) image) ∈ + InternalInverseGraph.inverse (CohenColumnRealName.poset {a}) SparseCohenRealName.poset f ↔ + image = e.symm condition := by + intro condition image + rw [InternalInverseGraph.pair_inverse] + simp only [label_mem,true_and,he] + constructor + · intro equality + apply e.injective + rw [OrderIso.apply_symm_apply] + exact equality.symm + · intro equality + rw [equality,OrderIso.apply_symm_apply] + let J := AutomorphismName.mapFilter e.symm L + have hJ := InternalOrderIsoTransport.map_ground_generic M _ _ _ hM hT hcω hcB hfi e.symm hfie L hL + have hJe := InternalOrderIsoTransport.extension_eq M _ _ _ hM hT hcω hcB hfi e.symm hfie L hL + refine ⟨J,hJ,hJe.trans hLe,CohenColumnRealName.val_realName {a} a J A ?_⟩ + intro n b + rw [←hbits n b,InternalCollapse.mem_unionGraph,InternalCollapse.mem_unionGraph] + constructor + · rintro ⟨p,hp,hpb⟩ + exact ⟨e p,hp,(hbit p n b).mpr hpb⟩ + · rintro ⟨p,hp,hpb⟩ + exact ⟨e.symm p,by simpa only [J,AutomorphismName.mapFilter,Set.mem_ofPred_eq, + OrderIso.symm_symm,OrderIso.apply_symm_apply] using hp, + (hbit (e.symm p) n b).mp (by simpa only [OrderIso.apply_symm_apply] using hpb)⟩ + +end TuringRigidity.PrefixSingletonRealization + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/PriorityStage.lean b/lean/OAI/Computability/DegreeRigidity/Effective/PriorityStage.lean new file mode 100644 index 0000000000000000000000000000000000000000..454111f5ed0c70dfc775785115d00de5b100c76e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/PriorityStage.lean @@ -0,0 +1,190 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformPair +import OAI.Computability.DegreeRigidity.CohenForcing.EffectiveForcing +import OAI.Computability.DegreeRigidity.Effective.FiniteInjuryLimits +import OAI.Computability.DegreeRigidity.Effective.FiniteInjurySchedule + +namespace OAI + +namespace TuringRigidity.PriorityStage +open Encodable CodingForcing EncodedForcing FiniteInjury +noncomputable section +attribute [local instance] Classical.propDecidable + +def pairProcedure (A : Oracle) : ℕ → ℕ := Classical.choose (UniformPair.pair_exists A) + +theorem pairProcedure_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun v => Part.some (pairProcedure A v)) := + (Classical.choose_spec (UniformPair.pair_exists A)).1 + +def candidate (A : Oracle) (t : ℕ) (p : Condition) : Condition := + atLevel (condition (pairProcedure A (Nat.pair t (code (atLevel p t))))) t + +theorem candidate_extends (A : Oracle) (t : ℕ) (p : Condition) : + Extends (columns A) (atLevel p t) (candidate A t p) := by + have h := ((Classical.choose_spec (UniformPair.pair_exists A)).2 t (code (atLevel p t))).1 + rw [condition_code] at h + exact ⟨h.1,h.2.1,le_rfl,h.2.2.2⟩ + +def Changes (A : Oracle) (t : ℕ) (p : Condition) : Prop := + (candidate A t p).left ≠ p.left ∨ (candidate A t p).right ≠ p.right + +def scan (A : Oracle) (p : Condition) (done : Finset ℕ) (t : ℕ) : ℕ → Option ℕ + | 0 => none + | n+1 => if t ∉ done ∧ Changes A t p then some t else scan A p done (t+1) n + +theorem scan_spec {A : Oracle} {p : Condition} {done : Finset ℕ} {t n i : ℕ} + (h : scan A p done t n = some i) : + t ≤ i ∧ i < t+n ∧ i ∉ done ∧ Changes A i p := by + induction n generalizing t with + | zero => simp [scan] at h + | succ n ih => + simp only [scan] at h + split at h + · rename_i ht + have he := Option.some.inj h + subst i + exact ⟨le_rfl,by omega,ht⟩ + · obtain ⟨hlo,hhi,hd,hc⟩ := ih h + exact ⟨by omega,by omega,hd,hc⟩ + +def openProcedure (A : Oracle) : ℕ → ℕ := + Classical.choose (EffectiveForcing.uniform_open_decision A A (reduces_refl A)) + +theorem open_extends (A : Oracle) (e : ℕ) (p : Condition) : + Extends (columns A) p (condition (openProcedure A (Nat.pair e (code p)))) := by + have h := ((Classical.choose_spec (EffectiveForcing.uniform_open_decision A A (reduces_refl A))).2 e (code p)).1 + simpa only [condition_code,openProcedure] using h + +structure State where + condition : Condition + done : Finset ℕ + seen : Finset ℕ + +def generic (A : Oracle) (p : State) : Condition := + EncodedForcing.condition (openProcedure A (Nat.pair (FiniteInjurySchedule.visit p.seen) (code p.condition))) + +def stageAction (A : Oracle) (s : ℕ) (p : State) : Option ℕ := scan A (generic A p) p.done 0 s + +def stageWord (A : Oracle) (s : ℕ) (p : State) : Condition := + match stageAction A s p with + | none => generic A p + | some t => candidate A t (generic A p) + +def advance (A : Oracle) (s : ℕ) (p : State) : State where + condition := atLevel (append (stageWord A s p) [false]) (s+1) + done := FiniteInjury.update p.done (stageAction A s p) + seen := FiniteInjurySchedule.reset (insert (FiniteInjurySchedule.visit p.seen) p.seen) (stageAction A s p) + +def construction (A : Oracle) : ℕ → State + | 0 => ⟨⟨[],[],rfl,0⟩,∅,∅⟩ + | s+1 => advance A s (construction A s) + +def conditions (A : Oracle) (s : ℕ) := (construction A s).condition + +def proposal (A : Oracle) (s : ℕ) (_ : Finset ℕ) : Option ℕ := + stageAction A s (construction A s) + +theorem action_not_done (A : Oracle) (s : ℕ) (p : State) (t : ℕ) + (h : stageAction A s p = some t) : t ∉ p.done := (scan_spec h).2.2.1 + +theorem accept_action (A : Oracle) (s : ℕ) (p : State) : + FiniteInjury.accept p.done (stageAction A s p) = stageAction A s p := by + cases ha : stageAction A s p with + | none => simp [FiniteInjury.accept] + | some t => simp [FiniteInjury.accept,action_not_done A s p t ha] + +theorem done_eq (A : Oracle) (s : ℕ) : + (construction A s).done = FiniteInjury.state (proposal A) s := by + induction s with + | zero => rfl + | succ s ih => + change FiniteInjury.update (construction A s).done (stageAction A s (construction A s)) = _ + rw [FiniteInjury.state] + rw [← ih] + simp only [proposal,accept_action] + +theorem action_eq (A : Oracle) (s : ℕ) : + FiniteInjury.action (proposal A) s = stageAction A s (construction A s) := by + rw [FiniteInjury.action,← done_eq] + exact accept_action A s _ + +theorem seen_eq (A : Oracle) (s : ℕ) : + (construction A s).seen = FiniteInjurySchedule.seen (proposal A) s := by + induction s with + | zero => rfl + | succ s ih => + change FiniteInjurySchedule.reset _ _ = _ + rw [FiniteInjurySchedule.seen,action_eq,← ih] + +theorem active_eq (A : Oracle) (s : ℕ) : (conditions A s).active = s := by + cases s <;> rfl + +theorem stage_words (A : Oracle) (s : ℕ) (p : State) : + p.condition.left <+: (stageWord A s p).left ∧ p.condition.right <+: (stageWord A s p).right := by + have ho := open_extends A (FiniteInjurySchedule.visit p.seen) p.condition + cases ha : stageAction A s p with + | none => exact ⟨by simpa [stageWord,ha,generic] using ho.1,by simpa [stageWord,ha,generic] using ho.2.1⟩ + | some t => + have hc := candidate_extends A t (generic A p) + exact ⟨by simpa [stageWord,ha] using ho.1.trans hc.1, + by simpa [stageWord,ha] using ho.2.1.trans hc.2.1⟩ + +theorem word_growth (A : Oracle) (s : ℕ) : + (conditions A s).left <+: (conditions A (s+1)).left ∧ + (conditions A s).right <+: (conditions A (s+1)).right := by + have h := stage_words A s (construction A s) + exact ⟨h.1.trans (List.prefix_append _ _),h.2.trans (List.prefix_append _ _)⟩ + +theorem length_bound (A : Oracle) (s : ℕ) : s ≤ (conditions A s).left.length := by + induction s with + | zero => exact Nat.zero_le _ + | succ s ih => + have h := (stage_words A s (construction A s)).1.length_le + change s+1 ≤ ((stageWord A s (construction A s)).left ++ [false]).length + simp only [List.length_append,List.length_singleton] + exact Nat.add_le_add_right (ih.trans h) 1 + +theorem level_step (A : Oracle) (s k : ℕ) (hk : k ≤ s) + (hact : ∀ t, FiniteInjury.action (proposal A) s = some t → k ≤ t) : + Extends (columns A) (atLevel (conditions A s) k) (atLevel (conditions A (s+1)) k) := by + let p := construction A s + have ho := open_extends A (FiniteInjurySchedule.visit p.seen) p.condition + have hg : Extends (columns A) (atLevel p.condition k) (atLevel (generic A p) k) := by + refine ⟨ho.1,ho.2.1,le_rfl,?_⟩ + intro m hm hlen + apply ho.2.2.2 m ⟨hm.1,?_,hm.2.2⟩ hlen + exact hm.2.1.trans_le (by + change k ≤ (conditions A s).active + rw [active_eq] + exact hk) + have hw : Extends (columns A) (atLevel (generic A p) k) (atLevel (stageWord A s p) k) := by + cases ha : stageAction A s p with + | none => simpa [stageWord,ha] using extends_refl (columns A) (atLevel (generic A p) k) + | some t => + have hkt : k ≤ t := hact t (by simpa [action_eq,p] using ha) + have hc := candidate_extends A t (generic A p) + have hc' : Extends (columns A) (atLevel (generic A p) t) (atLevel (candidate A t (generic A p)) t) := hc + simpa [stageWord,ha] using level_mono hc' hkt + have htail : Extends (columns A) (atLevel (stageWord A s p) k) + (atLevel (conditions A (s+1)) k) := append_extends _ _ [false] + exact extends_trans hg (extends_trans hw htail) + +theorem surviving_columns (A : Oracle) (k : ℕ) : ∃ S, ∀ m, + (conditions A S).left.length ≤ m → (Nat.unpair m).1 < k → + columns A (Nat.unpair m).1 (Nat.unpair m).2 = true → + leftLimit (conditions A) m = rightLimit (conditions A) m := + eventual_column_agreement (columns A) (proposal A) (conditions A) + (word_growth A) (length_bound A) (level_step A) k + +theorem surviving_generic_visit (A : Oracle) (t : ℕ) : ∃ s, + FiniteInjurySchedule.visit (construction A s).seen = t ∧ + ∀ u, s ≤ u → ∀ i < t, stageAction A u (construction A u) ≠ some i := by + obtain ⟨s,hs,hh⟩ := FiniteInjurySchedule.surviving_visit (proposal A) t + refine ⟨s,?_,?_⟩ + · simpa [seen_eq,FiniteInjurySchedule.scheduled] using hs + · simpa only [action_eq] using hh + +end +end TuringRigidity.PriorityStage + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/ProgramContinuity.lean b/lean/OAI/Computability/DegreeRigidity/Effective/ProgramContinuity.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee4bb9a875ec2346beae0fd30f14c55fb3489422 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/ProgramContinuity.lean @@ -0,0 +1,62 @@ +import OAI.Computability.DegreeRigidity.Representation.GenericIdentity +import OAI.Computability.DegreeRigidity.Representation.GenericRepresentation + +namespace OAI + +namespace TuringRigidity.GenericIdentity +open Set + +theorem value_continuousOn (p : OracleCode) (P : Oracle) (S : Set Oracle) + (hS : ∀ A ∈ S, Total p P A) : ContinuousOn (value p P) S := by + apply continuousOn_iff_continuous_domRestrict.mpr + apply continuous_pi + intro n + have hO : Continuous (fun A : S => join A.val P) := by + apply continuous_pi + intro i + dsimp only [join] + split + · exact continuous_const + · exact (continuous_apply _).comp continuous_subtype_val + have hf (b : Bool) : IsOpen {A : S | value p P A.val n = b} := by + have he : {A : S | value p P A.val n = b} = + (fun A : S => join A.val P) ⁻¹' + {B | (if b then 1 else 0) ∈ OracleCode.eval (oracleFunction B) p n} := by + ext A + simp only [mem_ofPred_eq,mem_preimage] + rw [(total_iff p P A.val).mp (hS A.val A.property)] + simp only [oracleFunction,Part.mem_some_iff] + cases b <;> cases value p P A.val n <;> simp + rw [he] + exact (OracleCode.halting_set_open p n _).preimage hO + apply continuous_def.mpr + intro U _ + have he : (fun A : S => value p P A.val n) ⁻¹' U = + ⋃ b : Bool, ⋃ (_ : b ∈ U), {A : S | value p P A.val n = b} := by + ext A; simp + change IsOpen ((fun A : S => value p P A.val n) ⁻¹' U) + rw [he] + exact isOpen_iUnion (fun b => isOpen_iUnion (fun _ => hf b)) + +end GenericIdentity + +theorem generic_continuous_of_program (π : Degree ≃o Degree) + (h : GenericProgramRepresentation π) : GenericContinuousRepresentation π := by + obtain ⟨D,hD,P,p,hp⟩ := h + have ht (A : Oracle) (hA : ShuffleRequirements.GenericFor D A) : GenericIdentity.Total p P A := by + obtain ⟨B,hB,_⟩ := hp A hA + exact ⟨B,hB⟩ + refine ⟨D,hD,GenericIdentity.value p P,GenericIdentity.value_continuousOn p P _ ht,?_⟩ + intro A hA + obtain ⟨B,hB,hπ⟩ := hp A hA + change degree (programOutput p (join A P)) = _ + rw [programOutput_eq p _ B hB] + exact hπ + +theorem generic_program_iff_continuous (π : Degree ≃o Degree) : + GenericProgramRepresentation π ↔ GenericContinuousRepresentation π := + ⟨generic_continuous_of_program π,generic_program_of_continuous π⟩ + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/ProgramSelection.lean b/lean/OAI/Computability/DegreeRigidity/Effective/ProgramSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..13abff046c6e5108f46fad668252e612cd559966 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/ProgramSelection.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DegreeRigidity.Effective.ProgramTopology +import OAI.Computability.DegreeRigidity.Computability.Joins +import OAI.Computability.DegreeRigidity.Representation.Category + +namespace OAI + +open Set Filter Topology +namespace TuringRigidity + +noncomputable def leastSuccess {X : Type*} (R : X → ℕ → Prop) + (hex : ∀ x, ∃ n, R x n) (x : X) : ℕ := by + classical + exact Nat.find (hex x) + +theorem leastSuccess_spec {X : Type*} (R : X → ℕ → Prop) (hex : ∀ x, ∃ n, R x n) + (x : X) : R x (leastSuccess R hex x) := by + classical + exact Nat.find_spec (hex x) + +theorem leastSuccess_eq_iff {X : Type*} (R : X → ℕ → Prop) (hex : ∀ x, ∃ n, R x n) + (x : X) (n : ℕ) : leastSuccess R hex x = n ↔ R x n ∧ ∀ k < n, ¬ R x k := by + classical + exact Nat.find_eq_iff (hex x) + +theorem leastSuccess_measurable {X : Type*} [MeasurableSpace X] (R : X → ℕ → Prop) + (hex : ∀ x, ∃ n, R x n) (hR : ∀ n, MeasurableSet {x | R x n}) : + Measurable (leastSuccess R hex) := by + apply measurable_to_countable' + intro n + have heq : (leastSuccess R hex) ⁻¹' {n} = + {x | R x n} ∩ ⋂ k : Fin n, {x | ¬ R x k.val} := by + ext x + constructor + · intro h + have hr := (leastSuccess_eq_iff R hex x n).mp h + exact ⟨hr.1, Set.mem_iInter.mpr (fun k => hr.2 k.val k.isLt)⟩ + · rintro ⟨h,hmin⟩ + exact (leastSuccess_eq_iff R hex x n).mpr ⟨h,fun k hk => Set.mem_iInter.mp hmin ⟨k,hk⟩⟩ + rw [heq] + exact (hR n).inter (MeasurableSet.iInter (fun k : Fin n => (hR k.val).compl)) + +def codeEnumeration (n : ℕ) : OracleCode := + (Encodable.decode (α := OracleCode) n).getD .zero + +theorem codeEnumeration_surjective : Function.Surjective codeEnumeration := by + intro c + refine ⟨Encodable.encode c, ?_⟩ + simp [codeEnumeration] + +theorem join_measurable {X : Type*} [MeasurableSpace X] (A B : X → Oracle) + (hA : Measurable A) (hB : Measurable B) : Measurable (fun x => join (A x) (B x)) := by + apply Measurable.of_eval + intro n + by_cases hn : n.bodd = true + · simpa [join, hn, Function.comp_def] using (measurable_pi_apply (n/2)).comp hB + · simpa [join, hn, Function.comp_def] using (measurable_pi_apply (n/2)).comp hA + +theorem addition_program_selection (F : ℝ → Oracle) (hF : Measurable F) + (hadd : ∀ x y, Reduces (F (x+y)) (join (F x) (F y))) : + ∃ e : ℝ × ℝ → ℕ, Measurable e ∧ ∀ x y, + OracleCode.eval (oracleFunction (join (F x) (F y))) (codeEnumeration (e (x,y))) = + oracleFunction (F (x+y)) := by + let R : (ℝ × ℝ) → ℕ → Prop := fun p n => + OracleCode.eval (oracleFunction (join (F p.1) (F p.2))) (codeEnumeration n) = + oracleFunction (F (p.1+p.2)) + have hR : ∀ n, MeasurableSet {p | R p n} := by + intro n + exact OracleCode.success_measurable (codeEnumeration n) + (fun p : ℝ × ℝ => join (F p.1) (F p.2)) (fun p : ℝ × ℝ => F (p.1+p.2)) + (join_measurable _ _ (hF.comp measurable_fst) (hF.comp measurable_snd)) + (hF.comp ((continuous_fst.add continuous_snd).measurable)) + have hex : ∀ p, ∃ n, R p n := by + intro p + obtain ⟨c,hc⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp (hadd p.1 p.2) + obtain ⟨n,hn⟩ := codeEnumeration_surjective c + refine ⟨n, ?_⟩ + dsimp [R] + rw [hn] + exact hc + exact ⟨leastSuccess R hex, leastSuccess_measurable R hex hR, + fun x y => leastSuccess_spec R hex (x,y)⟩ + +theorem addition_program_continuous_restriction (F : ℝ → Oracle) (hF : Measurable F) + (hadd : ∀ x y, Reduces (F (x+y)) (join (F x) (F y))) : + ∃ (e : ℝ × ℝ → ℕ) (E : Set (ℝ × ℝ)), E ∈ residual (ℝ × ℝ) ∧ + ContinuousOn e E ∧ ∀ x y, + OracleCode.eval (oracleFunction (join (F x) (F y))) (codeEnumeration (e (x,y))) = + oracleFunction (F (x+y)) := by + obtain ⟨e, he, hs⟩ := addition_program_selection F hF hadd + obtain ⟨E,hE,hcont⟩ := measurable_continuousOn_residual e he + exact ⟨e,E,hE,hcont,hs⟩ + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/ProgramTopology.lean b/lean/OAI/Computability/DegreeRigidity/Effective/ProgramTopology.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa1665402cfe1b4589dc4a5ad0a885bb705091bc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/ProgramTopology.lean @@ -0,0 +1,143 @@ +import OAI.Computability.DegreeRigidity.Computability.OracleCode +import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic +import Mathlib.Topology.Instances.Nat + +namespace OAI + +open Set +namespace TuringRigidity + +def OpenFiber {X α : Type*} [TopologicalSpace X] (f : X → Part α) : Prop := + ∀ a, IsOpen {x | a ∈ f x} + +namespace OpenFiber +variable {X : Type*} {α β : Type} [TopologicalSpace X] + +theorem const (p : Part α) : OpenFiber (fun _ : X => p) := by + intro a + by_cases h : a ∈ p <;> simp [h] + +theorem map {f : X → Part α} (hf : OpenFiber f) (g : α → β) : + OpenFiber (fun x => (f x).map g) := by + intro b + have heq : {x | b ∈ (f x).map g} = + ⋃ a : α, {x : X | g a = b} ∩ {x | a ∈ f x} := by + ext x + simp only [mem_ofPred_eq, mem_iUnion, mem_inter_iff, Part.mem_map_iff] + exact ⟨fun ⟨a,ha,hg⟩ => ⟨a,hg,ha⟩, fun ⟨a,hg,ha⟩ => ⟨a,ha,hg⟩⟩ + rw [heq] + apply isOpen_iUnion + intro a + have hg : IsOpen {x : X | g a = b} := by by_cases h : g a = b <;> simp [h] + exact hg.inter (hf a) + +theorem bind {f : X → Part α} {g : X → α → Part β} + (hf : OpenFiber f) (hg : ∀ a, OpenFiber (fun x => g x a)) : + OpenFiber (fun x => (f x).bind (g x)) := by + intro b + have heq : {x | b ∈ (f x).bind (g x)} = + ⋃ a : α, {x | a ∈ f x} ∩ {x | b ∈ g x a} := by + ext x + simp [Part.mem_bind_iff] + rw [heq] + exact isOpen_iUnion (fun a => (hf a).inter (hg a b)) + +theorem seq {f : X → Part (α → β)} {g : X → Part α} + (hf : OpenFiber f) (hg : OpenFiber g) : + OpenFiber (fun x => f x <*> g x) := by + exact hf.bind (fun k => hg.map k) + +theorem some [TopologicalSpace α] [DiscreteTopology α] {f : X → α} (hf : Continuous f) : + OpenFiber (fun x => Part.some (f x)) := by + intro a + simpa [Set.preimage, Part.mem_some_iff, eq_comm] using + (isOpen_discrete ({a} : Set α)).preimage hf + +theorem rfind {p : X → ℕ → Part Bool} (hp : ∀ n, OpenFiber (fun x => p x n)) : + OpenFiber (fun x => Nat.rfind (p x)) := by + intro n + have heq : {x | n ∈ Nat.rfind (p x)} = + {x | true ∈ p x n} ∩ ⋂ k : Fin n, {x | false ∈ p x k.val} := by + ext x + constructor + · intro h + have hr := Nat.mem_rfind.mp h + exact ⟨hr.1, Set.mem_iInter.mpr (fun k => hr.2 k.isLt)⟩ + · rintro ⟨h,hmin⟩ + exact Nat.mem_rfind.mpr ⟨h,fun {k} hk => Set.mem_iInter.mp hmin ⟨k,hk⟩⟩ + rw [heq] + exact (hp n true).inter (isOpen_iInter_of_finite (fun k : Fin n => hp k.val false)) +end OpenFiber + +namespace OracleCode + +theorem eval_openFiber {X : Type*} [TopologicalSpace X] (O : X → ℕ → ℕ) + (hO : ∀ n, Continuous (fun x => O x n)) (c : OracleCode) : + ∀ n, OpenFiber (fun x => eval (fun k => Part.some (O x k)) c n) := by + induction c with + | zero => intro n; exact OpenFiber.const _ + | succ => intro n; exact OpenFiber.const _ + | left => intro n; exact OpenFiber.const _ + | right => intro n; exact OpenFiber.const _ + | query => intro n; exact OpenFiber.some (hO n) + | pair c d hc hd => intro n; exact (OpenFiber.map (hc n) Nat.pair).seq (hd n) + | comp c d hc hd => intro n; exact (hd n).bind (fun k => hc k) + | prec c d hc hd => + intro p + have hrec : ∀ k : ℕ, OpenFiber (fun x => + Nat.rec (eval (fun j => Part.some (O x j)) c (Nat.unpair p).1) + (fun y ih => ih.bind (fun i => + eval (fun j => Part.some (O x j)) d (Nat.pair (Nat.unpair p).1 (Nat.pair y i)))) k) := by + intro k + induction k with + | zero => exact hc _ + | succ k ih => exact ih.bind (fun i => hd _) + exact hrec (Nat.unpair p).2 + | find c hc => + intro n + exact OpenFiber.rfind (fun k => (hc (Nat.pair n k)).map (fun m => decide (m=0))) + +theorem halting_set_open (c : OracleCode) (n m : ℕ) : + IsOpen {A : Oracle | m ∈ eval (oracleFunction A) c n} := by + have hO : ∀ n : ℕ, Continuous (fun A : Oracle => if A n then (1 : ℕ) else 0) := by + intro n + exact (continuous_of_discreteTopology : Continuous (fun b : Bool => if b then (1 : ℕ) else 0)).comp + (continuous_apply n) + exact eval_openFiber _ hO c n m + +theorem eval_eq_oracle_iff (c : OracleCode) (A B : Oracle) : + eval (oracleFunction A) c = oracleFunction B ↔ + ∀ n, (if B n then 1 else 0) ∈ eval (oracleFunction A) c n := by + constructor + · intro h n + rw [h] + exact Part.mem_some _ + · intro h + funext n + exact Part.eq_some_iff.mpr (h n) + +theorem success_measurable {X : Type*} [MeasurableSpace X] + (c : OracleCode) (A B : X → Oracle) (hA : Measurable A) (hB : Measurable B) : + MeasurableSet {x | eval (oracleFunction (A x)) c = oracleFunction (B x)} := by + have hv : ∀ n, Measurable (fun x => if B x n then (1 : ℕ) else 0) := by + intro n + exact (measurable_of_countable (fun b : Bool => if b then (1 : ℕ) else 0)).comp + ((measurable_pi_apply n).comp hB) + have hh (n m : ℕ) : MeasurableSet {x | m ∈ eval (oracleFunction (A x)) c n} := + (halting_set_open c n m).measurableSet.preimage hA + simp_rw [eval_eq_oracle_iff] + rw [Set.ofPred_forall] + apply MeasurableSet.iInter + intro n + have heq : {x | (if B x n then 1 else 0) ∈ eval (oracleFunction (A x)) c n} = + ⋃ m : ℕ, {x | (if B x n then 1 else 0) = m} ∩ + {x | m ∈ eval (oracleFunction (A x)) c n} := by + ext x + simp + rw [heq] + exact MeasurableSet.iUnion (fun m => (measurableSet_eq_fun (hv n) measurable_const).inter (hh n m)) +end OracleCode + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/RecursiveInfiniteSubset.lean b/lean/OAI/Computability/DegreeRigidity/Effective/RecursiveInfiniteSubset.lean new file mode 100644 index 0000000000000000000000000000000000000000..c07926b9b498fee24f488775edca14e5805496d1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/RecursiveInfiniteSubset.lean @@ -0,0 +1,148 @@ +import OAI.Computability.DegreeRigidity.Computability.OracleEnumeration + +namespace OAI + +namespace TuringRigidity.RecursiveInfiniteSubset +open Encodable PrefixComputability + +def Unbounded (E : ℕ → Option ℕ) : Prop := ∀ n, ∃ z m, n ≤ m ∧ m ∈ E z + +private theorem accepted_exists (E : ℕ → Option ℕ) (h : Unbounded E) (n : ℕ) : + ∃ z, E z ≠ none ∧ n ≤ (E z).getD 0 := by + obtain ⟨z, m, hm, hz⟩ := h n + exact ⟨z, by simp [Option.mem_def.mp hz, hm]⟩ + +noncomputable def index (E : ℕ → Option ℕ) (h : Unbounded E) (n : ℕ) : ℕ := + Nat.find (accepted_exists E h n) + +noncomputable def above (E : ℕ → Option ℕ) (h : Unbounded E) (n : ℕ) : ℕ := + (E (index E h n)).getD 0 + +theorem above_spec (E : ℕ → Option ℕ) (h : Unbounded E) (n : ℕ) : + n ≤ above E h n ∧ above E h n ∈ E (index E h n) := by + have hs := Nat.find_spec (accepted_exists E h n) + refine ⟨hs.2, ?_⟩ + change (E (index E h n)).getD 0 ∈ E (index E h n) + cases he : E (index E h n) with + | none => exact False.elim (hs.1 he) + | some a => simp + +private def flag (p : ℕ) : ℕ := + let v := (decode (α := Option ℕ) (Nat.unpair p).2).getD none + if v ≠ none ∧ (Nat.unpair p).1 ≤ v.getD 0 then 0 else 1 + +private theorem flag_primrec : Primrec flag := by + let hv := Primrec.option_getD_default.comp ((Primrec.decode (α := Option ℕ)).comp (Primrec.snd.comp Primrec.unpair)) + exact Primrec.ite (((Primrec.eq.comp hv (Primrec.const none)).not).and + (Primrec.nat_le.comp (Primrec.fst.comp Primrec.unpair) (Primrec.option_getD_default.comp hv))) + (Primrec.const 0) (Primrec.const 1) + +theorem index_recursive {O : Set (ℕ →. ℕ)} (E : ℕ → Option ℕ) (h : Unbounded E) + (hE : Nat.RecursiveIn O (fun z => Part.some (encode (E z)))) : + Nat.RecursiveIn O (fun n => Part.some (index E h n)) := by + have hn := total_primrec (O := O) (Primrec.fst.comp Primrec.unpair) + have hz := total_primrec (O := O) (Primrec.snd.comp Primrec.unpair) + have hf := total_comp (total_primrec flag_primrec) (total_pair hn (total_comp hE hz)) + apply (Nat.RecursiveIn.rfind hf).of_eq_tot + intro n + apply Nat.mem_rfind.mpr + constructor + · have hs := Nat.find_spec (accepted_exists E h n) + simp [flag, index, hs.1, hs.2] + · intro z hz + have hm := Nat.find_min (accepted_exists E h n) hz + simp [flag, hm] + +theorem above_recursive {O : Set (ℕ →. ℕ)} (E : ℕ → Option ℕ) (h : Unbounded E) + (hE : Nat.RecursiveIn O (fun z => Part.some (encode (E z)))) : + Nat.RecursiveIn O (fun n => Part.some (above E h n)) := by + have hv := total_primrec (O := O) (Primrec.option_getD_default.comp + (Primrec.option_getD_default.comp (Primrec.decode (α := Option ℕ)))) + exact (total_comp hv (total_comp hE (index_recursive E h hE))).of_eq + (fun n => by simp [above]) + +noncomputable def growing (E : ℕ → Option ℕ) (h : Unbounded E) : ℕ → ℕ + | 0 => above E h 0 + | n+1 => above E h (growing E h n + 1) + +theorem growing_strictMono (E : ℕ → Option ℕ) (h : Unbounded E) : StrictMono (growing E h) := by + apply strictMono_nat_of_lt_succ + intro n + exact (Nat.lt_succ_self _).trans_le (above_spec E h _).1 + +theorem growing_mem (E : ℕ → Option ℕ) (h : Unbounded E) (n : ℕ) : + ∃ z, growing E h n ∈ E z := by + cases n <;> exact ⟨_, (above_spec E h _).2⟩ + +theorem growing_recursive {O : Set (ℕ →. ℕ)} (E : ℕ → Option ℕ) (h : Unbounded E) + (hE : Nat.RecursiveIn O (fun z => Part.some (encode (E z)))) : + Nat.RecursiveIn O (fun n => Part.some (growing E h n)) := by + have habove := above_recursive E h hE + have hbase := total_comp habove (total_primrec (Primrec.const 0)) + have hstep := total_comp habove (total_primrec + (Primrec.succ.comp (Primrec.snd.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))))) + have hrec := Nat.RecursiveIn.prec hbase hstep + have hr := Nat.RecursiveIn.comp hrec + (total_pair (total_primrec (Primrec.const 0)) (total_primrec Primrec.id)) + apply hr.of_eq + intro n + change (Part.some (Nat.pair 0 n)).bind _ = _ + rw [Part.bind_some] + simp only [Nat.unpair_pair] + induction n with + | zero => rfl + | succ n ih => + simp only [ih] + simp [growing] + +theorem recursive_range (Y : Oracle) (f : ℕ → ℕ) (hf : StrictMono f) + (hrec : Nat.RecursiveIn {oracleFunction Y} (fun n => Part.some (f n))) : + ∃ C : Oracle, Reduces C Y ∧ ∀ m, C m = true ↔ ∃ n, f n = m := by + let E := fun n => some (f n) + have hE : Nat.RecursiveIn {oracleFunction Y} (fun n => Part.some (encode (E n))) := + total_comp (total_primrec (Primrec.encode.comp (Primrec.option_some.comp Primrec.id))) hrec + have hu : Unbounded E := fun n => ⟨n, f n, hf.id_le n, by simp [E]⟩ + let C : Oracle := fun m => decide (above E hu m = m) + refine ⟨C, ?_, ?_⟩ + · apply RecursiveIn.iff_nat.mpr + have heq := total_primrec (O := {oracleFunction Y}) + (Primrec.ite (Primrec.eq.comp (Primrec.fst.comp Primrec.unpair) + (Primrec.snd.comp Primrec.unpair)) (Primrec.const 1) (Primrec.const 0)) + have hh := total_comp heq (total_pair (above_recursive E hu hE) (total_primrec Primrec.id)) + apply hh.of_eq + intro m + by_cases he : above E hu m = m <;> simp [oracleFunction, C, he] + · intro m + change decide (above E hu m = m) = true ↔ _ + rw [decide_eq_true_eq] + constructor + · intro he + exact ⟨index E hu m, he⟩ + · rintro ⟨n, hn⟩ + have hi : index E hu m ≤ n := Nat.find_min' (accepted_exists E hu m) (by simp [E, hn]) + have hs := (above_spec E hu m).1 + have he : above E hu m = f (index E hu m) := by simp [above, E] + rw [he] at hs ⊢ + exact Nat.le_antisymm ((hf.monotone hi).trans (Nat.le_of_eq hn)) hs + +theorem infinite_recursive_subset (Y : Oracle) (E : ℕ → Option ℕ) + (h : Unbounded E) + (hE : Nat.RecursiveIn {oracleFunction Y} (fun z => Part.some (encode (E z)))) : + ∃ C : Oracle, Reduces C Y ∧ {m | C m = true}.Infinite ∧ + ∀ m, C m = true → ∃ z, m ∈ E z := by + obtain ⟨C, hCY, hC⟩ := recursive_range Y (growing E h) (growing_strictMono E h) + (growing_recursive E h hE) + refine ⟨C, hCY, ?_, ?_⟩ + · have heq : {m | C m = true} = Set.range (growing E h) := by + ext m + exact hC m + rw [heq] + exact Set.infinite_range_of_injective (growing_strictMono E h).injective + · intro m hm + obtain ⟨n, rfl⟩ := (hC m).mp hm + exact growing_mem E h n + +end TuringRigidity.RecursiveInfiniteSubset + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/SetCoding.lean b/lean/OAI/Computability/DegreeRigidity/Effective/SetCoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f02b6708e4df5ffbf6b3efd810af8c41808f0b3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/SetCoding.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.Effective.IndependentFamily +import OAI.Computability.DegreeRigidity.SetModels.CountableBound +import OAI.Computability.DegreeRigidity.Effective.AntichainParameters + +namespace OAI + +namespace TuringRigidity.SetCoding +open AntichainParameters IndependentFamily + +structure AntichainCode where + bound : Degree + left : Degree + right : Degree + +def AntichainCode.Holds (p : AntichainCode) (x : Degree) : Prop := + CodedAntichain p.bound p.left p.right x + +theorem exists_antichainCode (S : Set Degree) (hS : S.Countable) + (hAnti : ∀ x ∈ S, ∀ y ∈ S, x ≤ y → x = y) : + ∃ p : AntichainCode, ∀ x, p.Holds x ↔ x ∈ S := by + obtain ⟨b, hb⟩ := CountableBound.countable_bounded S hS + obtain ⟨g₀, g₁, hg⟩ := countable_antichain_parameters S b hS hb hAnti + exact ⟨⟨b, g₀, g₁⟩, hg⟩ + +structure SetCode where + bound : Degree + tags : AntichainCode + decorated : AntichainCode + +def SetCode.Graph (p : SetCode) (x c : Degree) : Prop := + x ≤ p.bound ∧ p.tags.Holds c ∧ p.decorated.Holds (x ⊔ c) + +def SetCode.Holds (p : SetCode) (x : Degree) : Prop := ∃ c, p.Graph x c + +theorem codes_with_tags (S : Set Degree) (hS : S.Countable) (b : Degree) + (hb : ∀ x ∈ S, x ≤ b) (index : S → ℕ) (hindex : Function.Injective index) : + ∃ p : SetCode, p.bound = b ∧ + (∀ x c, p.Graph x c ↔ ∃ a : S, a.val = x ∧ column b (index a) = c) ∧ + ∀ x, p.Holds x ↔ x ∈ S := by + let C : Set Degree := Set.range (fun a : S => column b (index a)) + let A : Set Degree := Set.range (fun a : S => a.val ⊔ column b (index a)) + have : Countable S := hS.to_subtype + have hC : C.Countable := Set.countable_range _ + have hA : A.Countable := Set.countable_range _ + have htag (x y : Degree) (hx : x ≤ b) (hy : y ≤ b) (i j : ℕ) : + x ⊔ column b i ≤ y ⊔ column b j ↔ x ≤ y ∧ i = j := by + simpa using independence b x y hx hy i {j} + have hac : ∀ x ∈ C, ∀ y ∈ C, x ≤ y → x = y := by + rintro x ⟨a, rfl⟩ y ⟨d, rfl⟩ h + have hi := (htag ⊥ ⊥ bot_le bot_le (index a) (index d)).mp (by simpa using h) + exact congrArg (column b) hi.2 + have haa : ∀ x ∈ A, ∀ y ∈ A, x ≤ y → x = y := by + rintro x ⟨a, rfl⟩ y ⟨d, rfl⟩ h + have hi := (htag a.val d.val (hb _ a.property) (hb _ d.property) _ _).mp h + have he := hindex hi.2 + subst d + rfl + obtain ⟨pc, hpc⟩ := exists_antichainCode C hC hac + obtain ⟨pa, hpa⟩ := exists_antichainCode A hA haa + let p : SetCode := ⟨b, pc, pa⟩ + have hgraph : ∀ x c, p.Graph x c ↔ ∃ a : S, a.val = x ∧ column b (index a) = c := by + intro x c + change (x ≤ b ∧ pc.Holds c ∧ pa.Holds (x ⊔ c)) ↔ _ + rw [hpc, hpa] + constructor + · rintro ⟨hx, ⟨a, rfl⟩, ⟨d, he⟩⟩ + have hl := (htag d.val x (hb _ d.property) hx (index d) (index a)).mp he.le + have hr := (htag x d.val hx (hb _ d.property) (index a) (index d)).mp he.ge + have hed := hindex hl.2 + subst d + exact ⟨a, le_antisymm hl.1 hr.1, rfl⟩ + · rintro ⟨a, rfl, rfl⟩ + exact ⟨hb _ a.property, ⟨a, rfl⟩, ⟨a, rfl⟩⟩ + refine ⟨p, rfl, hgraph, ?_⟩ + intro x + constructor + · rintro ⟨c, hc⟩ + obtain ⟨a, rfl, _⟩ := (hgraph x c).mp hc + exact a.property + · intro hx + exact ⟨column b (index ⟨x, hx⟩), (hgraph _ _).mpr ⟨⟨x, hx⟩, rfl, rfl⟩⟩ + +theorem countable_set_coding (S : Set Degree) (hS : S.Countable) : + ∃ p : SetCode, ∀ x, p.Holds x ↔ x ∈ S := by + classical + have : Countable S := hS.to_subtype + let := Encodable.ofCountable S + obtain ⟨b, hb⟩ := CountableBound.countable_bounded S hS + obtain ⟨p, _, _, hp⟩ := codes_with_tags S hS b hb Encodable.encode Encodable.encode_injective + exact ⟨p, hp⟩ + +end TuringRigidity.SetCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/StablePair.lean b/lean/OAI/Computability/DegreeRigidity/Effective/StablePair.lean new file mode 100644 index 0000000000000000000000000000000000000000..2e7c659f8e40ebe9f0a547b2fd93c0bf4e64a2ca --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/StablePair.lean @@ -0,0 +1,194 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformPair +import OAI.Computability.DegreeRigidity.Effective.CodingRequirements + +namespace OAI + +namespace TuringRigidity.StablePair +open Encodable UniformOracle ArithmeticHierarchy OracleJump EncodedForcing EffectiveWitness IndexMatrix +open CodingForcing UniformProgram UniformAgreement UniformPair + +theorem decide_stable_exists (A : Oracle) : ∃ f : ℕ → ℕ, + Nat.RecursiveIn {oracleFunction (jump A)} (fun v => Part.some (f v)) ∧ + ∀ x p, Extends (columns A) (condition p) (condition (f (Nat.pair x p))) ∧ + (Disagreement A x (condition (f (Nat.pair x p))) ∨ (f (Nat.pair x p) = p ∧ NoDisagreement A x (condition p))) := by + obtain ⟨search,hs,hsearch⟩ := sigma1_choice (cert_sigma A) + let out : ℕ → ℕ := fun v => if search v = 0 then (Nat.unpair v).2 else item (search v-1) 0 + have hmap : Primrec (fun v : ℕ => if (Nat.unpair v).2 = 0 then (Nat.unpair (Nat.unpair v).1).2 + else item ((Nat.unpair v).2-1) 0) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + exact Primrec.ite (Primrec.eq.comp r (Primrec.const 0)) (r.comp f) + (item_primrec.comp (Primrec.nat_sub.comp r (Primrec.const 1)) (Primrec.const 0)) + refine ⟨out,?_,fun x p => ?_⟩ + · exact (total_comp (total_primrec hmap) (total_pair (total_primrec Primrec.id) hs)).of_eq + (fun v => by simp only [Nat.unpair_pair]; rfl) + · rcases hsearch (Nat.pair x p) with ⟨hz,hn⟩ | ⟨hp,hc⟩ + · simp only [out,hz,↓reduceIte,Nat.unpair_pair] + refine ⟨extends_refl _ _,Or.inr ⟨trivial,fun q hpq hd => ?_⟩⟩ + obtain ⟨n,a,b,hab,ha,hb⟩ := hd + apply hn + refine ⟨encode [code q,n,a,b],?_⟩ + simpa [Cert,item,word,← show left (code q) = q.left from congrArg Condition.left (condition_code q), + ← show right (code q) = q.right from congrArg Condition.right (condition_code q),condition_code] using + And.intro hpq (And.intro hab (And.intro ha hb)) + · have hz : search (Nat.pair x p) ≠ 0 := by omega + simp only [out,ite_eq_right hz] + simp only [Cert,Nat.unpair_pair] at hc + exact ⟨hc.1,Or.inl ⟨_,_,_,hc.2⟩⟩ + +theorem pair_stable_exists (A : Oracle) : ∃ f : ℕ → ℕ, + Nat.RecursiveIn {oracleFunction (jump A)} (fun v => Part.some (f v)) ∧ + ∀ x p, Extends (columns A) (condition p) (condition (f (Nat.pair x p))) ∧ + (Disagreement A x (condition (f (Nat.pair x p))) ∨ + (NoDisagreement A x (condition p) ∧ f (Nat.pair x p) = next A (Nat.pair x p))) := by + obtain ⟨d,hd,hds⟩ := decide_stable_exists A + let f := fun v => next A (Nat.pair (Nat.unpair v).1 (d v)) + refine ⟨f,?_,fun x p => ?_⟩ + · have hh := total_comp (next_recursive A) (total_pair + (total_primrec (Primrec.fst.comp Primrec.unpair)) hd) + exact hh.of_eq (fun v => rfl) + · obtain ⟨hp,hm⟩ := hds x p + have hq := (next_extends A (Nat.pair x (d (Nat.pair x p)))).1 + simp only [Nat.unpair_pair] at hq + refine ⟨?_,?_⟩ + · simpa only [f,Nat.unpair_pair] using extends_trans hp hq + · rcases hm with hm | ⟨he,hm⟩ + · exact Or.inl (by simpa only [f,Nat.unpair_pair] using disagreement_mono hq hm) + · exact Or.inr ⟨hm,by simp only [f,Nat.unpair_pair,he]⟩ + +theorem next_precise (A : Oracle) (x p : ℕ) + (hn : UniformAgreement.NoDisagreement A x (condition p)) : + Extends (columns A) (condition p) (condition (next A (Nat.pair x p))) ∧ + (condition (next A (Nat.pair x p))).active = (condition p).active ∧ + ((condition (next A (Nat.pair x p)) = condition p ∧ + ((¬ ∃ z, UniformSplit.SplitCert A (Nat.pair (request (Nat.pair x p)) z)) ∨ + (∃ w, UniformSplit.PointCert A (Nat.pair (request (Nat.pair x p)) w) ∧ + CodingLocation (columns A) (condition p) (item w 2)))) ∨ + ∃ i n, (i = 1 ∨ i = 2) ∧ ∀ q, Extends (columns A) (condition (next A (Nat.pair x p))) q → + ∀ a, a ∉ UniformRun.run A (machine (item x 0)) (machine (item x i)) + (if i = 1 then q.left else q.right) n) := by + classical + let v := Nat.pair x p + let raw := UniformSplit.step A (request v) + have hs := UniformSplit.step_spec A (request v) + change UniformSplit.Accept A (Nat.pair (request v) raw) at hs + simp only [UniformSplit.Accept,Nat.unpair_pair] at hs + rcases hs with ⟨ht,hno⟩ | ⟨ht,hpoint⟩ | ⟨ht,hdiv⟩ + · have he : condition (next A v) = condition p := by + simp [next,outcome,update,retag,EffectiveSplitConditions.update,← show raw = UniformSplit.step A (request v) from rfl,ht,v,condition_code] + change Extends _ _ (condition (next A v)) ∧ _ + rw [he] + exact ⟨extends_refl _ _,rfl,Or.inl ⟨rfl,Or.inl hno⟩⟩ + · let w := (Nat.unpair raw).2 + have hp := hpoint + simp only [UniformSplit.PointCert,Nat.unpair_pair,UniformSplit.start,UniformSplit.base, + UniformSplit.program,request,v,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ, + word] at hp + have hpq : left p <+: word (item w 1) := hp.1 + let r := append (condition p) ((word (item w 1)).drop (left p).length) + have hl : r.left = word (item w 1) := by + change left p ++ (word (item w 1)).drop (left p).length = _ + rw [List.prefix_iff_eq_take] at hpq + conv_lhs => lhs; rw [hpq] + exact List.take_append_drop _ _ + by_cases hcoding : IsCoding A (Nat.pair p raw) + · have he : condition (next A v) = condition p := by + simp [next,outcome,update,retag,EffectiveSplitConditions.update, + ← show raw = UniformSplit.step A (request v) from rfl,ht,v,hcoding,condition_code] + change Extends _ _ (condition (next A v)) ∧ _ + rw [he] + exact ⟨extends_refl _ _,rfl,Or.inl ⟨rfl,Or.inr ⟨w,hpoint,by simpa only [IsCoding,Nat.unpair_pair] using hcoding⟩⟩⟩ + · have he : condition (next A v) = r := by + simp [next,outcome,update,retag,EffectiveSplitConditions.update, + ← show raw = UniformSplit.step A (request v) from rfl,ht,v,hcoding,condition_code] + rfl + have hnc : ¬ CodingLocation (columns A) (condition p) (item w 2) := by simpa only [IsCoding,Nat.unpair_pair] using hcoding + have hpr : Extends (columns A) (condition p) r := append_extends _ _ _ + have hd := split_coding_or_divergence (r := r) hn hpr + (item w 2) hp.2.1 (by simpa [hl,item,word,w] using hp.2.2.1) (item w 3).bodd + (item w 0) (item w 4) (item w 5) hp.2.2.2.1 + (by simpa [hl,item,word,w] using hp.2.2.2.2.1) (by simpa [hl,item,word,w] using hp.2.2.2.2.2) + change Extends _ _ (condition (next A v)) ∧ _ + rw [he] + refine ⟨append_extends _ _ _,rfl,Or.inr ⟨2,item w 0,Or.inr rfl,?_⟩⟩ + simpa using hd.resolve_left hnc + · let w := (Nat.unpair raw).2 + have hpq : left p <+: word (item w 1) := by + simpa [UniformSplit.DivCert,UniformSplit.start,request,v,item,word] using hdiv.1 + let r := append (condition p) ((word (item w 1)).drop (left p).length) + have hl : r.left = word (item w 1) := by + change left p ++ (word (item w 1)).drop (left p).length = _ + rw [List.prefix_iff_eq_take] at hpq + conv_lhs => lhs; rw [hpq] + exact List.take_append_drop _ _ + have he : condition (next A v) = r := by + simp [next,outcome,update,retag,EffectiveSplitConditions.update, + ← show raw = UniformSplit.step A (request v) from rfl,ht,v,condition_code] + rfl + change Extends _ _ (condition (next A v)) ∧ _ + rw [he] + refine ⟨append_extends _ _ _,rfl,Or.inr ⟨1,item w 0,Or.inl rfl,?_⟩⟩ + intro q hrq a ha + apply hdiv.2 + refine ⟨encode q.left,a,?_,?_⟩ + · simpa [word,w,hl] using hrq.1 + · simpa [UniformSplit.base,UniformSplit.program,request,v,item,word] using ha + +def Decisive (A : Oracle) (x : ℕ) (p : Condition) : Prop := + Disagreement A x p ∨ ∃ i n, (i = 1 ∨ i = 2) ∧ ∀ q, Extends (columns A) p q → + ∀ a, a ∉ UniformRun.run A (machine (item x 0)) (machine (item x i)) + (if i = 1 then q.left else q.right) n + +noncomputable def procedure (A : Oracle) : ℕ → ℕ := Classical.choose (pair_stable_exists A) + +theorem procedure_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (jump A)} (fun v => Part.some (procedure A v)) := + (Classical.choose_spec (pair_stable_exists A)).1 + +theorem changed_decisive (A : Oracle) (x p : ℕ) + (hchange : (condition (procedure A (Nat.pair x p))).left ≠ (condition p).left ∨ + (condition (procedure A (Nat.pair x p))).right ≠ (condition p).right) : + Decisive A x (condition (procedure A (Nat.pair x p))) := by + obtain ⟨_,hd | ⟨hn,he⟩⟩ := (Classical.choose_spec (pair_stable_exists A)).2 x p + · exact Or.inl hd + · change procedure A (Nat.pair x p) = _ at he + rw [he] at hchange ⊢ + rcases (next_precise A x p hn).2.2 with ⟨hunchanged,_⟩ | hdiv + · rw [hunchanged] at hchange + exact False.elim (hchange.elim (fun h => h rfl) (fun h => h rfl)) + · exact Or.inr hdiv + +theorem decisive_excludes_common {A Y G₀ G₁ Z : Oracle} {x : ℕ} {p : Condition} + (hbase : OracleCode.eval (oracleFunction A) (meaning (machine (item x 0))) = oracleFunction Y) + (h₀ : CommonIdeal.Extends G₀ p.left) (h₁ : CommonIdeal.Extends G₁ p.right) + (he₀ : OracleCode.eval (oracleFunction (join Y G₀)) (meaning (machine (item x 1))) = oracleFunction Z) + (he₁ : OracleCode.eval (oracleFunction (join Y G₁)) (meaning (machine (item x 2))) = oracleFunction Z) + (hd : Decisive A x p) : False := by + have hr (i : ℕ) (s : List Bool) (n : ℕ) : + UniformRun.run A (machine (item x 0)) (machine (item x i)) s n = + CommonIdeal.run Y (meaning (machine (item x i))) s n := by + simp only [UniformRun.run,hbase,CommonIdeal.run] + rcases hd with ⟨n,a,b,hab,ha,hb⟩ | ⟨i,n,hi,hdiv⟩ + · rw [hr] at ha hb + have ha' := CommonIdeal.run_total h₀ n a ha + have hb' := CommonIdeal.run_total h₁ n b hb + rw [he₀] at ha' + rw [he₁] at hb' + exact hab (Part.mem_unique ha' hb') + · rcases hi with rfl | rfl + · obtain ⟨s,hs,hv⟩ := CommonIdeal.run_finite_extension h₀ n (CommonIdeal.bit (Z n)) (by + rw [he₀]; exact Part.mem_some _) + obtain ⟨q,hpq,hq⟩ := CodingForcing.arbitrary_left_extension (columns A) p s hs + have hh := hdiv q hpq (CommonIdeal.bit (Z n)) + simp only [↓reduceIte,hr,hq] at hh + exact hh hv + · obtain ⟨s,hs,hv⟩ := CommonIdeal.run_finite_extension h₁ n (CommonIdeal.bit (Z n)) (by + rw [he₁]; exact Part.mem_some _) + obtain ⟨q,hpq,hq⟩ := CodingRequirements.arbitrary_right_extension (columns A) p s hs + have hh := hdiv q hpq (CommonIdeal.bit (Z n)) + simp only [show (2 : ℕ) ≠ 1 by decide,↓reduceIte,hr,hq] at hh + exact hh hv + +end TuringRigidity.StablePair + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/StageComputability.lean b/lean/OAI/Computability/DegreeRigidity/Effective/StageComputability.lean new file mode 100644 index 0000000000000000000000000000000000000000..5eb136524f6556821e9230b42d549ff6ea271997 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/StageComputability.lean @@ -0,0 +1,176 @@ +import OAI.Computability.DegreeRigidity.Effective.StageScan + +namespace OAI + +namespace TuringRigidity.StageComputability +open Encodable UniformOracle EncodedForcing CodingForcing FiniteInjury StageRecords +noncomputable section +attribute [local instance] Classical.propDecidable + +def state (v : ℕ) : PriorityStage.State := + ⟨condition (Nat.unpair v).1,members (Nat.unpair (Nat.unpair v).2).1,members (Nat.unpair (Nat.unpair v).2).2⟩ + +def generic (A : Oracle) (v : ℕ) : ℕ := PriorityStage.openProcedure A + (Nat.pair (nextVisit (Nat.unpair (Nat.unpair v).2).2) (Nat.unpair v).1) + +theorem open_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun v => Part.some (PriorityStage.openProcedure A v)) := + (Classical.choose_spec (EffectiveForcing.uniform_open_decision A A (reduces_refl A))).1 + +def canonical (p : ℕ) : ℕ := levelCode p (active p) +theorem canonical_eq (p : ℕ) : canonical p = code (condition p) := rfl + +def genericCanonical (A : Oracle) (v : ℕ) : ℕ := PriorityStage.openProcedure A + (Nat.pair (nextVisit (Nat.unpair (Nat.unpair v).2).2) (canonical (Nat.unpair v).1)) + +theorem generic_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun v => Part.some (genericCanonical A v)) := by + have hn := total_comp (nextVisit_recursive (O := {oracleFunction (OracleJump.jump A)})) (total_primrec (r.comp r)) + have hp := total_primrec (O := {oracleFunction (OracleJump.jump A)}) ((levelCode_primrec.comp Primrec.id active_primrec).comp f) + have hh := total_comp (open_recursive A) (total_pair hn hp) + exact hh.of_eq (fun v => rfl) + +@[simp] theorem generic_eq (A : Oracle) (v : ℕ) : + condition (genericCanonical A v) = PriorityStage.generic A (state v) := rfl + +def stageAction (A : Oracle) (s v : ℕ) : ℕ := + scan A (genericCanonical A v) (Nat.unpair (Nat.unpair v).2).1 s + +theorem stageAction_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun z => + Part.some (stageAction A (Nat.unpair z).1 (Nat.unpair z).2)) := by + have hg := total_comp (generic_recursive A) (total_primrec r) + have hh := total_comp (scan_recursive A) (total_pair (total_pair hg (total_primrec (f.comp (r.comp r)))) (total_primrec f)) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +@[simp] theorem stageAction_eq (A : Oracle) (s v : ℕ) : + action (stageAction A s v) = PriorityStage.stageAction A s (state v) := by + rw [stageAction,scan_eq,action_actionCode,generic_eq] + rfl + +def stageWord (A : Oracle) (z : ℕ) : ℕ := + let s := (Nat.unpair z).1 + let v := (Nat.unpair z).2 + let a := stageAction A s v + let g := genericCanonical A v + if a = 0 then g else candidate A (Nat.pair (a-1) g) + +theorem stageWord_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun z => Part.some (stageWord A z)) := by + have ha := stageAction_recursive A + have hg := total_comp (generic_recursive A) (total_primrec r) + have hc := total_comp (candidate_recursive A) (total_pair + (total_comp (total_primrec (Primrec.nat_sub.comp Primrec.id (Primrec.const 1))) ha) hg) + have hpost := Primrec.ite (Primrec.eq.comp f (Primrec.const 0)) (f.comp r) (r.comp r) + have hh := total_comp (total_primrec hpost) (total_pair ha (total_pair hg hc)) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +theorem stageWord_eq (A : Oracle) (s v : ℕ) : + condition (stageWord A (Nat.pair s v)) = PriorityStage.stageWord A s (state v) := by + have he := stageAction_eq A s v + unfold stageWord + simp only [Nat.unpair_pair] + by_cases ha : stageAction A s v = 0 + · have hn : PriorityStage.stageAction A s (state v) = none := by simpa only [StageRecords.action,ite_eq_left ha] using he.symm + simp [ha,PriorityStage.stageWord,hn,generic_eq] + · have hn : PriorityStage.stageAction A s (state v) = some (stageAction A s v-1) := by + simpa only [StageRecords.action,ite_eq_right ha] using he.symm + simp [ha,PriorityStage.stageWord,hn,candidate_eq,generic_eq] + +def grow (p s : ℕ) : ℕ := Nat.pair (encode (left p ++ [false])) + (Nat.pair (encode (right p ++ [false])) (s+1)) + +theorem grow_primrec : Primrec₂ grow := Primrec₂.natPair.comp + (Primrec.encode.comp (Primrec.list_append.comp (left_primrec.comp Primrec.fst) (Primrec.const [false]))) + (Primrec₂.natPair.comp + (Primrec.encode.comp (Primrec.list_append.comp (right_primrec.comp Primrec.fst) (Primrec.const [false]))) + (Primrec.succ.comp Primrec.snd)) + +@[simp] theorem condition_grow (p s : ℕ) : + condition (grow p s) = atLevel (append (condition p) [false]) (s+1) := condition_code (atLevel (append (condition p) [false]) (s+1)) + +def advance (A : Oracle) (z : ℕ) : ℕ := + let s := (Nat.unpair z).1 + let v := (Nat.unpair z).2 + let d := (Nat.unpair (Nat.unpair v).2).1 + let seen := (Nat.unpair (Nat.unpair v).2).2 + let a := stageAction A s v + Nat.pair (grow (stageWord A z) s) + (Nat.pair (doneUpdate d a) (seenReset (seenInsert seen (nextVisit seen)) a)) + +theorem advance_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun z => Part.some (advance A z)) := by + have ha := stageAction_recursive A + have hw := total_comp (total_primrec (grow_primrec.comp f r)) + (total_pair (stageWord_recursive A) (total_primrec f)) + have hd := total_comp (total_primrec (doneUpdate_primrec.comp f r)) + (total_pair (total_primrec (f.comp (r.comp r))) ha) + have hs := total_primrec (O := {oracleFunction (OracleJump.jump A)}) (r.comp (r.comp r)) + have hn := total_comp nextVisit_recursive hs + have hi := total_comp (total_primrec (seenInsert_primrec.comp f r)) (total_pair hs hn) + have hreset := total_comp (total_primrec (seenReset_primrec.comp f r)) (total_pair hi ha) + have hh := total_pair hw (total_pair hd hreset) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +theorem advance_eq (A : Oracle) (s v : ℕ) : + state (advance A (Nat.pair s v)) = PriorityStage.advance A s (state v) := by + unfold state advance + simp only [Nat.unpair_pair,condition_grow,stageWord_eq,members_doneUpdate, + members_seenReset,members_seenInsert,stageAction_eq] + rfl + +def initial : ℕ := Nat.pair (code ⟨[],[],rfl,0⟩) (Nat.pair (encode ([] : List ℕ)) (encode ([] : List ℕ))) + +def construction (A : Oracle) : ℕ → ℕ := + recur (fun _ => initial) (fun v => advance A (Nat.unpair v).2) 0 + +theorem construction_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun s => Part.some (construction A s)) := by + have h := recur_recursive (total_primrec (Primrec.const initial)) + (total_comp (advance_recursive A) (total_primrec r)) + have hh := total_comp h (total_primrec (Primrec₂.natPair.comp (Primrec.const 0) Primrec.id)) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +theorem construction_eq (A : Oracle) (s : ℕ) : + state (construction A s) = PriorityStage.construction A s := by + induction s with + | zero => simp [construction,recur,initial,state,condition_code,members,record,PriorityStage.construction] + | succ s ih => + change state (advance A (Nat.unpair (Nat.pair 0 (Nat.pair s (construction A s)))).2) = _ + rw [Nat.unpair_pair,advance_eq,ih] + rfl + +theorem conditions_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} + (fun s => Part.some (code (PriorityStage.conditions A s))) := by + have h := total_comp (total_primrec ((levelCode_primrec.comp Primrec.id active_primrec).comp f)) + (construction_recursive A) + apply h.of_eq + intro s + change Part.some (code (state (construction A s)).condition) = _ + rw [construction_eq] + rfl + +theorem limits_recursive (A : Oracle) : + Reduces (join (leftLimit (PriorityStage.conditions A)) (rightLimit (PriorityStage.conditions A))) + (OracleJump.jump A) := by + have hs := total_comp (conditions_recursive A) (total_primrec (Primrec.succ.comp Primrec.nat_div2)) + have hbit : Primrec (fun v : ℕ => CommonIdeal.bit + ((bif (Nat.unpair v).2.bodd then right (Nat.unpair v).1 else left (Nat.unpair v).1).getD + (Nat.unpair v).2.div2 false)) := CommonIdeal.bit_primrec.comp + ((Primrec.list_getD false).comp + (Primrec.cond (Primrec.nat_bodd.comp r) (right_primrec.comp f) (left_primrec.comp f)) + (Primrec.nat_div2.comp r)) + have h := total_comp (total_primrec hbit) (total_pair hs (total_primrec Primrec.id)) + apply RecursiveIn.iff_nat.mpr + have hl (p : Condition) : left (code p) = p.left := congrArg Condition.left (condition_code p) + have hr (p : Condition) : right (code p) = p.right := congrArg Condition.right (condition_code p) + exact h.of_eq (fun n => by + simp only [Nat.unpair_pair] + cases hb : n.bodd <;> simp [oracleFunction,join,hb,leftLimit,rightLimit,CommonIdeal.bit, + hl,hr,Nat.div2_val]) + +end +end TuringRigidity.StageComputability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/StageLimits.lean b/lean/OAI/Computability/DegreeRigidity/Effective/StageLimits.lean new file mode 100644 index 0000000000000000000000000000000000000000..3705738d9458b524caaa8f5a25e01a374f6b865b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/StageLimits.lean @@ -0,0 +1,150 @@ +import OAI.Computability.DegreeRigidity.Effective.StageComputability +import OAI.Computability.DegreeRigidity.CohenForcing.CohenCompleteness +import OAI.Computability.DegreeRigidity.Effective.CodingDiagonal +import OAI.Computability.DegreeRigidity.Effective.CodingExtraction + +namespace OAI + +namespace TuringRigidity.StageLimits +open Encodable UniformOracle ArithmeticHierarchy EncodedForcing CodingForcing FiniteInjury +open PriorityStage +noncomputable section +attribute [local instance] Classical.propDecidable + +def G₀ (A : Oracle) : Oracle := leftLimit (conditions A) +def G₁ (A : Oracle) : Oracle := rightLimit (conditions A) + +theorem generic_prefix_next (A : Oracle) (s : ℕ) : + (generic A (construction A s)).left <+: (conditions A (s+1)).left ∧ + (generic A (construction A s)).right <+: (conditions A (s+1)).right := by + have h : (generic A (construction A s)).left <+: (stageWord A s (construction A s)).left ∧ + (generic A (construction A s)).right <+: (stageWord A s (construction A s)).right := by + cases ha : stageAction A s (construction A s) with + | none => simp [stageWord,ha] + | some t => + have hc := candidate_extends A t (generic A (construction A s)) + exact ⟨by simpa [stageWord,ha,atLevel] using hc.1,by simpa [stageWord,ha,atLevel] using hc.2.1⟩ + exact ⟨h.1.trans (List.prefix_append _ _),h.2.trans (List.prefix_append _ _)⟩ + +theorem limits_extend_generic (A : Oracle) (s : ℕ) : + CommonIdeal.Extends (G₀ A) (generic A (construction A s)).left ∧ + CommonIdeal.Extends (G₁ A) (generic A (construction A s)).right := by + have hp := generic_prefix_next A s + constructor + · intro m hm + have hh := (limits_extend (word_growth A) (length_bound A) (s+1) m (hm.trans_le hp.1.length_le)).1 + exact hh.trans (getD_of_prefix hp.1 hm) + · intro m hm + have hn : m < (conditions A (s+1)).left.length := by + rw [(conditions A (s+1)).sameLength] + exact hm.trans_le hp.2.length_le + have hh := (limits_extend (word_growth A) (length_bound A) (s+1) m hn).2 + exact hh.trans (getD_of_prefix hp.2 hm) + +theorem meets_dense (A : Oracle) {P : ℕ → Prop} (hP : Sigma A 1 P) + (hdense : ∀ p : Condition, ∃ q : ℕ, Extends (columns A) p (condition q) ∧ P q) : + ∃ q : ℕ, P q ∧ CommonIdeal.Extends (G₀ A) (condition q).left ∧ + CommonIdeal.Extends (G₁ A) (condition q).right := by + obtain ⟨e,he⟩ := EffectiveCohen.sigma1_enumeration hP + obtain ⟨s,hs,_⟩ := surviving_generic_visit A e + let p := construction A s + let q := openProcedure A (Nat.pair e (code p.condition)) + have hdec := ((Classical.choose_spec (EffectiveForcing.uniform_open_decision A A (reduces_refl A))).2 + e (code p.condition)).2 + change OracleJump.Halts A e q ∨ + (∀ r, Extends (columns A) (condition q) (condition r) → ¬ OracleJump.Halts A e r) at hdec + have hq : P q := by + rcases hdec with h | h + · exact (he q).mpr h + · obtain ⟨r,hr,hR⟩ := hdense (condition q) + exact False.elim (h r hr ((he r).mp hR)) + refine ⟨q,hq,?_⟩ + have hh := limits_extend_generic A s + simpa only [generic,hs,p,q] using hh + +theorem disagreement_recursive (A X : Oracle) (loc : ℕ → ℕ) + (hloc : Nat.RecursiveIn {oracleFunction A} (fun n => Part.some (loc n))) + (hX : Reduces X A) : RecursivePred A (fun v => + loc (Nat.unpair v).2 < (left (Nat.unpair v).1).length ∧ + (left (Nat.unpair v).1).getD (loc (Nat.unpair v).2) false ≠ X (Nat.unpair v).2) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hm := total_comp hloc (total_primrec r) + have hx := total_comp (RecursiveIn.iff_nat.mp hX) (total_primrec r) + have hp : Primrec (fun v : ℕ => + if (Nat.unpair (Nat.unpair v).2).1 < (left (Nat.unpair v).1).length ∧ + CommonIdeal.bit ((left (Nat.unpair v).1).getD (Nat.unpair (Nat.unpair v).2).1 false) ≠ + (Nat.unpair (Nat.unpair v).2).2 then 1 else 0) := + Primrec.ite ((Primrec.nat_lt.comp (f.comp r) (Primrec.list_length.comp (left_primrec.comp f))).and + ((Primrec.eq.comp (CommonIdeal.bit_primrec.comp ((Primrec.list_getD false).comp + (left_primrec.comp f) (f.comp r))) (r.comp r)).not)) (Primrec.const 1) (Primrec.const 0) + have hh := total_comp (total_primrec hp) (total_pair (total_primrec f) (total_pair hm hx)) + have hbits (b c : Bool) : (CommonIdeal.bit b ≠ (if c then 1 else 0)) ↔ b ≠ c := by + cases b <;> cases c <;> decide + exact hh.of_eq (fun v => by + simp only [Nat.unpair_pair,hbits] + by_cases ht : loc (Nat.unpair v).2 < (left (Nat.unpair v).1).length ∧ + (left (Nat.unpair v).1).getD (loc (Nat.unpair v).2) false ≠ X (Nat.unpair v).2 + · simp only [ite_eq_left ht] + · simp only [ite_eq_right ht]) + +theorem reads_not_reduces (A : Oracle) (loc : ℕ → ℕ) + (hloc : Nat.RecursiveIn {oracleFunction A} (fun n => Part.some (loc n))) + (hunbounded : ∀ N, ∃ n, N ≤ loc n) : ¬ Reduces (fun n => G₀ A (loc n)) A := by + intro hX + let X : Oracle := fun n => G₀ A (loc n) + have hP : Sigma A 1 (fun p => ∃ n, loc n < (left p).length ∧ (left p).getD (loc n) false ≠ X n) := by + simpa only [Nat.unpair_pair] using + (Form.raise (n := 0) (s := true) (disagreement_recursive A X loc hloc hX)).ex + have hdense : ∀ p : Condition, ∃ q : ℕ, Extends (columns A) p (condition q) ∧ + ∃ n, loc n < (left q).length ∧ (left q).getD (loc n) false ≠ X n := by + intro p + obtain ⟨n,hn⟩ := hunbounded p.left.length + obtain ⟨q,hpq,hql,hqb⟩ := CodingDiagonal.prescribe (columns A) p (loc n) hn (!(X n)) + refine ⟨code q,by simpa [condition_code] using hpq,n,?_,?_⟩ + · simpa only [show left (code q) = q.left from congrArg Condition.left (condition_code q)] using hql + · rw [show left (code q) = q.left from congrArg Condition.left (condition_code q),hqb] + cases X n <;> decide + obtain ⟨q,⟨n,hn,hne⟩,hl,_⟩ := meets_dense A hP hdense + exact hne (hl (loc n) hn).symm + +theorem common_noncomputable_columns (A : Oracle) + (hA : ∀ k, {a | columns A k a = true}.Infinite) : + ∀ k, ∃ C : Oracle, Reduces C (join (G₀ A) (columns A k)) ∧ + Reduces C (join (G₁ A) (columns A k)) ∧ ¬ Reduces C (columns A k) := by + intro k + obtain ⟨S,hS⟩ := surviving_columns A (k+1) + let cutoff := (conditions A S).left.length + let loc := CodingColumns.location (columns A k) (hA k) k cutoff + have hcol : Reduces (columns A k) A := CodingExtraction.column_projection_reduces A k + have hloc : Nat.RecursiveIn {oracleFunction A} (fun n => Part.some (loc n)) := + (CodingColumns.location_recursive (columns A k) (hA k) k cutoff).subst (fun f hf => by + have he : f = oracleFunction (columns A k) := Set.mem_singleton_iff.mp hf + subst f + exact RecursiveIn.iff_nat.mp hcol) + have hn := reads_not_reduces A loc hloc (fun N => ⟨N,CodingColumns.le_location _ _ _ _ _⟩) + let C := CodingColumns.readColumn (columns A k) (hA k) k cutoff (G₀ A) + have heq : C = CodingColumns.readColumn (columns A k) (hA k) k cutoff (G₁ A) := by + funext n + have hm := CodingColumns.location_mem (columns A k) (hA k) k cutoff n + simp only [CodingColumns.column] at hm + split at hm + next h => + apply hS _ h.1 + · rw [h.2]; omega + · simpa only [h.2] using hm + next h => simp at hm + exact ⟨C,CodingColumns.readColumn_reduces _ _ _ _ _, + heq ▸ CodingColumns.readColumn_reduces _ _ _ _ _,fun h => hn (reduces_trans h hcol)⟩ + +theorem effective_first_clause (A : Oracle) + (hA : ∀ k, {a | columns A k a = true}.Infinite) : + Reduces (join (G₀ A) (G₁ A)) (OracleJump.jump A) ∧ + ∀ k, ∃ C : Oracle, Reduces C (join (G₀ A) (columns A k)) ∧ + Reduces C (join (G₁ A) (columns A k)) ∧ ¬ Reduces C (columns A k) := + ⟨StageComputability.limits_recursive A,common_noncomputable_columns A hA⟩ + +end +end TuringRigidity.StageLimits + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/StageNormalization.lean b/lean/OAI/Computability/DegreeRigidity/Effective/StageNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c00f24c87afa664884f7b6e3d42b4e93d497fb5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/StageNormalization.lean @@ -0,0 +1,83 @@ +import OAI.Computability.DegreeRigidity.Effective.StageLimits + +namespace OAI + +namespace TuringRigidity.StageNormalization +open Encodable UniformOracle EncodedForcing StageRecords + +def normalized (A : Oracle) : Oracle := fun v => + Introreducible.prefixSet (columns A (Nat.unpair v).1) (Nat.unpair v).2 + +@[simp] theorem normalized_column (A : Oracle) (k : ℕ) : + columns (normalized A) k = Introreducible.prefixSet (columns A k) := by + funext n + simp [normalized,columns] + +private def prefixStep (A : Oracle) (v : ℕ) : ℕ := UniformOracle.appendEncoded + (Nat.unpair (Nat.unpair v).2).2 + (CommonIdeal.bit (A (Nat.pair (Nat.unpair v).1 (Nat.unpair (Nat.unpair v).2).1))) + +private theorem prefixStep_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction A} (fun v => Part.some (prefixStep A v)) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hq : Nat.RecursiveIn {oracleFunction A} (oracleFunction A) := .oracle _ (Set.mem_singleton _) + have h := total_comp hq (total_primrec (Primrec₂.natPair.comp f (f.comp r))) + have hh := total_comp (total_primrec (UniformOracle.appendEncoded_primrec.comp f r)) + (total_pair (total_primrec (r.comp r)) h) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +def columnPrefix (A : Oracle) (k n : ℕ) : ℕ := + recur (fun _ => encode ([] : List ℕ)) (prefixStep A) k n + +theorem prefix_eq (A : Oracle) (k n : ℕ) : + columnPrefix A k n = Introreducible.prefixCode (columns A k) n := by + induction n with + | zero => rfl + | succ n ih => + change prefixStep A (Nat.pair k (Nat.pair n (columnPrefix A k n))) = _ + simp only [prefixStep,Nat.unpair_pair,ih,UniformOracle.appendEncoded, + Introreducible.prefixCode,encodek,Option.getD_some, + PrefixComputability.oraclePrefix,List.range_succ,List.map_append,List.map_cons,List.map_nil] + rfl + +theorem prefix_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction A} (fun v => Part.some (columnPrefix A (Nat.unpair v).1 (Nat.unpair v).2)) := + recur_recursive (total_primrec (Primrec.const (encode ([] : List ℕ)))) (prefixStep_recursive A) + +theorem normalized_reduces (A : Oracle) : Reduces (normalized A) A := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hp := total_comp (prefix_recursive A) (total_primrec (Primrec₂.natPair.comp f + (Introreducible.codeLength_primrec.comp r))) + have he : Primrec (fun v : ℕ => if (Nat.unpair v).1 = (Nat.unpair v).2 then 1 else 0) := + Primrec.ite (Primrec.eq.comp f r) (Primrec.const 1) (Primrec.const 0) + have hh := total_comp (total_primrec he) (total_pair hp (total_primrec r)) + apply RecursiveIn.iff_nat.mpr + exact hh.of_eq (fun v => by simp [Nat.unpair_pair,prefix_eq,normalized,Introreducible.prefixSet,oracleFunction]) + +theorem normalized_spec (A : Oracle) (k : ℕ) : + degree (columns (normalized A) k) = degree (columns A k) ∧ + {n | columns (normalized A) k n = true}.Infinite ∧ + ∀ Z : Oracle, (∀ n, Z n = true → columns (normalized A) k n = true) → + {n | Z n = true}.Infinite → Reduces (columns (normalized A) k) Z := by + rw [normalized_column] + exact ⟨Introreducible.prefixSet_degree _,Introreducible.prefixSet_infinite _,fun Z hs hi => + reduces_trans (Introreducible.prefixSet_reduces _) (Introreducible.reduces_of_infinite_subset hs hi)⟩ + +theorem effective_first_clause (A : Oracle) : ∃ G₀ G₁ : Oracle, + Reduces (join G₀ G₁) (OracleJump.jump A) ∧ + ∀ k, ∃ C : Oracle, Reduces C (join G₀ (columns A k)) ∧ + Reduces C (join G₁ (columns A k)) ∧ ¬ Reduces C (columns A k) := by + let B := normalized A + obtain ⟨hbound,hcode⟩ := StageLimits.effective_first_clause B (fun k => (normalized_spec A k).2.1) + refine ⟨StageLimits.G₀ B,StageLimits.G₁ B,?_,fun k => ?_⟩ + · exact reduces_trans hbound (OracleJump.jump_mono (normalized_reduces A)) + · obtain ⟨C,h₀,h₁,hn⟩ := hcode k + obtain ⟨hBA,hAB⟩ := (degree_eq_iff _ _).mp (normalized_spec A k).1 + exact ⟨C,reduces_trans h₀ (join_mono (reduces_refl _) hBA), + reduces_trans h₁ (join_mono (reduces_refl _) hBA),fun h => hn (reduces_trans h hAB)⟩ + +end TuringRigidity.StageNormalization + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/StageRecords.lean b/lean/OAI/Computability/DegreeRigidity/Effective/StageRecords.lean new file mode 100644 index 0000000000000000000000000000000000000000..24f2cb25fdcb6c5b84f081ef9c766deaa35def87 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/StageRecords.lean @@ -0,0 +1,108 @@ +import OAI.Computability.DegreeRigidity.Effective.PriorityStage + +namespace OAI + +namespace TuringRigidity.StageRecords +open Encodable UniformOracle EncodedForcing FiniteInjurySchedule + +def recur (z : ℕ → ℕ) (f : ℕ → ℕ) (a : ℕ) : ℕ → ℕ + | 0 => z a + | n+1 => f (Nat.pair a (Nat.pair n (recur z f a n))) + +theorem recur_recursive {O : Set (ℕ →. ℕ)} {z f : ℕ → ℕ} + (hz : Nat.RecursiveIn O (fun a => Part.some (z a))) + (hf : Nat.RecursiveIn O (fun a => Part.some (f a))) : + Nat.RecursiveIn O (fun v => Part.some (recur z f (Nat.unpair v).1 (Nat.unpair v).2)) := by + apply (Nat.RecursiveIn.prec hz hf).of_eq + intro v + generalize hv : Nat.unpair v = p + obtain ⟨a,n⟩ := p + simp only [Part.bind_eq_bind] + clear hv + induction n with + | zero => rfl + | succ n ih => simp only [ih,Part.bind_some,recur] + +def record (n : ℕ) : List ℕ := (decode n).getD [] +theorem record_primrec : Primrec record := Primrec.option_getD.comp Primrec.decode (Primrec.const []) + +def members (n : ℕ) : Finset ℕ := (record n).toFinset + +theorem mem_primrec : PrimrecRel (fun n i => i ∈ record n) := by + have h := Primrec.nat_lt.comp (Primrec.list_idxOf.comp Primrec.snd (record_primrec.comp Primrec.fst)) + (Primrec.list_length.comp (record_primrec.comp Primrec.fst)) + exact h.of_eq (fun p => List.idxOf_lt_length_iff) + +noncomputable def nextVisit (n : ℕ) : ℕ := visit (members n) + +theorem nextVisit_recursive {O : Set (ℕ →. ℕ)} : + Nat.RecursiveIn O (fun n => Part.some (nextVisit n)) := by + classical + have h : Primrec (fun v : ℕ => if (Nat.unpair v).2 ∈ record (Nat.unpair v).1 then 1 else 0) := + Primrec.ite (mem_primrec.comp (Primrec.fst.comp Primrec.unpair) (Primrec.snd.comp Primrec.unpair)) + (Primrec.const 1) (Primrec.const 0) + apply (Nat.RecursiveIn.rfind (total_primrec h)).of_eq_tot + intro n + apply Nat.mem_rfind.mpr + constructor + · have hn : nextVisit n ∉ record n := by simpa [members,nextVisit] using visit_missing (members n) + simp [hn] + · intro i hi + have hi' : i ∈ record n := by simpa [members] using before_visit (members n) hi + simp [hi'] + +def doneUpdate (n a : ℕ) : ℕ := + if a = 0 then n else encode ((a-1) :: (record n).filter (fun i => i < a-1)) + +def seenInsert (n t : ℕ) : ℕ := encode (t :: record n) +def seenReset (n a : ℕ) : ℕ := + if a = 0 then n else encode ((record n).filter (fun i => i < a)) + +def action (n : ℕ) : Option ℕ := if n = 0 then none else some (n-1) +def actionCode : Option ℕ → ℕ | none => 0 | some n => n+1 + +@[simp] theorem action_actionCode (a : Option ℕ) : action (actionCode a) = a := by + cases a <;> simp [action,actionCode] + +theorem filter_primrec : Primrec (fun p : ℕ × ℕ => (record p.1).filter (fun i => i < p.2)) := by + have h := Primrec.listFilterMap (record_primrec.comp Primrec.fst) + (Primrec.ite (Primrec.nat_lt.comp Primrec.snd (Primrec.snd.comp Primrec.fst)) + (Primrec.option_some.comp Primrec.snd) (Primrec.const none)).to₂ + exact h.of_eq (fun p => by + induction record p.1 with + | nil => rfl + | cons i l ih => by_cases hi : i < p.2 <;> simp [hi,ih]) + +theorem doneUpdate_primrec : Primrec₂ doneUpdate := by + have ht : Primrec (fun p : ℕ × ℕ => p.2-1) := Primrec.nat_sub.comp Primrec.snd (Primrec.const 1) + exact Primrec.ite (Primrec.eq.comp Primrec.snd (Primrec.const 0)) Primrec.fst + (Primrec.encode.comp (Primrec.list_cons.comp ht (filter_primrec.comp (Primrec.fst.pair ht)))) + +theorem seenInsert_primrec : Primrec₂ seenInsert := Primrec.encode.comp + (Primrec.list_cons.comp Primrec.snd (record_primrec.comp Primrec.fst)) + +theorem seenReset_primrec : Primrec₂ seenReset := Primrec.ite + (Primrec.eq.comp Primrec.snd (Primrec.const 0)) Primrec.fst (Primrec.encode.comp filter_primrec) + +@[simp] theorem members_seenInsert (n t : ℕ) : members (seenInsert n t) = insert t (members n) := by + simp [members,seenInsert,record] + +theorem members_doneUpdate (n a : ℕ) : members (doneUpdate n a) = FiniteInjury.update (members n) (action a) := by + by_cases ha : a = 0 + · simp [doneUpdate,ha,action,FiniteInjury.update] + · ext i + simp [doneUpdate,ha,action,FiniteInjury.update,members,record] + +theorem members_seenReset (n a : ℕ) : members (seenReset n a) = reset (members n) (action a) := by + by_cases ha : a = 0 + · simp [seenReset,ha,action,reset] + · ext i + simp only [seenReset,ite_eq_right ha,action,reset,members,record,encodek,Option.getD_some, + List.mem_toFinset,List.mem_filter,decide_eq_true_eq,Finset.mem_filter] + constructor + · rintro ⟨hm,hi⟩; exact ⟨hm,by omega⟩ + · rintro ⟨hm,hi⟩; exact ⟨hm,by omega⟩ + +end TuringRigidity.StageRecords + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/StageScan.lean b/lean/OAI/Computability/DegreeRigidity/Effective/StageScan.lean new file mode 100644 index 0000000000000000000000000000000000000000..d687209908acbb01f59e50fb39ff612902e05eb4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/StageScan.lean @@ -0,0 +1,112 @@ +import OAI.Computability.DegreeRigidity.Effective.StageRecords + +namespace OAI + +namespace TuringRigidity.StageComputability +open Encodable UniformOracle EncodedForcing CodingForcing FiniteInjury StageRecords +noncomputable section +attribute [local instance] Classical.propDecidable + +abbrev f := Primrec.fst.comp Primrec.unpair +abbrev r := Primrec.snd.comp Primrec.unpair + +def levelCode (p t : ℕ) : ℕ := Nat.pair (encode (left p)) (Nat.pair (encode (right p)) t) + +theorem levelCode_primrec : Primrec₂ levelCode := Primrec₂.natPair.comp + (Primrec.encode.comp (left_primrec.comp Primrec.fst)) + (Primrec₂.natPair.comp (Primrec.encode.comp (right_primrec.comp Primrec.fst)) Primrec.snd) + +theorem levelCode_eq (p t : ℕ) : levelCode p t = code (atLevel (condition p) t) := rfl + +@[simp] theorem condition_levelCode (p t : ℕ) : condition (levelCode p t) = atLevel (condition p) t := + condition_code (atLevel (condition p) t) + +def candidate (A : Oracle) (v : ℕ) : ℕ := + levelCode (PriorityStage.pairProcedure A (Nat.pair (Nat.unpair v).1 + (levelCode (Nat.unpair v).2 (Nat.unpair v).1))) (Nat.unpair v).1 + +theorem candidate_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun v => Part.some (candidate A v)) := by + have h := total_comp (PriorityStage.pairProcedure_recursive A) + (total_primrec (Primrec₂.natPair.comp f (levelCode_primrec.comp r f))) + have hh := total_comp (total_primrec (levelCode_primrec.comp f r)) (total_pair h (total_primrec f)) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +@[simp] theorem candidate_eq (A : Oracle) (t p : ℕ) : + condition (candidate A (Nat.pair t p)) = PriorityStage.candidate A t (condition p) := by + simp only [candidate,Nat.unpair_pair,levelCode_eq,PriorityStage.candidate,condition_code] + +def scanStep (A : Oracle) (v : ℕ) : ℕ := + let p := (Nat.unpair (Nat.unpair v).1).1 + let d := (Nat.unpair (Nat.unpair v).1).2 + let t := (Nat.unpair (Nat.unpair v).2).1 + let prev := (Nat.unpair (Nat.unpair v).2).2 + let c := candidate A (Nat.pair t p) + if prev = 0 ∧ t ∉ record d ∧ (left c ≠ left p ∨ right c ≠ right p) then t+1 else prev + +theorem scanStep_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun v => Part.some (scanStep A v)) := by + have hc := total_comp (candidate_recursive A) + (total_primrec (Primrec₂.natPair.comp (f.comp r) (f.comp f))) + let v := f + let c := r + let p := f.comp (f.comp v) + let d := r.comp (f.comp v) + let t := f.comp (r.comp v) + let prev := r.comp (r.comp v) + have hm := (mem_primrec.comp d t).not + have hl := (Primrec.eq.comp (left_primrec.comp c) (left_primrec.comp p)).not + have hr := (Primrec.eq.comp (right_primrec.comp c) (right_primrec.comp p)).not + have hpost := Primrec.ite ((Primrec.eq.comp prev (Primrec.const 0)).and (hm.and (hl.or hr))) + (Primrec.succ.comp t) prev + have hh := total_comp (total_primrec hpost) (total_pair (total_primrec Primrec.id) hc) + exact hh.of_eq (fun v => by simp only [Nat.unpair_pair]; rfl) + +def scan (A : Oracle) (p d n : ℕ) : ℕ := recur (fun _ => 0) (scanStep A) (Nat.pair p d) n + +theorem scan_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (OracleJump.jump A)} (fun v => + Part.some (scan A (Nat.unpair (Nat.unpair v).1).1 (Nat.unpair (Nat.unpair v).1).2 (Nat.unpair v).2)) := by + simpa only [scan,Nat.pair_unpair] using recur_recursive (total_primrec (Primrec.const 0)) (scanStep_recursive A) + +theorem source_scan_succ (A : Oracle) (p : Condition) (d : Finset ℕ) (t n : ℕ) : + PriorityStage.scan A p d t (n+1) = + match PriorityStage.scan A p d t n with + | some i => some i + | none => if t+n ∉ d ∧ PriorityStage.Changes A (t+n) p then some (t+n) else none := by + induction n generalizing t with + | zero => simp [PriorityStage.scan] + | succ n ih => + change (if t ∉ d ∧ PriorityStage.Changes A t p then some t else PriorityStage.scan A p d (t+1) (n+1)) = + match (if t ∉ d ∧ PriorityStage.Changes A t p then some t else PriorityStage.scan A p d (t+1) n) with + | some i => some i + | none => if t+(n+1) ∉ d ∧ PriorityStage.Changes A (t+(n+1)) p then some (t+(n+1)) else none + by_cases ht : t ∉ d ∧ PriorityStage.Changes A t p + · simp only [ite_eq_left ht] + · simpa only [ite_eq_right ht,Nat.add_assoc,Nat.add_comm,Nat.add_left_comm] using ih (t+1) + +theorem scan_eq (A : Oracle) (p d n : ℕ) : + scan A p d n = actionCode (PriorityStage.scan A (condition p) (members d) 0 n) := by + induction n with + | zero => rfl + | succ n ih => + rw [source_scan_succ] + change scanStep A (Nat.pair (Nat.pair p d) (Nat.pair n (scan A p d n))) = _ + simp only [scanStep,Nat.unpair_pair,ih,Nat.zero_add] + have hc : left (candidate A (Nat.pair n p)) ≠ left p ∨ + right (candidate A (Nat.pair n p)) ≠ right p ↔ PriorityStage.Changes A n (condition p) := by + change (condition (candidate A (Nat.pair n p))).left ≠ (condition p).left ∨ + (condition (candidate A (Nat.pair n p))).right ≠ (condition p).right ↔ _ + rw [candidate_eq] + rfl + cases he : PriorityStage.scan A (condition p) (members d) 0 n with + | none => + by_cases hn : n ∉ record d ∧ PriorityStage.Changes A n (condition p) + · simp_all only [actionCode,members,List.mem_toFinset,true_and]; simp + · simp_all only [actionCode,members,List.mem_toFinset,true_and]; simp + | some i => simp [actionCode] + +end +end TuringRigidity.StageComputability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/TableIndices.lean b/lean/OAI/Computability/DegreeRigidity/Effective/TableIndices.lean new file mode 100644 index 0000000000000000000000000000000000000000..7163589455e944cabf7e2274cb9cb6b47e641bb1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/TableIndices.lean @@ -0,0 +1,90 @@ +import OAI.Computability.DegreeRigidity.Representation.CommonIdealSearch + +namespace OAI + +namespace TuringRigidity.TableIndices +open Encodable UniformOracle CommonIdeal + +def run (Y : Oracle) (d : Nat.Partrec.Code) (n z : ℕ) : Option ℕ := + trial (fun k => bit (Y k)) d n z + +def Represents (Y : Oracle) (d : Nat.Partrec.Code) (A : Oracle) : Prop := + (∀ n z a, a ∈ run Y d n z → a = bit (A n)) ∧ + ∀ n, ∃ z a, a ∈ run Y d n z + +def Valid (Y : Oracle) (d : Nat.Partrec.Code) : Prop := + (∀ n, ∃ z b, run Y d n z = some (bit b)) ∧ + ∀ n z w a b, a ∈ run Y d n z → b ∈ run Y d n w → a = b + +theorem represents_reduces {Y A : Oracle} {d : Nat.Partrec.Code} (h : Represents Y d A) : + Reduces A Y := by + apply RecursiveIn.iff_nat.mpr + exact total_search (trial_recursive (fun k => bit (Y k)) d) (fun n => bit (A n)) h.1 h.2 + +theorem reduces_represents {Y A : Oracle} (h : Reduces A Y) : + ∃ d : Nat.Partrec.Code, Represents Y d A := by + obtain ⟨e, he⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h + have hf : Partrec₂ (fun L : List ℕ => fun n => OracleCode.eval (BranchMachine.lookup L) e n) := + OracleCode.eval_partrec BranchMachine.lookup_partrec e + obtain ⟨d, hd⟩ := partrec_code hf + have hd' : ∀ L n, d.eval (Nat.pair (encode L) n) = OracleCode.eval (BranchMachine.lookup L) e n := + fun L n => hd (L, n) + have ha (n : ℕ) : Approximates (oracleFunction A n) + (fun m => d.eval (Nat.pair (encode (oraclePrefix (fun k => bit (Y k)) m)) n)) := by + simp only [hd'] + rw [← he] + exact OracleCode.eval_approximates (prefix_approximates (fun k => bit (Y k))) e n + refine ⟨d, ?_, ?_⟩ + · intro n z a hz + exact Part.mem_some_iff.mp ((ha n).1 (Nat.unpair z).1 a (Nat.Partrec.Code.evaln_sound hz)) + · intro n + obtain ⟨m, hm⟩ := (ha n).2 (bit (A n)) (Part.mem_some _) + obtain ⟨t, ht⟩ := Nat.Partrec.Code.evaln_complete.mp (hm m le_rfl) + exact ⟨Nat.pair m t, bit (A n), by simpa [run, trial] using ht⟩ + +theorem reduces_iff_represents (A Y : Oracle) : + Reduces A Y ↔ ∃ d : Nat.Partrec.Code, Represents Y d A := + ⟨reduces_represents, fun ⟨_, h⟩ => represents_reduces h⟩ + +theorem valid_iff_represents (Y : Oracle) (d : Nat.Partrec.Code) : + Valid Y d ↔ ∃ A : Oracle, Represents Y d A := by + constructor + · rintro ⟨htotal, hconsistent⟩ + choose z A hA using htotal + refine ⟨A, ?_, ?_⟩ + · intro n w a ha + exact hconsistent n w (z n) a (bit (A n)) ha (Option.mem_def.mpr (hA n)) + · intro n + exact ⟨z n, bit (A n), Option.mem_def.mpr (hA n)⟩ + · rintro ⟨A, hs, ht⟩ + refine ⟨?_, ?_⟩ + · intro n + obtain ⟨z, a, ha⟩ := ht n + exact ⟨z, A n, by rw [← hs n z a ha]; exact Option.mem_def.mp ha⟩ + · intro n z w a b ha hb + exact (hs n z a ha).trans (hs n w b hb).symm + +theorem represents_unique {Y A B : Oracle} {d : Nat.Partrec.Code} + (hA : Represents Y d A) (hB : Represents Y d B) : A = B := by + apply oracleFunction_injective + funext n + obtain ⟨z, a, ha⟩ := hA.2 n + have hh := (hA.1 n z a ha).symm.trans (hB.1 n z a ha) + exact congrArg Part.some hh + +noncomputable def output (Y : Oracle) (d : {d : Nat.Partrec.Code // Valid Y d}) : Oracle := + Classical.choose ((valid_iff_represents Y d.val).mp d.property) + +theorem output_represents (Y : Oracle) (d : {d : Nat.Partrec.Code // Valid Y d}) : + Represents Y d.val (output Y d) := + Classical.choose_spec ((valid_iff_represents Y d.val).mp d.property) + +theorem index_surjective (Y : Oracle) (A : Oracle) (hA : Reduces A Y) : + ∃ d : {d : Nat.Partrec.Code // Valid Y d}, output Y d = A := by + obtain ⟨d, hd⟩ := reduces_represents hA + let e : {d : Nat.Partrec.Code // Valid Y d} := ⟨d, (valid_iff_represents Y d).mpr ⟨A, hd⟩⟩ + exact ⟨e, represents_unique (output_represents Y e) hd⟩ + +end TuringRigidity.TableIndices + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/TriplePrefix.lean b/lean/OAI/Computability/DegreeRigidity/Effective/TriplePrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..47238ec930d93b391e0b177daeffeb625d6f38b7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/TriplePrefix.lean @@ -0,0 +1,47 @@ +import OAI.Computability.DegreeRigidity.Representation.GenericSourceTransfer + +namespace OAI + + +namespace TuringRigidity.TriplePrefix +open FiniteShuffle ShuffleRequirements PairGenericSelection + +theorem join_agree {n : ℕ} {A A' B B' : Oracle} + (ha : Agree n A A') (hb : Agree n B B') : Agree n (join A B) (join A' B') := by + intro i hi + simp only [join] + split + · exact hb (i / 2) (by omega) + · exact ha (i / 2) (by omega) + +theorem join_columns (H : Oracle) : join (column false H) (column true H) = H := by + funext i + rcases Nat.mod_two_eq_zero_or_one i with hi | hi + · have he : i = 2 * (i / 2) := by omega + rw [he,join_even] + rfl + · have he : i = 2 * (i / 2) + 1 := by omega + rw [he,join_odd] + rfl + +def prefixes (s : List Bool) : List Bool × List Bool × List Bool := + let H : Oracle := fun i => s.getD i false + (initial (column false H) s.length, + initial (column false (column true H)) s.length, + initial (column true (column true H)) s.length) + +theorem realizes_join {s : List Bool} {Y L R : Oracle} + (hY : Realizes (prefixes s).1 Y) + (hL : Realizes (prefixes s).2.1 L) + (hR : Realizes (prefixes s).2.2 R) : Realizes s (join Y (join L R)) := by + let H : Oracle := fun i => s.getD i false + have hYa : Agree s.length (column false H) Y := (realizes_initial _ _ _).mp hY + have hLa : Agree s.length (column false (column true H)) L := (realizes_initial _ _ _).mp hL + have hRa : Agree s.length (column true (column true H)) R := (realizes_initial _ _ _).mp hR + have h := join_agree hYa (join_agree hLa hRa) + rw [join_columns,join_columns] at h + exact h + +end TuringRigidity.TriplePrefix + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/TupleFormula.lean b/lean/OAI/Computability/DegreeRigidity/Effective/TupleFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..8389c1b01a0734f6a1fbe1af881c6170e4976804 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/TupleFormula.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteTuple + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace FiniteTuple + +def unpack : ℕ → ℕ → ℕ → ℕ → Formula → Formula + | 0,t,_c,z,φ => .conj (.equal t z) φ + | n+1,t,c,z,φ => .existsMem c (.existsMem (c+1) + (.conj (.orderedPair (t+2) 1 0) + (unpack n 0 (c+2) (z+2) (φ.rename (rotate n))))) + +theorem pair_components {c x y : ZFSet.{u}} (hc : Transitive c) + (hp : ZFSet.pair x y ∈ c) : x ∈ c ∧ y ∈ c := by + have hxy : ({x,y} : ZFSet.{u}) ∈ c := + hc _ hp _ (ZFSet.mem_pair.mpr (Or.inr rfl)) + exact ⟨hc _ hxy _ (ZFSet.mem_pair.mpr (Or.inl rfl)), + hc _ hxy _ (ZFSet.mem_pair.mpr (Or.inr rfl))⟩ + +theorem eval_unpack (xs : List ZFSet.{u}) (t c z : ℕ) (φ : Formula) + (e : ℕ → ZFSet.{u}) (ht : e t = code xs) (hc : Transitive (e c)) + (hcode : code xs ∈ e c) (hz : e z = ∅) : + (unpack xs.length t c z φ).Eval e ↔ φ.Eval (prepend xs e) := by + induction xs generalizing t c z φ e with + | nil => + simp only [List.length_nil,unpack,Formula.Eval,ht,hz,code,prepend_nil,true_and] + | cons x xs ih => + have hparts := pair_components hc hcode + simp only [List.length_cons,unpack,Formula.Eval,Formula.eval_orderedPair, + cons_zero,cons_succ,ht] + constructor + · rintro ⟨y,hy,s,hs,hpair,hφ⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hpair + have h := (ih 0 (c+2) (z+2) (φ.rename (rotate xs.length)) + (cons (code xs) (cons x e)) rfl hc hparts.2 hz).mp hφ + rw [Formula.eval_rename,prepend_rotate] at h + exact h + · intro h + refine ⟨x,hparts.1,code xs,hparts.2,rfl,?_⟩ + apply (ih 0 (c+2) (z+2) (φ.rename (rotate xs.length)) + (cons (code xs) (cons x e)) rfl hc hparts.2 hz).mpr + rw [Formula.eval_rename,prepend_rotate] + exact h + +def relativizeBounded (d : ℕ) : Formula → Formula + | .equal i j => .equal i j + | .member i j => .member i j + | .conj φ ψ => .conj (relativizeBounded d φ) (relativizeBounded d ψ) + | .neg φ => .neg (relativizeBounded d φ) + | .existsMem i φ => .existsMem d (.conj (.member 0 (i+1)) (relativizeBounded (d+1) φ)) + +theorem eval_relativizeBounded (φ : Formula) (d : ℕ) (e : ℕ → ZFSet.{u}) : + (relativizeBounded d φ).Eval e ↔ φ.Realize (e d) e := by + induction φ generalizing d e with + | equal => rfl + | member => rfl + | conj φ ψ ihφ ihψ => exact and_congr (ihφ d e) (ihψ d e) + | neg φ ih => exact not_congr (ih d e) + | existsMem i φ ih => + simp only [relativizeBounded,Formula.Eval,Formula.Realize,cons_zero,cons_succ] + apply exists_congr; intro x + apply and_congr_right; intro _ + exact and_congr_right (fun _ => ih (d+1) (cons x e)) + +def relativizeSigma (d : ℕ) : SigmaFormula → Formula + | .bounded φ => relativizeBounded d φ + | .existsSet φ => .existsMem d (relativizeSigma (d+1) φ) + +theorem eval_relativizeSigma (φ : SigmaFormula) (d : ℕ) (e : ℕ → ZFSet.{u}) : + (relativizeSigma d φ).Eval e ↔ φ.Realize (e d) e := by + induction φ generalizing d e with + | bounded φ => exact eval_relativizeBounded φ d e + | existsSet φ ih => + simp only [relativizeSigma,Formula.Eval,SigmaFormula.Realize] + apply exists_congr; intro x + exact and_congr_right (fun _ => ih (d+1) (cons x e)) + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/TupleLookupAdequacy.lean b/lean/OAI/Computability/DegreeRigidity/Effective/TupleLookupAdequacy.lean new file mode 100644 index 0000000000000000000000000000000000000000..bcbfe66774cf3432e9a826858b8a3e80db76b7b5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/TupleLookupAdequacy.lean @@ -0,0 +1,119 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformSentenceSupport +import OAI.Computability.DegreeRigidity.Effective.TuplePrefixSyntax + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +variable {M : ZFSet.{u}} + +theorem internal_tuple_graph_bound (C : Context M) {A : ZFSet.{u}} (hA : A ∈ M) : + ∃ G ∈ M, ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), + (∀ i, v i ∈ A) → tupleGraph v ∈ G := by + obtain ⟨G,hG,hdef⟩ := internal_power M C.transitive C.power (C.prod_mem C.omega_mem hA) + refine ⟨G,hG,fun n v hv => (hdef _).mpr ⟨?_,?_⟩⟩ + · exact tupleGraph_mem M C.transitive C.pairing C.union C.omega_mem v + (fun i => C.transitive A hA _ (hv i)) + · intro z hz + obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hz + exact ZFSet.mem_prod.mpr ⟨_,(mem_omega _).mpr ⟨i.val,rfl⟩,_,hv i,rfl⟩ + +def TupleLookup (G t i x : ZFSet.{u}) : Prop := + ∃ n ∈ ZFSet.omega, ∃ g ∈ G, t = ZFSet.pair n g ∧ ZFSet.pair i x ∈ g + +theorem tupleLookup_definable (C : Context M) {G : ZFSet.{u}} (hG : G ∈ M) (t i x : ℕ) : + Definable M (fun e => TupleLookup G (e t) (e i) (e x)) := + (((defOrderedPair C (t+2) 1 0).and (defPairMem C (i+2) (x+2) 0)).existsParam hG).existsParam C.omega_mem + +theorem tupleLookup_spec (G : ZFSet.{u}) {n : ℕ} (v : Fin n → ZFSet.{u}) + (hG : tupleGraph v ∈ G) (i x : ZFSet.{u}) : + TupleLookup G (tupleCode v) i x ↔ ∃ k : Fin n, i = natSet k.val ∧ x = v k := by + constructor + · rintro ⟨m,_,g,_,he,hx⟩ + have hg : g = tupleGraph v := (ZFSet.pair_inj.mp he).2.symm + rw [hg] at hx + obtain ⟨k,hk⟩ := ZFSet.mem_range.mp hx + obtain ⟨hi,hx⟩ := ZFSet.pair_inj.mp hk + exact ⟨k,hi.symm,hx.symm⟩ + · rintro ⟨k,rfl,rfl⟩ + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,tupleGraph v,hG,rfl, + (tupleGraph_pair v k _).mpr rfl⟩ + +theorem tupleLookup_nat (G : ZFSet.{u}) {n : ℕ} (v : Fin n → ZFSet.{u}) + (hG : tupleGraph v ∈ G) (i : ℕ) (x : ZFSet.{u}) : + TupleLookup G (tupleCode v) (natSet i) x ↔ i < n ∧ x = tupleEnv v i := by + rw [tupleLookup_spec G v hG] + constructor + · rintro ⟨k,hi,rfl⟩ + have he := natSet_injective hi + subst i + exact ⟨k.isLt,by simp [tupleEnv]⟩ + · rintro ⟨hi,hx⟩ + exact ⟨⟨i,hi⟩,rfl,by simpa [tupleEnv,hi] using hx⟩ + +def TupleAdequate (Q B G c t : ZFSet.{u}) : Prop := + ∃ n ∈ ZFSet.omega, ∃ g ∈ G, ∃ b ∈ ZFSet.omega, + t = ZFSet.pair n g ∧ BoundWitness Q B c b ∧ b ⊆ n + +theorem tupleAdequate_definable (C : Context M) {Q B G : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (hG : G ∈ M) (c t : ℕ) : + Definable M (fun e => TupleAdequate Q B G (e c) (e t)) := + ((((defOrderedPair C (t+3) 2 1).and ((boundWitness_definable C hQ hB (c+3) 0).and + (defSubset C 0 2))).existsParam C.omega_mem).existsParam hG).existsParam C.omega_mem + +theorem tupleAdequate_spec (Q B G : ZFSet.{u}) + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) (p : SentenceForm) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hG : tupleGraph v ∈ G) : + TupleAdequate Q B G (natSet (Encodable.encode p)) (tupleCode v) ↔ p.bound ≤ n := by + constructor + · rintro ⟨m,_,g,_,b,_,he,hb,hle⟩ + have hm : m = natSet n := (ZFSet.pair_inj.mp he).1.symm + obtain ⟨q,hq,rfl⟩ := (boundWitness_spec Q B _ b hQ hB).mp hb + have hpq : p = q := Encodable.encode_injective (natSet_injective hq) + subst q + rw [hm] at hle + exact (natSet_subset_iff p.bound n).mp hle + · intro hb + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,tupleGraph v,hG, + natSet p.bound,(mem_omega _).mpr ⟨p.bound,rfl⟩,rfl, + (boundWitness_spec Q B _ _ hQ hB).mpr ⟨p,rfl,rfl⟩, + (natSet_subset_iff p.bound n).mpr hb⟩ + +def TuplePrefix (A G t x s : ZFSet.{u}) : Prop := + (tuplePrefixFormula 0 1 2 3 4 5 6).Eval + (cons A (cons ZFSet.omega (cons G (cons t (cons x (cons s (fun _ => natSet 0))))))) + +theorem tuplePrefix_spec (A G : ZFSet.{u}) + (hG : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → tupleGraph v ∈ G) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) (x s : ZFSet.{u}) (hx : x ∈ A) : + TuplePrefix A G (tupleCode v) x s ↔ s = tupleCode (Fin.cases x v) := + tuplePrefixFormula_spec 0 1 2 3 4 5 6 _ rfl rfl hG v hv rfl hx + +theorem tuplePrefix_definable (C : Context M) {G : ZFSet.{u}} (hG : G ∈ M) (a t x s : ℕ) : + Definable M (fun e => TuplePrefix (e a) G (e t) (e x) (e s)) := by + let d := cons ZFSet.omega (cons G (fun _ => natSet 0)) + let r : ℕ → ℕ := fun i => match i with + | 0 => 2*a | 1 => 1 | 2 => 3 | 3 => 2*t | 4 => 2*x | 5 => 2*s | _ => 5 + refine ⟨(tuplePrefixFormula 0 1 2 3 4 5 6).rename r,d,?_,?_⟩ + · intro i + rcases i with _|_|i + · exact C.omega_mem + · exact hG + · exact C.transitive _ C.omega_mem _ ((mem_omega _).mpr ⟨0,rfl⟩) + · intro e + rw [Formula.eval_rename_comp] + have he : mix e d ∘ r = cons (e a) (cons ZFSet.omega (cons G + (cons (e t) (cons (e x) (cons (e s) (fun _ => natSet 0)))))) := by + funext i + rcases i with _|_|_|_|_|_|i <;> simp only [r,d,Function.comp_apply,mix_even,cons_zero,cons_succ] <;> rfl + rw [he] + rfl + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/TuplePrefixSyntax.lean b/lean/OAI/Computability/DegreeRigidity/Effective/TuplePrefixSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..642a89cf34a9be538eeb99ab291b06debd2e00f5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/TuplePrefixSyntax.lean @@ -0,0 +1,102 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleTupleSpace + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +def PrefixGraphs (A n g m h x : ZFSet.{u}) : Prop := + m = insert n n ∧ FunctionGraph m A h ∧ ZFSet.pair (natSet 0) x ∈ h ∧ + ∀ i ∈ n, ∃ j ∈ m, j = insert i i ∧ + ∀ y ∈ A, ZFSet.pair i y ∈ g → ZFSet.pair j y ∈ h + +theorem prefixGraphs_spec (A g m h x : ZFSet.{u}) {n : ℕ} + (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) (hx : x ∈ A) + (hg : g = tupleGraph v) : + PrefixGraphs A (natSet n) g m h x ↔ + m = natSet (n+1) ∧ h = tupleGraph (Fin.cases (motive := fun _ => ZFSet.{u}) x v) := by + subst g + constructor + · rintro ⟨rfl,hh,hzero,hshift⟩ + have hn : insert (natSet.{u} n) (natSet n) = natSet (n+1) := rfl + rw [hn] at hh + obtain ⟨w,hw,rfl⟩ := functionGraph_tuple A h (n+1) hh + have hwv : w = Fin.cases (motive := fun _ => ZFSet.{u}) x v := by + funext i + refine Fin.cases ?_ (fun k => ?_) i + · exact ((tupleGraph_pair w 0 x).mp hzero).symm + · obtain ⟨j,_,hj,ht⟩ := hshift (natSet k.val) ((natSet_mem_natSet _ _).mpr k.isLt) + have hpair := ht (v k) (hv k) ((tupleGraph_pair v k _).mpr rfl) + rw [hj] at hpair + exact ((tupleGraph_pair w k.succ (v k)).mp hpair).symm + rw [hwv] + exact ⟨rfl,rfl⟩ + · rintro ⟨hm,hh⟩ + rw [hm,hh] + unfold PrefixGraphs + refine ⟨rfl,?_,?_,?_⟩ + · apply tupleGraph_function + intro i + exact Fin.cases hx hv i + · change ZFSet.pair (natSet 0) x ∈ ZFSet.range + (fun i : Fin (n+1) => ZFSet.pair (natSet i.val) ((Fin.cases (motive := fun _ => ZFSet.{u}) x v : Fin (n+1) → ZFSet.{u}) i)) + exact ZFSet.mem_range_self + (f := fun i : Fin (n+1) => ZFSet.pair (natSet i.val) + (Fin.cases (motive := fun _ => ZFSet.{u}) x v i)) + (⟨0,Nat.zero_lt_succ n⟩ : Fin (n+1)) + · intro i hi + obtain ⟨k,hk,rfl⟩ := (mem_natSet n i).mp hi + refine ⟨natSet (k+1),(natSet_mem_natSet _ _).mpr (Nat.succ_lt_succ hk),rfl,?_⟩ + intro y _ hy + have he := (tupleGraph_pair v ⟨k,hk⟩ y).mp hy + exact (tupleGraph_pair (Fin.cases (motive := fun _ => ZFSet.{u}) x v) (Fin.succ ⟨k,hk⟩) y).mpr he + +def prefixGraphsFormula (A n g m h x z : ℕ) : Formula := + .conj (.successor m n) (.conj (.functionGraph h m A) + (.conj (.pairMem z x h) + (.allMem n (.existsMem (m+1) (.conj (.successor 0 1) + (.allMem (A+2) (.imp (.pairMem 2 0 (g+3)) (.pairMem 1 0 (h+3))))))))) + +theorem prefixGraphsFormula_spec (A n g m h x z : ℕ) (e : ℕ → ZFSet.{u}) + (hz : e z = natSet 0) : + (prefixGraphsFormula A n g m h x z).Eval e ↔ + PrefixGraphs (e A) (e n) (e g) (e m) (e h) (e x) := by + simp only [prefixGraphsFormula,Formula.Eval,Formula.eval_successor,Formula.eval_functionGraph, + Formula.eval_pairMem,Formula.eval_allMem,Formula.eval_imp,cons_zero,cons_succ,hz,PrefixGraphs,FunctionGraph] + +def tuplePrefixFormula (A o Q t x u z : ℕ) : Formula := + .existsMem o (.existsMem (Q+1) (.existsMem (o+2) (.existsMem (Q+3) + (.conj (.orderedPair (t+4) 3 2) (.conj (.orderedPair (u+4) 1 0) + (prefixGraphsFormula (A+4) 3 2 1 0 (x+4) (z+4))))))) + +theorem tuplePrefixFormula_spec (A o Q t x u z : ℕ) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) (hz : e z = natSet 0) + (hQ : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ e A) → tupleGraph v ∈ e Q) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ e A) + (ht : e t = tupleCode v) (hx : e x ∈ e A) : + (tuplePrefixFormula A o Q t x u z).Eval e ↔ e u = tupleCode (Fin.cases (motive := fun _ => ZFSet.{u}) (e x) v) := by + simp only [tuplePrefixFormula,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ] + simp only [prefixGraphsFormula,Formula.Eval,Formula.eval_successor,Formula.eval_functionGraph, + Formula.eval_pairMem,Formula.eval_allMem,Formula.eval_imp,cons_zero,cons_succ,hz] + change (∃ n' ∈ e o, ∃ g ∈ e Q, ∃ m ∈ e o, ∃ h ∈ e Q, + e t = ZFSet.pair n' g ∧ e u = ZFSet.pair m h ∧ PrefixGraphs (e A) n' g m h (e x)) ↔ _ + rw [ho] + constructor + · rintro ⟨n',_,g,_,m,_,h,_,ht',hu,hp⟩ + have he := ZFSet.pair_inj.mp (ht.symm.trans ht') + have hn : n' = natSet n := he.1.symm + have hg : g = tupleGraph v := he.2.symm + rw [hn] at hp + obtain ⟨hm,hh⟩ := (prefixGraphs_spec (e A) g m h (e x) v hv hx hg).mp hp + rw [hu,hm,hh]; rfl + · intro hu + refine ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,tupleGraph v,hQ n v hv, + natSet (n+1),(mem_omega _).mpr ⟨n+1,rfl⟩,tupleGraph (Fin.cases (motive := fun _ => ZFSet.{u}) (e x) v), + hQ (n+1) _ (fun i => Fin.cases hx hv i),ht,hu,?_⟩ + exact (prefixGraphs_spec (e A) _ _ _ _ v hv hx rfl).mpr ⟨rfl,rfl⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/TupleRelation.lean b/lean/OAI/Computability/DegreeRigidity/Effective/TupleRelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2d92695e7030d23fd243d19ead0fc1e3b6aca90 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/TupleRelation.lean @@ -0,0 +1,113 @@ +import OAI.Computability.DegreeRigidity.Effective.TupleFormula +import OAI.Computability.DegreeRigidity.SetModels.InternalContainer + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace FiniteTuple + +def outputFirst (n k : ℕ) : ℕ → ℕ + | 0 => n + | i+1 => if i < n then i else i+k+1 + +theorem prepend_outputFirst (xs junk : List ZFSet.{u}) (y : ZFSet.{u}) + (e : ℕ → ZFSet.{u}) : + (fun i => prepend xs (cons y (prepend junk e)) (outputFirst xs.length junk.length i)) = + cons y (prepend xs e) := by + funext i + cases i with + | zero => exact prepend_tail xs (cons y (prepend junk e)) 0 + | succ i => + change prepend xs (cons y (prepend junk e)) + (if i < xs.length then i else i+junk.length+1) = prepend xs e i + by_cases hi : i < xs.length + · rw [ite_eq_left hi]; exact prepend_congr xs _ _ i hi + · rw [ite_eq_right hi] + obtain ⟨j,rfl⟩ := Nat.exists_eq_add_of_le (Nat.le_of_not_gt hi) + have harith : xs.length+j+junk.length+1 = xs.length+(junk.length+j+1) := by omega + rw [harith,prepend_tail,prepend_tail,cons_succ,prepend_tail] + +noncomputable def relation (d : ZFSet.{u}) (n : ℕ) (φ : Formula) + (e : ℕ → ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ xs : List ZFSet.{u}, xs.length = n ∧ + (∀ x ∈ xs, x ∈ d) ∧ ∃ y ∈ d, z = ZFSet.pair (code xs) y ∧ + φ.Eval (cons y (prepend xs e))) (ZFSet.prod (space d n) d) + +theorem relation_pair (d y : ZFSet.{u}) (xs : List ZFSet.{u}) (φ : Formula) + (e : ℕ → ZFSet.{u}) : ZFSet.pair (code xs) y ∈ relation d xs.length φ e ↔ + (∀ x ∈ xs, x ∈ d) ∧ y ∈ d ∧ φ.Eval (cons y (prepend xs e)) := by + rw [relation,ZFSet.mem_sep] + constructor + · rintro ⟨_,ys,hlen,hys,z,hz,hpair,hφ⟩ + obtain ⟨hcode,rfl⟩ := ZFSet.pair_inj.mp hpair + obtain rfl := code_injective_length xs ys hlen.symm hcode + exact ⟨hys,hz,hφ⟩ + · rintro ⟨hxs,hy,hφ⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨_,code_mem_space d xs hxs,y,hy,rfl⟩, + xs,rfl,hxs,y,hy,rfl,hφ⟩ + +def relationFormula (n : ℕ) (φ : Formula) : Formula := + .existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) + (unpack n 1 5 6 (φ.rename (outputFirst n 6))))) + +theorem eval_relationFormula (d c z : ZFSet.{u}) (n : ℕ) (φ : Formula) + (e : ℕ → ZFSet.{u}) (hc : Transitive c) (hspace : space d n ⊆ c) : + (relationFormula n φ).Eval (cons z (cons (space d n) (cons d (cons c (cons ∅ e))))) ↔ + z ∈ relation d n φ e := by + simp only [relationFormula,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ] + constructor + · rintro ⟨t,ht,y,hy,rfl,hφ⟩ + obtain ⟨xs,rfl,hxs,rfl⟩ := (mem_space d t n).mp ht + apply (relation_pair d y xs φ e).mpr + refine ⟨hxs,hy,?_⟩ + have h := (eval_unpack xs 1 5 6 (φ.rename (outputFirst xs.length 6)) + (cons y (cons (code xs) (cons (ZFSet.pair (code xs) y) + (cons (space d xs.length) (cons d (cons c (cons ∅ e))))))) + rfl hc (hspace ht) rfl).mp hφ + rw [Formula.eval_rename] at h + have he := prepend_outputFirst xs [code xs,ZFSet.pair (code xs) y,space d xs.length,d,c,∅] y e + exact he ▸ h + · intro hz + obtain ⟨_,xs,hlen,hxs,y,hy,rfl,hφ⟩ := ZFSet.mem_sep.mp hz + subst n + have ht := code_mem_space d xs hxs + refine ⟨code xs,ht,y,hy,rfl,?_⟩ + apply (eval_unpack xs 1 5 6 (φ.rename (outputFirst xs.length 6)) + (cons y (cons (code xs) (cons (ZFSet.pair (code xs) y) + (cons (space d xs.length) (cons d (cons c (cons ∅ e))))))) + rfl hc (hspace ht) rfl).mpr + rw [Formula.eval_rename] + have he := prepend_outputFirst xs [code xs,ZFSet.pair (code xs) y,space d xs.length,d,c,∅] y e + exact he.symm ▸ hφ + +theorem relation_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) + {d : ZFSet.{u}} (hd : d ∈ M) (n : ℕ) (φ : Formula) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : relation d n φ e ∈ M := by + have hs := space_mem M hM hP hU hPow hS hd n + obtain ⟨c,hc,hct,hsc⟩ := internal_transitive_container M hM hP hU hS hR hI hs + have h0 : (∅ : ZFSet.{u}) ∈ M := hM _ (omega_mem M hM hS hI) _ ZFSet.omega_zero + let env := cons (space d n) (cons d (cons c (cons ∅ e))) + have henv : ∀ i, env i ∈ M := by + intro i; rcases i with _|i; exact hs + rcases i with _|i; exact hd + rcases i with _|i; exact hc + rcases i with _|i; exact h0 + exact he i + have hsep := sep_mem M hM hS (relationFormula n φ) env henv + (product_mem M hM hP hU hPow hS hs hd) + have heq : ZFSet.sep (fun z => (relationFormula n φ).Eval (cons z env)) + (ZFSet.prod (space d n) d) = relation d n φ e := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,eval_relationFormula d c z n φ e hct (fun x hx => hct _ hsc x hx)] + exact and_iff_right_of_imp (fun hz => (ZFSet.mem_sep.mp hz).1) + exact heq ▸ hsep + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/TupleSystemCertificate.lean b/lean/OAI/Computability/DegreeRigidity/Effective/TupleSystemCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..7160f0bb2db3c07ff2953c342d0b42726d0fede5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/TupleSystemCertificate.lean @@ -0,0 +1,111 @@ +import OAI.Computability.DegreeRigidity.Syntax.VariableTruthSyntax + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +theorem tuplePrefix_sound (A G x s : ZFSet.{u}) {n : ℕ} + (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) (hx : x ∈ A) + (hs : TuplePrefix A G (tupleCode v) x s) : + s = tupleCode (Fin.cases (motive := fun _ => ZFSet.{u}) x v) := by + unfold TuplePrefix at hs + simp only [tuplePrefixFormula,Formula.Eval,Formula.eval_orderedPair, + cons_zero,cons_succ] at hs + simp only [prefixGraphsFormula,Formula.Eval,Formula.eval_successor, + Formula.eval_functionGraph,Formula.eval_pairMem,Formula.eval_allMem, + Formula.eval_imp,cons_zero,cons_succ] at hs + change ∃ n' ∈ ZFSet.omega, ∃ g ∈ G, ∃ m ∈ ZFSet.omega, ∃ h ∈ G, + tupleCode v = ZFSet.pair n' g ∧ s = ZFSet.pair m h ∧ + PrefixGraphs A n' g m h x at hs + obtain ⟨n',_,g,_,m,_,h,_,he,hs,hp⟩ := hs + obtain ⟨hn,hg⟩ := ZFSet.pair_inj.mp he + rw [← hn] at hp + obtain ⟨hm,hh⟩ := (prefixGraphs_spec A g m h x v hv hx hg.symm).mp hp + rw [hs,hm,hh] + rfl + +def TupleSystem (A G T : ZFSet.{u}) : Prop := + (∀ t ∈ T, ∃ n ∈ ZFSet.omega, ∃ g ∈ G, + t = ZFSet.pair n g ∧ FunctionGraph n A g) ∧ + ZFSet.pair (natSet 0) (natSet 0) ∈ T ∧ + ∀ t ∈ T, ∀ x ∈ A, ∃ s ∈ T, TuplePrefix A G t x s + +theorem tupleSystem_definable {M : ZFSet.{u}} (C : Context M) (a G T : ℕ) : + Definable M (fun e => TupleSystem (e a) (e G) (e T)) := by + have hfg (f n a : ℕ) : Definable M (fun e => FunctionGraph (e n) (e a) (e f)) := by + refine ⟨.functionGraph (2*f) (2*n) (2*a),fun _ => ZFSet.omega, + fun _ => C.omega_mem,?_⟩ + intro e + simp only [Formula.eval_functionGraph,mix_even,FunctionGraph] + have hn := defAllMem ((((defOrderedPair C 2 1 0).and + (hfg 0 1 (a+3))).existsMem (G+2)).existsParam C.omega_mem) T + have hz : Definable M (fun e => ZFSet.pair (natSet 0) (natSet 0) ∈ e T) := (((equal_param (C.nat_mem 0) 0).and + (defPairMem C 0 0 (T+1))).existsParam C.omega_mem).congr (fun e => by simp [show natSet.{u} 0 ∈ ZFSet.omega from (mem_omega _).mpr ⟨0,rfl⟩]) + have hc := defAllMem (defAllMem + ((tuplePrefix_variable C (a+3) (G+3) 2 1 0).existsMem (T+2)) (a+1)) T + exact hn.and (hz.and hc) + +theorem TupleSystem.exact {A G T : ZFSet.{u}} (h : TupleSystem A G T) : + T = tupleSpace A ∧ ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), + (∀ i, v i ∈ A) → tupleGraph v ∈ G := by + have hin : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → tupleCode v ∈ T := by + intro n + induction n with + | zero => + intro v _ + have hg : tupleGraph v = (∅ : ZFSet.{u}) := by + apply ZFSet.ext; intro z + simp [tupleGraph] + change ZFSet.pair (natSet 0) (tupleGraph v) ∈ T + rw [hg] + exact h.2.1 + | succ n ih => + intro v hv + let w : Fin n → ZFSet.{u} := fun i => v i.succ + obtain ⟨s,hs,hp⟩ := h.2.2 (tupleCode w) (ih w (fun i => hv i.succ)) (v 0) (hv 0) + have he := tuplePrefix_sound A G (v 0) s w (fun i => hv i.succ) (hv 0) hp + have hvw : (Fin.cases (motive := fun _ => ZFSet.{u}) (v 0) w) = v := by + funext i; exact Fin.cases rfl (fun _ => rfl) i + rwa [he,hvw] at hs + constructor + · apply ZFSet.ext; intro t + constructor + · intro ht + obtain ⟨n,hn,g,_,he,hg⟩ := h.1 t ht + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + obtain ⟨v,hv,rfl⟩ := functionGraph_tuple A g n hg + exact (mem_tupleSpace A t).mpr ⟨n,v,hv,he⟩ + · intro ht + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp ht + exact hin n v hv + · intro n v hv + obtain ⟨m,_,g,hg,he,_⟩ := h.1 (tupleCode v) (hin n v hv) + have he' : tupleGraph v = g := (ZFSet.pair_inj.mp he).2 + rwa [← he'] at hg + +theorem tupleSystem_canonical (A G : ZFSet.{u}) + (hG : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → tupleGraph v ∈ G) : + TupleSystem A G (tupleSpace A) := by + refine ⟨?_,?_,?_⟩ + · intro t ht + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp ht + exact ⟨_,(mem_omega _).mpr ⟨n,rfl⟩,_,hG n v hv,rfl,tupleGraph_function A v hv⟩ + · let v : Fin 0 → ZFSet.{u} := Fin.elim0 + have hg : tupleGraph v = (∅ : ZFSet.{u}) := by + apply ZFSet.ext; intro z; simp [tupleGraph] + have ht := (mem_tupleSpace A _).mpr ⟨0,v,fun i => Fin.elim0 i,rfl⟩ + change ZFSet.pair (natSet 0) (tupleGraph v) ∈ tupleSpace A at ht + rwa [hg] at ht + · intro t ht x hx + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp ht + let w : Fin (n+1) → ZFSet.{u} := Fin.cases x v + exact ⟨tupleCode w,(mem_tupleSpace A _).mpr ⟨n+1,w,fun i => Fin.cases hx hv i,rfl⟩, + (tuplePrefix_spec A G hG v hv x _ hx).mpr rfl⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformAgreement.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformAgreement.lean new file mode 100644 index 0000000000000000000000000000000000000000..c50f5abe3fed8cdcf700483aaca3d2c73f5558d2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformAgreement.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformRun +import OAI.Computability.DegreeRigidity.Effective.CodingOnePoint + +namespace OAI + +namespace TuringRigidity.UniformAgreement +open Encodable UniformOracle ArithmeticHierarchy OracleJump EncodedForcing EffectiveWitness IndexMatrix +open CodingForcing UniformProgram + +def Disagreement (A : Oracle) (x : ℕ) (p : Condition) : Prop := + ∃ n a b, a ≠ b ∧ + a ∈ UniformRun.run A (machine (item x 0)) (machine (item x 1)) p.left n ∧ + b ∈ UniformRun.run A (machine (item x 0)) (machine (item x 2)) p.right n + +def NoDisagreement (A : Oracle) (x : ℕ) (p : Condition) : Prop := + ∀ q, Extends (columns A) p q → ¬ Disagreement A x q + +def Cert (A : Oracle) (v : ℕ) : Prop := + let x := (Nat.unpair (Nat.unpair v).1).1 + let p := (Nat.unpair (Nat.unpair v).1).2 + let w := (Nat.unpair v).2 + Extends (columns A) (condition p) (condition (item w 0)) ∧ item w 2 ≠ item w 3 ∧ + item w 2 ∈ UniformRun.run A (machine (item x 0)) (machine (item x 1)) (left (item w 0)) (item w 1) ∧ + item w 3 ∈ UniformRun.run A (machine (item x 0)) (machine (item x 2)) (right (item w 0)) (item w 1) + +theorem cert_sigma (A : Oracle) : Sigma A 1 (Cert A) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let x (i : ℕ) := item_primrec.comp (f.comp f) (Primrec.const i) + let w (i : ℕ) := item_primrec.comp r (Primrec.const i) + have he := recursive_comp (extends_recursive A) (Primrec₂.natPair.comp (r.comp f) (w 0)) + have hn := recursive_primrecPred A ((Primrec.eq.comp (w 2) (w 3)).not) + have hl := UniformRun.graph_sigma_of A (x 0) (x 1) (Primrec.encode.comp (left_primrec.comp (w 0))) (w 1) (w 2) + have hr := UniformRun.graph_sigma_of A (x 0) (x 2) (Primrec.encode.comp (right_primrec.comp (w 0))) (w 1) (w 3) + unfold Cert + simpa only [Nat.unpair_pair,word,encodek,Option.getD_some] using + (Form.raise (n := 0) (s := true) he).and ((Form.raise (n := 0) (s := true) hn).and (hl.and hr)) + +theorem decide_exists (A : Oracle) : ∃ f : ℕ → ℕ, + Nat.RecursiveIn {oracleFunction (jump A)} (fun v => Part.some (f v)) ∧ + ∀ x p, Extends (columns A) (condition p) (condition (f (Nat.pair x p))) ∧ + (Disagreement A x (condition (f (Nat.pair x p))) ∨ NoDisagreement A x (condition (f (Nat.pair x p)))) := by + obtain ⟨search,hs,hsearch⟩ := sigma1_choice (cert_sigma A) + let out : ℕ → ℕ := fun v => if search v = 0 then (Nat.unpair v).2 else item (search v-1) 0 + have hmap : Primrec (fun v : ℕ => if (Nat.unpair v).2 = 0 then (Nat.unpair (Nat.unpair v).1).2 + else item ((Nat.unpair v).2-1) 0) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + exact Primrec.ite (Primrec.eq.comp r (Primrec.const 0)) (r.comp f) + (item_primrec.comp (Primrec.nat_sub.comp r (Primrec.const 1)) (Primrec.const 0)) + refine ⟨out,?_,fun x p => ?_⟩ + · exact (total_comp (total_primrec hmap) (total_pair (total_primrec Primrec.id) hs)).of_eq + (fun v => by simp only [Nat.unpair_pair]; rfl) + · rcases hsearch (Nat.pair x p) with ⟨hz,hn⟩ | ⟨hp,hc⟩ + · simp only [out,hz,↓reduceIte,Nat.unpair_pair] + refine ⟨extends_refl _ _,Or.inr (fun q hpq hd => ?_)⟩ + obtain ⟨n,a,b,hab,ha,hb⟩ := hd + apply hn + refine ⟨encode [code q,n,a,b],?_⟩ + simpa [Cert,item,word,← show left (code q) = q.left from congrArg Condition.left (condition_code q), + ← show right (code q) = q.right from congrArg Condition.right (condition_code q),condition_code] using + And.intro hpq (And.intro hab (And.intro ha hb)) + · have hz : search (Nat.pair x p) ≠ 0 := by omega + simp only [out,ite_eq_right hz] + simp only [Cert,Nat.unpair_pair] at hc + exact ⟨hc.1,Or.inl ⟨_,_,_,hc.2⟩⟩ + +end TuringRigidity.UniformAgreement + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenDefinitionExtension.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenDefinitionExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..fec42f699c98e394e7f3da215910602a482e8983 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenDefinitionExtension.lean @@ -0,0 +1,37 @@ +import OAI.Computability.DegreeRigidity.Representation.HomogeneousDegreeExtension +import OAI.Computability.DegreeRigidity.Effective.UniformCohenDefinitionSymmetry + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing BoundedForcing +open CohenGroundPoset +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder CohenNiceNameConstruction.cohenTop + +theorem uniform_cohen_definition_extension (M A I ρ : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hct : (M : Set ZFSet.{0}).Countable) + (hA : A ∈ M) (hI : I ∈ M) (hρ : ρ ∈ M) + (δ : Ordinal.{0}) (hδ : δ.toZFSet ∈ M) (X : ZFSet.{0}) (hX : X ∈ M) + (φ : ElementaryModel.SentenceForm) + (G₀ : GenericFilter (Conditions (conditions A))) (hG₀ : GroundGeneric M G₀) + (h₀ : OwnDegreeExtension (genericExtensionSet M (conditions A) G₀.carrier) I ρ + (definedSubset (level (groundReals (genericExtensionSet M (conditions A) G₀.carrier)) δ) + φ (fun _ : Fin φ.bound => X))) : + ∃ f : Name (Conditions (conditions A)), f.encode (label (conditions A)) ∈ M ∧ + ∀ G : GenericFilter (Conditions (conditions A)), GroundGeneric M G → + f.val G.carrier = definedSubset + (level (groundReals (genericExtensionSet M (conditions A) G.carrier)) δ) + φ (fun _ : Fin φ.bound => X) ∧ + OwnDegreeExtension (genericExtensionSet M (conditions A) G.carrier) I ρ (f.val G.carrier) := by + have hc := conditions_mem M A hM hT hA + obtain ⟨f,hf,hfv,hinv⟩ := uniform_ordinal_definition_symmetric M (conditions A) + hM hT hc δ hδ X hX φ + have hf₀ : OwnDegreeExtension (genericExtensionSet M (conditions A) G₀.carrier) I ρ + (f.val G₀.carrier) := by rw [hfv G₀ hG₀]; exact h₀ + have hall := degree_extension_all_generics M (conditions A) I ρ hM hT hct hc hI hρ + (InternalCohenBitFlip.internally_homogeneous M A hM hT hA) f hf hinv G₀ hG₀ hf₀ + exact ⟨f,hf,fun G hG => ⟨hfv G hG,hall G hG⟩⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenDefinitionSymmetry.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenDefinitionSymmetry.lean new file mode 100644 index 0000000000000000000000000000000000000000..49dfffd564ae64c83e7ea492c2a955c6dd47c448 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenDefinitionSymmetry.lean @@ -0,0 +1,42 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformDefinitionSymmetry +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenHomogeneity +import OAI.Computability.DegreeRigidity.CohenForcing.CohenNiceNameConstruction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open CohenGroundPoset +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder CohenNiceNameConstruction.cohenTop + +theorem uniform_cohen_definition_symmetric (M A : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hA : A ∈ M) + (δ : Ordinal.{0}) (hδ : δ.toZFSet ∈ M) (X : ZFSet.{0}) (hX : X ∈ M) + (φ : ElementaryModel.SentenceForm) : + ∃ f : Name (Conditions (conditions A)), f.encode (label (conditions A)) ∈ M ∧ + (∀ G : GenericFilter (Conditions (conditions A)), GroundGeneric M G → + f.val G.carrier = definedSubset + (level (groundReals (genericExtensionSet M (conditions A) G.carrier)) δ) + φ (fun _ : Fin φ.bound => X)) ∧ + (∀ B ∈ M, ∀ G : GenericFilter (Conditions (conditions A)), GroundGeneric M G → + f.val (AutomorphismName.mapFilter (InternalCohenBitFlip.flipIso A B) G).carrier = + f.val G.carrier) ∧ + (∀ p q : Conditions (conditions A), ∃ B ∈ M, ∃ r, + r ≤ InternalCohenBitFlip.flipIso A B p ∧ r ≤ q) := by + have hc := conditions_mem M A hM hT hA + obtain ⟨f,hf,hfv,hinv⟩ := uniform_ordinal_definition_symmetric M (conditions A) + hM hT hc δ hδ X hX φ + refine ⟨f,hf,hfv,?_,?_⟩ + · intro B hB G hG + exact hinv (InternalCohenBitFlip.flipGraph A B) + (InternalCohenBitFlip.flipGraph_mem M A B hM hT hA hB) + (InternalCohenBitFlip.flipIso A B) (InternalCohenBitFlip.flipGraph_spec A B) G hG + · intro p q + refine ⟨InternalCohenBitFlip.matchingSet A (label _ p) (label _ q), + InternalCohenBitFlip.matchingSet_mem M A _ _ hM hT hA + (hM _ hc _ (label_mem _ p)) (hM _ hc _ (label_mem _ q)), + InternalCohenBitFlip.matching_common_extension A p q⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenIteration.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..f71633db9580d81d7f2bad476fff5062eac6b7d8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenIteration.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformCohenJump +import OAI.Computability.DegreeRigidity.Effective.UniformJumpSimulation + +namespace OAI + + +namespace TuringRigidity.UniformCohenJump +open UniformPrograms OracleJump EffectiveCohen + +theorem iterate_join_program (Y : Oracle) (k : ℕ) : + ∃ p : OracleCode, ∀ G : Oracle, (∀ j < k, OneGeneric (iterate Y j) G) → + OracleCode.eval (oracleFunction (join (iterate Y k) G)) p = + oracleFunction (iterate (join Y G) k) := by + induction k with + | zero => exact ⟨.query,fun _ _ => rfl⟩ + | succ k ih => + let X := {G : Oracle // ∀ j < k+1, OneGeneric (iterate Y j) G} + obtain ⟨p,hp⟩ := ih + have hprev : Runs (fun G : X => oracleFunction (join (iterate Y k) G.val)) + (fun G => oracleFunction (iterate (join Y G.val) k)) := + ⟨p,fun G => hp G.val (fun j hj => G.property j (Nat.lt_succ_of_lt hj))⟩ + obtain ⟨q,hq⟩ := oneGeneric_jump_program (iterate Y k) + have hstep : Runs (fun G : X => oracleFunction (join (iterate Y (k+1)) G.val)) + (fun G => oracleFunction (jump (join (iterate Y k) G.val))) := + ⟨q,fun G => hq G.val (G.property k (Nat.lt_succ_self k))⟩ + obtain ⟨r,hr⟩ := hstep.trans hprev.jump + exact ⟨r,fun G hG => hr ⟨G,hG⟩⟩ + +theorem swap_program {X : Type*} (A B : X → Oracle) : + Runs (fun x => oracleFunction (join (A x) (B x))) + (fun x => oracleFunction (join (B x) (A x))) := by + have hq := @query X (fun x => oracleFunction (join (A x) (B x))) + have hs := primrec (O := fun x => oracleFunction (join (A x) (B x))) + (Primrec.ite (Primrec.eq.comp Primrec.nat_bodd (Primrec.const true)) + (Primrec.nat_sub.comp Primrec.id (Primrec.const 1)) Primrec.succ) + apply (hq.comp hs).of_eq + intro x n + change (Part.some (if n.bodd = true then n - 1 else n.succ)).bind + (fun index => oracleFunction (join (A x) (B x)) index) = _ + rw [Part.bind_some] + rcases Nat.mod_two_eq_zero_or_one n with hn|hn + · have hform : n = 2*(n/2) := by omega + conv_lhs => rw [hform] + conv_rhs => rw [hform] + simp [oracleFunction,join,Nat.add_div] + · have hform : n = 2*(n/2)+1 := by omega + conv_lhs => rw [hform] + conv_rhs => rw [hform] + simp [oracleFunction,join,Nat.add_div] + +theorem iterate_generic_join_program (Y : Oracle) (k : ℕ) : + ∃ p : OracleCode, ∀ G : Oracle, (∀ j < k, OneGeneric (iterate Y j) G) → + OracleCode.eval (oracleFunction (join G (iterate Y k))) p = + oracleFunction (iterate (join G Y) k) := by + let X := {G : Oracle // ∀ j < k, OneGeneric (iterate Y j) G} + obtain ⟨p,hp⟩ := iterate_join_program Y k + have hi : Runs (fun G : X => oracleFunction (join (iterate Y k) G.val)) + (fun G => oracleFunction (iterate (join Y G.val) k)) := + ⟨p,fun G => hp G.val G.property⟩ + have hfirst := swap_program (fun G : X => G.val) (fun _ => iterate Y k) + have hlast := (swap_program (fun _ : X => Y) (fun G => G.val)).iterate_jump k + obtain ⟨q,hq⟩ := (hfirst.trans hi).trans hlast + exact ⟨q,fun G hG => hq ⟨G,hG⟩⟩ + +end TuringRigidity.UniformCohenJump + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenJump.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenJump.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a28386ecf166d963fa8319b8f62e0227aa984a7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenJump.lean @@ -0,0 +1,83 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformCohenPrefix +import OAI.Computability.DegreeRigidity.Constructibility.RelativeCohenJump + +namespace OAI + + +namespace TuringRigidity.UniformCohenJump +open Encodable UniformPrograms CommonIdeal EncodedForcing OracleJump +open ArithmeticHierarchy CohenHalting CohenLowness EffectiveCohen +noncomputable section +attribute [local instance] Classical.propDecidable + +def searchTrial (Y G : Oracle) (x p : ℕ) : Option ℕ := + if Deciding Y G (Nat.pair x p) then + some (if OpenHalts Y x (encode (word p)) then 1 else 0) else none + +def trialAnswer (v : ℕ) : Option ℕ := + if (Nat.unpair v).1 = 1 ∧ + ((Nat.unpair (Nat.unpair v).2).1 = 1 ∨ (Nat.unpair (Nat.unpair v).2).2 = 0) + then some (Nat.unpair (Nat.unpair v).2).1 else none + +theorem trialAnswer_primrec : Primrec trialAnswer := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + exact Primrec.ite ((Primrec.eq.comp f (Primrec.const 1)).and + ((Primrec.eq.comp (f.comp r) (Primrec.const 1)).or + (Primrec.eq.comp (r.comp r) (Primrec.const 0)))) + (Primrec.option_some.comp (f.comp r)) (Primrec.const none) + +theorem searchTrial_program (Y : Oracle) : + Runs (fun G => oracleFunction (join (jump Y) G)) + (fun G v => Part.some (encode (searchTrial Y G (Nat.unpair v).1 (Nat.unpair v).2))) := by + let O := fun G => oracleFunction (join (jump Y) G) + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hground : Runs O (fun _ => oracleFunction (jump Y)) := join_left_program (fun _ => jump Y) id + have hG : Runs O oracleFunction := join_right_program (fun _ => jump Y) id + have hp := total_comp (UniformCohenPrefix.prefix_program id hG) (primrec r) + have hhalt := fixed_recursive (form_recursive (openHalts_sigma Y)) hground + have hh := total_comp hhalt (primrec + (Primrec₂.natPair.comp f (Primrec.encode.comp (word_primrec.comp r)))) + have he := fixed_recursive (form_recursive (extension_sigma Y)) hground + have ht := total_comp (primrec (Primrec.encode.comp trialAnswer_primrec)) + (total_pair hp (total_pair hh he)) + apply ht.of_eq + intro G v + simp only [Nat.unpair_pair] + by_cases hp : Prefix G (word (Nat.unpair v).2) <;> + by_cases hh : OpenHalts Y (Nat.unpair v).1 (encode (word (Nat.unpair v).2)) <;> + by_cases he : Extension Y (Nat.unpair v).1 (Nat.unpair v).2 <;> + simp [trialAnswer,searchTrial,Deciding,hp,hh,he] + +theorem oneGeneric_jump_program (Y : Oracle) : + ∃ p : OracleCode, ∀ G : Oracle, OneGeneric Y G → + OracleCode.eval (oracleFunction (join (jump Y) G)) p = + oracleFunction (jump (join Y G)) := by + let X := {G : Oracle // OneGeneric Y G} + let O := fun G : X => oracleFunction (join (jump Y) G.val) + let f := fun (G : X) x => if Halts (join Y G.val) (Nat.unpair x).1 (Nat.unpair x).2 then 1 else 0 + have ht : Runs O (fun G v => Part.some + (encode (searchTrial Y G.val (Nat.unpair v).1 (Nat.unpair v).2))) := + (searchTrial_program Y).reindex (fun G : X => G.val) + have hs (G : X) (x p a : ℕ) (ha : a ∈ searchTrial Y G.val x p) : a = f G x := by + by_cases hd : Deciding Y G.val (Nat.pair x p) + · have ha' : a = (if OpenHalts Y x (encode (word p)) then 1 else 0) := by + exact (by simpa only [searchTrial,ite_eq_left hd,Option.mem_some_iff] using ha : + (if OpenHalts Y x (encode (word p)) then 1 else 0) = a).symm + rw [ha',deciding_correct hd] + · simp [searchTrial,hd] at ha + have hc (G : X) (x : ℕ) : ∃ p a, a ∈ searchTrial Y G.val x p := by + obtain ⟨p,hp⟩ := deciding_total G.property x + exact ⟨p,(if OpenHalts Y x (encode (word p)) then 1 else 0),by + simp only [searchTrial,ite_eq_left hp,Option.mem_some_iff]⟩ + obtain ⟨p,hp⟩ := total_search ht f hs hc + refine ⟨p,fun G hG => ?_⟩ + have h := hp (⟨G,hG⟩ : X) + funext n + exact (congrFun h n).trans (by simp [f,oracleFunction,jump]) + +end +end TuringRigidity.UniformCohenJump + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenPrefix.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenPrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..adff22d3e155c9804c781dd3403ec36380a2d378 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformCohenPrefix.lean @@ -0,0 +1,49 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformOracleSimulation +import OAI.Computability.DegreeRigidity.CohenForcing.CohenHalting + +namespace OAI + + +namespace TuringRigidity.UniformCohenPrefix +open Encodable UniformPrograms UniformOracle CommonIdeal EncodedForcing CohenHalting +noncomputable section +attribute [local instance] Classical.propDecidable + +theorem bit_eq_iff (a b : Bool) : bit a = bit b ↔ a = b := by + cases a <;> cases b <;> simp [bit] + +theorem numericPrefix_iff (G : Oracle) (p : ℕ) : + oraclePrefix (fun i => bit (G i)) (word p).length = (word p).map bit ↔ + Prefix G (word p) := by + constructor + · intro h i hi + have he := congrArg (fun l : List ℕ => l.getD i 0) h + have hbit : bit (G i) = bit ((word p).getD i false) := by + simpa [oraclePrefix,List.getD,hi] using he + exact (bit_eq_iff _ _).mp hbit + · intro h + apply List.ext_getElem + · simp [oraclePrefix] + · intro i hi hj + have hi' : i < (word p).length := by simpa [oraclePrefix] using hi + simpa [oraclePrefix,List.getD,hi'] using congrArg bit (h i hi') + +theorem prefix_program {X : Type*} {O : X → ℕ →. ℕ} (G : X → Oracle) + (hG : Runs O (fun x => oracleFunction (G x))) : + Runs O (fun x p => Part.some (if Prefix (G x) (word p) then 1 else 0)) := by + classical + have hq : Runs O (fun x i => Part.some (bit (G x i))) := hG + have hi := total_comp (initial_program (fun x i => bit (G x i)) hq) + (primrec (Primrec.list_length.comp word_primrec)) + have hw := primrec (O := O) (Primrec.encode.comp + (Primrec.list_map word_primrec (bit_primrec.comp Primrec.snd).to₂)) + have hc := total_comp (primrec (O := O) (Primrec.ite + (Primrec.eq.comp (Primrec.fst.comp Primrec.unpair) (Primrec.snd.comp Primrec.unpair)) + (Primrec.const 1) (Primrec.const 0))) (total_pair hi hw) + exact hc.of_eq (fun x n => by + simp only [Nat.unpair_pair,encode_injective.eq_iff,numericPrefix_iff]) + +end +end TuringRigidity.UniformCohenPrefix + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformDegreeOrderName.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformDegreeOrderName.lean new file mode 100644 index 0000000000000000000000000000000000000000..0edbe3ac84b34b5af82933639822daad08db0a6d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformDegreeOrderName.lean @@ -0,0 +1,58 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformDegreeUniverseName +import OAI.Computability.DegreeRigidity.Constructibility.UniformProductName +import OAI.Computability.DegreeRigidity.SetModels.ModelDegreeOrder + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory +open RecursiveNames TransitiveNameModel AtomicForcing CountableForcing BoundedForcing +open RelativeConstructible +universe u + +theorem uniform_degreeOrder_name (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) : + ∃ L : Name (Conditions c), L.encode (label c) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ⊤ ∈ G.carrier → + L.val G.carrier = degreeOrder (groundReals (genericExtensionSet M c G.carrier)) := by + have hω := sourceT_omega_mem M hM hT + have hz : natSet.{u} 0 ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨0,rfl⟩) + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union + hT.powerSet hT.separation.finitePrefix.bounded hω + have hcheck {x : ZFSet.{u}} (hx : x ∈ M) : + (Name.check x : Name (Conditions c)).encode (label c) ∈ M := + encoded_check_mem M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc hx + obtain ⟨D,hD,hDv⟩ := uniform_degreeUniverse_name M hM hT hc hoM ho + obtain ⟨P,hP,hPv⟩ := uniform_product_name M hM hT hc hoM ho D D hD hD + obtain ⟨φ,hφ⟩ := degree_order_bounded.{u} + let e := push (Name.check ZFSet.omega) (push (Name.check Q) (push (Name.check (natSet 0)) (fun _ => D))) + have he (i : ℕ) : (e i).encode (label c) ∈ M := by + rcases i with _|_|_|i + exact hcheck hω; exact hcheck hQM; exact hcheck hz; exact hD + obtain ⟨B,hB,hBS,hBv⟩ := uniform_separation_name M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc hoM ho + (Formula.degreeOrderMember φ 1 2 3 4 0) P hP e he + refine ⟨P.restrict (label c) B,?_,?_⟩ + · rw [Name.encode_restrict _ _ _ hBS]; exact hB + · intro G hG ht + let E := genericExtensionSet M c G.carrier + have hr : ∀ w ∈ groundReals E, ∃ A : Oracle, realCode A = w := by + intro w hw + exact ⟨decodeReal w,realCode_decodeReal ((mem_groundReals E w).mp hw).2⟩ + have hv : (fun i => (e i).val G.carrier) = + cons ZFSet.omega (cons Q (cons (natSet 0) (fun _ => D.val G.carrier))) := by + funext i; rcases i with _|_|_|i + exact Name.val_check G.carrier ht _ + exact Name.val_check G.carrier ht _ + exact Name.val_check G.carrier ht _ + rfl + apply ZFSet.ext; intro z + rw [hBv G hG z,hv,Formula.degreeOrderMember_spec hφ 1 2 3 4 0 _ rfl hQ rfl + (groundReals E) (hDv G hG ht) hr,hPv G hG ht,hDv G hG ht] + exact ⟨And.right,fun h => ⟨(ZFSet.mem_sep.mp h).1,h⟩⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformDegreeUniverseName.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformDegreeUniverseName.lean new file mode 100644 index 0000000000000000000000000000000000000000..d36f74ea96328d664d5483b7850ee55ae0926eee --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformDegreeUniverseName.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformOwnRealsName +import OAI.Computability.DegreeRigidity.Constructibility.UniformSeparationName +import OAI.Computability.DegreeRigidity.SetModels.ModelDegreeUniverse + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory +open RecursiveNames TransitiveNameModel AtomicForcing CountableForcing BoundedForcing +open RelativeConstructible +universe u + +theorem uniform_degreeUniverse_name (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) : + ∃ D : Name (Conditions c), D.encode (label c) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → ⊤ ∈ G.carrier → + D.val G.carrier = degreeUniverse (groundReals (genericExtensionSet M c G.carrier)) := by + have hω := sourceT_omega_mem M hM hT + have hz : natSet.{u} 0 ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨0,rfl⟩) + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union + hT.powerSet hT.separation.finitePrefix.bounded hω + have hcheck {x : ZFSet.{u}} (hx : x ∈ M) : + (Name.check x : Name (Conditions c)).encode (label c) ∈ M := + encoded_check_mem M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc hx + obtain ⟨R,hR,hRv⟩ := uniform_ownReals_name M hM hT hc hoM ho + obtain ⟨P,hP,hPv⟩ := uniform_power_name M hM hT hc hoM ho R hR + obtain ⟨φ,hφ⟩ := degree_equality_bounded.{u} + let e := push (Name.check ZFSet.omega) (push (Name.check Q) (push (Name.check (natSet 0)) (fun _ => R))) + have he (i : ℕ) : (e i).encode (label c) ∈ M := by + rcases i with _|_|_|i + exact hcheck hω; exact hcheck hQM; exact hcheck hz; exact hR + obtain ⟨B,hB,hBS,hBv⟩ := uniform_separation_name M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc hoM ho + (Formula.degreeUniverseMember φ 1 2 3 4 0) P hP e he + refine ⟨P.restrict (label c) B,?_,?_⟩ + · rw [Name.encode_restrict _ _ _ hBS]; exact hB + · intro G hG ht + let E := genericExtensionSet M c G.carrier + have hE := genericExtensionSet_transitive M c hM G.carrier + have hTE := extension_sourceT M hM hT hc hoM ho G hG ht + have hr : ∀ w ∈ R.val G.carrier, ∃ A : Oracle, realCode A = w := by + rw [hRv G hG ht] + intro w hw + exact ⟨decodeReal w,realCode_decodeReal ((mem_groundReals E w).mp hw).2⟩ + have hRE : R.val G.carrier ∈ E := (mem_extensionSet M c G.carrier _).mpr ⟨R,hR,rfl⟩ + have hbound : degreeUniverse (R.val G.carrier) ⊆ P.val G.carrier := by + intro D hD + obtain ⟨A,hA,rfl⟩ := (mem_degreeUniverse _ _).mp hD + exact (hPv G hG ht _).mpr ⟨internal_degreeCode E hE hTE _ hRE hr (hE _ hRE _ hA), + degreeCode_subset _ A⟩ + have hv : (fun i => (e i).val G.carrier) = + cons ZFSet.omega (cons Q (cons (natSet 0) (fun _ => R.val G.carrier))) := by + funext i; rcases i with _|_|_|i + exact Name.val_check G.carrier ht _ + exact Name.val_check G.carrier ht _ + exact Name.val_check G.carrier ht _ + rfl + rw [←hRv G hG ht] + apply ZFSet.ext; intro D + rw [hBv G hG D,hv,Formula.degreeUniverseMember_spec hφ 1 2 3 4 0 _ rfl hQ rfl hr] + exact ⟨And.right,fun h => ⟨hbound h,h⟩⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformJumpSimulation.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformJumpSimulation.lean new file mode 100644 index 0000000000000000000000000000000000000000..d7c885280bf4b2df030e9b0cdfcf7f86275c854b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformJumpSimulation.lean @@ -0,0 +1,119 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformOracleSimulation +import OAI.Computability.DegreeRigidity.Computability.OracleJump + +namespace OAI + + +namespace TuringRigidity.UniformPrograms +open Encodable CommonIdeal TableIndices IndexMatrix OracleJump +noncomputable section +variable {X : Type*} + +theorem run_program (Y : X → Oracle) : + Runs (fun x => oracleFunction (Y x)) (fun x v => Part.some + (encode (run (Y x) (machine (Nat.unpair v).1) + (Nat.unpair (Nat.unpair v).2).1 (Nat.unpair (Nat.unpair v).2).2))) := by + let O := fun x => oracleFunction (Y x) + let e := Primrec.fst.comp Primrec.unpair + let rest := Primrec.snd.comp Primrec.unpair + let n := Primrec.fst.comp (Primrec.unpair.comp rest) + let z := Primrec.snd.comp (Primrec.unpair.comp rest) + have he := primrec (O := O) e + have hn := primrec (O := O) n + have hm := primrec (O := O) (Primrec.fst.comp (Primrec.unpair.comp z)) + have ht := primrec (O := O) (Primrec.snd.comp (Primrec.unpair.comp z)) + have hL := total_comp (initial_program (fun x k => bit (Y x k)) query) hm + let r := Primrec.snd.comp Primrec.unpair + have hdecode := primrec (O := O) (Primrec.encode.comp (Nat.Partrec.Code.primrec_evaln.comp + (((Primrec.fst.comp Primrec.unpair).pair + (machine_primrec.comp (Primrec.fst.comp (Primrec.unpair.comp r)))).pair + (Primrec.snd.comp (Primrec.unpair.comp r))))) + exact (total_comp hdecode (total_pair ht (total_pair he (total_pair hL hn)))).of_eq + (fun x v => by simp [TableIndices.run,UniformOracle.trial]) + +def haltFlag (v : ℕ) : ℕ := + if ((decode (α := Option ℕ) v).getD none).isSome then 0 else 1 + +theorem haltFlag_primrec : Primrec haltFlag := by + apply (Primrec.cond (Primrec.option_isSome.comp + (Primrec.option_getD_default.comp (Primrec.decode (α := Option ℕ)))) + (Primrec.const 0) (Primrec.const 1)).of_eq + intro n + change (cond ((decode (α := Option ℕ) n).getD none).isSome 0 1) = _ + cases h : ((decode (α := Option ℕ) n).getD none).isSome <;> + simp only [haltFlag,h] <;> rfl + +def haltingSearch (Y : Oracle) (v : ℕ) : Part ℕ := + Nat.rfind (fun z => Part.some (run Y (machine (Nat.unpair v).1) (Nat.unpair v).2 z).isSome) + +theorem haltingSearch_program (Y : X → Oracle) : + Runs (fun x => oracleFunction (Y x)) (fun x => haltingSearch (Y x)) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hr := total_comp (run_program Y) (primrec + (Primrec₂.natPair.comp (f.comp f) (Primrec₂.natPair.comp (r.comp f) r))) + have hh := (total_comp (primrec haltFlag_primrec) hr).find + apply hh.of_eq + intro x n + unfold haltingSearch + congr 1 + funext z + simp only [Nat.unpair_pair,haltFlag,encodek,Option.getD_some] + cases run (Y x) (machine (Nat.unpair n).1) (Nat.unpair n).2 z <;> rfl + +theorem haltingSearch_dom (Y : Oracle) (v : ℕ) : + (haltingSearch Y v).Dom ↔ Halts Y (Nat.unpair v).1 (Nat.unpair v).2 := by + erw [haltingSearch,Nat.rfind_dom] + simp [Halts,Option.isSome_iff_exists] + +theorem uniform_partial_table (c : OracleCode) : + ∃ e, ∀ Y : Oracle, ∀ n, Halts Y e n ↔ (OracleCode.eval (oracleFunction Y) c n).Dom := by + have hh : Partrec₂ (fun L : List ℕ => fun n => OracleCode.eval (BranchMachine.lookup L) c n) := + OracleCode.eval_partrec BranchMachine.lookup_partrec c + obtain ⟨d,hd⟩ := partrec_code hh + have hd' : ∀ L n, d.eval (Nat.pair (encode L) n) = OracleCode.eval (BranchMachine.lookup L) c n := + fun L n => hd (L,n) + refine ⟨encode d,fun Y n => ?_⟩ + let f := OracleCode.eval (oracleFunction Y) c + have ha : Approximates (f n) (fun m => d.eval + (Nat.pair (encode (UniformOracle.oraclePrefix (fun k => bit (Y k)) m)) n)) := by + simp only [hd'] + exact OracleCode.eval_approximates (UniformOracle.prefix_approximates (fun k => bit (Y k))) c n + constructor + · rintro ⟨z,a,hz⟩ + simp only [machine_encode] at hz + exact (ha.1 (Nat.unpair z).1 a (Nat.Partrec.Code.evaln_sound hz)).1 + · intro hf + obtain ⟨m,hm⟩ := ha.2 ((f n).get hf) ⟨hf,rfl⟩ + obtain ⟨t,ht⟩ := Nat.Partrec.Code.evaln_complete.mp (hm m le_rfl) + exact ⟨Nat.pair m t,(f n).get hf,by simpa [TableIndices.run,UniformOracle.trial] using ht⟩ + +theorem Runs.jump {Y Z : X → Oracle} + (h : Runs (fun x => oracleFunction (Z x)) (fun x => oracleFunction (Y x))) : + Runs (fun x => oracleFunction (jump (Z x))) (fun x => oracleFunction (jump (Y x))) := by + classical + obtain ⟨c,hc⟩ := h.trans (haltingSearch_program Y) + obtain ⟨e,he⟩ := uniform_partial_table c + have hhalts (x : X) (v : ℕ) : Halts (Z x) e v ↔ + Halts (Y x) (Nat.unpair v).1 (Nat.unpair v).2 := by + rw [he,hc x,haltingSearch_dom] + have hq := @query X (fun x => oracleFunction (OracleJump.jump (Z x))) + exact (hq.comp (primrec (Primrec₂.natPair.comp (Primrec.const e) Primrec.id))).of_eq + (fun x n => by + change (Part.some (Nat.pair e n)).bind + (fun input => Part.some (if OracleJump.jump (Z x) input then 1 else 0)) = _ + rw [Part.bind_some] + simp [oracleFunction,OracleJump.jump,hhalts]) + +theorem Runs.iterate_jump {Y Z : X → Oracle} + (h : Runs (fun x => oracleFunction (Z x)) (fun x => oracleFunction (Y x))) (k : ℕ) : + Runs (fun x => oracleFunction (iterate (Z x) k)) + (fun x => oracleFunction (iterate (Y x) k)) := by + induction k with + | zero => exact h + | succ k ih => exact ih.jump + +end +end TuringRigidity.UniformPrograms + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformOracle.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformOracle.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d5bd200eb099dc806fcde4b6ccacec3f6573def --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformOracle.lean @@ -0,0 +1,191 @@ +import OAI.Computability.DegreeRigidity.Computability.BranchMachine + +namespace OAI + +namespace TuringRigidity +open Encodable + +namespace UniformOracle +variable {O : Set (ℕ →. ℕ)} + +theorem total_comp {f g : ℕ → ℕ} + (hf : Nat.RecursiveIn O (fun n => Part.some (f n))) + (hg : Nat.RecursiveIn O (fun n => Part.some (g n))) : + Nat.RecursiveIn O (fun n => Part.some (f (g n))) := by + simpa using Nat.RecursiveIn.comp hf hg + +theorem total_pair {f g : ℕ → ℕ} + (hf : Nat.RecursiveIn O (fun n => Part.some (f n))) + (hg : Nat.RecursiveIn O (fun n => Part.some (g n))) : + Nat.RecursiveIn O (fun n => Part.some (Nat.pair (f n) (g n))) := by + simpa [Seq.seq] using Nat.RecursiveIn.pair hf hg + +theorem total_primrec {f : ℕ → ℕ} (hf : Primrec f) : + Nat.RecursiveIn O (fun n => Part.some (f n)) := + RecursiveIn.iff_nat.mp hf.computableIn + +def oraclePrefix (g : ℕ → ℕ) (m : ℕ) : List ℕ := (List.range m).map g + +def appendEncoded (a b : ℕ) : ℕ := encode ((decode (α := List ℕ) a).getD [] ++ [b]) + +theorem appendEncoded_primrec : Primrec₂ appendEncoded := + Primrec.encode.comp (Primrec.list_append.comp + (Primrec.option_getD_default.comp (Primrec.decode.comp Primrec.fst)) + (Primrec.list_cons.comp Primrec.snd (Primrec.const []))) + +theorem prefix_recursive (g : ℕ → ℕ) : + Nat.RecursiveIn {fun n => Part.some (g n)} (fun m => Part.some (encode (oraclePrefix g m))) := by + have hquery : Nat.RecursiveIn {fun n => Part.some (g n)} (fun n => Part.some (g n)) := + .oracle _ (Set.mem_singleton _) + have hy := (total_primrec (O := {fun n => Part.some (g n)})) (Primrec.fst.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hi := (total_primrec (O := {fun n => Part.some (g n)})) (Primrec.snd.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hs := total_comp ((total_primrec (O := {fun n => Part.some (g n)})) (appendEncoded_primrec.comp + (Primrec.fst.comp Primrec.unpair) (Primrec.snd.comp Primrec.unpair))) + (total_pair hi (total_comp hquery hy)) + have hp := Nat.RecursiveIn.prec ((total_primrec (O := {fun n => Part.some (g n)})) (Primrec.const (encode ([] : List ℕ)))) hs + have hh := Nat.RecursiveIn.comp hp + (total_pair ((total_primrec (O := {fun n => Part.some (g n)})) (Primrec.const 0)) ((total_primrec (O := {fun n => Part.some (g n)})) Primrec.id)) + apply hh.of_eq + intro n + change (Part.some (Nat.pair 0 n)).bind _ = _ + rw [Part.bind_some] + simp only [Nat.unpair_pair] + induction n with + | zero => rfl + | succ n ih => + simp only [ih] + simp [appendEncoded, oraclePrefix, List.range_succ] + +theorem prefix_approximates (g : ℕ → ℕ) (k : ℕ) : + Approximates (Part.some (g k)) (fun m => BranchMachine.lookup (oraclePrefix g m) k) := by + have he (m : ℕ) : (oraclePrefix g m)[k]? = if k < m then some (g k) else none := by + simp only [oraclePrefix, List.getElem?_map] + by_cases hk : k < m + · rw [List.getElem?_range hk, ite_eq_left hk] + rfl + · rw [List.getElem?_eq_none (by simpa using Nat.le_of_not_gt hk), ite_eq_right hk] + rfl + constructor + · intro m a ha + change a ∈ ((oraclePrefix g m)[k]? : Part ℕ) at ha + rw [he] at ha + split at ha + · simpa using ha + · simp at ha + · intro a ha + have ha' : a = g k := Part.mem_some_iff.mp ha + subst a + refine ⟨k+1,fun m hm => ?_⟩ + change g k ∈ ((oraclePrefix g m)[k]? : Part ℕ) + rw [he, ite_eq_left (by omega)] + exact Part.mem_some _ + +private def flag (e : ℕ) : ℕ := + if ((decode (α := Option ℕ) e).getD none).isSome then 0 else 1 +private def answer (e : ℕ) : ℕ := ((decode (α := Option ℕ) e).getD none).getD 0 + +private theorem flag_primrec : Primrec flag := by + apply (Primrec.cond (Primrec.option_isSome.comp (Primrec.option_getD_default.comp (Primrec.decode (α := Option ℕ)))) + (Primrec.const 0) (Primrec.const 1)).of_eq + intro n + change (cond ((decode (α := Option ℕ) n).getD none).isSome 0 1) = _ + cases hh : ((decode (α := Option ℕ) n).getD none).isSome <;> simp only [flag,hh] <;> rfl +private theorem answer_primrec : Primrec answer := + Primrec.option_getD_default.comp (Primrec.option_getD_default.comp Primrec.decode) + +theorem total_search {E : ℕ → ℕ → Option ℕ} + (hE : Nat.RecursiveIn O (fun z => Part.some (encode (E (Nat.unpair z).1 (Nat.unpair z).2)))) + (f : ℕ → ℕ) (hsound : ∀ n m a, a ∈ E n m → a = f n) + (hcomplete : ∀ n, ∃ m a, a ∈ E n m) : + Nat.RecursiveIn O (fun n => Part.some (f n)) := by + have hflag := total_comp (total_primrec flag_primrec) hE + have hfind := Nat.RecursiveIn.rfind hflag + have hpair := Nat.RecursiveIn.pair (total_primrec Primrec.id) hfind + have hrun := Nat.RecursiveIn.comp (total_primrec answer_primrec) + (Nat.RecursiveIn.comp hE hpair) + apply hrun.of_eq_tot + intro n + have hex : ∃ m, (E n m).isSome = true := by + obtain ⟨m,a,ha⟩ := hcomplete n + exact ⟨m, Option.isSome_iff_exists.mpr ⟨a,ha⟩⟩ + let m := Nat.find hex + have hm := Nat.find_spec hex + obtain ⟨a,ha⟩ := Option.isSome_iff_exists.mp hm + have hval : a = f n := hsound n m a ha + have hmem : m ∈ Nat.rfind (fun k => + (fun v : ℕ => decide (v=0)) <$> Part.some (flag (encode (E n k)))) := by + apply Nat.mem_rfind.mpr + constructor + · simp [flag, m, hm] + · intro k hk + have hk' : (E n k).isSome = false := Bool.eq_false_iff.mpr (Nat.find_min hex hk) + simp [flag, hk'] + apply Part.mem_bind_iff.mpr + refine ⟨encode (E n m), ?_, ?_⟩ + · apply Part.mem_bind_iff.mpr + refine ⟨Nat.pair n m, ?_, ?_⟩ + · simp only [Seq.seq] + apply Part.mem_bind_iff.mpr + refine ⟨Nat.pair n, (Part.mem_map_iff _).mpr ⟨n,Part.mem_some _,rfl⟩, ?_⟩ + exact (Part.mem_map_iff _).mpr ⟨m,by simpa only [Nat.unpair_pair] using hmem,rfl⟩ + · simp + · have hea : E n m = some a := Option.mem_def.mp ha + apply Part.mem_some_iff.mpr + rw [hea] + simpa only [answer, Encodable.encodek, Option.getD_some] using hval.symm + +def trial (g : ℕ → ℕ) (c : Nat.Partrec.Code) (n z : ℕ) : Option ℕ := + c.evaln (Nat.unpair z).2 (Nat.pair (encode (oraclePrefix g (Nat.unpair z).1)) n) + +theorem trial_recursive (g : ℕ → ℕ) (c : Nat.Partrec.Code) : + Nat.RecursiveIn {fun n => Part.some (g n)} + (fun z => Part.some (encode (trial g c (Nat.unpair z).1 (Nat.unpair z).2))) := by + have hm := (total_primrec (O := {fun n => Part.some (g n)})) (Primrec.fst.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hk := (total_primrec (O := {fun n => Part.some (g n)})) (Primrec.snd.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hn := (total_primrec (O := {fun n => Part.some (g n)})) (Primrec.fst.comp Primrec.unpair) + have hp := total_comp (prefix_recursive g) hm + have he := (total_primrec (O := {fun n => Part.some (g n)})) (Primrec.encode.comp + (Nat.Partrec.Code.primrec_evaln.comp + (((Primrec.fst.comp Primrec.unpair).pair (Primrec.const c)).pair + (Primrec.snd.comp Primrec.unpair)))) + exact (total_comp he (total_pair hk (total_pair hp hn))).of_eq (fun z => by + simp [trial]) + +theorem compute_of_finite (g f : ℕ → ℕ) (c : Nat.Partrec.Code) + (ha : ∀ n, Approximates (Part.some (f n)) + (fun m => c.eval (Nat.pair (encode (oraclePrefix g m)) n))) : + Nat.RecursiveIn {fun n => Part.some (g n)} (fun n => Part.some (f n)) := by + apply total_search (trial_recursive g c) f + · intro n z a h + exact Part.mem_some_iff.mp ((ha n).1 (Nat.unpair z).1 a + (Nat.Partrec.Code.evaln_sound h)) + · intro n + obtain ⟨M,hM⟩ := (ha n).2 (f n) (Part.mem_some _) + obtain ⟨k,hk⟩ := Nat.Partrec.Code.evaln_complete.mp (hM M le_rfl) + exact ⟨Nat.pair M k,f n,by simpa [trial] using hk⟩ + +theorem stage_recursive (p q : OracleCode) (j h : ℕ) (g f : ℕ → ℕ) + (hf : ∀ n k, BranchMachine.stage p q j h (fun x => Part.some (g x)) n k = + Part.some (f (Nat.pair n k))) : + Nat.RecursiveIn {fun n => Part.some (g n)} (fun n => Part.some (f n)) := by + obtain ⟨c,hc⟩ := partrec_code (BranchMachine.stage_finite_partrec p q j h) + have hc' (L : List ℕ) (z : ℕ) : + c.eval (Nat.pair (encode L) z) = + BranchMachine.stage p q j h (BranchMachine.lookup L) (Nat.unpair z).1 (Nat.unpair z).2 := by + have hh := hc (L,(Nat.unpair z).1,(Nat.unpair z).2) + change c.eval (Nat.pair (encode L) (Nat.pair (Nat.unpair z).1 (Nat.unpair z).2)) = _ at hh + simpa only [Nat.pair_unpair] using hh + apply compute_of_finite g f c + intro z + have hh := BranchMachine.stage_approximates p q j h (prefix_approximates g) + (Nat.unpair z).1 (Nat.unpair z).2 + simpa only [← hc', hf, Nat.pair_unpair] using hh + +end UniformOracle +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformOracleSimulation.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformOracleSimulation.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b6557198e77f3b08cf0098119d552bd48e39a2c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformOracleSimulation.lean @@ -0,0 +1,58 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformPrograms +import OAI.Computability.DegreeRigidity.Computability.Joins + +namespace OAI + + +namespace TuringRigidity.UniformPrograms +variable {X Z : Type*} {O F H : X → ℕ →. ℕ} + +theorem Runs.reindex (h : Runs O F) (g : Z → X) : + Runs (O ∘ g) (F ∘ g) := by + obtain ⟨p,hp⟩ := h + exact ⟨p,fun z => hp (g z)⟩ + +theorem Runs.simulate (h : Runs O F) (p : OracleCode) : + Runs O (fun x => OracleCode.eval (F x) p) := by + induction p with + | zero => exact primrec (Primrec.const 0) + | succ => exact primrec Primrec.succ + | left => exact primrec (Primrec.fst.comp Primrec.unpair) + | right => exact primrec (Primrec.snd.comp Primrec.unpair) + | query => exact h + | pair p q hp hq => exact hp.pair hq + | comp p q hp hq => exact hp.comp hq + | prec p q hp hq => exact hp.prec hq + | find p hp => exact hp.find + +theorem Runs.trans (h : Runs O F) (h' : Runs F H) : Runs O H := by + obtain ⟨p,hp⟩ := h' + exact (h.simulate p).of_eq (fun x n => congrFun (hp x) n) + +theorem fixed_recursive {g f : ℕ →. ℕ} (hf : Nat.RecursiveIn {g} f) + (hg : Runs O (fun _ => g)) : Runs O (fun _ => f) := by + obtain ⟨p,hp⟩ := OracleCode.exists_code hf + exact (hg.simulate p).of_eq (fun _ n => congrFun hp n) + +theorem join_left_program (A B : X → Oracle) : + Runs (fun x => oracleFunction (join (A x) (B x))) (fun x => oracleFunction (A x)) := by + have hq := @query X (fun x => oracleFunction (join (A x) (B x))) + exact (hq.comp (primrec (Primrec.nat_mul.comp (Primrec.const 2) Primrec.id))).of_eq + (fun x n => by + change (Part.some (2*n)).bind (fun input => oracleFunction (join (A x) (B x)) input) = _ + rw [Part.bind_some] + simp [oracleFunction,join]) + +theorem join_right_program (A B : X → Oracle) : + Runs (fun x => oracleFunction (join (A x) (B x))) (fun x => oracleFunction (B x)) := by + have hq := @query X (fun x => oracleFunction (join (A x) (B x))) + exact (hq.comp (primrec (Primrec.succ.comp + (Primrec.nat_mul.comp (Primrec.const 2) Primrec.id)))).of_eq + (fun x n => by + change (Part.some (2*n+1)).bind (fun input => oracleFunction (join (A x) (B x)) input) = _ + rw [Part.bind_some] + simp [oracleFunction,join,Nat.add_div]) + +end TuringRigidity.UniformPrograms + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformPair.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc8aef6696b921d5c481e78120870999453e185f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformPair.lean @@ -0,0 +1,221 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformSplit +import OAI.Computability.DegreeRigidity.Effective.UniformAgreement +import OAI.Computability.DegreeRigidity.Effective.EffectiveSplitConditions + +namespace OAI + +namespace TuringRigidity.UniformPair +open Encodable UniformOracle ArithmeticHierarchy OracleJump EncodedForcing EffectiveWitness IndexMatrix +open CodingForcing UniformProgram + +def request (v : ℕ) : ℕ := encode [item (Nat.unpair v).1 0,item (Nat.unpair v).1 1,encode (left (Nat.unpair v).2)] + +theorem request_primrec : Primrec request := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + exact Primrec.encode.comp (Primrec.list_cons.comp (item_primrec.comp f (Primrec.const 0)) + (Primrec.list_cons.comp (item_primrec.comp f (Primrec.const 1)) + (Primrec.list_cons.comp (Primrec.encode.comp (left_primrec.comp r)) (Primrec.const [])))) + +def IsCoding (A : Oracle) (v : ℕ) : Prop := + CodingLocation (columns A) (condition (Nat.unpair v).1) (item (Nat.unpair (Nat.unpair v).2).2 2) + +theorem coding_recursive (A : Oracle) : RecursivePred A (IsCoding A) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let m := item_primrec.comp (r.comp r) (Primrec.const 2) + have hl := recursive_primrecPred A (Primrec.nat_le.comp (Primrec.list_length.comp (left_primrec.comp f)) m) + have hk := recursive_primrecPred A (Primrec.nat_lt.comp (f.comp m) (active_primrec.comp f)) + have hq : Nat.RecursiveIn {oracleFunction A} (oracleFunction A) := .oracle _ (Set.mem_singleton _) + have ha : RecursivePred A (fun v => A (item (Nat.unpair (Nat.unpair v).2).2 2) = true) := by + exact (Nat.RecursiveIn.comp hq (total_primrec m)).of_eq (fun v => by + change (Part.some (item (Nat.unpair (Nat.unpair v).2).2 2)).bind (fun input => oracleFunction A input) = _ + rw [Part.bind_some] + cases h : A (item (Nat.unpair (Nat.unpair v).2).2 2) <;> simp [oracleFunction,h]) + unfold IsCoding + simpa only [CodingLocation,columns,condition,Nat.pair_unpair] using recursive_and hl (recursive_and hk ha) + +noncomputable def outcome (A : Oracle) (v : ℕ) : ℕ := by + classical + let w := UniformSplit.step A (request v) + exact if (Nat.unpair w).1 = 1 ∧ ¬ IsCoding A (Nat.pair (Nat.unpair v).2 w) + then Nat.pair 3 (Nat.unpair w).2 else w + +theorem outcome_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (jump A)} (fun v => Part.some (outcome A v)) := by + classical + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hs := total_comp (UniformSplit.step_recursive A) (total_primrec request_primrec) + have hcode := total_pair (total_primrec r) hs + have hc := total_comp (recursive_lift (coding_recursive A)) hcode + have hmap : Primrec (fun v : ℕ => if (Nat.unpair (Nat.unpair v).1).1 = 1 ∧ (Nat.unpair v).2 = 0 + then Nat.pair 3 (Nat.unpair (Nat.unpair v).1).2 else (Nat.unpair v).1) := + Primrec.ite ((Primrec.eq.comp (f.comp f) (Primrec.const 1)).and + (Primrec.eq.comp r (Primrec.const 0))) (Primrec₂.natPair.comp (Primrec.const 3) (r.comp f)) f + exact (total_comp (total_primrec hmap) (total_pair hs hc)).of_eq (fun v => by + simp only [Nat.unpair_pair,outcome] + by_cases h : IsCoding A (Nat.pair (Nat.unpair v).2 (UniformSplit.step A (request v))) <;> simp [h]) + +def retag (w : ℕ) : ℕ := + if (Nat.unpair w).1 = 3 then Nat.pair 2 (Nat.unpair w).2 else w + +theorem retag_primrec : Primrec retag := Primrec.ite + (Primrec.eq.comp (Primrec.fst.comp Primrec.unpair) (Primrec.const 3)) + (Primrec₂.natPair.comp (Primrec.const 2) (Primrec.snd.comp Primrec.unpair)) Primrec.id + +def update (p w : ℕ) : ℕ := EffectiveSplitConditions.update p (retag w) + +noncomputable def next (A : Oracle) (v : ℕ) : ℕ := update (Nat.unpair v).2 (outcome A v) + +theorem next_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (jump A)} (fun v => Part.some (next A v)) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hu := EffectiveSplitConditions.update_primrec.comp f (retag_primrec.comp r) + exact (total_comp (total_primrec hu) + (total_pair (total_primrec r) (outcome_recursive A))).of_eq + (fun v => by simp only [Nat.unpair_pair]; rfl) + +theorem next_extends (A : Oracle) (v : ℕ) : + Extends (columns A) (condition (Nat.unpair v).2) (condition (next A v)) ∧ + (condition (next A v)).active = (condition (Nat.unpair v).2).active := by + unfold next update EffectiveSplitConditions.update + split <;> rw [condition_code] + · exact ⟨append_extends _ _ _,rfl⟩ + · exact ⟨extends_refl _ _,rfl⟩ + +theorem split_coding_or_divergence {A : Oracle} {x : ℕ} {p r : Condition} + (hn : UniformAgreement.NoDisagreement A x p) (hpr : Extends (columns A) p r) + (m : ℕ) (hm : p.left.length ≤ m) (hmr : m < r.left.length) (b : Bool) + (n v w : ℕ) (hvw : v ≠ w) + (hv : v ∈ UniformRun.run A (machine (item x 0)) (machine (item x 1)) r.left n) + (hw : w ∈ UniformRun.run A (machine (item x 0)) (machine (item x 1)) (r.left.set m b) n) : + CodingLocation (columns A) p m ∨ + ∀ q, Extends (columns A) r q → ∀ c, + c ∉ UniformRun.run A (machine (item x 0)) (machine (item x 2)) q.right n := by + by_cases hc : CodingLocation (columns A) p m + · exact Or.inl hc + · right + intro q hrq c hvc + have hpq := extends_trans hpr hrq + have hpc := CodingOnePoint.changeLeft_extends hpq m hm hc b + have hvq := UniformRun.run_mono hrq.1 n v hv + have hwq := UniformRun.run_mono (CodingOnePoint.set_prefix_set hrq.1 m hmr b) n w hw + have hveq : v = c := by + by_contra hne + exact hn q hpq ⟨n,v,c,hne,hvq,hvc⟩ + have hweq : w = c := by + by_contra hne + exact hn (CodingOnePoint.changeLeft q m b) hpc ⟨n,w,c,hne,hwq,hvc⟩ + exact hvw (hveq.trans hweq.symm) + +theorem next_spec (A : Oracle) (x p : ℕ) + (hn : UniformAgreement.NoDisagreement A x (condition p)) : + Extends (columns A) (condition p) (condition (next A (Nat.pair x p))) ∧ + (condition (next A (Nat.pair x p))).active = (condition p).active ∧ + ((¬ ∃ z, UniformSplit.SplitCert A (Nat.pair (request (Nat.pair x p)) z)) ∨ + (∃ w, UniformSplit.PointCert A (Nat.pair (request (Nat.pair x p)) w) ∧ + CodingLocation (columns A) (condition p) (item w 2)) ∨ + ∃ i n, (i = 1 ∨ i = 2) ∧ ∀ q, Extends (columns A) (condition (next A (Nat.pair x p))) q → + ∀ a, a ∉ UniformRun.run A (machine (item x 0)) (machine (item x i)) + (if i = 1 then q.left else q.right) n) := by + classical + let v := Nat.pair x p + let raw := UniformSplit.step A (request v) + have hs := UniformSplit.step_spec A (request v) + change UniformSplit.Accept A (Nat.pair (request v) raw) at hs + simp only [UniformSplit.Accept,Nat.unpair_pair] at hs + rcases hs with ⟨ht,hno⟩ | ⟨ht,hpoint⟩ | ⟨ht,hdiv⟩ + · have he : condition (next A v) = condition p := by + simp [next,outcome,update,retag,EffectiveSplitConditions.update,← show raw = UniformSplit.step A (request v) from rfl,ht,v,condition_code] + change Extends _ _ (condition (next A v)) ∧ _ + rw [he] + exact ⟨extends_refl _ _,rfl,Or.inl hno⟩ + · let w := (Nat.unpair raw).2 + have hp := hpoint + simp only [UniformSplit.PointCert,Nat.unpair_pair,UniformSplit.start,UniformSplit.base, + UniformSplit.program,request,v,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ, + word] at hp + have hpq : left p <+: word (item w 1) := hp.1 + let r := append (condition p) ((word (item w 1)).drop (left p).length) + have hl : r.left = word (item w 1) := by + change left p ++ (word (item w 1)).drop (left p).length = _ + rw [List.prefix_iff_eq_take] at hpq + conv_lhs => lhs; rw [hpq] + exact List.take_append_drop _ _ + by_cases hcoding : IsCoding A (Nat.pair p raw) + · have he : condition (next A v) = condition p := by + simp [next,outcome,update,retag,EffectiveSplitConditions.update, + ← show raw = UniformSplit.step A (request v) from rfl,ht,v,hcoding,condition_code] + change Extends _ _ (condition (next A v)) ∧ _ + rw [he] + exact ⟨extends_refl _ _,rfl,Or.inr (Or.inl ⟨w,hpoint,by simpa only [IsCoding,Nat.unpair_pair] using hcoding⟩)⟩ + · have he : condition (next A v) = r := by + simp [next,outcome,update,retag,EffectiveSplitConditions.update, + ← show raw = UniformSplit.step A (request v) from rfl,ht,v,hcoding,condition_code] + rfl + have hnc : ¬ CodingLocation (columns A) (condition p) (item w 2) := by simpa only [IsCoding,Nat.unpair_pair] using hcoding + have hpr : Extends (columns A) (condition p) r := append_extends _ _ _ + have hd := split_coding_or_divergence (r := r) hn hpr + (item w 2) hp.2.1 (by simpa [hl,item,word,w] using hp.2.2.1) (item w 3).bodd + (item w 0) (item w 4) (item w 5) hp.2.2.2.1 + (by simpa [hl,item,word,w] using hp.2.2.2.2.1) (by simpa [hl,item,word,w] using hp.2.2.2.2.2) + change Extends _ _ (condition (next A v)) ∧ _ + rw [he] + refine ⟨append_extends _ _ _,rfl,Or.inr (Or.inr ⟨2,item w 0,Or.inr rfl,?_⟩)⟩ + simpa using hd.resolve_left hnc + · let w := (Nat.unpair raw).2 + have hpq : left p <+: word (item w 1) := by + simpa [UniformSplit.DivCert,UniformSplit.start,request,v,item,word] using hdiv.1 + let r := append (condition p) ((word (item w 1)).drop (left p).length) + have hl : r.left = word (item w 1) := by + change left p ++ (word (item w 1)).drop (left p).length = _ + rw [List.prefix_iff_eq_take] at hpq + conv_lhs => lhs; rw [hpq] + exact List.take_append_drop _ _ + have he : condition (next A v) = r := by + simp [next,outcome,update,retag,EffectiveSplitConditions.update, + ← show raw = UniformSplit.step A (request v) from rfl,ht,v,condition_code] + rfl + change Extends _ _ (condition (next A v)) ∧ _ + rw [he] + refine ⟨append_extends _ _ _,rfl,Or.inr (Or.inr ⟨1,item w 0,Or.inl rfl,?_⟩)⟩ + intro q hrq a ha + apply hdiv.2 + refine ⟨encode q.left,a,?_,?_⟩ + · simpa [word,w,hl] using hrq.1 + · simpa [UniformSplit.base,UniformSplit.program,request,v,item,word] using ha + +theorem disagreement_mono {A : Oracle} {x : ℕ} {p q : Condition} + (hpq : Extends (columns A) p q) (h : UniformAgreement.Disagreement A x p) : + UniformAgreement.Disagreement A x q := by + obtain ⟨n,a,b,hab,ha,hb⟩ := h + exact ⟨n,a,b,hab,UniformRun.run_mono hpq.1 n a ha,UniformRun.run_mono hpq.2.1 n b hb⟩ + +theorem pair_exists (A : Oracle) : ∃ f : ℕ → ℕ, + Nat.RecursiveIn {oracleFunction (jump A)} (fun v => Part.some (f v)) ∧ + ∀ x p, Extends (columns A) (condition p) (condition (f (Nat.pair x p))) ∧ + (UniformAgreement.Disagreement A x (condition (f (Nat.pair x p))) ∨ + ∃ q, Extends (columns A) (condition p) (condition q) ∧ + UniformAgreement.NoDisagreement A x (condition q) ∧ + f (Nat.pair x p) = next A (Nat.pair x q)) := by + obtain ⟨d,hd,hds⟩ := UniformAgreement.decide_exists A + let f := fun v => next A (Nat.pair (Nat.unpair v).1 (d v)) + refine ⟨f,?_,fun x p => ?_⟩ + · have hp := total_pair (total_primrec (O := {oracleFunction (jump A)}) + (Primrec.fst.comp Primrec.unpair)) hd + have hr := total_comp (next_recursive A) hp + exact hr.of_eq (fun v => rfl) + · obtain ⟨hp,hm⟩ := hds x p + have hq := (next_extends A (Nat.pair x (d (Nat.pair x p)))).1 + simp only [Nat.unpair_pair] at hq + refine ⟨?_,?_⟩ + · simpa only [f,Nat.unpair_pair] using extends_trans hp hq + · rcases hm with hm | hm + · exact Or.inl (by simpa only [f,Nat.unpair_pair] using disagreement_mono hq hm) + · exact Or.inr ⟨d (Nat.pair x p),hp,hm,by simp only [f,Nat.unpair_pair]⟩ + +end TuringRigidity.UniformPair + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformPartialGraph.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformPartialGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..10b7356baf4f3b03ec4b36848e9f69281daf6626 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformPartialGraph.lean @@ -0,0 +1,34 @@ +import OAI.Computability.DegreeRigidity.Effective.TableIndices + +namespace OAI + +namespace TuringRigidity.UniformPartialGraph +open Encodable UniformOracle CommonIdeal + +theorem eval_iff_table (p : OracleCode) : + ∃ d : Nat.Partrec.Code, ∀ Y : Oracle, ∀ n a : ℕ, + a ∈ OracleCode.eval (oracleFunction Y) p n ↔ + ∃ z, a ∈ TableIndices.run Y d n z := by + have hf : Partrec₂ (fun L : List ℕ => fun n => + OracleCode.eval (BranchMachine.lookup L) p n) := + OracleCode.eval_partrec BranchMachine.lookup_partrec p + obtain ⟨d, hd⟩ := partrec_code hf + have hd' (L : List ℕ) (n : ℕ) : + d.eval (Nat.pair (encode L) n) = OracleCode.eval (BranchMachine.lookup L) p n := + hd (L, n) + refine ⟨d, fun Y n a => ?_⟩ + have ha : Approximates (OracleCode.eval (oracleFunction Y) p n) + (fun m => d.eval (Nat.pair (encode (oraclePrefix (fun k => bit (Y k)) m)) n)) := by + simp only [hd'] + exact OracleCode.eval_approximates (prefix_approximates (fun k => bit (Y k))) p n + constructor + · intro h + obtain ⟨m, hm⟩ := ha.2 a h + obtain ⟨t, ht⟩ := Nat.Partrec.Code.evaln_complete.mp (hm m le_rfl) + exact ⟨Nat.pair m t, by simpa [TableIndices.run, trial] using ht⟩ + · rintro ⟨z, hz⟩ + exact ha.1 (Nat.unpair z).1 a (Nat.Partrec.Code.evaln_sound hz) + +end TuringRigidity.UniformPartialGraph + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformProgram.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..908fb6d70924cf8ee126100a0052d1ba318566c8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformProgram.lean @@ -0,0 +1,217 @@ +import OAI.Computability.DegreeRigidity.Computability.BranchMachine + +namespace OAI + +namespace TuringRigidity.UniformProgram +open Encodable Computable +abbrev Code := Nat.Partrec.Code +local instance : DecidableEq Code := Encodable.decidableEqOfEncodable Code + +def meaning : Code → OracleCode + | .zero => .zero + | .succ => .succ + | .left => .left + | .right => .right + | .pair c d => .pair (meaning c) (meaning d) + | .comp c d => .comp (meaning c) (meaning d) + | .prec c d => .prec (meaning c) (meaning d) + | .rfind' c => if c = .zero then .query else .find (meaning c) + +def represent : OracleCode → Code + | .zero => .zero + | .succ => .succ + | .left => .left + | .right => .right + | .query => .rfind' .zero + | .pair c d => .pair (represent c) (represent d) + | .comp c d => .comp (represent c) (represent d) + | .prec c d => .prec (represent c) (represent d) + | .find c => .rfind' (.comp (represent c) (.pair .left .right)) + +theorem represent_correct (g : ℕ →. ℕ) (e : OracleCode) : + OracleCode.eval g (meaning (represent e)) = OracleCode.eval g e := by + induction e with + | zero | succ | left | right | query => rfl + | pair c d hc hd | comp c d hc hd | prec c d hc hd => + simp only [represent,meaning,OracleCode.eval,hc,hd] + rfl + | find c hc => + simp only [represent,meaning,reduceCtorEq,↓reduceIte,OracleCode.eval,hc] + funext n + simp [Seq.seq,Part.bind_some] + apply congrArg Nat.rfind + funext candidate + exact congrArg (Part.map (fun value : ℕ => decide (value = 0))) + (Part.bind_some (Nat.pair n candidate) (OracleCode.eval g c)) + +def tag : Code → ℕ + | .zero => 0 | .succ => 1 | .left => 2 | .right => 3 + | .pair _ _ => 4 | .comp _ _ => 5 | .prec _ _ => 6 | .rfind' _ => 7 + +def first : Code → Code + | .pair c _ | .comp c _ | .prec c _ | .rfind' c => c + | _ => .zero + +def second : Code → Code + | .pair _ d | .comp _ d | .prec _ d => d + | _ => .zero + +theorem tag_primrec : Primrec tag := by + have h := Nat.Partrec.Code.primrec_recOn (α := Code) (σ := ℕ) Primrec.id + (Primrec.const 0) (Primrec.const 1) (Primrec.const 2) (Primrec.const 3) + (pr := fun _ _ _ _ _ => 4) (Primrec.const 4) + (co := fun _ _ _ _ _ => 5) (Primrec.const 5) + (pc := fun _ _ _ _ _ => 6) (Primrec.const 6) + (rf := fun _ _ _ => 7) (Primrec.const 7) + exact h.of_eq (fun e => by cases e <;> rfl) + +theorem first_primrec : Primrec first := by + have h := Nat.Partrec.Code.primrec_recOn (α := Code) (σ := Code) Primrec.id + (Primrec.const Nat.Partrec.Code.zero) (Primrec.const Nat.Partrec.Code.zero) + (Primrec.const Nat.Partrec.Code.zero) (Primrec.const Nat.Partrec.Code.zero) + (pr := fun _ c _ _ _ => c) (Primrec.fst.comp Primrec.snd) + (co := fun _ c _ _ _ => c) (Primrec.fst.comp Primrec.snd) + (pc := fun _ c _ _ _ => c) (Primrec.fst.comp Primrec.snd) + (rf := fun _ c _ => c) (Primrec.fst.comp Primrec.snd) + exact h.of_eq (fun e => by cases e <;> rfl) + +theorem second_primrec : Primrec second := by + have h := Nat.Partrec.Code.primrec_recOn (α := Code) (σ := Code) Primrec.id + (Primrec.const Nat.Partrec.Code.zero) (Primrec.const Nat.Partrec.Code.zero) + (Primrec.const Nat.Partrec.Code.zero) (Primrec.const Nat.Partrec.Code.zero) + (pr := fun _ _ d _ _ => d) (Primrec.fst.comp (Primrec.snd.comp Primrec.snd)) + (co := fun _ _ d _ _ => d) (Primrec.fst.comp (Primrec.snd.comp Primrec.snd)) + (pc := fun _ _ d _ _ => d) (Primrec.fst.comp (Primrec.snd.comp Primrec.snd)) + (rf := fun _ _ _ => Nat.Partrec.Code.zero) (Primrec.const Nat.Partrec.Code.zero) + exact h.of_eq (fun e => by cases e <;> rfl) + +variable {α : Type*} [Primcodable α] (g : α → ℕ →. ℕ) + +def layer (self : Code) (z : Code × α × ℕ) : Part ℕ := + let e := z.1 + let a := z.2.1 + let n := z.2.2 + let c := fun k => self.eval (encode (first e,a,k)) + let d := fun k => self.eval (encode (second e,a,k)) + if tag e = 0 then Part.some 0 else + if tag e = 1 then Part.some (n+1) else + if tag e = 2 then Part.some (Nat.unpair n).1 else + if tag e = 3 then Part.some (Nat.unpair n).2 else + if tag e = 4 then Nat.pair <$> c n <*> d n else + if tag e = 5 then d n >>= c else + if tag e = 6 then + if (Nat.unpair n).2 = 0 then c (Nat.unpair n).1 else + self.eval (encode (e,a,Nat.pair (Nat.unpair n).1 ((Nat.unpair n).2-1))) >>= fun b => + d (Nat.pair (Nat.unpair n).1 (Nat.pair ((Nat.unpair n).2-1) b)) else + if first e = .zero then g a n else + Nat.rfind (fun k => (fun b => b = 0) <$> c (Nat.pair n k)) + +theorem layer_partrec (hg : Partrec₂ g) : Partrec₂ (layer g) := by + let e : Computable (fun z : Code × (Code × α × ℕ) => z.2.1) := fst.comp snd + let a : Computable (fun z : Code × (Code × α × ℕ) => z.2.2.1) := fst.comp (snd.comp snd) + let n : Computable (fun z : Code × (Code × α × ℕ) => z.2.2.2) := snd.comp (snd.comp snd) + have hc : Partrec₂ (fun z : Code × (Code × α × ℕ) => fun (k : ℕ) => + z.1.eval (encode (first z.2.1,z.2.2.1,k))) := + Nat.Partrec.Code.eval_part.comp (fst.comp fst) + (Computable.encode.comp (((first_primrec.to_comp.comp e).comp fst).pair + ((a.comp fst).pair snd))) + have hd : Partrec₂ (fun z : Code × (Code × α × ℕ) => fun (k : ℕ) => + z.1.eval (encode (second z.2.1,z.2.2.1,k))) := + Nat.Partrec.Code.eval_part.comp (fst.comp fst) + (Computable.encode.comp (((second_primrec.to_comp.comp e).comp fst).pair + ((a.comp fst).pair snd))) + have ht (i : ℕ) : Computable (fun z : Code × (Code × α × ℕ) => tag z.2.1 == i) := + (Primrec.beq.comp (tag_primrec.comp (Primrec.fst.comp Primrec.snd)) (Primrec.const i)).to_comp + have hq : Computable (fun z : Code × (Code × α × ℕ) => first z.2.1 == Nat.Partrec.Code.zero) := + (Primrec.beq.comp (first_primrec.comp (Primrec.fst.comp Primrec.snd)) (Primrec.const Nat.Partrec.Code.zero)).to_comp + have hpair : Partrec (fun z : Code × (Code × α × ℕ) => + Nat.pair <$> z.1.eval (encode (first z.2.1,z.2.2.1,z.2.2.2)) <*> + z.1.eval (encode (second z.2.1,z.2.2.1,z.2.2.2))) := by + change Partrec (fun z : Code × (Code × α × ℕ) => + (z.1.eval (encode (first z.2.1,z.2.2.1,z.2.2.2))).bind + (fun x => (z.1.eval (encode (second z.2.1,z.2.2.1,z.2.2.2))).map (Nat.pair x))) + apply Partrec.bind (hc.comp Computable.id n) + apply Partrec.map ((hd.comp Computable.id n).comp fst) + exact Primrec₂.natPair.to_comp.comp (snd.comp fst) snd + have hcomp : Partrec (fun z : Code × (Code × α × ℕ) => + (z.1.eval (encode (second z.2.1,z.2.2.1,z.2.2.2))).bind + (fun k => z.1.eval (encode (first z.2.1,z.2.2.1,k)))) := (hd.comp Computable.id n).bind (hc.comp fst snd) + have hprev : Partrec (fun z : Code × (Code × α × ℕ) => + z.1.eval (encode (z.2.1,z.2.2.1,Nat.pair (Nat.unpair z.2.2.2).1 ((Nat.unpair z.2.2.2).2-1)))) := + Nat.Partrec.Code.eval_part.comp fst (Computable.encode.comp (e.pair (a.pair + (Primrec₂.natPair.to_comp.comp ((fst.comp Computable.unpair).comp n) + (Computable.pred.comp ((snd.comp Computable.unpair).comp n)))))) + have hnext : Partrec (fun z : (Code × (Code × α × ℕ)) × ℕ => + z.1.1.eval (encode (second z.1.2.1,z.1.2.2.1, + Nat.pair (Nat.unpair z.1.2.2.2).1 (Nat.pair ((Nat.unpair z.1.2.2.2).2-1) z.2)))) := + hd.comp fst (Primrec₂.natPair.to_comp.comp (((fst.comp Computable.unpair).comp n).comp fst) + (Primrec₂.natPair.to_comp.comp ((Computable.pred.comp ((snd.comp Computable.unpair).comp n)).comp fst) snd)) + have hzero : Computable (fun z : Code × (Code × α × ℕ) => (Nat.unpair z.2.2.2).2 == 0) := + (Primrec.beq.comp (Primrec.snd.comp (Primrec.unpair.comp (Primrec.snd.comp (Primrec.snd.comp Primrec.snd)))) + (Primrec.const 0)).to_comp + have hbase : Partrec (fun z : Code × (Code × α × ℕ) => + z.1.eval (encode (first z.2.1,z.2.2.1,(Nat.unpair z.2.2.2).1))) := + hc.comp Computable.id ((fst.comp Computable.unpair).comp n) + have hsucc : Partrec (fun z : Code × (Code × α × ℕ) => + (z.1.eval (encode (z.2.1,z.2.2.1,Nat.pair (Nat.unpair z.2.2.2).1 ((Nat.unpair z.2.2.2).2-1)))).bind + (fun v => z.1.eval (encode (second z.2.1,z.2.2.1, + Nat.pair (Nat.unpair z.2.2.2).1 (Nat.pair ((Nat.unpair z.2.2.2).2-1) v))))) := hprev.bind hnext + have hprec := partrec_cond hzero hbase hsucc + have hfind : Partrec (fun z : Code × (Code × α × ℕ) => + Nat.rfind (fun k => (fun b => b = 0) <$> z.1.eval (encode (first z.2.1,z.2.2.1,Nat.pair z.2.2.2 k)))) := Partrec.rfind ((hc.comp fst + (Primrec₂.natPair.to_comp.comp (n.comp fst) snd)).map + ((Primrec.beq.comp Primrec.snd (Primrec.const 0)).to_comp)) + have h := partrec_cond (ht 0) (Computable.const 0).partrec + (partrec_cond (ht 1) (Computable.succ.comp n).partrec + (partrec_cond (ht 2) ((fst.comp Computable.unpair).comp n).partrec + (partrec_cond (ht 3) ((snd.comp Computable.unpair).comp n).partrec + (partrec_cond (ht 4) hpair (partrec_cond (ht 5) hcomp + (partrec_cond (ht 6) hprec (partrec_cond hq (hg.comp a n) hfind))))))) + exact h.of_eq (fun z => by simp only [layer,beq_iff_eq]; rfl) + +theorem eval_partrec (hg : Partrec₂ g) : + Partrec (fun z : Code × α × ℕ => OracleCode.eval (g z.2.1) (meaning z.1) z.2.2) := by + obtain ⟨c,hc⟩ := partrec_fixed_point (layer_partrec g hg) + have he : ∀ e a n, c.eval (encode (e,a,n)) = OracleCode.eval (g a) (meaning e) n := by + intro e + induction e with + | zero | succ | left | right => intros; rw [hc]; rfl + | pair e f he hf | comp e f he hf => + intro a n + rw [hc] + simp only [layer,tag,first,second,meaning,OracleCode.eval,he,hf] + simp <;> rfl + | prec e f he hf => + intro a n + have hn : ∃ u k, n = Nat.pair u k := ⟨_,_,(Nat.pair_unpair n).symm⟩ + obtain ⟨u,k,rfl⟩ := hn + induction k with + | zero => + rw [hc] + simp only [layer,tag,first,second,meaning,Nat.unpair_pair] + simp only [show (6 : ℕ) ≠ 0 from by decide,show (6 : ℕ) ≠ 1 from by decide, + show (6 : ℕ) ≠ 2 from by decide,show (6 : ℕ) ≠ 3 from by decide, + show (6 : ℕ) ≠ 4 from by decide,show (6 : ℕ) ≠ 5 from by decide,↓reduceIte] + rw [he] + simp only [OracleCode.eval,Nat.unpair_pair,Nat.rec_zero] + | succ k ih => + rw [hc] + simp only [layer,tag,first,second,meaning,he,hf,Nat.unpair_pair] + simp only [show (6 : ℕ) ≠ 0 from by decide,show (6 : ℕ) ≠ 1 from by decide, + show (6 : ℕ) ≠ 2 from by decide,show (6 : ℕ) ≠ 3 from by decide, + show (6 : ℕ) ≠ 4 from by decide,show (6 : ℕ) ≠ 5 from by decide, + ↓reduceIte,Nat.add_one_ne_zero,Nat.add_sub_cancel] + rw [ih] + simp only [meaning,OracleCode.eval,Nat.unpair_pair] + | rfind' e he => + intro a n + rw [hc] + simp only [layer,tag,first,meaning,he] + simp + split <;> rfl + exact (Nat.Partrec.Code.eval_part.comp (Computable.const c) Computable.encode).of_eq + (fun z => he z.1 z.2.1 z.2.2) + +end TuringRigidity.UniformProgram + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformPrograms.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformPrograms.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7f391fff049de02e06de3fda05b9777fe5bb3d3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformPrograms.lean @@ -0,0 +1,157 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformOracle + +namespace OAI + +namespace TuringRigidity.UniformPrograms +open Encodable + +def Runs {X : Type*} (O : X → ℕ →. ℕ) (f : X → ℕ →. ℕ) : Prop := + ∃ p : OracleCode, ∀ x, OracleCode.eval (O x) p = f x + +variable {X : Type*} {O : X → ℕ →. ℕ} + +theorem oracle_free {f : ℕ →. ℕ} (hf : Nat.RecursiveIn ∅ f) : + ∃ p : OracleCode, ∀ g, OracleCode.eval g p = f := by + induction hf with + | zero => exact ⟨.zero,fun _ => rfl⟩ + | succ => exact ⟨.succ,fun _ => rfl⟩ + | left => exact ⟨.left,fun _ => rfl⟩ + | right => exact ⟨.right,fun _ => rfl⟩ + | oracle f hf => simp at hf + | pair _ _ hc hd => + obtain ⟨c,hc⟩ := hc; obtain ⟨d,hd⟩ := hd + exact ⟨.pair c d,fun g => by simp only [OracleCode.eval,hc g,hd g]; rfl⟩ + | comp _ _ hc hd => + obtain ⟨c,hc⟩ := hc; obtain ⟨d,hd⟩ := hd + exact ⟨.comp c d,fun g => by simp only [OracleCode.eval,hc g,hd g]; rfl⟩ + | prec _ _ hc hd => + obtain ⟨c,hc⟩ := hc; obtain ⟨d,hd⟩ := hd + exact ⟨.prec c d,fun g => by simp only [OracleCode.eval,hc g,hd g]; rfl⟩ + | rfind _ hc => + obtain ⟨c,hc⟩ := hc + exact ⟨.find c,fun g => by simp only [OracleCode.eval,hc g]; rfl⟩ + +theorem primrec {f : ℕ → ℕ} (hf : Primrec f) : Runs O (fun _ n => Part.some (f n)) := by + obtain ⟨p,hp⟩ := oracle_free (RecursiveIn.iff_nat.mp (hf.computableIn (O := ∅))) + exact ⟨p,fun x => hp (O x)⟩ + +theorem query : Runs O O := ⟨.query,fun _ => rfl⟩ + +theorem Runs.of_eq {f g : X → ℕ →. ℕ} (hf : Runs O f) (h : ∀ x n, f x n = g x n) : Runs O g := by + obtain ⟨p,hp⟩ := hf + exact ⟨p,fun x => (hp x).trans (funext (h x))⟩ + +theorem Runs.pair {f g : X → ℕ →. ℕ} (hf : Runs O f) (hg : Runs O g) : + Runs O (fun x n => Nat.pair <$> f x n <*> g x n) := by + obtain ⟨p,hp⟩ := hf; obtain ⟨q,hq⟩ := hg + exact ⟨.pair p q,fun x => by simp only [OracleCode.eval,hp x,hq x]; rfl⟩ + +theorem Runs.comp {f g : X → ℕ →. ℕ} (hf : Runs O f) (hg : Runs O g) : + Runs O (fun x n => g x n >>= f x) := by + obtain ⟨p,hp⟩ := hf; obtain ⟨q,hq⟩ := hg + exact ⟨.comp p q,fun x => by simp only [OracleCode.eval,hp x,hq x]; rfl⟩ + +theorem Runs.prec {f g : X → ℕ →. ℕ} (hf : Runs O f) (hg : Runs O g) : + Runs O (fun x p => ((Nat.unpair p).2).rec (f x (Nat.unpair p).1) + (fun y ih => ih.bind (fun i => g x (Nat.pair (Nat.unpair p).1 (Nat.pair y i))))) := by + obtain ⟨p,hp⟩ := hf; obtain ⟨q,hq⟩ := hg + exact ⟨.prec p q,fun x => by simp only [OracleCode.eval,hp x,hq x]; rfl⟩ + +theorem Runs.find {f : X → ℕ →. ℕ} (hf : Runs O f) : + Runs O (fun x a => Nat.rfind (fun n => (fun m => decide (m=0)) <$> f x (Nat.pair a n))) := by + obtain ⟨p,hp⟩ := hf + exact ⟨.find p,fun x => by simp only [OracleCode.eval,hp x]; rfl⟩ + +theorem total_comp {f g : X → ℕ → ℕ} + (hf : Runs O (fun x n => Part.some (f x n))) + (hg : Runs O (fun x n => Part.some (g x n))) : + Runs O (fun x n => Part.some (f x (g x n))) := by + simpa using hf.comp hg + +theorem total_pair {f g : X → ℕ → ℕ} + (hf : Runs O (fun x n => Part.some (f x n))) + (hg : Runs O (fun x n => Part.some (g x n))) : + Runs O (fun x n => Part.some (Nat.pair (f x n) (g x n))) := by + simpa [Seq.seq] using hf.pair hg + +theorem initial_program (g : X → ℕ → ℕ) + (hquery : Runs O (fun x n => Part.some (g x n))) : + Runs O (fun x m => Part.some (encode (UniformOracle.oraclePrefix (g x) m))) := by + have hy := (primrec (O := O)) (Primrec.fst.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hi := (primrec (O := O)) (Primrec.snd.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hs := total_comp ((primrec (O := O)) (UniformOracle.appendEncoded_primrec.comp + (Primrec.fst.comp Primrec.unpair) (Primrec.snd.comp Primrec.unpair))) + (total_pair hi (total_comp hquery hy)) + have hp := Runs.prec ((primrec (O := O)) (Primrec.const (encode ([] : List ℕ)))) hs + have hh := Runs.comp hp (total_pair ((primrec (O := O)) (Primrec.const 0)) + ((primrec (O := O)) Primrec.id)) + apply hh.of_eq + intro x n + change (Part.some (Nat.pair 0 n)).bind _ = _ + rw [Part.bind_some] + simp only [Nat.unpair_pair] + induction n with + | zero => rfl + | succ n ih => + simp only [ih] + simp [UniformOracle.appendEncoded,UniformOracle.oraclePrefix,List.range_succ] + +private def flag (e : ℕ) : ℕ := + if ((decode (α := Option ℕ) e).getD none).isSome then 0 else 1 +private def answer (e : ℕ) : ℕ := ((decode (α := Option ℕ) e).getD none).getD 0 + +private theorem flag_primrec : Primrec flag := by + apply (Primrec.cond (Primrec.option_isSome.comp (Primrec.option_getD_default.comp (Primrec.decode (α := Option ℕ)))) + (Primrec.const 0) (Primrec.const 1)).of_eq + intro n + change (cond ((decode (α := Option ℕ) n).getD none).isSome 0 1) = _ + cases hh : ((decode (α := Option ℕ) n).getD none).isSome <;> simp only [flag,hh] <;> rfl +private theorem answer_primrec : Primrec answer := + Primrec.option_getD_default.comp (Primrec.option_getD_default.comp Primrec.decode) + +theorem total_search {E : X → ℕ → ℕ → Option ℕ} + (hE : Runs O (fun x z => Part.some (encode (E x (Nat.unpair z).1 (Nat.unpair z).2)))) + (f : X → ℕ → ℕ) (hsound : ∀ x n m a, a ∈ E x n m → a = f x n) + (hcomplete : ∀ x n, ∃ m a, a ∈ E x n m) : + Runs O (fun x n => Part.some (f x n)) := by + have hflag := total_comp (primrec flag_primrec) hE + have hfind := Runs.find hflag + have hpair := Runs.pair (primrec Primrec.id) hfind + have hrun := Runs.comp (primrec answer_primrec) (Runs.comp hE hpair) + apply hrun.of_eq + intro x n + apply Part.eq_some_iff.mpr + have hex : ∃ m, (E x n m).isSome = true := by + obtain ⟨m,a,ha⟩ := hcomplete x n + exact ⟨m,Option.isSome_iff_exists.mpr ⟨a,ha⟩⟩ + let m := Nat.find hex + have hm := Nat.find_spec hex + obtain ⟨a,ha⟩ := Option.isSome_iff_exists.mp hm + have hval : a = f x n := hsound x n m a ha + have hmem : m ∈ Nat.rfind (fun k => + (fun v : ℕ => decide (v=0)) <$> Part.some (flag (encode (E x n k)))) := by + apply Nat.mem_rfind.mpr + constructor + · simp [flag,m,hm] + · intro k hk + have hk' : (E x n k).isSome = false := Bool.eq_false_iff.mpr (Nat.find_min hex hk) + simp [flag,hk'] + apply Part.mem_bind_iff.mpr + refine ⟨encode (E x n m),?_,?_⟩ + · apply Part.mem_bind_iff.mpr + refine ⟨Nat.pair n m,?_,?_⟩ + · simp only [Seq.seq] + apply Part.mem_bind_iff.mpr + refine ⟨Nat.pair n,(Part.mem_map_iff _).mpr ⟨n,Part.mem_some _,rfl⟩,?_⟩ + exact (Part.mem_map_iff _).mpr ⟨m,by simpa only [Nat.unpair_pair] using hmem,rfl⟩ + · simp + · have hea : E x n m = some a := Option.mem_def.mp ha + apply Part.mem_some_iff.mpr + rw [hea] + simpa only [answer,Encodable.encodek,Option.getD_some] using hval.symm + +end TuringRigidity.UniformPrograms + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformRun.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformRun.lean new file mode 100644 index 0000000000000000000000000000000000000000..33ed4a8da7846fcbfe047dbbd1640dbb3542073a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformRun.lean @@ -0,0 +1,137 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformProgram +import OAI.Computability.DegreeRigidity.CohenForcing.CohenRun + +namespace OAI + +namespace TuringRigidity.UniformRun +open Encodable Computable UniformOracle CommonIdeal ArithmeticHierarchy OracleJump EncodedForcing IndexMatrix +open UniformProgram + +def run (A : Oracle) (b e : Code) (p : List Bool) (n : ℕ) : Part ℕ := + OracleCode.eval (partialJoin (OracleCode.eval (oracleFunction A) (meaning b)) (table p)) (meaning e) n + +def finiteRun (z : List ℕ × Code × Code × List Bool × ℕ) : Part ℕ := + OracleCode.eval (partialJoin (OracleCode.eval (BranchMachine.lookup z.1) (meaning z.2.1)) + (table z.2.2.2.1)) (meaning z.2.2.1) z.2.2.2.2 + +private theorem eval_partialJoin_partrec {α : Type*} [Primcodable α] + {L : α → List ℕ} {b e : α → Code} {p : α → List Bool} {n : α → ℕ} + (hL : Computable L) (hb : Computable b) (he : Computable e) + (hp : Computable p) (hn : Computable n) : + Partrec (fun z => OracleCode.eval + (partialJoin (OracleCode.eval (BranchMachine.lookup (L z)) (meaning (b z))) (table (p z))) + (meaning (e z)) (n z)) := by + have hbase : Partrec₂ (fun z : α => OracleCode.eval (BranchMachine.lookup (L z)) (meaning (b z))) := + (UniformProgram.eval_partrec BranchMachine.lookup BranchMachine.lookup_partrec).comp + ((hb.comp fst).pair ((hL.comp fst).pair snd)) + have htable : Partrec₂ (fun z : α => table (p z)) := table_partrec.comp (hp.comp fst) snd + exact (UniformProgram.eval_partrec _ (BranchMachine.partialJoin_partrec hbase htable)).comp + (he.pair (Computable.id.pair hn)) + +theorem finiteRun_partrec : Partrec finiteRun := by + exact eval_partialJoin_partrec + (L := fun z : List ℕ × Code × Code × List Bool × ℕ => z.1) + (b := fun z => z.2.1) (e := fun z => z.2.2.1) + (p := fun z => z.2.2.2.1) (n := fun z => z.2.2.2.2) + fst (fst.comp snd) (fst.comp (snd.comp snd)) + (fst.comp (snd.comp (snd.comp snd))) (snd.comp (snd.comp (snd.comp snd))) + +theorem finiteRun_approximates (A : Oracle) (b e : Code) (p : List Bool) (n : ℕ) : + Approximates (run A b e p n) (fun m => finiteRun + (oraclePrefix (fun k => bit (A k)) m,b,e,p,n)) := by + apply OracleCode.eval_approximates + intro k + apply BranchMachine.partialJoin_approximates + · exact OracleCode.eval_approximates (prefix_approximates (fun k => bit (A k))) (meaning b) + · intro k; exact Approximates.const _ + +theorem run_represents (A : Oracle) (b e : OracleCode) (p : List Bool) (n : ℕ) : + run A (represent b) (represent e) p n = + OracleCode.eval (partialJoin (OracleCode.eval (oracleFunction A) b) (table p)) e n := by + simp only [run,represent_correct] + exact congrFun (represent_correct _ e) n + +theorem run_total_base {A Y : Oracle} {b e : OracleCode} + (hb : OracleCode.eval (oracleFunction A) b = oracleFunction Y) (p : List Bool) (n : ℕ) : + run A (represent b) (represent e) p n = CommonIdeal.run Y e p n := by + rw [run_represents,hb] + rfl + +theorem run_mono {A : Oracle} {b e : Code} {s t : List Bool} + (h : s <+: t) (n a : ℕ) (ha : a ∈ run A b e s n) : a ∈ run A b e t n := by + apply OracleCode.eval_mono (c := meaning e) (n := n) (a := a) ?_ ha + intro k v hv + cases hk : k.bodd with + | false => simpa [partialJoin,hk] using hv + | true => + exact table_mono h _ _ (by simpa [partialJoin,hk] using hv) |> + (fun hh => by simpa [partialJoin,hk] using hh) + +theorem run_table (A : Oracle) : ∃ d : Nat.Partrec.Code, + ∀ b e p n a, a ∈ run A b e (word p) n ↔ + ∃ z, a ∈ TableIndices.run A d (encode (b,e,word p,n)) z := by + obtain ⟨d,hd⟩ := partrec_code finiteRun_partrec + have hd' (L : List ℕ) (b e : Code) (p : List Bool) (n : ℕ) : + d.eval (Nat.pair (encode L) (encode (b,e,p,n))) = finiteRun (L,b,e,p,n) := hd (L,b,e,p,n) + refine ⟨d,fun b e p n a => ?_⟩ + have ha := finiteRun_approximates A b e (word p) n + constructor + · intro h + obtain ⟨m,hm⟩ := ha.2 a h + have hh := hm m le_rfl + dsimp only at hh + rw [← hd'] at hh + obtain ⟨t,ht⟩ := Nat.Partrec.Code.evaln_complete.mp hh + exact ⟨Nat.pair m t,by simpa only [TableIndices.run,trial,Nat.unpair_pair] using ht⟩ + · rintro ⟨z,hz⟩ + have hh := Nat.Partrec.Code.evaln_sound hz + rw [hd'] at hh + exact ha.1 (Nat.unpair z).1 a hh + +def Graph (A : Oracle) (v : ℕ) : Prop := + item v 4 ∈ run A (machine (item v 0)) (machine (item v 1)) (word (item v 2)) (item v 3) + +theorem graph_sigma (A : Oracle) : Sigma A 1 (Graph A) := by + obtain ⟨d,hd⟩ := run_table A + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let a (i : ℕ) := item_primrec.comp f (Primrec.const i) + have hinput := Primrec.encode.comp ((machine_primrec.comp (a 0)).pair + ((machine_primrec.comp (a 1)).pair ((word_primrec.comp (a 2)).pair (a 3)))) + have hr := total_comp (run_uniform_recursive A) (total_primrec + (Primrec₂.natPair.comp (Primrec.const (encode d)) (Primrec₂.natPair.comp hinput r))) + have heq : Primrec (fun v : ℕ => if (decode (α := Option ℕ) (Nat.unpair v).1).getD none = + some (Nat.unpair v).2 then 1 else 0) := + Primrec.ite (Primrec.eq.comp (Primrec.option_getD.comp (Primrec.decode.comp f) (Primrec.const none)) + (Primrec.option_some.comp r)) (Primrec.const 1) (Primrec.const 0) + have hcert : RecursivePred A (fun v => item (Nat.unpair v).1 4 ∈ + TableIndices.run A d (encode (machine (item (Nat.unpair v).1 0), + machine (item (Nat.unpair v).1 1),word (item (Nat.unpair v).1 2), + item (Nat.unpair v).1 3)) (Nat.unpair v).2) := by + exact (total_comp (total_primrec heq) (total_pair hr (total_primrec (a 4)))).of_eq + (fun v => by simp [Option.mem_def]) + apply Form.congr (exists_form (n := 0) hcert) + intro v + simp only [Graph,Nat.unpair_pair] + exact (hd _ _ _ _ _).symm + +theorem graph_sigma_of (A : Oracle) {b e p n a : ℕ → ℕ} + (hb : Primrec b) (he : Primrec e) (hp : Primrec p) (hn : Primrec n) (ha : Primrec a) : + Sigma A 1 (fun v => a v ∈ run A (machine (b v)) (machine (e v)) (word (p v)) (n v)) := by + have h := (graph_sigma A).comp (Primrec.encode.comp + (Primrec.list_cons.comp hb (Primrec.list_cons.comp he (Primrec.list_cons.comp hp + (Primrec.list_cons.comp hn (Primrec.list_cons.comp ha (Primrec.const []))))))) + simpa only [Graph,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ] using h + +theorem pair_coverage {A Y : Oracle} (hY : Reduces Y A) (e f : OracleCode) : + ∃ b i j : ℕ, ∀ p n, + run A (machine b) (machine i) p n = CommonIdeal.run Y e p n ∧ + run A (machine b) (machine j) p n = CommonIdeal.run Y f p n := by + obtain ⟨b,hb⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp hY + refine ⟨encode (represent b),encode (represent e),encode (represent f),fun p n => ?_⟩ + simp only [machine,encodek,Option.getD_some] + exact ⟨run_total_base hb p n,run_total_base hb p n⟩ + +end TuringRigidity.UniformRun + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformSplit.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformSplit.lean new file mode 100644 index 0000000000000000000000000000000000000000..e1e5ef411e6228926ed78cf9fa50e58c7082395c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformSplit.lean @@ -0,0 +1,150 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformRun +import OAI.Computability.DegreeRigidity.Effective.CodingSplitting + +namespace OAI + +namespace TuringRigidity.UniformSplit +open Encodable UniformOracle ArithmeticHierarchy OracleJump EncodedForcing EffectiveWitness IndexMatrix +open UniformProgram + +def base (x : ℕ) := machine (item x 0) +def program (x : ℕ) := machine (item x 1) +def start (x : ℕ) := word (item x 2) + +def SplitCert (A : Oracle) (v : ℕ) : Prop := + let x := (Nat.unpair v).1 + let w := (Nat.unpair v).2 + start x <+: word (item w 1) ∧ start x <+: word (item w 2) ∧ item w 3 ≠ item w 4 ∧ + item w 3 ∈ UniformRun.run A (base x) (program x) (word (item w 1)) (item w 0) ∧ + item w 4 ∈ UniformRun.run A (base x) (program x) (word (item w 2)) (item w 0) + +theorem splitCert_sigma (A : Oracle) : Sigma A 1 (SplitCert A) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let x (i : ℕ) := item_primrec.comp f (Primrec.const i) + let w (i : ℕ) := item_primrec.comp r (Primrec.const i) + have hp := EncodedForcing.prefix_recursive A (word_primrec.comp (x 2)) (word_primrec.comp (w 1)) + have hq := EncodedForcing.prefix_recursive A (word_primrec.comp (x 2)) (word_primrec.comp (w 2)) + have hn := recursive_primrecPred A ((Primrec.eq.comp (w 3) (w 4)).not) + have hl := UniformRun.graph_sigma_of A (x 0) (x 1) (w 1) (w 0) (w 3) + have hr := UniformRun.graph_sigma_of A (x 0) (x 1) (w 2) (w 0) (w 4) + exact (Form.raise (n := 0) (s := true) hp).and + ((Form.raise (n := 0) (s := true) hq).and ((Form.raise (n := 0) (s := true) hn).and (hl.and hr))) + +def PointCert (A : Oracle) (v : ℕ) : Prop := + let x := (Nat.unpair v).1 + let w := (Nat.unpair v).2 + let q := word (item w 1) + start x <+: q ∧ (start x).length ≤ item w 2 ∧ item w 2 < q.length ∧ item w 4 ≠ item w 5 ∧ + item w 4 ∈ UniformRun.run A (base x) (program x) q (item w 0) ∧ + item w 5 ∈ UniformRun.run A (base x) (program x) (q.set (item w 2) (item w 3).bodd) (item w 0) + +theorem pointCert_sigma (A : Oracle) : Sigma A 1 (PointCert A) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let x (i : ℕ) := item_primrec.comp f (Primrec.const i) + let w (i : ℕ) := item_primrec.comp r (Primrec.const i) + let p := word_primrec.comp (x 2) + let q := word_primrec.comp (w 1) + have hp := EncodedForcing.prefix_recursive A p q + have hlo := recursive_primrecPred A (Primrec.nat_le.comp (Primrec.list_length.comp p) (w 2)) + have hhi := recursive_primrecPred A (Primrec.nat_lt.comp (w 2) (Primrec.list_length.comp q)) + have hn := recursive_primrecPred A ((Primrec.eq.comp (w 4) (w 5)).not) + have hl := UniformRun.graph_sigma_of A (x 0) (x 1) (w 1) (w 0) (w 4) + have hr := UniformRun.graph_sigma_of A (x 0) (x 1) + (Primrec.encode.comp (Primrec.list_set.comp q ((w 2).pair (Primrec.nat_bodd.comp (w 3))))) + (w 0) (w 5) + unfold PointCert + simpa only [base,program,start,word,encodek,Option.getD_some] using + (Form.raise (n := 0) (s := true) hp).and ((Form.raise (n := 0) (s := true) hlo).and + ((Form.raise (n := 0) (s := true) hhi).and ((Form.raise (n := 0) (s := true) hn).and (hl.and hr)))) + +def ConvergesAbove (A : Oracle) (v : ℕ) : Prop := + let x := (Nat.unpair v).1 + let w := (Nat.unpair v).2 + ∃ q a, word (item w 1) <+: word q ∧ + a ∈ UniformRun.run A (base x) (program x) (word q) (item w 0) + +theorem convergesAbove_sigma (A : Oracle) : Sigma A 1 (ConvergesAbove A) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let x (i : ℕ) := item_primrec.comp (f.comp (f.comp f)) (Primrec.const i) + let w (i : ℕ) := item_primrec.comp (r.comp (f.comp f)) (Primrec.const i) + have hp := EncodedForcing.prefix_recursive A (word_primrec.comp (w 1)) (word_primrec.comp (r.comp f)) + have hh := UniformRun.graph_sigma_of A (x 0) (x 1) (r.comp f) (w 0) r + have h := ((Form.raise (n := 0) (s := true) hp).and hh).ex.ex + unfold ConvergesAbove + simpa only [base,program,Nat.unpair_pair] using h + +def DivCert (A : Oracle) (v : ℕ) : Prop := + start (Nat.unpair v).1 <+: word (item (Nat.unpair v).2 1) ∧ ¬ ConvergesAbove A v + +theorem divCert_recursive (A : Oracle) : RecursivePred (jump A) (DivCert A) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hp := EncodedForcing.prefix_recursive (jump A) + (word_primrec.comp (item_primrec.comp f (Primrec.const 2))) + (word_primrec.comp (item_primrec.comp r (Primrec.const 1))) + exact recursive_and hp (recursive_not (form_recursive (convergesAbove_sigma A))) + +def Accept (A : Oracle) (v : ℕ) : Prop := + let x := (Nat.unpair v).1 + let tag := (Nat.unpair (Nat.unpair v).2).1 + let w := (Nat.unpair (Nat.unpair v).2).2 + (tag = 0 ∧ ¬ ∃ z, SplitCert A (Nat.pair x z)) ∨ + (tag = 1 ∧ PointCert A (Nat.pair x w)) ∨ + (tag = 2 ∧ DivCert A (Nat.pair x w)) + +theorem accept_recursive (A : Oracle) : RecursivePred (jump A) (Accept A) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have ht (i : ℕ) := recursive_primrecPred (jump A) (Primrec.eq.comp (f.comp r) (Primrec.const i)) + have hn := recursive_comp (recursive_not (form_recursive (splitCert_sigma A).ex)) f + have hp := recursive_comp (form_recursive (pointCert_sigma A)) (Primrec₂.natPair.comp f (r.comp r)) + have hd := recursive_comp (divCert_recursive A) (Primrec₂.natPair.comp f (r.comp r)) + unfold Accept + apply Form.congr (n := 0) (s := true) (Form.or (n := 0) (s := true) (recursive_and (ht 0) hn) + (Form.or (n := 0) (s := true) (recursive_and (ht 1) hp) (recursive_and (ht 2) hd))) + intro v + rfl + +theorem accept_total (A : Oracle) : ∀ x, ∃ w, Accept A (Nat.pair x w) := by + intro x + by_cases hs : ∃ z, SplitCert A (Nat.pair x z) + · obtain ⟨z,hp,hq,hab,ha,hb⟩ := hs + simp only [Nat.unpair_pair] at hp hq hab ha hb + let f := fun w => UniformRun.run A (base x) (program x) w (item z 0) + have hs : CodingSplitting.OnePoint (start x) f ∨ + ∃ w, start x <+: w ∧ ∀ u v, v ∉ f (w ++ u) := by + by_cases hd : ∀ w, start x <+: w → ∃ u v, v ∈ f (w ++ u) + · exact Or.inl (CodingSplitting.onePoint_of_dense + (fun h v hv => UniformRun.run_mono h (item z 0) v hv) hd hp hq _ _ ha hb hab) + · right; push Not at hd; exact hd + rcases hs with hs | hd + · obtain ⟨q,m,b,a,c,hpq,hlo,hhi,hac,ha,hc⟩ := hs + refine ⟨Nat.pair 1 (encode [item z 0,encode q,m,CommonIdeal.bit b,a,c]),Or.inr (Or.inl ⟨by simp,?_⟩)⟩ + have hbit : (CommonIdeal.bit b).bodd = b := by cases b <;> rfl + simpa [PointCert,item,word,hbit,f] using + And.intro hpq (And.intro hlo (And.intro hhi (And.intro hac (And.intro ha hc)))) + · obtain ⟨q,hpq,hd⟩ := hd + refine ⟨Nat.pair 2 (encode [item z 0,encode q]),Or.inr (Or.inr ⟨by simp,?_,?_⟩)⟩ + · simpa [item,word] using hpq + · simp only [ConvergesAbove,Nat.unpair_pair,item,encodek,Option.getD_some, + List.getD_cons_zero,List.getD_cons_succ,word] + rintro ⟨r,a,hr,ha⟩ + obtain ⟨u,hu⟩ := hr + exact hd u a (hu ▸ ha) + · exact ⟨Nat.pair 0 0,Or.inl ⟨by simp,by simpa using hs⟩⟩ + +noncomputable def step (A : Oracle) : ℕ → ℕ := least (Accept A) (accept_total A) + +theorem step_recursive (A : Oracle) : + Nat.RecursiveIn {oracleFunction (jump A)} (fun x => Part.some (step A x)) := + least_recursive (accept_recursive A) (accept_total A) + +theorem step_spec (A : Oracle) (x : ℕ) : Accept A (Nat.pair x (step A x)) := + least_spec (Accept A) (accept_total A) x + +end TuringRigidity.UniformSplit + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Effective/UniformTableSimulation.lean b/lean/OAI/Computability/DegreeRigidity/Effective/UniformTableSimulation.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a6689f3b9889ddfeadebc531dd6e1860300047d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Effective/UniformTableSimulation.lean @@ -0,0 +1,59 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformJumpSimulation + +namespace OAI + + +namespace TuringRigidity.UniformPrograms +open Encodable CommonIdeal TableIndices IndexMatrix + +theorem table_program (d : ℕ) : + ∃ p : OracleCode, ∀ Y A : Oracle, Represents Y (machine d) A → + OracleCode.eval (oracleFunction Y) p = oracleFunction A := by + let X := {s : Oracle × Oracle // Represents s.1 (machine d) s.2} + let Y := fun s : X => s.val.1 + have hr := total_comp (run_program Y) (primrec + (Primrec₂.natPair.comp (Primrec.const d) Primrec.id)) + have hr' : Runs (fun s : X => oracleFunction (Y s)) (fun s v => + Part.some (encode (TableIndices.run s.val.1 (machine d) (Nat.unpair v).1 (Nat.unpair v).2))) := by + simpa only [Nat.unpair_pair,Y,id_eq] using hr + have hs : Runs (fun s => oracleFunction (Y s)) (fun s n => Part.some (bit (s.val.2 n))) := + UniformPrograms.total_search hr' (fun (s : X) n => bit (s.val.2 n)) + (fun (s : X) => s.property.1) (fun (s : X) => s.property.2) + obtain ⟨p,hp⟩ := hs + exact ⟨p,fun B A h => hp ⟨(B,A),h⟩⟩ + +theorem program_table (p : OracleCode) : + ∃ d : ℕ, ∀ Y A : Oracle, OracleCode.eval (oracleFunction Y) p = oracleFunction A → + Represents Y (machine d) A := by + have hf : Partrec₂ (fun L : List ℕ => fun n => OracleCode.eval (BranchMachine.lookup L) p n) := + OracleCode.eval_partrec BranchMachine.lookup_partrec p + obtain ⟨d,hd⟩ := partrec_code hf + have hd' : ∀ L n, d.eval (Nat.pair (encode L) n) = OracleCode.eval (BranchMachine.lookup L) p n := + fun L n => hd (L,n) + refine ⟨encode d,fun Y A he => ?_⟩ + have ha (n : ℕ) : Approximates (oracleFunction A n) + (fun m => d.eval (Nat.pair (encode (UniformOracle.oraclePrefix (fun k => bit (Y k)) m)) n)) := by + simp only [hd'] + rw [← he] + exact OracleCode.eval_approximates (UniformOracle.prefix_approximates (fun k => bit (Y k))) p n + rw [machine_encode] + constructor + · intro n z a hz + exact Part.mem_some_iff.mp ((ha n).1 (Nat.unpair z).1 a (Nat.Partrec.Code.evaln_sound hz)) + · intro n + obtain ⟨m,hm⟩ := (ha n).2 (bit (A n)) (Part.mem_some _) + obtain ⟨t,ht⟩ := Nat.Partrec.Code.evaln_complete.mp (hm m le_rfl) + exact ⟨Nat.pair m t,bit (A n),by simpa [TableIndices.run,UniformOracle.trial] using ht⟩ + +theorem Runs.table_simulation {X : Type*} {Y Z : X → Oracle} + (h : Runs (fun x => oracleFunction (Z x)) (fun x => oracleFunction (Y x))) (d : ℕ) : + ∃ e : ℕ, ∀ x : X, ∀ A : Oracle, Represents (Y x) (machine d) A → + Represents (Z x) (machine e) A := by + obtain ⟨p,hp⟩ := table_program d + obtain ⟨q,hq⟩ := h.simulate p + obtain ⟨e,he⟩ := program_table q + exact ⟨e,fun x A hA => he (Z x) A ((hq x).trans (hp (Y x) A hA))⟩ + +end TuringRigidity.UniformPrograms + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Main.lean b/lean/OAI/Computability/DegreeRigidity/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..e82b234e0219f58dc2d609278fe70985c80967e7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Main.lean @@ -0,0 +1,31 @@ +import OAI.Computability.DegreeRigidity.Representation.GlobalArithmeticGenericProgram +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenRequirements + +namespace OAI + + +namespace TuringRigidity.ManuscriptMain +open TransitiveNameModel BoundedSetTheory CountableForcing GenericIdentity OracleJump + +theorem generic_program_representation (π : Degree ≃o Degree) : GenericProgramRepresentation π := by + obtain ⟨R,p,_,hrep⟩ := RelativeConstructible.global_arithmetic_generic_program π + obtain ⟨M,hM,hT,hcount,_,_,hRM,_,_⟩ := + PrescribedFirstUncountable.prescribed_covering_model_with_omega_one π (fun _ => R) + let := hcount + have hP := sourceT_real_iterate M hM hT (hRM 0) 5 + obtain ⟨D,hD,hground⟩ := InternalCohen.ground_family M ⟨realCode.{0} R,hRM 0⟩ + refine ⟨D,hD,iterate R 5,p,?_⟩ + intro A hA + have ha := GroundArithmeticGeneric.ground_arithmetic M hM hT (fun _ => iterate R 5) + (fun _ => hP) A ((hground A).mp hA) + obtain ⟨ht,hπ⟩ := hrep A ha + exact ⟨value p (iterate R 5) A,(total_iff p (iterate R 5) A).mp ht,hπ⟩ + +theorem borel_representation : BorelRepresentation := + fun π => borel_of_generic_program π (generic_program_representation π) + +theorem rigidity : MainTheorem := main_of_representation borel_representation + +end TuringRigidity.ManuscriptMain + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Model.lean b/lean/OAI/Computability/DegreeRigidity/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..1458a5875274d5d61cd6ef464e9c4419c6fc7ff7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Model.lean @@ -0,0 +1,38 @@ +import Mathlib + +namespace OAI + +namespace TuringRigidity + +abbrev Oracle := ℕ → Bool + +def oracleFunction (A : Oracle) : ℕ →. ℕ := fun n => Part.some (if A n then 1 else 0) + +def Reduces (A B : Oracle) : Prop := TuringReducible (oracleFunction A) (oracleFunction B) + +instance : IsPreorder Oracle Reduces where + refl A := TuringReducible.refl (oracleFunction A) + trans _ _ _ h k := TuringReducible.trans h k + +def Degree := Antisymmetrization Oracle Reduces + +instance : PartialOrder Degree := + @instPartialOrderAntisymmetrization Oracle + { le := Reduces + lt A B := Reduces A B ∧ ¬ Reduces B A + lt_iff_le_not_ge _ _ := Iff.rfl + le_refl A := TuringReducible.refl (oracleFunction A) + le_trans _ _ _ h k := TuringReducible.trans h k } + +private instance oraclePreorder : Preorder Oracle where + le := Reduces + lt A B := Reduces A B ∧ ¬ Reduces B A + lt_iff_le_not_ge _ _ := Iff.rfl + le_refl A := TuringReducible.refl (oracleFunction A) + le_trans _ _ _ h k := TuringReducible.trans h k + +def MainTheorem : Prop := ∀ π : Degree ≃o Degree, ∀ a : Degree, π a = a + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CanonicalAdditionSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CanonicalAdditionSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..2893e6084ac311a83abbc4d3f72aa67f79ef942e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CanonicalAdditionSyntax.lean @@ -0,0 +1,115 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.CanonicalOmegaSyntax +import OAI.Computability.DegreeRigidity.SetModels.SetModelPairing + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SetModelArithmetic SetModelIteration +universe u + +def AdditionSystem (w d A : ZFSet.{u}) : Prop := + TransitiveNameModel.FunctionGraph d w A ∧ + (∃ z ∈ w, z = ∅ ∧ ∀ x ∈ w, ZFSet.pair (ZFSet.pair x z) x ∈ A) ∧ + ∀ x ∈ w, ∀ y ∈ w, ∀ v ∈ w, + ZFSet.pair (ZFSet.pair x y) v ∈ A → + ∀ y' ∈ w, ∀ v' ∈ w, y' = insert y y → v' = insert v v → + ZFSet.pair (ZFSet.pair x y') v' ∈ A + +theorem additionSet_members (z : ZFSet.{u}) : + z ∈ additionSet ↔ ∃ n m, z = ZFSet.pair (ZFSet.pair (natSet n) (natSet m)) (natSet (n+m)) := by + rw [additionSet,mem_iterationSet setSucc setSucc_omega] + constructor + · rintro ⟨n,x,hx,hz⟩ + obtain ⟨m,rfl⟩ := (mem_omega x).mp hx + exact ⟨n,m,by simpa only [iterate_setSucc,Nat.add_comm] using hz⟩ + · rintro ⟨n,m,rfl⟩ + exact ⟨n,natSet m,(mem_omega _).mpr ⟨m,rfl⟩,by rw [iterate_setSucc,Nat.add_comm]⟩ + +theorem additionSet_function : TransitiveNameModel.FunctionGraph pairNumbers.{u} ZFSet.omega additionSet := by + constructor + · intro z hz + obtain ⟨n,m,rfl⟩ := (additionSet_members z).mp hz + exact ⟨_,natPair_mem n m,_,(mem_omega _).mpr ⟨n+m,rfl⟩,rfl⟩ + · intro x hx + obtain ⟨a,ha,b,hb,rfl⟩ := ZFSet.mem_prod.mp hx + obtain ⟨n,rfl⟩ := (mem_omega a).mp ha + obtain ⟨m,rfl⟩ := (mem_omega b).mp hb + refine ⟨natSet (n+m),(mem_omega _).mpr ⟨n+m,rfl⟩,(addition_code n m _).mpr rfl,?_⟩ + intro z hz hpair + obtain ⟨k,rfl⟩ := (mem_omega z).mp hz + exact congrArg natSet ((addition_code n m k).mp hpair) + +theorem additionSystem_canonical : AdditionSystem ZFSet.omega pairNumbers.{u} additionSet := by + refine ⟨additionSet_function,⟨natSet 0,(mem_omega _).mpr ⟨0,rfl⟩,rfl,?_⟩,?_⟩ + · intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + exact (addition_code n 0 n).mpr (Nat.add_zero n).symm + · intro x hx y hy v hv hp y' _ v' _ hy' hv' + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + obtain ⟨m,rfl⟩ := (mem_omega y).mp hy + obtain ⟨k,rfl⟩ := (mem_omega v).mp hv + subst y'; subst v' + change ZFSet.pair (ZFSet.pair (natSet n) (natSet (m+1))) (natSet (k+1)) ∈ additionSet + exact (addition_code n (m+1) (k+1)).mpr (by have hk := (addition_code n m k).mp hp; omega) + +theorem AdditionSystem.exact {A : ZFSet.{u}} (h : AdditionSystem ZFSet.omega pairNumbers A) : + A = additionSet := by + have hn (n : ℕ) : natSet.{u} n ∈ ZFSet.omega := (mem_omega _).mpr ⟨n,rfl⟩ + have computes (n m : ℕ) : ZFSet.pair (ZFSet.pair (natSet n) (natSet m)) (natSet (n+m)) ∈ A := by + induction m with + | zero => + obtain ⟨z,_,rfl,hzero⟩ := h.2.1 + simpa only [Nat.add_zero,natSet] using hzero _ (hn n) + | succ m ih => + have hs := h.2.2 _ (hn n) _ (hn m) _ (hn (n+m)) ih _ (hn (m+1)) _ (hn (n+m+1)) rfl rfl + simpa only [Nat.add_succ] using hs + apply ZFSet.ext; intro z + constructor + · intro hz + obtain ⟨x,hx,y,hy,rfl⟩ := h.1.1 z hz + obtain ⟨a,ha,b,hb,rfl⟩ := ZFSet.mem_prod.mp hx + obtain ⟨n,rfl⟩ := (mem_omega a).mp ha + obtain ⟨m,rfl⟩ := (mem_omega b).mp hb + have eq := h.1.functional (natPair_mem n m) hz (computes n m) + rw [eq] + exact (addition_code n m _).mpr rfl + · intro hz + obtain ⟨n,m,rfl⟩ := (additionSet_members z).mp hz + exact computes n m + +def additionSystemFormula (w d A : ℕ) : Formula := + .conj (.functionGraph A d w) + (.conj (.existsMem w (.conj (.empty 0) + (.allMem (w+1) (tripleFormula 0 1 0 (A+2) (d+2))))) + (.allMem w (.allMem (w+1) (.allMem (w+2) + (.imp (tripleFormula 2 1 0 (A+3) (d+3)) + (.allMem (w+3) (.allMem (w+4) + (.imp (.successor 1 3) (.imp (.successor 0 2) + (tripleFormula 4 1 0 (A+5) (d+5))))))))))) + +theorem additionSystemFormula_spec (w d A : ℕ) (e : ℕ → ZFSet.{u}) + (hd : e d = ZFSet.prod (e w) (e w)) : + (additionSystemFormula w d A).Eval e ↔ AdditionSystem (e w) (e d) (e A) := by + simp only [additionSystemFormula,AdditionSystem,Formula.Eval,Formula.eval_functionGraph, + Formula.eval_empty,Formula.eval_allMem,Formula.eval_imp,Formula.eval_successor, + eval_tripleFormula,cons_zero,cons_succ] + simp only [hd,ZFSet.pair_mem_prod] + constructor + · rintro ⟨hf,⟨z,hz,he,hzero⟩,hstep⟩ + exact ⟨hf,⟨z,hz,he,fun x hx => (hzero x hx).2⟩, + fun x hx y hy v hv hp y' hy' v' hv' hys hvs => + (hstep x hx y hy v hv ⟨⟨hx,hy⟩,hp⟩ y' hy' v' hv' hys hvs).2⟩ + · rintro ⟨hf,⟨z,hz,he,hzero⟩,hstep⟩ + exact ⟨hf,⟨z,hz,he,fun x hx => ⟨⟨hx,hz⟩,hzero x hx⟩⟩, + fun x hx y hy v hv hp y' hy' v' hv' hys hvs => + ⟨⟨hx,hy'⟩,hstep x hx y hy v hv hp.2 y' hy' v' hv' hys hvs⟩⟩ + +theorem additionSystemFormula_unique (w d A : ℕ) (e : ℕ → ZFSet.{u}) + (hw : e w = ZFSet.omega) (hd : e d = pairNumbers) : + (additionSystemFormula w d A).Eval e ↔ e A = additionSet := by + rw [additionSystemFormula_spec w d A e (by rw [hd,hw]; rfl),hw,hd] + exact ⟨AdditionSystem.exact,fun h => h ▸ additionSystem_canonical⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CanonicalOmegaSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CanonicalOmegaSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc1679a483cc3a3d8bd78a447b12527b4aea471f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CanonicalOmegaSyntax.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.Syntax.SentenceInlining +import OAI.Computability.DegreeRigidity.SetModels.SetModelAddition + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +def inductiveSetFormula (w : ℕ) : Formula := + .conj (.existsMem w (.empty 0)) + (.allMem w (.existsMem (w+1) (.successor 0 1))) + +theorem inductiveSetFormula_spec (w : ℕ) (e : ℕ → ZFSet.{u}) : + (inductiveSetFormula w).Eval e ↔ + (∅ : ZFSet) ∈ e w ∧ ∀ x ∈ e w, insert x x ∈ e w := by + simp only [inductiveSetFormula,Formula.Eval,Formula.eval_empty, + Formula.eval_allMem,Formula.eval_successor,cons_zero,cons_succ] + simp only [exists_eq_right] + +theorem omega_subset_inductive {W : ZFSet.{u}} + (h : (∅ : ZFSet) ∈ W ∧ ∀ x ∈ W, insert x x ∈ W) : ZFSet.omega ⊆ W := by + intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + clear hx + induction n with + | zero => exact h.1 + | succ n ih => exact h.2 _ ih + +noncomputable def canonicalOmega (w : ℕ) : SentenceForm := + .conj (fromBounded (inductiveSetFormula w)) + (SentenceForm.all (SentenceForm.imp (fromBounded (inductiveSetFormula 0)) + (fromBounded (.subset (w+1) 0)))) + +theorem canonicalOmega_spec (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (w : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (canonicalOmega w).Sat (M : Set ZFSet) e ↔ e w = ZFSet.omega := by + have habs (p : Formula) (x : ZFSet.{u}) (hx : x ∈ M) : + (fromBounded p).Sat (M : Set ZFSet) (cons x e) ↔ p.Eval (cons x e) := by + rw [bounded_sat,Formula.absolute p M hM _ + (by intro i; cases i; exact hx; exact he _)] + have hw : (∅ : ZFSet.{u}) ∈ ZFSet.omega ∧ + ∀ x ∈ ZFSet.omega.{u}, insert x x ∈ ZFSet.omega := + ⟨(mem_omega _).mpr ⟨0,rfl⟩,SetModelArithmetic.setSucc_omega⟩ + change ((fromBounded (inductiveSetFormula w)).Sat (M : Set ZFSet) e ∧ + (SentenceForm.all (SentenceForm.imp (fromBounded (inductiveSetFormula 0)) + (fromBounded (.subset (w+1) 0)))).Sat (M : Set ZFSet) e) ↔ _ + simp only [SentenceForm.sat_all,SentenceForm.sat_imp] + rw [bounded_sat,Formula.absolute _ M hM e he,inductiveSetFormula_spec] + have hmin : (∀ x ∈ (M : Set ZFSet), + (fromBounded (inductiveSetFormula 0)).Sat (M : Set ZFSet) (cons x e) → + (fromBounded (.subset (w+1) 0)).Sat (M : Set ZFSet) (cons x e)) ↔ + ∀ x ∈ M, ((∅ : ZFSet) ∈ x ∧ ∀ y ∈ x, insert y y ∈ x) → e w ⊆ x := by + apply forall_congr'; intro x + apply forall_congr'; intro hx + rw [habs _ x hx,habs _ x hx,inductiveSetFormula_spec,Formula.eval_subset] + rfl + rw [hmin] + constructor + · rintro ⟨hi,hminimal⟩ + exact ZFSet.ext fun x => ⟨fun hx => hminimal _ hω hw hx,fun hx => omega_subset_inductive hi hx⟩ + · intro h + rw [h] + exact ⟨hw,fun _ _ hi => omega_subset_inductive hi⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CanonicalRealsSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CanonicalRealsSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec1988b94324ae56a754b7c807ba635a00c863f5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CanonicalRealsSyntax.lean @@ -0,0 +1,47 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.CanonicalOmegaSyntax +import OAI.Computability.DegreeRigidity.Representation.AmbientDegreeSyntax +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleGroundReals + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def canonicalReals (r : ℕ) : SentenceForm := + .ex (.conj (canonicalOmega 0) (FullSetForcing.ownPower 0 (r+1))) + +theorem canonicalReals_spec (M : ZFSet.{u}) (hM : Transitive M) + (hw : ZFSet.omega.{u} ∈ M) + (r : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (canonicalReals r).Sat (M : Set ZFSet) e ↔ e r = groundReals M := by + have hc (w : ZFSet.{u}) (hwM : w ∈ M) : ∀ i, cons w e i ∈ M := by + intro i; cases i; exact hwM; exact he _ + have hpower : (FullSetForcing.ownPower 0 (r+1)).Sat (M : Set ZFSet) (cons ZFSet.omega e) ↔ + e r = groundReals M := by + rw [FullSetForcing.ownPower_spec M hM 0 (r+1) _ (hc _ hw)] + simp only [cons_succ,cons_zero] + constructor + · intro h + exact ZFSet.ext fun x => (h x).trans (mem_groundReals M x).symm + · intro h x + rw [h,mem_groundReals] + change (∃ w ∈ M, (canonicalOmega 0).Sat (M : Set ZFSet) (cons w e) ∧ + (FullSetForcing.ownPower 0 (r+1)).Sat (M : Set ZFSet) (cons w e)) ↔ _ + constructor + · rintro ⟨w,hwM,hwS,hp⟩ + obtain rfl := (canonicalOmega_spec M hM hw 0 _ (hc w hwM)).mp hwS + exact hpower.mp hp + · intro h + exact ⟨_,hw,(canonicalOmega_spec M hM hw 0 _ (hc _ hw)).mpr rfl,hpower.mpr h⟩ + +theorem groundReals_between (M N : ZFSet.{u}) (hN : Transitive N) + (hNM : N ⊆ M) (hR : groundReals M ∈ N) : groundReals N = groundReals M := by + apply ZFSet.ext; intro x + rw [mem_groundReals,mem_groundReals] + exact ⟨fun hx => ⟨hNM hx.1,hx.2⟩, + fun hx => ⟨hN _ hR x ((mem_groundReals M x).mpr hx),hx.2⟩⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CodeBranchCertificates.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CodeBranchCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a340ba11938c98c4ef3424379526791687699af --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CodeBranchCertificates.lean @@ -0,0 +1,82 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.CodeOperationCertificates +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalPairSyntax + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +def CodeBranchCertificates (M : ZFSet.{u}) (twice : Bool) (a b : Ordinal.{u}) : Prop := + (a+1).toZFSet ∈ M ∧ (Ordinal.omega0 ^ (a+1)).toZFSet ∈ M ∧ + (Ordinal.omega0 ^ b).toZFSet ∈ M ∧ + (codeScale twice (Ordinal.omega0 ^ (a+1))).toZFSet ∈ M ∧ + OmegaPowerCertificates M (a+1).toZFSet ∧ OmegaPowerCertificates M b.toZFSet ∧ + (twice = true → SumCertificates M (Ordinal.omega0 ^ (a+1)) (Ordinal.omega0 ^ (a+1))) ∧ + SumCertificates M (codeScale twice (Ordinal.omega0 ^ (a+1))) (Ordinal.omega0 ^ b) + +theorem CodeBranchCertificates.mono {M N : ZFSet.{u}} {twice : Bool} {a b : Ordinal.{u}} + (h : CodeBranchCertificates M twice a b) (hMN : M ⊆ N) : CodeBranchCertificates N twice a b := by + obtain ⟨hk,hu,hv,ht,hp,hq,hd,hs⟩ := h + exact ⟨hMN hk,hMN hu,hMN hv,hMN ht,hp.mono hMN,hq.mono hMN, + fun h => (hd h).mono hMN,hs.mono hMN⟩ + +theorem codeBranchSentence_of_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (twice : Bool) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (a b : Ordinal.{u}) (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) + (hcert : CodeBranchCertificates M twice a b) + (hc : e 0 = (codeBranchValue twice a b).toZFSet) : + (codeBranchSentence twice).Sat (M : Set ZFSet) e := by + obtain ⟨hk,hu,hv,ht,hp,hq,hd,hs⟩ := hcert + let k := (a+1).toZFSet + let u := (Ordinal.omega0 ^ (a+1)).toZFSet + let v := (Ordinal.omega0 ^ b).toZFSet + let t := (codeScale twice (Ordinal.omega0 ^ (a+1))).toZFSet + let E := cons t (cons v (cons u (cons k e))) + have hE : ∀ i, E i ∈ M := by + intro i; rcases i with _|_|_|_|i + exact ht; exact hv; exact hu; exact hk; exact he i + refine ⟨k,hk,u,hu,v,hv,t,ht,?_,?_,?_,?_,?_⟩ + · rw [bounded_sat,Formula.absolute _ M hM E hE,Formula.eval_successor] + change k = insert (e 1) (e 1) + rw [ha,← Ordinal.toZFSet_add_one] + · apply codePowerAt_of_certificates M hM hω 2 3 E hE hp + simp [E,u,k] + · apply codePowerAt_of_certificates M hM hω 1 6 E hE + · simpa only [E,cons_succ,hb] using hq + · simp [E,v,hb] + · exact codeScaleAt_of_certificates M hM hω twice 0 2 E hE _ rfl hd rfl + · exact codeSumAt_of_certificates M hM hω 4 0 1 E hE _ _ rfl rfl hs hc + +def PairCodeCertificates (M : ZFSet.{u}) (a b : Ordinal.{u}) : Prop := + if b ≤ a then CodeBranchCertificates M false a b else CodeBranchCertificates M true b a + +theorem PairCodeCertificates.mono {M N : ZFSet.{u}} {a b : Ordinal.{u}} + (h : PairCodeCertificates M a b) (hMN : M ⊆ N) : PairCodeCertificates N a b := by + unfold PairCodeCertificates at h ⊢ + split <;> rename_i hc + · exact (by simpa only [ite_eq_left hc] using h : CodeBranchCertificates M false a b).mono hMN + · exact (by simpa only [ite_eq_right hc] using h : CodeBranchCertificates M true b a).mono hMN + +theorem pairCodeSentence_of_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (a b : Ordinal.{u}) (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) + (hcert : PairCodeCertificates M a b) (hc : e 0 = (pairCode a b).toZFSet) : + pairCodeSentence.Sat (M : Set ZFSet) e := by + apply (pairCodeSentence_semantics M hM e he).mpr + refine ⟨⟨ha.symm ▸ ZFSet.isOrdinal_toZFSet _,hb.symm ▸ ZFSet.isOrdinal_toZFSet _⟩,?_⟩ + have hsub : e 2 ⊆ e 1 ↔ b ≤ a := by rw [ha,hb,Ordinal.toZFSet_subset_toZFSet_iff] + by_cases hle : b ≤ a + · left + refine ⟨hsub.mpr hle,codeBranchSentence_of_certificates M hM hω false e he a b ha hb ?_ ?_⟩ + · simpa only [PairCodeCertificates,ite_eq_left hle] using hcert + · simpa only [pairCode,ite_eq_left hle,codeBranchValue,codeScale,Bool.false_eq_true,↓reduceIte] using hc + · right + refine ⟨fun h => hle (hsub.mp h),codeBranchSentence_of_certificates M hM hω true + (fun i => e (if i = 0 then 0 else if i = 1 then 2 else 1)) (fun i => he _) b a hb ha ?_ ?_⟩ + · simpa only [PairCodeCertificates,ite_eq_right hle] using hcert + · simpa only [pairCode,ite_eq_right hle,codeBranchValue,codeScale,↓reduceIte] using hc + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CodeBranchLevels.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CodeBranchLevels.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9c363a83e76d8e5700d10416d87c9ad584aafaa --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CodeBranchLevels.lean @@ -0,0 +1,61 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.CodeBranchCertificates +import OAI.Computability.DegreeRigidity.OrdinalCodes.SumCertificateLevels +import OAI.Computability.DegreeRigidity.Constructibility.UniformOmegaLevels + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem codeBranch_certificates_at_levels (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (twice : Bool) (a b : Ordinal.{u}) (ha : a.toZFSet ∈ M) (hb : b.toZFSet ∈ M) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ ∀ δ : Ordinal.{u}, γ ≤ δ → + a.toZFSet ∈ level (groundReals M) δ ∧ b.toZFSet ∈ level (groundReals M) δ ∧ + (codeBranchValue twice a b).toZFSet ∈ level (groundReals M) δ ∧ + CodeBranchCertificates (level (groundReals M) δ) twice a b := by + have hk := internal_ordinal_succ M hM hT a ha + have hu := ordinal_omega_opow_internal M hM hT (a+1) hk + have hv := ordinal_omega_opow_internal M hM hT b hb + have ht := codeScale_internal M hM hT twice _ hu + obtain ⟨κ,hκ,hκL⟩ := omega_certificates_at_levels M hM hT (a+1) hk + obtain ⟨ℓ,hℓ,hℓL⟩ := omega_certificates_at_levels M hM hT b hb + obtain ⟨μ,hμ,hμL⟩ := sum_certificates_at_levels M hM hT _ _ hu hu + obtain ⟨ν,hν,hνL⟩ := sum_certificates_at_levels M hM hT _ _ ht hv + refine ⟨max (max κ ℓ) (max μ ν), + internal_ordinal_max M (internal_ordinal_max M hκ hℓ) (internal_ordinal_max M hμ hν),?_⟩ + intro δ hδ + have hkδ := (le_max_left κ ℓ).trans ((le_max_left (max κ ℓ) (max μ ν)).trans hδ) + have hlδ := (le_max_right κ ℓ).trans ((le_max_left (max κ ℓ) (max μ ν)).trans hδ) + have hmδ := (le_max_left μ ν).trans ((le_max_right (max κ ℓ) (max μ ν)).trans hδ) + have hnδ := (le_max_right μ ν).trans ((le_max_right (max κ ℓ) (max μ ν)).trans hδ) + obtain ⟨hkL,huL,hpc,_⟩ := hκL δ hkδ + obtain ⟨hbL,hvL,hqc,_⟩ := hℓL δ hlδ + obtain ⟨_,_,_,hdc⟩ := hμL δ hmδ + obtain ⟨htL,_,hcL,hsc⟩ := hνL δ hnδ + have haL := ordinal_le_internal (level_transitive _ _) hkL (lt_add_one a).le + exact ⟨haL,hbL,hcL,hkL,huL,hvL,htL,hpc,hqc,fun _ => hdc,hsc⟩ + +theorem pairCode_certificates_at_levels (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a b : Ordinal.{u}) (ha : a.toZFSet ∈ M) (hb : b.toZFSet ∈ M) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ ∀ δ : Ordinal.{u}, γ ≤ δ → + a.toZFSet ∈ level (groundReals M) δ ∧ b.toZFSet ∈ level (groundReals M) δ ∧ + (pairCode a b).toZFSet ∈ level (groundReals M) δ ∧ + PairCodeCertificates (level (groundReals M) δ) a b := by + by_cases hle : b ≤ a + · obtain ⟨γ,hγ,hL⟩ := codeBranch_certificates_at_levels M hM hT false a b ha hb + refine ⟨γ,hγ,?_⟩ + intro δ hδ + simpa only [pairCode,ite_eq_left hle,PairCodeCertificates,codeBranchValue,codeScale, + Bool.false_eq_true,↓reduceIte] using hL δ hδ + · obtain ⟨γ,hγ,hL⟩ := codeBranch_certificates_at_levels M hM hT true b a hb ha + refine ⟨γ,hγ,?_⟩ + intro δ hδ + obtain ⟨hbL,haL,hc,hcert⟩ := hL δ hδ + refine ⟨haL,hbL,?_,?_⟩ + · simpa only [pairCode,ite_eq_right hle,codeBranchValue,codeScale,↓reduceIte] using hc + · simpa only [PairCodeCertificates,ite_eq_right hle] using hcert + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CodeOperationCertificates.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CodeOperationCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a4aa343f52042ed7e0b179f313ed454cd63c26f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/CodeOperationCertificates.lean @@ -0,0 +1,44 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.SumCertificates + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem codePowerAt_of_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (y x : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hc : OmegaPowerCertificates M (e x)) (hy : e y = (Ordinal.omega0 ^ (e x).rank).toZFSet) : + (codePowerAt y x).Sat (M : Set ZFSet) e := by + rw [codePowerAt,SentenceForm.sat_rename] + exact omegaPowerSentence_of_certificates M hM hω _ (fun i => he _) hc hy + +theorem codeSumAt_of_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (c a b : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (α β : Ordinal.{u}) (ha : e a = α.toZFSet) (hb : e b = β.toZFSet) + (hc : SumCertificates M α β) (hy : e c = (α+β).toZFSet) : + (codeSumAt c a b).Sat (M : Set ZFSet) e := by + rw [codeSumAt,SentenceForm.sat_rename] + exact sumSentence_of_certificates M hM hω _ (fun i => he _) α β ha hb hc hy + + +theorem codeScaleAt_of_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (twice : Bool) (y x : ℕ) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (a : Ordinal.{u}) (ha : e x = a.toZFSet) + (hc : twice = true → SumCertificates M a a) (hy : e y = (codeScale twice a).toZFSet) : + (codeScaleAt twice y x).Sat (M : Set ZFSet) e := by + cases twice with + | false => exact hy.trans ha.symm + | true => + change (doubleSentence.rename (fun i => if i = 0 then y else x)).Sat (M : Set ZFSet) e + rw [SentenceForm.sat_rename] + rw [doubleSentence,SentenceForm.sat_rename] + exact sumSentence_of_certificates M hM hω + (fun i => e (if (if i = 0 then 0 else 1) = 0 then y else x)) + (fun i => he _) a a ha ha (hc rfl) + (by simpa only [codeScale,↓reduceIte,Ordinal.mul_two] using hy) + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexJoin.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexJoin.lean new file mode 100644 index 0000000000000000000000000000000000000000..b98685a73dcd93d36d1fe61f23f1715e79d66a5b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexJoin.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DegreeRigidity.Effective.TableIndices + +namespace OAI + +namespace TuringRigidity.IndexJoin +open Encodable Computable UniformOracle CommonIdeal TableIndices + +def dispatch (v : (Nat.Partrec.Code × Nat.Partrec.Code) × ℕ) : Part ℕ := + let n := (Nat.unpair v.2).2 + let c := if n.bodd then v.1.2 else v.1.1 + c.eval (Nat.pair (Nat.unpair v.2).1 (n / 2)) + +theorem dispatch_partrec : Partrec dispatch := by + let n : Computable (fun v : (Nat.Partrec.Code × Nat.Partrec.Code) × ℕ => (Nat.unpair v.2).2) := + snd.comp (Computable.unpair.comp snd) + have hc : Computable (fun v : (Nat.Partrec.Code × Nat.Partrec.Code) × ℕ => + cond (Nat.unpair v.2).2.bodd v.1.2 v.1.1) := + Computable.cond (Computable.nat_bodd.comp n) (snd.comp fst) (fst.comp fst) + have hi := Primrec₂.natPair.to_comp.comp (fst.comp (Computable.unpair.comp snd)) + ((Primrec.nat_div.comp Primrec.id (Primrec.const 2)).to_comp.comp n) + exact (Nat.Partrec.Code.eval_part.comp hc hi).of_eq (fun v => by + cases hb : (Nat.unpair v.2).2.bodd <;> simp [dispatch, hb]) + +noncomputable def dispatcher : Nat.Partrec.Code := Classical.choose (partrec_code dispatch_partrec) + +theorem dispatcher_spec (e f : Nat.Partrec.Code) (x : ℕ) : + dispatcher.eval (Nat.pair (encode (e, f)) x) = dispatch ((e, f), x) := + Classical.choose_spec (partrec_code dispatch_partrec) ((e, f), x) + +noncomputable def joined (e f : Nat.Partrec.Code) : Nat.Partrec.Code := + dispatcher.curry (encode (e, f)) + +theorem joined_primrec : Primrec₂ joined := + Nat.Partrec.Code.primrec₂_curry.comp (Primrec.const dispatcher) Primrec.encode + +theorem joined_eval (e f : Nat.Partrec.Code) (L : List ℕ) (n : ℕ) : + (joined e f).eval (Nat.pair (encode L) n) = + if n.bodd then f.eval (Nat.pair (encode L) (n/2)) else e.eval (Nat.pair (encode L) (n/2)) := by + rw [joined, Nat.Partrec.Code.eval_curry, dispatcher_spec] + simp only [dispatch, Nat.unpair_pair] + split <;> rfl + +theorem joined_represents {Y A B : Oracle} {e f : Nat.Partrec.Code} + (he : Represents Y e A) (hf : Represents Y f B) : + Represents Y (joined e f) (join A B) := by + have hs : ∀ n m a, a ∈ (joined e f).eval + (Nat.pair (encode (oraclePrefix (fun k => bit (Y k)) m)) n) → a = bit (join A B n) := by + intro n m a ha + rw [joined_eval] at ha + cases hb : n.bodd with + | false => + simp only [hb, Bool.false_eq_true, ↓reduceIte] at ha + obtain ⟨t, ht⟩ := Nat.Partrec.Code.evaln_complete.mp ha + have hh := he.1 (n/2) (Nat.pair m t) a (by simpa [TableIndices.run, trial] using ht) + simpa [join, hb] using hh + | true => + simp only [hb, ↓reduceIte] at ha + obtain ⟨t, ht⟩ := Nat.Partrec.Code.evaln_complete.mp ha + have hh := hf.1 (n/2) (Nat.pair m t) a (by simpa [TableIndices.run, trial] using ht) + simpa [join, hb] using hh + have ht : ∀ n, ∃ m a, a ∈ (joined e f).eval + (Nat.pair (encode (oraclePrefix (fun k => bit (Y k)) m)) n) := by + intro n + cases hb : n.bodd with + | false => + obtain ⟨z, a, ha⟩ := he.2 (n/2) + exact ⟨(Nat.unpair z).1, a, by + rw [joined_eval, hb] + exact Nat.Partrec.Code.evaln_sound ha⟩ + | true => + obtain ⟨z, a, ha⟩ := hf.2 (n/2) + exact ⟨(Nat.unpair z).1, a, by + rw [joined_eval, hb] + exact Nat.Partrec.Code.evaln_sound ha⟩ + refine ⟨?_, ?_⟩ + · intro n z a ha + exact hs n (Nat.unpair z).1 a (Nat.Partrec.Code.evaln_sound ha) + · intro n + obtain ⟨m, a, ha⟩ := ht n + obtain ⟨t, ht⟩ := Nat.Partrec.Code.evaln_complete.mp ha + exact ⟨Nat.pair m t, a, by simpa [TableIndices.run, trial] using ht⟩ + +end TuringRigidity.IndexJoin + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexMatrix.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..958247caa23dc4d0569993c8aed485157f9333b5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexMatrix.lean @@ -0,0 +1,126 @@ +import OAI.Computability.DegreeRigidity.Effective.TableIndices + +namespace OAI + +namespace TuringRigidity.IndexMatrix +open Encodable UniformOracle CommonIdeal TableIndices + +def machine (e : ℕ) : Nat.Partrec.Code := (decode e).getD .zero + +theorem machine_primrec : Primrec machine := + Primrec.option_getD.comp Primrec.decode (Primrec.const Nat.Partrec.Code.zero) + +@[simp] theorem machine_encode (d : Nat.Partrec.Code) : machine (encode d) = d := by + simp [machine] + +theorem run_uniform_recursive (Y : Oracle) : + Nat.RecursiveIn {oracleFunction Y} (fun v => Part.some + (encode (run Y (machine (Nat.unpair v).1) + (Nat.unpair (Nat.unpair v).2).1 (Nat.unpair (Nat.unpair v).2).2))) := by + let O : Set (ℕ →. ℕ) := {oracleFunction Y} + let e := Primrec.fst.comp Primrec.unpair + let rest := Primrec.snd.comp Primrec.unpair + let n := Primrec.fst.comp (Primrec.unpair.comp rest) + let z := Primrec.snd.comp (Primrec.unpair.comp rest) + have he := total_primrec (O := O) e + have hn := total_primrec (O := O) n + have hm := total_primrec (O := O) (Primrec.fst.comp (Primrec.unpair.comp z)) + have ht := total_primrec (O := O) (Primrec.snd.comp (Primrec.unpair.comp z)) + have hL := total_comp (prefix_recursive (fun k => bit (Y k))) hm + let r := Primrec.snd.comp Primrec.unpair + have hdecode := total_primrec (O := O) (Primrec.encode.comp (Nat.Partrec.Code.primrec_evaln.comp + (((Primrec.fst.comp Primrec.unpair).pair + (machine_primrec.comp (Primrec.fst.comp (Primrec.unpair.comp r)))).pair + (Primrec.snd.comp (Primrec.unpair.comp r))))) + exact (total_comp hdecode (total_pair ht (total_pair he (total_pair hL hn)))).of_eq + (fun v => by simp [TableIndices.run, trial]) + +def validMatrix (Y : Oracle) (e q r : ℕ) : Prop := + run Y (machine e) (Nat.unpair q).1 (Nat.unpair r).1 = + some (bit (Nat.unpair r).2.bodd) ∧ + let a := run Y (machine e) (Nat.unpair q).1 (Nat.unpair (Nat.unpair q).2).1 + let b := run Y (machine e) (Nat.unpair q).1 (Nat.unpair (Nat.unpair q).2).2 + a = none ∨ b = none ∨ a = b + +instance (Y : Oracle) (e q r : ℕ) : Decidable (validMatrix Y e q r) := by + unfold validMatrix + infer_instance + +theorem valid_normal_form (Y : Oracle) (e : ℕ) : + Valid Y (machine e) ↔ ∀ q, ∃ r, validMatrix Y e q r := by + constructor + · rintro ⟨ht, hc⟩ q + obtain ⟨z, b, hb⟩ := ht (Nat.unpair q).1 + refine ⟨Nat.pair z (if b then 1 else 0), ?_, ?_⟩ + · cases b <;> simpa [Nat.unpair_pair] using hb + · dsimp only + cases ha : run Y (machine e) (Nat.unpair q).1 (Nat.unpair (Nat.unpair q).2).1 with + | none => exact Or.inl rfl + | some a => + cases hb : run Y (machine e) (Nat.unpair q).1 (Nat.unpair (Nat.unpair q).2).2 with + | none => exact Or.inr (Or.inl rfl) + | some b => exact Or.inr (Or.inr (congrArg some + (hc _ _ _ _ _ (Option.mem_def.mpr ha) (Option.mem_def.mpr hb)))) + · intro h + constructor + · intro n + obtain ⟨r, hr, _⟩ := h (Nat.pair n (Nat.pair 0 0)) + exact ⟨(Nat.unpair r).1, (Nat.unpair r).2.bodd, by simpa using hr⟩ + · intro n z w a b ha hb + obtain ⟨r, _, hc⟩ := h (Nat.pair n (Nat.pair z w)) + simp only [Nat.unpair_pair] at hc + rcases hc with hc | hc | hc + · rw [hc] at ha; simp at ha + · rw [hc] at hb; simp at hb + · rw [Option.mem_def.mp ha, Option.mem_def.mp hb] at hc + exact Option.some.inj hc + +def checkMatrix (v : ℕ) : ℕ := + let wanted := (Nat.unpair v).1 + let s := (decode (α := Option ℕ) (Nat.unpair (Nat.unpair v).2).1).getD none + let a := (decode (α := Option ℕ) (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).1).getD none + let b := (decode (α := Option ℕ) (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).2).getD none + if s = some (bit wanted.bodd) ∧ (a = none ∨ b = none ∨ a = b) then 1 else 0 + +theorem checkMatrix_primrec : Primrec checkMatrix := by + let first := Primrec.fst.comp Primrec.unpair + let rest := Primrec.snd.comp Primrec.unpair + let dec : Primrec (fun v : ℕ => (decode (α := Option ℕ) v).getD none) := + Primrec.option_getD.comp Primrec.decode (Primrec.const none) + let s := dec.comp (first.comp rest) + let a := dec.comp (first.comp (rest.comp rest)) + let b := dec.comp (rest.comp (rest.comp rest)) + let want := Primrec.option_some.comp (bit_primrec.comp (Primrec.nat_bodd.comp first)) + exact Primrec.ite ((Primrec.eq.comp s want).and + (((Primrec.eq.comp a (Primrec.const none)).or (Primrec.eq.comp b (Primrec.const none))).or + (Primrec.eq.comp a b))) (Primrec.const 1) (Primrec.const 0) |>.of_eq (fun v => by + simp only [checkMatrix, or_assoc]) + +theorem validMatrix_recursive (Y : Oracle) : + Nat.RecursiveIn {oracleFunction Y} (fun v => Part.some + (if validMatrix Y (Nat.unpair v).1 (Nat.unpair (Nat.unpair v).2).1 + (Nat.unpair (Nat.unpair v).2).2 then 1 else 0)) := by + classical + let O : Set (ℕ →. ℕ) := {oracleFunction Y} + let fst := Primrec.fst.comp Primrec.unpair + let snd := Primrec.snd.comp Primrec.unpair + let e := fst + let q := fst.comp snd + let r := snd.comp snd + let n := fst.comp q + have mk : ∀ (f : ℕ → ℕ), Primrec f → Nat.RecursiveIn O + (fun v => Part.some (encode (run Y (machine (Nat.unpair v).1) + (Nat.unpair (Nat.unpair (Nat.unpair v).2).1).1 (f v)))) := by + intro f hf + have hin := total_pair (O := O) (total_primrec e) (total_pair (total_primrec n) (total_primrec hf)) + exact (total_comp (run_uniform_recursive Y) hin).of_eq (fun v => by simp) + have hs := mk _ (fst.comp r) + have ha := mk _ (fst.comp (snd.comp q)) + have hb := mk _ (snd.comp (snd.comp q)) + exact (total_comp (total_primrec checkMatrix_primrec) + (total_pair (total_primrec (snd.comp r)) (total_pair hs (total_pair ha hb)))).of_eq (fun v => by + simp [checkMatrix, validMatrix]) + +end TuringRigidity.IndexMatrix + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexPresentation.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e3330480e31da41aa531876e19b96f71e4217bb --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexPresentation.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.Effective.OrderMatrixRecursive +import OAI.Computability.DegreeRigidity.OrdinalCodes.IndexJoin + +namespace OAI + +namespace TuringRigidity.IndexPresentation +open Encodable TableIndices IndexMatrix OrderNormalForm + +abbrev Dom (Y : Oracle) (e : ℕ) := Valid Y (machine e) +def LE (Y : Oracle) (e f : ℕ) : Prop := ∃ d, ∀ q, ∃ r, orderMatrix Y e f d q r +noncomputable def joinIndex (e f : ℕ) : ℕ := encode (IndexJoin.joined (machine e) (machine f)) + +theorem joinIndex_primrec : Primrec₂ joinIndex := + Primrec.encode.comp (IndexJoin.joined_primrec.comp (machine_primrec.comp Primrec.fst) + (machine_primrec.comp Primrec.snd)) + +noncomputable def value (Y : Oracle) (e : ℕ) : Degree := by + classical + exact if h : Dom Y e then degree (output Y ⟨machine e, h⟩) else ⊥ + +theorem value_eq {Y A : Oracle} {e : ℕ} (h : Represents Y (machine e) A) : + value Y e = degree A := by + have hv : Dom Y e := (valid_iff_represents _ _).mpr ⟨A, h⟩ + simp only [value, dite_eq_left hv] + rw [represents_unique (output_represents _ _) h] + +theorem value_below (Y : Oracle) (e : ℕ) : value Y e ≤ degree Y := by + classical + by_cases h : Dom Y e + · simp only [value, dite_eq_left h] + exact represents_reduces (output_represents _ _) + · simp [value, h] + +theorem value_surjective (Y : Oracle) (x : Degree) (hx : x ≤ degree Y) : + ∃ e, Dom Y e ∧ value Y e = x := by + obtain ⟨A, rfl⟩ := degree_surjective x + obtain ⟨d, hd⟩ := reduces_represents hx + have hr : Represents Y (machine (encode d)) A := by simpa using hd + exact ⟨encode d, (valid_iff_represents _ _).mpr ⟨A, hr⟩, value_eq hr⟩ + +theorem le_iff {Y : Oracle} {e f : ℕ} (he : Dom Y e) (hf : Dom Y f) : + LE Y e f ↔ value Y e ≤ value Y f := by + rw [value_eq (output_represents Y ⟨machine e, he⟩), + value_eq (output_represents Y ⟨machine f, hf⟩)] + exact (order_normal_form (output_represents Y ⟨machine e, he⟩) (output_represents Y ⟨machine f, hf⟩)).symm + +theorem join_dom {Y : Oracle} {e f : ℕ} (he : Dom Y e) (hf : Dom Y f) : + Dom Y (joinIndex e f) := by + apply (valid_iff_represents _ _).mpr + refine ⟨join (output Y ⟨machine e, he⟩) (output Y ⟨machine f, hf⟩), ?_⟩ + simpa only [joinIndex, machine_encode] using + IndexJoin.joined_represents (output_represents Y ⟨machine e, he⟩) + (output_represents Y ⟨machine f, hf⟩) + +theorem join_value {Y : Oracle} {e f : ℕ} (he : Dom Y e) (hf : Dom Y f) : + value Y (joinIndex e f) = value Y e ⊔ value Y f := by + have hr : Represents Y (machine (joinIndex e f)) + (join (output Y ⟨machine e, he⟩) (output Y ⟨machine f, hf⟩)) := by + simpa only [joinIndex, machine_encode] using + IndexJoin.joined_represents (output_represents Y ⟨machine e, he⟩) + (output_represents Y ⟨machine f, hf⟩) + rw [value_eq hr, value_eq (output_represents Y ⟨machine e, he⟩), + value_eq (output_represents Y ⟨machine f, hf⟩)] + rfl + +end TuringRigidity.IndexPresentation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexTuples.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexTuples.lean new file mode 100644 index 0000000000000000000000000000000000000000..9617b418bbdd56f1876f95057f0c3b1e441dbad2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexTuples.lean @@ -0,0 +1,90 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.IndexPresentation +import Mathlib.Data.Finset.Lattice.Fold + +namespace OAI + +namespace TuringRigidity.IndexTuples +open Encodable IndexPresentation IndexMatrix TableIndices + +def entry : ℕ → ℕ → ℕ + | 0, t => (Nat.unpair t).1 + | i+1, t => entry i (Nat.unpair t).2 + +theorem entry_primrec (i : ℕ) : Primrec (entry i) := by + induction i with + | zero => exact Primrec.fst.comp Primrec.unpair + | succ i ih => exact ih.comp (Primrec.snd.comp Primrec.unpair) + +theorem tuple_surjective {n : ℕ} (v : Fin n → ℕ) : ∃ t, ∀ i, entry i.val t = v i := by + induction n with + | zero => exact ⟨0, fun i => Fin.elim0 i⟩ + | succ n ih => + obtain ⟨t, ht⟩ := ih (fun i => v i.succ) + refine ⟨Nat.pair (v 0) t, ?_⟩ + intro i + refine Fin.cases ?_ (fun j => ?_) i + · simp [entry] + · simpa only [Fin.val_succ, entry, Nat.unpair_pair] using ht j + +def zeroIndex : ℕ := encode Nat.Partrec.Code.zero + +theorem zero_represents (Y : Oracle) : Represents Y (machine zeroIndex) (fun _ => false) := by + simp only [zeroIndex, machine_encode] + constructor + · intro n z a ha + have h := Nat.Partrec.Code.evaln_sound ha + change a ∈ Part.some 0 at h + exact Part.mem_some_iff.mp h + · intro n + obtain ⟨t, ht⟩ := Nat.Partrec.Code.evaln_complete.mp + (show 0 ∈ Nat.Partrec.Code.zero.eval (Nat.pair (encode ([] : List ℕ)) n) from Part.mem_some 0) + refine ⟨Nat.pair 0 t, 0, ?_⟩ + simpa [TableIndices.run, UniformOracle.trial, UniformOracle.oraclePrefix] using ht + +theorem zero_dom (Y : Oracle) : Dom Y zeroIndex := + (valid_iff_represents _ _).mpr ⟨_, zero_represents Y⟩ + +theorem zero_value (Y : Oracle) : value Y zeroIndex = ⊥ := value_eq (zero_represents Y) + +noncomputable def supIndex : ℕ → ℕ → ℕ + | 0, _ => zeroIndex + | n+1, t => joinIndex ((Nat.unpair t).1) (supIndex n (Nat.unpair t).2) + +theorem supIndex_primrec (n : ℕ) : Primrec (supIndex n) := by + induction n with + | zero => exact Primrec.const _ + | succ n ih => + exact joinIndex_primrec.comp (Primrec.fst.comp Primrec.unpair) + (ih.comp (Primrec.snd.comp Primrec.unpair)) + +theorem sup_dom {Y : Oracle} {n t : ℕ} (h : ∀ i : Fin n, Dom Y (entry i.val t)) : + Dom Y (supIndex n t) := by + induction n generalizing t with + | zero => exact zero_dom Y + | succ n ih => exact join_dom (h 0) (ih (fun i => h i.succ)) + +theorem sup_value {Y : Oracle} {n t : ℕ} (h : ∀ i : Fin n, Dom Y (entry i.val t)) : + value Y (supIndex n t) = Finset.univ.sup (fun i : Fin n => value Y (entry i.val t)) := by + induction n generalizing t with + | zero => simp [supIndex, zero_value] + | succ n ih => + have h0 : Dom Y ((Nat.unpair t).1) := h 0 + rw [supIndex, join_value h0 (sup_dom (fun i : Fin n => h i.succ)), + ih (fun i : Fin n => h i.succ)] + apply le_antisymm + · apply sup_le + · exact Finset.le_sup (f := fun i : Fin (n+1) => value Y (entry i.val t)) (Finset.mem_univ 0) + · apply Finset.sup_le + intro i _ + exact Finset.le_sup (f := fun j : Fin (n+1) => value Y (entry j.val t)) + (Finset.mem_univ i.succ) + · apply Finset.sup_le + intro i _ + refine Fin.cases ?_ (fun j => ?_) i + · exact le_sup_left + · exact (Finset.le_sup (f := fun j : Fin n => value Y (entry j.val (Nat.unpair t).2)) + (Finset.mem_univ j)).trans le_sup_right + +end TuringRigidity.IndexTuples + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexedOrder.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexedOrder.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5a6bae383069e6cbb2a88d097a4ac3652c42211 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/IndexedOrder.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.IndexMatrix + +namespace OAI + +namespace TuringRigidity.IndexedOrder +open Encodable CommonIdeal UniformOracle TableIndices IndexMatrix + +def Reads (Y : Oracle) (e : Nat.Partrec.Code) (L : List (ℕ × ℕ)) : Prop := + ∀ j : Fin L.length, TableIndices.run Y e j.val (L[j].2) = some (L[j].1) + +def values (L : List (ℕ × ℕ)) : List ℕ := L.map Prod.fst + +theorem reads_values {Y A : Oracle} {e : Nat.Partrec.Code} + (he : Represents Y e A) (L : List (ℕ × ℕ)) (hL : Reads Y e L) : + values L = oraclePrefix (fun k => bit (A k)) L.length := by + apply List.ext_getElem + · simp [values, oraclePrefix] + · intro j hj hj' + have hjL : j < L.length := by simpa [values] using hj + have hh := he.1 j (L[j].2) (L[j].1) (Option.mem_def.mpr (hL ⟨j, by simpa [values] using hj⟩)) + simpa [values, oraclePrefix] using hh + +theorem exists_reads {Y A : Oracle} {e : Nat.Partrec.Code} + (he : Represents Y e A) (m : ℕ) : + ∃ L : List (ℕ × ℕ), L.length = m ∧ Reads Y e L := by + have hh : ∀ j, ∃ z, TableIndices.run Y e j z = some (bit (A j)) := by + intro j + obtain ⟨z, a, ha⟩ := he.2 j + exact ⟨z, by rw [← he.1 j z a ha]; exact Option.mem_def.mp ha⟩ + choose z hz using hh + let L := (List.range m).map (fun j => (bit (A j), z j)) + refine ⟨L, by simp [L], ?_⟩ + intro j + simpa [L] using hz j.val + +def Certificate (Y : Oracle) (e d : Nat.Partrec.Code) (n a z : ℕ) : Prop := + let L := (decode (α := List (ℕ × ℕ)) (Nat.unpair z).1).getD [] + Reads Y e L ∧ d.evaln (Nat.unpair z).2 (Nat.pair (encode (values L)) n) = some a + +theorem certificate_iff_run {Y A : Oracle} {e : Nat.Partrec.Code} + (he : Represents Y e A) (d : Nat.Partrec.Code) (n a : ℕ) : + (∃ z, Certificate Y e d n a z) ↔ ∃ z, TableIndices.run A d n z = some a := by + constructor + · rintro ⟨z, hL, hd⟩ + let L := (decode (α := List (ℕ × ℕ)) (Nat.unpair z).1).getD [] + refine ⟨Nat.pair L.length (Nat.unpair z).2, ?_⟩ + have hv := reads_values he L hL + change d.evaln (Nat.unpair z).2 (Nat.pair (encode (values L)) n) = some a at hd + simpa only [TableIndices.run, trial, Nat.unpair_pair, ← hv] using hd + · rintro ⟨z, hz⟩ + obtain ⟨L, hlen, hL⟩ := exists_reads he (Nat.unpair z).1 + refine ⟨Nat.pair (encode L) (Nat.unpair z).2, ?_⟩ + simp only [Certificate, Nat.unpair_pair, encodek, Option.getD_some] + refine ⟨hL, ?_⟩ + rw [reads_values he L hL, hlen] + exact hz + +def OrderWitness (Y : Oracle) (e₀ e₁ d : Nat.Partrec.Code) : Prop := + (∀ n a b z w, Certificate Y e₁ d n a z → Certificate Y e₁ d n b w → a = b) ∧ + ∀ n, ∃ a z w, Certificate Y e₁ d n a z ∧ TableIndices.run Y e₀ n w = some a + +theorem order_iff_witness {Y A₀ A₁ : Oracle} {e₀ e₁ : Nat.Partrec.Code} + (h₀ : Represents Y e₀ A₀) (h₁ : Represents Y e₁ A₁) : + Reduces A₀ A₁ ↔ ∃ d : Nat.Partrec.Code, OrderWitness Y e₀ e₁ d := by + constructor + · intro h + obtain ⟨d, hd⟩ := reduces_represents h + refine ⟨d, ?_, ?_⟩ + · intro n a b z w hz hw + obtain ⟨u, hu⟩ := (certificate_iff_run h₁ d n a).mp ⟨z, hz⟩ + obtain ⟨v, hv⟩ := (certificate_iff_run h₁ d n b).mp ⟨w, hw⟩ + exact (hd.1 n u a (Option.mem_def.mpr hu)).trans + (hd.1 n v b (Option.mem_def.mpr hv)).symm + · intro n + obtain ⟨u, a, hu⟩ := hd.2 n + obtain ⟨z, hz⟩ := (certificate_iff_run h₁ d n a).mpr ⟨u, Option.mem_def.mp hu⟩ + obtain ⟨w, b, hw⟩ := h₀.2 n + have hab : b = a := (h₀.1 n w b hw).trans (hd.1 n u a hu).symm + exact ⟨a, z, w, hz, by rw [← hab]; exact Option.mem_def.mp hw⟩ + · rintro ⟨d, hc, ht⟩ + apply represents_reduces (d := d) + constructor + · intro n u a hu + obtain ⟨z, hz⟩ := (certificate_iff_run h₁ d n a).mpr ⟨u, Option.mem_def.mp hu⟩ + obtain ⟨b, w, v, hw, hv⟩ := ht n + exact (hc n a b z w hz hw).trans (h₀.1 n v b (Option.mem_def.mpr hv)) + · intro n + obtain ⟨a, z, w, hz, _⟩ := ht n + obtain ⟨u, hu⟩ := (certificate_iff_run h₁ d n a).mp ⟨z, hz⟩ + exact ⟨u, a, Option.mem_def.mpr hu⟩ + +end TuringRigidity.IndexedOrder + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LargestOrdinalSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LargestOrdinalSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..012168e2c379003bcab5112897b0b050214b5524 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LargestOrdinalSyntax.lean @@ -0,0 +1,88 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.LevelOrdinalHeight + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def largestOrdinalSentence : SentenceForm := + .conj ordinalSentence (.all (.imp ordinalSentence (.disj (.member 0 1) (.equal 0 1)))) + +theorem largestOrdinalSentence_bound : largestOrdinalSentence.bound = 1 := by rfl + +theorem largestOrdinalSentence_spec (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : e 0 ∈ A) : + largestOrdinalSentence.Sat (A : Set ZFSet) e ↔ + (e 0).IsOrdinal ∧ ∀ x ∈ A, x.IsOrdinal → x ∈ e 0 ∨ x = e 0 := by + simp only [largestOrdinalSentence,SentenceForm.Sat,SentenceForm.sat_all, + SentenceForm.sat_imp,SentenceForm.sat_disj,cons_zero,cons_succ] + rw [ordinalSentence_spec A hA e he] + apply and_congr_right; intro _ + apply forall_congr'; intro x + apply forall_congr'; intro hx + rw [ordinalSentence_spec A hA (cons x e) hx] + rfl + +theorem largestOrdinalSentence_unique (A : ZFSet.{u}) (hA : Transitive A) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ A) + (hmax : ∀ b : Ordinal.{u}, b.toZFSet ∈ A → b ≤ a) + (e : ℕ → ZFSet.{u}) (he : e 0 ∈ A) : + largestOrdinalSentence.Sat (A : Set ZFSet) e ↔ e 0 = a.toZFSet := by + rw [largestOrdinalSentence_spec A hA e he] + constructor + · rintro ⟨ho,hm⟩ + have heq := ho.toZFSet_rank_eq + have hle := hmax (e 0).rank (by rwa [heq]) + have hge : a ≤ (e 0).rank := by + rcases hm a.toZFSet ha (ZFSet.isOrdinal_toZFSet a) with h|h + · rw [← heq,Ordinal.toZFSet_mem_toZFSet_iff] at h + exact h.le + · have := congrArg ZFSet.rank h + simpa only [Ordinal.rank_toZFSet] using this.le + exact heq.symm.trans (congrArg Ordinal.toZFSet (le_antisymm hle hge)) + · intro heq + refine ⟨heq ▸ ZFSet.isOrdinal_toZFSet a,?_⟩ + intro x hx ho + have hle : x.rank ≤ a := hmax x.rank (by rwa [ho.toZFSet_rank_eq]) + rcases lt_or_eq_of_le hle with h|h + · left + rw [heq,← ho.toZFSet_rank_eq] + exact Ordinal.toZFSet_mem_toZFSet_iff.mpr h + · right + rw [← ho.toZFSet_rank_eq,h,heq] + +theorem largestOrdinalSentence_level (R : ZFSet.{u}) (o : Ordinal.{u}) + (e : ℕ → ZFSet.{u}) (he : e 0 ∈ level R (o+1)) : + largestOrdinalSentence.Sat (level R (o+1) : Set ZFSet) e ↔ + e 0 = (ordinalHeight (seed R) + o).toZFSet := by + have hm := largest_ordinal_level_succ R o + exact largestOrdinalSentence_unique _ (level_transitive R _) _ hm.1 + (fun b hb => (hm.2 b).mp hb) e he + +noncomputable def bindLargestOrdinal (p : SentenceForm) : SentenceForm := + .ex (.conj largestOrdinalSentence p) + +theorem bindLargestOrdinal_bound (p : SentenceForm) : + (bindLargestOrdinal p).bound = p.bound - 1 := by + change max largestOrdinalSentence.bound p.bound - 1 = p.bound - 1 + rw [largestOrdinalSentence_bound] + omega + +theorem bindLargestOrdinal_level (p : SentenceForm) (R : ZFSet.{u}) (o : Ordinal.{u}) + (e : ℕ → ZFSet.{u}) : + (bindLargestOrdinal p).Sat (level R (o+1) : Set ZFSet) e ↔ + p.Sat (level R (o+1) : Set ZFSet) (cons (ordinalHeight (seed R) + o).toZFSet e) := by + change (∃ a ∈ level R (o+1), largestOrdinalSentence.Sat _ (cons a e) ∧ p.Sat _ (cons a e)) ↔ _ + constructor + · rintro ⟨a,ha,hm,hp⟩ + have heq := (largestOrdinalSentence_level R o (cons a e) ha).mp hm + change a = _ at heq + simpa only [heq] using hp + · intro hp + have hm := largest_ordinal_level_succ R o + exact ⟨_,hm.1,(largestOrdinalSentence_level R o _ hm.1).mpr rfl,hp⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LevelInlinedDefinition.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LevelInlinedDefinition.lean new file mode 100644 index 0000000000000000000000000000000000000000..6fb8daf7f075efb14170cb296ad7812e86028e0c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LevelInlinedDefinition.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructionStageBound +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModelPower +import OAI.Computability.DegreeRigidity.Constructibility.PersistentConstruction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SetModelArithmetic +open SetDegreeDecoding PersistentRestrictions +universe u + +theorem Construction.singleInputs_relative (t : Construction.{u}) (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (P : Oracle) + (hP : P ∈ modelReals M) (hi : t.Indexed M) : + ∀ i, t.singleInputs (groundReals M) P i ∈ relativeModel M (groundReals M) := by + let R := groundReals M + let N := relativeModel M R + have hR := groundReals_mem M hM hT + have hN := relativeModel_transitive M R hM + have hp := relativeModel_pairing M R hM hT hR + have hu := relativeModel_union M R hM hT hR + have hpow := relativeModel_power_set M R hM hT hR + have hs := relativeModel_bounded_separation M R hM hT hR + have hinf := ground_relativeModel_infinity M hM hT + have hw := ground_relativeModel_omega M hM hT + intro i + rcases i with _|_|_|_|_|i + · exact (mem_relativeModel M R R hM hT hR).mpr (parameter_in_relativeModel M R hM hT) + · exact (relativeModel_ground_reals M hM hT (realCode P) (realCode_subset P)).mpr hP + · exact hw + · exact additionSet_mem N hN hp hu hpow hs hinf + · exact product_mem N hN hp hu hpow hs hw hw + · have hid := t.inputData_indexed M hi i + change t.stageInputs R i ∈ N + unfold Construction.stageInputs + cases hd : t.inputData i with + | reals => exact (mem_relativeModel M R R hM hT hR).mpr (parameter_in_relativeModel M R hM hT) + | realPath path => exact (mem_relativeModel M R R hM hT hR).mpr (parameter_in_relativeModel M R hM hT) + | stage o => + rw [hd] at hid + exact (mem_relativeModel M R _ hM hT hR).mpr (level_in_relativeModel M R hM hT o hid) + +theorem Construction.inlined_at_level (t : Construction.{u}) (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (P : Oracle) + (hP : P ∈ modelReals M) (ht : t.Certified (groundReals M) P) (hi : t.Indexed M) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ + t.value (groundReals M) P ∈ level (groundReals M) γ ∧ + (∀ i, t.singleInputs (groundReals M) P i ∈ level (groundReals M) γ) ∧ + ∀ z ∈ level (groundReals M) γ, + t.singleMembership.Sat (level (groundReals M) γ : Set ZFSet) + (cons z (t.singleInputs (groundReals M) P)) ↔ z ∈ t.value (groundReals M) P := by + let R := groundReals M + have hR := groundReals_mem M hM hT + have hinputs := t.singleInputs_relative M hM hT P hP hi + let e := cons (t.value R P) (t.singleInputs R P) + have he (i : ℕ) (_hin : i < 6) : InRelativeModel M R (e i) := by + cases i with + | zero => exact t.value_in_relativeModel M R hM hT P ht hi + | succ i => exact (mem_relativeModel M R _ hM hT hR).mp (hinputs i) + obtain ⟨o,ho,hbound⟩ := finite_parameters_in_relative_level M R hM hT e 6 he + let γ := max o t.stageBound + have hγ : γ.toZFSet ∈ M := internal_ordinal_max M ho (t.stageBound_mem M hM hT hi) + have hv : t.value R P ∈ level R γ := level_mono R (le_max_left _ _) (hbound 0 (by decide)) + have hin (i : ℕ) : t.singleInputs R P i ∈ level R γ := by + by_cases hi5 : i < 5 + · exact level_mono R (le_max_left _ _) (hbound (i+1) (by omega)) + · obtain ⟨k,rfl⟩ : ∃ k, i = k+5 := ⟨i-5,by omega⟩ + change t.stageInputs R k ∈ level R γ + exact level_mono R (le_max_right _ _) (t.stageInputs_bounded R k) + refine ⟨γ,hγ,hv,hin,?_⟩ + intro z hz + exact t.singleMembership_of_inputs (level R γ) R (level_transitive R γ) P ht hin hv z hz + +theorem persistent_graph_inlined_at_level (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) + (hρ : Persistent (modelIdeal M hM hT) ρ) : + ∃ (t : Construction.{u}) (P : Oracle) (γ : Ordinal.{u}), + P ∈ modelReals M ∧ t.Indexed M ∧ t.Certified (groundReals M) P ∧ + γ.toZFSet ∈ M ∧ t.value (groundReals M) P = automorphismSet ρ ∧ + automorphismSet ρ ∈ level (groundReals M) γ ∧ + (∀ i, t.singleInputs (groundReals M) P i ∈ level (groundReals M) γ) ∧ + ∀ z ∈ level (groundReals M) γ, + t.singleMembership.Sat (level (groundReals M) γ : Set ZFSet) + (cons z (t.singleInputs (groundReals M) P)) ↔ z ∈ automorphismSet ρ := by + obtain ⟨t,P,hP,hi,ht,hval⟩ := persistent_graph_construction M hM hT ρ hρ + obtain ⟨γ,hγ,hv,he,hf⟩ := t.inlined_at_level M hM hT P hP ht hi + refine ⟨t,P,γ,hP,hi,ht,hγ,hval,hval ▸ hv,he,?_⟩ + intro z hz + rw [← hval] + exact hf z hz + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LevelOrdinalHeight.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LevelOrdinalHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec10779e187302f663262c0c2021b764fdc57531 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LevelOrdinalHeight.lean @@ -0,0 +1,51 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalCut + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +theorem ordinalHeight_level (R : ZFSet.{u}) (o : Ordinal.{u}) : + ordinalHeight (level R o) = ordinalHeight (seed R) + o := by + induction o using Ordinal.limitRecOn with + | zero => simp only [level_zero,add_zero] + | add_one o ih => + rw [level_succ,ordinalHeight_definablePower _ (level_transitive R o),ih,add_assoc] + | limit o ho ih => + apply le_antisymm + · by_contra h + have hx := (ordinal_mem_iff_height _ (level_transitive R o) _).mpr (lt_of_not_ge h) + obtain ⟨i,hi,hx⟩ := (mem_level_limit R _ o ho).mp hx + have hx' := (ordinal_mem_iff_height _ (level_transitive R i) _).mp hx + rw [ih i hi] at hx' + exact (not_lt_of_ge (add_le_add (le_refl (ordinalHeight (seed R))) hi.le)) hx' + · by_contra h + obtain ⟨i,hi,hi'⟩ := Ordinal.lt_add_iff_of_isSuccLimit ho |>.mp (lt_of_not_ge h) + rw [← ih i hi] at hi' + have hx := (ordinal_mem_iff_height _ (level_transitive R i) _).mpr hi' + have hx' := level_mono R hi.le hx + exact (lt_irrefl _) ((ordinal_mem_iff_height _ (level_transitive R o) _).mp hx') + +theorem ordinal_mem_level_iff (R : ZFSet.{u}) (o a : Ordinal.{u}) : + a.toZFSet ∈ level R o ↔ a < ordinalHeight (seed R) + o := by + rw [ordinal_mem_iff_height _ (level_transitive R o),ordinalHeight_level] + +theorem largest_ordinal_level_succ (R : ZFSet.{u}) (o : Ordinal.{u}) : + (ordinalHeight (seed R) + o).toZFSet ∈ level R (o+1) ∧ + ∀ a : Ordinal.{u}, a.toZFSet ∈ level R (o+1) ↔ a ≤ ordinalHeight (seed R) + o := by + have h (a : Ordinal.{u}) : a.toZFSet ∈ level R (o+1) ↔ a ≤ ordinalHeight (seed R) + o := by + rw [ordinal_mem_level_iff,← add_assoc] + exact Order.lt_add_one_iff + exact ⟨(h _).mpr le_rfl,h⟩ + +theorem largest_ordinal_at_difference (R : ZFSet.{u}) (a : Ordinal.{u}) + (ha : ordinalHeight (seed R) ≤ a) : + a.toZFSet ∈ level R (a - ordinalHeight (seed R) + 1) ∧ + ∀ b : Ordinal.{u}, b.toZFSet ∈ level R (a - ordinalHeight (seed R) + 1) ↔ b ≤ a := by + simpa only [Ordinal.add_sub_cancel_of_le ha] using + largest_ordinal_level_succ R (a - ordinalHeight (seed R)) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LevelSubsetDefinition.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LevelSubsetDefinition.lean new file mode 100644 index 0000000000000000000000000000000000000000..78cb04ac6a821d20dfaef305a4c45b030f56fbb2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LevelSubsetDefinition.lean @@ -0,0 +1,54 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.LevelInlinedDefinition + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SetDegreeDecoding PersistentRestrictions +universe u + +theorem Construction.subset_at_level (t : Construction.{u}) (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (P : Oracle) + (hP : P ∈ modelReals M) (ht : t.Certified (groundReals M) P) (hi : t.Indexed M) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ + (∀ i, t.singleInputs (groundReals M) P i ∈ level (groundReals M) γ) ∧ + t.value (groundReals M) P = definedSubset (level (groundReals M) γ) t.singleMembership + (fun i : Fin t.singleMembership.bound => t.singleInputs (groundReals M) P i) := by + obtain ⟨γ,hγ,hv,he,hf⟩ := t.inlined_at_level M hM hT P hP ht hi + refine ⟨γ,hγ,he,?_⟩ + apply ZFSet.ext; intro z + rw [mem_definedSubset] + have hs := t.singleMembership.finite_support (level (groundReals M) γ : Set ZFSet) + (cons z (t.singleInputs (groundReals M) P)) + (cons z (tupleEnv (fun i : Fin t.singleMembership.bound => t.singleInputs (groundReals M) P i))) + (by + intro i hin + cases i with + | zero => rfl + | succ i => + simp only [cons_succ,tupleEnv,dite_eq_left (show i < t.singleMembership.bound by omega)]) + constructor + · intro hz + have hzL := level_transitive _ γ _ hv z hz + exact ⟨hzL,hs.mp ((hf z hzL).mpr hz)⟩ + · rintro ⟨hzL,hz⟩ + exact (hf z hzL).mp (hs.mpr hz) + +theorem persistent_extension_subset_at_level (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) + (I : CountableIdeal) (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (hIM : I.carrier ⊆ (modelIdeal M hM hT).carrier) : + ∃ σ : modelIdeal M hM hT ≃o modelIdeal M hM hT, + Extends hIM ρ σ ∧ Persistent (modelIdeal M hM hT) σ ∧ + ∃ (t : Construction.{u}) (P : Oracle) (γ : Ordinal.{u}), + P ∈ modelReals M ∧ t.Indexed M ∧ t.Certified (groundReals M) P ∧ γ.toZFSet ∈ M ∧ + (∀ i, t.singleInputs (groundReals M) P i ∈ level (groundReals M) γ) ∧ + automorphismSet σ = definedSubset (level (groundReals M) γ) t.singleMembership + (fun i : Fin t.singleMembership.bound => t.singleInputs (groundReals M) P i) := by + obtain ⟨σ,he,hσ,t,P,hP,hi,ht,hval⟩ := persistent_extension_construction M hM hT I ρ hρ hz hIM + obtain ⟨γ,hγ,hin,hdef⟩ := t.subset_at_level M hM hT P hP ht hi + exact ⟨σ,he,hσ,t,P,γ,hP,hi,ht,hγ,hin,hval ▸ hdef⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LimitOmegaCertificates.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LimitOmegaCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..4623bf88fd6cf6b656f2c4f0af3636b479a650bd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LimitOmegaCertificates.lean @@ -0,0 +1,77 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.LimitOmegaGraphSyntax +import OAI.Computability.DegreeRigidity.SetModels.ExactOmegaGraph +import OAI.Computability.DegreeRigidity.Constructibility.FiniteStageSetBounds +import OAI.Computability.DegreeRigidity.OrdinalCodes.LevelOrdinalHeight + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +theorem omega_graph_at_limit_successor (R : ZFSet.{u}) (a : Ordinal.{u}) + (ha : Order.IsSuccLimit a) (hheight : ordinalHeight (seed R) + a = a) + (hω : ZFSet.omega.{u} ∈ level R a) + (hpow : ∀ c < a, (Ordinal.omega0 ^ c).toZFSet ∈ level R a ∧ + OmegaPowerCertificates (level R a) c.toZFSet) : + ∃ f ∈ level R (a+1), ∀ z, z ∈ f ↔ + ∃ x ∈ a.toZFSet, z = ZFSet.pair x (omegaNext x) := by + let A := level R a + have hcut (c : Ordinal.{u}) : c.toZFSet ∈ A ↔ c < a := by + rw [ordinal_mem_level_iff,hheight] + let f := A.sep (fun z => omegaNextPairSentence.Sat (A : Set ZFSet) + (cons z (fun _ => ZFSet.omega))) + have hf : f ∈ level R (a+1) := by + rw [level_succ] + exact separation_mem_definablePower A omegaNextPairSentence (fun _ => ZFSet.omega) + (fun _ _ => hω) + refine ⟨f,hf,?_⟩ + intro z + change z ∈ A.sep _ ↔ _ + rw [ZFSet.mem_sep] + constructor + · rintro ⟨hz,hzspec⟩ + obtain ⟨c,hc,hz⟩ := (omegaNextPairSentence_at_cut A (level_transitive R a) hω a ha hcut hpow + _ (fun i => by cases i; exact hz; exact hω)).mp hzspec + exact ⟨c.toZFSet,Ordinal.toZFSet_mem_toZFSet_iff.mpr hc,hz⟩ + · rintro ⟨x,hx,rfl⟩ + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + have hy : omegaNext c.toZFSet ∈ A := by + simpa only [omegaNext,Ordinal.rank_toZFSet] using (hpow (c+1) (ha.succ_lt hc)).1 + have hz := orderedPair_mem_level_limit R a ha ((hcut c).mpr hc) hy + refine ⟨hz,(omegaNextPairSentence_at_cut A (level_transitive R a) hω a ha hcut hpow + _ (fun i => by cases i; exact hz; exact hω)).mpr ⟨c,hc,rfl⟩⟩ + +theorem omega_certificates_at_limit_add_three (R : ZFSet.{u}) (a : Ordinal.{u}) + (ha : Order.IsSuccLimit a) (hheight : ordinalHeight (seed R) + a = a) + (hω : ZFSet.omega.{u} ∈ level R a) + (hpow : ∀ c < a, (Ordinal.omega0 ^ c).toZFSet ∈ level R a ∧ + OmegaPowerCertificates (level R a) c.toZFSet) : + OmegaPowerCertificates (level R (a+3)) a.toZFSet := by + obtain ⟨f,hf,hexact⟩ := omega_graph_at_limit_successor R a ha hheight hω hpow + have h01 : a ≤ a+1 := le_self_add + have h13 : a+1 ≤ a+3 := add_le_add le_rfl (by norm_num : (1 : Ordinal.{u}) ≤ 3) + have h03 := h01.trans h13 + have hd : a.toZFSet ∈ level R (a+3) := by + apply level_mono R h13 + apply (ordinal_mem_level_iff R (a+1) a).mpr + rw [← add_assoc,hheight] + exact lt_add_one a + have hr : iterUnion 2 f ∈ level R (a+3) := by + simpa only [Nat.cast_ofNat,add_assoc,show (1 : Ordinal.{u})+2=3 by norm_num] using + iterUnion_mem_level_add R (a+1) hf 2 + refine ⟨hd,f,level_mono R h13 hf,_,hr, + omegaGraph_of_exact_pairs _ _ f (ZFSet.isOrdinal_toZFSet a) hexact ?_,?_⟩ + · intro x hx + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + rw [Ordinal.rank_toZFSet] + exact level_mono R h03 (hpow c hc).1 + · intro x hx + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + obtain ⟨_,g,hg,r,hr,hgraph,hprod⟩ := (hpow (c+1) (ha.succ_lt hc)).2 + exact (hprod c.toZFSet (Ordinal.toZFSet_mem_toZFSet_iff.mpr (lt_add_one c))).mono + (level_mono R h03) + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LimitOmegaGraphSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LimitOmegaGraphSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd1b3576c692918a689389ce37b1bf32431baaa8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/LimitOmegaGraphSyntax.lean @@ -0,0 +1,84 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.CodeOperationCertificates +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalCodeBranch + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open OrdinalCoding +universe u + +noncomputable def omegaNextPairSentence : SentenceForm := + .ex (.ex (.ex (.conj + (fromBounded (.conj (ordinalFormula 2) (.conj (.successor 0 2) (.orderedPair 3 2 1)))) + (codePowerAt 1 0)))) + +theorem omegaNextPairSentence_bound : omegaNextPairSentence.bound = 1 := by + have hbounded : + (fromBounded (.conj (ordinalFormula 2) (.conj (.successor 0 2) (.orderedPair 3 2 1)))).bound = 4 := by + rfl + have hpower : (codePowerAt 1 0).bound ≤ 4 := + code_rename_bound omegaPowerSentence _ 4 (by intro i _; split <;> omega) + have finish (p q : SentenceForm) (hp : p.bound = 4) (hq : q.bound ≤ 4) : + (SentenceForm.ex (.ex (.ex (.conj p q)))).bound = 1 := by + change max p.bound q.bound - 1 - 1 - 1 = 1 + rw [hp, max_eq_left hq] + exact finish _ _ hbounded hpower + + +theorem omegaNextPairSentence_semantics (M : ZFSet.{u}) (hM : Transitive M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + omegaNextPairSentence.Sat (M : Set ZFSet) e ↔ + ∃ x ∈ M, ∃ y ∈ M, ∃ k ∈ M, + (x.IsOrdinal ∧ k = insert x x ∧ e 0 = ZFSet.pair x y) ∧ + (codePowerAt 1 0).Sat (M : Set ZFSet) (cons k (cons y (cons x e))) := by + change (∃ x ∈ M, ∃ y ∈ M, ∃ k ∈ M, _) ↔ _ + apply exists_congr; intro x + apply and_congr_right; intro hx + apply exists_congr; intro y + apply and_congr_right; intro hy + apply exists_congr; intro k + apply and_congr_right; intro hk + have hE : ∀ i, cons k (cons y (cons x e)) i ∈ M := by + intro i; rcases i with _|_|_|i + exact hk; exact hy; exact hx; exact he i + rw [SentenceForm.Sat,bounded_sat,Formula.absolute _ M hM _ hE] + simp only [Formula.Eval,eval_ordinalFormula,Formula.eval_successor, + Formula.eval_orderedPair,cons_zero,cons_succ] + +theorem omegaNextPairSentence_at_cut (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (a : Ordinal.{u}) (ha : Order.IsSuccLimit a) + (hcut : ∀ c : Ordinal.{u}, c.toZFSet ∈ M ↔ c < a) + (hpow : ∀ c < a, (Ordinal.omega0 ^ c).toZFSet ∈ M ∧ OmegaPowerCertificates M c.toZFSet) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + omegaNextPairSentence.Sat (M : Set ZFSet) e ↔ + ∃ c < a, e 0 = ZFSet.pair c.toZFSet (omegaNext c.toZFSet) := by + rw [omegaNextPairSentence_semantics M hM e he] + constructor + · rintro ⟨x,hx,y,hy,k,hk,⟨ho,hkdef,hz⟩,hp⟩ + have hE : ∀ i, cons k (cons y (cons x e)) i ∈ M := by + intro i; rcases i with _|_|_|i + exact hk; exact hy; exact hx; exact he i + have hv := (codePowerAt_sound M hM hω 1 0 _ hE hp).2 + change y = (Ordinal.omega0 ^ k.rank).toZFSet at hv + have hsucc : k = (x.rank+1).toZFSet := by + rw [Ordinal.toZFSet_add_one,ho.toZFSet_rank_eq,hkdef] + rw [hsucc,Ordinal.rank_toZFSet] at hv + refine ⟨x.rank,(hcut _).mp (ho.toZFSet_rank_eq.symm ▸ hx),?_⟩ + simpa only [ho.toZFSet_rank_eq,omegaNext] using hz.trans (congrArg (ZFSet.pair x) hv) + · rintro ⟨c,hc,hz⟩ + have hs : c+1 < a := ha.succ_lt hc + have hx := (hcut c).mpr hc + have hk := (hcut (c+1)).mpr hs + obtain ⟨hy,hcert⟩ := hpow (c+1) hs + refine ⟨c.toZFSet,hx,(Ordinal.omega0 ^ (c+1)).toZFSet,hy,(c+1).toZFSet,hk, + ⟨ZFSet.isOrdinal_toZFSet _,Ordinal.toZFSet_add_one c,?_⟩,?_⟩ + · simpa only [omegaNext,Ordinal.rank_toZFSet] using hz + · apply codePowerAt_of_certificates M hM hω 1 0 _ (fun i => by + rcases i with _|_|_|i + exact hk; exact hy; exact hx; exact he i) hcert + simp only [cons_zero,cons_succ,Ordinal.rank_toZFSet] + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalAdditionTrace.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalAdditionTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..3148591fc30382942ea40b33999293a3aa3e1468 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalAdditionTrace.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteNaturalGraph + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +def AdditionTrace (o z k n x f : ZFSet.{u}) : Prop := + TransitiveNameModel.FunctionGraph k o f ∧ k = insert n n ∧ z = ∅ ∧ ZFSet.pair z x ∈ f ∧ + ∀ i ∈ n, ∀ j ∈ o, j = insert i i → ∀ v ∈ o, ∀ w ∈ o, + ZFSet.pair i v ∈ f → ZFSet.pair j w ∈ f → w = insert v v + +theorem additionTrace_exists (a n : ℕ) : + AdditionTrace ZFSet.omega (natSet 0) (natSet (n+1)) (natSet n) (natSet a) + (finiteNaturalGraph.{u} (fun i => a+i) n) := by + refine ⟨finiteNaturalGraph_function _ n,rfl,rfl,?_,?_⟩ + · exact (finiteNaturalGraph_pair _ n 0 _).mpr ⟨Nat.zero_le _,by simp⟩ + · intro i hi j _ hj v _ w _ hiv hjw + obtain ⟨i,hi,rfl⟩ := (mem_natSet n i).mp hi + have hj' : j = natSet (i+1) := hj + subst j + have hv := ((finiteNaturalGraph_pair _ n i v).mp hiv).2 + have hw := ((finiteNaturalGraph_pair _ n (i+1) w).mp hjw).2 + rw [hv,hw,Nat.add_succ] + rfl + +theorem AdditionTrace.correct {z k f : ZFSet.{u}} (a n : ℕ) + (hf : AdditionTrace ZFSet.omega z k (natSet n) (natSet a) f) + {y : ZFSet.{u}} (hy : ZFSet.pair (natSet n) y ∈ f) : y = natSet (a+n) := by + obtain ⟨hfun,hk,rfl,hzero,hstep⟩ := hf + have hk' : k = natSet (n+1) := hk + subst k + have computes (i : ℕ) (hi : i ≤ n) : ZFSet.pair (natSet i) (natSet (a+i)) ∈ f := by + induction i with + | zero => simpa only [Nat.add_zero,natSet] using hzero + | succ i ih => + have hin : i ≤ n := by omega + have hj : natSet.{u} (i+1) ∈ natSet (n+1) := (natSet_mem_natSet _ _).mpr (by omega) + obtain ⟨w,hw,hjw,_⟩ := hfun.2 _ hj + have he := hstep (natSet i) ((natSet_mem_natSet _ _).mpr (by omega)) (natSet (i+1)) + ((mem_omega _).mpr ⟨i+1,rfl⟩) rfl (natSet (a+i)) ((mem_omega _).mpr ⟨a+i,rfl⟩) + w hw (ih hin) hjw + have he' : w = natSet (a+(i+1)) := by + rw [Nat.add_succ] + exact he + exact he' ▸ hjw + exact hfun.functional ((natSet_mem_natSet n (n+1)).mpr (Nat.lt_succ_self n)) hy (computes n le_rfl) + +namespace Formula +def additionTrace (o z k n x f : ℕ) : Formula := + .conj (.functionGraph f k o) (.conj (.successor k n) (.conj (.empty z) + (.conj (.pairMem z x f) + (allMem n (allMem (o+1) (imp (.successor 0 1) + (allMem (o+2) (allMem (o+3) (imp (.pairMem 3 1 (f+4)) + (imp (.pairMem 2 0 (f+4)) (.successor 0 1))))))))))) + +theorem eval_additionTrace (o z k n x f : ℕ) (e : ℕ → ZFSet.{u}) : + (additionTrace o z k n x f).Eval e ↔ AdditionTrace (e o) (e z) (e k) (e n) (e x) (e f) := by + simp only [additionTrace,AdditionTrace,TransitiveNameModel.FunctionGraph,Formula.Eval,eval_functionGraph,eval_successor, + eval_empty,eval_pairMem,eval_allMem,eval_imp,cons_zero,cons_succ] + +def addition (o Q x n y : ℕ) : Formula := .existsMem o (.existsMem (o+1) (.existsMem (Q+2) + (.conj (additionTrace (o+3) 1 2 (n+3) (x+3) 0) (.pairMem (n+3) (y+3) 0)))) + +theorem eval_addition (o Q x n y : ℕ) (e : ℕ → ZFSet.{u}) : + (addition o Q x n y).Eval e ↔ ∃ k ∈ e o, ∃ z ∈ e o, ∃ f ∈ e Q, + AdditionTrace (e o) z k (e n) (e x) f ∧ ZFSet.pair (e n) (e y) ∈ f := by + simp only [addition,Formula.Eval,eval_additionTrace,eval_pairMem,cons_zero,cons_succ] +end Formula + +theorem additionFormula_correct (Q : ZFSet.{u}) + (hQ : ∀ f : ℕ → ℕ, ∀ n, finiteNaturalGraph f n ∈ Q) (a n : ℕ) (y : ZFSet.{u}) : + (Formula.addition 3 4 1 2 0).Eval (cons y (cons (natSet a) (cons (natSet n) + (cons ZFSet.omega (fun _ => Q))))) ↔ y = natSet (a+n) := by + rw [Formula.eval_addition] + simp only [cons_zero,cons_succ] + constructor + · rintro ⟨k,_,z,_,f,_,hf,hy⟩ + exact hf.correct a n hy + · intro hy + refine ⟨natSet (n+1),(mem_omega _).mpr ⟨n+1,rfl⟩,natSet 0, + (mem_omega _).mpr ⟨0,rfl⟩,finiteNaturalGraph (fun i => a+i) n,hQ _ _,additionTrace_exists a n,?_⟩ + exact (finiteNaturalGraph_pair _ n n y).mpr ⟨le_rfl,hy⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalDefinitions.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalDefinitions.lean new file mode 100644 index 0000000000000000000000000000000000000000..849fa3f5bd78c005c95d6050e2834e58111fd7cd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalDefinitions.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NaturalPairingFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +universe u + +def DefinesNatural (φ : Formula) (f : ℕ → ℕ) : Prop := + ∀ e : ℕ → ZFSet.{u}, e 2 = ZFSet.omega → + (∀ g : ℕ → ℕ, ∀ k, finiteNaturalGraph g k ∈ e 3) → ∀ n, e 1 = natSet n → + (φ.Eval e ↔ e 0 = natSet (f n)) + +namespace Formula +def unaryVars (o Q x y : ℕ) : ℕ → ℕ + | 0 => y + | 1 => x + | 2 => o + | _+3 => Q + +def unary (φ : Formula) (o Q x y : ℕ) : Formula := φ.rename (unaryVars o Q x y) + +theorem unary_spec {φ : Formula} {f : ℕ → ℕ} (hφ : DefinesNatural.{u} φ f) + (o Q x y : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ g : ℕ → ℕ, ∀ k, finiteNaturalGraph g k ∈ e Q) (n : ℕ) (hx : e x = natSet n) : + (unary φ o Q x y).Eval e ↔ e y = natSet (f n) := by + rw [unary,eval_rename] + exact hφ (fun i => e (unaryVars o Q x y i)) ho hQ n hx + +def numericComposition (φ ψ : Formula) : Formula := .existsMem 2 + (.conj (unary ψ 3 4 2 0) (unary φ 3 4 0 1)) + +def numericPair (φ ψ : Formula) : Formula := .existsMem 2 (.existsMem 3 + (.conj (unary φ 4 5 3 1) (.conj (unary ψ 4 5 3 0) (naturalPair 4 5 1 0 2)))) + +def pairedUnary (φ : Formula) (o Q a b y : ℕ) : Formula := .existsMem o + (.conj (naturalPair (o+1) (Q+1) (a+1) (b+1) 0) (unary φ (o+1) (Q+1) 0 (y+1))) + +theorem pairedUnary_spec {φ : Formula} {f : ℕ → ℕ} (hφ : DefinesNatural.{u} φ f) + (o Q x n y : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ g : ℕ → ℕ, ∀ k, finiteNaturalGraph g k ∈ e Q) + (a b : ℕ) (ha : e x = natSet a) (hb : e n = natSet b) : + (pairedUnary φ o Q x n y).Eval e ↔ e y = natSet (f (Nat.pair a b)) := by + have hp (w : ZFSet.{u}) := naturalPair_spec (o+1) (Q+1) (x+1) (n+1) 0 (cons w e) ho hQ a b ha hb + have hu := unary_spec hφ (o+1) (Q+1) 0 (y+1) (cons (natSet (Nat.pair a b)) e) ho hQ (Nat.pair a b) rfl + simp only [pairedUnary,Formula.Eval] + constructor + · rintro ⟨w,_,hw,h⟩ + obtain rfl := (hp w).mp hw + exact hu.mp h + · intro h + refine ⟨natSet (Nat.pair a b),?_,(hp _).mpr rfl,hu.mpr h⟩ + rw [ho]; exact (mem_omega _).mpr ⟨Nat.pair a b,rfl⟩ +end Formula + +theorem definesNatural_zero : DefinesNatural.{u} (.empty 0) (fun _ => 0) := by + intro e _ _ n _ + exact Formula.eval_empty 0 e + +theorem definesNatural_succ : DefinesNatural.{u} (.successor 0 1) Nat.succ := by + intro e _ _ n hn + rw [Formula.eval_successor,hn] + rfl + +theorem DefinesNatural.comp {φ ψ : Formula} {f g : ℕ → ℕ} + (hf : DefinesNatural.{u} φ f) (hg : DefinesNatural.{u} ψ g) : + DefinesNatural.{u} (Formula.numericComposition φ ψ) (fun n => f (g n)) := by + intro e ho hQ n hn + have hv (w : ZFSet.{u}) := Formula.unary_spec hg 3 4 2 0 (cons w e) ho hQ n hn + have hu := Formula.unary_spec hf 3 4 0 1 (cons (natSet (g n)) e) ho hQ (g n) rfl + simp only [Formula.numericComposition,Formula.Eval] + constructor + · rintro ⟨w,_,hw,h⟩ + obtain rfl := (hv w).mp hw + exact hu.mp h + · intro h + refine ⟨natSet (g n),?_,(hv _).mpr rfl,hu.mpr h⟩ + rw [ho]; exact (mem_omega _).mpr ⟨g n,rfl⟩ + +theorem DefinesNatural.pair {φ ψ : Formula} {f g : ℕ → ℕ} + (hf : DefinesNatural.{u} φ f) (hg : DefinesNatural.{u} ψ g) : + DefinesNatural.{u} (Formula.numericPair φ ψ) (fun n => Nat.pair (f n) (g n)) := by + intro e ho hQ n hn + have hv (w z : ZFSet.{u}) := Formula.unary_spec hf 4 5 3 1 (cons z (cons w e)) ho hQ n hn + have hw (w z : ZFSet.{u}) := Formula.unary_spec hg 4 5 3 0 (cons z (cons w e)) ho hQ n hn + have hp := Formula.naturalPair_spec 4 5 1 0 2 (cons (natSet (g n)) (cons (natSet (f n)) e)) + ho hQ (f n) (g n) rfl rfl + have hmem (k : ℕ) : natSet.{u} k ∈ e 2 := by rw [ho]; exact (mem_omega _).mpr ⟨k,rfl⟩ + simp only [Formula.numericPair,Formula.Eval] + constructor + · rintro ⟨w,_,z,_,hvw,hwz,h⟩ + obtain rfl := (hv w z).mp hvw + obtain rfl := (hw _ z).mp hwz + exact hp.mp h + · intro h + exact ⟨natSet (f n),hmem _,natSet (g n),hmem _,(hv _ _).mpr rfl,(hw _ _).mpr rfl,hp.mpr h⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalIterationFormula.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalIterationFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..9fd753febcb69c9e8dc7af39df40461a4aeb04c2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalIterationFormula.lean @@ -0,0 +1,65 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NaturalIterationTrace +import OAI.Computability.DegreeRigidity.OrdinalCodes.NaturalAdditionTrace + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace Formula + +theorem addition_spec (o Q x n y : ℕ) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) + (a b : ℕ) (ha : e x = natSet a) (hb : e n = natSet b) : + (addition o Q x n y).Eval e ↔ e y = natSet (a+b) := by + have h := additionFormula_correct (e Q) hQ a b (e y) + rw [eval_addition] at h + simp only [cons_zero,cons_succ] at h + rw [eval_addition,ho,ha,hb] + exact h + +def iterationOuterVars : ℕ → ℕ + | 0 => 0 + | 1 => 1 + | 2 => 2 + | i+3 => i+6 + +def iteration (o Q n b y : ℕ) (θ : Formula) : Formula := + .existsMem o (.existsMem (o+1) (.existsMem (Q+2) + (.conj (iterationTrace (o+3) 1 2 (n+3) (b+3) 0 (θ.rename iterationOuterVars)) + (.pairMem (n+3) (y+3) 0)))) + +theorem eval_iteration (o Q n b y : ℕ) (θ : Formula) (e : ℕ → ZFSet.{u}) : + (iteration o Q n b y θ).Eval e ↔ ∃ k ∈ e o, ∃ z ∈ e o, ∃ f ∈ e Q, + IterationTrace (e o) z k (e n) (e b) f + (fun i v w => θ.Eval (cons w (cons v (cons i e)))) ∧ ZFSet.pair (e n) (e y) ∈ f := by + simp only [iteration,Formula.Eval,eval_iterationTrace,eval_pairMem,eval_rename,cons_zero,cons_succ] + have eq (k z f i v w : ZFSet.{u}) : + (fun n => cons w (cons v (cons i (cons f (cons z (cons k e))))) (iterationOuterVars n)) = + cons w (cons v (cons i e)) := by + funext n + rcases n with _|n; rfl + rcases n with _|n; rfl + rcases n with _|n <;> rfl + simp only [eq] + +theorem iteration_spec (o Q n b y : ℕ) (θ : Formula) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) + (N B : ℕ) (hn : e n = natSet N) (hb : e b = natSet B) (g : ℕ → ℕ → ℕ) + (hθ : ∀ i v w, θ.Eval (cons w (cons (natSet v) (cons (natSet i) e))) ↔ w = natSet (g i v)) : + (iteration o Q n b y θ).Eval e ↔ e y = natSet (Nat.rec B g N) := by + rw [eval_iteration,ho,hn,hb] + constructor + · rintro ⟨k,_,z,_,f,_,hf,hy⟩ + exact hf.correct B N g _ (fun i v w h => (hθ i v w).mp h) hy + · intro hy + refine ⟨natSet (N+1),(mem_omega _).mpr ⟨N+1,rfl⟩,natSet 0,(mem_omega _).mpr ⟨0,rfl⟩, + finiteNaturalGraph (fun i => Nat.rec B g i) N,hQ _ _,?_,?_⟩ + · exact iterationTrace_exists B g _ (fun i v => (hθ i v _).mpr rfl) N + · exact (finiteNaturalGraph_pair _ N N _).mpr ⟨le_rfl,hy⟩ + +end Formula +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalIterationTrace.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalIterationTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..46f95c96fba84c297e15f2c305411168370f4d43 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalIterationTrace.lean @@ -0,0 +1,83 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteNaturalGraph +import OAI.Computability.DegreeRigidity.Effective.TupleFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +def IterationTrace (o z k n b f : ZFSet.{u}) (S : ZFSet.{u} → ZFSet.{u} → ZFSet.{u} → Prop) : Prop := + TransitiveNameModel.FunctionGraph k o f ∧ k = insert n n ∧ z = ∅ ∧ ZFSet.pair z b ∈ f ∧ + ∀ i ∈ n, ∀ j ∈ o, j = insert i i → ∀ v ∈ o, ∀ w ∈ o, + ZFSet.pair i v ∈ f → ZFSet.pair j w ∈ f → S i v w + +theorem iterationTrace_exists (b : ℕ) (g : ℕ → ℕ → ℕ) + (S : ZFSet.{u} → ZFSet.{u} → ZFSet.{u} → Prop) + (hS : ∀ i v, S (natSet i) (natSet v) (natSet (g i v))) (n : ℕ) : + IterationTrace ZFSet.omega (natSet 0) (natSet (n+1)) (natSet n) (natSet b) + (finiteNaturalGraph (fun i => Nat.rec b g i) n) S := by + refine ⟨finiteNaturalGraph_function _ n,rfl,rfl,?_,?_⟩ + · exact (finiteNaturalGraph_pair _ n 0 _).mpr ⟨Nat.zero_le _,rfl⟩ + · intro i hi j _ hj v _ w _ hiv hjw + obtain ⟨i,_,rfl⟩ := (mem_natSet n i).mp hi + have hj' : j = natSet (i+1) := hj + subst j + rw [((finiteNaturalGraph_pair _ n i v).mp hiv).2, + ((finiteNaturalGraph_pair _ n (i+1) w).mp hjw).2] + exact hS i (Nat.rec b g i) + +theorem IterationTrace.correct {z k f : ZFSet.{u}} (b n : ℕ) (g : ℕ → ℕ → ℕ) + (S : ZFSet.{u} → ZFSet.{u} → ZFSet.{u} → Prop) + (hS : ∀ i v w, S (natSet i) (natSet v) w → w = natSet (g i v)) + (hf : IterationTrace ZFSet.omega z k (natSet n) (natSet b) f S) + {y : ZFSet.{u}} (hy : ZFSet.pair (natSet n) y ∈ f) : y = natSet (Nat.rec b g n) := by + obtain ⟨hfun,hk,rfl,hzero,hstep⟩ := hf + have hk' : k = natSet (n+1) := hk + subst k + have computes (i : ℕ) (hi : i ≤ n) : ZFSet.pair (natSet i) (natSet (Nat.rec b g i)) ∈ f := by + induction i with + | zero => exact hzero + | succ i ih => + have hin : i ≤ n := by omega + have hj : natSet.{u} (i+1) ∈ natSet (n+1) := (natSet_mem_natSet _ _).mpr (by omega) + obtain ⟨w,hw,hjw,_⟩ := hfun.2 _ hj + have hs := hstep (natSet i) ((natSet_mem_natSet _ _).mpr (by omega)) (natSet (i+1)) + ((mem_omega _).mpr ⟨i+1,rfl⟩) rfl (natSet (Nat.rec b g i)) + ((mem_omega _).mpr ⟨Nat.rec b g i,rfl⟩) w hw (ih hin) hjw + have he : w = natSet (Nat.rec b g (i+1)) := hS i (Nat.rec b g i) w hs + exact he ▸ hjw + exact hfun.functional ((natSet_mem_natSet n (n+1)).mpr (Nat.lt_succ_self n)) hy (computes n le_rfl) + +namespace Formula +def iterationVars : ℕ → ℕ + | 0 => 0 + | 1 => 1 + | 2 => 3 + | i+3 => i+4 + +def iterationTrace (o z k n b f : ℕ) (θ : Formula) : Formula := + .conj (.functionGraph f k o) (.conj (.successor k n) (.conj (.empty z) + (.conj (.pairMem z b f) + (allMem n (allMem (o+1) (imp (.successor 0 1) + (allMem (o+2) (allMem (o+3) (imp (.pairMem 3 1 (f+4)) + (imp (.pairMem 2 0 (f+4)) (θ.rename iterationVars))))))))))) + +theorem eval_iterationTrace (o z k n b f : ℕ) (θ : Formula) (e : ℕ → ZFSet.{u}) : + (iterationTrace o z k n b f θ).Eval e ↔ IterationTrace (e o) (e z) (e k) (e n) (e b) (e f) + (fun i v w => θ.Eval (cons w (cons v (cons i e)))) := by + simp only [iterationTrace,IterationTrace,TransitiveNameModel.FunctionGraph,Formula.Eval, + eval_functionGraph,eval_successor,eval_empty,eval_pairMem,eval_allMem,eval_imp,eval_rename,cons_zero,cons_succ] + have eq (i j v w : ZFSet.{u}) : + (fun n => cons w (cons v (cons j (cons i e))) (iterationVars n)) = cons w (cons v (cons i e)) := by + funext n + rcases n with _|n; rfl + rcases n with _|n; rfl + rcases n with _|n <;> rfl + simp only [eq] +end Formula + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalMultiplicationFormula.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalMultiplicationFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..370184470f075f3ac1f406f6639638977f0eb619 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalMultiplicationFormula.lean @@ -0,0 +1,49 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NaturalIterationFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +universe u + +theorem nat_iteration_add (a n : ℕ) : Nat.rec 0 (fun _ v => v+a) n = a*n := by + induction n with + | zero => simp + | succ n ih => + change Nat.rec 0 (fun _ v => v+a) n + a = a*(n+1) + rw [ih,Nat.mul_succ] + +namespace Formula +def multiplication (o Q x n y : ℕ) : Formula := .existsMem o + (.conj (.empty 0) (iteration (o+1) (Q+1) (n+1) 0 (y+1) + (addition (o+4) (Q+4) 1 (x+4) 0))) + +theorem multiplication_spec (o Q x n y : ℕ) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) + (a b : ℕ) (ha : e x = natSet a) (hb : e n = natSet b) : + (multiplication o Q x n y).Eval e ↔ e y = natSet (a*b) := by + have hθ (i v : ℕ) (w : ZFSet.{u}) : + (addition (o+4) (Q+4) 1 (x+4) 0).Eval + (cons w (cons (natSet v) (cons (natSet i) (cons ∅ e)))) ↔ w = natSet (v+a) := by + apply addition_spec (o+4) (Q+4) 1 (x+4) 0 + (cons w (cons (natSet v) (cons (natSet i) (cons ∅ e)))) + (by simpa only [cons_succ] using ho) + (by intro f k; simpa only [cons_succ] using hQ f k) v a rfl + simpa only [cons_succ] using ha + have hi := iteration_spec (o+1) (Q+1) (n+1) 0 (y+1) + (addition (o+4) (Q+4) 1 (x+4) 0) (cons ∅ e) + (by simpa only [cons_succ] using ho) + (by intro f k; simpa only [cons_succ] using hQ f k) b 0 + (by simpa only [cons_succ] using hb) rfl (fun _ v => v+a) hθ + simp only [cons_succ,nat_iteration_add] at hi + simp only [multiplication,Formula.Eval,eval_empty,cons_zero] + constructor + · rintro ⟨z,_,rfl,h⟩ + exact hi.mp h + · intro h + exact ⟨∅,ho.symm ▸ ZFSet.omega_zero,rfl,hi.mpr h⟩ + +end Formula +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalPairingFormula.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalPairingFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d211674a3c5a64cdc521949dc01519fe4494838 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalPairingFormula.lean @@ -0,0 +1,39 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NaturalTermFormula +import Mathlib.Data.Nat.Pairing + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +universe u +namespace Formula + +def pairVars (a b : ℕ) : ℕ → ℕ + | 0 => a + | _+1 => b + +def pairLeftTerm : NaturalTerm := .binary false (.binary true (.var 1) (.var 1)) (.var 0) +def pairRightTerm : NaturalTerm := .binary false + (.binary false (.binary true (.var 0) (.var 0)) (.var 0)) (.var 1) + +def naturalPair (o Q x n y : ℕ) : Formula := .disj + (.conj (.member x n) (pairLeftTerm.graph o Q y (pairVars x n))) + (.conj (.neg (.member x n)) (pairRightTerm.graph o Q y (pairVars x n))) + +theorem naturalPair_spec (o Q x n y : ℕ) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) + (a b : ℕ) (ha : e x = natSet a) (hb : e n = natSet b) : + (naturalPair o Q x n y).Eval e ↔ e y = natSet (Nat.pair a b) := by + have hv : ∀ i, e (pairVars x n i) = natSet (pairVars a b i) := by + intro i; cases i <;> assumption + have hl := NaturalTerm.graph_spec pairLeftTerm o Q y (pairVars x n) e ho hQ (pairVars a b) hv + have hr := NaturalTerm.graph_spec pairRightTerm o Q y (pairVars x n) e ho hQ (pairVars a b) hv + change (pairLeftTerm.graph o Q y (pairVars x n)).Eval e ↔ e y = natSet (b*b+a) at hl + change (pairRightTerm.graph o Q y (pairVars x n)).Eval e ↔ e y = natSet (a*a+a+b) at hr + simp only [naturalPair,eval_disj,Formula.Eval,hl,hr,ha,hb,natSet_mem_natSet,Nat.pair] + by_cases h : a < b <;> simp [h] + +end Formula +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalPrimitiveRecursion.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalPrimitiveRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc85517dadc50e52914a41bbbe463bb2e1aa255b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalPrimitiveRecursion.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NaturalProjectionFormula +import Mathlib.Computability.Primrec.Basic + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +universe u +namespace Formula + +def primitiveStep (ψ : Formula) : Formula := .existsMem 8 + (.conj (naturalPair 9 10 3 2 0) (pairedUnary ψ 9 10 6 0 1)) + +def primitiveRecursion (φ ψ : Formula) : Formula := .existsMem 2 (.existsMem 3 (.existsMem 4 + (.conj (naturalPair 5 6 2 1 4) (.conj (unary φ 5 6 2 0) + (iteration 5 6 1 0 3 (primitiveStep ψ)))))) + +theorem primitiveStep_spec {ψ : Formula} {g : ℕ → ℕ} (hg : DefinesNatural.{u} ψ g) + (e : ℕ → ZFSet.{u}) (ho : e 5 = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e 6) (z : ℕ) (hz : e 2 = natSet z) + (i v : ℕ) (w : ZFSet.{u}) : + (primitiveStep ψ).Eval (cons w (cons (natSet v) (cons (natSet i) e))) ↔ + w = natSet (g (Nat.pair z (Nat.pair i v))) := by + let E := cons w (cons (natSet v) (cons (natSet i) e)) + have hp (t : ZFSet.{u}) := naturalPair_spec 9 10 3 2 0 (cons t E) ho hQ i v rfl rfl + have hu := pairedUnary_spec hg 9 10 6 0 1 (cons (natSet (Nat.pair i v)) E) + ho hQ z (Nat.pair i v) hz rfl + simp only [primitiveStep,Formula.Eval] + constructor + · rintro ⟨t,_,ht,h⟩ + obtain rfl := (hp t).mp ht + exact hu.mp h + · intro h + refine ⟨natSet (Nat.pair i v),?_,(hp _).mpr rfl,hu.mpr h⟩ + change natSet (Nat.pair i v) ∈ e 5 + rw [ho]; exact (mem_omega _).mpr ⟨Nat.pair i v,rfl⟩ +end Formula + +theorem DefinesNatural.prec {φ ψ : Formula} {f g : ℕ → ℕ} + (hf : DefinesNatural.{u} φ f) (hg : DefinesNatural.{u} ψ g) : + DefinesNatural.{u} (Formula.primitiveRecursion φ ψ) + (Nat.unpaired fun z n => Nat.rec (f z) (fun i v => g (Nat.pair z (Nat.pair i v))) n) := by + intro e ho hQ N hn + have hmem (k : ℕ) : natSet.{u} k ∈ e 2 := by rw [ho]; exact (mem_omega _).mpr ⟨k,rfl⟩ + have decode (x : ZFSet.{u}) (hx : x ∈ e 2) : ∃ n, x = natSet n := by + rw [ho] at hx; exact (mem_omega x).mp hx + have hp (z n : ℕ) (b : ZFSet.{u}) := Formula.naturalPair_spec 5 6 2 1 4 + (cons b (cons (natSet n) (cons (natSet z) e))) ho hQ z n rfl rfl + have hb (z n : ℕ) (b : ZFSet.{u}) := Formula.unary_spec hf 5 6 2 0 + (cons b (cons (natSet n) (cons (natSet z) e))) ho hQ z rfl + have hi (z n : ℕ) := Formula.iteration_spec 5 6 1 0 3 (Formula.primitiveStep ψ) + (cons (natSet (f z)) (cons (natSet n) (cons (natSet z) e))) ho hQ n (f z) rfl rfl + (fun i v => g (Nat.pair z (Nat.pair i v))) + (Formula.primitiveStep_spec hg _ ho hQ z rfl) + simp only [Formula.primitiveRecursion,Formula.Eval] + constructor + · rintro ⟨z,hz,n,hnum,b,_,hp',hb',hi'⟩ + obtain ⟨z,rfl⟩ := decode z hz + obtain ⟨n,rfl⟩ := decode n hnum + have hN : N = Nat.pair z n := natSet_injective (hn.symm.trans ((hp z n b).mp hp')) + obtain rfl := (hb z n b).mp hb' + have h := (hi z n).mp hi' + simpa only [cons_succ,hN,Nat.unpaired,Nat.unpair_pair] using h + · intro h + let z := (Nat.unpair N).1 + let n := (Nat.unpair N).2 + refine ⟨natSet z,hmem _,natSet n,hmem _,natSet (f z),hmem _,?_,(hb z n _).mpr rfl,?_⟩ + · apply (hp z n _).mpr + simpa only [cons_succ,z,n,Nat.pair_unpair] using hn + · apply (hi z n).mpr + exact h + +theorem primitive_bounded_definition {f : ℕ → ℕ} (hf : Nat.Primrec f) : + ∃ φ : Formula, DefinesNatural.{u} φ f := by + induction hf with + | zero => exact ⟨.empty 0,definesNatural_zero⟩ + | succ => exact ⟨.successor 0 1,definesNatural_succ⟩ + | left => exact ⟨.naturalProjection false,Formula.naturalProjection_spec false⟩ + | right => exact ⟨.naturalProjection true,Formula.naturalProjection_spec true⟩ + | pair _ _ ihf ihg => + obtain ⟨φ,hφ⟩ := ihf; obtain ⟨ψ,hψ⟩ := ihg + exact ⟨.numericPair φ ψ,hφ.pair hψ⟩ + | comp _ _ ihf ihg => + obtain ⟨φ,hφ⟩ := ihf; obtain ⟨ψ,hψ⟩ := ihg + exact ⟨.numericComposition φ ψ,hφ.comp hψ⟩ + | prec _ _ ihf ihg => + obtain ⟨φ,hφ⟩ := ihf; obtain ⟨ψ,hψ⟩ := ihg + exact ⟨.primitiveRecursion φ ψ,hφ.prec hψ⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalProjectionFormula.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalProjectionFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..9548d353ef5ecc999409741f173b29548dc254d3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalProjectionFormula.lean @@ -0,0 +1,41 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NaturalDefinitions + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +universe u +namespace Formula + +def naturalProjection (right : Bool) : Formula := .existsMem 2 (.existsMem 3 + (.conj (naturalPair 4 5 1 0 3) (.equal 2 (if right then 0 else 1)))) + +theorem naturalProjection_spec (right : Bool) : DefinesNatural.{u} (naturalProjection right) + (fun n => if right then (Nat.unpair n).2 else (Nat.unpair n).1) := by + intro e ho hQ n hn + have select (a b : ZFSet.{u}) : cons b (cons a e) (if right then 0 else 1) = + if right then b else a := by cases right <;> rfl + have hmem (k : ℕ) : natSet.{u} k ∈ e 2 := by rw [ho]; exact (mem_omega _).mpr ⟨k,rfl⟩ + simp only [naturalProjection,Formula.Eval,cons_succ,select] + constructor + · rintro ⟨a,ha,b,hb,hpair,hy⟩ + rw [ho] at ha hb + obtain ⟨a,rfl⟩ := (mem_omega a).mp ha + obtain ⟨b,rfl⟩ := (mem_omega b).mp hb + have hp := (naturalPair_spec 4 5 1 0 3 (cons (natSet b) (cons (natSet a) e)) + ho hQ a b rfl rfl).mp hpair + have he : n = Nat.pair a b := natSet_injective (hn.symm.trans hp) + subst n + cases right <;> simpa only [Bool.false_eq_true,ite_false,ite_true,Nat.unpair_pair] using hy + · intro hy + refine ⟨natSet (Nat.unpair n).1,hmem _,natSet (Nat.unpair n).2,hmem _,?_,?_⟩ + · apply (naturalPair_spec 4 5 1 0 3 + (cons (natSet (Nat.unpair n).2) (cons (natSet (Nat.unpair n).1) e)) + ho hQ _ _ rfl rfl).mpr + simpa only [cons_succ,Nat.pair_unpair] using hn + · cases right <;> simpa only [Bool.false_eq_true,ite_false,ite_true] using hy + +end Formula +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalRealRelation.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalRealRelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..c094609cc2dc3a48d1bd0a4333faa837d2eece26 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalRealRelation.lean @@ -0,0 +1,93 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalNaturalRelationReal +import OAI.Computability.DegreeRigidity.SetModels.ModelArithmeticComprehension + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse EncodedForcing +universe u + +noncomputable def realRelation (B : Oracle) : ZFSet.{u} := + ZFSet.sep (fun p => ∃ n k : ℕ, p = ZFSet.pair (natSet n) (natSet k) ∧ B (Nat.pair n k) = true) + (ZFSet.prod ZFSet.omega ZFSet.omega) + +theorem realRelation_on (B : Oracle) : On ZFSet.omega (realRelation.{u} B) := + fun _ h => (ZFSet.mem_sep.mp h).1 + +theorem realRelation_pair (B : Oracle) (n k : ℕ) : + ZFSet.pair (natSet.{u} n) (natSet k) ∈ realRelation B ↔ B (Nat.pair n k) = true := by + rw [realRelation,ZFSet.mem_sep] + constructor + · rintro ⟨_,i,j,he,hb⟩ + obtain ⟨hi,hj⟩ := ZFSet.pair_inj.mp he + obtain rfl := natSet_injective hi + obtain rfl := natSet_injective hj + exact hb + · intro hb + exact ⟨ZFSet.mem_prod.mpr ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩, + natSet k,(mem_omega _).mpr ⟨k,rfl⟩,rfl⟩,n,k,rfl,hb⟩ + +namespace Formula +def realRelationMember (o Q B p : ℕ) : Formula := + .existsMem o (.existsMem (o+1) (.conj (.orderedPair (p+2) 1 0) + (columnBit (o+2) (Q+2) 1 (B+2) 0))) + +theorem realRelationMember_spec (o Q B p : ℕ) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) + (A : Oracle) (hA : e B = realCode A) : + (realRelationMember o Q B p).Eval e ↔ e p ∈ realRelation A := by + simp only [realRelationMember,Formula.Eval,eval_orderedPair,cons_zero,cons_succ] + rw [ho] + constructor + · rintro ⟨x,hx,y,hy,he,hb⟩ + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + obtain ⟨k,rfl⟩ := (mem_omega y).mp hy + rw [he,realRelation_pair] + exact (columnBit_spec (o+2) (Q+2) 1 (B+2) 0 + (cons (natSet k) (cons (natSet n) e)) ho hQ A hA n k rfl rfl).mp hb + · intro hp + obtain ⟨_,n,k,he,hb⟩ := ZFSet.mem_sep.mp hp + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,natSet k,(mem_omega _).mpr ⟨k,rfl⟩,he, + (columnBit_spec (o+2) (Q+2) 1 (B+2) 0 + (cons (natSet k) (cons (natSet n) e)) ho hQ A hA n k rfl rfl).mpr hb⟩ +end Formula + +theorem sourceT_realRelation (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {B : Oracle} (hB : B ∈ modelReals M) : realRelation B ∈ M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω + let e := cons ZFSet.omega (cons Q (fun _ => realCode B)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hω + rcases i with _|i; exact hQM + exact hB + have hs := sep_mem M hM hS (Formula.realRelationMember 1 2 3 0) e he + (product_mem M hM hT.pairing hT.union hT.powerSet hS hω hω) + have heq : ZFSet.sep (fun p => (Formula.realRelationMember 1 2 3 0).Eval (cons p e)) + (ZFSet.prod ZFSet.omega ZFSet.omega) = realRelation B := by + apply ZFSet.ext; intro p + rw [ZFSet.mem_sep,Formula.realRelationMember_spec 1 2 3 0 (cons p e) rfl hQ B rfl] + exact ⟨And.right,fun h => ⟨realRelation_on B h,h⟩⟩ + exact heq ▸ hs + +theorem sourceT_realRelation_descent (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {B : Oracle} (hB : B ∈ modelReals M) + (hbad : ∃ f : ℕ → ℕ, ∀ n, B (Nat.pair (f (n+1)) (f n)) = true) : + ∃ f : ℕ → ℕ, ∃ G ∈ modelReals M, + (∀ n k, G (Nat.pair n k) = true ↔ k = f n) ∧ + ∀ n, B (Nat.pair (f (n+1)) (f n)) = true := by + have hw : ¬ WellFounded (Rel ZFSet.omega (realRelation.{u} B)) := by + intro hw + obtain ⟨f,hf⟩ := hbad + exact wellFounded_no_descent _ _ hw (fun n => natSet (f n)) + (fun n => (mem_omega _).mpr ⟨f n,rfl⟩) + (fun n => (realRelation_pair B _ _).mpr (hf n)) + obtain ⟨f,G,hGM,hG,hf⟩ := sourceT_natural_descent_real M hM hT + (sourceT_realRelation M hM hT hB) (realRelation_on B) hw + exact ⟨f,G,hGM,hG,fun n => (realRelation_pair B _ _).mp (hf n)⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalTermFormula.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalTermFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..d2d6c7541840deafafcdd00f9ba1f3f8d8f7f464 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NaturalTermFormula.lean @@ -0,0 +1,66 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NaturalMultiplicationFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +universe u + +inductive NaturalTerm where + | var (i : ℕ) + | binary (mul : Bool) (a b : NaturalTerm) + +namespace NaturalTerm +def eval (v : ℕ → ℕ) : NaturalTerm → ℕ + | .var i => v i + | .binary m a b => if m then eval v a * eval v b else eval v a + eval v b + +def operation (m : Bool) (o Q a b y : ℕ) : Formula := + if m then .multiplication o Q a b y else .addition o Q a b y + +theorem operation_spec (m : Bool) (o Q x n y : ℕ) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) + (a b : ℕ) (ha : e x = natSet a) (hb : e n = natSet b) : + (operation m o Q x n y).Eval e ↔ e y = natSet (if m then a*b else a+b) := by + cases m with + | false => exact Formula.addition_spec o Q x n y e ho hQ a b ha hb + | true => exact Formula.multiplication_spec o Q x n y e ho hQ a b ha hb + +def graph (o Q y : ℕ) (v : ℕ → ℕ) : NaturalTerm → Formula + | .var i => .equal y (v i) + | .binary m a b => .existsMem o (.existsMem (o+1) + (.conj (graph (o+2) (Q+2) 1 (fun i => v i+2) a) + (.conj (graph (o+2) (Q+2) 0 (fun i => v i+2) b) (operation m (o+2) (Q+2) 1 0 (y+2))))) + +theorem graph_spec (t : NaturalTerm) (o Q y : ℕ) (v : ℕ → ℕ) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) + (a : ℕ → ℕ) (ha : ∀ i, e (v i) = natSet (a i)) : + (graph o Q y v t).Eval e ↔ e y = natSet (t.eval a) := by + induction t generalizing o Q y v e with + | var i => exact congrArg (fun z => e y = z) (ha i) |>.to_iff + | binary m t s iht ihs => + have hωmem (k : ℕ) : natSet.{u} k ∈ e o := by + rw [ho]; exact (mem_omega _).mpr ⟨k,rfl⟩ + have ht (w z : ZFSet.{u}) : + (graph (o+2) (Q+2) 1 (fun i => v i+2) t).Eval (cons z (cons w e)) ↔ w = natSet (t.eval a) := + iht (o+2) (Q+2) 1 (fun i => v i+2) (cons z (cons w e)) ho hQ ha + have hs (w z : ZFSet.{u}) : + (graph (o+2) (Q+2) 0 (fun i => v i+2) s).Eval (cons z (cons w e)) ↔ z = natSet (s.eval a) := + ihs (o+2) (Q+2) 0 (fun i => v i+2) (cons z (cons w e)) ho hQ ha + have hop := operation_spec m (o+2) (Q+2) 1 0 (y+2) + (cons (natSet (s.eval a)) (cons (natSet (t.eval a)) e)) ho hQ (t.eval a) (s.eval a) rfl rfl + simp only [graph,Formula.Eval] + constructor + · rintro ⟨w,_,z,_,hw,hz,h⟩ + obtain rfl := (ht w z).mp hw + obtain rfl := (hs _ z).mp hz + exact hop.mp h + · intro h + refine ⟨natSet (t.eval a),hωmem (t.eval a), + natSet (s.eval a),hωmem (s.eval a), + (ht _ _).mpr rfl,(hs _ _).mpr rfl,hop.mpr h⟩ + +end NaturalTerm +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericBinding.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericBinding.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca89cc7b5617695a6952a46ea0d3012284b55c05 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericBinding.lean @@ -0,0 +1,72 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericHierarchy +import OAI.Computability.DegreeRigidity.SetModels.BindCanonicalArithmetic + +namespace OAI + +namespace TuringRigidity.NumericSyntax +open ElementaryModel BoundedSetTheory TransitiveNameModel BoundedDefinability RelativeConstructible +universe u + +noncomputable def bindNumbers (p : SentenceForm) : SentenceForm := + .ex (.conj (canonicalOmega 0) + (.ex (.conj (fromBounded (squareFormula 1 0)) + (.ex (.conj (FullSetForcing.ownPower 1 0) + (.ex (.conj (fromBounded (.empty 0)) p))))))) + +theorem bindNumbers_spec (N : ZFSet.{u}) (hN : Transitive N) + (hw : ZFSet.omega.{u} ∈ N) (hs : ZFSet.prod ZFSet.omega ZFSet.omega ∈ N) + (p : SentenceForm) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ N) : + (bindNumbers p).Sat (N : Set ZFSet) e ↔ + ∃ B ∈ N, PowerBound N (ZFSet.prod ZFSet.omega ZFSet.omega) B ∧ + p.Sat (N : Set ZFSet) (cons (natSet 0) (cons B + (cons (ZFSet.prod ZFSet.omega ZFSet.omega) (cons ZFSet.omega e)))) := by + have hc {a : ZFSet.{u}} {d : ℕ → ZFSet.{u}} (ha : a ∈ N) (hd : ∀ i, d i ∈ N) : + ∀ i, cons a d i ∈ N := by intro i; cases i; exact ha; exact hd _ + have hz : natSet.{u} 0 ∈ N := hN _ hw _ ((mem_omega _).mpr ⟨0,rfl⟩) + have hwf (w : ZFSet.{u}) (hwN : w ∈ N) := canonicalOmega_spec N hN hw 0 (cons w e) (hc hwN he) + have hsf (s : ZFSet.{u}) (hsN : s ∈ N) : + (fromBounded (squareFormula 1 0)).Sat (N : Set ZFSet) (cons s (cons ZFSet.omega e)) ↔ + s = ZFSet.prod ZFSet.omega ZFSet.omega := by + rw [bounded_sat,Formula.absolute _ N hN _ (hc hsN (hc hw he)),squareFormula_spec] + rfl + have hbf (B : ZFSet.{u}) (hBN : B ∈ N) : + (FullSetForcing.ownPower 1 0).Sat (N : Set ZFSet) + (cons B (cons (ZFSet.prod ZFSet.omega ZFSet.omega) (cons ZFSet.omega e))) ↔ + PowerBound N (ZFSet.prod ZFSet.omega ZFSet.omega) B := by + rw [FullSetForcing.ownPower_spec N hN _ _ _ (hc hBN (hc hs (hc hw he)))] + rfl + have hzf (B z : ZFSet.{u}) (hBN : B ∈ N) (hzN : z ∈ N) : + (fromBounded (.empty 0)).Sat (N : Set ZFSet) + (cons z (cons B (cons (ZFSet.prod ZFSet.omega ZFSet.omega) (cons ZFSet.omega e)))) ↔ + z = natSet 0 := by + rw [bounded_sat,Formula.absolute _ N hN _ (hc hzN (hc hBN (hc hs (hc hw he)))),Formula.eval_empty] + rfl + change (∃ w ∈ N, (canonicalOmega 0).Sat _ (cons w e) ∧ + ∃ s ∈ N, (fromBounded (squareFormula 1 0)).Sat _ (cons s (cons w e)) ∧ + ∃ B ∈ N, (FullSetForcing.ownPower 1 0).Sat _ (cons B (cons s (cons w e))) ∧ + ∃ z ∈ N, (fromBounded (.empty 0)).Sat _ (cons z (cons B (cons s (cons w e)))) ∧ + p.Sat _ (cons z (cons B (cons s (cons w e))))) ↔ _ + constructor + · rintro ⟨w,hwN,hwS,s,hsN,hsS,B,hBN,hBS,z,hzN,hzS,hp⟩ + obtain rfl := (hwf w hwN).mp hwS + obtain rfl := (hsf s hsN).mp hsS + obtain rfl := (hzf B z hBN hzN).mp hzS + exact ⟨B,hBN,(hbf B hBN).mp hBS,hp⟩ + · rintro ⟨B,hBN,hBS,hp⟩ + exact ⟨_,hw,(hwf _ hw).mpr rfl,_,hs,(hsf _ hs).mpr rfl,B,hBN,(hbf B hBN).mpr hBS, + _,hz,(hzf B _ hBN hz).mpr rfl,hp⟩ + +theorem finiteGraph_subset (f : ℕ → ℕ) (k : ℕ) : + finiteNaturalGraph.{u} f k ⊆ ZFSet.prod ZFSet.omega ZFSet.omega := by + intro z hz + obtain ⟨i,_,rfl⟩ := (mem_finiteNaturalGraph f k z).mp hz + exact ZFSet.mem_prod.mpr ⟨_,(mem_omega _).mpr ⟨i,rfl⟩,_,(mem_omega _).mpr ⟨f i,rfl⟩,rfl⟩ + +theorem covers_of_power {N B : ZFSet.{u}} + (hfin : ∀ f k, finiteNaturalGraph f k ∈ N) + (hB : PowerBound N (ZFSet.prod ZFSet.omega ZFSet.omega) B) : Covers B := + fun f k => (hB _).mpr ⟨hfin f k,finiteGraph_subset f k⟩ + +end TuringRigidity.NumericSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericDefSystem.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericDefSystem.lean new file mode 100644 index 0000000000000000000000000000000000000000..b88e6c6cf3cbf6641b1b4cbfedf73d8d3e31bd1c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericDefSystem.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericTruth +import OAI.Computability.DegreeRigidity.Syntax.VariableCertificateBounds + +namespace OAI + +namespace TuringRigidity.NumericSyntax +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding RelativeConstructible +open BoundedDefinability SetModelFunctions SetModelReals +universe u +theorem boundWitness_allBounds (Q B c b : ℕ) : + Numeric.{u} (fun e => BoundWitness (e Q) (e B) (e c) (e b)) := + (((leastFamily_definable (Q+2) (c+2) 1).and + ((setSupportRecursion_definable 1 0).and (defPairMem (c+2) (b+2) 0))).existsMem + (B+1)).existsMem Q + +theorem tupleAdequate_allBounds (Q B G c t : ℕ) : + Numeric.{u} (fun e => TupleAdequate (e Q) (e B) (e G) (e c) (e t)) := + ((((defOrderedPair (t+3) 2 1).and + ((boundWitness_allBounds (Q+3) (B+3) (c+3) 0).and + (defSubset 0 2))).existsNat).existsMem (G+1)).existsNat + +theorem setTruthRecursion_allBounds (Q B a G T f s : ℕ) : + Numeric.{u} (fun e => SetTruthRecursion (e Q) (e B) (e G) (e a) (e T) (e f) (e s)) := by + have hn := defAllMem ((((tupleAdequate_allBounds (Q+3) (B+3) (G+3) 1 0).and + (defOrderedPair 2 1 0)).existsMem (T+2)).existsMem (f+1)) s + have hr := defAllMem (defAllMem (defImp + (tupleAdequate_allBounds (Q+2) (B+2) (G+2) 1 0) + (defIff (defPairMem 1 0 (s+2)) + (setTruthStep_variable (a+2) (G+2) (T+2) (s+2) 1 0))) (T+1)) f + exact hn.and hr + +theorem truthWitness_allBounds (Q B a G T c s : ℕ) : + Numeric.{u} (fun e => TruthWitness (e Q) (e B) (e G) (e a) (e T) (e c) (e s)) := + ((leastFamily_definable (Q+1) (c+1) 0).and + (setTruthRecursion_allBounds (Q+1) (B+1) (a+1) (G+1) (T+1) 0 (s+1))).existsMem Q + +theorem satisfactionWitness_allBounds (Q B a G H T z : ℕ) : + Numeric.{u} (fun e => SatisfactionWitness (e Q) (e B) (e G) (e H) (e a) (e T) (e z)) := + ((((truthWitness_allBounds (Q+3) (B+3) (a+3) (G+3) (T+3) 2 0).and + ((defPairMem 2 1 0).and (defOrderedPair (z+3) 2 1))).existsMem (H+2)).existsMem + (T+1)).existsNat + +theorem parameterAdequate_allBounds (Q B G c t : ℕ) : + Numeric.{u} (fun e => ParameterAdequate (e Q) (e B) (e G) (e c) (e t)) := + ((((defOrderedPair (t+3) 2 1).and + ((boundWitness_allBounds (Q+3) (B+3) (c+3) 0).and + (defAllMem (defOr (member_definable 0 3) (equal_definable 0 3)) 0))).existsNat).existsMem (G+1)).existsNat + +theorem definitionWitness_allBounds (Q B a G T Z S : ℕ) : + Numeric.{u} (fun e => DefinitionWitness (e Q) (e B) (e G) (e a) (e T) (e Z) (e S)) := + (((parameterAdequate_allBounds (Q+2) (B+2) (G+2) 1 0).and + (definesSubset_variable (a+2) (G+2) (T+2) (Z+2) 1 0 (S+2))).existsMem (T+1)).existsNat + +theorem satisfactionSystem_allBounds (Q B a G T H Z : ℕ) : + Numeric.{u} (fun e => SatisfactionSystem (e Q) (e B) (e a) (e G) (e T) (e H) (e Z)) := by + have ht := defAllNat (defAllMem (defImp (leastFamily_definable (Q+2) 1 0) + ((setTruthRecursion_allBounds (Q+3) (B+3) (a+3) (G+3) (T+3) 1 0).existsMem (H+2))) (Q+1)) + have hn := defAllMem (satisfactionWitness_allBounds (Q+1) (B+1) (a+1) (G+1) (H+1) (T+1) 0) Z + have hc := defAllNat (defAllMem (defAllMem + (defImp (truthWitness_allBounds (Q+3) (B+3) (a+3) (G+3) (T+3) 2 0) + (defImp (defPairMem 2 1 0) (defPairMem 2 1 (Z+3)))) (H+2)) (T+1)) + exact (tupleSystem_definable a G T).and (ht.and (hn.and hc)) + +theorem defSystem_allBounds (Q B a G T H Z D : ℕ) : + Numeric.{u} (fun e => DefSystem (e Q) (e B) (e a) (e G) (e T) (e H) (e Z) (e D)) := by + have hn := defAllMem (definitionWitness_allBounds (Q+1) (B+1) (a+1) (G+1) (T+1) (Z+1) 0) D + have hc := defAllNat (defAllMem (defImp (parameterAdequate_allBounds (Q+2) (B+2) (G+2) 1 0) + ((definesSubset_variable (a+3) (G+3) (T+3) (Z+3) 2 1 0).existsMem (D+2))) (T+1)) + exact (satisfactionSystem_allBounds Q B a G T H Z).and (hn.and hc) + +end TuringRigidity.NumericSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericDomain.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericDomain.lean new file mode 100644 index 0000000000000000000000000000000000000000..ebcb7242758b1aa323cc0690dac2d7dbc5025a6f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericDomain.lean @@ -0,0 +1,86 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericDefSystem +import OAI.Computability.DegreeRigidity.Constructibility.DomainSyntaxClosure + +namespace OAI + +namespace TuringRigidity.NumericSyntax +open ElementaryModel BoundedSetTheory TransitiveNameModel BoundedDefinability +universe u + +def Domain (P : ZFSet.{u} → (ℕ → ZFSet.{u}) → Prop) : Prop := + ∃ p : SentenceForm, ∀ B, Covers B → ∀ N : ZFSet.{u}, Transitive N → + (∀ i, params B i ∈ N) → ∀ e, (∀ i, e i ∈ N) → + (p.Sat (N : Set ZFSet) (mix e (params B)) ↔ P N e) + +variable {P Q : ZFSet.{u} → (ℕ → ZFSet.{u}) → Prop} + +theorem Numeric.toDomain {P : (ℕ → ZFSet.{u}) → Prop} (h : Numeric P) : + Domain (fun _ e => P e) := by + obtain ⟨p,hp⟩ := h + refine ⟨fromBounded p,?_⟩ + intro B hB N hN hd e he + rw [bounded_sat,Formula.absolute p N hN _ (by + intro i; unfold mix; split <;> first | exact he _ | exact hd _)] + exact hp B hB e + +theorem Domain.congr (h : Domain P) (he : ∀ N e, P N e ↔ Q N e) : Domain Q := by + obtain ⟨p,hp⟩ := h + exact ⟨p,fun B hB N hN hd e he' => (hp B hB N hN hd e he').trans (he N e)⟩ + +theorem Domain.and (h : Domain P) (k : Domain Q) : Domain (fun N e => P N e ∧ Q N e) := by + obtain ⟨p,hp⟩ := h; obtain ⟨q,hq⟩ := k + exact ⟨.conj p q,fun B hB N hN hd e he => + and_congr (hp B hB N hN hd e he) (hq B hB N hN hd e he)⟩ + +theorem Domain.neg (h : Domain P) : Domain (fun N e => ¬ P N e) := by + obtain ⟨p,hp⟩ := h + exact ⟨.neg p,fun B hB N hN hd e he => not_congr (hp B hB N hN hd e he)⟩ + +theorem Domain.imp (h : Domain P) (k : Domain Q) : Domain (fun N e => P N e → Q N e) := + (h.and k.neg).neg.congr (fun _ _ => by tauto) + +theorem Domain.subst (h : Domain P) (r : ℕ → ℕ) : Domain (fun N e => P N (e ∘ r)) := by + obtain ⟨p,hp⟩ := h + refine ⟨p.rename (slotMap r id),?_⟩ + intro B hB N hN hd e he + rw [SentenceForm.sat_rename] + change p.Sat _ (mix e (params B) ∘ slotMap r id) ↔ _ + rw [mix_slotMap,Function.comp_id] + exact hp B hB N hN hd (e ∘ r) (fun i => he (r i)) + +theorem Domain.existsSet (h : Domain P) : Domain (fun N e => ∃ x ∈ N, P N (cons x e)) := by + obtain ⟨p,hp⟩ := h + refine ⟨.ex (p.rename bindSlots),?_⟩ + intro B hB N hN hd e he + change (∃ x ∈ N, (p.rename bindSlots).Sat _ (cons x (mix e (params B)))) ↔ _ + apply exists_congr; intro x + apply and_congr_right; intro hx + rw [SentenceForm.sat_rename] + change p.Sat _ (cons x (mix e (params B)) ∘ bindSlots) ↔ _ + rw [bind_mix] + exact hp B hB N hN hd (cons x e) (by intro i; cases i; exact hx; exact he _) + +theorem Domain.allMem (h : Domain P) (a : ℕ) : Domain (fun N e => ∀ x ∈ e a, P N (cons x e)) := by + obtain ⟨p,hp⟩ := ((member_definable 0 (a+1)).toDomain.and h.neg).existsSet.neg + refine ⟨p,?_⟩ + intro B hB N hN hd e he + rw [hp B hB N hN hd e he] + change (¬ ∃ x ∈ N, x ∈ e a ∧ ¬ P N (cons x e)) ↔ _ + classical + constructor + · intro h x hx + by_contra hn + exact h ⟨x,hN _ (he a) x hx,hx,hn⟩ + · intro h ⟨x,_,hx,hn⟩ + exact hn (h x hx) + +theorem powerBound_domain (a q : ℕ) : Domain (fun N e => RelativeConstructible.PowerBound N (e a) (e q)) := by + refine ⟨FullSetForcing.ownPower (2*a) (2*q),?_⟩ + intro B hB N hN hd e he + rw [FullSetForcing.ownPower_spec N hN _ _ _ (by + intro i; unfold mix; split <;> first | exact he _ | exact hd _)] + simp only [mix_even,RelativeConstructible.PowerBound] + +end TuringRigidity.NumericSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericFamilySupport.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericFamilySupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8222947b38ac8d656aa8159cab553f26550b636 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericFamilySupport.lean @@ -0,0 +1,55 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericParameters +import OAI.Computability.DegreeRigidity.Constructibility.UniformSentenceSupport + +namespace OAI + +namespace TuringRigidity.NumericSyntax +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding RelativeConstructible +open BoundedDefinability SetModelFunctions SetModelReals +universe u +theorem setStep_definable (s c : ℕ) : + Numeric.{u} (fun e => SetStep (e s) (e c)) := by + have he := ((binaryGraph_definable _ (atomic_primrec 0) 1 0 (c+2)).existsNat).existsNat + have hm := ((binaryGraph_definable _ (atomic_primrec 1) 1 0 (c+2)).existsNat).existsNat + have ha := ((binaryGraph_definable _ (binary_primrec 2) 1 0 (c+2)).existsMem (s+1)).existsMem s + have hn := (unaryGraph_definable _ (unary_primrec 3) 0 (c+1)).existsMem s + have hx := (unaryGraph_definable _ (unary_primrec 4) 0 (c+1)).existsMem s + exact defOr he (defOr hm (defOr ha (defOr hn hx))) + +theorem setClosed_definable (s : ℕ) : + Numeric.{u} (fun e => SetClosed (e s)) := by + have hs := defAllMem (memberNat 0) s + have hc := defAllMem (setStep_definable (s+1) 0) s + exact (hs.and hc).congr (fun e => (setClosed_spec (e s)).symm) + +theorem leastFamily_definable (q c s : ℕ) : + Numeric.{u} (fun e => LeastFamily (e q) (e c) (e s)) := by + have hm := defAllMem (defImp (member_definable (c+1) 0) + (defImp (setClosed_definable 0) (defSubset (s+1) 0))) q + exact (member_definable c s).and ((setClosed_definable s).and hm) + +theorem setSupportStep_definable (g c b : ℕ) : + Numeric.{u} (fun e => SetSupportStep (e g) (e c) (e b)) := by + have hm : Primrec₂ (fun i j : ℕ => max i j + 1) := Primrec.succ.comp Primrec.nat_max + have ha (t : ℕ) := (((binaryGraph_definable _ (atomic_primrec t) 1 0 (c+2)).and + (binaryGraph_definable _ hm 1 0 (b+2))).existsNat).existsNat + have hc := (((((binaryGraph_definable _ (binary_primrec 2) 3 2 (c+4)).and + ((defPairMem 3 1 (g+4)).and ((defPairMem 2 0 (g+4)).and + (binaryGraph_definable max Primrec.nat_max 1 0 (b+4))))).existsNat).existsNat).existsNat).existsNat + have hn := ((unaryGraph_definable _ (unary_primrec 3) 0 (c+1)).and + (defPairMem 0 (b+1) (g+1))).existsNat + have hp : Primrec (fun n : ℕ => n-1) := Primrec.nat_sub.comp Primrec.id (Primrec.const 1) + have hx := (((unaryGraph_definable _ (unary_primrec 4) 1 (c+2)).and + ((defPairMem 1 0 (g+2)).and (unaryGraph_definable _ hp 0 (b+2)))).existsNat).existsNat + exact defOr (ha 0) (defOr (ha 1) (defOr hc (defOr hn hx))) + +theorem setSupportRecursion_definable (f g : ℕ) : + Numeric.{u} (fun e => SetSupportRecursion (e f) (e g)) := by + have hn := defAllMem (((defOrderedPair 2 1 0).existsNat).existsMem (f+1)) g + have hr := defAllMem (defAllNat (defIff (defPairMem 1 0 (g+2)) + (setSupportStep_definable (g+2) 1 0))) f + exact hn.and hr + +end TuringRigidity.NumericSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericHierarchy.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericHierarchy.lean new file mode 100644 index 0000000000000000000000000000000000000000..3dabd0d632e5554aabfc270829617ccaac757914 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericHierarchy.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericDomain +import OAI.Computability.DegreeRigidity.Constructibility.SeedBoundStageSyntax + +namespace OAI + +namespace TuringRigidity.NumericSyntax +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding RelativeConstructible +open BoundedDefinability SetModelFunctions SetModelReals +universe u +theorem stageStep_definable (s f r x A : ℕ) : + Numeric.{u} (fun e => StageStep (e s) (e f) (e r) (e x) (e A)) := by + have hn := defAllMem (defOr (member_definable 0 (s+1)) + ((((defPairMem 1 0 (f+3)).and (member_definable 2 0)).existsMem (r+2)).existsMem (x+1))) A + have hc := defAllMem (defAllMem (defImp (defPairMem 1 0 (f+2)) + (defSubset 0 (A+2))) (r+1)) x + exact (defSubset s A).and (hn.and hc) + +theorem functionGraph_definable (d r f : ℕ) : + Numeric.{u} (fun e => FunctionGraph (e d) (e r) (e f)) := by + refine ⟨.functionGraph (2*f) (2*d) (2*r),?_⟩ + intro B hB e + simp only [Formula.eval_functionGraph,mix_even,FunctionGraph] + +theorem insertedSelf_definable (s R : ℕ) : + Numeric.{u} (fun e => e s = insert (e R) (e R)) := by + have h := (member_definable R s).and ((defSubset R s).and + (defAllMem (defOr (equal_definable 0 (R+1)) (member_definable 0 (R+1))) s)) + apply h.congr + intro e + constructor + · rintro ⟨hR,hsub,hall⟩ + apply ZFSet.ext; intro z + rw [ZFSet.mem_insert_iff] + exact ⟨fun hz => hall z hz,fun h => h.elim (fun he => he ▸ hR) (fun hz => hsub hz)⟩ + · rintro he + rw [he] + exact ⟨ZFSet.mem_insert_iff.mpr (Or.inl rfl), + fun _ hz => ZFSet.mem_insert_iff.mpr (Or.inr hz),fun _ hz => ZFSet.mem_insert_iff.mp hz⟩ + +theorem checkedDefSuccessor_domainDefinable : + Domain.{u} (fun N e => CheckedDefSuccessor N (e 2) (e 3) (e 1) (e 0)) := by + have hs := (defSystem_allBounds 5 4 7 3 2 1 0 6).toDomain.existsSet.existsSet.existsSet.existsSet + have hb := (powerBound_domain 4 1).and (powerBound_domain 5 0) + exact (hb.and hs).existsSet.existsSet + +theorem checkedHierarchyGraph_domainDefinable + (w sq s d r f : ℕ) : + Domain.{u} (fun N e => CheckedHierarchyGraph N (e w) (e sq) (e s) (e d) (e r) (e f)) := by + have hd := (defAllMem (defSubset 0 (d+1)) d).toDomain + have hf := (functionGraph_definable d r f).toDomain + have hv := (checkedDefSuccessor_domainDefinable).subst + (fun i => match i with | 0 => 1 | 1 => 0 | 2 => w+3 | _ => sq+3) + have hs := (stageStep_definable (s+3) (f+3) (r+3) 2 0).toDomain.and hv + have hi := (defPairMem 1 0 (f+2)).toDomain.imp hs.existsSet + exact hd.and (hf.and ((hi.allMem (r+1)).allMem d)) + +theorem seedBoundStage_domainDefinable : + Domain.{u} (fun N e => SeedBoundStage N (e 3) (e 4) (e 2) (e 1) (e 0)) := by + have h := (insertedSelf_definable 3 6).toDomain.and + ((member_definable 5 2).toDomain.and + ((checkedHierarchyGraph_domainDefinable 7 8 3 2 0 1).and + (stageStep_definable 3 1 0 5 4).toDomain)) + exact h.existsSet.existsSet.existsSet.existsSet + +end TuringRigidity.NumericSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericParameters.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd4e85779c6621eba4e87f4fd47a6b9cf479b2ad --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericParameters.lean @@ -0,0 +1,120 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NaturalPrimitiveRecursion +import OAI.Computability.DegreeRigidity.Syntax.SentenceCodeDefinability + +namespace OAI + +namespace TuringRigidity.NumericSyntax +open BoundedSetTheory TransitiveNameModel BoundedDefinability SentenceCoding +universe u + +def params (Q : ZFSet.{u}) : ℕ → ZFSet.{u} := + cons ZFSet.omega (cons Q (fun _ => natSet 0)) + +def Covers (Q : ZFSet.{u}) : Prop := ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ Q + +def Numeric (P : (ℕ → ZFSet.{u}) → Prop) : Prop := + ∃ p : Formula, ∀ Q, Covers Q → ∀ e, p.Eval (mix e (params Q)) ↔ P e + +variable {P Q : (ℕ → ZFSet.{u}) → Prop} + +theorem Numeric.congr (h : Numeric P) (he : ∀ e, P e ↔ Q e) : Numeric Q := by + obtain ⟨p,hp⟩ := h + exact ⟨p,fun B hB e => (hp B hB e).trans (he e)⟩ + +theorem Numeric.subst (h : Numeric P) (r : ℕ → ℕ) : Numeric (fun e => P (e ∘ r)) := by + obtain ⟨p,hp⟩ := h + refine ⟨p.rename (slotMap r id),?_⟩ + intro B hB e + simpa only [Formula.eval_rename_comp,mix_slotMap,Function.comp_id] using hp B hB (e ∘ r) + +theorem Numeric.neg (h : Numeric P) : Numeric (fun e => ¬ P e) := by + obtain ⟨p,hp⟩ := h + exact ⟨.neg p,fun B hB e => not_congr (hp B hB e)⟩ + +theorem Numeric.and (h : Numeric P) (k : Numeric Q) : Numeric (fun e => P e ∧ Q e) := by + obtain ⟨p,hp⟩ := h; obtain ⟨q,hq⟩ := k + exact ⟨.conj p q,fun B hB e => and_congr (hp B hB e) (hq B hB e)⟩ + +theorem Numeric.existsMem (h : Numeric P) (i : ℕ) : + Numeric (fun e => ∃ x ∈ e i, P (cons x e)) := by + obtain ⟨p,hp⟩ := h + refine ⟨.existsMem (2*i) (p.rename bindSlots),?_⟩ + intro B hB e + simp only [Formula.Eval,mix_even,Formula.eval_rename_comp,bind_mix,hp B hB] + +theorem Numeric.existsNat (h : Numeric P) : + Numeric (fun e => ∃ x ∈ ZFSet.omega, P (cons x e)) := by + obtain ⟨p,hp⟩ := h + refine ⟨.existsMem 1 (p.rename bindSlots),?_⟩ + intro B hB e + simp only [Formula.Eval,Formula.eval_rename_comp,bind_mix,hp B hB] + rfl + +theorem defOr (h : Numeric P) (k : Numeric Q) : Numeric (fun e => P e ∨ Q e) := + (h.neg.and k.neg).neg.congr (fun _ => by tauto) +theorem defImp (h : Numeric P) (k : Numeric Q) : Numeric (fun e => P e → Q e) := + (h.and k.neg).neg.congr (fun _ => by tauto) +theorem defIff (h : Numeric P) (k : Numeric Q) : Numeric (fun e => P e ↔ Q e) := + ((defImp h k).and (defImp k h)).congr (fun _ => iff_def.symm) +theorem defAllMem (h : Numeric P) (i : ℕ) : Numeric (fun e => ∀ x ∈ e i, P (cons x e)) := + (h.neg.existsMem i).neg.congr (fun _ => by simp) +theorem defAllNat (h : Numeric P) : Numeric (fun e => ∀ x ∈ ZFSet.omega, P (cons x e)) := + h.neg.existsNat.neg.congr (fun _ => by simp) + +theorem equal_definable (i j : ℕ) : Numeric (fun e => e i = e j) := + ⟨.equal (2*i) (2*j),fun _ _ e => by simp [Formula.Eval]⟩ +theorem member_definable (i j : ℕ) : Numeric (fun e => e i ∈ e j) := + ⟨.member (2*i) (2*j),fun _ _ e => by simp [Formula.Eval]⟩ +theorem memberNat (i : ℕ) : Numeric (fun e => e i ∈ ZFSet.omega) := + ⟨.member (2*i) 1,fun _ _ e => by simp [Formula.Eval,mix,params]⟩ +theorem equalZero (i : ℕ) : Numeric (fun e => e i = natSet 0) := + ⟨.empty (2*i),fun _ _ e => by simp only [Formula.eval_empty,mix_even]; rfl⟩ +theorem defSubset (i j : ℕ) : Numeric (fun e => e i ⊆ e j) := + defAllMem (member_definable 0 (j+1)) i +theorem defPairMem (i j g : ℕ) : Numeric (fun e => ZFSet.pair (e i) (e j) ∈ e g) := + ⟨.pairMem (2*i) (2*j) (2*g),fun _ _ e => by simp only [Formula.eval_pairMem,mix_even]⟩ +theorem defOrderedPair (z i j : ℕ) : Numeric (fun e => e z = ZFSet.pair (e i) (e j)) := + ⟨.orderedPair (2*z) (2*i) (2*j),fun _ _ e => by simp only [Formula.eval_orderedPair,mix_even]⟩ + +theorem unaryGraph_definable (f : ℕ → ℕ) (hf : Primrec f) (i j : ℕ) : + Numeric (fun e => UnaryGraph f (e i) (e j)) := by + obtain ⟨p,hp⟩ := primitive_bounded_definition (Primrec.nat_iff.mp hf) + refine ⟨.conj (.member (2*i) 1) (Formula.unary p 1 3 (2*i) (2*j)),?_⟩ + intro B hB e + simp only [Formula.Eval,mix_even] + change (e i ∈ ZFSet.omega ∧ (Formula.unary p 1 3 (2*i) (2*j)).Eval (mix e (params B))) ↔ _ + constructor + · rintro ⟨hn,h⟩ + obtain ⟨n,hn⟩ := (mem_omega _).mp hn + refine ⟨n,hn,?_⟩ + simpa only [mix_even] using (Formula.unary_spec hp 1 3 (2*i) (2*j) (mix e (params B)) rfl hB n + (by simpa only [mix_even] using hn)).mp h + · rintro ⟨n,hn,hj⟩ + exact ⟨(mem_omega _).mpr ⟨n,hn⟩,(Formula.unary_spec hp 1 3 (2*i) (2*j) (mix e (params B)) rfl hB n + (by simpa only [mix_even] using hn)).mpr (by simpa only [mix_even] using hj)⟩ + +theorem binaryGraph_definable (f : ℕ → ℕ → ℕ) (hf : Primrec₂ f) (i j k : ℕ) : + Numeric (fun e => BinaryGraph f (e i) (e j) (e k)) := by + have hu : Primrec (Nat.unpaired f) := hf.comp (Primrec.fst.comp Primrec.unpair) (Primrec.snd.comp Primrec.unpair) + obtain ⟨p,hp⟩ := primitive_bounded_definition (Primrec.nat_iff.mp hu) + refine ⟨.conj (.member (2*i) 1) (.conj (.member (2*j) 1) + (Formula.pairedUnary p 1 3 (2*i) (2*j) (2*k))),?_⟩ + intro B hB e + simp only [Formula.Eval,mix_even] + change (e i ∈ ZFSet.omega ∧ e j ∈ ZFSet.omega ∧ + (Formula.pairedUnary p 1 3 (2*i) (2*j) (2*k)).Eval (mix e (params B))) ↔ _ + have hs (a b : ℕ) (ha : e i = natSet a) (hb : e j = natSet b) := + Formula.pairedUnary_spec hp 1 3 (2*i) (2*j) (2*k) (mix e (params B)) rfl hB a b + (by simpa only [mix_even] using ha) (by simpa only [mix_even] using hb) + simp only [mix_even,Nat.unpaired,Nat.unpair_pair] at hs + constructor + · rintro ⟨ha,hb,h⟩ + obtain ⟨a,ha⟩ := (mem_omega _).mp ha + obtain ⟨b,hb⟩ := (mem_omega _).mp hb + exact ⟨a,b,ha,hb,(hs a b ha hb).mp h⟩ + · rintro ⟨a,b,ha,hb,hc⟩ + exact ⟨(mem_omega _).mpr ⟨a,ha⟩,(mem_omega _).mpr ⟨b,hb⟩,(hs a b ha hb).mpr hc⟩ + +end TuringRigidity.NumericSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericStage.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericStage.lean new file mode 100644 index 0000000000000000000000000000000000000000..b72f1e1de7889ea5f7922792d013df755e0c4d6b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericStage.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericBinding + +namespace OAI + +namespace TuringRigidity.NumericSyntax +open ElementaryModel BoundedSetTheory TransitiveNameModel BoundedDefinability RelativeConstructible +universe u + +def stageSlots (n : ℕ) : ℕ := + if n % 2 = 0 then + match n / 2 with | 0 => 4 | 1 => 5 | 2 => 6 | 3 => 3 | _ => 2 + else match n / 2 with | 0 => 3 | 1 => 1 | _ => 0 + +def stageInputs (e : ℕ → ZFSet.{u}) : ℕ → ZFSet.{u} := + cons (e 0) (cons (e 1) (cons (e 2) (cons ZFSet.omega + (fun _ => ZFSet.prod ZFSet.omega ZFSet.omega)))) + +theorem stageSlots_comp (B : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + cons (natSet 0) (cons B (cons (ZFSet.prod ZFSet.omega ZFSet.omega) + (cons ZFSet.omega e))) ∘ stageSlots = mix (stageInputs e) (params B) := by + apply parity_ext + · intro n + rcases n with _|_|_|_|n <;> simp [stageSlots,stageInputs,mix] + · intro n + rcases n with _|_|n <;> simp [stageSlots,params,Nat.add_div,mix] + +theorem stage_formula : + ∃ p : SentenceForm, ∀ N : ZFSet.{u}, Transitive N → + ZFSet.omega ∈ N → ZFSet.prod ZFSet.omega ZFSet.omega ∈ N → + (∀ f k, finiteNaturalGraph f k ∈ N) → + (∃ B ∈ N, PowerBound N (ZFSet.prod ZFSet.omega ZFSet.omega) B) → + ∀ e, (∀ i, e i ∈ N) → + (p.Sat (N : Set ZFSet) e ↔ + SeedBoundStage N ZFSet.omega (ZFSet.prod ZFSet.omega ZFSet.omega) (e 2) (e 1) (e 0)) := by + obtain ⟨p,hp⟩ := seedBoundStage_domainDefinable.{u} + refine ⟨bindNumbers (p.rename stageSlots),?_⟩ + intro N hN hw hs hfin hex e he + rw [bindNumbers_spec N hN hw hs _ e he] + have hbody (B : ZFSet.{u}) (hBN : B ∈ N) + (hB : PowerBound N (ZFSet.prod ZFSet.omega ZFSet.omega) B) : + (p.rename stageSlots).Sat (N : Set ZFSet) + (cons (natSet 0) (cons B (cons (ZFSet.prod ZFSet.omega ZFSet.omega) (cons ZFSet.omega e)))) ↔ + SeedBoundStage N ZFSet.omega (ZFSet.prod ZFSet.omega ZFSet.omega) (e 2) (e 1) (e 0) := by + rw [SentenceForm.sat_rename] + change p.Sat (N : Set ZFSet) + (cons (natSet 0) (cons B (cons (ZFSet.prod ZFSet.omega ZFSet.omega) (cons ZFSet.omega e))) ∘ stageSlots) ↔ _ + rw [stageSlots_comp] + apply hp B (covers_of_power hfin hB) N hN + · intro i + rcases i with _|_|i + · exact hw + · exact hBN + · exact hN _ hw _ ((mem_omega _).mpr ⟨0,rfl⟩) + · intro i + rcases i with _|_|_|_|i + · exact he 0 + · exact he 1 + · exact he 2 + · exact hw + · exact hs + constructor + · rintro ⟨B,hBN,hB,h⟩ + exact (hbody B hBN hB).mp h + · intro h + obtain ⟨B,hBN,hB⟩ := hex + exact ⟨B,hBN,hB,(hbody B hBN hB).mpr h⟩ + +end TuringRigidity.NumericSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericTruth.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericTruth.lean new file mode 100644 index 0000000000000000000000000000000000000000..6079df3f8d283a6060b9a2fcfbcc5ec147738b81 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericTruth.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericFamilySupport +import OAI.Computability.DegreeRigidity.Effective.TupleSystemCertificate + +namespace OAI + +namespace TuringRigidity.NumericSyntax +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding RelativeConstructible +open BoundedDefinability SetModelFunctions SetModelReals +universe u +theorem tupleLookup_variable (G t i x : ℕ) : + Numeric.{u} (fun e => TupleLookup (e G) (e t) (e i) (e x)) := + (((defOrderedPair (t+2) 1 0).and (defPairMem (i+2) (x+2) 0)).existsMem (G+1)).existsNat + +theorem tuplePrefix_variable (a G t x s : ℕ) : + Numeric.{u} (fun e => TuplePrefix (e a) (e G) (e t) (e x) (e s)) := by + let r : ℕ → ℕ := fun i => match i with + | 0 => 2*a | 1 => 1 | 2 => 2*G | 3 => 2*t | 4 => 2*x | 5 => 2*s | _ => 5 + refine ⟨(tuplePrefixFormula 0 1 2 3 4 5 6).rename r,?_⟩ + intro B _ e + rw [Formula.eval_rename_comp] + have he : mix e (params B) ∘ r = cons (e a) (cons ZFSet.omega (cons (e G) + (cons (e t) (cons (e x) (cons (e s) (fun _ => natSet 0)))))) := by + funext i + rcases i with _|_|_|_|_|_|i <;> simp only [r,params,Function.comp_apply,mix_even,cons_zero,cons_succ] <;> rfl + rw [he] + rfl + +theorem setTruthStep_variable (a G T S c t : ℕ) : + Numeric.{u} (fun e => SetTruthStep (e a) (e G) (e T) (e S) (e c) (e t)) := by + have ha (tag : ℕ) (hr : Numeric.{u} (fun e => e 1 = e 0)) := + (((((binaryGraph_definable _ (atomic_primrec tag) 3 2 (c+4)).and + ((tupleLookup_variable (G+4) (t+4) 3 1).and + ((tupleLookup_variable (G+4) (t+4) 2 0).and hr))).existsMem (a+3)).existsMem (a+2)).existsNat).existsNat + have he := ha 0 (equal_definable 1 0) + have hm := (((((binaryGraph_definable _ (atomic_primrec 1) 3 2 (c+4)).and + ((tupleLookup_variable (G+4) (t+4) 3 1).and + ((tupleLookup_variable (G+4) (t+4) 2 0).and (member_definable 1 0)))).existsMem (a+3)).existsMem + (a+2)).existsNat).existsNat + have hc := (((binaryGraph_definable _ (binary_primrec 2) 1 0 (c+2)).and + ((defPairMem 1 (t+2) (S+2)).and (defPairMem 0 (t+2) (S+2)))).existsNat).existsNat + have hn := ((unaryGraph_definable _ (unary_primrec 3) 0 (c+1)).and + (defPairMem 0 (t+1) (S+1)).neg).existsNat + have hbody := (((tuplePrefix_variable (a+3) (G+3) (t+3) 1 0).and + (defPairMem 2 0 (S+3))).existsMem (T+2)).existsMem (a+1) + have hx := ((unaryGraph_definable _ (unary_primrec 4) 0 (c+1)).and hbody).existsNat + exact defOr he (defOr hm (defOr hc (defOr hn hx))) + +theorem definesSubset_variable (a G T Z c t S : ℕ) : + Numeric.{u} (fun e => DefinesSubset (e a) (e G) (e T) (e Z) (e c) (e t) (e S)) := + (defSubset S a).and (defAllMem (defIff (member_definable 0 (S+1)) + (((tuplePrefix_variable (a+2) (G+2) (t+2) 1 0).and + (defPairMem (c+2) 0 (Z+2))).existsMem (T+1))) a) + +theorem tupleSystem_definable (a G T : ℕ) : + Numeric.{u} (fun e => TupleSystem (e a) (e G) (e T)) := by + have hfg (f n a : ℕ) : Numeric.{u} (fun e => FunctionGraph (e n) (e a) (e f)) := by + refine ⟨.functionGraph (2*f) (2*n) (2*a),?_⟩ + intro B hB e + simp only [Formula.eval_functionGraph,mix_even,FunctionGraph] + have hn := defAllMem ((((defOrderedPair 2 1 0).and + (hfg 0 1 (a+3))).existsMem (G+2)).existsNat) T + have hz : Numeric.{u} (fun e => ZFSet.pair (natSet 0) (natSet 0) ∈ e T) := (((equalZero 0).and + (defPairMem 0 0 (T+1))).existsNat).congr (fun e => by simp [show natSet.{u} 0 ∈ ZFSet.omega from (mem_omega _).mpr ⟨0,rfl⟩]) + have hc := defAllMem (defAllMem + ((tuplePrefix_variable (a+3) (G+3) 2 1 0).existsMem (T+2)) (a+1)) T + exact hn.and (hz.and hc) + +end TuringRigidity.NumericSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalAutomorphism.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalAutomorphism.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f8e32868e766f13e0b13c4a1e92c84ded148673 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalAutomorphism.lean @@ -0,0 +1,84 @@ +import OAI.Computability.DegreeRigidity.Constructibility.PersistentExtension + +namespace OAI + +namespace TuringRigidity.NumericalAutomorphism +open EncodedForcing PersistentRestrictions PersistentPresentation +noncomputable section + +structure Action (H : Oracle) (P : ℕ → Prop) : Prop where + total : ∀ n, ∃ m, P (Nat.pair n m) + onto : ∀ m, ∃ n, P (Nat.pair n m) + order : ∀ n m n' m', P (Nat.pair n m) → P (Nat.pair n' m') → + (degree (columns H n) ≤ degree (columns H n') ↔ + degree (columns H m) ≤ degree (columns H m')) + saturated : ∀ n m m', P (Nat.pair n m) → + degree (columns H m) = degree (columns H m') → P (Nat.pair n m') + +theorem action_of_automorphism {I : CountableIdeal} {H : Oracle} + (hpres : Presented I H) (ρ : I ≃o I) : Action H (Graph ρ hpres) := by + constructor + · intro n + obtain ⟨m,hm⟩ := (hpres (ρ (entry hpres n)).val).mp (ρ (entry hpres n)).property + exact ⟨m,by simpa only [PersistentPresentation.Graph,Nat.unpair_pair] using hm.symm⟩ + · intro m + obtain ⟨n,hn⟩ := (hpres (ρ.symm (entry hpres m)).val).mp (ρ.symm (entry hpres m)).property + have he : entry hpres n = ρ.symm (entry hpres m) := Subtype.ext hn + refine ⟨n,?_⟩ + simp only [PersistentPresentation.Graph,Nat.unpair_pair] + rw [he,ρ.apply_symm_apply] + rfl + · intro n m n' m' hp hq + simp only [PersistentPresentation.Graph,Nat.unpair_pair] at hp hq + rw [← hp,← hq] + change entry hpres n ≤ entry hpres n' ↔ ρ (entry hpres n) ≤ ρ (entry hpres n') + exact ρ.le_iff_le.symm + · intro n m m' hp he + simpa only [PersistentPresentation.Graph,Nat.unpair_pair,← he] using hp + +theorem reconstruct {I : CountableIdeal} {H : Oracle} (hpres : Presented I H) + {P : ℕ → Prop} (ha : Action H P) : + ∃ ρ : I ≃o I, ∀ v, P v ↔ Graph ρ hpres v := by + classical + let idx (x : I) : ℕ := Classical.choose ((hpres x.val).mp x.property) + have hidx (x : I) : degree (columns H (idx x)) = x.val := + Classical.choose_spec ((hpres x.val).mp x.property) + let out (n : ℕ) : ℕ := Classical.choose (ha.total n) + have hout (n : ℕ) : P (Nat.pair n (out n)) := Classical.choose_spec (ha.total n) + let f (x : I) : I := entry hpres (out (idx x)) + have hf (x : I) (n m : ℕ) (hn : degree (columns H n) = x.val) + (hp : P (Nat.pair n m)) : (f x).val = degree (columns H m) := by + apply le_antisymm + · exact (ha.order _ _ _ _ (hout (idx x)) hp).mp (by rw [hidx,hn]) + · exact (ha.order _ _ _ _ hp (hout (idx x))).mp (by rw [hidx,hn]) + have hle (x y : I) : f x ≤ f y ↔ x ≤ y := by + have hh := (ha.order _ _ _ _ (hout (idx x)) (hout (idx y))).symm + change degree (columns H (out (idx x))) ≤ degree (columns H (out (idx y))) ↔ x.val ≤ y.val + simpa only [hidx] using hh + have hinj : Function.Injective f := by + intro x y he + exact le_antisymm ((hle x y).mp (le_of_eq he)) ((hle y x).mp (le_of_eq he.symm)) + have hsurj : Function.Surjective f := by + intro y + obtain ⟨n,hn⟩ := ha.onto (idx y) + refine ⟨entry hpres n,Subtype.ext ?_⟩ + exact (hf (entry hpres n) n (idx y) rfl hn).trans (hidx y) + let ρ : I ≃o I := + { toEquiv := Equiv.ofBijective f ⟨hinj,hsurj⟩ + map_rel_iff' := by intro x y; exact hle x y } + refine ⟨ρ,fun v => ?_⟩ + obtain ⟨⟨n,m⟩,rfl⟩ := Nat.pairEquiv.surjective v + change P (Nat.pair n m) ↔ Graph ρ hpres (Nat.pair n m) + simp only [PersistentPresentation.Graph,Nat.unpair_pair] + constructor + · intro hp + exact hf (entry hpres n) n m rfl hp + · intro hg + change (f (entry hpres n)).val = degree (columns H m) at hg + have hnm := hf (entry hpres n) n (out n) rfl (hout n) + exact ha.saturated n (out n) m (hout n) (hnm.symm.trans hg) + +end +end TuringRigidity.NumericalAutomorphism + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalCohenProductSets.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalCohenProductSets.lean new file mode 100644 index 0000000000000000000000000000000000000000..25fd49013af1ed4390e28135c1de3e16ea32fd9b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalCohenProductSets.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericalCohenSets +import OAI.Computability.DegreeRigidity.CohenForcing.TaggedProductConditions + +namespace OAI + + +namespace TuringRigidity.NumericalCohenProductSets +open TransitiveNameModel BoundedSetTheory SetModelFunctions SetModelArithmetic +open InternalCohen Encodable UniformArithmetic +open EncodedForcing (word) +open TaggedProductConditions (code) + +noncomputable def image (c : ZFSet.{0}) (B : Oracle) : ZFSet.{0} := + c.sep (fun z => ∃ n : ℕ, B n = true ∧ + z = code (wordCode (word (left n))) (wordCode (word (right n)))) + +theorem image_mem (M c : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (B : Oracle) (hB : realCode B ∈ M) : image c B ∈ M := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet, + hT.separation.finitePrefix.bounded,hT.infinity⟩ + obtain ⟨gl,hgl,hl⟩ := primrec_graph C left_primrec + obtain ⟨gr,hgr,hr⟩ := primrec_graph C right_primrec + let e := cons (realCode B) (cons ZFSet.omega (cons conditions + (cons gl (cons gr (cons wordCodeGraph (cons (natSet 0) (fun _ => natSet 1))))))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|_|_|_|i + · exact hB + · exact C.omega_mem + · exact conditions_mem M hM hT + · exact hgl + · exact hgr + · exact wordCodeGraph_mem M hM hT + all_goals exact hM _ C.omega_mem _ ((mem_omega _).mpr ⟨_,rfl⟩) + let φ : Formula := .existsMem 1 (.existsMem 3 (.existsMem 4 + (.existsMem 6 (.existsMem 7 + (.conj (.pairMem 4 3 9) (.conj (.pairMem 4 2 10) + (.conj (.pairMem 3 1 11) (.conj (.pairMem 2 0 11) + (TaggedProductConditions.codeFormula 1 0 5 12 13))))))))) + have hspec (z : ZFSet.{0}) : φ.Eval (cons z e) ↔ + ∃ n : ℕ, B n = true ∧ + z = code (wordCode (word (left n))) (wordCode (word (right n))) := by + have hcode (leftCondition rightCondition leftIndex rightIndex index : ZFSet.{0}) : + (TaggedProductConditions.codeFormula 1 0 5 12 13).Eval + (cons rightCondition (cons leftCondition (cons rightIndex + (cons leftIndex (cons index (cons z e)))))) ↔ + z = code leftCondition rightCondition := + TaggedProductConditions.codeFormula_spec 1 0 5 12 13 _ rfl rfl + simp only [φ,Formula.Eval,Formula.eval_pairMem,hcode, + cons_zero,cons_succ,e] + constructor + · rintro ⟨k,hk,i,hi,j,hj,u,_,v,_,hli,hrj,hu,hv,hz⟩ + obtain ⟨n,rfl⟩ := (mem_omega k).mp (realCode_subset B hk) + obtain ⟨a,rfl⟩ := (mem_omega i).mp hi + obtain ⟨b,rfl⟩ := (mem_omega j).mp hj + have ha := (hl n a).mp hli + have hb := (hr n b).mp hrj + subst a + subst b + rw [(pair_mem_wordCodeGraph _ _).mp hu,(pair_mem_wordCodeGraph _ _).mp hv] at hz + exact ⟨n,(natSet_mem_realCode B n).mp hk,hz⟩ + · rintro ⟨n,hn,hz⟩ + exact ⟨natSet n,(natSet_mem_realCode B n).mpr hn, + natSet (left n),(mem_omega _).mpr ⟨_,rfl⟩, + natSet (right n),(mem_omega _).mpr ⟨_,rfl⟩, + wordCode (word (left n)),(mem_conditions _).mpr ⟨_,wordCode_function _⟩, + wordCode (word (right n)),(mem_conditions _).mpr ⟨_,wordCode_function _⟩, + (hl _ _).mpr rfl,(hr _ _).mpr rfl, + (pair_mem_wordCodeGraph _ _).mpr rfl,(pair_mem_wordCodeGraph _ _).mpr rfl,hz⟩ + have hs := sep_mem M hM C.separation φ e he hc + have heq : c.sep (fun z => φ.Eval (cons z e)) = image c B := by + apply ZFSet.ext + intro z + simp only [image,ZFSet.mem_sep,hspec] + exact heq ▸ hs + +theorem image_spec (c : ZFSet.{0}) + (hcs : ∀ z, z ∈ c ↔ ∃ p ∈ conditions, ∃ s ∈ conditions, z = code p s) + (P : List Bool → List Bool → Prop) (B : Oracle) + (hB : ∀ n, B n = true ↔ P (word (left n)) (word (right n))) + (s t : List Bool) : code (wordCode s) (wordCode t) ∈ image c B ↔ P s t := by + rw [image,ZFSet.mem_sep] + constructor + · rintro ⟨_,n,hn,he⟩ + obtain ⟨hs,ht⟩ := (TaggedProductConditions.code_injective _ _ _ _).mp he + rw [wordCode_injective hs,wordCode_injective ht] + exact (hB n).mp hn + · intro h + refine ⟨(hcs _).mpr ⟨_,(mem_conditions _).mpr ⟨_,wordCode_function _⟩, + _,(mem_conditions _).mpr ⟨_,wordCode_function _⟩,rfl⟩, + Nat.pair (encode s) (encode t),?_,?_⟩ + · apply (hB _).mpr + simpa [left,right,word] using h + · simp [left,right,word] + +end TuringRigidity.NumericalCohenProductSets + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalCohenSets.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalCohenSets.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7fd5919cfc4464df948ac00254b31d78e221521 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalCohenSets.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.CohenWordCodeGraph +import OAI.Computability.DegreeRigidity.SetModels.ModelArithmeticComprehension + +namespace OAI + + +namespace TuringRigidity.InternalCohen +open TransitiveNameModel BoundedSetTheory Encodable + +noncomputable def wordPullback (D : ZFSet.{0}) : Oracle := fun n => by + classical + exact decide (wordCode (EncodedForcing.word n) ∈ D) + +theorem wordPullback_true (D : ZFSet.{0}) (n : ℕ) : + wordPullback D n = true ↔ wordCode (EncodedForcing.word n) ∈ D := by + classical + simp [wordPullback] + +theorem wordPullback_mem (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (D : ZFSet.{0}) (hD : D ∈ M) : realCode (wordPullback D) ∈ M := by + let e := cons D (fun _ => wordCodeGraph) + have he : ∀ i, e i ∈ M := by + intro i + cases i with + | zero => exact hD + | succ i => exact wordCodeGraph_mem M hM hT + have hh := sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.pairMem 1 0 3)) e he (sourceT_omega_mem M hM hT) + have heq : ZFSet.sep (fun n => + (Formula.existsMem 1 (.pairMem 1 0 3)).Eval (cons n e)) ZFSet.omega = + realCode (wordPullback D) := by + apply ZFSet.ext + intro x + simp only [ZFSet.mem_sep,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] + constructor + · rintro ⟨hx,q,hq,hxq⟩ + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + rw [(pair_mem_wordCodeGraph n q).mp hxq] at hq + exact (natSet_mem_realCode _ _).mpr ((wordPullback_true D n).mpr hq) + · intro hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp (realCode_subset _ hx) + exact ⟨(mem_omega _).mpr ⟨n,rfl⟩,wordCode (EncodedForcing.word n), + (wordPullback_true D n).mp ((natSet_mem_realCode _ _).mp hx), + (pair_mem_wordCodeGraph _ _).mpr rfl⟩ + exact heq ▸ hh + +noncomputable def wordImage (A : Oracle) : ZFSet.{0} := + ZFSet.sep (fun q => ∃ n ∈ realCode A, ZFSet.pair n q ∈ wordCodeGraph) conditions + +theorem wordImage_mem (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (A : Oracle) (hA : realCode A ∈ M) : wordImage A ∈ M := by + let e := cons (realCode A) (fun _ => wordCodeGraph) + have he : ∀ i, e i ∈ M := by + intro i + cases i with + | zero => exact hA + | succ i => exact wordCodeGraph_mem M hM hT + have hh := sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.pairMem 0 1 3)) e he (conditions_mem M hM hT) + simpa only [wordImage,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] using hh + +theorem wordImage_spec (P : List Bool → Prop) (A : Oracle) + (hA : ∀ n, A n = true ↔ P (EncodedForcing.word n)) (p : List Bool) : + wordCode p ∈ wordImage A ↔ P p := by + rw [wordImage,ZFSet.mem_sep] + constructor + · rintro ⟨_,x,hx,hq⟩ + obtain ⟨n,rfl⟩ := (mem_omega x).mp (realCode_subset _ hx) + have hp := wordCode_injective ((pair_mem_wordCodeGraph _ _).mp hq) + rw [hp] + exact (hA n).mp ((natSet_mem_realCode _ _).mp hx) + · intro hp + exact ⟨(mem_conditions _).mpr ⟨_,wordCode_function _⟩,natSet (encode p), + (natSet_mem_realCode _ _).mpr ((hA _).mpr (by simpa [EncodedForcing.word] using hp)), + (canonical_wordCodeGraph p _).mpr rfl⟩ + +end TuringRigidity.InternalCohen + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalExtension.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..33694012fd4260e25a5a2cad88bd7a0e907ded55 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalExtension.lean @@ -0,0 +1,51 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericalIdeal + +namespace OAI + +namespace TuringRigidity.NumericalExtension +open EncodedForcing PersistentRestrictions PersistentPresentation NumericalAutomorphism +noncomputable section + +def Compatible (A H : Oracle) (R P : ℕ → Prop) : Prop := + ∀ i j n m, R (Nat.pair i j) → P (Nat.pair n m) → + degree (columns A i) = degree (columns H n) → + degree (columns A j) = degree (columns H m) + +theorem compatible_iff {I J : CountableIdeal} {A H : Oracle} + (hA : Presented I A) (hH : Presented J H) (hIJ : I.carrier ⊆ J.carrier) + (ρ : I ≃o I) (σ : J ≃o J) : + Compatible A H (Graph ρ hA) (Graph σ hH) ↔ Extends hIJ ρ σ := by + constructor + · intro hc x + obtain ⟨i,hi⟩ := (hA x.val).mp x.property + obtain ⟨j,hj⟩ := (hA (ρ x).val).mp (ρ x).property + obtain ⟨n,hn⟩ := (hH x.val).mp (hIJ x.property) + obtain ⟨m,hm⟩ := (hH (σ ⟨x.val,hIJ x.property⟩).val).mp (σ ⟨x.val,hIJ x.property⟩).property + have heI : entry hA i = x := Subtype.ext hi + have heJ : entry hH n = ⟨x.val,hIJ x.property⟩ := Subtype.ext hn + have hR : Graph ρ hA (Nat.pair i j) := by + simp only [PersistentPresentation.Graph,Nat.unpair_pair] + rw [heI,hj] + have hP : Graph σ hH (Nat.pair n m) := by + simp only [PersistentPresentation.Graph,Nat.unpair_pair] + rw [heJ,hm] + exact hm.symm.trans ((hc i j n m hR hP (hi.trans hn.symm)).symm.trans hj) + · intro he i j n m hR hP hin + have hi : (⟨(entry hA i).val,hIJ (entry hA i).property⟩ : J) = entry hH n := Subtype.ext hin + have hh := he (entry hA i) + rw [hi] at hh + simp only [PersistentPresentation.Graph,Nat.unpair_pair] at hR hP + exact hR.symm.trans (hh.symm.trans hP) + +theorem compatible_congr {A H : Oracle} {R P Q : ℕ → Prop} + (h : ∀ v, P v ↔ Q v) : Compatible A H R P ↔ Compatible A H R Q := by + constructor + · intro hc i j n m hR hQ + exact hc i j n m hR ((h _).mpr hQ) + · intro hc i j n m hR hP + exact hc i j n m hR ((h _).mp hP) + +end +end TuringRigidity.NumericalExtension + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalIdeal.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalIdeal.lean new file mode 100644 index 0000000000000000000000000000000000000000..d05ad366a0f360caa769667112e16257c3525738 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/NumericalIdeal.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericalAutomorphism + +namespace OAI + +namespace TuringRigidity.NumericalIdeal +open EncodedForcing OracleJump IndexPresentation IdealInterpretation IdealLocality +open PersistentRestrictions PersistentLocality PersistentPresentation +noncomputable section + +structure JumpCode (H : Oracle) : Prop where + lower : ∀ n e, Dom (columns H n) e → + ∃ m, value (columns H n) e = degree (columns H m) + join : ∀ n m, ∃ k, degree (columns H n) ⊔ degree (columns H m) = degree (columns H k) + jump : ∀ n, ∃ m, degreeJump (degree (columns H n)) = degree (columns H m) + +def decode (H : Oracle) (hc : JumpCode H) : CountableIdeal where + carrier := Set.range (fun n => degree (columns H n)) + nonempty := ⟨degree (columns H 0),0,rfl⟩ + countable := Set.countable_range _ + lower := by + intro a b hab hb + obtain ⟨n,rfl⟩ := hb + obtain ⟨e,he,hv⟩ := value_surjective (columns H n) a hab + obtain ⟨m,hm⟩ := hc.lower n e he + exact ⟨m,hm.symm.trans hv⟩ + join_mem := by + intro a b ha hb + obtain ⟨n,rfl⟩ := ha + obtain ⟨m,rfl⟩ := hb + obtain ⟨k,hk⟩ := hc.join n m + exact ⟨k,hk.symm⟩ + +theorem decoded_presentation (H : Oracle) (hc : JumpCode H) : Presented (decode H hc) H := + fun _ => Iff.rfl + +theorem decoded_closed (H : Oracle) (hc : JumpCode H) : JumpClosed (ideal (decode H hc)) := by + intro x hx + obtain ⟨n,rfl⟩ := hx + obtain ⟨m,hm⟩ := hc.jump n + exact ⟨m,hm.symm⟩ + +theorem code_of_ideal {J : CountableIdeal} {H : Oracle} (hp : Presented J H) + (hj : JumpClosed (ideal J)) : JumpCode H := by + constructor + · intro n e _ + obtain ⟨m,hm⟩ := (hp _).mp (J.lower (value_below (columns H n) e) (entry hp n).property) + exact ⟨m,hm.symm⟩ + · intro n m + obtain ⟨k,hk⟩ := (hp _).mp (J.join_mem (entry hp n).property (entry hp m).property) + exact ⟨k,hk.symm⟩ + · intro n + obtain ⟨m,hm⟩ := (hp _).mp (hj _ (entry hp n).property) + exact ⟨m,hm.symm⟩ + +def Includes (A H : Oracle) : Prop := ∀ n, ∃ m, degree (columns A n) = degree (columns H m) + +theorem includes_iff {I J : CountableIdeal} {A H : Oracle} + (hA : Presented I A) (hH : Presented J H) : Includes A H ↔ I.carrier ⊆ J.carrier := by + constructor + · intro h x hx + obtain ⟨n,rfl⟩ := (hA x).mp hx + obtain ⟨m,hm⟩ := h n + exact (hH _).mpr ⟨m,hm.symm⟩ + · intro h n + obtain ⟨m,hm⟩ := (hH _).mp (h (entry hA n).property) + exact ⟨m,hm.symm⟩ + +end +end TuringRigidity.NumericalIdeal + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaCertificateCollection.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaCertificateCollection.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b35401e63d2c38adb405e092aa2bf3847e3301d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaCertificateCollection.lean @@ -0,0 +1,55 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeOmegaLevels + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open BoundedDefinability SetModelFunctions SentenceCoding +universe u + +theorem omega_bundle_sigma (M : ZFSet.{u}) (C : Context M) + (hRep : SigmaReplacement M) (hColl : SigmaCollection M) : + ∃ p : SigmaFormula, ∃ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ M) ∧ + ∀ x ∈ M, ∀ B ∈ M, p.Realize M (cons B (cons x e)) ↔ + ∃ f ∈ M, ∃ r ∈ M, f ∈ B ∧ r ∈ B ∧ OmegaGraph M x r f := by + have hm := ((member_definable C 1 2).and (member_definable C 0 2)).toSigma C.transitive + have hg := omegaGraph_sigmaDefinable_schemas M C hRep hColl 3 0 1 + have h := (hm.and hg).existsSet.existsSet + apply sigma_binary_relation _ (h.congr ?_) + intro e _ + simp only [cons_zero,cons_succ] + apply exists_congr; intro f + apply and_congr_right; intro _ + apply exists_congr; intro r + apply and_congr_right; intro _ + exact and_assoc + +theorem omega_graph_collection (M : ZFSet.{u}) (C : Context M) + (hRep : SigmaReplacement M) (hColl : SigmaCollection M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) : + ∃ U ∈ M, ∀ c ≤ a, ∃ f ∈ U, ∃ r ∈ U, OmegaGraph M c.toZFSet r f := by + obtain ⟨p,e,he,hp⟩ := omega_bundle_sigma M C hRep hColl + have hs : (a+1).toZFSet ∈ M := by + rw [Ordinal.toZFSet_add_one] + exact insert_self_mem M C.transitive C.pairing C.union ha + obtain ⟨W,hW,hcover⟩ := hColl p e he (a+1).toZFSet hs (by + intro x hx + have hxM := C.transitive _ hs _ hx + obtain ⟨f,hf,hg⟩ := internal_omegaGraph_below_schemas M C hRep hColl x hxM + ((ZFSet.isOrdinal_toZFSet (a+1)).mem hx) + have hr := iterUnion_mem M C.transitive C.union hf 2 + have hB := pair_mem M C.transitive C.pairing hf hr + refine ⟨{f,iterUnion 2 f},hB,(hp x hxM _ hB).mpr ?_⟩ + exact ⟨f,hf,_,hr,ZFSet.mem_pair.mpr (Or.inl rfl),ZFSet.mem_pair.mpr (Or.inr rfl),hg⟩) + refine ⟨ZFSet.sUnion W,union_mem M C.transitive C.union hW,?_⟩ + intro c hc + have hcs : c.toZFSet ∈ (a+1).toZFSet := + Ordinal.toZFSet_mem_toZFSet_iff.mpr (hc.trans_lt (lt_add_one a)) + obtain ⟨B,hB,h⟩ := hcover c.toZFSet hcs + obtain ⟨f,_,r,_,hf,hr,hg⟩ := (hp c.toZFSet (C.transitive _ hs _ hcs) + B (C.transitive _ hW _ hB)).mp h + exact ⟨f,ZFSet.mem_sUnion.mpr ⟨B,hB,hf⟩,r,ZFSet.mem_sUnion.mpr ⟨B,hB,hr⟩,hg⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaGraphRestriction.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaGraphRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c42bc103ea3e50f1f0f30fad64c1e14e347c889 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaGraphRestriction.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaPowerDefinability + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +theorem omegaStageStep_domain (M x r f : ZFSet.{u}) (hg : OmegaGraph M x r f) : + StageStep (1 : Ordinal.{u}).toZFSet f r x (Ordinal.omega0 ^ x.rank).toZFSet := by + refine ⟨?_,?_,?_⟩ + · intro z hz; exact (omegaPower_members x.rank z).mpr (Or.inl hz) + · intro z hz + rcases (omegaPower_members x.rank z).mp hz with hz|⟨t,ht,hz⟩ + · exact Or.inl hz + · rw [hg.1.toZFSet_rank_eq] at ht + obtain ⟨v,hv,hfv,_⟩ := hg.2.1.2 t ht + rw [← hg.correct t ht v hv hfv] at hz + exact Or.inr ⟨t,ht,v,hv,hfv,hz⟩ + · intro t ht v hv hfv z hz + rw [hg.correct t ht v hv hfv] at hz + exact (omegaPower_members x.rank z).mpr + (Or.inr ⟨t,hg.1.toZFSet_rank_eq.symm ▸ ht,hz⟩) + +theorem omegaStageStep_domain_exact {M x r f A : ZFSet.{u}} (hg : OmegaGraph M x r f) + (hs : StageStep (1 : Ordinal.{u}).toZFSet f r x A) : + A = (Ordinal.omega0 ^ x.rank).toZFSet := by + have ht := omegaStageStep_domain M x r f hg + apply ZFSet.ext; intro z + constructor + · intro hz + rcases hs.2.1 z hz with hz|⟨t,ht',v,hv,hfv,hz⟩ + · exact ht.1 hz + · exact ht.2.2 t ht' v hv hfv hz + · intro hz + rcases ht.2.1 z hz with hz|⟨t,ht',v,hv,hfv,hz⟩ + · exact hs.1 hz + · exact hs.2.2 t ht' v hv hfv hz + +theorem internal_omegaGraph_below (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (x : ZFSet.{u}) (hx : x ∈ M) (ho : x.IsOrdinal) : + ∃ f ∈ M, OmegaGraph M x (iterUnion 2 f) f := by + obtain ⟨f,hf,hg⟩ := internal_omegaGraph M hM hT x hx ho + let p : Formula := .existsMem 1 (.existsMem 3 (.orderedPair 2 1 0)) + let e : ℕ → ZFSet.{u} := cons x (fun _ => iterUnion 2 f) + let g := ZFSet.sep (fun z => p.Eval (cons z e)) f + have hgM : g ∈ M := sep_mem M hM hT.separation.finitePrefix.bounded p e + (by intro i; cases i; exact hx; exact iterUnion_mem M hM hT.union hf 2) hf + have hm (z : ZFSet.{u}) : z ∈ g ↔ ∃ t ∈ x, z = ZFSet.pair t (omegaNext t) := by + change z ∈ ZFSet.sep _ f ↔ _ + simp only [ZFSet.mem_sep,p,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ] + change (z ∈ f ∧ ∃ t ∈ x, ∃ v ∈ iterUnion 2 f, z = ZFSet.pair t v) ↔ _ + constructor + · rintro ⟨hz,t,ht,v,hv,rfl⟩ + exact ⟨t,ht,by rw [hg.correct t (ZFSet.mem_insert_of_mem x ht) v hv hz]⟩ + · rintro ⟨t,ht,rfl⟩ + have hp := (hg.mem_iff _).mpr ⟨t,ZFSet.mem_insert_of_mem x ht,rfl⟩ + exact ⟨hp,t,ht,_,second_mem_doubleUnion hp,rfl⟩ + exact ⟨g,hgM,omegaGraph_of_mem_iff M x g hM hT hx hgM ho hm⟩ + +theorem OmegaGraph.value_subset_power {M r f : ZFSet.{u}} {a : Ordinal.{u}} + (hg : OmegaGraph M a.toZFSet r f) (t v : ZFSet.{u}) + (ht : t ∈ a.toZFSet) (hv : v ∈ r) (hfv : ZFSet.pair t v ∈ f) : + v ⊆ (Ordinal.omega0 ^ a).toZFSet := by + rw [hg.correct t ht v hv hfv,omegaNext] + obtain ⟨b,hb,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ht + rw [Ordinal.rank_toZFSet] + exact Ordinal.toZFSet_monotone + (Ordinal.opow_le_opow_right Ordinal.omega0_pos (Order.succ_le_of_lt hb)) + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaGraphSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaGraphSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..a950c871cff9254daaa87e0229fee480de81884d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaGraphSyntax.lean @@ -0,0 +1,88 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaStageSyntax + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +noncomputable def omegaGraphSentence (s w d r f : ℕ) : SentenceForm := + .conj (fromBounded (ordinalFormula d)) + (.conj (fromBounded (.functionGraph f d r)) + (ordinalAllMem d (ordinalAllMem (r+1) + (.imp (fromBounded (.pairMem 1 0 (f+2))) + (.ex (.conj (fromBounded (omegaStageMatrix (s+3) (f+3) (r+3) 2 0)) + (.conj (fromBounded (ordinalFormula 0)) (ordinalProductAt 1 0 (w+3))))))))) + +theorem omegaGraphSentence_semantics (M : ZFSet.{u}) (hM : Transitive M) + (s w d r f : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (omegaGraphSentence s w d r f).Sat (M : Set ZFSet) e ↔ + (e d).IsOrdinal ∧ FunctionGraph (e d) (e r) (e f) ∧ + ∀ x ∈ e d, ∀ v ∈ e r, ZFSet.pair x v ∈ e f → + ∃ A ∈ M, StageStep (e s) (e f) (e r) x A ∧ A.IsOrdinal ∧ + (ordinalProductAt 1 0 (w+3)).Sat (M : Set ZFSet) (cons A (cons v (cons x e))) := by + have hb (p : Formula) : (fromBounded p).Sat (M : Set ZFSet) e ↔ p.Eval e := by + rw [bounded_sat,Formula.absolute _ M hM e he] + change ((fromBounded _).Sat _ e ∧ (fromBounded _).Sat _ e ∧ + (ordinalAllMem d _).Sat _ e) ↔ _ + rw [hb,hb,eval_ordinalFormula,Formula.eval_functionGraph, + ordinalAllMem_sat M hM d _ e (he d)] + apply and_congr_right; intro _ + apply and_congr_right; intro _ + apply forall_congr'; intro x + apply forall_congr'; intro hx + have hxM := hM _ (he d) x hx + rw [ordinalAllMem_sat M hM (r+1) _ (cons x e) (he r)] + apply forall_congr'; intro v + apply forall_congr'; intro hv + have hvM := hM _ (he r) v hv + rw [SentenceForm.sat_imp,bounded_sat,Formula.absolute _ M hM _ (by + intro i; rcases i with _|_|i; exact hvM; exact hxM; exact he i),Formula.eval_pairMem] + apply forall_congr'; intro _ + change (∃ A ∈ M, (fromBounded _).Sat _ _ ∧ (fromBounded _).Sat _ _ ∧ _) ↔ _ + apply exists_congr; intro A + apply and_congr_right; intro hA + have heA : ∀ i, cons A (cons v (cons x e)) i ∈ M := by + intro i; rcases i with _|_|_|i; exact hA; exact hvM; exact hxM; exact he i + rw [bounded_sat,Formula.absolute _ M hM _ heA,omegaStageMatrix_eval, + bounded_sat,Formula.absolute _ M hM _ heA,eval_ordinalFormula] + rfl + +theorem omegaGraphSentence_sound (M : ZFSet.{u}) (hM : Transitive M) + (s w d r f : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hs : e s = (1 : Ordinal.{u}).toZFSet) (hw : e w = ZFSet.omega) : + (omegaGraphSentence s w d r f).Sat (M : Set ZFSet) e → + OmegaGraph M (e d) (e r) (e f) := by + rw [omegaGraphSentence_semantics M hM s w d r f e he] + rintro ⟨hd,hf,hstep⟩ + refine ⟨hd,hf,?_⟩ + intro x hx v hv hfv + obtain ⟨A,hA,hst,ho,hp⟩ := hstep x hx v hv hfv + have hwOrd : ZFSet.omega.{u}.IsOrdinal := toZFSet_omega ▸ ZFSet.isOrdinal_toZFSet Ordinal.omega0 + have hm := ordinalProductAt_sound M hM 1 0 (w+3) _ (by + intro i; rcases i with _|_|_|i; exact hA; exact hM _ (he r) v hv; + exact hM _ (he d) x hx; exact he i) ho (by simpa [hw] using hwOrd) hp + simp only [cons_zero,cons_succ,hw,← toZFSet_omega,Ordinal.rank_toZFSet] at hm + exact ⟨A,hA,hs ▸ hst,ho,hm⟩ + +theorem omegaGraphSentence_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (s w d r f : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hs : e s = (1 : Ordinal.{u}).toZFSet) (hw : e w = ZFSet.omega) : + (omegaGraphSentence s w d r f).Sat (M : Set ZFSet) e ↔ + OmegaGraph M (e d) (e r) (e f) := by + refine ⟨omegaGraphSentence_sound M hM s w d r f e he hs hw,?_⟩ + intro hg + apply (omegaGraphSentence_semantics M hM s w d r f e he).mpr + refine ⟨hg.1,hg.2.1,?_⟩ + intro x hx v hv hfv + obtain ⟨A,hA,hst,ho,hp⟩ := hg.2.2 x hx v hv hfv + refine ⟨A,hA,hs.symm ▸ hst,ho,?_⟩ + have hwOrd : ZFSet.omega.{u}.IsOrdinal := toZFSet_omega ▸ ZFSet.isOrdinal_toZFSet Ordinal.omega0 + apply (ordinalProductAt_sourceT M hM hT 1 0 (w+3) _ (by + intro i; rcases i with _|_|_|i; exact hA; exact hM _ (he r) v hv; + exact hM _ (he d) x hx; exact he i) ho (by simpa [hw] using hwOrd)).mpr + simpa only [cons_zero,cons_succ,hw,← toZFSet_omega,Ordinal.rank_toZFSet] using hp + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelArithmetic.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b7bbf30951a41cea263a4e745a0e17dfbbcabf4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelArithmetic.lean @@ -0,0 +1,61 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaModelAxiomTransport +import OAI.Computability.DegreeRigidity.SetModels.SetModelArithmeticClosure + +namespace OAI + +namespace TuringRigidity.OmegaModelCore.OmegaData +open BoundedSetTheory SetModelReals SetModelSyntax +universe u +noncomputable section +variable {α : Type u} (S : OmegaData α) + +def RealCode (a : α) (A : Oracle) : Prop := + S.mem a (S.power S.omega) ∧ ∀ n, S.mem (S.num n) a ↔ A n = true + +theorem realCode_collapse {a : α} {A : Oracle} (ha : S.RealCode a A) : + S.collapse (⟨a,1,ha.1⟩ : S.Core) = realSet A := by + obtain ⟨B,hB,hBc⟩ := S.collapse_real a ha.1 + have he : B=A := by + funext n + have hn := (hBc n).trans (ha.2 n) + cases hb : B n <;> cases ha : A n <;> simp_all + exact hB.trans (congrArg realSet he) + +theorem represented_real_iff (A : Oracle) : + (∃ a : α, S.RealCode a A) ↔ A ∈ reals S.collapsedModel := by + constructor + · rintro ⟨a,ha⟩ + exact (S.mem_collapsedModel _).mpr ⟨⟨a,1,ha.1⟩,(S.realCode_collapse ha).symm⟩ + · intro hA + change realSet A ∈ S.collapsedModel at hA + obtain ⟨a,ha⟩ := (S.mem_collapsedModel _).mp hA + have hsub : S.collapse a ⊆ S.collapse S.omegaNode := by + rw [S.collapse_omega,←ha] + exact realSet_subset A + refine ⟨a.val,(S.mem_power _ _).mpr ((S.collapse_subset_iff a S.omegaNode).mp hsub),?_⟩ + intro n + change S.Rel (S.numNode n) a ↔ A n = true + rw [←S.collapse_mem_iff,S.collapse_num,←ha,nat_mem_realSet] + +theorem omega_arithmetic_comprehension (hP : S.PairingAxiom) (hU : S.UnionAxiom) + (hS : S.SeparationAxiom) {P : UniformArithmetic.Predicate} (hp : UniformArithmetic.Arith P) + (O : UniformArithmetic.Oracles) (hO : ∀ i, ∃ a, S.RealCode a (O i)) + (A : Oracle) (hA : ∀ n, P O n ↔ A n = true) : ∃ a, S.RealCode a A := by + apply (S.represented_real_iff A).mpr + exact arithmetic_comprehension (S.collapsed_context hP hU hS) hp O + (fun i => (S.represented_real_iff _).mp (hO i)) A hA + +theorem omega_lower (hP : S.PairingAxiom) (hU : S.UnionAxiom) (hS : S.SeparationAxiom) + {A B : Oracle} (hB : ∃ b, S.RealCode b B) (hAB : Reduces A B) : ∃ a, S.RealCode a A := + (S.represented_real_iff _).mpr (lower_mem (S.collapsed_context hP hU hS) + ((S.represented_real_iff _).mp hB) hAB) + +theorem omega_jump (hP : S.PairingAxiom) (hU : S.UnionAxiom) (hS : S.SeparationAxiom) + {A : Oracle} (hA : ∃ a, S.RealCode a A) : ∃ b, S.RealCode b (OracleJump.jump A) := + (S.represented_real_iff _).mpr (jump_mem (S.collapsed_context hP hU hS) + ((S.represented_real_iff _).mp hA)) + +end +end TuringRigidity.OmegaModelCore.OmegaData + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelAxiomTransport.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelAxiomTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..403084b5388e9f4469de6325a542406967c7f4cf --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelAxiomTransport.lean @@ -0,0 +1,115 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaModelSyntax +import OAI.Computability.DegreeRigidity.SetModels.SetModelFunctionGraphs + +namespace OAI + +namespace TuringRigidity.OmegaModelCore.OmegaData +open BoundedSetTheory TransitiveNameModel SetModelFunctions +universe u +noncomputable section +variable {α : Type u} (S : OmegaData α) + +theorem collapsed_pairing (hP : S.PairingAxiom) : Pairing S.collapsedModel := by + intro a ha b hb + obtain ⟨x,rfl⟩ := (S.mem_collapsedModel a).mp ha + obtain ⟨y,rfl⟩ := (S.mem_collapsedModel b).mp hb + obtain ⟨c,hc⟩ := hP x.val y.val + let v : S.Core := ⟨c,S.pair_core x.property y.property hc⟩ + refine ⟨S.collapse v,(S.mem_collapsedModel _).mpr ⟨v,rfl⟩,?_⟩ + intro z hz + obtain ⟨z,rfl⟩ := (S.mem_collapsedModel z).mp hz + rw [S.collapse_mem_iff] + change S.mem z.val c ↔ _ + rw [hc] + constructor + · intro h + exact h.elim (fun h => Or.inl (congrArg S.collapse (Subtype.ext h))) + (fun h => Or.inr (congrArg S.collapse (Subtype.ext h))) + · intro h + exact h.elim (fun h => Or.inl (congrArg Subtype.val (S.collapse_injective h))) + (fun h => Or.inr (congrArg Subtype.val (S.collapse_injective h))) + +theorem collapsed_union (hU : S.UnionAxiom) : BoundedSetTheory.Union S.collapsedModel := by + intro a ha + obtain ⟨a,rfl⟩ := (S.mem_collapsedModel a).mp ha + obtain ⟨b,hb⟩ := hU a.val + let v : S.Core := ⟨b,S.union_core a.property hb⟩ + refine ⟨S.collapse v,(S.mem_collapsedModel _).mpr ⟨v,rfl⟩,?_⟩ + intro z hz + obtain ⟨z,rfl⟩ := (S.mem_collapsedModel z).mp hz + constructor + · intro h + obtain ⟨y,hy,hzy⟩ := (hb z.val).mp ((S.collapse_mem_iff z v).mp h) + let y' : S.Core := ⟨y,S.core_transitive a.property hy⟩ + exact ⟨S.collapse y',(S.mem_collapsedModel _).mpr ⟨y',rfl⟩, + (S.collapse_mem_iff y' a).mpr hy,(S.collapse_mem_iff z y').mpr hzy⟩ + · rintro ⟨y,hy,hya,hzy⟩ + obtain ⟨y,rfl⟩ := (S.mem_collapsedModel y).mp hy + exact (S.collapse_mem_iff z v).mpr ((hb z.val).mpr + ⟨y.val,(S.collapse_mem_iff y a).mp hya,(S.collapse_mem_iff z y).mp hzy⟩) + +theorem collapsed_power : PowerSet S.collapsedModel := by + intro a ha + obtain ⟨a,rfl⟩ := (S.mem_collapsedModel a).mp ha + let v : S.Core := ⟨S.power a.val,S.power_core a.property⟩ + refine ⟨S.collapse v,(S.mem_collapsedModel _).mpr ⟨v,rfl⟩,?_⟩ + intro x hx + obtain ⟨x,rfl⟩ := (S.mem_collapsedModel x).mp hx + constructor + · intro h y hy hyx + have hs := (S.mem_power a.val x.val).mp ((S.collapse_mem_iff x v).mp h) + exact (S.collapse_subset_iff x a).mpr hs hyx + · intro h + apply (S.collapse_mem_iff x v).mpr + apply (S.mem_power a.val x.val).mpr + apply (S.collapse_subset_iff x a).mp + intro y hy + exact h y (S.collapsedModel_transitive _ ((S.mem_collapsedModel _).mpr ⟨x,rfl⟩) _ hy) hy + +theorem collapsed_separation (hS : S.SeparationAxiom) : Separation S.collapsedModel := by + intro p e he a ha + have hex (i : ℕ) : ∃ x : S.Core, e i = S.collapse x := (S.mem_collapsedModel _).mp (he i) + choose d hd using hex + obtain ⟨a,ha⟩ := (S.mem_collapsedModel a).mp ha + obtain ⟨b,hb⟩ := hS p (fun i => (d i).val) a.val + let v : S.Core := ⟨b,S.core_subset a.property (fun y hy => ((hb y).mp hy).1)⟩ + refine ⟨S.collapse v,(S.mem_collapsedModel _).mpr ⟨v,rfl⟩,?_⟩ + intro z hz + obtain ⟨z,rfl⟩ := (S.mem_collapsedModel z).mp hz + have ee : (fun i => S.collapse (push z d i)) = cons (S.collapse z) e := by + funext i + cases i with + | zero => rfl + | succ i => exact (hd i).symm + have er : p.Realize S.collapsedModel (cons (S.collapse z) e) ↔ + S.Eval (push z.val (fun i => (d i).val)) p := by + rw [←ee] + apply (p.absolute S.collapsedModel S.collapsedModel_transitive _ + (fun i => (S.mem_collapsedModel _).mpr ⟨push z d i,rfl⟩)).trans + have hv : (fun i => (push z d i).val) = push z.val (fun i => (d i).val) := by + funext i + cases i <;> rfl + simpa only [hv] using S.collapse_eval p (push z d) + rw [ha,S.collapse_mem_iff,S.collapse_mem_iff,er] + exact hb z.val + +theorem collapsed_infinity : Infinity S.collapsedModel := by + have hn (n : ℕ) : natSet.{u} n ∈ S.collapsedModel := + (S.mem_collapsedModel _).mpr ⟨S.numNode n,(S.collapse_num n).symm⟩ + refine ⟨ZFSet.omega,S.collapsedModel_omega,?_,?_⟩ + · exact ⟨natSet 0,hn 0,(mem_omega _).mpr ⟨0,rfl⟩,fun z _ => ZFSet.notMem_empty z⟩ + · intro x hx hω + obtain ⟨n,rfl⟩ := (mem_omega x).mp hω + refine ⟨natSet (n+1),hn (n+1),(mem_omega _).mpr ⟨n+1,rfl⟩,?_⟩ + intro z hz + exact ZFSet.mem_insert_iff + +theorem collapsed_context (hP : S.PairingAxiom) (hU : S.UnionAxiom) (hS : S.SeparationAxiom) : + Context S.collapsedModel := + ⟨S.collapsedModel_transitive,S.collapsed_pairing hP,S.collapsed_union hU, + S.collapsed_power,S.collapsed_separation hS,S.collapsed_infinity⟩ + +end +end TuringRigidity.OmegaModelCore.OmegaData + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelCollapse.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelCollapse.lean new file mode 100644 index 0000000000000000000000000000000000000000..bbe0dde356d22faba1bf1bc23fb9829c72e35bd2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelCollapse.lean @@ -0,0 +1,131 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaModelCore + +namespace OAI + +namespace TuringRigidity.OmegaModelCore +open BoundedSetTheory TransitiveNameModel SetModelReals +universe u +noncomputable section +namespace OmegaData +variable {α : Type u} (S : OmegaData α) + +def collapse : S.Core → ZFSet.{u} := S.core_wellFounded.fix + (fun x rec => ZFSet.range (fun y : {y : S.Core // S.Rel y x} => rec y.val y.property)) + +theorem collapse_eq (x : S.Core) : + S.collapse x = ZFSet.range (fun y : {y : S.Core // S.Rel y x} => S.collapse y.val) := by + rw [collapse,WellFounded.fix_eq] + +@[simp] theorem mem_collapse (x : S.Core) (z : ZFSet.{u}) : + z ∈ S.collapse x ↔ ∃ y : S.Core, S.Rel y x ∧ z = S.collapse y := by + rw [S.collapse_eq,ZFSet.mem_range] + constructor + · rintro ⟨⟨y,hy⟩,he⟩ + exact ⟨y,hy,he.symm⟩ + · rintro ⟨y,hy,he⟩ + exact ⟨⟨y,hy⟩,he.symm⟩ + +theorem collapse_injective : Function.Injective S.collapse := by + intro x + induction x using S.core_wellFounded.induction with + | h x ih => + intro y he + apply S.core_extensional + intro z + constructor + · intro hz + have hm : S.collapse z ∈ S.collapse y := he ▸ (S.mem_collapse x _).mpr ⟨z,hz,rfl⟩ + obtain ⟨w,hw,hew⟩ := (S.mem_collapse y _).mp hm + have hzw := ih z hz hew + exact hzw ▸ hw + · intro hz + have hm : S.collapse z ∈ S.collapse x := he.symm ▸ (S.mem_collapse y _).mpr ⟨z,hz,rfl⟩ + obtain ⟨w,hw,hew⟩ := (S.mem_collapse x _).mp hm + have hwz := ih w hw hew.symm + exact hwz ▸ hw + +@[simp] theorem collapse_mem_iff (x y : S.Core) : S.collapse x ∈ S.collapse y ↔ S.Rel x y := by + rw [S.mem_collapse] + constructor + · rintro ⟨z,hz,he⟩ + exact S.collapse_injective he ▸ hz + · intro h + exact ⟨x,h,rfl⟩ + +def collapsedModel : ZFSet.{u} := ZFSet.range S.collapse + +@[simp] theorem mem_collapsedModel (z : ZFSet.{u}) : + z ∈ S.collapsedModel ↔ ∃ x : S.Core, z = S.collapse x := by + rw [collapsedModel,ZFSet.mem_range] + exact exists_congr (fun x => eq_comm) + +theorem collapsedModel_transitive : Transitive S.collapsedModel := by + intro x hx y hy + obtain ⟨a,rfl⟩ := (S.mem_collapsedModel x).mp hx + obtain ⟨b,hb,rfl⟩ := (S.mem_collapse a y).mp hy + exact (S.mem_collapsedModel _).mpr ⟨b,rfl⟩ + +def numNode (n : ℕ) : S.Core := ⟨S.num n,0,(S.omega_mem _).mpr ⟨n,rfl⟩⟩ + +theorem rel_numNode (x : S.Core) (n : ℕ) : + S.Rel x (S.numNode n) ↔ ∃ k < n, x = S.numNode k := by + change S.mem x.val (S.num n) ↔ _ + rw [S.num_mem] + constructor + · rintro ⟨k,hk,he⟩ + exact ⟨k,hk,Subtype.ext he⟩ + · rintro ⟨k,hk,rfl⟩ + exact ⟨k,hk,rfl⟩ + +theorem collapse_num (n : ℕ) : S.collapse (S.numNode n) = natSet n := by + induction n using Nat.strong_induction_on with + | h n ih => + apply ZFSet.ext + intro z + rw [S.mem_collapse,mem_natSet] + constructor + · rintro ⟨x,hx,hz⟩ + obtain ⟨k,hk,rfl⟩ := (S.rel_numNode x n).mp hx + exact ⟨k,hk,hz.trans (ih k hk)⟩ + · rintro ⟨k,hk,rfl⟩ + exact ⟨S.numNode k,(S.rel_numNode _ n).mpr ⟨k,hk,rfl⟩,(ih k hk).symm⟩ + +def omegaNode : S.Core := ⟨S.omega,1,(S.mem_power S.omega S.omega).mpr (fun _ h => h)⟩ + +theorem collapse_omega : S.collapse S.omegaNode = ZFSet.omega := by + apply ZFSet.ext + intro z + rw [S.mem_collapse,mem_omega] + constructor + · rintro ⟨x,hx,hz⟩ + obtain ⟨n,hn⟩ := (S.omega_mem x.val).mp hx + have he : x = S.numNode n := Subtype.ext hn + exact ⟨n,by rw [hz,he,S.collapse_num]⟩ + · rintro ⟨n,rfl⟩ + exact ⟨S.numNode n,(S.omega_mem _).mpr ⟨n,rfl⟩,(S.collapse_num n).symm⟩ + +theorem collapsedModel_omega : ZFSet.omega.{u} ∈ S.collapsedModel := + (S.mem_collapsedModel _).mpr ⟨S.omegaNode,S.collapse_omega.symm⟩ + +theorem collapse_real (x : α) (hx : S.mem x (S.power S.omega)) : + ∃ A : TuringRigidity.Oracle, + S.collapse (⟨x,1,hx⟩ : S.Core) = realSet A ∧ + ∀ n, A n = true ↔ S.mem (S.num n) x := by + let c : S.Core := ⟨x,1,hx⟩ + have hsub : S.collapse c ⊆ ZFSet.omega := by + intro z hz + obtain ⟨y,hy,rfl⟩ := (S.mem_collapse c z).mp hz + have hyω := (S.mem_power _ _).mp hx y.val hy + rw [←S.collapse_omega,S.collapse_mem_iff] + exact hyω + refine ⟨oracleOf (S.collapse c),(realSet_oracleOf hsub).symm,?_⟩ + intro n + simp only [oracleOf,decide_eq_true_eq] + rw [←S.collapse_num,S.collapse_mem_iff] + rfl + +end OmegaData +end +end TuringRigidity.OmegaModelCore + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelCore.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelCore.lean new file mode 100644 index 0000000000000000000000000000000000000000..2958fe5e4bd8bbcf9689f9145f7448dc1af4fddd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelCore.lean @@ -0,0 +1,96 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelReals + +namespace OAI + +namespace TuringRigidity.OmegaModelCore +universe u +noncomputable section + +structure OmegaData (α : Type u) where + mem : α → α → Prop + extensional : ∀ x y, (∀ z, mem z x ↔ mem z y) → x = y + num : ℕ → α + num_mem : ∀ x n, mem x (num n) ↔ ∃ k < n, x = num k + omega : α + omega_mem : ∀ x, mem x omega ↔ ∃ n, x = num n + power_exists : ∀ a, ∃ b, ∀ x, mem x b ↔ ∀ y, mem y x → mem y a + +namespace OmegaData +variable {α : Type u} (S : OmegaData α) + +def power (a : α) : α := (S.power_exists a).choose + +theorem mem_power (a x : α) : S.mem x (S.power a) ↔ ∀ y, S.mem y x → S.mem y a := + (S.power_exists a).choose_spec x + +def level : ℕ → α + | 0 => S.omega + | n+1 => S.power (level n) + +def InCore (x : α) : Prop := ∃ n, S.mem x (S.level n) + +theorem num_accessible (n : ℕ) : Acc S.mem (S.num n) := by + induction n using Nat.strong_induction_on with + | h n ih => + constructor + intro x hx + obtain ⟨k,hk,rfl⟩ := (S.num_mem x n).mp hx + exact ih k hk + +theorem level_accessible (n : ℕ) : ∀ x, S.mem x (S.level n) → Acc S.mem x := by + induction n with + | zero => + intro x hx + obtain ⟨k,rfl⟩ := (S.omega_mem x).mp hx + exact S.num_accessible k + | succ n ih => + intro x hx + constructor + intro y hy + exact ih y ((S.mem_power _ x).mp hx y hy) + +theorem core_accessible {x : α} (hx : S.InCore x) : Acc S.mem x := by + obtain ⟨n,hn⟩ := hx + exact S.level_accessible n x hn + +theorem core_transitive {x y : α} (hx : S.InCore x) (hy : S.mem y x) : S.InCore y := by + obtain ⟨n,hn⟩ := hx + cases n with + | zero => + obtain ⟨k,rfl⟩ := (S.omega_mem x).mp hn + obtain ⟨j,hj,rfl⟩ := (S.num_mem y k).mp hy + exact ⟨0,(S.omega_mem _).mpr ⟨j,rfl⟩⟩ + | succ n => exact ⟨n,(S.mem_power _ x).mp hn y hy⟩ + +abbrev Core := {x : α // S.InCore x} +def Rel (x y : S.Core) : Prop := S.mem x.val y.val + +theorem core_wellFounded : WellFounded S.Rel := by + have lift (x : α) (h : Acc S.mem x) : ∀ hx, Acc S.Rel (⟨x,hx⟩ : S.Core) := by + induction h with + | intro x h ih => + intro hx + constructor + intro y hy + exact ih y.val hy y.property + exact ⟨fun x => lift x.val (S.core_accessible x.property) x.property⟩ + +theorem core_extensional (x y : S.Core) (h : ∀ z : S.Core, S.Rel z x ↔ S.Rel z y) : x = y := by + apply Subtype.ext + apply S.extensional + intro z + constructor + · intro hz + exact (h ⟨z,S.core_transitive x.property hz⟩).mp hz + · intro hz + exact (h ⟨z,S.core_transitive y.property hz⟩).mpr hz + +theorem core_is_wellFounded_extensional : + WellFounded S.Rel ∧ ∀ x y : S.Core, (∀ z, S.Rel z x ↔ S.Rel z y) → x = y := + ⟨S.core_wellFounded,S.core_extensional⟩ + +end OmegaData +end +end TuringRigidity.OmegaModelCore + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelCoreClosure.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelCoreClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..06bb1557eb9bbc5186dcedf5a8116600bffb06a4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelCoreClosure.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaModelCollapse + +namespace OAI + +namespace TuringRigidity.OmegaModelCore.OmegaData +universe u +noncomputable section +variable {α : Type u} (S : OmegaData α) + +def TransitiveAt (a : α) : Prop := ∀ x, S.mem x a → ∀ y, S.mem y x → S.mem y a + +theorem omega_transitive : S.TransitiveAt S.omega := by + intro x hx y hy + obtain ⟨n,rfl⟩ := (S.omega_mem x).mp hx + obtain ⟨k,hk,rfl⟩ := (S.num_mem y n).mp hy + exact (S.omega_mem _).mpr ⟨k,rfl⟩ + +theorem power_transitive {a : α} (ha : S.TransitiveAt a) : S.TransitiveAt (S.power a) := by + intro x hx y hy + apply (S.mem_power a y).mpr + intro z hz + exact ha y ((S.mem_power a x).mp hx y hy) z hz + +theorem level_transitive (n : ℕ) : S.TransitiveAt (S.level n) := by + induction n with + | zero => exact S.omega_transitive + | succ n ih => exact S.power_transitive ih + +theorem level_succ {n : ℕ} {x : α} (hx : S.mem x (S.level n)) : + S.mem x (S.level (n+1)) := + (S.mem_power _ x).mpr (fun y hy => S.level_transitive n x hx y hy) + +theorem level_mono {n m : ℕ} (hnm : n ≤ m) {x : α} (hx : S.mem x (S.level n)) : + S.mem x (S.level m) := by + induction hnm with + | refl => exact hx + | step h ih => exact S.level_succ ih + +theorem core_of_subset_level {x : α} {n : ℕ} + (hx : ∀ y, S.mem y x → S.mem y (S.level n)) : S.InCore x := + ⟨n+1,(S.mem_power _ _).mpr hx⟩ + +theorem core_subset {x a : α} (ha : S.InCore a) (hx : ∀ y, S.mem y x → S.mem y a) : + S.InCore x := by + obtain ⟨n,hn⟩ := ha + exact S.core_of_subset_level (fun y hy => S.level_transitive n a hn y (hx y hy)) + +theorem power_core {a : α} (ha : S.InCore a) : S.InCore (S.power a) := by + obtain ⟨n,hn⟩ := ha + apply S.core_of_subset_level (n := n+1) + intro x hx + apply (S.mem_power _ x).mpr + intro y hy + exact S.level_transitive n a hn y ((S.mem_power a x).mp hx y hy) + +theorem pair_core {a b c : α} (ha : S.InCore a) (hb : S.InCore b) + (hc : ∀ x, S.mem x c ↔ x=a ∨ x=b) : S.InCore c := by + obtain ⟨n,hn⟩ := ha + obtain ⟨m,hm⟩ := hb + apply S.core_of_subset_level (n := max n m) + intro x hx + rcases (hc x).mp hx with rfl|rfl + · exact S.level_mono (Nat.le_max_left _ _) hn + · exact S.level_mono (Nat.le_max_right _ _) hm + +theorem union_core {a b : α} (ha : S.InCore a) + (hb : ∀ x, S.mem x b ↔ ∃ y, S.mem y a ∧ S.mem x y) : S.InCore b := by + obtain ⟨n,hn⟩ := ha + apply S.core_of_subset_level (n := n) + intro x hx + obtain ⟨y,hy,hxy⟩ := (hb x).mp hx + exact S.level_transitive n y (S.level_transitive n a hn y hy) x hxy + +theorem collapse_subset_iff (x y : S.Core) : + S.collapse x ⊆ S.collapse y ↔ ∀ z, S.mem z x.val → S.mem z y.val := by + constructor + · intro h z hz + let c : S.Core := ⟨z,S.core_transitive x.property hz⟩ + exact (S.collapse_mem_iff c y).mp (h ((S.collapse_mem_iff c x).mpr hz)) + · intro h z hz + obtain ⟨c,hc,rfl⟩ := (S.mem_collapse x z).mp hz + exact (S.collapse_mem_iff c y).mpr (h c.val hc) + +end +end TuringRigidity.OmegaModelCore.OmegaData + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..8461c313bb8f7611e4f797f4b6c62814751a8640 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaModelSyntax.lean @@ -0,0 +1,62 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaModelCoreClosure + +namespace OAI + +namespace TuringRigidity.OmegaModelCore.OmegaData +open BoundedSetTheory +universe u +noncomputable section +variable {α : Type u} (S : OmegaData α) + +def push {β : Type*} (x : β) (e : ℕ → β) : ℕ → β + | 0 => x + | n+1 => e n + +def Eval (e : ℕ → α) : Formula → Prop + | .equal i j => e i = e j + | .member i j => S.mem (e i) (e j) + | .conj p q => Eval e p ∧ Eval e q + | .neg p => ¬ Eval e p + | .existsMem i p => ∃ x, S.mem x (e i) ∧ Eval (push x e) p + +theorem collapse_eval (p : Formula) (e : ℕ → S.Core) : + p.Eval (fun i => S.collapse (e i)) ↔ S.Eval (fun i => (e i).val) p := by + induction p generalizing e with + | equal i j => + change S.collapse (e i) = S.collapse (e j) ↔ (e i).val = (e j).val + exact ⟨fun h => congrArg Subtype.val (S.collapse_injective h), + fun h => congrArg S.collapse (Subtype.ext h)⟩ + | member i j => exact S.collapse_mem_iff (e i) (e j) + | conj p q hp hq => exact and_congr (hp e) (hq e) + | neg p hp => exact not_congr (hp e) + | existsMem i p hp => + have hstep (y : S.Core) : p.Eval (cons (S.collapse y) (fun i => S.collapse (e i))) ↔ + S.Eval (push y.val (fun i => (e i).val)) p := by + have he : (fun i => S.collapse (push y e i)) = + cons (S.collapse y) (fun i => S.collapse (e i)) := by + funext i + cases i <;> rfl + have hv : (fun i => (push y e i).val) = push y.val (fun i => (e i).val) := by + funext i + cases i <;> rfl + simpa only [he,hv] using hp (push y e) + constructor + · rintro ⟨x,hx,hp'⟩ + obtain ⟨y,hy,rfl⟩ := (S.mem_collapse (e i) x).mp hx + exact ⟨y.val,hy,(hstep y).mp hp'⟩ + · rintro ⟨x,hx,hp'⟩ + let y : S.Core := ⟨x,S.core_transitive (e i).property hx⟩ + exact ⟨S.collapse y,(S.mem_collapse (e i) _).mpr ⟨y,hx,rfl⟩, + (hstep y).mpr hp'⟩ + +def PairingAxiom : Prop := ∀ a b : α, ∃ c, ∀ x, S.mem x c ↔ x=a ∨ x=b + +def UnionAxiom : Prop := ∀ a : α, ∃ b, ∀ x, S.mem x b ↔ ∃ y, S.mem y a ∧ S.mem x y + +def SeparationAxiom : Prop := ∀ (p : Formula) (e : ℕ → α) (a : α), + ∃ b, ∀ x, S.mem x b ↔ S.mem x a ∧ S.Eval (push x e) p + +end +end TuringRigidity.OmegaModelCore.OmegaData + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerCertificates.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a16a08b197976b6fa24ac47360dac25048372fe --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerCertificates.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaPowerSyntax + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +def ProductCertificates (M : ZFSet.{u}) (a b : Ordinal.{u}) : Prop := + ZFSet.prod b.toZFSet a.toZFSet ∈ M ∧ productRelation a.toZFSet b.toZFSet ∈ M ∧ + ∃ f ∈ M, OrderTypeCertificate (ZFSet.prod b.toZFSet a.toZFSet) + (productRelation a.toZFSet b.toZFSet) (a*b).toZFSet f + +theorem ProductCertificates.sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a b : Ordinal.{u}) (ha : a.toZFSet ∈ M) (hb : b.toZFSet ∈ M) : ProductCertificates M a b := by + obtain ⟨_,f,hf,_,hc⟩ := ordinal_mul_internal M hM hT a b ha hb + exact ⟨product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hb ha, + productRelation_mem M _ _ hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded ha hb, + f,hf,hc⟩ + +theorem ProductCertificates.mono {M N : ZFSet.{u}} {a b : Ordinal.{u}} + (h : ProductCertificates M a b) (hMN : M ⊆ N) : ProductCertificates N a b := + ⟨hMN h.1,hMN h.2.1,let ⟨f,hf,hc⟩ := h.2.2; ⟨f,hMN hf,hc⟩⟩ + +theorem ordinalProductAt_of_certificates (M : ZFSet.{u}) (hM : Transitive M) + (v a b : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (α β : Ordinal.{u}) (ha : e a = α.toZFSet) (hb : e b = β.toZFSet) + (hc : ProductCertificates M α β) (hv : e v = (α*β).toZFSet) : + (ordinalProductAt v a b).Sat (M : Set ZFSet) e := by + rw [ordinalProductAt,SentenceForm.sat_rename] + exact (productSentence_spec_of_certificate M hM + (fun i => e (if i = 0 then v else if i = 1 then a else b)) (fun i => he _) α β ha hb + hc.1 hc.2.1 hc.2.2).mpr hv + +def OmegaPowerCertificates (M x : ZFSet.{u}) : Prop := + x ∈ M ∧ ∃ f ∈ M, ∃ r ∈ M, OmegaGraph M (x) r f ∧ + ∀ t ∈ x, ProductCertificates M (Ordinal.omega0 ^ t.rank) Ordinal.omega0 + +theorem OmegaPowerCertificates.sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (x : ZFSet.{u}) (hx : x ∈ M) (ho : x.IsOrdinal) : OmegaPowerCertificates M x := by + obtain ⟨f,hf,hg⟩ := internal_omegaGraph_below M hM hT x hx ho + have hd := hx + refine ⟨hd,f,hf,_,iterUnion_mem M hM hT.union hf 2,hg,?_⟩ + intro t ht + have htM := hM _ hd t ht + exact ProductCertificates.sourceT M hM hT _ _ + (ordinal_omega_opow_internal M hM hT t.rank ((hg.1.mem ht).toZFSet_rank_eq.symm ▸ htM)) + (toZFSet_omega.symm ▸ omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity) + +theorem OmegaPowerCertificates.mono {M N x : ZFSet.{u}} + (h : OmegaPowerCertificates M x) (hMN : M ⊆ N) : OmegaPowerCertificates N x := by + obtain ⟨hd,f,hf,r,hr,hg,hp⟩ := h + refine ⟨hMN hd,f,hMN hf,r,hMN hr,⟨hg.1,hg.2.1,?_⟩,fun t ht => (hp t ht).mono hMN⟩ + intro t ht v hv hfv + obtain ⟨A,hA,hs,ho,he⟩ := hg.2.2 t ht v hv hfv + exact ⟨A,hMN hA,hs,ho,he⟩ + +theorem omegaGraphSentence_of_certificates (M : ZFSet.{u}) (hM : Transitive M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hs : e 3 = (1 : Ordinal.{u}).toZFSet) (hw : e 4 = ZFSet.omega) + (hg : OmegaGraph M (e 0) (e 1) (e 2)) + (hp : ∀ t ∈ e 0, ProductCertificates M (Ordinal.omega0 ^ t.rank) Ordinal.omega0) : + (omegaGraphSentence 3 4 0 1 2).Sat (M : Set ZFSet) e := by + apply (omegaGraphSentence_semantics M hM 3 4 0 1 2 e he).mpr + refine ⟨hg.1,hg.2.1,?_⟩ + intro t ht v hv hfv + obtain ⟨A,hA,hst,ho,hval⟩ := hg.2.2 t ht v hv hfv + have hAe := omegaStageStep_exact hg ht hst + refine ⟨A,hA,hs.symm ▸ hst,ho,?_⟩ + apply ordinalProductAt_of_certificates M hM 1 0 7 (cons A (cons v (cons t e))) + (fun i => by + rcases i with _|_|_|i + exact hA; exact hM _ (he 1) v hv; exact hM _ (he 0) t ht; exact he i) + (Ordinal.omega0 ^ t.rank) Ordinal.omega0 hAe (by simpa using hw.trans toZFSet_omega.symm) (hp t ht) + simpa only [cons_zero,cons_succ,hAe,Ordinal.rank_toZFSet] using hval + +theorem omegaPowerSentence_of_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hc : OmegaPowerCertificates M (e 1)) + (hy : e 0 = (Ordinal.omega0 ^ (e 1).rank).toZFSet) : + omegaPowerSentence.Sat (M : Set ZFSet) e := by + obtain ⟨hd,f,hf,r,hr,hg,hp⟩ := hc + have hs : (1 : Ordinal.{u}).toZFSet ∈ M := by + rw [← Nat.cast_one,toZFSet_nat] + exact hM _ hω _ ((mem_omega _).mpr ⟨1,rfl⟩) + have hst := omegaStageStep_domain M (e 1) r f hg + apply (omegaPowerSentence_semantics M hM hω e he).mpr + refine ⟨_,hω,_,hs,f,hf,r,hr,_,hd,rfl,rfl,rfl,?_,hy.symm ▸ hst⟩ + exact omegaGraphSentence_of_certificates M hM _ (by + intro i; rcases i with _|_|_|_|_|i + exact hd; exact hr; exact hf; exact hs; exact hω; exact he i) rfl rfl hg hp + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerDefinability.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerDefinability.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba5631ff380db0ecafa306a1f46d4f531d257aec --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerDefinability.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DegreeRigidity.Constructibility.InternalOmegaPower + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open BoundedDefinability SetModelFunctions SentenceCoding +universe u + +theorem omegaStageStep_exact {M d r f x A : ZFSet.{u}} (hg : OmegaGraph M d r f) + (hx : x ∈ d) (hs : StageStep (1 : Ordinal.{u}).toZFSet f r x A) : + A = (Ordinal.omega0 ^ x.rank).toZFSet := by + apply ZFSet.ext; intro z + rw [omegaPower_members,(hg.1.mem hx).toZFSet_rank_eq] + constructor + · intro hz + rcases hs.2.1 z hz with hz|⟨y,hy,w,hw,hfw,hz⟩ + · exact Or.inl hz + · exact Or.inr ⟨y,hy,(hg.correct y (hg.1.subset_of_mem hx hy) w hw hfw) ▸ hz⟩ + · rintro (hz|⟨y,hy,hz⟩) + · exact hs.1 hz + · obtain ⟨w,hw,hfw,_⟩ := hg.2.1.2 y (hg.1.subset_of_mem hx hy) + rw [← hg.correct y (hg.1.subset_of_mem hx hy) w hw hfw] at hz + exact hs.2.2 y hy w hw hfw hz + +theorem omegaPower_sigmaDefinable (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + SigmaDefinable M (fun e => (e 1).IsOrdinal ∧ e 0 = (Ordinal.omega0 ^ (e 1).rank).toZFSet) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + have h1 : (1 : Ordinal.{u}).toZFSet ∈ M := by + rw [← Nat.cast_one,toZFSet_nat]; exact C.nat_mem 1 + have hd : Definable M (fun e => e 0 = insert (e 4) (e 4)) := by + refine ⟨.successor 0 8,fun _ => ZFSet.omega,fun _ => C.omega_mem,?_⟩ + intro e; simp [Formula.eval_successor,mix] + have hs : SigmaDefinable M (fun e => + StageStep (1 : Ordinal.{u}).toZFSet (e 2) (e 1) (e 4) (e 3)) := by + have hb := (stageStep_definable C 0 3 2 5 4).toSigma hM + exact (((equal_param h1 0).toSigma hM).and hb).existsSet.congr (fun e _ => by simp [h1]) + have hg := (hd.toSigma hM).and ((omegaGraph_sigmaDefinable M hM hT 0 1 2).and hs) + apply hg.existsSet.existsSet.existsSet.congr + intro e he + change (∃ f ∈ M, ∃ r ∈ M, ∃ d ∈ M, + d = insert (e 1) (e 1) ∧ OmegaGraph M d r f ∧ + StageStep (1 : Ordinal.{u}).toZFSet f r (e 1) (e 0)) ↔ _ + constructor + · rintro ⟨f,_,r,_,d,_,rfl,hg,hs⟩ + have hx : e 1 ∈ insert (e 1) (e 1) := ZFSet.mem_insert_iff.mpr (Or.inl rfl) + exact ⟨hg.1.mem hx,omegaStageStep_exact hg hx hs⟩ + · rintro ⟨ho,hy⟩ + obtain ⟨f,hf,hg⟩ := internal_omegaGraph M hM hT (e 1) (he 1) ho + have hx : e 1 ∈ insert (e 1) (e 1) := ZFSet.mem_insert_iff.mpr (Or.inl rfl) + obtain ⟨v,hv,hfv,_⟩ := hg.2.1.2 (e 1) hx + obtain ⟨A,_,hA,_⟩ := hg.2.2 (e 1) hx v hv hfv + have hAy : A = e 0 := (omegaStageStep_exact hg hx hA).trans hy.symm + exact ⟨f,hf,_,iterUnion_mem M hM hT.union hf 2,_, + insert_self_mem M hM hT.pairing hT.union (he 1),rfl,hg,hAy ▸ hA⟩ + +theorem uniform_omega_power (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ∃ p : SigmaFormula, ∃ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ M) ∧ + ∀ x ∈ M, ∀ y ∈ M, p.Realize M (cons y (cons x e)) ↔ + x.IsOrdinal ∧ y = (Ordinal.omega0 ^ x.rank).toZFSet := + sigma_binary_relation _ (omegaPower_sigmaDefinable M hM hT) + +theorem omega_power_image_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) : + ∃ b ∈ M, ∀ y, y ∈ b ↔ ∃ c < a, y = (Ordinal.omega0 ^ c).toZFSet := by + obtain ⟨p,e,he,hp⟩ := uniform_omega_power M hM hT + obtain ⟨b,hb,hdef⟩ := replacement_image M hM hT.replacement.finitePrefix p e he ha + (fun x => (Ordinal.omega0 ^ x.rank).toZFSet) (by + intro x hx + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + rw [Ordinal.rank_toZFSet] + exact ordinal_omega_opow_internal M hM hT c + (hM _ ha _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hc))) (by + intro x hx y hy + rw [hp x (hM _ ha x hx) y hy] + exact and_iff_right ((ZFSet.isOrdinal_toZFSet a).mem hx)) + refine ⟨b,hb,?_⟩ + intro y + rw [hdef y] + constructor + · rintro ⟨x,hx,hy⟩ + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + exact ⟨c,hc,by simpa using hy.symm⟩ + · rintro ⟨c,hc,rfl⟩ + exact ⟨c.toZFSet,Ordinal.toZFSet_mem_toZFSet_iff.mpr hc,by rw [Ordinal.rank_toZFSet]⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerGraph.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b251fa67172d9a7e4f6907f76d606d8978b8004 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerGraph.lean @@ -0,0 +1,123 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaPowerStage + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open BoundedDefinability SetModelFunctions SentenceCoding +universe u + +theorem insert_self_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + (hU : BoundedSetTheory.Union M) {x : ZFSet.{u}} (hx : x ∈ M) : insert x x ∈ M := by + have he : insert x x = ({x} : ZFSet.{u}) ∪ x := by + apply ZFSet.ext; intro z + simp only [ZFSet.mem_insert_iff,ZFSet.mem_union,ZFSet.mem_singleton] + rw [he] + exact binary_union_mem M hM hP hU (singleton_mem M hM hP hx) hx + +theorem omegaGraph_of_mem_iff (M d f : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hdM : d ∈ M) (hfM : f ∈ M) (hd : d.IsOrdinal) + (hf : ∀ z, z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (omegaNext x)) : + OmegaGraph M d (iterUnion 2 f) f := by + have h1 : (1 : Ordinal.{u}).toZFSet ∈ M := by + rw [← Nat.cast_one,toZFSet_nat] + exact hM _ (omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity) _ ((mem_omega _).mpr ⟨1,rfl⟩) + have hpair (x v : ZFSet.{u}) : ZFSet.pair x v ∈ f ↔ x ∈ d ∧ v = omegaNext x := by + rw [hf] + constructor + · rintro ⟨y,hy,he⟩ + obtain ⟨rfl,hv⟩ := ZFSet.pair_inj.mp he + exact ⟨hy,hv⟩ + · rintro ⟨hx,rfl⟩; exact ⟨x,hx,rfl⟩ + refine ⟨hd,⟨?_,?_⟩,?_⟩ + · intro z hz + obtain ⟨x,hx,rfl⟩ := (hf z).mp hz + exact ⟨x,hx,_,second_mem_doubleUnion hz,rfl⟩ + · intro x hx + have hp := (hpair x _).mpr ⟨hx,rfl⟩ + exact ⟨_,second_mem_doubleUnion hp,hp,fun v _ hv => (hpair x v).mp hv |>.2⟩ + · intro x hx v _ hv + have he := (hpair x v).mp hv |>.2 + subst v + have hA := omegaStageImage d f x hd hx hf + refine ⟨(Ordinal.omega0 ^ x.rank).toZFSet, + hA ▸ stageImage_mem M hM hT h1 (hM d hdM x hx) hfM,?_,ZFSet.isOrdinal_toZFSet _,?_⟩ + · refine ⟨?_,?_,?_⟩ + · intro z hz; exact (omegaPower_members x.rank z).mpr (Or.inl hz) + · intro z hz + rcases (omegaPower_members x.rank z).mp hz with hz|⟨y,hy,hz⟩ + · exact Or.inl hz + · rw [(hd.mem hx).toZFSet_rank_eq] at hy + have hp := (hpair y _).mpr ⟨hd.subset_of_mem hx hy,rfl⟩ + exact Or.inr ⟨y,hy,_,second_mem_doubleUnion hp,hp,hz⟩ + · intro y hy w _ hw z hz + rw [(hpair y w).mp hw |>.2] at hz + exact (omegaPower_members x.rank z).mpr + (Or.inr ⟨y,(hd.mem hx).toZFSet_rank_eq.symm ▸ hy,hz⟩) + · rw [omegaNext,Ordinal.opow_add_one,Ordinal.rank_toZFSet] + +theorem mulOmega_sigmaDefinable (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + SigmaDefinable M (fun e => (e 1).IsOrdinal ∧ e 0 = ((e 1).rank*Ordinal.omega0).toZFSet) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + have ho := omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity + let p := SigmaFormula.conj (.bounded (ordinalFormula 2)) + (productSigma.rename (fun i => if i = 0 then 0 else if i = 1 then 2 else 1)) + refine ⟨p,fun _ => ZFSet.omega,fun _ => ho,?_⟩ + intro e he + rw [SigmaFormula.realize_conj] + have hoSem : (SigmaFormula.bounded (ordinalFormula 2)).Realize M + (mix e (fun _ => ZFSet.omega)) ↔ (e 1).IsOrdinal := by + rw [SigmaFormula.Realize,Formula.absolute _ M hM _ (by + intro i; unfold mix; split; exact he _; exact ho),eval_ordinalFormula] + rfl + rw [hoSem] + apply and_congr_right; intro heo + rw [SigmaFormula.realize_rename] + exact productSigma_sourceT M hM hT _ (by + intro i; change mix e (fun _ => ZFSet.omega) + (if i = 0 then 0 else if i = 1 then 2 else 1) ∈ M + split; exact he 0 + split; exact he 1 + exact ho) (e 1).rank Ordinal.omega0 heo.toZFSet_rank_eq.symm toZFSet_omega.symm + +theorem omegaGraph_sigmaDefinable (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (d r f : ℕ) : SigmaDefinable M (fun e => OmegaGraph M (e d) (e r) (e f)) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + have h1 : (1 : Ordinal.{u}).toZFSet ∈ M := by + rw [← Nat.cast_one,toZFSet_nat] + exact C.nat_mem 1 + have hs : SigmaDefinable M (fun e => + StageStep (1 : Ordinal.{u}).toZFSet (e (f+3)) (e (r+3)) (e 2) (e 0)) := by + have hb := (stageStep_definable C 0 (f+4) (r+4) 3 1).toSigma hM + have hc := ((equal_param h1 0).toSigma hM).and hb + exact hc.existsSet.congr (fun e _ => by simp [h1]) + have hv : SigmaDefinable M (fun e => (e 0).IsOrdinal ∧ + e 1 = ((e 0).rank*Ordinal.omega0).toZFSet) := + (mulOmega_sigmaDefinable M hM hT).subst (fun i => if i = 0 then 1 else 0) + have hi := SigmaDefinable.impBounded C (defPairMem C 1 0 (f+2)) (hs.and hv).existsSet + exact ((ordinal_definable C d).toSigma hM).and + (((functionGraph_definable C d r f).toSigma hM).and + ((hi.allMem hM hT (r+1)).allMem hM hT d)) + +theorem uniform_omega_certificate (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ∃ p : SigmaFormula, ∃ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ M) ∧ + ∀ x ∈ M, ∀ f ∈ M, p.Realize M (cons f (cons x e)) ↔ + ∃ r ∈ M, OmegaGraph M (insert x x) r f := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + have hd : Definable M (fun e => e 0 = insert (e 3) (e 3)) := by + refine ⟨.successor 0 6,fun _ => ZFSet.omega,fun _ => C.omega_mem,?_⟩ + intro e; simp [Formula.eval_successor,mix] + have hg := (hd.toSigma hM).and (omegaGraph_sigmaDefinable M hM hT 0 1 2) + obtain ⟨p,e,he,hp⟩ := sigma_binary_relation (fun x f => ∃ r ∈ M, + ∃ d ∈ M, d = insert x x ∧ OmegaGraph M d r f) hg.existsSet.existsSet + refine ⟨p,e,he,?_⟩ + intro x hx f hf + rw [hp x hx f hf] + constructor + · rintro ⟨r,hr,d,_,rfl,h⟩; exact ⟨r,hr,h⟩ + · rintro ⟨r,hr,h⟩ + exact ⟨r,hr,insert x x,insert_self_mem M hM hT.pairing hT.union hx,rfl,h⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerStage.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerStage.lean new file mode 100644 index 0000000000000000000000000000000000000000..9968b7a59e6d89ef28e092938361583a0ab41b6c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerStage.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalProductReplacement +import OAI.Computability.DegreeRigidity.Constructibility.HierarchySyntax + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open BoundedDefinability SetModelFunctions +universe u + +noncomputable def omegaNext (x : ZFSet.{u}) : ZFSet.{u} := + (Ordinal.omega0 ^ (x.rank+1)).toZFSet + +theorem omegaPower_members (a : Ordinal.{u}) (z : ZFSet.{u}) : + z ∈ (Ordinal.omega0 ^ a).toZFSet ↔ z ∈ (1 : Ordinal.{u}).toZFSet ∨ + ∃ x ∈ a.toZFSet, z ∈ omegaNext x := by + constructor + · intro hz + by_cases ha : a = 0 + · left; simpa [ha] using hz + · obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hz + obtain ⟨b,hb,n,hn⟩ := (Ordinal.lt_omega0_opow ha).mp hc + refine Or.inr ⟨b.toZFSet,Ordinal.toZFSet_mem_toZFSet_iff.mpr hb,?_⟩ + rw [omegaNext,Ordinal.rank_toZFSet,Ordinal.toZFSet_mem_toZFSet_iff] + exact hn.trans (Ordinal.opow_mul_lt_opow (Ordinal.natCast_lt_omega0 n) (lt_add_one b)) + · rintro (hz|⟨x,hx,hz⟩) + · exact Ordinal.toZFSet_monotone (Order.one_le_iff_ne_zero.mpr (Ordinal.opow_ne_zero _ Ordinal.omega0_ne_zero)) hz + · obtain ⟨b,hb,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + change z ∈ (Ordinal.omega0 ^ (b.toZFSet.rank+1)).toZFSet at hz + rw [Ordinal.rank_toZFSet] at hz + exact Ordinal.toZFSet_monotone + (Ordinal.opow_le_opow_right Ordinal.omega0_pos (Order.succ_le_of_lt hb)) hz + +def OmegaGraph (M d r f : ZFSet.{u}) : Prop := + d.IsOrdinal ∧ FunctionGraph d r f ∧ + ∀ x ∈ d, ∀ v ∈ r, ZFSet.pair x v ∈ f → + ∃ A ∈ M, StageStep (1 : Ordinal.{u}).toZFSet f r x A ∧ + A.IsOrdinal ∧ v = (A.rank*Ordinal.omega0).toZFSet + +theorem OmegaGraph.correct {M d r f : ZFSet.{u}} (h : OmegaGraph M d r f) + (x : ZFSet.{u}) (hx : x ∈ d) (v : ZFSet.{u}) (hv : v ∈ r) + (hfv : ZFSet.pair x v ∈ f) : v = omegaNext x := by + induction x using ZFSet.inductionOn generalizing v with + | h x ih => + obtain ⟨A,_,hs,_,rfl⟩ := h.2.2 x hx v hv hfv + have hxo := h.1.mem hx + have he : A = (Ordinal.omega0 ^ x.rank).toZFSet := by + apply ZFSet.ext; intro z + rw [omegaPower_members,hxo.toZFSet_rank_eq] + constructor + · intro hz + rcases hs.2.1 z hz with hz|⟨y,hy,w,hw,hfw,hz⟩ + · exact Or.inl hz + · exact Or.inr ⟨y,hy,(ih y hy (h.1.subset_of_mem hx hy) w hw hfw) ▸ hz⟩ + · rintro (hz|⟨y,hy,hz⟩) + · exact hs.1 hz + · obtain ⟨w,hw,hfw,_⟩ := h.2.1.2 y (h.1.subset_of_mem hx hy) + rw [← ih y hy (h.1.subset_of_mem hx hy) w hw hfw] at hz + exact hs.2.2 y hy w hw hfw hz + rw [he,Ordinal.rank_toZFSet,omegaNext,Ordinal.opow_add_one] + +theorem OmegaGraph.mem_iff {M d r f : ZFSet.{u}} (h : OmegaGraph M d r f) (z : ZFSet.{u}) : + z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (omegaNext x) := by + constructor + · intro hz + obtain ⟨x,hx,v,hv,rfl⟩ := h.2.1.1 z hz + exact ⟨x,hx,by rw [h.correct x hx v hv hz]⟩ + · rintro ⟨x,hx,rfl⟩ + obtain ⟨v,hv,hfv,_⟩ := h.2.1.2 x hx + rw [← h.correct x hx v hv hfv] + exact hfv + +theorem OmegaGraph.unique {M N d r t f g : ZFSet.{u}} + (hf : OmegaGraph M d r f) (hg : OmegaGraph N d t g) : f = g := by + apply ZFSet.ext; intro z + exact (hf.mem_iff z).trans (hg.mem_iff z).symm + +theorem omegaStageImage (d f x : ZFSet.{u}) (hd : d.IsOrdinal) (hx : x ∈ d) + (hf : ∀ z, z ∈ f ↔ ∃ y ∈ d, z = ZFSet.pair y (omegaNext y)) : + stageImage (1 : Ordinal.{u}).toZFSet x f = (Ordinal.omega0 ^ x.rank).toZFSet := by + apply ZFSet.ext; intro z + rw [mem_stageImage,omegaPower_members,(hd.mem hx).toZFSet_rank_eq] + apply or_congr_right + constructor + · rintro ⟨y,hy,w,hfw,hz⟩ + obtain ⟨v,_,hp⟩ := (hf _).mp hfw + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact ⟨y,hy,hz⟩ + · rintro ⟨y,hy,hz⟩ + exact ⟨y,hy,_,(hf _).mpr ⟨y,hd.subset_of_mem hx hy,rfl⟩,hz⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..79b293621f896bed69c5dd30631889da09227c38 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaPowerSyntax.lean @@ -0,0 +1,112 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaGraphSyntax +import OAI.Computability.DegreeRigidity.OrdinalCodes.CanonicalOmegaSyntax +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaGraphRestriction + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +def ordinalOneMatrix (s : ℕ) : Formula := + .conj (.allMem s (.empty 0)) (.existsMem s (.empty 0)) + +theorem ordinalOneMatrix_eval (s : ℕ) (e : ℕ → ZFSet.{u}) : + (ordinalOneMatrix s).Eval e ↔ e s = (1 : Ordinal.{u}).toZFSet := by + have hone : (1 : Ordinal.{u}).toZFSet = ({∅} : ZFSet.{u}) := by + rw [← Nat.cast_one,toZFSet_nat]; rfl + rw [hone] + simp only [ordinalOneMatrix,Formula.Eval,Formula.eval_allMem,Formula.eval_empty,cons_zero] + constructor + · rintro ⟨hall,x,hx,rfl⟩ + apply ZFSet.ext; intro z + simp only [ZFSet.mem_singleton] + exact ⟨hall z,fun h => h.symm ▸ hx⟩ + · intro he + rw [he] + exact ⟨fun z hz => ZFSet.mem_singleton.mp hz,∅,ZFSet.mem_singleton.mpr rfl,rfl⟩ + +noncomputable def omegaPowerBody : SentenceForm := + .conj (canonicalOmega 4) + (.conj (fromBounded (.conj (ordinalOneMatrix 3) (.equal 0 6))) + (.conj (omegaGraphSentence 3 4 0 1 2) + (fromBounded (omegaStageMatrix 3 2 1 6 5)))) + +noncomputable def omegaPowerSentence : SentenceForm := + .ex (.ex (.ex (.ex (.ex omegaPowerBody)))) + +theorem omegaPowerSentence_bound : omegaPowerSentence.bound = 2 := by rfl + +theorem omegaPowerBody_semantics (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + omegaPowerBody.Sat (M : Set ZFSet) e ↔ + e 4 = ZFSet.omega ∧ e 3 = (1 : Ordinal.{u}).toZFSet ∧ + e 0 = e 6 ∧ + (omegaGraphSentence 3 4 0 1 2).Sat (M : Set ZFSet) e ∧ + StageStep (e 3) (e 2) (e 1) (e 6) (e 5) := by + change ((canonicalOmega 4).Sat _ e ∧ (fromBounded _).Sat _ e ∧ + (omegaGraphSentence 3 4 0 1 2).Sat _ e ∧ (fromBounded _).Sat _ e) ↔ _ + rw [canonicalOmega_spec M hM hω 4 e he,bounded_sat, + Formula.absolute _ M hM e he,Formula.Eval,ordinalOneMatrix_eval, + Formula.Eval,bounded_sat,Formula.absolute _ M hM e he,omegaStageMatrix_eval] + tauto + +theorem omegaPowerSentence_semantics (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + omegaPowerSentence.Sat (M : Set ZFSet) e ↔ + ∃ w ∈ M, ∃ s ∈ M, ∃ f ∈ M, ∃ r ∈ M, ∃ d ∈ M, + w = ZFSet.omega ∧ s = (1 : Ordinal.{u}).toZFSet ∧ d = e 1 ∧ + (omegaGraphSentence 3 4 0 1 2).Sat (M : Set ZFSet) + (cons d (cons r (cons f (cons s (cons w e))))) ∧ + StageStep s f r (e 1) (e 0) := by + change (∃ w ∈ M, ∃ s ∈ M, ∃ f ∈ M, ∃ r ∈ M, ∃ d ∈ M, + omegaPowerBody.Sat _ _) ↔ _ + apply exists_congr; intro w + apply and_congr_right; intro hw + apply exists_congr; intro s + apply and_congr_right; intro hs + apply exists_congr; intro f + apply and_congr_right; intro hf + apply exists_congr; intro r + apply and_congr_right; intro hr + apply exists_congr; intro d + apply and_congr_right; intro hd + exact omegaPowerBody_semantics M hM hω _ (by + intro i; rcases i with _|_|_|_|_|i + exact hd; exact hr; exact hf; exact hs; exact hw; exact he i) + +theorem omegaPowerSentence_sound (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + omegaPowerSentence.Sat (M : Set ZFSet) e → + (e 1).IsOrdinal ∧ e 0 = (Ordinal.omega0 ^ (e 1).rank).toZFSet := by + rw [omegaPowerSentence_semantics M hM hω e he] + rintro ⟨w,hw,s,hs,f,hf,r,hr,d,hd,hew,hes,hed,hg,hst⟩ + have hgraph := omegaGraphSentence_sound M hM 3 4 0 1 2 _ (by + intro i; rcases i with _|_|_|_|_|i + exact hd; exact hr; exact hf; exact hs; exact hw; exact he i) hes hew hg + change OmegaGraph M d r f at hgraph + rw [hed] at hgraph + exact ⟨hgraph.1,omegaStageStep_domain_exact hgraph (hes ▸ hst)⟩ + +theorem omegaPowerSentence_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + omegaPowerSentence.Sat (M : Set ZFSet) e ↔ + (e 1).IsOrdinal ∧ e 0 = (Ordinal.omega0 ^ (e 1).rank).toZFSet := by + have hω := omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity + refine ⟨omegaPowerSentence_sound M hM hω e he,?_⟩ + rintro ⟨ho,hy⟩ + obtain ⟨f,hf,hg⟩ := internal_omegaGraph_below M hM hT (e 1) (he 1) ho + have hs : (1 : Ordinal.{u}).toZFSet ∈ M := by + rw [← Nat.cast_one,toZFSet_nat] + exact hM _ hω _ ((mem_omega _).mpr ⟨1,rfl⟩) + have hr := iterUnion_mem M hM hT.union hf 2 + have hst := omegaStageStep_domain M (e 1) (iterUnion 2 f) f hg + apply (omegaPowerSentence_semantics M hM hω e he).mpr + refine ⟨_,hω,_,hs,f,hf,_,hr,e 1,he 1,rfl,rfl,rfl,?_,hy.symm ▸ hst⟩ + exact (omegaGraphSentence_sourceT M hM hT 3 4 0 1 2 _ (by + intro i; rcases i with _|_|_|_|_|i + exact he 1; exact hr; exact hf; exact hs; exact hω; exact he i) rfl rfl).mpr hg + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaRecursionSchemas.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaRecursionSchemas.lean new file mode 100644 index 0000000000000000000000000000000000000000..438ecb2ead675e81e7c144eabc2313a19e4939ef --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaRecursionSchemas.lean @@ -0,0 +1,128 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaPowerGraph +import OAI.Computability.DegreeRigidity.Constructibility.ContextHierarchyGraph +import OAI.Computability.DegreeRigidity.Syntax.SigmaCollectionClosure + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open BoundedDefinability SetModelFunctions SentenceCoding +universe u + +theorem productSigma_context (M : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (a b : Ordinal.{u}) + (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) : + productSigma.Realize M e ↔ e 0 = (a*b).toZFSet := by + rw [← sigma_sat,productSigma_sentence] + have haM : a.toZFSet ∈ M := ha ▸ he 1 + have hbM : b.toZFSet ∈ M := hb ▸ he 2 + obtain ⟨_,f,hf,hc⟩ := ordinal_mul_internal_schemas M C.transitive C.pairing C.union + C.power C.separation hRep a b haM hbM + exact productSentence_spec_of_certificate M C.transitive e he a b ha hb + (product_mem M C.transitive C.pairing C.union C.power C.separation hbM haM) + (productRelation_mem M _ _ C.transitive C.pairing C.union C.power C.separation haM hbM) + ⟨f,hf,hc⟩ + +theorem omegaGraph_of_mem_iff_context (M d f : ZFSet.{u}) (C : Context M) + (hdM : d ∈ M) (hfM : f ∈ M) (hd : d.IsOrdinal) + (hf : ∀ z, z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (omegaNext x)) : + OmegaGraph M d (iterUnion 2 f) f := by + have h1 : (1 : Ordinal.{u}).toZFSet ∈ M := by + rw [← Nat.cast_one,toZFSet_nat] + exact C.transitive _ (omega_mem M C.transitive C.separation C.infinity) _ ((mem_omega _).mpr ⟨1,rfl⟩) + have hpair (x v : ZFSet.{u}) : ZFSet.pair x v ∈ f ↔ x ∈ d ∧ v = omegaNext x := by + rw [hf] + constructor + · rintro ⟨y,hy,he⟩ + obtain ⟨rfl,hv⟩ := ZFSet.pair_inj.mp he + exact ⟨hy,hv⟩ + · rintro ⟨hx,rfl⟩; exact ⟨x,hx,rfl⟩ + refine ⟨hd,⟨?_,?_⟩,?_⟩ + · intro z hz + obtain ⟨x,hx,rfl⟩ := (hf z).mp hz + exact ⟨x,hx,_,second_mem_doubleUnion hz,rfl⟩ + · intro x hx + have hp := (hpair x _).mpr ⟨hx,rfl⟩ + exact ⟨_,second_mem_doubleUnion hp,hp,fun v _ hv => (hpair x v).mp hv |>.2⟩ + · intro x hx v _ hv + have he := (hpair x v).mp hv |>.2 + subst v + have hA := omegaStageImage d f x hd hx hf + refine ⟨(Ordinal.omega0 ^ x.rank).toZFSet, + hA ▸ stageImage_mem_context M C h1 (C.transitive d hdM x hx) hfM,?_,ZFSet.isOrdinal_toZFSet _,?_⟩ + · refine ⟨?_,?_,?_⟩ + · intro z hz; exact (omegaPower_members x.rank z).mpr (Or.inl hz) + · intro z hz + rcases (omegaPower_members x.rank z).mp hz with hz|⟨y,hy,hz⟩ + · exact Or.inl hz + · rw [(hd.mem hx).toZFSet_rank_eq] at hy + have hp := (hpair y _).mpr ⟨hd.subset_of_mem hx hy,rfl⟩ + exact Or.inr ⟨y,hy,_,second_mem_doubleUnion hp,hp,hz⟩ + · intro y hy w _ hw z hz + rw [(hpair y w).mp hw |>.2] at hz + exact (omegaPower_members x.rank z).mpr + (Or.inr ⟨y,(hd.mem hx).toZFSet_rank_eq.symm ▸ hy,hz⟩) + · rw [omegaNext,Ordinal.opow_add_one,Ordinal.rank_toZFSet] + +theorem mulOmega_sigmaDefinable_schemas (M : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) : + SigmaDefinable M (fun e => (e 1).IsOrdinal ∧ e 0 = ((e 1).rank*Ordinal.omega0).toZFSet) := by + have ho := omega_mem M C.transitive C.separation C.infinity + let p := SigmaFormula.conj (.bounded (ordinalFormula 2)) + (productSigma.rename (fun i => if i = 0 then 0 else if i = 1 then 2 else 1)) + refine ⟨p,fun _ => ZFSet.omega,fun _ => ho,?_⟩ + intro e he + rw [SigmaFormula.realize_conj] + have hoSem : (SigmaFormula.bounded (ordinalFormula 2)).Realize M + (mix e (fun _ => ZFSet.omega)) ↔ (e 1).IsOrdinal := by + rw [SigmaFormula.Realize,Formula.absolute _ M C.transitive _ (by + intro i; unfold mix; split; exact he _; exact ho),eval_ordinalFormula] + rfl + rw [hoSem] + apply and_congr_right; intro heo + rw [SigmaFormula.realize_rename] + exact productSigma_context M C hRep _ (by + intro i; change mix e (fun _ => ZFSet.omega) + (if i = 0 then 0 else if i = 1 then 2 else 1) ∈ M + split; exact he 0 + split; exact he 1 + exact ho) (e 1).rank Ordinal.omega0 heo.toZFSet_rank_eq.symm toZFSet_omega.symm + +theorem omegaGraph_sigmaDefinable_schemas (M : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) (hColl : SigmaCollection M) + (d r f : ℕ) : SigmaDefinable M (fun e => OmegaGraph M (e d) (e r) (e f)) := by + have h1 : (1 : Ordinal.{u}).toZFSet ∈ M := by + rw [← Nat.cast_one,toZFSet_nat] + exact C.nat_mem 1 + have hs : SigmaDefinable M (fun e => + StageStep (1 : Ordinal.{u}).toZFSet (e (f+3)) (e (r+3)) (e 2) (e 0)) := by + have hb := (stageStep_definable C 0 (f+4) (r+4) 3 1).toSigma C.transitive + have hc := ((equal_param h1 0).toSigma C.transitive).and hb + exact hc.existsSet.congr (fun e _ => by simp [h1]) + have hv : SigmaDefinable M (fun e => (e 0).IsOrdinal ∧ + e 1 = ((e 0).rank*Ordinal.omega0).toZFSet) := + (mulOmega_sigmaDefinable_schemas M C hRep).subst (fun i => if i = 0 then 1 else 0) + have hi := SigmaDefinable.impBounded C (defPairMem C 1 0 (f+2)) (hs.and hv).existsSet + exact ((ordinal_definable C d).toSigma C.transitive).and + (((functionGraph_definable C d r f).toSigma C.transitive).and + ((hi.allMem_collection C hRep hColl (r+1)).allMem_collection C hRep hColl d)) + +theorem uniform_omega_certificate_schemas (M : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) (hColl : SigmaCollection M) : + ∃ p : SigmaFormula, ∃ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ M) ∧ + ∀ x ∈ M, ∀ f ∈ M, p.Realize M (cons f (cons x e)) ↔ + ∃ r ∈ M, OmegaGraph M (insert x x) r f := by + have hd : Definable M (fun e => e 0 = insert (e 3) (e 3)) := by + refine ⟨.successor 0 6,fun _ => ZFSet.omega,fun _ => C.omega_mem,?_⟩ + intro e; simp [Formula.eval_successor,mix] + have hg := (hd.toSigma C.transitive).and (omegaGraph_sigmaDefinable_schemas M C hRep hColl 0 1 2) + obtain ⟨p,e,he,hp⟩ := sigma_binary_relation (fun x f => ∃ r ∈ M, + ∃ d ∈ M, d = insert x x ∧ OmegaGraph M d r f) hg.existsSet.existsSet + refine ⟨p,e,he,?_⟩ + intro x hx f hf + rw [hp x hx f hf] + constructor + · rintro ⟨r,hr,d,_,rfl,h⟩; exact ⟨r,hr,h⟩ + · rintro ⟨r,hr,h⟩ + exact ⟨r,hr,insert x x,insert_self_mem M C.transitive C.pairing C.union hx,rfl,h⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaStageSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaStageSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..d38b396511c3477729267eb43ca782817e800623 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OmegaStageSyntax.lean @@ -0,0 +1,56 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaPowerDefinability + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +def omegaStageMatrix (s f r x A : ℕ) : Formula := + .conj (.subset s A) + (.conj (.allMem A (.disj (.member 0 (s+1)) + (.existsMem (x+1) (.existsMem (r+2) + (.conj (.pairMem 1 0 (f+3)) (.member 2 0)))))) + (.allMem x (.allMem (r+1) + (.imp (.pairMem 1 0 (f+2)) (.subset 0 (A+2)))))) + +theorem omegaStageMatrix_eval (s f r x A : ℕ) (e : ℕ → ZFSet.{u}) : + (omegaStageMatrix s f r x A).Eval e ↔ StageStep (e s) (e f) (e r) (e x) (e A) := by + simp only [omegaStageMatrix,Formula.Eval,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_disj,Formula.eval_pairMem,Formula.eval_imp,cons_zero,cons_succ,StageStep] + +def ordinalAllMem (i : ℕ) (p : SentenceForm) : SentenceForm := + .all (.imp (.member 0 (i+1)) p) + +theorem ordinalAllMem_sat (M : ZFSet.{u}) (hM : Transitive M) + (i : ℕ) (p : SentenceForm) (e : ℕ → ZFSet.{u}) (hi : e i ∈ M) : + (ordinalAllMem i p).Sat (M : Set ZFSet) e ↔ + ∀ x ∈ e i, p.Sat (M : Set ZFSet) (cons x e) := by + simp only [ordinalAllMem,SentenceForm.sat_all,SentenceForm.sat_imp, + SentenceForm.Sat,cons_zero,cons_succ] + exact ⟨fun h x hx => h x (hM _ hi x hx) hx,fun h x _ hx => h x hx⟩ + +noncomputable def ordinalProductAt (v a b : ℕ) : SentenceForm := + productSentence.rename (fun i => if i = 0 then v else if i = 1 then a else b) + +theorem ordinalProductAt_sound (M : ZFSet.{u}) (hM : Transitive M) + (v a b : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (ha : (e a).IsOrdinal) (hb : (e b).IsOrdinal) : + (ordinalProductAt v a b).Sat (M : Set ZFSet) e → + e v = ((e a).rank * (e b).rank).toZFSet := by + rw [ordinalProductAt,SentenceForm.sat_rename] + exact productSentence_sound M hM _ (fun i => he _) _ _ + ha.toZFSet_rank_eq.symm hb.toZFSet_rank_eq.symm + +theorem ordinalProductAt_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (v a b : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (ha : (e a).IsOrdinal) (hb : (e b).IsOrdinal) : + (ordinalProductAt v a b).Sat (M : Set ZFSet) e ↔ + e v = ((e a).rank * (e b).rank).toZFSet := by + rw [ordinalProductAt,SentenceForm.sat_rename] + exact productSentence_sourceT M hM hT _ (fun i => he _) _ _ + ha.toZFSet_rank_eq.symm hb.toZFSet_rank_eq.symm + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalCodeBranch.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalCodeBranch.lean new file mode 100644 index 0000000000000000000000000000000000000000..30eacd44ecc44629138d0f95f32623cbdbadec9d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalCodeBranch.lean @@ -0,0 +1,132 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalCodeOperations + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem code_rename_bound (p : SentenceForm) (r : ℕ → ℕ) (n : ℕ) + (h : ∀ i, i < p.bound → r i < n) : (p.rename r).bound ≤ n := by + induction p generalizing r n with + | equal i j => + have hi := h i (by simp [SentenceForm.bound]) + have hj := h j (by simp [SentenceForm.bound]) + simp only [SentenceForm.rename,SentenceForm.bound]; omega + | member i j => + have hi := h i (by simp [SentenceForm.bound]) + have hj := h j (by simp [SentenceForm.bound]) + simp only [SentenceForm.rename,SentenceForm.bound]; omega + | conj p q ihp ihq => + exact max_le (ihp r n (fun i hi => h i (by change i < max p.bound q.bound; omega))) + (ihq r n (fun i hi => h i (by change i < max p.bound q.bound; omega))) + | neg p ih => exact ih r n h + | ex p ih => + have ht := ih (fun i => match i with | 0 => 0 | j+1 => r j+1) (n+1) (by + intro i hi + cases i with + | zero => simp + | succ i => have hh := h i (by change i < p.bound-1; omega); simp; omega) + exact (Nat.sub_le_sub_right ht 1).trans (by omega) + +noncomputable def codeBranchValue (twice : Bool) (a b : Ordinal.{u}) : Ordinal.{u} := + codeScale twice (Ordinal.omega0 ^ (a+1)) + Ordinal.omega0 ^ b + +noncomputable def codeBranchBody (twice : Bool) : SentenceForm := + .conj (fromBounded (.successor 3 5)) + (.conj (codePowerAt 2 3) (.conj (codePowerAt 1 6) + (.conj (codeScaleAt twice 0 2) (codeSumAt 4 0 1)))) + +noncomputable def codeBranchSentence (twice : Bool) : SentenceForm := + .ex (.ex (.ex (.ex (codeBranchBody twice)))) + +theorem codeBranchSentence_bound (twice : Bool) : (codeBranchSentence twice).bound = 3 := by + have hfirst : (fromBounded (.successor 3 5)).bound = 6 := by rfl + have hleft : (codePowerAt 2 3).bound ≤ 7 := + code_rename_bound omegaPowerSentence _ 7 (by intro i _; split <;> omega) + have hright : (codePowerAt 1 6).bound ≤ 7 := + code_rename_bound omegaPowerSentence _ 7 (by intro i _; split <;> omega) + have hright_lower : 7 ≤ (codePowerAt 1 6).bound := by + have lower (p q r : SentenceForm) : + 7 ≤ ((SentenceForm.ex (.ex (.ex (.ex (.ex + (.conj p (.conj (.conj q (.equal 0 6)) r))))))).rename + (fun i => if i = 0 then 1 else 6)).bound := by + simp [SentenceForm.rename, SentenceForm.bound] + omega + exact lower (canonicalOmega 4) (fromBounded (ordinalOneMatrix 3)) + (.conj (omegaGraphSentence 3 4 0 1 2) (fromBounded (omegaStageMatrix 3 2 1 6 5))) + have hright_eq := Nat.le_antisymm hright hright_lower + have hscale : (codeScaleAt twice 0 2).bound ≤ 7 := by + cases twice with + | false => decide + | true => exact code_rename_bound doubleSentence _ 7 (by intro i _; split <;> omega) + have hsum : (codeSumAt 4 0 1).bound ≤ 7 := + code_rename_bound sumSentence _ 7 (by intro i _; split <;> (try split) <;> omega) + have finish (a b c : ℕ) (ha : a ≤ 7) (hb : b ≤ 7) (hc : c ≤ 7) : + max 6 (max a (max 7 (max b c))) - 1 - 1 - 1 - 1 = 3 := by omega + change max (fromBounded (.successor 3 5)).bound + (max (codePowerAt 2 3).bound (max (codePowerAt 1 6).bound + (max (codeScaleAt twice 0 2).bound (codeSumAt 4 0 1).bound))) - 1 - 1 - 1 - 1 = 3 + rw [hfirst, hright_eq] + exact finish _ _ _ hleft hscale hsum + +theorem codeBranchBody_sound (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (twice : Bool) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (a b : Ordinal.{u}) (ha : e 5 = a.toZFSet) (hb : e 6 = b.toZFSet) : + (codeBranchBody twice).Sat (M : Set ZFSet) e → e 4 = (codeBranchValue twice a b).toZFSet := by + intro h + obtain ⟨hk,hu,hv,ht,hc⟩ := h + have hks : e 3 = (a+1).toZFSet := by + rw [bounded_sat,Formula.absolute _ M hM e he,Formula.eval_successor,ha] at hk + simpa only [Ordinal.toZFSet_add_one] using hk + have hus := (codePowerAt_sound M hM hω 2 3 e he hu).2 + rw [hks,Ordinal.rank_toZFSet] at hus + have hvs := (codePowerAt_sound M hM hω 1 6 e he hv).2 + rw [hb,Ordinal.rank_toZFSet] at hvs + have hts := codeScaleAt_sound M hM twice 0 2 e he _ hus ht + exact codeSumAt_sound M hM 4 0 1 e he _ _ hts hvs hc + +theorem codeBranchSentence_sound (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (twice : Bool) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (a b : Ordinal.{u}) (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) : + (codeBranchSentence twice).Sat (M : Set ZFSet) e → e 0 = (codeBranchValue twice a b).toZFSet := by + rintro ⟨k,hk,u,hu,v,hv,t,ht,h⟩ + exact codeBranchBody_sound M hM hω twice _ (by + intro i; rcases i with _|_|_|_|i + exact ht; exact hv; exact hu; exact hk; exact he i) a b ha hb h + +theorem codeBranchSentence_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (twice : Bool) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (a b : Ordinal.{u}) (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) : + (codeBranchSentence twice).Sat (M : Set ZFSet) e ↔ e 0 = (codeBranchValue twice a b).toZFSet := by + have hω := omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity + refine ⟨codeBranchSentence_sound M hM hω twice e he a b ha hb,?_⟩ + intro hc + let k := (a+1).toZFSet + let u := (Ordinal.omega0 ^ (a+1)).toZFSet + let v := (Ordinal.omega0 ^ b).toZFSet + let t := (codeScale twice (Ordinal.omega0 ^ (a+1))).toZFSet + have hk : k ∈ M := internal_ordinal_succ M hM hT a (ha ▸ he 1) + have hu : u ∈ M := ordinal_omega_opow_internal M hM hT (a+1) hk + have hv : v ∈ M := ordinal_omega_opow_internal M hM hT b (hb ▸ he 2) + have ht : t ∈ M := codeScale_internal M hM hT twice _ hu + let E := cons t (cons v (cons u (cons k e))) + have hE : ∀ i, E i ∈ M := by + intro i; rcases i with _|_|_|_|i + exact ht; exact hv; exact hu; exact hk; exact he i + refine ⟨k,hk,u,hu,v,hv,t,ht,?_,?_,?_,?_,?_⟩ + · rw [bounded_sat,Formula.absolute _ M hM E hE,Formula.eval_successor] + change k = insert (e 1) (e 1) + rw [ha,← Ordinal.toZFSet_add_one] + · apply (codePowerAt_sourceT M hM hT 2 3 E hE).mpr + exact ⟨ZFSet.isOrdinal_toZFSet _,by change u = (Ordinal.omega0 ^ k.rank).toZFSet; simp [u,k]⟩ + · apply (codePowerAt_sourceT M hM hT 1 6 E hE).mpr + change (e 2).IsOrdinal ∧ v = (Ordinal.omega0 ^ (e 2).rank).toZFSet + rw [hb,Ordinal.rank_toZFSet] + exact ⟨ZFSet.isOrdinal_toZFSet _,rfl⟩ + · exact (codeScaleAt_sourceT M hM hT twice 0 2 E hE _ rfl).mpr rfl + · exact (codeSumAt_sourceT M hM hT 4 0 1 E hE _ _ rfl rfl).mpr hc + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalCodeDomains.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalCodeDomains.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab7e373f26c864ed7447d3d45c62e4e4284c51ea --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalCodeDomains.lean @@ -0,0 +1,51 @@ +import OAI.Computability.DegreeRigidity.SetModels.FiniteOrdinalCode +import OAI.Computability.DegreeRigidity.Constructibility.UniformHeightDomains + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory ElementaryModel RelativeConstructible +universe u + +theorem paddedCode_entries_mem (A : ZFSet.{u}) (hA : Transitive A) + {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (ha : (paddedCode v β).toZFSet ∈ A) (i : Fin n) : (v i).toZFSet ∈ A := + hA _ ha _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr (entry_lt_paddedCode v β i)) + +theorem paddedCode_padding_mem (A : ZFSet.{u}) (hA : Transitive A) + {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (ha : (paddedCode v β).toZFSet ∈ A) : β.toZFSet ∈ A := + hA _ ha _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr (padding_lt_paddedCode v β)) + +theorem paddedCode_body_mem (A : ZFSet.{u}) (hA : Transitive A) + {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (ha : (paddedCode v β).toZFSet ∈ A) : (vectorCode v).toZFSet ∈ A := + hA _ ha _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr (right_lt_pairCode _ _)) + +theorem padded_height_domain (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hβ : realSeedOffset ≤ β) : + let a := paddedCode v β + a.toZFSet ∈ level (groundReals M) (heightDomainIndex a) ∧ + (∀ i, (v i).toZFSet ∈ level (groundReals M) (heightDomainIndex a)) ∧ + β.toZFSet ∈ level (groundReals M) (heightDomainIndex a) ∧ + (vectorCode v).toZFSet ∈ level (groundReals M) (heightDomainIndex a) ∧ + paddedDecode n a = v ∧ + (∀ e : ℕ → ZFSet.{u}, e 0 ∈ level (groundReals M) (heightDomainIndex a) → + (largestOrdinalSentence.Sat (level (groundReals M) (heightDomainIndex a) : Set ZFSet) e ↔ + e 0 = a.toZFSet)) := by + have hm := largestOrdinal_ground_domain M hM hT (paddedCode v β) + (hβ.trans (padding_lt_paddedCode v β).le) + exact ⟨hm.1,paddedCode_entries_mem _ (level_transitive _ _) v β hm.1, + paddedCode_padding_mem _ (level_transitive _ _) v β hm.1, + paddedCode_body_mem _ (level_transitive _ _) v β hm.1,paddedDecode_paddedCode v β,hm.2⟩ + +theorem padded_height_index_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (ha : (paddedCode v β).toZFSet ∈ M) : + (heightDomainIndex (paddedCode v β)).toZFSet ∈ M := + heightDomainIndex_internal M hM hT _ ha + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalCodeOperations.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalCodeOperations.lean new file mode 100644 index 0000000000000000000000000000000000000000..b70f97f37eaa1c5c386c4cfa7fb34bbc5bcc960e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalCodeOperations.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaPowerSyntax +import OAI.Computability.DegreeRigidity.SetModels.InternalOrdinalCodes + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +noncomputable def codePowerAt (y x : ℕ) : SentenceForm := + omegaPowerSentence.rename (fun i => if i = 0 then y else x) + +noncomputable def codeSumAt (c a b : ℕ) : SentenceForm := + sumSentence.rename (fun i => if i = 0 then c else if i = 1 then a else b) + +noncomputable def codeScaleAt (twice : Bool) (y x : ℕ) : SentenceForm := + if twice then doubleSentence.rename (fun i => if i = 0 then y else x) else .equal y x + +noncomputable def codeScale (twice : Bool) (a : Ordinal.{u}) : Ordinal.{u} := + if twice then a*2 else a + +theorem codePowerAt_sound (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (y x : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (codePowerAt y x).Sat (M : Set ZFSet) e → + (e x).IsOrdinal ∧ e y = (Ordinal.omega0 ^ (e x).rank).toZFSet := by + rw [codePowerAt,SentenceForm.sat_rename] + exact omegaPowerSentence_sound M hM hω _ (fun i => he _) + +theorem codePowerAt_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (y x : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (codePowerAt y x).Sat (M : Set ZFSet) e ↔ + (e x).IsOrdinal ∧ e y = (Ordinal.omega0 ^ (e x).rank).toZFSet := by + rw [codePowerAt,SentenceForm.sat_rename] + exact omegaPowerSentence_sourceT M hM hT _ (fun i => he _) + +theorem codeSumAt_sound (M : ZFSet.{u}) (hM : Transitive M) + (c a b : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (α β : Ordinal.{u}) (ha : e a = α.toZFSet) (hb : e b = β.toZFSet) : + (codeSumAt c a b).Sat (M : Set ZFSet) e → e c = (α+β).toZFSet := by + rw [codeSumAt,SentenceForm.sat_rename] + exact sumSentence_sound M hM _ (fun i => he _) α β ha hb + +theorem codeSumAt_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (c a b : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (α β : Ordinal.{u}) (ha : e a = α.toZFSet) (hb : e b = β.toZFSet) : + (codeSumAt c a b).Sat (M : Set ZFSet) e ↔ e c = (α+β).toZFSet := by + rw [codeSumAt,SentenceForm.sat_rename] + exact sumSentence_sourceT M hM hT _ (fun i => he _) α β ha hb + +theorem codeScaleAt_sound (M : ZFSet.{u}) (hM : Transitive M) + (twice : Bool) (y x : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (a : Ordinal.{u}) (ha : e x = a.toZFSet) : + (codeScaleAt twice y x).Sat (M : Set ZFSet) e → e y = (codeScale twice a).toZFSet := by + cases twice with + | false => exact fun h => h.trans ha + | true => + rw [codeScaleAt,ite_eq_left rfl,SentenceForm.sat_rename] + exact doubleSentence_sound M hM _ (fun i => he _) a ha + +theorem codeScaleAt_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (twice : Bool) (y x : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (a : Ordinal.{u}) (ha : e x = a.toZFSet) : + (codeScaleAt twice y x).Sat (M : Set ZFSet) e ↔ e y = (codeScale twice a).toZFSet := by + cases twice with + | false => change e y = e x ↔ _; rw [ha]; rfl + | true => + rw [codeScaleAt,ite_eq_left rfl,SentenceForm.sat_rename] + exact doubleSentence_sourceT M hM hT _ (fun i => he _) a ha + +theorem codeScale_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (twice : Bool) (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) : + (codeScale twice a).toZFSet ∈ M := by + cases twice + · exact ha + · exact ordinal_mul_two_internal M hM hT a ha + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalConstruction.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..be4253c2aea6c05c7cbebdd38a52ee76831a01ad --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalConstruction.lean @@ -0,0 +1,113 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalInputSyntax + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u +attribute [local irreducible] Construction.ownRealsMembership SentenceForm.bound + +theorem Construction.ordinal_definition (t : Construction.{u}) : + ∃ q : SentenceForm, ∀ M : ZFSet.{u}, Transitive M → SourceT M → + ∀ P : Oracle, P ∈ modelReals M → t.Certified (groundReals M) P → t.Indexed M → + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ + ∀ δ : Ordinal.{u}, δ.toZFSet ∈ M → γ ≤ δ → + t.value (groundReals M) P ∈ level (groundReals M) δ ∧ + (∀ i, t.ordinalInputs P i ∈ level (groundReals M) δ) ∧ + ∀ z ∈ level (groundReals M) δ, + q.Sat (level (groundReals M) δ : Set ZFSet) (cons z (t.ordinalInputs P)) ↔ + z ∈ t.value (groundReals M) P := by + classical + obtain ⟨p,hp⟩ := parameter_free_ordinal_stage.{u} + refine ⟨t.ordinalMembership p,?_⟩ + intro M hM hT P hP ht hi + let R := groundReals M + let n := t.ownRealsMembership.bound + obtain ⟨α,hα,hvα,heα,_⟩ := t.inlined_at_level M hM hT P hP ht hi + have hbound (k : Fin n) : ∃ β : Ordinal.{u}, β.toZFSet ∈ M ∧ + ∀ δ : Ordinal.{u}, δ.toZFSet ∈ M → β ≤ δ → + ∀ o : Ordinal.{u}, t.ordinalData k = some o → + o.toZFSet ∈ level R δ ∧ level R o ∈ level R δ ∧ + ∀ A ∈ level R δ, + p.Sat (level R δ : Set ZFSet) (cons A (cons o.toZFSet (fun _ => R))) ↔ A = level R o := by + cases hk : t.ordinalData k with + | none => + refine ⟨0,internal_ordinal_zero M hM hT,?_⟩ + intro δ hδ hle o ho + cases ho + | some o => + obtain ⟨β,hβ,hβspec⟩ := hp M hM hT o (t.ordinalData_mem M hi k o hk) + refine ⟨β,hβ,?_⟩ + intro δ hδ hle o' ho' + have heq : o = o' := Option.some.inj ho' + subst o' + obtain ⟨hoL,hsL,_,hdef⟩ := hβspec δ hδ hle + exact ⟨hoL,hsL,hdef⟩ + choose b hb hbs using hbound + let β : Ordinal.{u} := Finset.univ.sup b + have hβ : β.toZFSet ∈ M := internal_ordinal_finite_sup M hM hT Finset.univ b (fun i _ => hb i) + refine ⟨max α β,internal_ordinal_max M hα hβ,?_⟩ + intro δ hδ hle + have hαδ : α ≤ δ := (le_max_left α β).trans hle + have hβδ : β ≤ δ := (le_max_right α β).trans hle + have hbδ (k : Fin n) : b k ≤ δ := (Finset.le_sup (Finset.mem_univ k)).trans hβδ + have hL := level_transitive R δ + have hv : t.value R P ∈ level R δ := level_mono R hαδ hvα + have he : ∀ i, t.singleInputs R P i ∈ level R δ := fun i => level_mono R hαδ (heα i) + have hown := t.ownRealsInputs_mem (level R δ) R P he + have hR := groundReals_mem M hM hT + have hsame : groundReals (level R δ) = R := groundReals_between M (level R δ) hL + (level_subset_model M R hM hT hR δ hδ) (he 0) + have hord : ∀ i, t.ordinalInputs P i ∈ level R δ := by + intro i + cases i with + | zero => exact he 1 + | succ k => + change (if k < n then match t.ordinalData k with | none => realCode P | some o => o.toZFSet + else realCode P) ∈ level R δ + by_cases hk : k < n + · rw [ite_eq_left hk] + cases ho : t.ordinalData k with + | none => exact he 1 + | some o => exact (hbs ⟨k,hk⟩ δ hδ (hbδ ⟨k,hk⟩) o ho).1 + · rw [ite_eq_right hk]; exact he 1 + refine ⟨hv,hord,?_⟩ + intro z hz + have hf (k : ℕ) (hk : k < n) (A : ZFSet.{u}) (hA : A ∈ level R δ) : + (t.ordinalInputFormula p k).Sat (level R δ : Set ZFSet) (cons A (cons z (t.ordinalInputs P))) ↔ + A = t.ownRealsInputs R P (k+1) := by + cases ho : t.ordinalData k with + | none => + simp only [Construction.ordinalInputFormula,ho,SentenceForm.Sat,cons_zero,cons_succ, + Construction.ordinalInputs,Construction.ownRealsInputs] + | some o => + have hstage := hbs ⟨k,hk⟩ δ hδ (hbδ ⟨k,hk⟩) o ho + simp only [Construction.ordinalInputFormula,ho,SentenceForm.sat_rename] + have henv : (fun i => cons A (cons z (t.ordinalInputs P)) (if i = 0 then 0 else k+3)) = + cons A (fun _ => o.toZFSet) := by + funext i + cases i with + | zero => rfl + | succ i => simp [Construction.ordinalInputs,show k < t.ownRealsMembership.bound from hk,ho] + rw [henv,ownStageFormula_spec p (level R δ) R o.toZFSet A hL (he 2) hsame (he 0) hA hstage.1] + simpa only [Construction.ownRealsInputs,cons_succ,ho] using hstage.2.2 A hA + exact (t.ordinalMembership_spec p (level R δ) R P z (fun k _ => hown (k+1)) hf).trans + (t.ownRealsMembership_spec (level R δ) R hL hsame P ht he hv z hz) + +theorem Construction.ordinal_subset_definition (t : Construction.{u}) : + ∃ q : SentenceForm, ∀ M : ZFSet.{u}, Transitive M → SourceT M → + ∀ P : Oracle, P ∈ modelReals M → t.Certified (groundReals M) P → t.Indexed M → + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ + (∀ i, t.ordinalInputs P i ∈ level (groundReals M) γ) ∧ + t.value (groundReals M) P = definedSubset (level (groundReals M) γ) q + (fun i : Fin q.bound => t.ordinalInputs P i) := by + obtain ⟨q,hq⟩ := t.ordinal_definition + refine ⟨q,?_⟩ + intro M hM hT P hP ht hi + obtain ⟨γ,hγ,hγspec⟩ := hq M hM hT P hP ht hi + obtain ⟨hv,he,hf⟩ := hγspec γ hγ le_rfl + exact ⟨γ,hγ,he,definedSubset_of_membership _ _ (level_transitive _ γ) hv q (t.ordinalInputs P) hf⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalCut.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalCut.lean new file mode 100644 index 0000000000000000000000000000000000000000..acd28464ad2a584c884826c94728be7daad3db91 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalCut.lean @@ -0,0 +1,91 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeModelSyntax +import OAI.Computability.DegreeRigidity.SetModels.ElementarySatisfaction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def ordinalCut (A : ZFSet.{u}) : ZFSet.{u} := A.sep ZFSet.IsOrdinal + +theorem mem_ordinalCut (A x : ZFSet.{u}) : + x ∈ ordinalCut A ↔ x ∈ A ∧ x.IsOrdinal := ZFSet.mem_sep + +theorem ordinalCut_isOrdinal (A : ZFSet.{u}) (hA : Transitive A) : + (ordinalCut A).IsOrdinal := by + apply ZFSet.isOrdinal_iff_forall_mem_isOrdinal.mpr + constructor + · intro x hx y hy + obtain ⟨hx,ho⟩ := (mem_ordinalCut A x).mp hx + exact (mem_ordinalCut A y).mpr ⟨hA x hx y hy,ho.mem hy⟩ + · intro x hx; exact ((mem_ordinalCut A x).mp hx).2 + +noncomputable def ordinalHeight (A : ZFSet.{u}) : Ordinal.{u} := (ordinalCut A).rank + +theorem ordinalHeight_toZFSet (A : ZFSet.{u}) (hA : Transitive A) : + (ordinalHeight A).toZFSet = ordinalCut A := (ordinalCut_isOrdinal A hA).toZFSet_rank_eq + +theorem ordinal_mem_iff_height (A : ZFSet.{u}) (hA : Transitive A) (o : Ordinal.{u}) : + o.toZFSet ∈ A ↔ o < ordinalHeight A := by + rw [← Ordinal.toZFSet_mem_toZFSet_iff,ordinalHeight_toZFSet A hA,mem_ordinalCut] + exact (and_iff_left (ZFSet.isOrdinal_toZFSet o)).symm + +theorem ordinal_subset_iff_height (A : ZFSet.{u}) (hA : Transitive A) (o : Ordinal.{u}) : + o.toZFSet ⊆ A ↔ o ≤ ordinalHeight A := by + rw [← Ordinal.toZFSet_subset_toZFSet_iff,ordinalHeight_toZFSet A hA] + constructor + · intro h x hx + exact (mem_ordinalCut A x).mpr ⟨h hx,(ZFSet.isOrdinal_toZFSet o).mem hx⟩ + · intro h x hx; exact ((mem_ordinalCut A x).mp (h hx)).1 + +noncomputable def ordinalSentence : SentenceForm := fromBounded (ordinalFormula 0) + +theorem ordinalSentence_bound : ordinalSentence.bound = 1 := by rfl + +theorem ordinalSentence_spec (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : e 0 ∈ A) : + ordinalSentence.Sat (A : Set ZFSet) e ↔ (e 0).IsOrdinal := by + have hs := ordinalSentence.finite_support (A : Set ZFSet) e (fun _ => e 0) (by + intro i hi + rw [ordinalSentence_bound] at hi + have : i = 0 := by omega + subst i; rfl) + rw [hs] + exact (bounded_sat _ _ _).trans + (((ordinalFormula 0).absolute A hA _ (fun _ => he)).trans (eval_ordinalFormula 0 _)) + +theorem ordinalCut_mem_definablePower (A : ZFSet.{u}) (hA : Transitive A) : + ordinalCut A ∈ definablePower A := by + apply (mem_definablePower A _).mpr + refine ⟨0,ordinalSentence,Fin.elim0,by rw [ordinalSentence_bound],fun i => Fin.elim0 i,?_⟩ + apply ZFSet.ext; intro x + rw [mem_ordinalCut,mem_definedSubset] + apply and_congr_right; intro hx + exact (ordinalSentence_spec A hA (cons x (tupleEnv (Fin.elim0 : Fin 0 → ZFSet.{u}))) hx).symm + +theorem ordinal_definablePower_iff (A : ZFSet.{u}) (hA : Transitive A) (o : Ordinal.{u}) : + o.toZFSet ∈ definablePower A ↔ o ≤ ordinalHeight A := by + constructor + · intro ho + exact (ordinal_subset_iff_height A hA o).mp (subset_of_mem_definablePower ho) + · intro ho + rcases lt_or_eq_of_le ho with ho|rfl + · exact subset_definablePower hA ((ordinal_mem_iff_height A hA o).mpr ho) + · rw [ordinalHeight_toZFSet A hA] + exact ordinalCut_mem_definablePower A hA + +theorem ordinalHeight_definablePower (A : ZFSet.{u}) (hA : Transitive A) : + ordinalHeight (definablePower A) = ordinalHeight A + 1 := by + apply le_antisymm + · by_contra h + have hm := (ordinal_mem_iff_height _ (definablePower_transitive hA) _).mpr (lt_of_not_ge h) + have := (ordinal_definablePower_iff A hA _).mp hm + exact (not_le_of_gt (lt_add_one (ordinalHeight A))) this + · apply Order.add_one_le_iff.mpr + exact (ordinal_mem_iff_height _ (definablePower_transitive hA) _).mp + ((ordinal_definablePower_iff A hA _).mpr le_rfl) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalDecoderDomains.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalDecoderDomains.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e41b381376ead7e51844546834a86f04b071642 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalDecoderDomains.lean @@ -0,0 +1,51 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalEntryDecoder + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem ground_level_omega_mem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (δ : Ordinal.{u}) : ZFSet.omega ∈ level (groundReals M) δ := + seed_subset_stage _ _ (parameter_subset_seed _ (omega_mem_groundReals M hM hT)) + +theorem padded_entry_height_sound (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (n : ℕ) (k : Fin n) (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hβ : realSeedOffset ≤ β) (z : ZFSet.{u}) + (hz : z ∈ level (groundReals M) (heightDomainIndex (paddedCode v β))) : + (paddedEntrySentence n k).Sat + (level (groundReals M) (heightDomainIndex (paddedCode v β)) : Set ZFSet) + (cons z (fun _ => (paddedCode v β).toZFSet)) → z = (v k).toZFSet := by + have hc := (padded_height_domain M hM hT v β hβ).1 + exact paddedEntrySentence_sound _ (level_transitive _ _) (ground_level_omega_mem M hM hT _) + n k _ (fun i => by cases i; exact hz; exact hc) v β rfl + +noncomputable def largestPaddedEntrySentence (n : ℕ) (k : Fin n) : SentenceForm := + bindLargestOrdinal ((paddedEntrySentence n k).rename (fun i => if i = 0 then 1 else 0)) + +theorem largestPaddedEntrySentence_bound (n : ℕ) (k : Fin n) : + (largestPaddedEntrySentence n k).bound ≤ 1 := by + have hb := code_rename_bound (paddedEntrySentence n k) + (fun i => if i = 0 then 1 else 0) 2 (by intro i _; split <;> omega) + rw [largestPaddedEntrySentence,bindLargestOrdinal_bound] + omega + +theorem largestPaddedEntrySentence_sound (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (n : ℕ) (k : Fin n) (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hβ : realSeedOffset ≤ β) (e : ℕ → ZFSet.{u}) + (he : e 0 ∈ level (groundReals M) (heightDomainIndex (paddedCode v β))) : + (largestPaddedEntrySentence n k).Sat + (level (groundReals M) (heightDomainIndex (paddedCode v β)) : Set ZFSet) e → + e 0 = (v k).toZFSet := by + rw [largestPaddedEntrySentence,bindLargestOrdinal_ground_domain _ M hM hT _ + (hβ.trans (padding_lt_paddedCode v β).le),SentenceForm.sat_rename] + have heq : (fun i => cons (paddedCode v β).toZFSet e (if i = 0 then 1 else 0)) = + cons (e 0) (fun _ => (paddedCode v β).toZFSet) := by + funext i; cases i <;> rfl + rw [heq] + exact padded_entry_height_sound M hM hT n k v β hβ (e 0) he + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalEntryBinding.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalEntryBinding.lean new file mode 100644 index 0000000000000000000000000000000000000000..01e7830620ccd46876f6730d403e3c694fa767bf --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalEntryBinding.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalPaddingSyntax + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +def codeBindEntries : ℕ → SentenceForm → SentenceForm + | 0, p => p + | n+1, p => .ex (codeBindEntries n p) + +theorem codeBindEntries_bound (n : ℕ) (p : SentenceForm) : + (codeBindEntries n p).bound = p.bound - n := by + induction n with + | zero => rfl + | succ n ih => simp only [codeBindEntries,SentenceForm.bound,ih,Nat.sub_sub] + +theorem code_prepend_congr (w v : ℕ → ZFSet.{u}) (n : ℕ) (e : ℕ → ZFSet.{u}) + (h : ∀ i, i < n → w i = v i) : prependValues w n e = prependValues v n e := by + funext i + by_cases hi : i < n + · rw [prependValues_lt w n e i hi,prependValues_lt v n e i hi,h i hi] + · have heq : i = n+(i-n) := by omega + rw [heq,prependValues_tail,prependValues_tail] + +theorem codeBindEntries_sat (M : ZFSet.{u}) (n : ℕ) (p : SentenceForm) + (e : ℕ → ZFSet.{u}) : + (codeBindEntries n p).Sat (M : Set ZFSet) e ↔ + ∃ w : ℕ → ZFSet.{u}, (∀ i, i < n → w i ∈ M) ∧ + p.Sat (M : Set ZFSet) (prependValues w n e) := by + induction n generalizing e with + | zero => exact ⟨fun h => ⟨e,by intro i hi; omega,h⟩,fun ⟨_,_,h⟩ => h⟩ + | succ n ih => + change (∃ x ∈ M, (codeBindEntries n p).Sat _ (cons x e)) ↔ _ + constructor + · rintro ⟨x,hx,hp⟩ + obtain ⟨w,hw,hp⟩ := (ih (cons x e)).mp hp + let v : ℕ → ZFSet.{u} := fun i => if i < n then w i else x + have hn : v n = x := by simp [v] + refine ⟨v,?_,?_⟩ + · intro i hi; dsimp [v]; split; exact hw i ‹i < n›; exact hx + · change p.Sat _ (prependValues v n (cons (v n) e)) + rw [hn,code_prepend_congr v w n (cons x e) (by intro i hi; simp [v,hi])] + exact hp + · rintro ⟨w,hw,hp⟩ + exact ⟨w n,hw n (by omega),(ih _).mpr ⟨w,fun i hi => hw i (by omega),hp⟩⟩ + +def entryCodeSlots (n : ℕ) : ℕ → ℕ + | 0 => n+1 + | i+1 => if i < n then i else n+1 + +noncomputable def paddedEntrySentence (n : ℕ) (k : Fin n) : SentenceForm := + codeBindEntries n (.conj (.equal n k.val) + ((paddedCodeSentence n).rename (entryCodeSlots n))) + +theorem paddedEntrySentence_bound (n : ℕ) (k : Fin n) : + (paddedEntrySentence n k).bound ≤ 2 := by + have hp := code_rename_bound (paddedCodeSentence n) (entryCodeSlots n) (n+2) (by + intro i _; cases i <;> simp only [entryCodeSlots] <;> (try split) <;> omega) + rw [paddedEntrySentence,codeBindEntries_bound] + change max (max n k.val + 1) _ - n ≤ 2 + have hk := k.isLt + omega + +theorem entryCodeSlots_env (n : ℕ) (e w : ℕ → ZFSet.{u}) : + ∀ i, i < (paddedCodeSentence n).bound → + prependValues w n e (entryCodeSlots n i) = cons (e 1) w i := by + intro i hi + have hb := paddedCodeSentence_bound n + cases i with + | zero => exact prependValues_tail w n e 1 + | succ i => + simp only [entryCodeSlots,ite_eq_left (show i < n by omega),cons_succ] + exact prependValues_lt w n e i (by omega) + +theorem paddedEntrySentence_semantics (M : ZFSet.{u}) (n : ℕ) (k : Fin n) + (e : ℕ → ZFSet.{u}) : + (paddedEntrySentence n k).Sat (M : Set ZFSet) e ↔ + ∃ w : ℕ → ZFSet.{u}, (∀ i, i < n → w i ∈ M) ∧ e 0 = w k.val ∧ + (paddedCodeSentence n).Sat (M : Set ZFSet) (cons (e 1) w) := by + rw [paddedEntrySentence,codeBindEntries_sat] + apply exists_congr; intro w + apply and_congr_right; intro _ + change (prependValues w n e n = prependValues w n e k.val ∧ _) ↔ _ + rw [show prependValues w n e n = e 0 from prependValues_tail w n e 0,prependValues_lt w n e k.val k.isLt, + SentenceForm.sat_rename] + exact and_congr Iff.rfl ((paddedCodeSentence n).finite_support _ _ _ (entryCodeSlots_env n e w)) + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalEntryDecoder.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalEntryDecoder.lean new file mode 100644 index 0000000000000000000000000000000000000000..fcf553f2fa9bc9b1754c1a48b0edb81aba68be2d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalEntryDecoder.lean @@ -0,0 +1,63 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalEntryBinding + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem paddedEntrySentence_sound (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (n : ℕ) (k : Fin n) (e : ℕ → ZFSet.{u}) + (he : ∀ i, e i ∈ M) (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hc : e 1 = (paddedCode v β).toZFSet) + (hp : (paddedEntrySentence n k).Sat (M : Set ZFSet) e) : e 0 = (v k).toZFSet := by + obtain ⟨w,hw,hy,hp⟩ := (paddedEntrySentence_semantics M n k e).mp hp + let w' : ℕ → ZFSet.{u} := fun i => if i < n then w i else e 0 + have hw' (i : ℕ) : w' i ∈ M := by + dsimp [w']; split; exact hw i ‹i < n›; exact he 0 + have hp' : (paddedCodeSentence n).Sat (M : Set ZFSet) (cons (e 1) w') := by + apply ((paddedCodeSentence n).finite_support _ (cons (e 1) w) (cons (e 1) w') ?_).mp hp + intro i hi + have hb := paddedCodeSentence_bound n + cases i with + | zero => rfl + | succ i => simp [w',show i < n by omega] + have hv := paddedCodeSentence_recovers M hM hω n (cons (e 1) w') + (fun i => by cases i; exact he 1; exact hw' _) v β hc hp' + have hk := hv k + simpa only [cons_succ,w',ite_eq_left k.isLt,← hy] using hk + +theorem paddedEntrySentence_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (n : ℕ) (k : Fin n) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) (hc : e 1 = (paddedCode v β).toZFSet) : + (paddedEntrySentence n k).Sat (M : Set ZFSet) e ↔ e 0 = (v k).toZFSet := by + have hω := omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity + refine ⟨paddedEntrySentence_sound M hM hω n k e he v β hc,?_⟩ + intro hy + let w : ℕ → ZFSet.{u} := fun i => if hi : i < n then (v ⟨i,hi⟩).toZFSet else e 0 + have hw (i : ℕ) : w i ∈ M := by + dsimp [w] + split + · exact paddedCode_entries_mem M hM v β (hc ▸ he 1) _ + · exact he 0 + apply (paddedEntrySentence_semantics M n k e).mpr + refine ⟨w,fun i _ => hw i,?_,?_⟩ + · simpa [w,k.isLt] using hy + · apply (paddedCodeSentence_recognition M hM hT n (cons (e 1) w) + (fun i => by cases i; exact he 1; exact hw _) v β hc).mpr + intro i + simp [w,i.isLt] + +theorem uniform_padded_entry_decoder (n : ℕ) (k : Fin n) : + ∃ p : SentenceForm, p.bound ≤ 2 ∧ ∀ M : ZFSet.{u}, Transitive M → SourceT M → + ∀ (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}), (paddedCode v β).toZFSet ∈ M → + ∀ z ∈ M, p.Sat (M : Set ZFSet) (cons z (fun _ => (paddedCode v β).toZFSet)) ↔ + z = (v k).toZFSet := by + refine ⟨paddedEntrySentence n k,paddedEntrySentence_bound n k,?_⟩ + intro M hM hT v β hc z hz + exact paddedEntrySentence_sourceT M hM hT n k _ + (fun i => by cases i; exact hz; exact hc) v β rfl + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalInputSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalInputSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e45eb65b0555ecc508e9af3c4a1cddedc8f2c05 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalInputSyntax.lean @@ -0,0 +1,83 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ParameterFreeOrdinalStage +import OAI.Computability.DegreeRigidity.Representation.OwnRealsLevelDefinition + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def ownStageFormula (p : SentenceForm) : SentenceForm := + .ex (.conj (canonicalReals 0) (p.rename (fun i => match i with | 0 => 1 | 1 => 2 | _ => 0))) + +theorem ownStageFormula_spec (p : SentenceForm) (N R x A : ZFSet.{u}) (hN : Transitive N) + (hw : ZFSet.omega.{u} ∈ N) (hR : groundReals N = R) (hRN : R ∈ N) + (hA : A ∈ N) (hx : x ∈ N) : + (ownStageFormula p).Sat (N : Set ZFSet) (cons A (fun _ => x)) ↔ + p.Sat (N : Set ZFSet) (cons A (cons x (fun _ => R))) := by + have hf (r : ZFSet.{u}) (hr : r ∈ N) : + (canonicalReals 0).Sat (N : Set ZFSet) (cons r (cons A (fun _ => x))) ↔ r = R := by + rw [canonicalReals_spec N hN hw 0 _ + (by intro i; rcases i with _|_|i; exact hr; exact hA; exact hx),hR] + rfl + have he (r : ZFSet.{u}) : + (fun i => cons r (cons A (fun _ => x)) (match i with | 0 => 1 | 1 => 2 | _ => 0)) = + cons A (cons x (fun _ => r)) := by + funext i; rcases i with _|_|i <;> rfl + change (∃ r ∈ N, (canonicalReals 0).Sat _ (cons r (cons A (fun _ => x))) ∧ + (p.rename _).Sat _ (cons r (cons A (fun _ => x)))) ↔ _ + simp only [SentenceForm.sat_rename,he] + constructor + · rintro ⟨r,hr,h,hp⟩ + obtain rfl := (hf r hr).mp h + exact hp + · intro hp + exact ⟨R,hRN,(hf R hRN).mpr rfl,hp⟩ + +noncomputable def Construction.ordinalInputs (t : Construction.{u}) (P : Oracle) : ℕ → ZFSet.{u} := + cons (realCode P) (fun k => if k < t.ownRealsMembership.bound then + match t.ordinalData k with | none => realCode P | some o => o.toZFSet + else realCode P) + +noncomputable def Construction.ordinalInputFormula (t : Construction.{u}) (p : SentenceForm) (k : ℕ) : SentenceForm := + match t.ordinalData k with + | none => .equal 0 2 + | some _ => (ownStageFormula p).rename (fun i => if i = 0 then 0 else k+3) + +def ordinalBodySlots (n : ℕ) : ℕ → ℕ + | 0 => n + | 1 => n+1 + | k+2 => if k < n then k else n+1 + +noncomputable def Construction.ordinalMembership (t : Construction.{u}) (p : SentenceForm) : SentenceForm := + bindComputed t.ownRealsMembership.bound (t.ordinalInputFormula p) + (t.ownRealsMembership.rename (ordinalBodySlots t.ownRealsMembership.bound)) + +theorem ordinalBodySlots_spec (p : SentenceForm) (N : ZFSet.{u}) + (e w : ℕ → ZFSet.{u}) : + (p.rename (ordinalBodySlots p.bound)).Sat (N : Set ZFSet) (prependValues w p.bound e) ↔ + p.Sat (N : Set ZFSet) (cons (e 0) (cons (e 1) w)) := by + rw [SentenceForm.sat_rename] + apply p.finite_support + intro i hi + rcases i with _|_|k + · exact prependValues_tail w p.bound e 0 + · exact prependValues_tail w p.bound e 1 + · simp only [ordinalBodySlots,ite_eq_left (show k < p.bound by omega),cons_succ] + exact prependValues_lt w p.bound e k (by omega) + +theorem Construction.ordinalMembership_spec (t : Construction.{u}) (p : SentenceForm) + (N R : ZFSet.{u}) (P : Oracle) (z : ZFSet.{u}) + (hw : ∀ k, k < t.ownRealsMembership.bound → t.ownRealsInputs R P (k+1) ∈ N) + (hf : ∀ k, k < t.ownRealsMembership.bound → ∀ A ∈ N, + (t.ordinalInputFormula p k).Sat (N : Set ZFSet) (cons A (cons z (t.ordinalInputs P))) ↔ + A = t.ownRealsInputs R P (k+1)) : + (t.ordinalMembership p).Sat (N : Set ZFSet) (cons z (t.ordinalInputs P)) ↔ + t.ownRealsMembership.Sat (N : Set ZFSet) (cons z (t.ownRealsInputs R P)) := by + rw [Construction.ordinalMembership,bindComputed_spec N _ _ _ _ _ hw hf, + ordinalBodySlots_spec] + rfl + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalOrderPresentation.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalOrderPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..9223cc29271fc7fd845ef0ee3fa2794aa69cef10 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalOrderPresentation.lean @@ -0,0 +1,77 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalOrderTypeSyntax + +namespace OAI + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory +universe u + +theorem value_of_ordinal_presentation (d r : ZFSet.{u}) (o : Ordinal.{u}) + (wf : WellFounded (Rel d r)) (j : ZFSet.{u} → ZFSet.{u}) + (hj : ∀ x ∈ d, j x ∈ o.toZFSet) + (hs : ∀ z ∈ o.toZFSet, ∃ x ∈ d, j x = z) + (he : ∀ x ∈ d, ∀ y ∈ d, ZFSet.pair x y ∈ r ↔ j x ∈ j y) + (x : ZFSet.{u}) (hx : x ∈ d) : value d r wf x = j x := by + induction x using wf.induction with + | h x ih => + apply ZFSet.ext; intro z + rw [mem_value] + constructor + · rintro ⟨y,hy,hyx,rfl⟩ + rw [ih y ⟨hy,hyx⟩ hy] + exact (he y hy x hx).mp hyx + · intro hz + have hzo := (ZFSet.isOrdinal_toZFSet o).subset_of_mem (hj x hx) hz + obtain ⟨y,hy,hyz⟩ := hs z hzo + have hyx : ZFSet.pair y x ∈ r := (he y hy x hx).mpr (hyz ▸ hz) + exact ⟨y,hy,hyx,hyz.symm.trans (ih y ⟨hy,hyx⟩ hy).symm⟩ + +theorem orderType_of_ordinal_presentation (d r : ZFSet.{u}) (o : Ordinal.{u}) + (wf : WellFounded (Rel d r)) (j : ZFSet.{u} → ZFSet.{u}) + (hj : ∀ x ∈ d, j x ∈ o.toZFSet) + (hs : ∀ z ∈ o.toZFSet, ∃ x ∈ d, j x = z) + (he : ∀ x ∈ d, ∀ y ∈ d, ZFSet.pair x y ∈ r ↔ j x ∈ j y) : + orderType d r wf = o := by + have hr : ordinalRange d r wf = o.toZFSet := by + apply ZFSet.ext; intro z + rw [mem_ordinalRange] + constructor + · rintro ⟨x,hx,rfl⟩ + rw [value_of_ordinal_presentation d r o wf j hj hs he x hx] + exact hj x hx + · intro hz + obtain ⟨x,hx,heq⟩ := hs z hz + exact ⟨x,hx,heq.symm.trans (value_of_ordinal_presentation d r o wf j hj hs he x hx).symm⟩ + unfold orderType + rw [hr,Ordinal.rank_toZFSet] + +theorem ordinal_internal_of_presentation (M d r : ZFSet.{u}) (o : Ordinal.{u}) + (hM : Transitive M) (hT : SourceT M) (hd : d ∈ M) (hr : r ∈ M) (hon : On d r) + (j : ZFSet.{u} → ZFSet.{u}) + (hj : ∀ x ∈ d, j x ∈ o.toZFSet) + (hs : ∀ z ∈ o.toZFSet, ∃ x ∈ d, j x = z) + (he : ∀ x ∈ d, ∀ y ∈ d, ZFSet.pair x y ∈ r ↔ j x ∈ j y) : + o.toZFSet ∈ M ∧ ∃ f ∈ M, Presents d f j ∧ OrderTypeCertificate d r o.toZFSet f := by + have wf : WellFounded (Rel d r) := by + apply (InvImage.wf j ZFSet.mem_wf).mono + intro x y hxy + exact (he x hxy.1 y (right_mem hon hxy.2)).mp hxy.2 + have ht : TransitiveOn d r := by + intro x hx y hy z hz hxy hyz + apply (he x hx z hz).mpr + exact ((ZFSet.isOrdinal_toZFSet o).mem (hj z hz)).subset_of_mem + ((he y hy z hz).mp hyz) ((he x hx y hy).mp hxy) + have hval := value_of_ordinal_presentation d r o wf j hj hs he + have heq := orderType_of_ordinal_presentation d r o wf j hj hs he + obtain ⟨ha,f,hf,hc⟩ := orderTypeCertificate_exists M d r hM hT hd hr wf ht + rw [heq] at ha hc + refine ⟨ha,f,hf,?_,hc⟩ + intro z + rw [hc.2.1.mem_iff wf] + apply exists_congr; intro x + apply and_congr_right; intro hx + rw [hval x hx] + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalOrderType.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalOrderType.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cc7c4548e89b737080163a4ffedccd3d5d9d7bf --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalOrderType.lean @@ -0,0 +1,120 @@ +import OAI.Computability.DegreeRigidity.SetModels.MostowskiCollapse +import Mathlib.SetTheory.ZFC.Ordinal + +namespace OAI + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory +universe u + +def TransitiveOn (d r : ZFSet.{u}) : Prop := + ∀ x ∈ d, ∀ y ∈ d, ∀ z ∈ d, + ZFSet.pair x y ∈ r → ZFSet.pair y z ∈ r → ZFSet.pair x z ∈ r + +def TotalOn (d r : ZFSet.{u}) : Prop := + ∀ x ∈ d, ∀ y ∈ d, x = y ∨ ZFSet.pair x y ∈ r ∨ ZFSet.pair y x ∈ r + +theorem value_isOrdinal {d r : ZFSet.{u}} (wf : WellFounded (Rel d r)) + (ht : TransitiveOn d r) (x : ZFSet.{u}) (hx : x ∈ d) : + (value d r wf x).IsOrdinal := by + induction x using wf.induction with + | h x ih => + apply ZFSet.isOrdinal_iff_forall_mem_isOrdinal.mpr + constructor + · intro y hy z hz + obtain ⟨b,hb,hbx,rfl⟩ := (mem_value d r wf x y).mp hy + obtain ⟨a,ha,hab,rfl⟩ := (mem_value d r wf b z).mp hz + exact (mem_value d r wf x _).mpr ⟨a,ha,ht a ha b hb x hx hab hbx,rfl⟩ + · intro y hy + obtain ⟨a,ha,hax,rfl⟩ := (mem_value d r wf x y).mp hy + exact ih a ⟨ha,hax⟩ ha + +theorem total_extensional {d r : ZFSet.{u}} (wf : WellFounded (Rel d r)) + (ht : TotalOn d r) : Extensional d r := by + intro x hx y hy he + rcases ht x hx y hy with h|h|h + · exact h + · exact False.elim (wf.irrefl.irrefl x ⟨hx,(he x hx).mpr h⟩) + · exact False.elim (wf.irrefl.irrefl y ⟨hy,(he y hy).mp h⟩) + +noncomputable def ordinalRange (d r : ZFSet.{u}) (wf : WellFounded (Rel d r)) : ZFSet.{u} := + ZFSet.range (fun s : Conditions d => value d r wf (label d s)) + +theorem mem_ordinalRange (d r : ZFSet.{u}) (wf : WellFounded (Rel d r)) (z : ZFSet.{u}) : + z ∈ ordinalRange d r wf ↔ ∃ x ∈ d, z = value d r wf x := by + rw [ordinalRange,ZFSet.mem_range] + constructor + · rintro ⟨s,hs⟩; exact ⟨label d s,label_mem d s,hs.symm⟩ + · rintro ⟨x,hx,rfl⟩ + obtain ⟨s,rfl⟩ := label_surjective d hx + exact ⟨s,rfl⟩ + +theorem ordinalRange_isOrdinal {d r : ZFSet.{u}} (wf : WellFounded (Rel d r)) + (ht : TransitiveOn d r) : (ordinalRange d r wf).IsOrdinal := by + apply ZFSet.isOrdinal_iff_forall_mem_isOrdinal.mpr + constructor + · intro x hx y hy + obtain ⟨a,_,rfl⟩ := (mem_ordinalRange d r wf x).mp hx + obtain ⟨b,hb,_,rfl⟩ := (mem_value d r wf a y).mp hy + exact (mem_ordinalRange d r wf _).mpr ⟨b,hb,rfl⟩ + · intro x hx + obtain ⟨a,ha,rfl⟩ := (mem_ordinalRange d r wf x).mp hx + exact value_isOrdinal wf ht a ha + +noncomputable def orderType (d r : ZFSet.{u}) (wf : WellFounded (Rel d r)) : Ordinal.{u} := + (ordinalRange d r wf).rank + +theorem orderType_toZFSet {d r : ZFSet.{u}} (wf : WellFounded (Rel d r)) + (ht : TransitiveOn d r) : (orderType d r wf).toZFSet = ordinalRange d r wf := + (ordinalRange_isOrdinal wf ht).toZFSet_rank_eq + +theorem orderType_value_lt {d r : ZFSet.{u}} (wf : WellFounded (Rel d r)) + (x : ZFSet.{u}) (hx : x ∈ d) : + (value d r wf x).rank < orderType d r wf := by + apply ZFSet.rank_lt_of_mem + exact (mem_ordinalRange d r wf _).mpr ⟨x,hx,rfl⟩ + +theorem orderType_internal (M d r : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) + (hd : d ∈ M) (hr : r ∈ M) (wf : WellFounded (Rel d r)) + (ht : TransitiveOn d r) : + (orderType d r wf).toZFSet ∈ M ∧ + ∃ f ∈ M, Graph d r d (orderType d r wf).toZFSet f ∧ + ∀ z ∈ (orderType d r wf).toZFSet, ∃ x ∈ d, ZFSet.pair x z ∈ f := by + obtain ⟨f,hf,hg⟩ := internal_graph M d r hM hP hU hPow hS hR hd hr wf + have heq : graphRange d f = ordinalRange d r wf := by + apply ZFSet.ext; intro z + exact (hg.range_iff wf z).trans (mem_ordinalRange d r wf z).symm + have hm : ordinalRange d r wf ∈ M := heq ▸ graphRange_mem M hM hU hS hd hf + rw [orderType_toZFSet wf ht] + refine ⟨hm,f,hf,?_,?_⟩ + · refine ⟨(fun _ hx => hx),(fun _ _ _ hy _ => hy),?_,?_,?_⟩ + · intro z hz + obtain ⟨x,hx,rfl⟩ := (hg.mem_iff wf z).mp hz + exact ⟨x,hx,_,(mem_ordinalRange d r wf _).mpr ⟨x,hx,rfl⟩,rfl⟩ + · intro x hx + refine ⟨value d r wf x,(mem_ordinalRange d r wf _).mpr ⟨x,hx,rfl⟩, + (hg.mem_iff wf _).mpr ⟨x,hx,rfl⟩,?_⟩ + intro z _ hxz + obtain ⟨y,_,he⟩ := (hg.mem_iff wf _).mp hxz + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + rfl + · intro x hx z _ hxz + obtain ⟨y,hy,he⟩ := (hg.mem_iff wf _).mp hxz + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + constructor + · intro z hz + obtain ⟨y,hy,hyx,rfl⟩ := (mem_value d r wf x z).mp hz + exact ⟨y,hy,hyx,(hg.mem_iff wf _).mpr ⟨y,hy,rfl⟩⟩ + · intro y hy hyx z _ hyz + obtain ⟨w,_,he⟩ := (hg.mem_iff wf _).mp hyz + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact (mem_value d r wf x _).mpr ⟨y,hy,hyx,rfl⟩ + · intro z hz + obtain ⟨x,hx,rfl⟩ := (mem_ordinalRange d r wf z).mp hz + exact ⟨x,hx,(hg.mem_iff wf _).mpr ⟨x,hx,rfl⟩⟩ + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalOrderTypeLevels.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalOrderTypeLevels.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a2c002977716e00f32267b233cf90920cd080de --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalOrderTypeLevels.lean @@ -0,0 +1,59 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalOrderPresentation +import OAI.Computability.DegreeRigidity.Constructibility.RelativeLevySchemas + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel RelationCollapse +universe u + +theorem orderType_certificate_relative (M R d r : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) (hd : d ∈ relativeModel M R) (hr : r ∈ relativeModel M R) + (wf : WellFounded (Rel d r)) (ht : TransitiveOn d r) : + (orderType d r wf).toZFSet ∈ relativeModel M R ∧ + ∃ f ∈ relativeModel M R, OrderTypeCertificate d r (orderType d r wf).toZFSet f := by + obtain ⟨ha,f,hf,hg,ho⟩ := orderType_internal (relativeModel M R) d r + (relativeModel_transitive M R hM) (relativeModel_pairing M R hM hT hR) + (relativeModel_union M R hM hT hR) (relativeModel_power_set M R hM hT hR) + (relativeModel_bounded_separation M R hM hT hR) + (relativeModel_sigma_replacement M R hM hT hR) hd hr wf ht + exact ⟨ha,f,hf,ZFSet.isOrdinal_toZFSet _,hg,ho⟩ + +theorem orderType_sentence_at_levels (M R d r : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hR : R ∈ M) (hd : d ∈ relativeModel M R) (hr : r ∈ relativeModel M R) + (wf : WellFounded (Rel d r)) (ht : TransitiveOn d r) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ ∀ δ : Ordinal.{u}, γ ≤ δ → + d ∈ level R δ ∧ r ∈ level R δ ∧ (orderType d r wf).toZFSet ∈ level R δ ∧ + (∃ f ∈ level R δ, OrderTypeCertificate d r (orderType d r wf).toZFSet f) ∧ + ∀ z ∈ level R δ, + orderTypeSentence.Sat (level R δ : Set ZFSet) (cons z (cons d (cons r (fun _ => d)))) ↔ + z = (orderType d r wf).toZFSet := by + obtain ⟨ha,f,hf,hc⟩ := orderType_certificate_relative M R d r hM hT hR hd hr wf ht + let e := cons d (cons r (cons (orderType d r wf).toZFSet (fun _ => f))) + have he (i : ℕ) : e i ∈ relativeModel M R := by + rcases i with _|_|_|i + · exact hd + · exact hr + · exact ha + · exact hf + obtain ⟨γ,hγ,hγe⟩ := finite_parameters_in_relative_level M R hM hT e 4 + (fun i _ => (mem_relativeModel M R _ hM hT hR).mp (he i)) + refine ⟨γ,hγ,?_⟩ + intro δ hδ + have hdL : d ∈ level R δ := level_mono R hδ (hγe 0 (by omega)) + have hrL : r ∈ level R δ := level_mono R hδ (hγe 1 (by omega)) + have haL : (orderType d r wf).toZFSet ∈ level R δ := level_mono R hδ (hγe 2 (by omega)) + have hfL : f ∈ level R δ := level_mono R hδ (hγe 3 (by omega)) + refine ⟨hdL,hrL,haL,⟨f,hfL,hc⟩,?_⟩ + intro z hz + exact orderTypeSentence_spec_of_certificate (level R δ) (level_transitive R δ) + (cons z (cons d (cons r (fun _ => d)))) (by + intro i; rcases i with _|_|_|i + · exact hz + · exact hdL + · exact hrL + · exact hdL) wf ht ⟨f,hfL,hc⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalOrderTypeSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalOrderTypeSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..178dbbb2350d3e69af4bcd721d421356362f696e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalOrderTypeSyntax.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalOrderType +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalCut +import OAI.Computability.DegreeRigidity.Representation.SourceTheory + +namespace OAI + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory ElementaryModel RelativeConstructible +universe u + +def OrderTypeCertificate (d r a f : ZFSet.{u}) : Prop := + a.IsOrdinal ∧ Graph d r d a f ∧ + ∀ z ∈ a, ∃ x ∈ d, ZFSet.pair x z ∈ f + +theorem OrderTypeCertificate.exact {d r a f : ZFSet.{u}} + (wf : WellFounded (Rel d r)) (ht : TransitiveOn d r) + (hc : OrderTypeCertificate d r a f) : a = (orderType d r wf).toZFSet := by + rw [orderType_toZFSet wf ht] + apply ZFSet.ext; intro z + rw [mem_ordinalRange] + constructor + · intro hz + obtain ⟨x,hx,hxz⟩ := hc.2.2 z hz + exact ⟨x,hx,hc.2.1.correct wf x hx z hz hxz⟩ + · rintro ⟨x,hx,rfl⟩ + obtain ⟨z,hz,hxz,_⟩ := hc.2.1.2.2.2.1 x hx + exact hc.2.1.correct wf x hx z hz hxz ▸ hz + +theorem orderTypeCertificate_exists (M d r : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hd : d ∈ M) (hr : r ∈ M) + (wf : WellFounded (Rel d r)) (ht : TransitiveOn d r) : + (orderType d r wf).toZFSet ∈ M ∧ + ∃ f ∈ M, OrderTypeCertificate d r (orderType d r wf).toZFSet f := by + obtain ⟨ha,f,hf,hg,ho⟩ := orderType_internal M d r hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hd hr wf ht + exact ⟨ha,f,hf,ZFSet.isOrdinal_toZFSet _,hg,ho⟩ + +def orderTypeMatrix (a d r f : ℕ) : Formula := + .conj (ordinalFormula a) (.conj (Code.graph d r d a f) + (Formula.allMem a (.existsMem (d+1) (Formula.pairMem 0 1 (f+2))))) + +theorem orderTypeMatrix_eval (a d r f : ℕ) (e : ℕ → ZFSet.{u}) : + (orderTypeMatrix a d r f).Eval e ↔ OrderTypeCertificate (e d) (e r) (e a) (e f) := by + simp only [orderTypeMatrix,OrderTypeCertificate,Formula.Eval,eval_ordinalFormula, + Code.eval_graph,Formula.eval_allMem,Formula.eval_pairMem,cons_zero,cons_succ] + +noncomputable def orderTypeSentence : SentenceForm := + .ex (fromBounded (orderTypeMatrix 1 2 3 0)) + +theorem orderTypeSentence_bound : orderTypeSentence.bound = 3 := by rfl + +theorem orderTypeSentence_semantics (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) : + orderTypeSentence.Sat (A : Set ZFSet) e ↔ + ∃ f ∈ A, OrderTypeCertificate (e 1) (e 2) (e 0) f := by + change (∃ f ∈ A, (fromBounded _).Sat _ (cons f e)) ↔ _ + apply exists_congr; intro f + apply and_congr_right; intro hf + rw [bounded_sat,Formula.absolute _ A hA _ + (by intro i; cases i <;> simp [cons,hf,he]),orderTypeMatrix_eval] + rfl + +theorem orderTypeSentence_sound (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) + (wf : WellFounded (Rel (e 1) (e 2))) (ht : TransitiveOn (e 1) (e 2)) : + orderTypeSentence.Sat (A : Set ZFSet) e → + e 0 = (orderType (e 1) (e 2) wf).toZFSet := by + intro h + obtain ⟨f,_,hf⟩ := (orderTypeSentence_semantics A hA e he).mp h + exact hf.exact wf ht + +theorem orderTypeSentence_spec_of_certificate (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) + (wf : WellFounded (Rel (e 1) (e 2))) (ht : TransitiveOn (e 1) (e 2)) + (hw : ∃ f ∈ A, OrderTypeCertificate (e 1) (e 2) + (orderType (e 1) (e 2) wf).toZFSet f) : + orderTypeSentence.Sat (A : Set ZFSet) e ↔ + e 0 = (orderType (e 1) (e 2) wf).toZFSet := by + refine ⟨orderTypeSentence_sound A hA e he wf ht,?_⟩ + intro heq + apply (orderTypeSentence_semantics A hA e he).mpr + simpa only [heq] using hw + +theorem orderTypeSentence_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (wf : WellFounded (Rel (e 1) (e 2))) (ht : TransitiveOn (e 1) (e 2)) : + orderTypeSentence.Sat (M : Set ZFSet) e ↔ + e 0 = (orderType (e 1) (e 2) wf).toZFSet := + orderTypeSentence_spec_of_certificate M hM e he wf ht + (orderTypeCertificate_exists M _ _ hM hT (he 1) (he 2) wf ht).2 + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalPaddingSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalPaddingSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa37023a29c49b552cb630777dc50f18c2a6506a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalPaddingSyntax.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalVectorRecovery + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +noncomputable def paddedCodeSentence (n : ℕ) : SentenceForm := + .ex (.ex (.conj + (pairCodeSentence.rename (fun i => if i = 0 then 2 else if i = 1 then 1 else 0)) + ((vectorCodeSentence n).rename vectorTailSlots))) + +theorem paddedCodeSentence_bound (n : ℕ) : (paddedCodeSentence n).bound ≤ n+1 := by + have hp := code_rename_bound pairCodeSentence + (fun i => if i = 0 then 2 else if i = 1 then 1 else 0) 3 (by + intro i _; split <;> (try split) <;> omega) + have ht := code_rename_bound (vectorCodeSentence n) vectorTailSlots (n+3) (by + intro i hi + have hb := vectorCodeSentence_bound n + cases i with + | zero => simp [vectorTailSlots] + | succ i => change i+3 < n+3; omega) + change max _ _ - 1 - 1 ≤ n+1 + omega + +theorem paddedCodeSentence_recovers (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (n : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) (hc : e 0 = (paddedCode v β).toZFSet) + (hp : (paddedCodeSentence n).Sat (M : Set ZFSet) e) : + ∀ i, e (i.val+1) = (v i).toZFSet := by + obtain ⟨b,hb,t,ht,hpair,hvec⟩ := hp + rw [SentenceForm.sat_rename] at hpair hvec + have hrec := pairCodeSentence_recovers M hM hω + (fun i => cons t (cons b e) (if i = 0 then 2 else if i = 1 then 1 else 0)) (fun i => by + split; exact he 0 + split; exact hb + exact ht) β (vectorCode v) hc hpair + have htcode : t = (vectorCode v).toZFSet := hrec.2 + exact vectorCodeSentence_recovers M hM hω n + (fun i => cons t (cons b e) (vectorTailSlots i)) + (fun i => by cases i; exact ht; exact he _) v htcode hvec + +theorem paddedCodeSentence_recognition (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (n : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) (hc : e 0 = (paddedCode v β).toZFSet) : + (paddedCodeSentence n).Sat (M : Set ZFSet) e ↔ ∀ i, e (i.val+1) = (v i).toZFSet := by + have hω := omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity + refine ⟨paddedCodeSentence_recovers M hM hω n e he v β hc,?_⟩ + intro hv + have hcode : (paddedCode v β).toZFSet ∈ M := hc ▸ he 0 + have hb := paddedCode_padding_mem M hM v β hcode + have ht := paddedCode_body_mem M hM v β hcode + refine ⟨β.toZFSet,hb,(vectorCode v).toZFSet,ht,?_,?_⟩ + · rw [SentenceForm.sat_rename] + apply (pairCodeSentence_sourceT M hM hT _ (fun i => by + split; exact he 0 + split; exact hb + exact ht)).mpr + exact ⟨ZFSet.isOrdinal_toZFSet _,ZFSet.isOrdinal_toZFSet _,by simpa [paddedCode] using hc⟩ + · rw [SentenceForm.sat_rename] + exact (vectorCodeSentence_sourceT M hM hT n + (fun i => cons (vectorCode v).toZFSet (cons β.toZFSet e) (vectorTailSlots i)) + (fun i => by cases i; exact ht; exact he _) v hv).mpr rfl + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalPairCode.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalPairCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..34b0b40dccbeda25d4fa5ef651a7e252d65425f7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalPairCode.lean @@ -0,0 +1,73 @@ +import Mathlib.SetTheory.Ordinal.CantorNormalForm + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +universe u +open Ordinal + +noncomputable def pairCode (x y : Ordinal.{u}) : Ordinal.{u} := + if y ≤ x then omega0 ^ (x+1) + omega0 ^ y + else omega0 ^ (y+1) * 2 + omega0 ^ x + +theorem cnf_monomial (x : Ordinal.{u}) : + CNF omega0 (omega0 ^ x) = [(x,1)] := by + simpa only [mul_one,add_zero,CNF.zero_right] using + (CNF.opow_mul_add (b := omega0) (e := x) (x := 1) (y := 0) + one_lt_omega0 one_ne_zero one_lt_omega0 (opow_pos x omega0_pos)) + +theorem pairCode_cnf_left (x y : Ordinal.{u}) (hy : y ≤ x) : + CNF omega0 (pairCode x y) = [(x+1,1),(y,1)] := by + rw [pairCode,ite_eq_left hy] + have h := CNF.opow_mul_add (b := omega0) (e := x+1) (x := 1) (y := omega0 ^ y) + one_lt_omega0 one_ne_zero one_lt_omega0 + ((opow_lt_opow_iff_right one_lt_omega0).mpr (hy.trans_lt (lt_add_one x))) + simpa only [mul_one,cnf_monomial] using h + +theorem pairCode_cnf_right (x y : Ordinal.{u}) (hy : ¬ y ≤ x) : + CNF omega0 (pairCode x y) = [(y+1,2),(x,1)] := by + rw [pairCode,ite_eq_right hy] + have h := CNF.opow_mul_add (b := omega0) (e := y+1) (x := 2) (y := omega0 ^ x) + one_lt_omega0 (by simp) (by exact_mod_cast natCast_lt_omega0 2) + ((opow_lt_opow_iff_right one_lt_omega0).mpr + ((lt_of_not_ge hy).trans (lt_add_one y))) + simpa only [cnf_monomial] using h + +noncomputable def unpairCode (a : Ordinal.{u}) : Ordinal.{u} × Ordinal.{u} := + let h := (CNF omega0 a).getD 0 (0,0) + let t := (CNF omega0 a).getD 1 (0,0) + if h.2 = 1 then (Ordinal.pred h.1,t.1) else (t.1,Ordinal.pred h.1) + +theorem unpairCode_pairCode (x y : Ordinal.{u}) : unpairCode (pairCode x y) = (x,y) := by + by_cases hy : y ≤ x + · simp [unpairCode,pairCode_cnf_left x y hy,Ordinal.pred_add_one] + · simp [unpairCode,pairCode_cnf_right x y hy,Ordinal.pred_add_one] + +theorem pairCode_inj (x y x' y' : Ordinal.{u}) : + pairCode x y = pairCode x' y' ↔ x = x' ∧ y = y' := by + constructor + · intro h + have h' := congrArg unpairCode h + simpa only [unpairCode_pairCode,Prod.mk.injEq] using h' + · rintro ⟨rfl,rfl⟩; rfl + +theorem max_lt_pairCode (x y : Ordinal.{u}) : max x y < pairCode x y := by + by_cases hy : y ≤ x + · rw [max_eq_left hy,pairCode,ite_eq_left hy] + exact ((lt_add_one x).trans_le (right_le_opow (x+1) one_lt_omega0)).trans_le le_self_add + · have hx : x ≤ y := (lt_of_not_ge hy).le + rw [max_eq_right hx,pairCode,ite_eq_right hy] + have hmul : omega0 ^ (y+1) ≤ omega0 ^ (y+1) * 2 := + Ordinal.le_mul_left _ (zero_lt_one.trans_le one_le_two) + exact ((lt_add_one y).trans_le (right_le_opow (y+1) one_lt_omega0)).trans_le + (hmul.trans le_self_add) + +theorem left_lt_pairCode (x y : Ordinal.{u}) : x < pairCode x y := + (le_max_left x y).trans_lt (max_lt_pairCode x y) + +theorem right_lt_pairCode (x y : Ordinal.{u}) : y < pairCode x y := + (le_max_right x y).trans_lt (max_lt_pairCode x y) + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalPairSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalPairSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..87c7016e15e5e263f0bb7c89c0e41d9f105af731 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalPairSyntax.lean @@ -0,0 +1,96 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalCodeBranch + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +noncomputable def pairCodeSentence : SentenceForm := + .conj (fromBounded (.conj (ordinalFormula 1) (ordinalFormula 2))) + (.disj (.conj (fromBounded (.subset 2 1)) (codeBranchSentence false)) + (.conj (.neg (fromBounded (.subset 2 1))) + ((codeBranchSentence true).rename (fun i => if i = 0 then 0 else if i = 1 then 2 else 1)))) + +theorem pairCodeSentence_bound : pairCodeSentence.bound = 3 := by + have hord : (fromBounded (.conj (ordinalFormula 1) (ordinalFormula 2))).bound = 3 := by rfl + have hsub : (fromBounded (.subset 2 1)).bound = 3 := by rfl + have hrename : ((codeBranchSentence true).rename + (fun i => if i = 0 then 0 else if i = 1 then 2 else 1)).bound ≤ 3 := + code_rename_bound (codeBranchSentence true) _ 3 (by intro i _; split <;> (try split) <;> omega) + have finish (p q r s : SentenceForm) + (hp : p.bound = 3) (hq : q.bound = 3) (hr : r.bound = 3) (hs : s.bound ≤ 3) : + (SentenceForm.conj p (.disj (.conj q r) (.conj (.neg q) s))).bound = 3 := by + change max p.bound (max (max q.bound r.bound) (max q.bound s.bound)) = 3 + rw [hp, hq, hr] + omega + exact finish _ _ _ _ hord hsub (codeBranchSentence_bound false) hrename + +theorem pairCodeSentence_semantics (M : ZFSet.{u}) (hM : Transitive M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + pairCodeSentence.Sat (M : Set ZFSet) e ↔ + ((e 1).IsOrdinal ∧ (e 2).IsOrdinal) ∧ + ((e 2 ⊆ e 1 ∧ (codeBranchSentence false).Sat (M : Set ZFSet) e) ∨ + (¬ e 2 ⊆ e 1) ∧ (codeBranchSentence true).Sat (M : Set ZFSet) + (fun i => e (if i = 0 then 0 else if i = 1 then 2 else 1))) := by + change ((fromBounded _).Sat _ e ∧ (SentenceForm.disj _ _).Sat _ e) ↔ _ + rw [bounded_sat,Formula.absolute _ M hM e he,Formula.Eval,eval_ordinalFormula,eval_ordinalFormula, + SentenceForm.sat_disj] + simp only [SentenceForm.Sat,SentenceForm.sat_rename,bounded_sat, + Formula.absolute _ M hM e he,Formula.eval_subset] + +theorem pairCodeSentence_sound (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + pairCodeSentence.Sat (M : Set ZFSet) e → + (e 1).IsOrdinal ∧ (e 2).IsOrdinal ∧ e 0 = (pairCode (e 1).rank (e 2).rank).toZFSet := by + rw [pairCodeSentence_semantics M hM e he] + rintro ⟨⟨ha,hb⟩,h⟩ + refine ⟨ha,hb,?_⟩ + have hsub : e 2 ⊆ e 1 ↔ (e 2).rank ≤ (e 1).rank := by + rw [← ha.toZFSet_rank_eq,← hb.toZFSet_rank_eq,Ordinal.toZFSet_subset_toZFSet_iff] + simp only [Ordinal.rank_toZFSet] + rcases h with ⟨hle,hc⟩|⟨hnle,hc⟩ + · have hv := codeBranchSentence_sound M hM hω false e he _ _ + ha.toZFSet_rank_eq.symm hb.toZFSet_rank_eq.symm hc + simpa only [pairCode,ite_eq_left (hsub.mp hle),codeBranchValue,codeScale,Bool.false_eq_true,↓reduceIte] using hv + · have hv := codeBranchSentence_sound M hM hω true + (fun i => e (if i = 0 then 0 else if i = 1 then 2 else 1)) (fun i => he _) _ _ + hb.toZFSet_rank_eq.symm ha.toZFSet_rank_eq.symm hc + simpa only [pairCode,ite_eq_right (fun h => hnle (hsub.mpr h)),codeBranchValue,codeScale,↓reduceIte] using hv + +theorem pairCodeSentence_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + pairCodeSentence.Sat (M : Set ZFSet) e ↔ + (e 1).IsOrdinal ∧ (e 2).IsOrdinal ∧ e 0 = (pairCode (e 1).rank (e 2).rank).toZFSet := by + have hω := omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity + refine ⟨pairCodeSentence_sound M hM hω e he,?_⟩ + rintro ⟨ha,hb,hc⟩ + apply (pairCodeSentence_semantics M hM e he).mpr + refine ⟨⟨ha,hb⟩,?_⟩ + have hsub : e 2 ⊆ e 1 ↔ (e 2).rank ≤ (e 1).rank := by + rw [← ha.toZFSet_rank_eq,← hb.toZFSet_rank_eq,Ordinal.toZFSet_subset_toZFSet_iff] + simp only [Ordinal.rank_toZFSet] + by_cases hle : (e 2).rank ≤ (e 1).rank + · left + refine ⟨hsub.mpr hle,(codeBranchSentence_sourceT M hM hT false e he _ _ + ha.toZFSet_rank_eq.symm hb.toZFSet_rank_eq.symm).mpr ?_⟩ + simpa only [pairCode,ite_eq_left hle,codeBranchValue,codeScale,Bool.false_eq_true,↓reduceIte] using hc + · right + refine ⟨fun h => hle (hsub.mp h),(codeBranchSentence_sourceT M hM hT true + (fun i => e (if i = 0 then 0 else if i = 1 then 2 else 1)) (fun i => he _) _ _ hb.toZFSet_rank_eq.symm ha.toZFSet_rank_eq.symm).mpr ?_⟩ + simpa only [pairCode,ite_eq_right hle,codeBranchValue,codeScale,↓reduceIte] using hc + +theorem pairCodeSentence_recovers (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (a b : Ordinal.{u}) (hc : e 0 = (pairCode a b).toZFSet) + (hp : pairCodeSentence.Sat (M : Set ZFSet) e) : e 1 = a.toZFSet ∧ e 2 = b.toZFSet := by + obtain ⟨ha,hb,h⟩ := pairCodeSentence_sound M hM hω e he hp + rw [hc] at h + have h := congrArg ZFSet.rank h + simp only [Ordinal.rank_toZFSet] at h + obtain ⟨h1,h2⟩ := (pairCode_inj a b (e 1).rank (e 2).rank).mp h + exact ⟨by rw [h1,ha.toZFSet_rank_eq],by rw [h2,hb.toZFSet_rank_eq]⟩ + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductClosure.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..716e672449cc12e8cb51298e981236a7cbe4c96f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductClosure.lean @@ -0,0 +1,58 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalProductSyntax +import Mathlib.SetTheory.Ordinal.Exponential + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel +universe u + +theorem toZFSet_nat (n : ℕ) : (n : Ordinal.{u}).toZFSet = natSet n := by + induction n with + | zero => simp [natSet] + | succ n ih => rw [Nat.cast_add_one,Ordinal.toZFSet_add_one,ih]; rfl + +theorem toZFSet_omega : Ordinal.omega0.toZFSet = ZFSet.omega.{u} := by + apply ZFSet.ext; intro x + rw [Ordinal.mem_toZFSet_iff,mem_omega] + constructor + · rintro ⟨a,ha,rfl⟩ + obtain ⟨n,rfl⟩ := Ordinal.lt_omega0.mp ha + exact ⟨n,toZFSet_nat n⟩ + · rintro ⟨n,rfl⟩ + exact ⟨n,Ordinal.natCast_lt_omega0 n,toZFSet_nat n⟩ + +theorem ordinal_mul_internal_schemas (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) + (a b : Ordinal.{u}) (ha : a.toZFSet ∈ M) (hb : b.toZFSet ∈ M) : + (a*b).toZFSet ∈ M ∧ ∃ f ∈ M, + OrderTypeCertificate (ZFSet.prod b.toZFSet a.toZFSet) + (productRelation a.toZFSet b.toZFSet) (a*b).toZFSet f := by + obtain ⟨hc,f,hf,hg,ho⟩ := orderType_internal M _ _ hM hP hU hPow hS hR + (product_mem M hM hP hU hPow hS hb ha) + (productRelation_mem M _ _ hM hP hU hPow hS ha hb) + (productRelation_wellFounded a b) (productRelation_transitive a b) + rw [product_orderType] at hc hg ho + exact ⟨hc,f,hf,ZFSet.isOrdinal_toZFSet _,hg,ho⟩ + +theorem ordinal_mul_omega_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) : (a*Ordinal.omega0).toZFSet ∈ M := by + have ho : Ordinal.omega0.toZFSet ∈ M := by + simpa only [toZFSet_omega] using + omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity + exact (ordinal_mul_internal M hM hT a Ordinal.omega0 ha ho).1 + +theorem ordinal_opow_nat_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) (n : ℕ) : (a^(n : Ordinal)).toZFSet ∈ M := by + induction n with + | zero => + rw [Nat.cast_zero,Ordinal.opow_zero,← Nat.cast_one,toZFSet_nat] + exact hM _ (omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity) _ ((mem_omega _).mpr ⟨1,rfl⟩) + | succ n ih => + simpa only [Nat.cast_add_one,Ordinal.opow_add_one] using + (ordinal_mul_internal M hM hT (a^(n : Ordinal)) a ih ha).1 + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductPresentation.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3d144eab47cd7a4d2b12a83a7e65669b9888b91 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductPresentation.lean @@ -0,0 +1,105 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalProductSets + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse +universe u + +noncomputable def productValue (a : Ordinal.{u}) (x : ZFSet.{u}) : ZFSet.{u} := by + classical + exact if h : ∃ s t, x = ZFSet.pair s t then + (a * h.choose.rank + h.choose_spec.choose.rank).toZFSet else ∅ + +theorem productValue_pair (a : Ordinal.{u}) (s t : ZFSet.{u}) : + productValue a (ZFSet.pair s t) = (a*s.rank+t.rank).toZFSet := by + classical + have h : ∃ v w, ZFSet.pair s t = ZFSet.pair v w := ⟨s,t,rfl⟩ + simp only [productValue,dite_eq_left h] + obtain ⟨hs,ht⟩ := ZFSet.pair_inj.mp h.choose_spec.choose_spec + exact congrArg Ordinal.toZFSet (congrArg₂ (fun c d : ZFSet.{u} => a*c.rank+d.rank) hs ht).symm + +theorem productValue_mem (a b : Ordinal.{u}) (x : ZFSet.{u}) + (hx : x ∈ ZFSet.prod b.toZFSet a.toZFSet) : productValue a x ∈ (a*b).toZFSet := by + obtain ⟨s,hs,t,ht,rfl⟩ := ZFSet.mem_prod.mp hx + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hs + obtain ⟨d,hd,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ht + rw [productValue_pair,Ordinal.rank_toZFSet,Ordinal.rank_toZFSet,Ordinal.toZFSet_mem_toZFSet_iff] + exact Ordinal.lt_mul_iff.mpr ⟨c,hc,d,hd,rfl⟩ + +theorem productValue_surjective (a b : Ordinal.{u}) (z : ZFSet.{u}) + (hz : z ∈ (a*b).toZFSet) : + ∃ x ∈ ZFSet.prod b.toZFSet a.toZFSet, productValue a x = z := by + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hz + obtain ⟨q,hq,r,hr,rfl⟩ := Ordinal.lt_mul_iff.mp hc + refine ⟨ZFSet.pair q.toZFSet r.toZFSet,ZFSet.mem_prod.mpr + ⟨_,Ordinal.toZFSet_mem_toZFSet_iff.mpr hq,_,Ordinal.toZFSet_mem_toZFSet_iff.mpr hr,rfl⟩,?_⟩ + rw [productValue_pair,Ordinal.rank_toZFSet,Ordinal.rank_toZFSet] + +theorem productValue_lt_iff (a s t v w : Ordinal.{u}) (ht : t < a) (hw : w < a) : + a*s+t < a*v+w ↔ s < v ∨ (s = v ∧ t < w) := by + have step (s t v w : Ordinal.{u}) (ht : t < a) (hsv : s < v) : + a*s+t < a*v+w := by + have h := (Ordinal.lt_mul_iff.mpr ⟨s,hsv,t,ht,rfl⟩ : a*s+t < a*v) + exact h.trans_le le_self_add + constructor + · intro h + rcases lt_trichotomy s v with hsv|rfl|hvs + · exact Or.inl hsv + · exact Or.inr ⟨rfl,(add_lt_add_iff_left _).mp h⟩ + · exact False.elim ((not_lt_of_gt (step v w s t hw hvs)) h) + · rintro (hsv|⟨rfl,htw⟩) + · exact step s t v w ht hsv + · exact (add_lt_add_iff_left _).mpr htw + +theorem productValue_relation (a b : Ordinal.{u}) (x : ZFSet.{u}) + (hx : x ∈ ZFSet.prod b.toZFSet a.toZFSet) (y : ZFSet.{u}) + (hy : y ∈ ZFSet.prod b.toZFSet a.toZFSet) : + ZFSet.pair x y ∈ productRelation a.toZFSet b.toZFSet ↔ + productValue a x ∈ productValue a y := by + rw [pair_mem_productRelation,and_iff_right hx,and_iff_right hy] + obtain ⟨s,hs,t,ht,rfl⟩ := ZFSet.mem_prod.mp hx + obtain ⟨v,hv,w,hw,rfl⟩ := ZFSet.mem_prod.mp hy + rw [productLess_pair] + simp only [hs,ht,hv,hw,true_and,productValue_pair] + obtain ⟨s,hs,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hs + obtain ⟨t,ht,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ht + obtain ⟨v,hv,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hv + obtain ⟨w,hw,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hw + simp only [Ordinal.rank_toZFSet,Ordinal.toZFSet_mem_toZFSet_iff,Ordinal.toZFSet_injective.eq_iff] + exact (productValue_lt_iff a s t v w (Ordinal.toZFSet_mem_toZFSet_iff.mp ht) (Ordinal.toZFSet_mem_toZFSet_iff.mp hw)).symm + +theorem productRelation_wellFounded (a b : Ordinal.{u}) : + WellFounded (Rel (ZFSet.prod b.toZFSet a.toZFSet) (productRelation a.toZFSet b.toZFSet)) := by + apply (InvImage.wf (productValue a) ZFSet.mem_wf).mono + intro x y h + exact (productValue_relation a b x h.1 y (right_mem (productRelation_on _ _) h.2)).mp h.2 + +theorem productRelation_transitive (a b : Ordinal.{u}) : + TransitiveOn (ZFSet.prod b.toZFSet a.toZFSet) (productRelation a.toZFSet b.toZFSet) := by + intro x hx y hy z hz hxy hyz + apply (productValue_relation a b x hx z hz).mpr + exact ((ZFSet.isOrdinal_toZFSet (a*b)).mem (productValue_mem a b z hz)).subset_of_mem + ((productValue_relation a b y hy z hz).mp hyz) ((productValue_relation a b x hx y hy).mp hxy) + +theorem product_orderType (a b : Ordinal.{u}) : + orderType (ZFSet.prod b.toZFSet a.toZFSet) (productRelation a.toZFSet b.toZFSet) + (productRelation_wellFounded a b) = a*b := + orderType_of_ordinal_presentation _ _ _ _ (productValue a) + (productValue_mem a b) (productValue_surjective a b) (productValue_relation a b) + +theorem ordinal_mul_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a b : Ordinal.{u}) (ha : a.toZFSet ∈ M) (hb : b.toZFSet ∈ M) : + (a*b).toZFSet ∈ M ∧ ∃ f ∈ M, + Presents (ZFSet.prod b.toZFSet a.toZFSet) f (productValue a) ∧ + OrderTypeCertificate (ZFSet.prod b.toZFSet a.toZFSet) + (productRelation a.toZFSet b.toZFSet) (a*b).toZFSet f := + ordinal_internal_of_presentation M _ _ _ hM hT + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hb ha) + (productRelation_mem M _ _ hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded ha hb) + (productRelation_on _ _) (productValue a) (productValue_mem a b) + (productValue_surjective a b) (productValue_relation a b) + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductReplacement.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..62b93f14a3ea1c5e9f1cbf20e3b34ee9aa63ab80 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductReplacement.lean @@ -0,0 +1,91 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalProductClosure + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel +universe u + +def productSigma : SigmaFormula := + .existsSet (.existsSet (.existsSet (.bounded (productMatrix 3 4 5 2 1 0)))) + +theorem productSigma_sentence : fromSigma productSigma = productSentence := rfl + +theorem productSigma_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (a b : Ordinal.{u}) + (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) : + productSigma.Realize M e ↔ e 0 = (a*b).toZFSet := by + rw [← sigma_sat,productSigma_sentence] + exact productSentence_sourceT M hM hT e he a b ha hb + +def multiplePairSigma : SigmaFormula := + .existsSet (.conj (.bounded (.orderedPair 1 2 0)) + (productSigma.rename (fun i => if i = 0 then 0 else if i = 1 then 3 else 2))) + +theorem multiplePairSigma_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a c : Ordinal.{u}) (ha : a.toZFSet ∈ M) (hc : c.toZFSet ∈ M) + (y : ZFSet.{u}) (hy : y ∈ M) : + multiplePairSigma.Realize M (cons y (cons c.toZFSet (fun _ => a.toZFSet))) ↔ + y = ZFSet.pair c.toZFSet (a*c).toZFSet := by + change (∃ v ∈ M, (SigmaFormula.conj _ _).Realize M + (cons v (cons y (cons c.toZFSet (fun _ => a.toZFSet))))) ↔ _ + have sem (v : ZFSet.{u}) (hv : v ∈ M) : + (SigmaFormula.conj (.bounded (.orderedPair 1 2 0)) + (productSigma.rename (fun i => if i = 0 then 0 else if i = 1 then 3 else 2))).Realize M + (cons v (cons y (cons c.toZFSet (fun _ => a.toZFSet)))) ↔ + y = ZFSet.pair c.toZFSet v ∧ v = (a*c).toZFSet := by + rw [SigmaFormula.realize_conj] + apply and_congr + · change (Formula.orderedPair 1 2 0).Realize M _ ↔ _ + rw [Formula.absolute _ M hM _ (by + intro i; rcases i with _|_|_|i <;> assumption),Formula.eval_orderedPair] + rfl + · rw [SigmaFormula.realize_rename] + exact productSigma_sourceT M hM hT _ (by + intro i + change cons v (cons y (cons c.toZFSet (fun _ => a.toZFSet))) + (if i = 0 then 0 else if i = 1 then 3 else 2) ∈ M + split; exact hv + split; exact ha + exact hc) a c rfl rfl + constructor + · rintro ⟨v,hv,h⟩ + obtain ⟨he,rfl⟩ := (sem v hv).mp h + exact he + · intro h + have hv := (ordinal_mul_internal M hM hT a c ha hc).1 + exact ⟨_,hv,(sem _ hv).mpr ⟨h,rfl⟩⟩ + +theorem ordinal_multiple_graph_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a b : Ordinal.{u}) (ha : a.toZFSet ∈ M) (hb : b.toZFSet ∈ M) : + ∃ f ∈ M, ∀ z : ZFSet.{u}, z ∈ f ↔ + ∃ c < b, z = ZFSet.pair c.toZFSet (a*c).toZFSet := by + let pairAt := fun c : Ordinal.{u} => ZFSet.pair c.toZFSet (a*c).toZFSet + have hcM (c : Ordinal.{u}) (hc : c < b) : c.toZFSet ∈ M := + hM _ hb _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hc) + have hpM (c : Ordinal.{u}) (hc : c < b) : pairAt c ∈ M := + orderedPair_mem M hM hT.pairing (hcM c hc) + (ordinal_mul_internal M hM hT a c ha (hcM c hc)).1 + obtain ⟨f,hf,hdef⟩ := hT.replacement.finitePrefix multiplePairSigma (fun _ => a.toZFSet) + (fun _ => ha) b.toZFSet hb (by + intro x hx + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + refine ⟨pairAt c,hpM c hc, + (multiplePairSigma_sourceT M hM hT a c ha (hcM c hc) _ (hpM c hc)).mpr rfl,?_⟩ + intro y hy h + exact (multiplePairSigma_sourceT M hM hT a c ha (hcM c hc) y hy).mp h) + refine ⟨f,hf,?_⟩ + intro z + constructor + · intro hz + have hzM := hM _ hf _ hz + obtain ⟨x,hx,hp⟩ := (hdef z hzM).mp hz + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + exact ⟨c,hc,(multiplePairSigma_sourceT M hM hT a c ha (hcM c hc) z hzM).mp hp⟩ + · rintro ⟨c,hc,rfl⟩ + exact (hdef _ (hpM c hc)).mpr ⟨c.toZFSet,Ordinal.toZFSet_mem_toZFSet_iff.mpr hc, + (multiplePairSigma_sourceT M hM hT a c ha (hcM c hc) _ (hpM c hc)).mpr rfl⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductSets.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductSets.lean new file mode 100644 index 0000000000000000000000000000000000000000..a1ec2fdfadb9b8be43bbbe05e4794a4cdf5ef637 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductSets.lean @@ -0,0 +1,81 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalOrderPresentation + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse +universe u + +def ProductLess (a b x y : ZFSet.{u}) : Prop := + ∃ s ∈ b, ∃ t ∈ a, ∃ v ∈ b, ∃ w ∈ a, + x = ZFSet.pair s t ∧ y = ZFSet.pair v w ∧ (s ∈ v ∨ (s = v ∧ t ∈ w)) + +noncomputable def productRelation (a b : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun p => ∃ x ∈ ZFSet.prod b a, ∃ y ∈ ZFSet.prod b a, + p = ZFSet.pair x y ∧ ProductLess a b x y) + (ZFSet.prod (ZFSet.prod b a) (ZFSet.prod b a)) + +theorem productRelation_on (a b : ZFSet.{u}) : + On (ZFSet.prod b a) (productRelation a b) := fun _ h => (ZFSet.mem_sep.mp h).1 + +theorem pair_mem_productRelation (a b x y : ZFSet.{u}) : + ZFSet.pair x y ∈ productRelation a b ↔ + x ∈ ZFSet.prod b a ∧ y ∈ ZFSet.prod b a ∧ ProductLess a b x y := by + rw [productRelation,ZFSet.mem_sep] + constructor + · rintro ⟨_,s,hs,t,ht,he,h⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hs,ht,h⟩ + · rintro ⟨hx,hy,h⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨x,hx,y,hy,rfl⟩,x,hx,y,hy,rfl,h⟩ + +theorem productLess_pair (a b s t v w : ZFSet.{u}) : + ProductLess a b (ZFSet.pair s t) (ZFSet.pair v w) ↔ + s ∈ b ∧ t ∈ a ∧ v ∈ b ∧ w ∈ a ∧ (s ∈ v ∨ (s = v ∧ t ∈ w)) := by + simp only [ProductLess,ZFSet.pair_inj] + constructor + · rintro ⟨s',hs,t',ht,v',hv,w',hw,⟨rfl,rfl⟩,⟨rfl,rfl⟩,h⟩ + exact ⟨hs,ht,hv,hw,h⟩ + · rintro ⟨hs,ht,hv,hw,h⟩ + exact ⟨s,hs,t,ht,v,hv,w,hw,⟨rfl,rfl⟩,⟨rfl,rfl⟩,h⟩ + +def productLessFormula (a b x y : ℕ) : Formula := + .existsMem b (.existsMem (a+1) (.existsMem (b+2) (.existsMem (a+3) + (.conj (.orderedPair (x+4) 3 2) (.conj (.orderedPair (y+4) 1 0) + (.disj (.member 3 1) (.conj (.equal 3 1) (.member 2 0)))))))) + +theorem productLessFormula_eval (a b x y : ℕ) (e : ℕ → ZFSet.{u}) : + (productLessFormula a b x y).Eval e ↔ ProductLess (e a) (e b) (e x) (e y) := by + simp [productLessFormula,Formula.Eval,ProductLess] + +def productRelationFormula : Formula := + .existsMem 1 (.existsMem 2 (.conj (.orderedPair 2 1 0) + (productLessFormula 4 5 1 0))) + +theorem productRelationFormula_eval (a b p : ZFSet.{u}) : + productRelationFormula.Eval (cons p (cons (ZFSet.prod b a) (cons a (fun _ => b)))) ↔ + ∃ x ∈ ZFSet.prod b a, ∃ y ∈ ZFSet.prod b a, + p = ZFSet.pair x y ∧ ProductLess a b x y := by + simp [productRelationFormula,Formula.Eval,productLessFormula_eval] + +theorem productRelation_mem (M a b : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (ha : a ∈ M) (hb : b ∈ M) : productRelation a b ∈ M := by + have hd := product_mem M hM hP hU hPow hS hb ha + let e := cons (ZFSet.prod b a) (cons a (fun _ => b)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i + · exact hd + · exact ha + · exact hb + have hs := sep_mem M hM hS productRelationFormula e he + (product_mem M hM hP hU hPow hS hd hd) + have eq : ZFSet.sep (fun p => productRelationFormula.Eval (cons p e)) + (ZFSet.prod (ZFSet.prod b a) (ZFSet.prod b a)) = productRelation a b := by + apply ZFSet.ext; intro p + simp only [productRelation,ZFSet.mem_sep,e,productRelationFormula_eval] + exact eq ▸ hs + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..db8ba4712a409da227fcd5ba7d2213fdb19ccdd2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalProductSyntax.lean @@ -0,0 +1,135 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalProductPresentation + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel +universe u + +def productDomainMatrix (d a b : ℕ) : Formula := + .conj (.allMem d (.existsMem (b+1) (.existsMem (a+2) (.orderedPair 2 1 0)))) + (.allMem b (.allMem (a+1) (.pairMem 1 0 (d+2)))) + +theorem productDomainMatrix_eval (d a b : ℕ) (e : ℕ → ZFSet.{u}) : + (productDomainMatrix d a b).Eval e ↔ e d = ZFSet.prod (e b) (e a) := by + simp only [productDomainMatrix,Formula.Eval,Formula.eval_allMem, + Formula.eval_orderedPair,Formula.eval_pairMem,cons_zero,cons_succ] + constructor + · rintro ⟨hsub,hsup⟩ + apply ZFSet.ext; intro x + constructor + · intro hx; exact ZFSet.mem_prod.mpr (hsub x hx) + · intro hx + obtain ⟨s,hs,t,ht,rfl⟩ := ZFSet.mem_prod.mp hx + exact hsup s hs t ht + · intro heq + rw [heq] + exact ⟨fun x hx => ZFSet.mem_prod.mp hx, + fun s hs t ht => ZFSet.mem_prod.mpr ⟨s,hs,t,ht,rfl⟩⟩ + +def productRelationMatrix (r d a b : ℕ) : Formula := + .conj (.allMem r (.existsMem (d+1) (.existsMem (d+2) + (.conj (.orderedPair 2 1 0) (productLessFormula (a+3) (b+3) 1 0))))) + (.allMem d (.allMem (d+1) (.imp (productLessFormula (a+2) (b+2) 1 0) + (.pairMem 1 0 (r+2))))) + +theorem productRelationMatrix_eval (r d a b : ℕ) (e : ℕ → ZFSet.{u}) + (hd : e d = ZFSet.prod (e b) (e a)) : + (productRelationMatrix r d a b).Eval e ↔ e r = productRelation (e a) (e b) := by + simp only [productRelationMatrix,Formula.Eval,Formula.eval_allMem,Formula.eval_orderedPair, + Formula.eval_imp,Formula.eval_pairMem,cons_zero,cons_succ] + have h3 (x y p : ZFSet.{u}) := productLessFormula_eval (a+3) (b+3) 1 0 + (cons y (cons x (cons p e))) + have h2 (x y : ZFSet.{u}) := productLessFormula_eval (a+2) (b+2) 1 0 + (cons y (cons x e)) + simp only [h3,h2,cons_zero,cons_succ,hd] + constructor + · rintro ⟨hr,hall⟩ + apply ZFSet.ext; intro p + constructor + · intro hp + obtain ⟨x,hx,y,hy,rfl,hxy⟩ := hr p hp + exact (pair_mem_productRelation _ _ _ _).mpr ⟨hx,hy,hxy⟩ + · intro hp + obtain ⟨_,x,hx,y,hy,rfl,hxy⟩ := ZFSet.mem_sep.mp hp + exact hall x hx y hy hxy + · intro heq + rw [heq] + exact ⟨fun p hp => (ZFSet.mem_sep.mp hp).2, + fun x hx y hy hxy => (pair_mem_productRelation _ _ _ _).mpr ⟨hx,hy,hxy⟩⟩ + +def productMatrix (c a b d r f : ℕ) : Formula := + .conj (productDomainMatrix d a b) + (.conj (productRelationMatrix r d a b) (orderTypeMatrix c d r f)) + +theorem productMatrix_eval (c a b d r f : ℕ) (e : ℕ → ZFSet.{u}) : + (productMatrix c a b d r f).Eval e ↔ + e d = ZFSet.prod (e b) (e a) ∧ e r = productRelation (e a) (e b) ∧ + OrderTypeCertificate (e d) (e r) (e c) (e f) := by + simp only [productMatrix,Formula.Eval,productDomainMatrix_eval] + apply and_congr_right; intro hd + rw [productRelationMatrix_eval r d a b e hd,orderTypeMatrix_eval] + +noncomputable def productSentence : SentenceForm := + .ex (.ex (.ex (fromBounded (productMatrix 3 4 5 2 1 0)))) + +theorem productSentence_bound : productSentence.bound = 3 := by rfl + +theorem productSentence_semantics (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) : + productSentence.Sat (A : Set ZFSet) e ↔ + ∃ d ∈ A, ∃ r ∈ A, ∃ f ∈ A, + d = ZFSet.prod (e 2) (e 1) ∧ r = productRelation (e 1) (e 2) ∧ + OrderTypeCertificate d r (e 0) f := by + change (∃ d ∈ A, ∃ r ∈ A, ∃ f ∈ A, + (fromBounded _).Sat _ (cons f (cons r (cons d e)))) ↔ _ + apply exists_congr; intro d + apply and_congr_right; intro hd + apply exists_congr; intro r + apply and_congr_right; intro hr + apply exists_congr; intro f + apply and_congr_right; intro hf + rw [bounded_sat,Formula.absolute _ A hA _ (by + intro i; rcases i with _|_|_|i <;> simp [cons,he,hd,hr,hf]),productMatrix_eval] + rfl + +theorem productSentence_sound (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) (a b : Ordinal.{u}) + (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) : + productSentence.Sat (A : Set ZFSet) e → e 0 = (a*b).toZFSet := by + intro h + obtain ⟨d,_,r,_,f,_,hd,hr,hc⟩ := (productSentence_semantics A hA e he).mp h + rw [ha,hb] at hd hr + rw [hd,hr] at hc + exact (hc.exact (productRelation_wellFounded a b) (productRelation_transitive a b)).trans + (congrArg Ordinal.toZFSet (product_orderType a b)) + +theorem productSentence_spec_of_certificate (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) (a b : Ordinal.{u}) + (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) + (hd : ZFSet.prod b.toZFSet a.toZFSet ∈ A) + (hr : productRelation a.toZFSet b.toZFSet ∈ A) + (hf : ∃ f ∈ A, OrderTypeCertificate (ZFSet.prod b.toZFSet a.toZFSet) + (productRelation a.toZFSet b.toZFSet) (a*b).toZFSet f) : + productSentence.Sat (A : Set ZFSet) e ↔ e 0 = (a*b).toZFSet := by + refine ⟨productSentence_sound A hA e he a b ha hb,?_⟩ + intro hc + obtain ⟨f,hf,hcert⟩ := hf + apply (productSentence_semantics A hA e he).mpr + exact ⟨_,hd,_,hr,f,hf,by rw [ha,hb],by rw [ha,hb],hc ▸ hcert⟩ + +theorem productSentence_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (a b : Ordinal.{u}) + (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) : + productSentence.Sat (M : Set ZFSet) e ↔ e 0 = (a*b).toZFSet := by + have haM : a.toZFSet ∈ M := ha ▸ he 1 + have hbM : b.toZFSet ∈ M := hb ▸ he 2 + obtain ⟨_,f,hf,_,hc⟩ := ordinal_mul_internal M hM hT a b haM hbM + exact productSentence_spec_of_certificate M hM e he a b ha hb + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hbM haM) + (productRelation_mem M _ _ hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded haM hbM) + ⟨f,hf,hc⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumClosure.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d0ecdf94dcfcb40f487d384d2fafc22f9deb393 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumClosure.lean @@ -0,0 +1,57 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalSumSyntax + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel +universe u + +theorem ordinal_add_internal_schemas (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (h0 : (∅ : ZFSet.{u}) ∈ M) + (a b : Ordinal.{u}) (ha : a.toZFSet ∈ M) (hb : b.toZFSet ∈ M) : + (a+b).toZFSet ∈ M ∧ ∃ f ∈ M, + OrderTypeCertificate (sumDomain a.toZFSet b.toZFSet) + (sumRelation a.toZFSet b.toZFSet) (a+b).toZFSet f := by + obtain ⟨hc,f,hf,hg,ho⟩ := orderType_internal M _ _ hM hP hU hPow hS hR + (sumDomain_mem M _ _ hM hP hU hPow hS h0 ha hb) + (sumRelation_mem M _ _ hM hP hU hPow hS h0 ha hb) + (sumRelation_wellFounded a b) (sumRelation_transitive a b) + rw [sum_orderType] at hc hg ho + exact ⟨hc,f,hf,ZFSet.isOrdinal_toZFSet _,hg,ho⟩ + +theorem ordinal_mul_nat_internal_schemas (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (h0 : (∅ : ZFSet.{u}) ∈ M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) (n : ℕ) : (a*n).toZFSet ∈ M := by + induction n with + | zero => simpa using h0 + | succ n ih => + simpa only [Nat.cast_add_one,mul_add_one] using + (ordinal_add_internal_schemas M hM hP hU hPow hS hR h0 (a*n) a ih ha).1 + +theorem ordinal_mul_two_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) : (a*2).toZFSet ∈ M := by + rw [Ordinal.mul_two] + exact (ordinal_add_internal M hM hT a a ha ha).1 + +noncomputable def doubleSentence : SentenceForm := + sumSentence.rename (fun i => if i = 0 then 0 else 1) + +theorem doubleSentence_bound : doubleSentence.bound = 2 := by rfl + +theorem doubleSentence_sound (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) (a : Ordinal.{u}) (ha : e 1 = a.toZFSet) : + doubleSentence.Sat (A : Set ZFSet) e → e 0 = (a*2).toZFSet := by + rw [doubleSentence,SentenceForm.sat_rename,Ordinal.mul_two] + exact sumSentence_sound A hA _ (fun i => he _) a a ha ha + +theorem doubleSentence_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (a : Ordinal.{u}) (ha : e 1 = a.toZFSet) : + doubleSentence.Sat (M : Set ZFSet) e ↔ e 0 = (a*2).toZFSet := by + rw [doubleSentence,SentenceForm.sat_rename,Ordinal.mul_two] + exact sumSentence_sourceT M hM hT _ (fun i => he _) a a ha ha + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumLevels.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumLevels.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ce8ad66934cd61e5df23ded35ee5e4aa8961d3c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumLevels.lean @@ -0,0 +1,75 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalSumClosure +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalOrderTypeLevels + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +theorem ordinal_add_relative (M R : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hR : R ∈ M) (a b : Ordinal.{u}) + (ha : a.toZFSet ∈ relativeModel M R) (hb : b.toZFSet ∈ relativeModel M R) : + (a+b).toZFSet ∈ relativeModel M R ∧ ∃ f ∈ relativeModel M R, + OrderTypeCertificate (sumDomain a.toZFSet b.toZFSet) + (sumRelation a.toZFSet b.toZFSet) (a+b).toZFSet f := + ordinal_add_internal_schemas _ (relativeModel_transitive M R hM) + (relativeModel_pairing M R hM hT hR) (relativeModel_union M R hM hT hR) + (relativeModel_power_set M R hM hT hR) (relativeModel_bounded_separation M R hM hT hR) + (relativeModel_sigma_replacement M R hM hT hR) + ((mem_relativeModel M R _ hM hT hR).mpr (empty_in_relativeModel M R hM hT)) a b ha hb + +theorem sum_sentence_at_levels (M R : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hR : R ∈ M) (a b : Ordinal.{u}) + (ha : a.toZFSet ∈ relativeModel M R) (hb : b.toZFSet ∈ relativeModel M R) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ ∀ δ : Ordinal.{u}, γ ≤ δ → + a.toZFSet ∈ level R δ ∧ b.toZFSet ∈ level R δ ∧ (a+b).toZFSet ∈ level R δ ∧ + (∃ f ∈ level R δ, OrderTypeCertificate (sumDomain a.toZFSet b.toZFSet) + (sumRelation a.toZFSet b.toZFSet) (a+b).toZFSet f) ∧ + ∀ z ∈ level R δ, sumSentence.Sat (level R δ : Set ZFSet) + (cons z (cons a.toZFSet (fun _ => b.toZFSet))) ↔ z = (a+b).toZFSet := by + let N := relativeModel M R + have hN := relativeModel_transitive M R hM + have hP := relativeModel_pairing M R hM hT hR + have hU := relativeModel_union M R hM hT hR + have hPow := relativeModel_power_set M R hM hT hR + have hS := relativeModel_bounded_separation M R hM hT hR + have h0 : (∅ : ZFSet.{u}) ∈ N := + (mem_relativeModel M R _ hM hT hR).mpr (empty_in_relativeModel M R hM hT) + have h1 := singleton_mem N hN hP h0 + have hd := sumDomain_mem N _ _ hN hP hU hPow hS h0 ha hb + have hr := sumRelation_mem N _ _ hN hP hU hPow hS h0 ha hb + obtain ⟨hc,f,hf,hcert⟩ := ordinal_add_relative M R hM hT hR a b ha hb + let e := cons a.toZFSet (cons b.toZFSet (cons (a+b).toZFSet + (cons (sumDomain a.toZFSet b.toZFSet) (cons (sumRelation a.toZFSet b.toZFSet) + (cons ∅ (cons ({∅} : ZFSet.{u}) (fun _ => f))))))) + have he (i : ℕ) : e i ∈ N := by + rcases i with _|_|_|_|_|_|_|i + · exact ha + · exact hb + · exact hc + · exact hd + · exact hr + · exact h0 + · exact h1 + · exact hf + obtain ⟨γ,hγ,hγe⟩ := finite_parameters_in_relative_level M R hM hT e 8 + (fun i _ => (mem_relativeModel M R _ hM hT hR).mp (he i)) + refine ⟨γ,hγ,?_⟩ + intro δ hδ + have hL (i : ℕ) (hi : i < 8) : e i ∈ level R δ := level_mono R hδ (hγe i hi) + refine ⟨hL 0 (by omega),hL 1 (by omega),hL 2 (by omega), + ⟨f,hL 7 (by omega),hcert⟩,?_⟩ + intro z hz + exact sumSentence_spec_of_certificate (level R δ) (level_transitive R δ) + (cons z (cons a.toZFSet (fun _ => b.toZFSet))) + (by intro i; rcases i with _|_|i + · exact hz + · exact hL 0 (by omega) + · exact hL 1 (by omega)) a b rfl rfl + (hL 5 (by omega)) (hL 6 (by omega)) (hL 3 (by omega)) (hL 4 (by omega)) + ⟨f,hL 7 (by omega),hcert⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumPresentation.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..279095ae7e08d50dacd0655c8ae8761e978b849b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumPresentation.lean @@ -0,0 +1,126 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalSumSets + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse +universe u + +theorem rightNode_ne_leftNode (x y : ZFSet.{u}) : rightNode x ≠ leftNode y := + (leftNode_ne_rightNode y x).symm + +attribute [local simp] leftNode_inj rightNode_inj leftNode_ne_rightNode rightNode_ne_leftNode + +theorem sumLess_left_left (a b s t : ZFSet.{u}) : + SumLess a b (leftNode s) (leftNode t) ↔ s ∈ a ∧ t ∈ a ∧ s ∈ t := by + simp [SumLess] + +theorem sumLess_left_right (a b s t : ZFSet.{u}) : + SumLess a b (leftNode s) (rightNode t) ↔ s ∈ a ∧ t ∈ b := by + simp [SumLess] + +theorem sumLess_right_left (a b s t : ZFSet.{u}) : + ¬ SumLess a b (rightNode s) (leftNode t) := by + simp [SumLess] + +theorem sumLess_right_right (a b s t : ZFSet.{u}) : + SumLess a b (rightNode s) (rightNode t) ↔ s ∈ b ∧ t ∈ b ∧ s ∈ t := by + simp [SumLess] + +noncomputable def sumValue (a : Ordinal.{u}) (x : ZFSet.{u}) : ZFSet.{u} := by + classical + exact if h : ∃ s, x = leftNode s then h.choose + else if k : ∃ s, x = rightNode s then (a + k.choose.rank).toZFSet else ∅ + +theorem sumValue_left (a : Ordinal.{u}) (s : ZFSet.{u}) : + sumValue a (leftNode s) = s := by + classical + have h : ∃ t, leftNode s = leftNode t := ⟨s,rfl⟩ + simp only [sumValue, dite_eq_left h] + exact (leftNode_inj.mp h.choose_spec).symm + +theorem sumValue_right (a : Ordinal.{u}) (s : ZFSet.{u}) : + sumValue a (rightNode s) = (a+s.rank).toZFSet := by + classical + have h : ¬ ∃ t, rightNode s = leftNode t := by simp + have k : ∃ t, rightNode s = rightNode t := ⟨s,rfl⟩ + simp only [sumValue, dite_eq_right h, dite_eq_left k] + rw [← rightNode_inj.mp k.choose_spec] + +theorem sumValue_mem (a b : Ordinal.{u}) (x : ZFSet.{u}) + (hx : x ∈ sumDomain a.toZFSet b.toZFSet) : sumValue a x ∈ (a+b).toZFSet := by + rcases (mem_sumDomain _ _ _).mp hx with ⟨s,hs,rfl⟩|⟨s,hs,rfl⟩ + · rw [sumValue_left] + exact Ordinal.toZFSet_monotone le_self_add hs + · obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hs + rw [sumValue_right,Ordinal.rank_toZFSet,Ordinal.toZFSet_mem_toZFSet_iff] + exact (add_lt_add_iff_left a).mpr hc + +theorem sumValue_surjective (a b : Ordinal.{u}) (z : ZFSet.{u}) + (hz : z ∈ (a+b).toZFSet) : + ∃ x ∈ sumDomain a.toZFSet b.toZFSet, sumValue a x = z := by + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hz + by_cases h : c < a + · exact ⟨leftNode c.toZFSet,(mem_sumDomain _ _ _).mpr + (Or.inl ⟨c.toZFSet,Ordinal.toZFSet_mem_toZFSet_iff.mpr h,rfl⟩),sumValue_left _ _⟩ + · have hle := le_of_not_gt h + have hb : c-a < b := (Ordinal.sub_lt_of_le hle).mpr hc + refine ⟨rightNode (c-a).toZFSet,(mem_sumDomain _ _ _).mpr + (Or.inr ⟨(c-a).toZFSet,Ordinal.toZFSet_mem_toZFSet_iff.mpr hb,rfl⟩),?_⟩ + rw [sumValue_right,Ordinal.rank_toZFSet,Ordinal.add_sub_cancel_of_le hle] + +theorem sumValue_relation (a b : Ordinal.{u}) (x : ZFSet.{u}) + (hx : x ∈ sumDomain a.toZFSet b.toZFSet) (y : ZFSet.{u}) + (hy : y ∈ sumDomain a.toZFSet b.toZFSet) : + ZFSet.pair x y ∈ sumRelation a.toZFSet b.toZFSet ↔ sumValue a x ∈ sumValue a y := by + rw [pair_mem_sumRelation, and_iff_right hx, and_iff_right hy] + rcases (mem_sumDomain _ _ _).mp hx with ⟨s,hs,rfl⟩|⟨s,hs,rfl⟩ <;> + rcases (mem_sumDomain _ _ _).mp hy with ⟨t,ht,rfl⟩|⟨t,ht,rfl⟩ + · simp only [sumLess_left_left,hs,ht,true_and,sumValue_left] + · rw [sumLess_left_right,sumValue_left,sumValue_right] + exact iff_of_true ⟨hs,ht⟩ (Ordinal.toZFSet_monotone le_self_add hs) + · rw [iff_false_left (sumLess_right_left _ _ _ _),sumValue_right,sumValue_left] + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ht + rw [Ordinal.toZFSet_mem_toZFSet_iff] + exact not_lt_of_ge (hc.le.trans le_self_add) + · rw [sumLess_right_right,sumValue_right,sumValue_right] + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hs + obtain ⟨d,hd,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ht + simp only [Ordinal.toZFSet_mem_toZFSet_iff,hc,hd,true_and,Ordinal.rank_toZFSet, + add_lt_add_iff_left] + +theorem sumRelation_wellFounded (a b : Ordinal.{u}) : + WellFounded (Rel (sumDomain a.toZFSet b.toZFSet) (sumRelation a.toZFSet b.toZFSet)) := by + apply (InvImage.wf (sumValue a) ZFSet.mem_wf).mono + intro x y h + exact (sumValue_relation a b x h.1 y (right_mem (sumRelation_on _ _) h.2)).mp h.2 + +theorem sumRelation_transitive (a b : Ordinal.{u}) : + TransitiveOn (sumDomain a.toZFSet b.toZFSet) (sumRelation a.toZFSet b.toZFSet) := by + intro x hx y hy z hz hxy hyz + apply (sumValue_relation a b x hx z hz).mpr + exact ((ZFSet.isOrdinal_toZFSet (a+b)).mem (sumValue_mem a b z hz)).subset_of_mem + ((sumValue_relation a b y hy z hz).mp hyz) ((sumValue_relation a b x hx y hy).mp hxy) + +theorem sum_orderType (a b : Ordinal.{u}) : + orderType (sumDomain a.toZFSet b.toZFSet) (sumRelation a.toZFSet b.toZFSet) + (sumRelation_wellFounded a b) = a+b := + orderType_of_ordinal_presentation _ _ _ _ (sumValue a) + (sumValue_mem a b) (sumValue_surjective a b) (sumValue_relation a b) + +theorem ordinal_add_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a b : Ordinal.{u}) (ha : a.toZFSet ∈ M) (hb : b.toZFSet ∈ M) : + (a+b).toZFSet ∈ M ∧ ∃ f ∈ M, + Presents (sumDomain a.toZFSet b.toZFSet) f (sumValue a) ∧ + OrderTypeCertificate (sumDomain a.toZFSet b.toZFSet) + (sumRelation a.toZFSet b.toZFSet) (a+b).toZFSet f := by + have h0 := hM _ (omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity) _ ZFSet.omega_zero + exact ordinal_internal_of_presentation M _ _ _ hM hT + (sumDomain_mem M _ _ hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded h0 ha hb) + (sumRelation_mem M _ _ hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded h0 ha hb) + (sumRelation_on _ _) (sumValue a) (sumValue_mem a b) + (sumValue_surjective a b) (sumValue_relation a b) + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumSets.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumSets.lean new file mode 100644 index 0000000000000000000000000000000000000000..bed4fbee4e5f6daa37b1bea9a2d522764e327a39 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumSets.lean @@ -0,0 +1,128 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalOrderPresentation + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse +universe u + +def leftNode (x : ZFSet.{u}) : ZFSet.{u} := ZFSet.pair ∅ x +def rightNode (x : ZFSet.{u}) : ZFSet.{u} := ZFSet.pair {∅} x + +theorem leftNode_inj {x y : ZFSet.{u}} : leftNode x = leftNode y ↔ x = y := by + simp [leftNode, ZFSet.pair_inj] + +theorem rightNode_inj {x y : ZFSet.{u}} : rightNode x = rightNode y ↔ x = y := by + simp [rightNode, ZFSet.pair_inj] + +theorem leftNode_ne_rightNode (x y : ZFSet.{u}) : leftNode x ≠ rightNode y := by + intro h + have hz := (ZFSet.pair_inj.mp h).1 + have hm : (∅ : ZFSet.{u}) ∈ ({∅} : ZFSet.{u}) := ZFSet.mem_singleton.mpr rfl + rw [← hz] at hm + exact ZFSet.notMem_empty _ hm + +noncomputable def sumDomain (a b : ZFSet.{u}) : ZFSet.{u} := + ZFSet.prod {∅} a ∪ ZFSet.prod {{∅}} b + +theorem mem_sumDomain (a b x : ZFSet.{u}) : x ∈ sumDomain a b ↔ + (∃ s ∈ a, x = leftNode s) ∨ (∃ t ∈ b, x = rightNode t) := by + simp only [sumDomain, ZFSet.mem_union, ZFSet.mem_prod, ZFSet.mem_singleton, + exists_eq_left, leftNode, rightNode] + +def SumLess (a b x y : ZFSet.{u}) : Prop := + (∃ s ∈ a, ∃ t ∈ a, x = leftNode s ∧ y = leftNode t ∧ s ∈ t) ∨ + (∃ s ∈ a, ∃ t ∈ b, x = leftNode s ∧ y = rightNode t) ∨ + (∃ s ∈ b, ∃ t ∈ b, x = rightNode s ∧ y = rightNode t ∧ s ∈ t) + +noncomputable def sumRelation (a b : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun p => ∃ x ∈ sumDomain a b, ∃ y ∈ sumDomain a b, + p = ZFSet.pair x y ∧ SumLess a b x y) (ZFSet.prod (sumDomain a b) (sumDomain a b)) + +theorem sumRelation_on (a b : ZFSet.{u}) : On (sumDomain a b) (sumRelation a b) := + fun _ h => (ZFSet.mem_sep.mp h).1 + +theorem pair_mem_sumRelation (a b x y : ZFSet.{u}) : + ZFSet.pair x y ∈ sumRelation a b ↔ + x ∈ sumDomain a b ∧ y ∈ sumDomain a b ∧ SumLess a b x y := by + rw [sumRelation, ZFSet.mem_sep] + constructor + · rintro ⟨_,s,hs,t,ht,he,h⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hs,ht,h⟩ + · rintro ⟨hx,hy,h⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨x,hx,y,hy,rfl⟩,x,hx,y,hy,rfl,h⟩ + +def taggedClause (a b t v x y : ℕ) (cmp : Bool) : Formula := + .existsMem a (.existsMem (b+1) + (.conj (.orderedPair (x+2) (t+2) 1) + (.conj (.orderedPair (y+2) (v+2) 0) + (if cmp then .member 1 0 else .equal 0 0)))) + +theorem taggedClause_eval (a b t v x y : ℕ) (cmp : Bool) (e : ℕ → ZFSet.{u}) : + (taggedClause a b t v x y cmp).Eval e ↔ + ∃ s ∈ e a, ∃ q ∈ e b, e x = ZFSet.pair (e t) s ∧ + e y = ZFSet.pair (e v) q ∧ (if cmp then s ∈ q else True) := by + cases cmp <;> simp [taggedClause, Formula.Eval] + +def sumLessFormula (a b z o x y : ℕ) : Formula := + .disj (taggedClause a a z z x y true) + (.disj (taggedClause a b z o x y false) (taggedClause b b o o x y true)) + +theorem sumLessFormula_eval (a b z o x y : ℕ) (e : ℕ → ZFSet.{u}) + (hz : e z = ∅) (ho : e o = {∅}) : + (sumLessFormula a b z o x y).Eval e ↔ SumLess (e a) (e b) (e x) (e y) := by + simp [sumLessFormula, taggedClause_eval, hz, ho, SumLess, leftNode, rightNode] + +def sumRelationFormula : Formula := + .existsMem 1 (.existsMem 2 (.conj (.orderedPair 2 1 0) + (sumLessFormula 4 5 6 7 1 0))) + +theorem sumRelationFormula_eval (a b p : ZFSet.{u}) : + sumRelationFormula.Eval + (cons p (cons (sumDomain a b) (cons a (cons b (cons ∅ (fun _ => {∅})))))) ↔ + ∃ x ∈ sumDomain a b, ∃ y ∈ sumDomain a b, + p = ZFSet.pair x y ∧ SumLess a b x y := by + simp only [sumRelationFormula, Formula.Eval, Formula.eval_orderedPair, + cons_zero, cons_succ] + apply exists_congr; intro x + apply and_congr_right; intro _ + apply exists_congr; intro y + apply and_congr_right; intro _ + apply and_congr_right; intro _ + exact sumLessFormula_eval _ _ _ _ _ _ _ rfl rfl + +theorem sumDomain_mem (M a b : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (h0 : (∅ : ZFSet.{u}) ∈ M) (ha : a ∈ M) (hb : b ∈ M) : + sumDomain a b ∈ M := by + have h1 := singleton_mem M hM hP h0 + exact binary_union_mem M hM hP hU + (product_mem M hM hP hU hPow hS h1 ha) + (product_mem M hM hP hU hPow hS (singleton_mem M hM hP h1) hb) + +theorem sumRelation_mem (M a b : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (h0 : (∅ : ZFSet.{u}) ∈ M) (ha : a ∈ M) (hb : b ∈ M) : + sumRelation a b ∈ M := by + have hd := sumDomain_mem M a b hM hP hU hPow hS h0 ha hb + have h1 := singleton_mem M hM hP h0 + let e := cons (sumDomain a b) (cons a (cons b (cons ∅ (fun _ => {∅})))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hd + rcases i with _|i; exact ha + rcases i with _|i; exact hb + rcases i with _|i; exact h0 + exact h1 + have hs := sep_mem M hM hS sumRelationFormula e he + (product_mem M hM hP hU hPow hS hd hd) + have eq : ZFSet.sep (fun p => sumRelationFormula.Eval (cons p e)) + (ZFSet.prod (sumDomain a b) (sumDomain a b)) = sumRelation a b := by + apply ZFSet.ext; intro p + simp only [sumRelation, ZFSet.mem_sep, e, sumRelationFormula_eval] + exact eq ▸ hs + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd5beefd6d1bf7e0fb309317528c095472219401 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalSumSyntax.lean @@ -0,0 +1,163 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalSumPresentation + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel +universe u + +def nodeMember (a t x : ℕ) : Formula := + .existsMem a (.orderedPair (x+1) (t+1) 0) + +theorem nodeMember_eval (a t x : ℕ) (e : ℕ → ZFSet.{u}) : + (nodeMember a t x).Eval e ↔ ∃ s ∈ e a, e x = ZFSet.pair (e t) s := by + simp [nodeMember,Formula.Eval] + +def sumDomainMatrix (d a b z o : ℕ) : Formula := + .conj (.allMem d (.disj (nodeMember (a+1) (z+1) 0) (nodeMember (b+1) (o+1) 0))) + (.conj (.allMem a (.existsMem (d+1) (.orderedPair 0 (z+2) 1))) + (.allMem b (.existsMem (d+1) (.orderedPair 0 (o+2) 1)))) + +theorem sumDomainMatrix_eval (d a b z o : ℕ) (e : ℕ → ZFSet.{u}) + (hz : e z = ∅) (ho : e o = {∅}) : + (sumDomainMatrix d a b z o).Eval e ↔ e d = sumDomain (e a) (e b) := by + simp only [sumDomainMatrix,Formula.Eval,Formula.eval_allMem,Formula.eval_disj, + nodeMember_eval,Formula.eval_orderedPair,cons_zero,cons_succ,hz,ho] + change ((∀ x ∈ e d, (∃ s ∈ e a, x = leftNode s) ∨ (∃ s ∈ e b, x = rightNode s)) ∧ + (∀ s ∈ e a, ∃ x ∈ e d, x = leftNode s) ∧ + (∀ s ∈ e b, ∃ x ∈ e d, x = rightNode s)) ↔ _ + constructor + · rintro ⟨hd,ha,hb⟩ + apply ZFSet.ext; intro x + rw [mem_sumDomain] + refine ⟨hd x,?_⟩ + rintro (⟨s,hs,rfl⟩|⟨s,hs,rfl⟩) + · obtain ⟨x,hx,rfl⟩ := ha s hs; exact hx + · obtain ⟨x,hx,rfl⟩ := hb s hs; exact hx + · intro heq + rw [heq] + exact ⟨fun x hx => (mem_sumDomain _ _ _).mp hx, + fun s hs => ⟨leftNode s,(mem_sumDomain _ _ _).mpr (Or.inl ⟨s,hs,rfl⟩),rfl⟩, + fun s hs => ⟨rightNode s,(mem_sumDomain _ _ _).mpr (Or.inr ⟨s,hs,rfl⟩),rfl⟩⟩ + +def sumRelationMatrix (r d a b z o : ℕ) : Formula := + .conj (.allMem r (.existsMem (d+1) (.existsMem (d+2) + (.conj (.orderedPair 2 1 0) (sumLessFormula (a+3) (b+3) (z+3) (o+3) 1 0))))) + (.allMem d (.allMem (d+1) (.imp (sumLessFormula (a+2) (b+2) (z+2) (o+2) 1 0) + (.pairMem 1 0 (r+2))))) + +theorem sumRelationMatrix_eval (r d a b z o : ℕ) (e : ℕ → ZFSet.{u}) + (hz : e z = ∅) (ho : e o = {∅}) (hd : e d = sumDomain (e a) (e b)) : + (sumRelationMatrix r d a b z o).Eval e ↔ e r = sumRelation (e a) (e b) := by + simp only [sumRelationMatrix,Formula.Eval,Formula.eval_allMem,Formula.eval_orderedPair, + Formula.eval_imp,Formula.eval_pairMem,cons_zero,cons_succ] + have h3 (x y p : ZFSet.{u}) := sumLessFormula_eval (a+3) (b+3) (z+3) (o+3) 1 0 + (cons y (cons x (cons p e))) (by simpa using hz) (by simpa using ho) + have h2 (x y : ZFSet.{u}) := sumLessFormula_eval (a+2) (b+2) (z+2) (o+2) 1 0 + (cons y (cons x e)) (by simpa using hz) (by simpa using ho) + simp only [h3,h2,cons_zero,cons_succ,hd] + constructor + · rintro ⟨hr,hall⟩ + apply ZFSet.ext; intro p + constructor + · intro hp + obtain ⟨x,hx,y,hy,rfl,hxy⟩ := hr p hp + exact (pair_mem_sumRelation _ _ _ _).mpr ⟨hx,hy,hxy⟩ + · intro hp + obtain ⟨_,x,hx,y,hy,rfl,hxy⟩ := ZFSet.mem_sep.mp hp + exact hall x hx y hy hxy + · intro heq + rw [heq] + exact ⟨fun p hp => (ZFSet.mem_sep.mp hp).2, + fun x hx y hy hxy => (pair_mem_sumRelation _ _ _ _).mpr ⟨hx,hy,hxy⟩⟩ + +def sumMatrix (c a b d r f z o : ℕ) : Formula := + .conj (.allMem z (.neg (.equal 0 0))) + (.conj (.singleton o z) (.conj (sumDomainMatrix d a b z o) + (.conj (sumRelationMatrix r d a b z o) (orderTypeMatrix c d r f)))) + +theorem sumMatrix_eval (c a b d r f z o : ℕ) (e : ℕ → ZFSet.{u}) : + (sumMatrix c a b d r f z o).Eval e ↔ + e z = ∅ ∧ e o = {∅} ∧ e d = sumDomain (e a) (e b) ∧ + e r = sumRelation (e a) (e b) ∧ + OrderTypeCertificate (e d) (e r) (e c) (e f) := by + have hempty : (Formula.allMem z (.neg (.equal 0 0))).Eval e ↔ e z = ∅ := by + simp only [Formula.eval_allMem,Formula.Eval,not_true_eq_false,imp_false] + exact ⟨fun h => ZFSet.ext (fun x => by simp [h x]),fun h x => h ▸ ZFSet.notMem_empty x⟩ + simp only [sumMatrix,Formula.Eval,hempty,Formula.eval_singleton] + apply and_congr_right; intro hz + rw [hz] + apply and_congr_right; intro ho + rw [sumDomainMatrix_eval d a b z o e hz ho] + apply and_congr_right; intro hd + rw [sumRelationMatrix_eval r d a b z o e hz ho hd,orderTypeMatrix_eval] + +noncomputable def sumSentence : SentenceForm := + .ex (.ex (.ex (.ex (.ex (fromBounded (sumMatrix 5 6 7 4 3 2 1 0)))))) + +theorem sumSentence_bound : sumSentence.bound = 3 := by rfl + +theorem sumSentence_semantics (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) : + sumSentence.Sat (A : Set ZFSet) e ↔ + ∃ d ∈ A, ∃ r ∈ A, ∃ f ∈ A, ∃ z ∈ A, ∃ o ∈ A, + z = ∅ ∧ o = {∅} ∧ d = sumDomain (e 1) (e 2) ∧ + r = sumRelation (e 1) (e 2) ∧ OrderTypeCertificate d r (e 0) f := by + change (∃ d ∈ A, ∃ r ∈ A, ∃ f ∈ A, ∃ z ∈ A, ∃ o ∈ A, + (fromBounded _).Sat _ (cons o (cons z (cons f (cons r (cons d e)))))) ↔ _ + apply exists_congr; intro d + apply and_congr_right; intro hd + apply exists_congr; intro r + apply and_congr_right; intro hr + apply exists_congr; intro f + apply and_congr_right; intro hf + apply exists_congr; intro z + apply and_congr_right; intro hz + apply exists_congr; intro o + apply and_congr_right; intro ho + rw [bounded_sat,Formula.absolute _ A hA _ (by + intro i; rcases i with _|_|_|_|_|i <;> simp [cons,he,hd,hr,hf,hz,ho]),sumMatrix_eval] + rfl + +theorem sumSentence_sound (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) (a b : Ordinal.{u}) + (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) : + sumSentence.Sat (A : Set ZFSet) e → e 0 = (a+b).toZFSet := by + intro h + obtain ⟨d,_,r,_,f,_,z,_,o,_,_,_,hd,hr,hc⟩ := (sumSentence_semantics A hA e he).mp h + rw [ha,hb] at hd hr + rw [hd,hr] at hc + exact (hc.exact (sumRelation_wellFounded a b) (sumRelation_transitive a b)).trans + (congrArg Ordinal.toZFSet (sum_orderType a b)) + +theorem sumSentence_spec_of_certificate (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) (a b : Ordinal.{u}) + (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) + (h0 : (∅ : ZFSet.{u}) ∈ A) (h1 : ({∅} : ZFSet.{u}) ∈ A) + (hd : sumDomain a.toZFSet b.toZFSet ∈ A) (hr : sumRelation a.toZFSet b.toZFSet ∈ A) + (hf : ∃ f ∈ A, OrderTypeCertificate (sumDomain a.toZFSet b.toZFSet) + (sumRelation a.toZFSet b.toZFSet) (a+b).toZFSet f) : + sumSentence.Sat (A : Set ZFSet) e ↔ e 0 = (a+b).toZFSet := by + refine ⟨sumSentence_sound A hA e he a b ha hb,?_⟩ + intro hc + obtain ⟨f,hf,hcert⟩ := hf + apply (sumSentence_semantics A hA e he).mpr + exact ⟨_,hd,_,hr,f,hf,∅,h0,{∅},h1,rfl,rfl,by rw [ha,hb],by rw [ha,hb],hc ▸ hcert⟩ + +theorem sumSentence_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (a b : Ordinal.{u}) + (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) : + sumSentence.Sat (M : Set ZFSet) e ↔ e 0 = (a+b).toZFSet := by + have haM : a.toZFSet ∈ M := ha ▸ he 1 + have hbM : b.toZFSet ∈ M := hb ▸ he 2 + have h0 := hM _ (omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity) _ ZFSet.omega_zero + obtain ⟨_,f,hf,_,hc⟩ := ordinal_add_internal M hM hT a b haM hbM + exact sumSentence_spec_of_certificate M hM e he a b ha hb h0 + (singleton_mem M hM hT.pairing h0) + (sumDomain_mem M _ _ hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded h0 haM hbM) + (sumRelation_mem M _ _ hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded h0 haM hbM) + ⟨f,hf,hc⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalVectorRecovery.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalVectorRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f2f6fc469bd7ed04497903c80f0dd30cfd25f32 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalVectorRecovery.lean @@ -0,0 +1,42 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalVectorSyntax + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem vectorCodeSentence_recovers (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (n : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (v : Fin n → Ordinal.{u}) (hc : e 0 = (vectorCode v).toZFSet) + (hp : (vectorCodeSentence n).Sat (M : Set ZFSet) e) : + ∀ i, e (i.val+1) = (v i).toZFSet := by + induction n generalizing e with + | zero => intro i; exact Fin.elim0 i + | succ n ih => + obtain ⟨t,ht,hpair,hrest⟩ := hp + rw [SentenceForm.sat_rename] at hpair hrest + have hrec := pairCodeSentence_recovers M hM hω + (fun i => cons t e (if i = 0 then 1 else if i = 1 then 2 else 0)) (fun i => by + split; exact he 0 + split; exact he 1 + exact ht) (v 0) (vectorCode (fun i => v i.succ)) hc hpair + have hh : e 1 = (v 0).toZFSet := hrec.1 + have htcode : t = (vectorCode (fun i => v i.succ)).toZFSet := hrec.2 + have htail := ih (fun i => cons t e (vectorTailSlots i)) (fun i => by + cases i; exact ht; exact he _) (fun i => v i.succ) htcode hrest + intro i + exact Fin.cases hh (fun j => htail j) i + +theorem vectorCodeSentence_recognition (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (n : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (v : Fin n → Ordinal.{u}) (hc : e 0 = (vectorCode v).toZFSet) : + (vectorCodeSentence n).Sat (M : Set ZFSet) e ↔ ∀ i, e (i.val+1) = (v i).toZFSet := by + refine ⟨vectorCodeSentence_recovers M hM + (omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity) n e he v hc,?_⟩ + intro hv + exact (vectorCodeSentence_sourceT M hM hT n e he v hv).mpr hc + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalVectorSyntax.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalVectorSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..9aaf38d59775da260768aa5a0d55402420e5da8a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/OrdinalVectorSyntax.lean @@ -0,0 +1,86 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalPairSyntax + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +def vectorTailSlots : ℕ → ℕ + | 0 => 0 + | i+1 => i+3 + +noncomputable def vectorCodeSentence : ℕ → SentenceForm + | 0 => fromBounded (ordinalOneMatrix 0) + | n+1 => .ex (.conj + (pairCodeSentence.rename (fun i => if i = 0 then 1 else if i = 1 then 2 else 0)) + ((vectorCodeSentence n).rename vectorTailSlots)) + +theorem vectorCodeSentence_bound (n : ℕ) : (vectorCodeSentence n).bound ≤ n+1 := by + induction n with + | zero => exact Nat.le_refl _ + | succ n ih => + have hp := code_rename_bound pairCodeSentence + (fun i => if i = 0 then 1 else if i = 1 then 2 else 0) 3 (by + intro i _; split <;> (try split) <;> omega) + have ht := code_rename_bound (vectorCodeSentence n) vectorTailSlots (n+3) (by + intro i hi + cases i with + | zero => simp [vectorTailSlots] + | succ i => change i+3 < n+3; omega) + change max _ _ - 1 ≤ n+1+1 + omega + +theorem vectorCodeSentence_sound (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (n : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (v : Fin n → Ordinal.{u}) (hv : ∀ i, e (i.val+1) = (v i).toZFSet) : + (vectorCodeSentence n).Sat (M : Set ZFSet) e → e 0 = (vectorCode v).toZFSet := by + induction n generalizing e with + | zero => + rw [vectorCodeSentence,bounded_sat,Formula.absolute _ M hM e he,ordinalOneMatrix_eval] + exact id + | succ n ih => + rintro ⟨t,ht,hp,hrest⟩ + rw [SentenceForm.sat_rename] at hp hrest + have htail := ih _ (fun i => by + cases i; exact ht; exact he _) (fun i => v i.succ) (fun i => hv i.succ) hrest + have hpair := pairCodeSentence_sound M hM hω _ (fun i => by + split; exact he 0 + split; exact he 1 + exact ht) hp + have hh : e 1 = (v 0).toZFSet := hv 0 + change t = (vectorCode (fun i => v i.succ)).toZFSet at htail + have hpval : e 0 = (pairCode (e 1).rank t.rank).toZFSet := hpair.2.2 + simpa only [hh,htail,Ordinal.rank_toZFSet,vectorCode] using hpval + +theorem vectorCodeSentence_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (n : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (v : Fin n → Ordinal.{u}) (hv : ∀ i, e (i.val+1) = (v i).toZFSet) : + (vectorCodeSentence n).Sat (M : Set ZFSet) e ↔ e 0 = (vectorCode v).toZFSet := by + have hω := omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity + refine ⟨vectorCodeSentence_sound M hM hω n e he v hv,?_⟩ + induction n generalizing e with + | zero => + intro hc + rw [vectorCodeSentence,bounded_sat,Formula.absolute _ M hM e he,ordinalOneMatrix_eval] + exact hc + | succ n ih => + intro hc + let t := (vectorCode (fun i => v i.succ)).toZFSet + have ht : t ∈ M := vectorCode_internal M hM hT _ (fun i => hv i.succ ▸ he _) + refine ⟨t,ht,?_,?_⟩ + · rw [SentenceForm.sat_rename] + apply (pairCodeSentence_sourceT M hM hT _ (fun i => by + split; exact he 0 + split; exact he 1 + exact ht)).mpr + change (e 1).IsOrdinal ∧ t.IsOrdinal ∧ e 0 = (pairCode (e 1).rank t.rank).toZFSet + have hh : e 1 = (v 0).toZFSet := hv 0 + rw [hh] + exact ⟨ZFSet.isOrdinal_toZFSet _,ZFSet.isOrdinal_toZFSet _,by simpa [t,vectorCode] using hc⟩ + · rw [SentenceForm.sat_rename] + exact ih _ (fun i => by cases i; exact ht; exact he _) _ (fun i => hv i.succ) rfl + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/PaddedOmegaBoundary.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/PaddedOmegaBoundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..c64acfd36a86a1d1c3b6481779683bb6552e04b4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/PaddedOmegaBoundary.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.LimitOmegaCertificates +import OAI.Computability.DegreeRigidity.OrdinalCodes.SuccessorOmegaCertificates +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalDecoderDomains + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem offset_absorbed_above (s a b : Ordinal.{u}) (ha : s+a=a) (hab : a ≤ b) : s+b=b := by + calc + s+b = s+(a+(b-a)) := by rw [Ordinal.add_sub_cancel_of_le hab] + _ = b := by rw [← add_assoc,ha,Ordinal.add_sub_cancel_of_le hab] + +theorem heightDomainIndex_of_absorbed (a : Ordinal.{u}) (ha : realSeedOffset+a=a) : + heightDomainIndex a = a+1 := by + rw [heightDomainIndex,Ordinal.sub_eq_of_add_eq ha] + +theorem padded_omega_boundary_certificates (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hβ : Order.IsSuccLimit β) (hoff : realSeedOffset+β=β) (hv : vectorCode v ≤ β) + (hpow : ∀ c < β, (Ordinal.omega0 ^ c).toZFSet ∈ level (groundReals M) β ∧ + OmegaPowerCertificates (level (groundReals M) β) c.toZFSet) + (hprod : ProductCertificates + (level (groundReals M) (Ordinal.omega0 ^ (β+1)+1)) (Ordinal.omega0 ^ β) Ordinal.omega0) : + OmegaPowerCertificates + (level (groundReals M) (heightDomainIndex (paddedCode v β))) (β+1).toZFSet := by + let R := groundReals M + let b := Ordinal.omega0 ^ (β+1) + have hβpos : 0 < β := Ordinal.natCast_lt_of_isSuccLimit hβ 0 + have hβb : β < b := (lt_add_one β).trans_le (Ordinal.right_le_opow (β+1) Ordinal.one_lt_omega0) + have hbLimit : Order.IsSuccLimit b := Ordinal.isSuccLimit_opow_left + Ordinal.isSuccLimit_omega0 (ne_of_gt (hβpos.trans (lt_add_one β))) + have hβ3 : β+3 < b := by + have h := hbLimit.succ_lt (hbLimit.succ_lt (hbLimit.succ_lt hβb)) + simpa only [Order.succ_eq_add_one,add_assoc,one_add_one_eq_two, + show (2 : Ordinal.{u})+1=3 by norm_num] using h + have hheight : ordinalHeight (seed R)+β=β := by + rw [ground_seed_offset M hM hT]; exact hoff + have hc := omega_certificates_at_limit_add_three R β hβ hheight + (ground_level_omega_mem M hM hT β) hpow + have hbabs := offset_absorbed_above realSeedOffset β b hoff hβb.le + have hbM : b.toZFSet ∈ level R (b+1) := by + apply (ordinal_mem_level_iff R (b+1) b).mpr + rw [ground_seed_offset M hM hT,← add_assoc,hbabs] + exact lt_add_one b + have hpM : (Ordinal.omega0 ^ β).toZFSet ∈ level R (b+1) := + internal_ordinal_downward _ (level_transitive R (b+1)) hbM + (Ordinal.opow_le_opow_right Ordinal.omega0_pos (le_of_lt (lt_add_one β))) + have hs := omega_certificates_successor_add_five R (b+1) β + (hc.mono (level_mono R (hβ3.le.trans le_self_add))) hpM hbM hprod + have hbcode : b < paddedCode v β := by + change b < pairCode β (vectorCode v) + rw [pairCode,ite_eq_left hv] + simpa only [add_zero] using (add_lt_add_iff_left b).mpr + (Ordinal.opow_pos (vectorCode v) Ordinal.omega0_pos) + have hcodeabs := offset_absorbed_above realSeedOffset β (paddedCode v β) hoff + (padding_lt_paddedCode v β).le + rw [heightDomainIndex_of_absorbed _ hcodeabs] + apply hs.mono (level_mono R ?_) + have hmargin := finite_margin_lt_paddedCode v β b hβpos hbcode 6 + have hsum : b+1+5 = b+6 := by + rw [add_assoc]; congr 1; norm_num + rw [hsum] + exact hmargin.le.trans le_self_add + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/ProductCertificateCollection.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/ProductCertificateCollection.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f6cf5d29331b3fbbbf10ba536205084746b733b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/ProductCertificateCollection.lean @@ -0,0 +1,88 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeOmegaCertificates + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open BoundedDefinability SetModelFunctions SentenceCoding +universe u + +def productBundleSigma : SigmaFormula := + .existsSet (.existsSet (.existsSet (.existsSet (.bounded + (.conj (productMatrix 3 5 6 2 1 0) + (.conj (.member 2 4) (.conj (.member 1 4) + (.conj (.member 0 4) (.member 3 4))))))))) + +theorem productBundleSigma_spec (M : ZFSet.{u}) (hM : Transitive M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (a b : Ordinal.{u}) + (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) : + productBundleSigma.Realize M e ↔ + ZFSet.prod b.toZFSet a.toZFSet ∈ e 0 ∧ productRelation a.toZFSet b.toZFSet ∈ e 0 ∧ + ∃ f ∈ e 0, OrderTypeCertificate (ZFSet.prod b.toZFSet a.toZFSet) + (productRelation a.toZFSet b.toZFSet) (a*b).toZFSet f ∧ (a*b).toZFSet ∈ e 0 := by + have sem (c d r f : ZFSet.{u}) (hc : c ∈ M) (hd : d ∈ M) (hr : r ∈ M) (hf : f ∈ M) : + (Formula.conj (productMatrix 3 5 6 2 1 0) + (.conj (.member 2 4) (.conj (.member 1 4) (.conj (.member 0 4) (.member 3 4))))).Realize M + (cons f (cons r (cons d (cons c e)))) ↔ + (d = ZFSet.prod b.toZFSet a.toZFSet ∧ r = productRelation a.toZFSet b.toZFSet ∧ + OrderTypeCertificate d r c f) ∧ d ∈ e 0 ∧ r ∈ e 0 ∧ f ∈ e 0 ∧ c ∈ e 0 := by + rw [Formula.absolute _ M hM _ (by + intro i; rcases i with _|_|_|_|i + exact hf; exact hr; exact hd; exact hc; exact he i)] + simp only [Formula.Eval,productMatrix_eval,cons_zero,cons_succ,ha,hb] + change (∃ c ∈ M, ∃ d ∈ M, ∃ r ∈ M, ∃ f ∈ M, _) ↔ _ + constructor + · rintro ⟨c,hc,d,hd,r,hr,f,hf,h⟩ + obtain ⟨⟨rfl,rfl,hcert⟩,hd0,hr0,hf0,hc0⟩ := (sem c d r f hc hd hr hf).mp h + have eq := hcert.exact (productRelation_wellFounded a b) (productRelation_transitive a b) + rw [product_orderType] at eq + subst c + exact ⟨hd0,hr0,f,hf0,hcert,hc0⟩ + · rintro ⟨hd,hr,f,hf,hcert,hc⟩ + exact ⟨_,hM _ (he 0) _ hc,_,hM _ (he 0) _ hd,_,hM _ (he 0) _ hr, + f,hM _ (he 0) _ hf,(sem _ _ _ f (hM _ (he 0) _ hc) (hM _ (he 0) _ hd) + (hM _ (he 0) _ hr) (hM _ (he 0) _ hf)).mpr ⟨⟨rfl,rfl,hcert⟩,hd,hr,hf,hc⟩⟩ + +theorem product_certificate_collection (M : ZFSet.{u}) (C : Context M) + (hRep : SigmaReplacement M) (hColl : SigmaCollection M) + (a b : Ordinal.{u}) (ha : a.toZFSet ∈ M) (hb : b.toZFSet ∈ M) : + ∃ U ∈ M, ∀ c < a, + ZFSet.prod b.toZFSet c.toZFSet ∈ U ∧ productRelation c.toZFSet b.toZFSet ∈ U ∧ + ∃ f ∈ U, OrderTypeCertificate (ZFSet.prod b.toZFSet c.toZFSet) + (productRelation c.toZFSet b.toZFSet) (c*b).toZFSet f ∧ (c*b).toZFSet ∈ U := by + obtain ⟨W,hW,hcover⟩ := hColl productBundleSigma (fun _ => b.toZFSet) (fun _ => hb) + a.toZFSet ha (by + intro x hx + obtain ⟨c,hca,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + have hc := C.transitive _ ha _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hca) + obtain ⟨hprod,f,hf,hcert⟩ := ordinal_mul_internal_schemas M C.transitive C.pairing + C.union C.power C.separation hRep c b hc hb + have hd := product_mem M C.transitive C.pairing C.union C.power C.separation hb hc + have hr := productRelation_mem M _ _ C.transitive C.pairing C.union C.power C.separation hc hb + let B := FiniteTuple.elements [ZFSet.prod b.toZFSet c.toZFSet, + productRelation c.toZFSet b.toZFSet,f,(c*b).toZFSet] + have hB : B ∈ M := FiniteTuple.elements_mem M C.transitive C.pairing C.union + (C.transitive _ C.omega_mem _ ZFSet.omega_zero) _ (by + intro y hy + simp only [List.mem_cons,List.not_mem_nil,or_false] at hy + rcases hy with rfl|rfl|rfl|rfl <;> assumption) + refine ⟨B,hB,(productBundleSigma_spec M C.transitive _ (by + intro i; rcases i with _|_|i; exact hB; exact hc; exact hb) c b rfl rfl).mpr ?_⟩ + have hm (y : ZFSet.{u}) : y ∈ B ↔ y ∈ [ZFSet.prod b.toZFSet c.toZFSet, + productRelation c.toZFSet b.toZFSet,f,(c*b).toZFSet] := FiniteTuple.mem_elements _ _ + exact ⟨(hm _).mpr (by simp),(hm _).mpr (by simp),f,(hm _).mpr (by simp),hcert, + (hm _).mpr (by simp)⟩) + refine ⟨ZFSet.sUnion W,union_mem M C.transitive C.union hW,?_⟩ + intro c hc + obtain ⟨B,hB,hcert⟩ := hcover c.toZFSet (Ordinal.toZFSet_mem_toZFSet_iff.mpr hc) + obtain ⟨hd,hr,f,hf,hcert,hp⟩ := (productBundleSigma_spec M C.transitive _ (by + intro i; rcases i with _|_|i + exact C.transitive _ hW _ hB + exact C.transitive _ ha _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hc) + exact hb) c b rfl rfl).mp hcert + exact ⟨ZFSet.mem_sUnion.mpr ⟨B,hB,hd⟩,ZFSet.mem_sUnion.mpr ⟨B,hB,hr⟩, + f,ZFSet.mem_sUnion.mpr ⟨B,hB,hf⟩,hcert,ZFSet.mem_sUnion.mpr ⟨B,hB,hp⟩⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/RankDefinability.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/RankDefinability.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0bf3268d78d78fa8ccfb4f87580f1a312f31f91 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/RankDefinability.lean @@ -0,0 +1,59 @@ +import OAI.Computability.DegreeRigidity.Constructibility.InternalRankRecursion +import OAI.Computability.DegreeRigidity.SetModels.InternalContainer + +namespace OAI + + +namespace TuringRigidity.InternalRank +open TransitiveNameModel BoundedSetTheory +universe u + +theorem rankSet_mem_ground (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) + {x : ZFSet.{u}} (hx : x ∈ M) : rankSet x ∈ M := by + obtain ⟨d,hd,hdT,hxd⟩ := internal_transitive_container M hM hP hU hS hR hI hx + exact rankSet_mem_of_container M d hM hP hU hPow hS hR hd hdT hxd + +namespace Code + +def value (x v : ℕ) : SigmaFormula := .existsSet (.existsSet (.existsSet (.bounded + (.conj (graph 2 1 0) (.conj (.member (x+3) 2) (.pairMem (x+3) (v+3) 0)))))) +end Code + +theorem realize_rankValue (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (x v : ℕ) : + (Code.value x v).Realize M e ↔ e v = rankSet (e x) := by + have matrix (d r f : ZFSet.{u}) (hd : d ∈ M) (hr : r ∈ M) (hf : f ∈ M) : + (Formula.conj (Code.graph 2 1 0) + (.conj (.member (x+3) 2) (.pairMem (x+3) (v+3) 0))).Realize M + (cons f (cons r (cons d e))) ↔ + Graph d r f ∧ e x ∈ d ∧ ZFSet.pair (e x) (e v) ∈ f := by + rw [Formula.absolute _ M hM _ (by + intro i; rcases i with _|i; exact hf + rcases i with _|i; exact hr + rcases i with _|i; exact hd + exact he i)] + simp only [Formula.Eval,Code.eval_graph,Formula.eval_pairMem,cons_zero,cons_succ] + change (∃ d ∈ M, ∃ r ∈ M, ∃ f ∈ M, _) ↔ _ + constructor + · rintro ⟨d,hd,r,hr,f,hf,hφ⟩ + obtain ⟨hg,hxd,hpair⟩ := (matrix d r f hd hr hf).mp hφ + obtain ⟨a,ha,b,hb,heq⟩ := hg.2.1 _ hpair + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + exact hg.correct _ ha _ hb hpair + · intro hv + obtain ⟨d,hd,hdT,hxd⟩ := internal_transitive_container M hM hP hU hS hR hI (he x) + obtain ⟨q,hq,hqdef⟩ := internal_power M hM hPow hd + obtain ⟨f,hf,hfg⟩ := internal_rankGraph M d q hM hP hU hS hR hd hq hdT hqdef (e x) hxd + have hh := hull_mem M d q hM hS hd hq (he x) + have hr := iterUnion_mem M hM hU hf 2 + refine ⟨_,hh,_,hr,f,hf,(matrix _ _ f hh hr hf).mpr + ⟨hfg,self_mem_hull d q hxd,?_⟩⟩ + exact (hfg.mem_iff _).mpr ⟨e x,self_mem_hull d q hxd,by rw [hv]⟩ + +end TuringRigidity.InternalRank + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/RankGraphConstruction.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/RankGraphConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a5b0c009247a479053f508765b8860d2dcf21f3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/RankGraphConstruction.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.RankRecursion +import OAI.Computability.DegreeRigidity.Syntax.CheckGraphConstruction + +namespace OAI + + +namespace TuringRigidity.InternalRank +open TransitiveNameModel BoundedSetTheory +universe u + +noncomputable def rankImage (x f : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ y ∈ x, ∃ w ∈ iterUnion 2 f, + ZFSet.pair y w ∈ f ∧ (z = w ∨ z ∈ w)) + (iterUnion 2 f ∪ ZFSet.sUnion (iterUnion 2 f)) + +theorem mem_rankImage (x f z : ZFSet.{u}) : + z ∈ rankImage x f ↔ ∃ y ∈ x, ∃ w, ZFSet.pair y w ∈ f ∧ (z = w ∨ z ∈ w) := by + rw [rankImage,ZFSet.mem_sep] + constructor + · rintro ⟨_,y,hy,w,_,hfw,hz⟩; exact ⟨y,hy,w,hfw,hz⟩ + · rintro ⟨y,hy,w,hfw,hz⟩ + have hw := second_mem_doubleUnion hfw + refine ⟨?_,y,hy,w,hw,hfw,hz⟩ + apply ZFSet.mem_union.mpr + exact hz.elim (fun h => Or.inl (h ▸ hw)) + (fun h => Or.inr (ZFSet.mem_sUnion.mpr ⟨w,hw,h⟩)) + +def imageFormula : Formula := + .existsMem 1 (.existsMem 4 (.conj (.pairMem 1 0 4) + (.disj (.equal 2 0) (.member 2 0)))) + +theorem eval_imageFormula (z x f r : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + imageFormula.Eval (cons z (cons x (cons f (cons r e)))) ↔ + ∃ y ∈ x, ∃ w ∈ r, ZFSet.pair y w ∈ f ∧ (z = w ∨ z ∈ w) := by + simp only [imageFormula,Formula.Eval,Formula.eval_pairMem,Formula.eval_disj,cons_zero,cons_succ] + +theorem rankImage_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + (hU : BoundedSetTheory.Union M) (hS : Separation M) + {x f : ZFSet.{u}} (hx : x ∈ M) (hf : f ∈ M) : rankImage x f ∈ M := by + have hr := iterUnion_mem M hM hU hf 2 + let e := cons x (cons f (cons (iterUnion 2 f) (fun _ => x))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hx + rcases i with _|i; exact hf + rcases i with _|i; exact hr + exact hx + have hs := sep_mem M hM hS imageFormula e he + (binary_union_mem M hM hP hU hr (union_mem M hM hU hr)) + have heq : ZFSet.sep (fun z => imageFormula.Eval (cons z e)) + (iterUnion 2 f ∪ ZFSet.sUnion (iterUnion 2 f)) = rankImage x f := by + apply ZFSet.ext + intro z + simp only [rankImage,ZFSet.mem_sep] + exact and_congr_right (fun _ => eval_imageFormula z x f _ _) + exact heq ▸ hs + +theorem Graph.mem_iff {d r f : ZFSet.{u}} (h : Graph d r f) (z : ZFSet.{u}) : + z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (rankSet x) := by + constructor + · intro hz + obtain ⟨x,hx,y,hy,rfl⟩ := h.2.1 z hz + exact ⟨x,hx,by rw [h.correct x hx y hy hz]⟩ + · rintro ⟨x,hx,rfl⟩ + obtain ⟨y,hy,hfy,_⟩ := h.2.2.1 x hx + rw [←h.correct x hx y hy hfy] + exact hfy + +theorem graph_of_mem_iff (d f : ZFSet.{u}) (hd : Transitive d) + (hf : ∀ z, z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (rankSet x)) : + Graph d (iterUnion 2 f) f := by + have hpair (x v : ZFSet.{u}) : ZFSet.pair x v ∈ f ↔ x ∈ d ∧ v = rankSet x := by + rw [hf] + constructor + · rintro ⟨y,hy,he⟩ + obtain ⟨rfl,hv⟩ := ZFSet.pair_inj.mp he + exact ⟨hy,hv⟩ + · rintro ⟨hx,rfl⟩; exact ⟨x,hx,rfl⟩ + refine ⟨hd,?_,?_,?_⟩ + · intro z hz + obtain ⟨x,hx,rfl⟩ := (hf z).mp hz + exact ⟨x,hx,rankSet x,second_mem_doubleUnion hz,rfl⟩ + · intro x hx + have hp := (hpair x _).mpr ⟨hx,rfl⟩ + exact ⟨_,second_mem_doubleUnion hp,hp,fun v _ hv => (hpair x v).mp hv |>.2⟩ + · intro x hx v _ hv + have he := (hpair x v).mp hv |>.2 + subst v + constructor + · intro z hz + obtain ⟨y,hy,hz⟩ := (mem_rankSet x z).mp hz + have hp := (hpair y _).mpr ⟨hd x hx y hy,rfl⟩ + exact ⟨y,hy,_,second_mem_doubleUnion hp,hp,hz⟩ + · intro y hy w _ hw + rw [(hpair y w).mp hw |>.2] + exact ⟨(mem_rankSet x _).mpr ⟨y,hy,Or.inl rfl⟩, + fun z hz => (mem_rankSet x z).mpr ⟨y,hy,Or.inr hz⟩⟩ + +end TuringRigidity.InternalRank + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/RankOrdinal.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/RankOrdinal.lean new file mode 100644 index 0000000000000000000000000000000000000000..8739abed9fb26b1e75f83c2c4cb1bbdc412e2821 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/RankOrdinal.lean @@ -0,0 +1,44 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.RankDefinability +import Mathlib.SetTheory.ZFC.Ordinal + +namespace OAI + + +namespace TuringRigidity.InternalRank +open TransitiveNameModel BoundedSetTheory +universe u + +theorem rankSet_eq_ordinal (x : ZFSet.{u}) : rankSet x = x.rank.toZFSet := by + induction x using ZFSet.inductionOn with + | h x ih => + apply ZFSet.ext + intro z + rw [mem_rankSet] + constructor + · rintro ⟨y,hy,rfl|hz⟩ + · rw [ih y hy] + exact Ordinal.toZFSet_mem_toZFSet_iff.mpr (ZFSet.rank_lt_of_mem hy) + · rw [ih y hy] at hz + exact Ordinal.toZFSet_monotone (ZFSet.rank_lt_of_mem hy).le hz + · intro hz + obtain ⟨a,ha,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hz + obtain ⟨y,hy,hay⟩ := ZFSet.lt_rank_iff.mp ha + refine ⟨y,hy,?_⟩ + rw [ih y hy] + rcases lt_or_eq_of_le hay with hay|rfl + · exact Or.inr (Ordinal.toZFSet_mem_toZFSet_iff.mpr hay) + · exact Or.inl rfl + +theorem rankSet_isOrdinal (x : ZFSet.{u}) : (rankSet x).IsOrdinal := by + rw [rankSet_eq_ordinal] + exact ZFSet.isOrdinal_toZFSet _ + +theorem rankSet_lt_iff (x y : ZFSet.{u}) : rankSet x ∈ rankSet y ↔ x.rank < y.rank := by + rw [rankSet_eq_ordinal,rankSet_eq_ordinal,Ordinal.toZFSet_mem_toZFSet_iff] + +theorem rankSet_le_iff (x y : ZFSet.{u}) : rankSet x ⊆ rankSet y ↔ x.rank ≤ y.rank := by + rw [rankSet_eq_ordinal,rankSet_eq_ordinal,Ordinal.toZFSet_subset_toZFSet_iff] + +end TuringRigidity.InternalRank + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/RankRecursion.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/RankRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff3c9519521ac7abaab0e97d3ceae968ba5d9a74 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/RankRecursion.lean @@ -0,0 +1,108 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedRelations + +namespace OAI + + +namespace TuringRigidity.InternalRank +open TransitiveNameModel BoundedSetTheory +universe u + +noncomputable def rankSet (x : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sUnion (ZFSet.range (fun y : Shrink x => + insert (rankSet ((equivShrink x).symm y).val) (rankSet ((equivShrink x).symm y).val))) +termination_by x +decreasing_by exact ((equivShrink x).symm y).property + +theorem mem_rankSet (x z : ZFSet.{u}) : + z ∈ rankSet x ↔ ∃ y ∈ x, z = rankSet y ∨ z ∈ rankSet y := by + rw [rankSet,ZFSet.mem_sUnion] + constructor + · rintro ⟨v,hv,hz⟩ + obtain ⟨y,rfl⟩ := ZFSet.mem_range.mp hv + exact ⟨_,((equivShrink x).symm y).property,ZFSet.mem_insert_iff.mp hz⟩ + · rintro ⟨y,hy,hz⟩ + refine ⟨_,ZFSet.mem_range.mpr ⟨equivShrink x ⟨y,hy⟩,rfl⟩,?_⟩ + simpa using ZFSet.mem_insert_iff.mpr hz + +theorem rankSet_mem {x y : ZFSet.{u}} (hy : y ∈ x) : rankSet y ∈ rankSet x := + (mem_rankSet x _).mpr ⟨y,hy,Or.inl rfl⟩ + +theorem rankSet_transitive (x : ZFSet.{u}) : Transitive (rankSet x) := by + induction x using ZFSet.inductionOn with + | h x ih => + intro z hz w hw + obtain ⟨y,hy,rfl|hz⟩ := (mem_rankSet x z).mp hz + · exact (mem_rankSet x w).mpr ⟨y,hy,Or.inr hw⟩ + · exact (mem_rankSet x w).mpr ⟨y,hy,Or.inr (ih y hy z hz w hw)⟩ + +def Step (f r x v : ZFSet.{u}) : Prop := + (∀ z ∈ v, ∃ y ∈ x, ∃ w ∈ r, ZFSet.pair y w ∈ f ∧ (z = w ∨ z ∈ w)) ∧ + (∀ y ∈ x, ∀ w ∈ r, ZFSet.pair y w ∈ f → w ∈ v ∧ w ⊆ v) + +def Graph (d r f : ZFSet.{u}) : Prop := + Transitive d ∧ + (∀ z ∈ f, ∃ x ∈ d, ∃ y ∈ r, z = ZFSet.pair x y) ∧ + (∀ x ∈ d, ∃ y ∈ r, ZFSet.pair x y ∈ f ∧ + ∀ z ∈ r, ZFSet.pair x z ∈ f → z = y) ∧ + (∀ x ∈ d, ∀ y ∈ r, ZFSet.pair x y ∈ f → Step f r x y) + +theorem Graph.correct {d r f : ZFSet.{u}} (h : Graph d r f) + (x : ZFSet.{u}) (hx : x ∈ d) (v : ZFSet.{u}) (hv : v ∈ r) + (hfv : ZFSet.pair x v ∈ f) : v = rankSet x := by + induction x using ZFSet.inductionOn generalizing v with + | h x ih => + have hs := h.2.2.2 x hx v hv hfv + apply ZFSet.ext + intro z + rw [mem_rankSet] + constructor + · intro hz + obtain ⟨y,hy,w,hw,hfw,hz⟩ := hs.1 z hz + rw [ih y hy (h.1 x hx y hy) w hw hfw] at hz + exact ⟨y,hy,hz⟩ + · rintro ⟨y,hy,hz⟩ + obtain ⟨w,hw,hfw,_⟩ := h.2.2.1 y (h.1 x hx y hy) + rw [←ih y hy (h.1 x hx y hy) w hw hfw] at hz + exact hz.elim (fun hzw => hzw ▸ (hs.2 y hy w hw hfw).1) + (fun hz => (hs.2 y hy w hw hfw).2 hz) + +theorem Graph.unique {d r s f g : ZFSet.{u}} + (hf : Graph d r f) (hg : Graph d s g) : f = g := by + apply ZFSet.ext + intro z + have forward {r s f g : ZFSet.{u}} (hf : Graph d r f) + (hg : Graph d s g) (hz : z ∈ f) : z ∈ g := by + obtain ⟨x,hx,y,hy,rfl⟩ := hf.2.1 z hz + obtain ⟨v,hv,hgv,_⟩ := hg.2.2.1 x hx + have he := (hf.correct x hx y hy hz).trans (hg.correct x hx v hv hgv).symm + exact he ▸ hgv + exact ⟨forward hf hg,forward hg hf⟩ + +namespace Code +open Formula + +def step (f r x v : ℕ) : Formula := + .conj (allMem v (.existsMem (x+1) (.existsMem (r+2) + (.conj (pairMem 1 0 (f+3)) (disj (.equal 2 0) (.member 2 0)))))) + (allMem x (allMem (r+1) (imp (pairMem 1 0 (f+2)) + (.conj (.member 0 (v+2)) (subset 0 (v+2)))))) + +theorem eval_step (f r x v : ℕ) (e : ℕ → ZFSet.{u}) : + (step f r x v).Eval e ↔ Step (e f) (e r) (e x) (e v) := by + simp only [step,Formula.Eval,eval_allMem,eval_pairMem,eval_disj, + eval_imp,eval_subset,cons_zero,cons_succ,Step] + +def graph (d r f : ℕ) : Formula := + .conj (transitive d) (.conj (functionGraph f d r) + (allMem d (allMem (r+1) (imp (pairMem 1 0 (f+2)) (step (f+2) (r+2) 1 0))))) + +theorem eval_graph (d r f : ℕ) (e : ℕ → ZFSet.{u}) : + (graph d r f).Eval e ↔ Graph (e d) (e r) (e f) := by + simp only [graph,Formula.Eval,eval_transitive,eval_functionGraph, + eval_allMem,eval_imp,eval_pairMem,eval_step,cons_zero,cons_succ,Graph] + exact and_congr_right (fun _ => and_assoc) +end Code + +end TuringRigidity.InternalRank + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/Recurrence.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/Recurrence.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c885d4f272bdb89fb88a8c702d2d569439ee49b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/Recurrence.lean @@ -0,0 +1,191 @@ +import Mathlib.Algebra.Order.Archimedean.Real.Basic +import Mathlib.Data.Rat.Encodable +import Mathlib.NumberTheory.Real.Irrational +import Mathlib.Data.Set.Countable +import Mathlib.Algebra.BigOperators.Group.Finset.Basic +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Ring +import Mathlib.Tactic.FieldSimp + +namespace OAI + +namespace TuringRigidity + +def choiceBit (test : ℝ → Bool) (s : ℝ) : ℝ := if test s then 1 else 0 + +def state (test : ℝ → Bool) (δ t : ℝ) : ℕ → ℝ + | 0 => 0 + | n + 1 => state test δ t n + δ * (t - choiceBit test (state test δ t n)) + +def branch (test : ℝ → Bool) (δ t : ℝ) (n : ℕ) : ℝ := + choiceBit test (state test δ t n) + +theorem choiceBit_eq_zero_or_one (test : ℝ → Bool) (s : ℝ) : + choiceBit test s = 0 ∨ choiceBit test s = 1 := by + simp only [choiceBit] + split <;> simp + +theorem state_mem_Icc (test : ℝ → Bool) (δ t lo hi : ℝ) + (hδ : 0 < δ) (ht₀ : 0 < t) (ht₁ : t < 1) + (hlo : lo ≤ 0) (hhi : 0 ≤ hi) + (left : ∀ s ∈ Set.Icc lo (lo + δ), test s = false) + (right : ∀ s ∈ Set.Icc (hi - δ) hi, test s = true) : + ∀ n, state test δ t n ∈ Set.Icc lo hi := by + intro n + induction n with + | zero => exact ⟨hlo, hhi⟩ + | succ n ih => + rcases ih with ⟨hslo, hshi⟩ + have hdt₀ : 0 < δ * t := mul_pos hδ ht₀ + have hdt₁ : δ * t < δ := by nlinarith + have hneg : δ * (t - 1) < 0 := mul_neg_of_pos_of_neg hδ (by linarith) + cases hb : test (state test δ t n) with + | false => + have hs : state test δ t n < hi - δ := by + by_contra h + have := right _ ⟨le_of_not_gt h, hshi⟩ + simp [hb] at this + simp only [state, choiceBit, hb, Bool.false_eq_true, ↓reduceIte, sub_zero] + constructor <;> linarith + | true => + have hs : lo + δ < state test δ t n := by + by_contra h + have := left _ ⟨hslo, le_of_not_gt h⟩ + simp [hb] at this + simp only [state, choiceBit, hb, ↓reduceIte] + constructor <;> nlinarith + +theorem state_eq_sum (test : ℝ → Bool) (δ t : ℝ) (n : ℕ) : + state test δ t n = δ * ((n : ℝ) * t - ∑ k ∈ Finset.range n, branch test δ t k) := by + induction n with + | zero => simp [state] + | succ n ih => + simp only [state, Finset.sum_range_succ, Nat.cast_add, Nat.cast_one] + change state test δ t n + δ * (t - branch test δ t n) = _ + rw [ih] + ring + +theorem frequency_error (test : ℝ → Bool) (δ t : ℝ) (n : ℕ) + (hδ : 0 < δ) (hn : 0 < n) (hs : |state test δ t n| < 1) : + |t - (∑ k ∈ Finset.range n, branch test δ t k) / (n : ℝ)| < + 1 / ((n : ℝ) * δ) := by + have hn' : (0 : ℝ) < n := by exact_mod_cast hn + have hden : 0 < (n : ℝ) * δ := mul_pos hn' hδ + have heq : t - (∑ k ∈ Finset.range n, branch test δ t k) / (n : ℝ) = + state test δ t n / ((n : ℝ) * δ) := by + rw [state_eq_sum] + field_simp + rw [heq, abs_div, abs_of_pos hden] + exact (div_lt_div_iff_of_pos_right hden).mpr hs + +def rationalSpan (t : ℝ) : Set ℝ := {s | ∃ a b : ℚ, s = a + b * t} + +theorem rationalSpan_countable (t : ℝ) : (rationalSpan t).Countable := by + have hr : rationalSpan t = Set.range (fun p : ℚ × ℚ => (p.1 : ℝ) + p.2 * t) := by + ext s + simp only [rationalSpan, Set.mem_ofPred_eq, Set.mem_range, Prod.exists] + exact ⟨fun ⟨a,b,h⟩ => ⟨a,b,h.symm⟩, fun ⟨a,b,h⟩ => ⟨a,b,h.symm⟩⟩ + rw [hr] + exact Set.countable_range _ + +theorem state_mem_rationalSpan (test : ℝ → Bool) (δ : ℚ) (t : ℝ) : + ∀ n, state test (δ : ℝ) t n ∈ rationalSpan t := by + intro n + induction n with + | zero => exact ⟨0,0, by simp [state]⟩ + | succ n ih => + rcases ih with ⟨a,b,hab⟩ + cases hb : test (state test (δ : ℝ) t n) with + | false => + refine ⟨a,b+δ, ?_⟩ + simp only [state, choiceBit, hb, Bool.false_eq_true, ↓reduceIte, sub_zero] + rw [hab] + push_cast + ring + | true => + refine ⟨a-δ,b+δ, ?_⟩ + simp only [state, choiceBit, hb, ↓reduceIte] + rw [hab] + push_cast + ring + +theorem state_mem_Icc_on_span (test : ℝ → Bool) (δ : ℚ) (t lo hi : ℝ) + (hδ : (0 : ℝ) < δ) (ht₀ : 0 < t) (ht₁ : t < 1) + (hlo : lo ≤ 0) (hhi : 0 ≤ hi) + (left : ∀ s ∈ rationalSpan t, s ∈ Set.Icc lo (lo + δ) → test s = false) + (right : ∀ s ∈ rationalSpan t, s ∈ Set.Icc (hi - δ) hi → test s = true) : + ∀ n, state test (δ : ℝ) t n ∈ Set.Icc lo hi := by + intro n + induction n with + | zero => exact ⟨hlo, hhi⟩ + | succ n ih => + rcases ih with ⟨hslo, hshi⟩ + have hdt₀ : 0 < (δ : ℝ) * t := mul_pos hδ ht₀ + have hdt₁ : (δ : ℝ) * t < δ := by nlinarith + have hneg : (δ : ℝ) * (t - 1) < 0 := + mul_neg_of_pos_of_neg hδ (by linarith) + cases hb : test (state test (δ : ℝ) t n) with + | false => + have hs : state test (δ : ℝ) t n < hi - δ := by + by_contra h + have := right _ (state_mem_rationalSpan test δ t n) ⟨le_of_not_gt h, hshi⟩ + simp [hb] at this + simp only [state, choiceBit, hb, Bool.false_eq_true, ↓reduceIte, sub_zero] + constructor <;> linarith + | true => + have hs : lo + δ < state test (δ : ℝ) t n := by + by_contra h + have := left _ (state_mem_rationalSpan test δ t n) ⟨hslo, le_of_not_gt h⟩ + simp [hb] at this + simp only [state, choiceBit, hb, ↓reduceIte] + constructor <;> nlinarith + +theorem exists_radius_lt (δ ε : ℝ) (hδ : 0 < δ) (hε : 0 < ε) : + ∃ n : ℕ, 0 < n ∧ 1 / ((n : ℝ) * δ) < ε := by + obtain ⟨n, hn⟩ := exists_nat_gt (1 / (δ * ε)) + have hpos : 0 < 1 / (δ * ε) := one_div_pos.mpr (mul_pos hδ hε) + have hn' : (0 : ℝ) < n := lt_trans hpos hn + refine ⟨n, by exact_mod_cast hn', ?_⟩ + have hh : 1 < (n : ℝ) * (δ * ε) := (div_lt_iff₀ (mul_pos hδ hε)).mp hn + apply (div_lt_iff₀ (mul_pos hn' hδ)).mpr + nlinarith + +theorem comparison_search (t δ : ℝ) (a : ℕ → ℝ) (hδ : 0 < δ) + (herr : ∀ n : ℕ, 0 < n → |t - a n| < 1 / ((n : ℝ) * δ)) + (q : ℝ) (hqt : q ≠ t) : + (∃ n : ℕ, 0 < n ∧ + (q < a n - 1 / ((n : ℝ) * δ) ∨ a n + 1 / ((n : ℝ) * δ) < q)) ∧ + (∀ n : ℕ, 0 < n → + (q < a n - 1 / ((n : ℝ) * δ) → q < t) ∧ + (a n + 1 / ((n : ℝ) * δ) < q → t < q)) := by + constructor + · rcases lt_or_gt_of_ne hqt with hlt | hgt + · obtain ⟨n, hn, hrad⟩ := exists_radius_lt δ ((t-q)/2) hδ (by linarith) + refine ⟨n, hn, Or.inl ?_⟩ + have he := (abs_lt.mp (herr n hn)).2 + linarith + · obtain ⟨n, hn, hrad⟩ := exists_radius_lt δ ((q-t)/2) hδ (by linarith) + refine ⟨n, hn, Or.inr ?_⟩ + have he := (abs_lt.mp (herr n hn)).1 + linarith + · intro n hn + rcases abs_lt.mp (herr n hn) with ⟨hl,hu⟩ + constructor <;> intro h <;> linarith + +theorem irrational_cut_iff_search (t δ : ℝ) (a : ℕ → ℝ) (ht : Irrational t) + (hδ : 0 < δ) + (herr : ∀ n : ℕ, 0 < n → |t - a n| < 1 / ((n : ℝ) * δ)) (q : ℚ) : + (q : ℝ) < t ↔ ∃ n : ℕ, 0 < n ∧ (q : ℝ) < a n - 1 / ((n : ℝ) * δ) := by + have hne : (q : ℝ) ≠ t := fun h => ht ⟨q, h⟩ + obtain ⟨⟨n, hn, hs⟩, sound⟩ := comparison_search t δ a hδ herr q hne + constructor + · intro hqt + rcases hs with hs | hs + · exact ⟨n, hn, hs⟩ + · exact False.elim ((not_lt_of_gt hqt) ((sound n hn).2 hs)) + · rintro ⟨m, hm, hcmp⟩ + exact (sound m hm).1 hcmp + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SelectorOrdinalEnumeration.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SelectorOrdinalEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ce2121d2ad07f6388c2d880926e2aea304f1b0c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SelectorOrdinalEnumeration.lean @@ -0,0 +1,90 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalMinimalSelector + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse +universe u +namespace InternalWellOrder + +theorem internal_enumeration_from_selector (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) + {a q s : ZFSet.{u}} (ha : a ∈ M) (hq : q ∈ M) (hsM : s ∈ M) + (hs : ChoiceGraph q s) (hqdef : ∀ x, x ∈ q ↔ x ∈ M ∧ x ⊆ a ∧ ∃ y, y ∈ x) : + ∃ δ ∈ M, δ.IsOrdinal ∧ ∃ F ∈ M, TransitiveNameModel.FunctionGraph δ a F ∧ + (∀ x ∈ a, ∃ i ∈ δ, ZFSet.pair i x ∈ F) ∧ + (∀ i ∈ δ, ∀ j ∈ δ, ∀ x, ZFSet.pair i x ∈ F → ZFSet.pair j x ∈ F → i = j) ∧ + (∀ i ∈ δ, ∀ x ∈ a, ZFSet.pair i x ∈ F → + ∃ b ∈ q, Remaining a F i b ∧ ZFSet.pair b x ∈ s) := by + classical + obtain ⟨α,hαM,hα,hHartogs⟩ := internal_hartogs M a hM hP hU hPow hS hR hI ha + have hαT : Transitive α := fun i hi j hj => hα.subset_of_mem hi hj + obtain ⟨F,hF,htrace,hmax⟩ := internal_maximal_trace M hM hP hU hPow hS.bounded hαM ha hq hsM hαT hs + have hfun := htrace.functional hαT hs + have hmissing : ∃ i ∈ α, ¬ ∃ x ∈ a, ZFSet.pair i x ∈ F := by + by_contra hn + have htotal : ∀ i ∈ α, ∃ x ∈ a, ZFSet.pair i x ∈ F := by + intro i hi; exact Classical.byContradiction (fun h => hn ⟨i,hi,h⟩) + have hfg : TransitiveNameModel.FunctionGraph α a F := by + refine ⟨htrace.shape,?_⟩ + intro i hi + obtain ⟨x,hx,hix⟩ := htotal i hi + exact ⟨x,hx,hix,fun y _ hiy => hfun i y x hiy hix⟩ + obtain ⟨v,hv,hva⟩ := FunctionGraph.exists_presentation hfg + apply hHartogs F hF v hv hva + intro i hi j hj he + have hip := (hv.pair_iff i (v i)).mpr ⟨hi,rfl⟩ + have hjp := (hv.pair_iff j (v j)).mpr ⟨hj,rfl⟩ + rw [← he] at hjp + exact htrace.injective hα hs i j (v i) hip hjp + have minimal (i : ZFSet.{u}) : i ∈ α → (¬ ∃ x ∈ a, ZFSet.pair i x ∈ F) → + ∃ j ∈ α, (¬ ∃ x ∈ a, ZFSet.pair j x ∈ F) ∧ + ∀ k ∈ j, ∃ x ∈ a, ZFSet.pair k x ∈ F := by + induction i using ZFSet.inductionOn with + | h i ih => + intro hi hmiss + by_cases hex : ∃ j ∈ i, ¬ ∃ x ∈ a, ZFSet.pair j x ∈ F + · obtain ⟨j,hji,hjmiss⟩ := hex + exact ih j hji (hα.subset_of_mem hi hji) hjmiss + · refine ⟨i,hi,hmiss,?_⟩ + intro j hji + exact Classical.byContradiction (fun h => hex ⟨j,hji,h⟩) + obtain ⟨i,hi,hmiss⟩ := hmissing + obtain ⟨i,hi,hmiss,hprev⟩ := minimal i hi hmiss + have hiM := hM α hαM i hi + have hiT : Transitive i := fun j hj k hk => (hα.mem hi).subset_of_mem hj hk + have hdom : ∀ j y, ZFSet.pair j y ∈ F → j ∈ i := htrace.domain_before hα hi hmiss + have hres := residual_mem M hM hS.bounded ha hF hiM + have hrem := residual_remaining a F i + have hempty : ¬ ∃ x, x ∈ residual a F i := by + intro hex + have hrq : residual a F i ∈ q := (hqdef _).mpr ⟨hres,hrem.1,hex⟩ + obtain ⟨x,hxr,hrx,_⟩ := hs.2 _ hrq + have hxa := hrem.1 hxr + have hpair := orderedPair_mem M hM hP hiM (hM a ha x hxa) + have hnew := binary_union_mem M hM hP hU hF (singleton_mem M hM hP hpair) + have hnewtrace := htrace.adjoin hi hiT hxa hrq hrem hrx hprev hdom + have hnewsub := hmax _ hnew hnewtrace + exact hmiss ⟨x,hxa,hnewsub (ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_singleton.mpr rfl)))⟩ + refine ⟨i,hiM,hα.mem hi,F,hF,?_,?_,?_,?_⟩ + · refine ⟨?_,?_⟩ + · intro z hz + obtain ⟨j,_,x,hx,rfl⟩ := htrace.shape z hz + exact ⟨j,hdom j x hz,x,hx,rfl⟩ + · intro j hj + obtain ⟨x,hx,hjx⟩ := hprev j hj + exact ⟨x,hx,hjx,fun y _ hjy => hfun j y x hjy hjx⟩ + · intro x hx + exact Classical.byContradiction (fun hn => hempty ⟨x,(hrem.2 x hx).mpr hn⟩) + · intro j _ k _ x hjx hkx + exact htrace.injective hα hs j k x hjx hkx + + · intro j hj x hx hjx + exact htrace.choice j (hα.subset_of_mem hi hj) x hx hjx + +end InternalWellOrder +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SuccessorOmegaCertificates.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SuccessorOmegaCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f11c5dd05335e1975754877ec85df5ac979a345 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SuccessorOmegaCertificates.lean @@ -0,0 +1,62 @@ +import OAI.Computability.DegreeRigidity.SetModels.ExactOmegaGraph +import OAI.Computability.DegreeRigidity.Constructibility.FiniteStageSetBounds + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +theorem omega_certificates_successor_add_five (R : ZFSet.{u}) (γ a : Ordinal.{u}) + (hc : OmegaPowerCertificates (level R γ) a.toZFSet) + (ha : (Ordinal.omega0 ^ a).toZFSet ∈ level R γ) + (hs : (Ordinal.omega0 ^ (a+1)).toZFSet ∈ level R γ) + (hp : ProductCertificates (level R γ) (Ordinal.omega0 ^ a) Ordinal.omega0) : + OmegaPowerCertificates (level R (γ+5)) (a+1).toZFSet := by + obtain ⟨hd,f,hf,r,hr,hg,hprod⟩ := hc + have h02 : γ ≤ γ+2 := le_self_add + have h05 : γ ≤ γ+5 := le_self_add + have h15 : γ+1 ≤ γ+5 := add_le_add le_rfl (by norm_num) + have h35 : γ+3 ≤ γ+5 := add_le_add le_rfl (by exact_mod_cast (by decide : (3 : ℕ) ≤ 5)) + let g := insert (ZFSet.pair a.toZFSet (omegaNext a.toZFSet)) f + have hy : omegaNext a.toZFSet ∈ level R γ := by + simpa only [omegaNext,Ordinal.rank_toZFSet] using hs + have hgM : g ∈ level R (γ+3) := by + have h := insert_mem_level_succ R (γ+2) + (orderedPair_mem_level_add_two R γ hd hy) (level_mono R h02 hf) + simpa only [add_assoc,show (2 : Ordinal.{u})+1=3 by norm_num] using h + have hexact (z : ZFSet.{u}) : z ∈ g ↔ + ∃ x ∈ (a+1).toZFSet, z = ZFSet.pair x (omegaNext x) := by + rw [Ordinal.toZFSet_add_one] + change z ∈ insert _ f ↔ _ + rw [ZFSet.mem_insert_iff,hg.mem_iff] + constructor + · rintro (hz|⟨x,hx,hz⟩) + · exact ⟨a.toZFSet,ZFSet.mem_insert _ _,hz⟩ + · exact ⟨x,ZFSet.mem_insert_of_mem _ hx,hz⟩ + · rintro ⟨x,hx,hz⟩ + rcases ZFSet.mem_insert_iff.mp hx with rfl|hx + · exact Or.inl hz + · exact Or.inr ⟨x,hx,hz⟩ + have hdom : (a+1).toZFSet ∈ level R (γ+5) := by + rw [Ordinal.toZFSet_add_one] + exact level_mono R h15 (insert_mem_level_succ R γ hd hd) + have hrange : iterUnion 2 g ∈ level R (γ+5) := by + simpa only [Nat.cast_ofNat,add_assoc,show (3 : Ordinal.{u})+2=5 by norm_num] using + iterUnion_mem_level_add R (γ+3) hgM 2 + refine ⟨hdom,g,level_mono R h35 hgM,_,hrange, + omegaGraph_of_exact_pairs _ _ g (ZFSet.isOrdinal_toZFSet _) hexact ?_,?_⟩ + · intro x hx + rw [Ordinal.toZFSet_add_one] at hx + rcases ZFSet.mem_insert_iff.mp hx with rfl|hx + · simpa only [Ordinal.rank_toZFSet] using level_mono R h05 ha + · exact level_mono R h05 (hg.union_value_mem hx) + · intro x hx + rw [Ordinal.toZFSet_add_one] at hx + rcases ZFSet.mem_insert_iff.mp hx with rfl|hx + · simpa only [Ordinal.rank_toZFSet] using hp.mono (level_mono R h05) + · exact (hprod x hx).mono (level_mono R h05) + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SumCertificateLevels.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SumCertificateLevels.lean new file mode 100644 index 0000000000000000000000000000000000000000..72e79fd0126843f4cfbc281c63e9084d06b83792 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SumCertificateLevels.lean @@ -0,0 +1,39 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.SumCertificates +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalSumLevels + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +theorem sum_certificates_at_levels (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (a b : Ordinal.{u}) (ha : a.toZFSet ∈ M) (hb : b.toZFSet ∈ M) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ ∀ δ : Ordinal.{u}, γ ≤ δ → + a.toZFSet ∈ level (groundReals M) δ ∧ b.toZFSet ∈ level (groundReals M) δ ∧ + (a+b).toZFSet ∈ level (groundReals M) δ ∧ SumCertificates (level (groundReals M) δ) a b := by + let R := groundReals M + let N := relativeModel M R + have hR := groundReals_mem M hM hT + have C := ground_relative_context M hM hT + have hRep := relativeModel_sigma_replacement M R hM hT hR + have haN := (ground_relativeModel_ordinal_iff M hM hT a).mpr ha + have hbN := (ground_relativeModel_ordinal_iff M hM hT b).mpr hb + obtain ⟨hd,hr,f,hf,hcert⟩ := SumCertificates.context N C hRep a b haN hbN + have hc := (ordinal_add_relative M R hM hT hR a b haN hbN).1 + let e := cons a.toZFSet (cons b.toZFSet (cons (a+b).toZFSet + (cons (sumDomain a.toZFSet b.toZFSet) (cons (sumRelation a.toZFSet b.toZFSet) (fun _ => f))))) + have he (i : ℕ) : e i ∈ N := by + rcases i with _|_|_|_|_|i + exact haN; exact hbN; exact hc; exact hd; exact hr; exact hf + obtain ⟨γ,hγ,hγe⟩ := finite_parameters_in_relative_level M R hM hT e 6 + (fun i _ => (mem_relativeModel M R _ hM hT hR).mp (he i)) + refine ⟨γ,hγ,?_⟩ + intro δ hδ + have hL (i : ℕ) (hi : i < 6) : e i ∈ level R δ := level_mono R hδ (hγe i hi) + exact ⟨hL 0 (by omega),hL 1 (by omega),hL 2 (by omega), + hL 3 (by omega),hL 4 (by omega),f,hL 5 (by omega),hcert⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SumCertificates.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SumCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0edc669505527a3beae5e80672615fe799eb5e4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SumCertificates.lean @@ -0,0 +1,43 @@ +import OAI.Computability.DegreeRigidity.Constructibility.RelativeOmegaCertificates +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalCodeOperations + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open BoundedDefinability SetModelFunctions +universe u + +def SumCertificates (M : ZFSet.{u}) (a b : Ordinal.{u}) : Prop := + sumDomain a.toZFSet b.toZFSet ∈ M ∧ sumRelation a.toZFSet b.toZFSet ∈ M ∧ + ∃ f ∈ M, OrderTypeCertificate (sumDomain a.toZFSet b.toZFSet) + (sumRelation a.toZFSet b.toZFSet) (a+b).toZFSet f + +theorem SumCertificates.context (M : ZFSet.{u}) (C : Context M) + (hRep : SigmaReplacement M) (a b : Ordinal.{u}) + (ha : a.toZFSet ∈ M) (hb : b.toZFSet ∈ M) : SumCertificates M a b := by + have h0 := C.transitive _ C.omega_mem _ ZFSet.omega_zero + obtain ⟨_,f,hf,hc⟩ := ordinal_add_internal_schemas M C.transitive C.pairing C.union + C.power C.separation hRep h0 a b ha hb + exact ⟨sumDomain_mem M _ _ C.transitive C.pairing C.union C.power C.separation h0 ha hb, + sumRelation_mem M _ _ C.transitive C.pairing C.union C.power C.separation h0 ha hb, + f,hf,hc⟩ + +theorem SumCertificates.mono {M N : ZFSet.{u}} {a b : Ordinal.{u}} + (h : SumCertificates M a b) (hMN : M ⊆ N) : SumCertificates N a b := + ⟨hMN h.1,hMN h.2.1,let ⟨f,hf,hc⟩ := h.2.2; ⟨f,hMN hf,hc⟩⟩ + +theorem sumSentence_of_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (a b : Ordinal.{u}) (ha : e 1 = a.toZFSet) (hb : e 2 = b.toZFSet) + (hc : SumCertificates M a b) (hy : e 0 = (a+b).toZFSet) : + sumSentence.Sat (M : Set ZFSet) e := by + have h1 : ({∅} : ZFSet.{u}) ∈ M := by + have h := hM _ hω _ ((mem_omega _).mpr ⟨1,rfl⟩) + simpa [natSet] using h + exact (sumSentence_spec_of_certificate M hM e he a b ha hb + (hM _ hω _ ZFSet.omega_zero) h1 hc.1 hc.2.1 hc.2.2).mpr hy + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SumComparison.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SumComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..67defe518109cf180a821ba74eaec7966cc161f4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/SumComparison.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.Computability.RationalCut + +namespace OAI + +namespace TuringRigidity.RationalCoding + +def sumLeft (z : ℕ × ℕ × ℕ) : ℕ := + positiveNumerator z.1 * denominator z.2.1 * denominator z.2.2 + + negativeNumerator z.2.1 * denominator z.1 * denominator z.2.2 + + negativeNumerator z.2.2 * denominator z.1 * denominator z.2.1 + +def sumRight (z : ℕ × ℕ × ℕ) : ℕ := + negativeNumerator z.1 * denominator z.2.1 * denominator z.2.2 + + positiveNumerator z.2.1 * denominator z.1 * denominator z.2.2 + + positiveNumerator z.2.2 * denominator z.1 * denominator z.2.1 + +private theorem polynomial_primrec {p a b : ℕ → ℕ} (hp : Primrec p) + (ha : Primrec a) (hb : Primrec b) : Primrec (fun z : ℕ × ℕ × ℕ => + p z.1*denominator z.2.1*denominator z.2.2 + + a z.2.1*denominator z.1*denominator z.2.2 + + b z.2.2*denominator z.1*denominator z.2.1) := + Primrec.nat_add.comp (Primrec.nat_add.comp + (Primrec.nat_mul.comp (Primrec.nat_mul.comp (hp.comp Primrec.fst) + (denominator_primrec.comp (Primrec.fst.comp Primrec.snd))) + (denominator_primrec.comp (Primrec.snd.comp Primrec.snd))) + (Primrec.nat_mul.comp (Primrec.nat_mul.comp (ha.comp (Primrec.fst.comp Primrec.snd)) + (denominator_primrec.comp Primrec.fst)) + (denominator_primrec.comp (Primrec.snd.comp Primrec.snd)))) + (Primrec.nat_mul.comp (Primrec.nat_mul.comp (hb.comp (Primrec.snd.comp Primrec.snd)) + (denominator_primrec.comp Primrec.fst)) + (denominator_primrec.comp (Primrec.fst.comp Primrec.snd))) + +theorem sumLeft_primrec : Primrec sumLeft := + polynomial_primrec positiveNumerator_primrec negativeNumerator_primrec negativeNumerator_primrec + +theorem sumRight_primrec : Primrec sumRight := + polynomial_primrec negativeNumerator_primrec positiveNumerator_primrec positiveNumerator_primrec + +theorem sum_difference (i j k : ℕ) : + ((rationalEnumeration j : ℝ)+(rationalEnumeration k : ℝ)-(rationalEnumeration i : ℝ))* + ((denominator i : ℝ)*denominator j*denominator k) = + (sumRight (i,j,k) : ℝ)-(sumLeft (i,j,k) : ℝ) := by + have hi : (denominator i : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (denominator_pos i)) + have hj : (denominator j : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (denominator_pos j)) + have hk : (denominator k : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (denominator_pos k)) + rw [signed_query_value,signed_query_value,signed_query_value] + simp only [sumLeft,sumRight,Nat.cast_add,Nat.cast_mul] + field_simp + ring + +theorem lt_sum_iff (i j k : ℕ) : + sumLeft (i,j,k) < sumRight (i,j,k) ↔ + (rationalEnumeration i : ℝ) < (rationalEnumeration j : ℝ)+(rationalEnumeration k : ℝ) := by + have hd : (0 : ℝ) < (denominator i : ℝ)*denominator j*denominator k := by + exact mul_pos (mul_pos (by exact_mod_cast denominator_pos i) + (by exact_mod_cast denominator_pos j)) (by exact_mod_cast denominator_pos k) + constructor + · intro h + have hh : (sumLeft (i,j,k) : ℝ) < (sumRight (i,j,k) : ℝ) := by exact_mod_cast h + have hp : 0 < ((rationalEnumeration j : ℝ)+(rationalEnumeration k : ℝ)-(rationalEnumeration i : ℝ))* + ((denominator i : ℝ)*denominator j*denominator k) := by + rw [sum_difference]; exact sub_pos.mpr hh + exact sub_pos.mp ((mul_pos_iff_of_pos_right hd).mp hp) + · intro h + have hh := mul_pos (sub_pos.mpr h) hd + rw [sum_difference] at hh + exact_mod_cast sub_pos.mp hh + +theorem sum_lt_iff (i j k : ℕ) : + sumRight (i,j,k) < sumLeft (i,j,k) ↔ + (rationalEnumeration j : ℝ)+(rationalEnumeration k : ℝ) < (rationalEnumeration i : ℝ) := by + have hd : (0 : ℝ) < (denominator i : ℝ)*denominator j*denominator k := by + exact mul_pos (mul_pos (by exact_mod_cast denominator_pos i) + (by exact_mod_cast denominator_pos j)) (by exact_mod_cast denominator_pos k) + constructor + · intro h + have hh : (sumRight (i,j,k) : ℝ) < (sumLeft (i,j,k) : ℝ) := by exact_mod_cast h + have hp : ((rationalEnumeration j : ℝ)+(rationalEnumeration k : ℝ)-(rationalEnumeration i : ℝ))* + ((denominator i : ℝ)*denominator j*denominator k) < 0 := by + rw [sum_difference]; exact sub_neg.mpr hh + have hh' : (rationalEnumeration j : ℝ)+(rationalEnumeration k : ℝ)-(rationalEnumeration i : ℝ)<0 := by + by_contra hn + exact (not_lt_of_ge (mul_nonneg (le_of_not_gt hn) hd.le)) hp + exact sub_neg.mp hh' + · intro h + have hh := mul_neg_of_neg_of_pos (sub_neg.mpr h) hd + rw [sum_difference] at hh + exact_mod_cast sub_neg.mp hh + +end TuringRigidity.RationalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedBoundaryCertificates.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedBoundaryCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce8bb6f56d131092285887945d567d19c557c6cd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedBoundaryCertificates.lean @@ -0,0 +1,90 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.TrimmedProductGraph +import OAI.Computability.DegreeRigidity.OrdinalCodes.TrimmedSumGraph +import OAI.Computability.DegreeRigidity.OrdinalCodes.PaddedOmegaBoundary + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalCoding +universe u + +theorem product_certificates_at_exact_cut (R : ZFSet.{u}) (a b : Ordinal.{u}) + (ha0 : 0 < a) (hγ : Order.IsSuccLimit (a*b)) + (hcut : ordinalHeight (seed R) + a*b = a*b) + (hω : ZFSet.omega.{u} ∈ level R (a*b)) + (ha : a.toZFSet ∈ level R (a*b)) (hb : b.toZFSet ∈ level R (a*b)) + (hp : ∀ s < b, ProductCertificates (level R (a*b)) a s) + (hs : ∀ s < b, ∀ t < a, SumCertificates (level R (a*b)) (a*s) t) : + ProductCertificates (level R (a*b+1)) a b := by + apply product_certificates_at_limit_successor R (a*b) a b hγ hω ha hb + intro s hsb + have hmem (c : Ordinal.{u}) (hc : c < a*b) : c.toZFSet ∈ level R (a*b) := by + rw [ordinal_mem_level_iff,hcut]; exact hc + refine ⟨hmem _ (mul_lt_mul_of_pos_left hsb ha0),hp s hsb,?_⟩ + intro t hta + exact ⟨hmem _ (Ordinal.lt_mul_iff.mpr ⟨s,hsb,t,hta,rfl⟩),hs s hsb t hta⟩ + +theorem sum_certificates_at_exact_cut (R : ZFSet.{u}) (a b : Ordinal.{u}) + (hγ : Order.IsSuccLimit (a+b)) (hcut : ordinalHeight (seed R)+(a+b)=a+b) + (hω : ZFSet.omega.{u} ∈ level R (a+b)) + (ha : a.toZFSet ∈ level R (a+b)) (hb : b.toZFSet ∈ level R (a+b)) + (h0 : (∅ : ZFSet.{u}) ∈ level R (a+b)) (h1 : ({∅} : ZFSet.{u}) ∈ level R (a+b)) + (hs : ∀ t < b, SumCertificates (level R (a+b)) a t) : + SumCertificates (level R (a+b+1)) a b := by + apply sum_certificates_at_limit_successor R (a+b) a b hγ hω ha hb h0 h1 + intro t ht + refine ⟨?_,hs t ht⟩ + rw [ordinal_mem_level_iff,hcut] + exact (add_lt_add_iff_left a).mpr ht + +theorem lower_omega_closure_fixed_point (R : ZFSet.{u}) (β : Ordinal.{u}) + (hβ : Order.IsSuccLimit β) (hoff : ordinalHeight (seed R)+β=β) + (hpow : ∀ c < β, (Ordinal.omega0 ^ c).toZFSet ∈ level R β) : + Ordinal.omega0 ^ β = β := by + apply le_antisymm + · apply (Ordinal.opow_le_of_isSuccLimit (ne_of_gt Ordinal.omega0_pos) hβ).mpr + intro c hc + have h := (ordinal_mem_level_iff R β (Ordinal.omega0 ^ c)).mp (hpow c hc) + rw [hoff] at h + exact h.le + · exact Ordinal.right_le_opow β Ordinal.one_lt_omega0 + +theorem omega_boundary_product_of_smaller_certificates (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (β : Ordinal.{u}) + (hβ : 0 < β) (hoff : realSeedOffset+β=β) + (hp : ∀ s < Ordinal.omega0, + ProductCertificates (level (groundReals M) (Ordinal.omega0 ^ (β+1))) + (Ordinal.omega0 ^ β) s) + (hs : ∀ s < Ordinal.omega0, ∀ t < Ordinal.omega0 ^ β, + SumCertificates (level (groundReals M) (Ordinal.omega0 ^ (β+1))) + (Ordinal.omega0 ^ β*s) t) : + ProductCertificates (level (groundReals M) (Ordinal.omega0 ^ (β+1)+1)) + (Ordinal.omega0 ^ β) Ordinal.omega0 := by + let R := groundReals M + let a := Ordinal.omega0 ^ β + let b := Ordinal.omega0 ^ (β+1) + have hab : a * Ordinal.omega0 = b := (Ordinal.opow_add_one Ordinal.omega0 β).symm + have hβb : β < b := (lt_add_one β).trans_le (Ordinal.right_le_opow (β+1) Ordinal.one_lt_omega0) + have hcut : ordinalHeight (seed R)+b=b := by + rw [ground_seed_offset M hM hT] + exact offset_absorbed_above _ β b hoff hβb.le + have hmem (c : Ordinal.{u}) (hc : c < b) : c.toZFSet ∈ level R b := by + rw [ordinal_mem_level_iff,hcut]; exact hc + have ha : a.toZFSet ∈ level R b := hmem _ + ((Ordinal.opow_lt_opow_iff_right Ordinal.one_lt_omega0).mpr (lt_add_one β)) + have hb : Ordinal.omega0.toZFSet ∈ level R b := hmem _ (by + have h := (Ordinal.opow_lt_opow_iff_right Ordinal.one_lt_omega0).mpr + (show (1 : Ordinal.{u}) < β+1 from Order.lt_add_one_iff.mpr (by simpa only [zero_add] using Order.add_one_le_iff.mpr hβ)) + simpa only [Ordinal.opow_one] using h) + have hl : Order.IsSuccLimit b := Ordinal.isSuccLimit_opow_left + Ordinal.isSuccLimit_omega0 (ne_of_gt (hβ.trans (lt_add_one β))) + have result := product_certificates_at_exact_cut R a Ordinal.omega0 + (Ordinal.opow_pos β Ordinal.omega0_pos) (hab.symm ▸ hl) (by rw [hab]; exact hcut) + (by rw [hab]; exact ground_level_omega_mem M hM hT b) + (by rw [hab]; exact ha) (by rw [hab]; exact hb) + (by rw [hab]; exact hp) (by rw [hab]; exact hs) + simpa only [hab] using result + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedOrderDomains.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedOrderDomains.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ed1981c4d4828f62c4aedaedf0ecf659ee4f288 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedOrderDomains.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DegreeRigidity.Constructibility.FiniteStageSetBounds +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalProductSets +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalSumSets + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +theorem defined_set_at_successor (R : ZFSet.{u}) (γ : Ordinal.{u}) + (p : SentenceForm) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ level R γ) + (s : ZFSet.{u}) (hsub : s ⊆ level R γ) + (hs : ∀ z ∈ level R γ, p.Sat (level R γ : Set ZFSet) (cons z e) ↔ z ∈ s) : + s ∈ level R (γ+1) := by + have h := separation_mem_definablePower (level R γ) p e (fun i _ => he i) + have eq : (level R γ).sep (fun z => p.Sat (level R γ : Set ZFSet) (cons z e)) = s := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep] + exact ⟨fun ⟨hz,hp⟩ => (hs z hz).mp hp,fun hz => ⟨hsub hz,(hs z (hsub hz)).mpr hz⟩⟩ + rw [eq] at h + rwa [level_succ] + +noncomputable def trimmedProductDomainSentence : SentenceForm := + fromBounded (.existsMem 2 (.existsMem 2 (.orderedPair 2 1 0))) + +noncomputable def trimmedProductRelationSentence : SentenceForm := + .ex (.ex (fromBounded (.conj (.orderedPair 2 1 0) (productLessFormula 3 4 1 0)))) + +theorem product_domain_subset_limit (R : ZFSet.{u}) (γ : Ordinal.{u}) + (hγ : Order.IsSuccLimit γ) {a b : ZFSet.{u}} + (ha : a ∈ level R γ) (hb : b ∈ level R γ) : ZFSet.prod b a ⊆ level R γ := by + intro z hz + obtain ⟨s,hs,t,ht,rfl⟩ := ZFSet.mem_prod.mp hz + exact orderedPair_mem_level_limit R γ hγ + (level_transitive R γ _ hb _ hs) (level_transitive R γ _ ha _ ht) + +theorem product_domain_at_limit_successor (R : ZFSet.{u}) (γ : Ordinal.{u}) + (hγ : Order.IsSuccLimit γ) {a b : ZFSet.{u}} + (ha : a ∈ level R γ) (hb : b ∈ level R γ) : ZFSet.prod b a ∈ level R (γ+1) := by + let e := cons a (fun _ => b) + have he (i : ℕ) : e i ∈ level R γ := by cases i; exact ha; exact hb + apply defined_set_at_successor R γ trimmedProductDomainSentence e he _ + (product_domain_subset_limit R γ hγ ha hb) + intro z hz + rw [trimmedProductDomainSentence,bounded_sat,Formula.absolute _ _ (level_transitive R γ) _ + (fun i => by cases i; exact hz; exact he _)] + simp only [Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,e,ZFSet.mem_prod] + +theorem product_relation_at_limit_successor (R : ZFSet.{u}) (γ : Ordinal.{u}) + (hγ : Order.IsSuccLimit γ) {a b : ZFSet.{u}} + (ha : a ∈ level R γ) (hb : b ∈ level R γ) : productRelation a b ∈ level R (γ+1) := by + let A := level R γ + let e := cons a (fun _ => b) + have he (i : ℕ) : e i ∈ A := by cases i; exact ha; exact hb + have hd := product_domain_subset_limit R γ hγ ha hb + have hsub : productRelation a b ⊆ A := by + intro z hz + obtain ⟨x,hx,y,hy,rfl⟩ := ZFSet.mem_prod.mp (productRelation_on a b hz) + exact orderedPair_mem_level_limit R γ hγ (hd hx) (hd hy) + apply defined_set_at_successor R γ trimmedProductRelationSentence e he _ hsub + intro z hz + change (∃ x ∈ A, ∃ y ∈ A, (fromBounded _).Sat _ (cons y (cons x (cons z e)))) ↔ _ + have hspec (x y : ZFSet.{u}) (hx : x ∈ A) (hy : y ∈ A) : + (fromBounded (.conj (.orderedPair 2 1 0) (productLessFormula 3 4 1 0))).Sat + (A : Set ZFSet) (cons y (cons x (cons z e))) ↔ + z = ZFSet.pair x y ∧ ProductLess a b x y := by + rw [bounded_sat,Formula.absolute _ A (level_transitive R γ) _ (fun i => by + rcases i with _|_|_|i; exact hy; exact hx; exact hz; exact he i)] + simp only [Formula.Eval,Formula.eval_orderedPair,productLessFormula_eval,cons_zero,cons_succ,e] + constructor + · rintro ⟨x,hx,y,hy,h⟩ + obtain ⟨rfl,hless⟩ := (hspec x y hx hy).mp h + have hkeep := hless + obtain ⟨s,hs,t,ht,v,hv,w,hw,hx',hy',_⟩ := hless + exact (pair_mem_productRelation a b x y).mpr + ⟨ZFSet.mem_prod.mpr ⟨s,hs,t,ht,hx'⟩,ZFSet.mem_prod.mpr ⟨v,hv,w,hw,hy'⟩,hkeep⟩ + · intro h + obtain ⟨x,hx,y,hy,rfl⟩ := ZFSet.mem_prod.mp (productRelation_on a b h) + exact ⟨x,hd hx,y,hd hy,(hspec x y (hd hx) (hd hy)).mpr + ⟨rfl,((pair_mem_productRelation a b x y).mp h).2.2⟩⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedPaddedSum.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedPaddedSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..772653084c7b4512436a5e56c29d6e439dfd436e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedPaddedSum.lean @@ -0,0 +1,45 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.TrimmedBoundaryCertificates + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem padded_final_sum_of_smaller_certificates (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) {n : ℕ} (v : Fin n → Ordinal.{u}) + (β : Ordinal.{u}) (hβ : 0 < β) (hoff : realSeedOffset+β=β) (hv : vectorCode v ≤ β) + (hs : ∀ t < Ordinal.omega0 ^ vectorCode v, + SumCertificates (level (groundReals M) (paddedCode v β)) (Ordinal.omega0 ^ (β+1)) t) : + SumCertificates (level (groundReals M) (heightDomainIndex (paddedCode v β))) + (Ordinal.omega0 ^ (β+1)) (Ordinal.omega0 ^ vectorCode v) := by + let R := groundReals M + let a := Ordinal.omega0 ^ (β+1) + let b := Ordinal.omega0 ^ vectorCode v + let c := paddedCode v β + have hc : c = a+b := by change pairCode β (vectorCode v) = _; rw [pairCode,ite_eq_left hv] + have hca : a < c := by + rw [hc] + simpa only [add_zero] using (add_lt_add_iff_left a).mpr (Ordinal.opow_pos (vectorCode v) Ordinal.omega0_pos) + have hba : b < a := (Ordinal.opow_lt_opow_iff_right Ordinal.one_lt_omega0).mpr + (hv.trans_lt (lt_add_one β)) + have habs := offset_absorbed_above realSeedOffset β c hoff (padding_lt_paddedCode v β).le + have hcut : ordinalHeight (seed R)+c=c := by rw [ground_seed_offset M hM hT]; exact habs + have hmem (o : Ordinal.{u}) (ho : o < c) : o.toZFSet ∈ level R c := by + rw [ordinal_mem_level_iff,hcut]; exact ho + have hω := ground_level_omega_mem M hM hT c + have h0 := level_transitive R c _ hω _ ZFSet.omega_zero + have h1 : ({∅} : ZFSet.{u}) ∈ level R c := by + have h := level_transitive R c _ hω _ ((mem_omega _).mpr ⟨1,rfl⟩) + simpa [natSet] using h + have hlim := paddedCode_isSuccLimit v β hβ + have hresult := sum_certificates_at_exact_cut R a b (hc ▸ hlim) + (by rw [← hc]; exact hcut) (by rw [← hc]; exact hω) + (by rw [← hc]; exact hmem a hca) (by rw [← hc]; exact hmem b (hba.trans hca)) + (by rw [← hc]; exact h0) (by rw [← hc]; exact h1) (by rw [← hc]; exact hs) + rw [heightDomainIndex_of_absorbed _ habs] + simpa only [← hc] using hresult + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedPresentation.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a0fd24f0e26ebab13bd32bb51eeffadf4504025 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedPresentation.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.TrimmedOrderDomains + +namespace OAI + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem order_certificate_of_exact_pairs (d r f : ZFSet.{u}) (o : Ordinal.{u}) + (j : ZFSet.{u} → ZFSet.{u}) + (hj : ∀ x ∈ d, j x ∈ o.toZFSet) + (hs : ∀ z ∈ o.toZFSet, ∃ x ∈ d, j x = z) + (he : ∀ x ∈ d, ∀ y ∈ d, ZFSet.pair x y ∈ r ↔ j x ∈ j y) + (hf : ∀ z, z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (j x)) : + OrderTypeCertificate d r o.toZFSet f := by + have pair (x : ZFSet.{u}) (hx : x ∈ d) := (hf _).mpr ⟨x,hx,rfl⟩ + have eq (x z : ZFSet.{u}) (h : ZFSet.pair x z ∈ f) : z = j x := by + obtain ⟨y,_,hh⟩ := (hf _).mp h + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hh + rfl + refine ⟨ZFSet.isOrdinal_toZFSet _,⟨fun _ h => h,fun _ _ _ h _ => h,?_,?_,?_⟩,?_⟩ + · intro z hz + obtain ⟨x,hx,rfl⟩ := (hf z).mp hz + exact ⟨x,hx,j x,hj x hx,rfl⟩ + · intro x hx + exact ⟨j x,hj x hx,pair x hx,fun z _ hz => eq x z hz⟩ + · intro x hx v _ hxv + rw [eq x v hxv] + constructor + · intro z hz + obtain ⟨y,hy,rfl⟩ := hs z ((ZFSet.isOrdinal_toZFSet o).subset_of_mem (hj x hx) hz) + exact ⟨y,hy,(he y hy x hx).mpr hz,pair y hy⟩ + · intro y hy hyx z _ hyz + rw [eq y z hyz] + exact (he y hy x hx).mp hyx + · intro z hz + obtain ⟨x,hx,rfl⟩ := hs z hz + exact ⟨x,hx,pair x hx⟩ + +theorem presentation_graph_at_limit_successor (R : ZFSet.{u}) (γ : Ordinal.{u}) + (hγ : Order.IsSuccLimit γ) (d r : ZFSet.{u}) (o : Ordinal.{u}) + (j : ZFSet.{u} → ZFSet.{u}) (hd : d ⊆ level R γ) + (hjA : ∀ x ∈ d, j x ∈ level R γ) + (hj : ∀ x ∈ d, j x ∈ o.toZFSet) + (hs : ∀ z ∈ o.toZFSet, ∃ x ∈ d, j x = z) + (he : ∀ x ∈ d, ∀ y ∈ d, ZFSet.pair x y ∈ r ↔ j x ∈ j y) + (p : SentenceForm) (e : ℕ → ZFSet.{u}) (henv : ∀ i, e i ∈ level R γ) + (hp : ∀ z ∈ level R γ, p.Sat (level R γ : Set ZFSet) (cons z e) ↔ + ∃ x ∈ d, z = ZFSet.pair x (j x)) : + ∃ f ∈ level R (γ+1), OrderTypeCertificate d r o.toZFSet f := by + let A := level R γ + let f := A.sep (fun z => p.Sat (A : Set ZFSet) (cons z e)) + have hf : f ∈ level R (γ+1) := by + rw [level_succ] + exact separation_mem_definablePower A p e (fun i _ => henv i) + have hexact (z : ZFSet.{u}) : z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (j x) := by + change z ∈ A.sep _ ↔ _ + rw [ZFSet.mem_sep] + constructor + · rintro ⟨hz,h⟩; exact (hp z hz).mp h + · rintro ⟨x,hx,rfl⟩ + have hz := orderedPair_mem_level_limit R γ hγ (hd hx) (hjA x hx) + exact ⟨hz,(hp _ hz).mpr ⟨x,hx,rfl⟩⟩ + exact ⟨f,hf,order_certificate_of_exact_pairs d r f o j hj hs he hexact⟩ + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedProductGraph.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedProductGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..bae48b88c86a95b9d228ab12d99dba6b9132e902 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedProductGraph.lean @@ -0,0 +1,118 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.TrimmedPresentation +import OAI.Computability.DegreeRigidity.OrdinalCodes.CodeOperationCertificates + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalCoding +universe u + +noncomputable def trimmedProductGraphSentence : SentenceForm := + .ex (.ex (.ex (.ex (.ex (.conj + (fromBounded (.conj (.member 4 7) (.conj (.member 3 6) + (.conj (.orderedPair 2 4 3) (.orderedPair 5 2 1))))) + (.conj (ordinalProductAt 0 6 4) (codeSumAt 1 0 3))))))) + +theorem trimmedProductGraphSentence_semantics (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) : + trimmedProductGraphSentence.Sat (A : Set ZFSet) e ↔ + ∃ s ∈ A, ∃ t ∈ A, ∃ x ∈ A, ∃ y ∈ A, ∃ v ∈ A, + (s ∈ e 2 ∧ t ∈ e 1 ∧ x = ZFSet.pair s t ∧ e 0 = ZFSet.pair x y) ∧ + (ordinalProductAt 0 6 4).Sat (A : Set ZFSet) (cons v (cons y (cons x (cons t (cons s e))))) ∧ + (codeSumAt 1 0 3).Sat (A : Set ZFSet) (cons v (cons y (cons x (cons t (cons s e))))) := by + change (∃ s ∈ A, ∃ t ∈ A, ∃ x ∈ A, ∃ y ∈ A, ∃ v ∈ A, _) ↔ _ + apply exists_congr; intro s; apply and_congr_right; intro hs + apply exists_congr; intro t; apply and_congr_right; intro ht + apply exists_congr; intro x; apply and_congr_right; intro hx + apply exists_congr; intro y; apply and_congr_right; intro hy + apply exists_congr; intro v; apply and_congr_right; intro hv + have hE : ∀ i, cons v (cons y (cons x (cons t (cons s e)))) i ∈ A := by + intro i; rcases i with _|_|_|_|_|i + exact hv; exact hy; exact hx; exact ht; exact hs; exact he i + rw [SentenceForm.Sat,bounded_sat,Formula.absolute _ A hA _ hE] + simp only [Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,SentenceForm.Sat] + +theorem trimmedProductGraphSentence_spec (R : ZFSet.{u}) (γ a b : Ordinal.{u}) + (hγ : Order.IsSuccLimit γ) (hω : ZFSet.omega.{u} ∈ level R γ) + (ha : a.toZFSet ∈ level R γ) (hb : b.toZFSet ∈ level R γ) + (hlocal : ∀ s < b, (a*s).toZFSet ∈ level R γ ∧ + ProductCertificates (level R γ) a s ∧ ∀ t < a, + (a*s+t).toZFSet ∈ level R γ ∧ SumCertificates (level R γ) (a*s) t) + (z : ZFSet.{u}) (hz : z ∈ level R γ) : + trimmedProductGraphSentence.Sat (level R γ : Set ZFSet) + (cons z (cons a.toZFSet (fun _ => b.toZFSet))) ↔ + ∃ x ∈ ZFSet.prod b.toZFSet a.toZFSet, z = ZFSet.pair x (productValue a x) := by + let A := level R γ + let e := cons z (cons a.toZFSet (fun _ => b.toZFSet)) + have he (i : ℕ) : e i ∈ A := by rcases i with _|_|i; exact hz; exact ha; exact hb + rw [trimmedProductGraphSentence_semantics A (level_transitive R γ) e he] + constructor + · rintro ⟨s,hs,t,ht,x,hx,y,hy,v,hv,⟨hsb,hta,hxdef,hzdef⟩,hp,hq⟩ + change s ∈ b.toZFSet at hsb + obtain ⟨s,hsb,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hsb + have hsb := Ordinal.toZFSet_mem_toZFSet_iff.mp hsb + change t ∈ a.toZFSet at hta + obtain ⟨t,hta,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hta + have hta := Ordinal.toZFSet_mem_toZFSet_iff.mp hta + have hE : ∀ i, cons v (cons y (cons x (cons t.toZFSet (cons s.toZFSet e)))) i ∈ A := by + intro i; rcases i with _|_|_|_|_|i + exact hv; exact hy; exact hx; exact ht; exact hs; exact he i + have hvdef : v = (a*s).toZFSet := by + rw [ordinalProductAt,SentenceForm.sat_rename] at hp + exact productSentence_sound A (level_transitive R γ) _ (fun i => hE _) a s rfl rfl hp + have hydef : y = (a*s+t).toZFSet := + codeSumAt_sound A (level_transitive R γ) 1 0 3 _ hE (a*s) t hvdef rfl hq + refine ⟨x,ZFSet.mem_prod.mpr ⟨s.toZFSet,Ordinal.toZFSet_mem_toZFSet_iff.mpr hsb, + t.toZFSet,Ordinal.toZFSet_mem_toZFSet_iff.mpr hta,hxdef⟩,?_⟩ + change z = ZFSet.pair x y at hzdef + rw [hzdef,hydef,hxdef,productValue_pair,Ordinal.rank_toZFSet,Ordinal.rank_toZFSet] + · rintro ⟨x,hxd,hzdef⟩ + obtain ⟨s,hsb,t,hta,rfl⟩ := ZFSet.mem_prod.mp hxd + change s ∈ b.toZFSet at hsb + obtain ⟨s,hsb,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hsb + have hsb := Ordinal.toZFSet_mem_toZFSet_iff.mp hsb + change t ∈ a.toZFSet at hta + obtain ⟨t,hta,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hta + have hta := Ordinal.toZFSet_mem_toZFSet_iff.mp hta + have hs := level_transitive R γ _ hb _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hsb) + have ht := level_transitive R γ _ ha _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hta) + have hx := orderedPair_mem_level_limit R γ hγ hs ht + obtain ⟨hv,hp,hrest⟩ := hlocal s hsb + obtain ⟨hy,hq⟩ := hrest t hta + let E := cons (a*s).toZFSet (cons (a*s+t).toZFSet + (cons (ZFSet.pair s.toZFSet t.toZFSet) (cons t.toZFSet (cons s.toZFSet e)))) + have hE (i : ℕ) : E i ∈ A := by + rcases i with _|_|_|_|_|i + exact hv; exact hy; exact hx; exact ht; exact hs; exact he i + refine ⟨s.toZFSet,hs,t.toZFSet,ht,_,hx,(a*s+t).toZFSet,hy,(a*s).toZFSet,hv, + ⟨Ordinal.toZFSet_mem_toZFSet_iff.mpr hsb,Ordinal.toZFSet_mem_toZFSet_iff.mpr hta,rfl,?_⟩,?_,?_⟩ + · simpa only [e,cons_zero,productValue_pair,Ordinal.rank_toZFSet] using hzdef + · exact ordinalProductAt_of_certificates A (level_transitive R γ) 0 6 4 E hE a s rfl rfl hp rfl + · exact codeSumAt_of_certificates A (level_transitive R γ) hω 1 0 3 E hE (a*s) t rfl rfl hq rfl + +theorem product_certificates_at_limit_successor (R : ZFSet.{u}) (γ a b : Ordinal.{u}) + (hγ : Order.IsSuccLimit γ) (hω : ZFSet.omega.{u} ∈ level R γ) + (ha : a.toZFSet ∈ level R γ) (hb : b.toZFSet ∈ level R γ) + (hlocal : ∀ s < b, (a*s).toZFSet ∈ level R γ ∧ + ProductCertificates (level R γ) a s ∧ ∀ t < a, + (a*s+t).toZFSet ∈ level R γ ∧ SumCertificates (level R γ) (a*s) t) : + ProductCertificates (level R (γ+1)) a b := by + refine ⟨product_domain_at_limit_successor R γ hγ ha hb, + product_relation_at_limit_successor R γ hγ ha hb,?_⟩ + apply presentation_graph_at_limit_successor R γ hγ _ _ (a*b) (productValue a) + (product_domain_subset_limit R γ hγ ha hb) ?_ + (productValue_mem a b) (productValue_surjective a b) (productValue_relation a b) + trimmedProductGraphSentence (cons a.toZFSet (fun _ => b.toZFSet)) + (fun i => by cases i; exact ha; exact hb) + · exact trimmedProductGraphSentence_spec R γ a b hγ hω ha hb hlocal + · intro x hx + obtain ⟨s,hs,t,ht,rfl⟩ := ZFSet.mem_prod.mp hx + obtain ⟨s,hs,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hs + obtain ⟨t,ht,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ht + have hs := Ordinal.toZFSet_mem_toZFSet_iff.mp hs + have ht := Ordinal.toZFSet_mem_toZFSet_iff.mp ht + simpa only [productValue_pair,Ordinal.rank_toZFSet] using ((hlocal s hs).2.2 t ht).1 + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedSumDomains.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedSumDomains.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b65c86204e49f3314629c005b94b4c21731f1e7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedSumDomains.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.TrimmedOrderDomains + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +noncomputable def trimmedSumDomainSentence : SentenceForm := fromBounded + (.disj (.existsMem 1 (.orderedPair 1 4 0)) (.existsMem 2 (.orderedPair 1 5 0))) + +noncomputable def trimmedSumRelationSentence : SentenceForm := + .ex (.ex (fromBounded (.conj (.orderedPair 2 1 0) (sumLessFormula 3 4 5 6 1 0)))) + +theorem sum_domain_subset_limit (R : ZFSet.{u}) (γ : Ordinal.{u}) + (hγ : Order.IsSuccLimit γ) {a b : ZFSet.{u}} + (ha : a ∈ level R γ) (hb : b ∈ level R γ) + (h0 : (∅ : ZFSet.{u}) ∈ level R γ) (h1 : ({∅} : ZFSet.{u}) ∈ level R γ) : + sumDomain a b ⊆ level R γ := by + intro z hz + rcases (mem_sumDomain a b z).mp hz with ⟨s,hs,rfl⟩|⟨s,hs,rfl⟩ + · exact orderedPair_mem_level_limit R γ hγ h0 (level_transitive R γ _ ha _ hs) + · exact orderedPair_mem_level_limit R γ hγ h1 (level_transitive R γ _ hb _ hs) + +theorem sum_domain_at_limit_successor (R : ZFSet.{u}) (γ : Ordinal.{u}) + (hγ : Order.IsSuccLimit γ) {a b : ZFSet.{u}} + (ha : a ∈ level R γ) (hb : b ∈ level R γ) + (h0 : (∅ : ZFSet.{u}) ∈ level R γ) (h1 : ({∅} : ZFSet.{u}) ∈ level R γ) : + sumDomain a b ∈ level R (γ+1) := by + let e := cons a (cons b (cons ∅ (fun _ => {∅}))) + have he (i : ℕ) : e i ∈ level R γ := by + rcases i with _|_|_|i; exact ha; exact hb; exact h0; exact h1 + apply defined_set_at_successor R γ trimmedSumDomainSentence e he _ + (sum_domain_subset_limit R γ hγ ha hb h0 h1) + intro z hz + rw [trimmedSumDomainSentence,bounded_sat,Formula.absolute _ _ (level_transitive R γ) _ + (fun i => by cases i; exact hz; exact he _)] + simp only [Formula.eval_disj,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,e, + mem_sumDomain,leftNode,rightNode] + +theorem sum_relation_at_limit_successor (R : ZFSet.{u}) (γ : Ordinal.{u}) + (hγ : Order.IsSuccLimit γ) {a b : ZFSet.{u}} + (ha : a ∈ level R γ) (hb : b ∈ level R γ) + (h0 : (∅ : ZFSet.{u}) ∈ level R γ) (h1 : ({∅} : ZFSet.{u}) ∈ level R γ) : + sumRelation a b ∈ level R (γ+1) := by + let A := level R γ + let e := cons a (cons b (cons ∅ (fun _ => {∅}))) + have he (i : ℕ) : e i ∈ A := by + rcases i with _|_|_|i; exact ha; exact hb; exact h0; exact h1 + have hd := sum_domain_subset_limit R γ hγ ha hb h0 h1 + have hsub : sumRelation a b ⊆ A := by + intro z hz + obtain ⟨x,hx,y,hy,rfl⟩ := ZFSet.mem_prod.mp (sumRelation_on a b hz) + exact orderedPair_mem_level_limit R γ hγ (hd hx) (hd hy) + apply defined_set_at_successor R γ trimmedSumRelationSentence e he _ hsub + intro z hz + change (∃ x ∈ A, ∃ y ∈ A, (fromBounded _).Sat _ (cons y (cons x (cons z e)))) ↔ _ + have hspec (x y : ZFSet.{u}) (hx : x ∈ A) (hy : y ∈ A) : + (fromBounded (.conj (.orderedPair 2 1 0) (sumLessFormula 3 4 5 6 1 0))).Sat + (A : Set ZFSet) (cons y (cons x (cons z e))) ↔ + z = ZFSet.pair x y ∧ SumLess a b x y := by + rw [bounded_sat,Formula.absolute _ A (level_transitive R γ) _ (fun i => by + rcases i with _|_|_|i; exact hy; exact hx; exact hz; exact he i)] + simp only [Formula.Eval,Formula.eval_orderedPair] + rw [sumLessFormula_eval _ _ _ _ _ _ _ rfl rfl] + rfl + constructor + · rintro ⟨x,hx,y,hy,h⟩ + obtain ⟨rfl,hless⟩ := (hspec x y hx hy).mp h + have hkeep := hless + have hxy : x ∈ sumDomain a b ∧ y ∈ sumDomain a b := by + rcases hless with ⟨s,hs,t,ht,rfl,rfl,_⟩|⟨s,hs,t,ht,rfl,rfl⟩|⟨s,hs,t,ht,rfl,rfl,_⟩ + · exact ⟨(mem_sumDomain _ _ _).mpr (Or.inl ⟨s,hs,rfl⟩), + (mem_sumDomain _ _ _).mpr (Or.inl ⟨t,ht,rfl⟩)⟩ + · exact ⟨(mem_sumDomain _ _ _).mpr (Or.inl ⟨s,hs,rfl⟩), + (mem_sumDomain _ _ _).mpr (Or.inr ⟨t,ht,rfl⟩)⟩ + · exact ⟨(mem_sumDomain _ _ _).mpr (Or.inr ⟨s,hs,rfl⟩), + (mem_sumDomain _ _ _).mpr (Or.inr ⟨t,ht,rfl⟩)⟩ + exact (pair_mem_sumRelation a b x y).mpr ⟨hxy.1,hxy.2,hkeep⟩ + · intro h + obtain ⟨x,hx,y,hy,rfl⟩ := ZFSet.mem_prod.mp (sumRelation_on a b h) + exact ⟨x,hd hx,y,hd hy,(hspec x y (hd hx) (hd hy)).mpr + ⟨rfl,((pair_mem_sumRelation a b x y).mp h).2.2⟩⟩ + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedSumGraph.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedSumGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..4395e975d097c198b11522af383d8a7ecbf9ace6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/TrimmedSumGraph.lean @@ -0,0 +1,112 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.TrimmedSumDomains +import OAI.Computability.DegreeRigidity.OrdinalCodes.TrimmedPresentation +import OAI.Computability.DegreeRigidity.OrdinalCodes.CodeOperationCertificates + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalCoding +universe u + +noncomputable def trimmedSumGraphSentence : SentenceForm := .ex (.ex (.ex + (.disj (fromBounded (.conj (.member 2 4) (.conj (.orderedPair 1 6 2) + (.conj (.orderedPair 3 1 0) (.equal 0 2))))) + (.conj (fromBounded (.conj (.member 2 5) (.conj (.orderedPair 1 7 2) + (.orderedPair 3 1 0)))) (codeSumAt 0 4 2))))) + +theorem trimmedSumGraphSentence_semantics (A : ZFSet.{u}) (hA : Transitive A) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) : + trimmedSumGraphSentence.Sat (A : Set ZFSet) e ↔ + ∃ t ∈ A, ∃ x ∈ A, ∃ y ∈ A, + (t ∈ e 1 ∧ x = ZFSet.pair (e 3) t ∧ e 0 = ZFSet.pair x y ∧ y = t) ∨ + ((t ∈ e 2 ∧ x = ZFSet.pair (e 4) t ∧ e 0 = ZFSet.pair x y) ∧ + (codeSumAt 0 4 2).Sat (A : Set ZFSet) (cons y (cons x (cons t e)))) := by + change (∃ t ∈ A, ∃ x ∈ A, ∃ y ∈ A, _) ↔ _ + apply exists_congr; intro t; apply and_congr_right; intro ht + apply exists_congr; intro x; apply and_congr_right; intro hx + apply exists_congr; intro y; apply and_congr_right; intro hy + have hE : ∀ i, cons y (cons x (cons t e)) i ∈ A := by + intro i; rcases i with _|_|_|i; exact hy; exact hx; exact ht; exact he i + rw [SentenceForm.sat_disj,SentenceForm.Sat] + simp only [bounded_sat,Formula.absolute _ A hA _ hE,Formula.Eval, + Formula.eval_orderedPair,cons_zero,cons_succ] + +theorem trimmedSumGraphSentence_spec (R : ZFSet.{u}) (γ a b : Ordinal.{u}) + (hγ : Order.IsSuccLimit γ) (hω : ZFSet.omega.{u} ∈ level R γ) + (ha : a.toZFSet ∈ level R γ) (hb : b.toZFSet ∈ level R γ) + (h0 : (∅ : ZFSet.{u}) ∈ level R γ) (h1 : ({∅} : ZFSet.{u}) ∈ level R γ) + (hlocal : ∀ t < b, (a+t).toZFSet ∈ level R γ ∧ SumCertificates (level R γ) a t) + (z : ZFSet.{u}) (hz : z ∈ level R γ) : + trimmedSumGraphSentence.Sat (level R γ : Set ZFSet) + (cons z (cons a.toZFSet (cons b.toZFSet (cons ∅ (fun _ => {∅}))))) ↔ + ∃ x ∈ sumDomain a.toZFSet b.toZFSet, z = ZFSet.pair x (sumValue a x) := by + let A := level R γ + let e := cons z (cons a.toZFSet (cons b.toZFSet (cons ∅ (fun _ => {∅})))) + have he (i : ℕ) : e i ∈ A := by + rcases i with _|_|_|_|i; exact hz; exact ha; exact hb; exact h0; exact h1 + rw [trimmedSumGraphSentence_semantics A (level_transitive R γ) e he] + constructor + · rintro ⟨t,ht,x,hx,y,hy,hleft|⟨hright,hq⟩⟩ + · obtain ⟨hta,hxdef,hzdef,hydef⟩ := hleft + change x = leftNode t at hxdef + refine ⟨x,(mem_sumDomain _ _ _).mpr (Or.inl ⟨t,hta,hxdef⟩),?_⟩ + change z = ZFSet.pair x y at hzdef + rw [hzdef,hydef,hxdef,sumValue_left] + · obtain ⟨htb,hxdef,hzdef⟩ := hright + change t ∈ b.toZFSet at htb + obtain ⟨t,htb,rfl⟩ := Ordinal.mem_toZFSet_iff.mp htb + have htb := Ordinal.toZFSet_mem_toZFSet_iff.mp htb + have hE : ∀ i, cons y (cons x (cons t.toZFSet e)) i ∈ A := by + intro i; rcases i with _|_|_|i; exact hy; exact hx; exact ht; exact he i + have hydef := codeSumAt_sound A (level_transitive R γ) 0 4 2 _ hE a t rfl rfl hq + change x = rightNode t.toZFSet at hxdef + refine ⟨x,(mem_sumDomain _ _ _).mpr (Or.inr + ⟨t.toZFSet,Ordinal.toZFSet_mem_toZFSet_iff.mpr htb,hxdef⟩),?_⟩ + change z = ZFSet.pair x y at hzdef + change y = (a+t).toZFSet at hydef + rw [hzdef,hydef,hxdef,sumValue_right,Ordinal.rank_toZFSet] + · rintro ⟨x,hx,hzdef⟩ + rcases (mem_sumDomain _ _ _).mp hx with ⟨t,ht,rfl⟩|⟨t,ht,rfl⟩ + · have htA := level_transitive R γ _ ha _ ht + have hxA := orderedPair_mem_level_limit R γ hγ h0 htA + refine ⟨t,htA,_,hxA,t,htA,Or.inl ⟨ht,rfl,?_,rfl⟩⟩ + rw [sumValue_left] at hzdef + simpa only [e,cons_zero,leftNode] using hzdef + · obtain ⟨t,ht,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ht + have ht := Ordinal.toZFSet_mem_toZFSet_iff.mp ht + have htA := level_transitive R γ _ hb _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr ht) + have hxA := orderedPair_mem_level_limit R γ hγ h1 htA + obtain ⟨hy,hq⟩ := hlocal t ht + let E := cons (a+t).toZFSet (cons (rightNode t.toZFSet) (cons t.toZFSet e)) + have hE (i : ℕ) : E i ∈ A := by + rcases i with _|_|_|i; exact hy; exact hxA; exact htA; exact he i + refine ⟨t.toZFSet,htA,_,hxA,(a+t).toZFSet,hy,Or.inr + ⟨⟨Ordinal.toZFSet_mem_toZFSet_iff.mpr ht,rfl,?_⟩,?_⟩⟩ + · rw [sumValue_right,Ordinal.rank_toZFSet] at hzdef + simpa only [e,cons_zero,rightNode] using hzdef + · exact codeSumAt_of_certificates A (level_transitive R γ) hω 0 4 2 E hE a t rfl rfl hq rfl + +theorem sum_certificates_at_limit_successor (R : ZFSet.{u}) (γ a b : Ordinal.{u}) + (hγ : Order.IsSuccLimit γ) (hω : ZFSet.omega.{u} ∈ level R γ) + (ha : a.toZFSet ∈ level R γ) (hb : b.toZFSet ∈ level R γ) + (h0 : (∅ : ZFSet.{u}) ∈ level R γ) (h1 : ({∅} : ZFSet.{u}) ∈ level R γ) + (hlocal : ∀ t < b, (a+t).toZFSet ∈ level R γ ∧ SumCertificates (level R γ) a t) : + SumCertificates (level R (γ+1)) a b := by + refine ⟨sum_domain_at_limit_successor R γ hγ ha hb h0 h1, + sum_relation_at_limit_successor R γ hγ ha hb h0 h1,?_⟩ + apply presentation_graph_at_limit_successor R γ hγ _ _ (a+b) (sumValue a) + (sum_domain_subset_limit R γ hγ ha hb h0 h1) ?_ + (sumValue_mem a b) (sumValue_surjective a b) (sumValue_relation a b) + trimmedSumGraphSentence (cons a.toZFSet (cons b.toZFSet (cons ∅ (fun _ => {∅})))) + (fun i => by rcases i with _|_|_|i; exact ha; exact hb; exact h0; exact h1) + · exact trimmedSumGraphSentence_spec R γ a b hγ hω ha hb h0 h1 hlocal + · intro x hx + rcases (mem_sumDomain _ _ _).mp hx with ⟨t,ht,rfl⟩|⟨t,ht,rfl⟩ + · simpa only [sumValue_left] using level_transitive R γ _ ha _ ht + · obtain ⟨t,ht,rfl⟩ := Ordinal.mem_toZFSet_iff.mp ht + have ht := Ordinal.toZFSet_mem_toZFSet_iff.mp ht + simpa only [sumValue_right,Ordinal.rank_toZFSet] using (hlocal t ht).1 + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/VectorCodeCertificates.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/VectorCodeCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..96fbe13f58259ac2f9f115df33bef0160198857b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/VectorCodeCertificates.lean @@ -0,0 +1,111 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.CodeBranchCertificates +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalDecoderDomains + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +def VectorCodeCertificates (M : ZFSet.{u}) : {n : ℕ} → (Fin n → Ordinal.{u}) → Prop + | 0, _ => True + | _+1, v => + (vectorCode (fun i => v i.succ)).toZFSet ∈ M ∧ + PairCodeCertificates M (v 0) (vectorCode (fun i => v i.succ)) ∧ + VectorCodeCertificates M (fun i => v i.succ) + +theorem VectorCodeCertificates.mono {M N : ZFSet.{u}} {n : ℕ} {v : Fin n → Ordinal.{u}} + (h : VectorCodeCertificates M v) (hMN : M ⊆ N) : VectorCodeCertificates N v := by + induction n with + | zero => trivial + | succ n ih => exact ⟨hMN h.1,h.2.1.mono hMN,ih h.2.2⟩ + +theorem vectorCodeSentence_of_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (n : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (v : Fin n → Ordinal.{u}) (hv : ∀ i, e (i.val+1) = (v i).toZFSet) + (hcert : VectorCodeCertificates M v) (hc : e 0 = (vectorCode v).toZFSet) : + (vectorCodeSentence n).Sat (M : Set ZFSet) e := by + induction n generalizing e with + | zero => + rw [vectorCodeSentence,bounded_sat,Formula.absolute _ M hM e he,ordinalOneMatrix_eval] + exact hc + | succ n ih => + obtain ⟨ht,hp,hs⟩ := hcert + let t := (vectorCode (fun i => v i.succ)).toZFSet + refine ⟨t,ht,?_,?_⟩ + · rw [SentenceForm.sat_rename] + apply pairCodeSentence_of_certificates M hM hω + (fun i => cons t e (if i = 0 then 1 else if i = 1 then 2 else 0)) (fun i => by + split; exact he 0 + split; exact he 1 + exact ht) (v 0) (vectorCode (fun i => v i.succ)) (hv 0) rfl hp + exact hc + · rw [SentenceForm.sat_rename] + exact ih _ (fun i => by cases i; exact ht; exact he _) _ (fun i => hv i.succ) hs rfl + +def PaddedCodeCertificates (M : ZFSet.{u}) {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) : Prop := + β.toZFSet ∈ M ∧ (vectorCode v).toZFSet ∈ M ∧ + PairCodeCertificates M β (vectorCode v) ∧ VectorCodeCertificates M v + +theorem PaddedCodeCertificates.mono {M N : ZFSet.{u}} {n : ℕ} + {v : Fin n → Ordinal.{u}} {β : Ordinal.{u}} + (h : PaddedCodeCertificates M v β) (hMN : M ⊆ N) : PaddedCodeCertificates N v β := + ⟨hMN h.1,hMN h.2.1,h.2.2.1.mono hMN,h.2.2.2.mono hMN⟩ + +theorem paddedCodeSentence_of_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (n : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) (hv : ∀ i, e (i.val+1) = (v i).toZFSet) + (hcert : PaddedCodeCertificates M v β) (hc : e 0 = (paddedCode v β).toZFSet) : + (paddedCodeSentence n).Sat (M : Set ZFSet) e := by + obtain ⟨hb,ht,hp,hs⟩ := hcert + refine ⟨β.toZFSet,hb,(vectorCode v).toZFSet,ht,?_,?_⟩ + · rw [SentenceForm.sat_rename] + exact pairCodeSentence_of_certificates M hM hω _ (fun i => by + split; exact he 0 + split; exact hb + exact ht) β (vectorCode v) rfl rfl hp hc + · rw [SentenceForm.sat_rename] + exact vectorCodeSentence_of_certificates M hM hω n _ + (fun i => by cases i; exact ht; exact he _) v hv hs rfl + +theorem paddedEntrySentence_of_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) (n : ℕ) (k : Fin n) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) (hc : e 1 = (paddedCode v β).toZFSet) + (hcert : PaddedCodeCertificates M v β) (hy : e 0 = (v k).toZFSet) : + (paddedEntrySentence n k).Sat (M : Set ZFSet) e := by + let w : ℕ → ZFSet.{u} := fun i => if hi : i < n then (v ⟨i,hi⟩).toZFSet else e 0 + have hw (i : ℕ) : w i ∈ M := by + dsimp [w] + split + · exact paddedCode_entries_mem M hM v β (hc ▸ he 1) _ + · exact he 0 + apply (paddedEntrySentence_semantics M n k e).mpr + refine ⟨w,fun i _ => hw i,?_,?_⟩ + · simpa [w,k.isLt] using hy + · exact paddedCodeSentence_of_certificates M hM hω n (cons (e 1) w) + (fun i => by cases i; exact he 1; exact hw _) v β + (fun i => by simp [w,i.isLt]) hcert hc + +theorem largestPaddedEntrySentence_of_certificates (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (n : ℕ) (k : Fin n) (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hβ : realSeedOffset ≤ β) (e : ℕ → ZFSet.{u}) + (he : e 0 ∈ level (groundReals M) (heightDomainIndex (paddedCode v β))) + (hcert : PaddedCodeCertificates (level (groundReals M) (heightDomainIndex (paddedCode v β))) v β) : + (largestPaddedEntrySentence n k).Sat + (level (groundReals M) (heightDomainIndex (paddedCode v β)) : Set ZFSet) e ↔ + e 0 = (v k).toZFSet := by + refine ⟨largestPaddedEntrySentence_sound M hM hT n k v β hβ e he,?_⟩ + intro hy + rw [largestPaddedEntrySentence,bindLargestOrdinal_ground_domain _ M hM hT _ + (hβ.trans (padding_lt_paddedCode v β).le),SentenceForm.sat_rename] + have heq : (fun i => cons (paddedCode v β).toZFSet e (if i = 0 then 1 else 0)) = + cons (e 0) (fun _ => (paddedCode v β).toZFSet) := by + funext i; cases i <;> rfl + rw [heq] + exact paddedEntrySentence_of_certificates _ (level_transitive _ _) (ground_level_omega_mem M hM hT _) + n k _ (fun i => by cases i; exact he; exact (padded_height_domain M hM hT v β hβ).1) + v β rfl hcert hy + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/VectorCodeLevels.lean b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/VectorCodeLevels.lean new file mode 100644 index 0000000000000000000000000000000000000000..53ce1cd97acc592d6fb12d68e431d02c86eba439 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/OrdinalCodes/VectorCodeLevels.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.CodeBranchLevels +import OAI.Computability.DegreeRigidity.OrdinalCodes.VectorCodeCertificates + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem vectorCode_certificates_at_levels (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {n : ℕ} (v : Fin n → Ordinal.{u}) (hv : ∀ i, (v i).toZFSet ∈ M) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ ∀ δ : Ordinal.{u}, γ ≤ δ → + (vectorCode v).toZFSet ∈ level (groundReals M) δ ∧ + VectorCodeCertificates (level (groundReals M) δ) v := by + induction n with + | zero => + refine ⟨0,internal_ordinal_zero M hM hT,?_⟩ + intro δ _ + refine ⟨?_,trivial⟩ + change (1 : Ordinal.{u}).toZFSet ∈ _ + rw [← Nat.cast_one,toZFSet_nat] + exact level_transitive _ δ _ (ground_level_omega_mem M hM hT δ) _ ((mem_omega _).mpr ⟨1,rfl⟩) + | succ n ih => + obtain ⟨α,hα,hαL⟩ := ih (fun i => v i.succ) (fun i => hv i.succ) + obtain ⟨β,hβ,hβL⟩ := pairCode_certificates_at_levels M hM hT (v 0) + (vectorCode (fun i => v i.succ)) (hv 0) + (vectorCode_internal M hM hT _ (fun i => hv i.succ)) + refine ⟨max α β,internal_ordinal_max M hα hβ,?_⟩ + intro δ hδ + obtain ⟨ht,hs⟩ := hαL δ ((le_max_left α β).trans hδ) + obtain ⟨_,_,hc,hp⟩ := hβL δ ((le_max_right α β).trans hδ) + exact ⟨hc,ht,hp,hs⟩ + +theorem paddedCode_certificates_at_levels (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hv : ∀ i, (v i).toZFSet ∈ M) (hβ : β.toZFSet ∈ M) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ ∀ δ : Ordinal.{u}, γ ≤ δ → + (paddedCode v β).toZFSet ∈ level (groundReals M) δ ∧ + PaddedCodeCertificates (level (groundReals M) δ) v β := by + obtain ⟨α,hα,hαL⟩ := vectorCode_certificates_at_levels M hM hT v hv + obtain ⟨κ,hκ,hκL⟩ := pairCode_certificates_at_levels M hM hT β (vectorCode v) + hβ (vectorCode_internal M hM hT v hv) + refine ⟨max α κ,internal_ordinal_max M hα hκ,?_⟩ + intro δ hδ + obtain ⟨ht,hs⟩ := hαL δ ((le_max_left α κ).trans hδ) + obtain ⟨hb,_,hc,hp⟩ := hκL δ ((le_max_right α κ).trans hδ) + exact ⟨hc,hb,ht,hp,hs⟩ + +theorem paddedEntry_sentences_at_levels (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hv : ∀ i, (v i).toZFSet ∈ M) (hβ : β.toZFSet ∈ M) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ ∀ δ : Ordinal.{u}, γ ≤ δ → + (paddedCode v β).toZFSet ∈ level (groundReals M) δ ∧ + PaddedCodeCertificates (level (groundReals M) δ) v β ∧ + ∀ (k : Fin n) z, z ∈ level (groundReals M) δ → + ((paddedEntrySentence n k).Sat (level (groundReals M) δ : Set ZFSet) + (cons z (fun _ => (paddedCode v β).toZFSet)) ↔ z = (v k).toZFSet) := by + obtain ⟨γ,hγ,hL⟩ := paddedCode_certificates_at_levels M hM hT v β hv hβ + refine ⟨γ,hγ,?_⟩ + intro δ hδ + obtain ⟨hc,hcert⟩ := hL δ hδ + refine ⟨hc,hcert,?_⟩ + intro k z hz + have he : ∀ i, cons z (fun _ => (paddedCode v β).toZFSet) i ∈ level (groundReals M) δ := by + intro i; cases i; exact hz; exact hc + exact ⟨paddedEntrySentence_sound _ (level_transitive _ _) (ground_level_omega_mem M hM hT δ) + n k _ he v β rfl, + paddedEntrySentence_of_certificates _ (level_transitive _ _) (ground_level_omega_mem M hM hT δ) + n k _ he v β rfl hcert⟩ + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/AmbientDegreeActual.lean b/lean/OAI/Computability/DegreeRigidity/Representation/AmbientDegreeActual.lean new file mode 100644 index 0000000000000000000000000000000000000000..fea94ca6a98b3e258f7d54a38bcfa7342ac19ffe --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/AmbientDegreeActual.lean @@ -0,0 +1,42 @@ +import OAI.Computability.DegreeRigidity.Representation.AmbientDegreeBinding + +namespace OAI + + +namespace TuringRigidity.FullSetForcing +open BoundedSetTheory TransitiveNameModel SetDegreeDecoding +universe u + +theorem ownRealPower_codes (M R : ZFSet.{u}) + (hR : ∀ x, x ∈ R ↔ x ∈ M ∧ x ⊆ ZFSet.omega) : + ∀ A : Oracle, realCode A ∈ R ↔ A ∈ modelReals M := by + intro A + exact (hR _).trans (and_iff_left (realCode_subset A)) + +theorem ownDegreeUniverse_actual (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hR : ∀ x, x ∈ R ↔ x ∈ M ∧ x ⊆ ZFSet.omega) : + ∀ x, x ∈ degreeUniverse R ↔ + ∃ A ∈ SetModelReals.reals M, x = degreeSet (degree A) := by + intro x + rw [mem_degreeUniverse] + have hr := ownRealPower_codes M R hR + constructor + · rintro ⟨A,hA,rfl⟩ + exact ⟨A,(hr A).mp hA,degreeCode_eq_degreeSet M hM hT R hr ((hr A).mp hA)⟩ + · rintro ⟨A,hA,rfl⟩ + exact ⟨A,(hr A).mpr hA,(degreeCode_eq_degreeSet M hM hT R hr hA).symm⟩ + +theorem ownDegreeOrder_actual (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hR : ∀ x, x ∈ R ↔ x ∈ M ∧ x ⊆ ZFSet.omega) : + ∀ A ∈ SetModelReals.reals M, ∀ B ∈ SetModelReals.reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ degreeOrder R ↔ + Reduces A B := by + intro A hA B hB + have hr := ownRealPower_codes M R hR + rw [←degreeCode_eq_degreeSet M hM hT R hr hA, + ←degreeCode_eq_degreeSet M hM hT R hr hB] + exact degreeOrder_actual R ((hr A).mpr hA) ((hr B).mpr hB) + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/AmbientDegreeBinding.lean b/lean/OAI/Computability/DegreeRigidity/Representation/AmbientDegreeBinding.lean new file mode 100644 index 0000000000000000000000000000000000000000..829d0458bd76756d5873af580578fc58c4722397 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/AmbientDegreeBinding.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.Representation.AmbientDegreeSyntax + +namespace OAI + +namespace TuringRigidity.FullSetForcing +open BoundedSetTheory TransitiveNameModel ElementaryModel SentenceForm +universe u + +noncomputable def ownGraphBound (o Q : ℕ) : SentenceForm := + definedSet Q (.allMem 0 (productMember (o+2) (o+2) 0)) + +theorem ownGraphBound_spec (M : ZFSet.{u}) (hM : Transitive M) + (o Q : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (ownGraphBound o Q).Sat (M : Set ZFSet) e ↔ + ∀ x, x ∈ e Q ↔ x ∈ M ∧ x ⊆ ZFSet.prod (e o) (e o) := by + rw [ownGraphBound,definedSet_spec M hM Q _ e he] + simp only [Formula.eval_allMem,productMember_spec,cons_zero,cons_succ] + constructor + · intro h x + exact ⟨fun hx => ⟨hM _ (he Q) _ hx,(h x (hM _ (he Q) _ hx)).mp hx⟩, + fun hx => (h x hx.1).mpr hx.2⟩ + · intro h x hx + exact (h x).trans (and_iff_right hx) + +theorem graphBound_certificates (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {Q : ZFSet.{u}} (hQ : ∀ x, x ∈ Q ↔ x ∈ M ∧ x ⊆ ZFSet.prod ZFSet.omega ZFSet.omega) : + ∀ f : ℕ → ℕ, ∀ n, finiteNaturalGraph f n ∈ Q := by + intro f n + refine (hQ _).mpr ⟨finiteNaturalGraph_mem M hM hT.pairing hT.union + (sourceT_omega_mem M hM hT) f n,?_⟩ + intro z hz + obtain ⟨i,_,rfl⟩ := (mem_finiteNaturalGraph f n z).mp hz + exact ZFSet.mem_prod.mpr ⟨_,(mem_omega _).mpr ⟨i,rfl⟩,_,(mem_omega _).mpr ⟨f i,rfl⟩,rfl⟩ + +noncomputable def degreeSetup (eqf lef : Formula) : SentenceForm := + .conj (ownPower 6 3) (.conj (ownGraphBound 6 2) + (.conj (definedSet 1 (Formula.degreeUniverseMember eqf 7 3 8 4 0)) + (definedSet 0 (Formula.degreeOrderMember lef 7 3 8 2 0)))) + +theorem degreeSetup_spec {eqf lef : Formula} (heq : DegreeEqualityFormula.{u} eqf) + (hle : DegreeOrderFormula.{u} lef) + (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (ho : e 6 = ZFSet.omega) (hz : e 7 = natSet 0) : + (degreeSetup eqf lef).Sat (M : Set ZFSet) e ↔ + (∀ x, x ∈ e 3 ↔ x ∈ M ∧ x ⊆ ZFSet.omega) ∧ + (∀ x, x ∈ e 2 ↔ x ∈ M ∧ x ⊆ ZFSet.prod ZFSet.omega ZFSet.omega) ∧ + e 1 = degreeUniverse (e 3) ∧ e 0 = degreeOrder (e 3) := by + simp only [degreeSetup,Sat,ownPower_spec M hM 6 3 e he, + ownGraphBound_spec M hM 6 2 e he,ho] + apply and_congr_right; intro hR + apply and_congr_right; intro hQ + have hr : ∀ w ∈ e 3, ∃ A : Oracle, realCode A = w := by + intro w hw + exact ⟨decodeReal w,realCode_decodeReal ((hR w).mp hw).2⟩ + have hq := graphBound_certificates M hM hT hQ + have hd := definedSet_unique M hM 1 (Formula.degreeUniverseMember eqf 7 3 8 4 0) e he + (degreeUniverse (e 3)) (internal_degreeUniverse M hM hT _ (he 3) hr) + (fun x _ => Formula.degreeUniverseMember_spec heq 7 3 8 4 0 (cons x e) ho hq hz hr) + rw [hd] + apply and_congr_right; intro hD + exact definedSet_unique M hM 0 (Formula.degreeOrderMember lef 7 3 8 2 0) e he + (degreeOrder (e 3)) (internal_degreeOrder M hM hT _ (he 3) hr) + (fun x _ => Formula.degreeOrderMember_spec hle 7 3 8 2 0 (cons x e) ho hq hz (e 3) hD hr) + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/AmbientDegreeSyntax.lean b/lean/OAI/Computability/DegreeRigidity/Representation/AmbientDegreeSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..03b7a03a0ac7b93e4406c46a42a81160c1fdb31e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/AmbientDegreeSyntax.lean @@ -0,0 +1,63 @@ +import OAI.Computability.DegreeRigidity.Representation.FullNativePersistence +import OAI.Computability.DegreeRigidity.Representation.NativeModelCompatibility +import OAI.Computability.DegreeRigidity.SetModels.ModelDegreeOrder + +namespace OAI + + +namespace TuringRigidity.FullSetForcing +open BoundedSetTheory TransitiveNameModel ElementaryModel SentenceForm +universe u + +noncomputable def definedSet (s : ℕ) (p : Formula) : SentenceForm := + all (SentenceForm.iff (.member 0 (s+1)) (fromBounded p)) + +theorem definedSet_spec (M : ZFSet.{u}) (hM : Transitive M) + (s : ℕ) (p : Formula) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (definedSet s p).Sat (M : Set ZFSet) e ↔ + ∀ x ∈ M, x ∈ e s ↔ p.Eval (cons x e) := by + simp only [definedSet,sat_all,sat_iff,Sat,cons_zero,cons_succ,bounded_sat] + apply forall_congr'; intro x + apply forall_congr'; intro hx + exact iff_congr Iff.rfl (Formula.absolute p M hM _ + (by intro i; cases i; exact hx; exact he _)) + +noncomputable def ownPower (a s : ℕ) : SentenceForm := + definedSet s (.subset 0 (a+1)) + +theorem ownPower_spec (M : ZFSet.{u}) (hM : Transitive M) + (a s : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (ownPower a s).Sat (M : Set ZFSet) e ↔ + ∀ x, x ∈ e s ↔ x ∈ M ∧ x ⊆ e a := by + rw [ownPower,definedSet_spec M hM s _ e he] + simp only [Formula.eval_subset,cons_zero,cons_succ] + constructor + · intro h x + exact ⟨fun hx => ⟨hM _ (he s) _ hx,(h x (hM _ (he s) _ hx)).mp hx⟩, + fun hx => (h x hx.1).mpr hx.2⟩ + · intro h x hx + exact (h x).trans (and_iff_right hx) + +def productMember (a b x : ℕ) : Formula := + .existsMem a (.existsMem (b+1) (.orderedPair (x+2) 1 0)) + +theorem productMember_spec (a b x : ℕ) (e : ℕ → ZFSet.{u}) : + (productMember a b x).Eval e ↔ e x ∈ ZFSet.prod (e a) (e b) := by + simp only [productMember,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,ZFSet.mem_prod] + +theorem definedSet_unique (M : ZFSet.{u}) (hM : Transitive M) + (s : ℕ) (p : Formula) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (S : ZFSet.{u}) (hS : S ∈ M) + (hs : ∀ x ∈ M, p.Eval (cons x e) ↔ x ∈ S) : + (definedSet s p).Sat (M : Set ZFSet) e ↔ e s = S := by + rw [definedSet_spec M hM s p e he] + constructor + · intro h + apply ZFSet.ext; intro x + exact ⟨fun hx => (hs x (hM _ (he s) _ hx)).mp ((h x (hM _ (he s) _ hx)).mp hx), + fun hx => (h x (hM _ hS _ hx)).mpr ((hs x (hM _ hS _ hx)).mpr hx)⟩ + · intro h x hx; rw [h]; exact (hs x hx).symm + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/AmbientExtensionBody.lean b/lean/OAI/Computability/DegreeRigidity/Representation/AmbientExtensionBody.lean new file mode 100644 index 0000000000000000000000000000000000000000..6264f75986c256bf02d3c80070214a2975fc4a3f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/AmbientExtensionBody.lean @@ -0,0 +1,65 @@ +import OAI.Computability.DegreeRigidity.Representation.AmbientDegreeActual +import OAI.Computability.DegreeRigidity.SetModels.ElementaryModelIdeal + +namespace OAI + +namespace TuringRigidity.FullSetForcing +open BoundedSetTheory TransitiveNameModel ElementaryModel SentenceForm +open SetDegreeDecoding PersistentRestrictions SetModelSatisfaction ArithmeticTree +universe u + +theorem ownDegreeUniverse_eq_idealSet (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) (R : ZFSet.{u}) + (hR : ∀ x, x ∈ R ↔ x ∈ M ∧ x ⊆ ZFSet.omega) : + degreeUniverse R = idealSet (modelIdeal M hM hT) := by + apply ZFSet.ext + intro x + rw [ownDegreeUniverse_actual M hM hT R hR, mem_idealSet] + constructor + · rintro ⟨A,hA,rfl⟩ + exact ⟨degree A,⟨A,hA,rfl⟩,rfl⟩ + · rintro ⟨d,⟨A,hA,rfl⟩,rfl⟩ + exact ⟨A,hA,rfl⟩ + +noncomputable def extensionBody (eqf lef : Formula) : SentenceForm := + .conj (degreeSetup eqf lef) + (fromBounded (.conj (actionFormula 8 1 0) + (.conj (.subset 4 1) (.subset 5 8)))) + +theorem extensionBody_spec {eqf lef : Formula} (heq : DegreeEqualityFormula.{u} eqf) + (hle : DegreeOrderFormula.{u} lef) + (M : ZFSet.{u}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (I : CountableIdeal) (ρ : I ≃o I) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hi : e 4 = idealSet I) (hρ : e 5 = automorphismSet ρ) + (ho : e 6 = ZFSet.omega) (hz : e 7 = natSet 0) : + (extensionBody eqf lef).Sat (M : Set ZFSet) e ↔ + (degreeSetup eqf lef).Sat (M : Set ZFSet) e ∧ + ∃ hIJ : I.carrier ⊆ (modelIdeal M hM hT).carrier, + ∃ σ : modelIdeal M hM hT ≃o modelIdeal M hM hT, + automorphismSet σ = e 8 ∧ Extends hIJ ρ σ := by + change (_ ∧ _) ↔ (_ ∧ _) + apply and_congr_right + intro hs + obtain ⟨hR,_,hD,hL⟩ := (degreeSetup_spec heq hle M hM hT e he ho hz).mp hs + have hd : e 1 = idealSet (modelIdeal M hM hT) := + hD.trans (ownDegreeUniverse_eq_idealSet M hM hT (e 3) hR) + have hl := ownDegreeOrder_actual M hM hT (e 3) hR + rw [←hL] at hl + rw [bounded_sat, Formula.absolute _ M hM e he] + simp only [Formula.Eval, eval_actionFormula, Formula.eval_subset, hi, hρ, hd] + constructor + · rintro ⟨ha,hij,hext⟩ + have hij' := ideal_subset_iff.mp hij + obtain ⟨σ,hσ⟩ := decode_action (sourceContext M hM hT) hl + (modelIdeal M hM hT) (hd ▸ he 1) ha + refine ⟨hij',σ,hσ,(extends_sets_iff hij' ρ σ).mp ?_⟩ + rwa [hσ] + · rintro ⟨hij,σ,hσ,hext⟩ + rw [←hσ] + exact ⟨action_satisfaction (sourceContext M hM hT) hl (hd ▸ he 1) σ, + ideal_subset hij, extends_sets hext⟩ + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/ArithmeticRepresentation.lean b/lean/OAI/Computability/DegreeRigidity/Representation/ArithmeticRepresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..09a4772c44aec2ff6b4b1ce81b023d42cb70b92c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/ArithmeticRepresentation.lean @@ -0,0 +1,23 @@ +import OAI.Computability.DegreeRigidity.Main + +namespace OAI + + +namespace TuringRigidity.ManuscriptArithmeticRepresentation +open UniformArithmetic + +theorem identity_graph_arith : Arith (fun O _ => O 0 = O 1) := by + have h := (((Arith.query 0).iff (Arith.query 1)).comp _ right_primrec).all + apply h.congr + intro O v + simp only [right,Nat.unpair_pair] + exact ⟨fun h => funext (fun n => Bool.eq_iff_iff.mpr (h n)),fun h n => by rw [h]⟩ + +theorem arithmetic_representation (π : Degree ≃o Degree) : + ∃ F : Oracle → Oracle, Arith (fun O _ => F (O 0) = O 1) ∧ + ∀ A : Oracle, degree (F A) = π (degree A) := + ⟨id,identity_graph_arith,fun A => (ManuscriptMain.rigidity π (degree A)).symm⟩ + +end TuringRigidity.ManuscriptArithmeticRepresentation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/Assembly.lean b/lean/OAI/Computability/DegreeRigidity/Representation/Assembly.lean new file mode 100644 index 0000000000000000000000000000000000000000..24ad942ee410b9b04b232198298f8cb7a884cab0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/Assembly.lean @@ -0,0 +1,123 @@ +import OAI.Computability.DegreeRigidity.Computability.Cuts +import OAI.Computability.DegreeRigidity.Computability.Joins +import Mathlib.Topology.Baire.CompleteMetrizable + +namespace OAI + +open Set Filter Topology +namespace TuringRigidity + +def BorelRepresentation : Prop := + ∀ π : Degree ≃o Degree, ∃ F : Oracle → Oracle, + Measurable F ∧ ∀ A, degree (F A) = π (degree A) + +structure CutArithmetic : Prop where + add : ∀ x y : ℝ, realDegree (x+y) ≤ realDegree x ⊔ realDegree y + sub : ∀ x y : ℝ, realDegree (x-y) ≤ realDegree x ⊔ realDegree y + smul : ∀ (q : ℚ) (x : ℝ), realDegree ((q : ℝ)*x) ≤ realDegree x + translate : ∀ (x : ℝ) (q : ℚ), realDegree (x+(q : ℝ)) ≤ realDegree x + +def IrrationalDegreeCoverage : Prop := ∀ a : Degree, a ≠ ⊥ → + ∃ t : ℝ, Irrational t ∧ 0 < t ∧ t < 1 ∧ realDegree t = a + +def CategoryAvoidance : Prop := ∀ A Y : Oracle, ¬ Reduces Y A → + IsMeagre {p : ℝ × ℝ | Reduces Y (join (join A (cut p.1)) (cut p.2))} + +noncomputable def fourTuple (F : ℝ → Oracle) (t u v : ℝ) (δ : ℚ) : Oracle := + join (join (join (F u) (F (u-v))) (F (v-u+(δ : ℝ)*t))) + (F (v-u+(δ : ℝ)*(t-1))) + +def FourValueRecovery : Prop := ∀ F : ℝ → Oracle, + Measurable F → (∀ B, {x | F x = B}.Countable) → + (∀ x y, Reduces (F (x+y)) (join (F x) (F y))) → + ∀ t : ℝ, Irrational t → 0 < t → t < 1 → + ∃ G : Set (ℝ × ℝ), G ∈ residual (ℝ × ℝ) ∧ + ∀ p ∈ G, ∃ δ : ℚ, 0 < δ ∧ δ < 1 ∧ Reduces (cut t) (fourTuple F t p.1 p.2 δ) + +theorem lift_of_representation (hrep : BorelRepresentation) (harith : CutArithmetic) + (π : Degree ≃o Degree) : + ∃ F : ℝ → Oracle, Measurable F ∧ + (∀ B, {x | F x = B}.Countable) ∧ + (∀ x, degree (F x) = π (realDegree x)) ∧ + (∀ x y, Reduces (F (x+y)) (join (F x) (F y))) := by + obtain ⟨F₀, hmeas, hF₀⟩ := hrep π + let F : ℝ → Oracle := fun x => F₀ (cut x) + have hF : ∀ x, degree (F x) = π (realDegree x) := fun x => hF₀ (cut x) + refine ⟨F, hmeas.comp cut_measurable, represented_real_map_countable_fibers π F hF, hF, ?_⟩ + intro x y + change degree (F (x+y)) ≤ degree (F x) ⊔ degree (F y) + rw [hF, hF, hF, ← π.map_sup] + exact π.monotone (harith.add x y) + +theorem fourTuple_bound (harith : CutArithmetic) (π : Degree ≃o Degree) + (F : ℝ → Oracle) (hF : ∀ x, degree (F x) = π (realDegree x)) + (t u v : ℝ) (δ : ℚ) : + degree (fourTuple F t u v δ) ≤ π (realDegree t ⊔ realDegree u ⊔ realDegree v) := by + let b := realDegree t ⊔ realDegree u ⊔ realDegree v + have ht : realDegree t ≤ b := le_trans le_sup_left le_sup_left + have hu : realDegree u ≤ b := le_trans le_sup_right le_sup_left + have hv : realDegree v ≤ b := le_sup_right + have huv : realDegree (u-v) ≤ b := (harith.sub u v).trans (sup_le hu hv) + have hvu : realDegree (v-u) ≤ b := (harith.sub v u).trans (sup_le hv hu) + have hδt : realDegree ((δ : ℝ)*t) ≤ b := (harith.smul δ t).trans ht + have ht1 : realDegree (t-1) ≤ realDegree t := by + simpa [sub_eq_add_neg] using harith.translate t (-1) + have hδt1 : realDegree ((δ : ℝ)*(t-1)) ≤ b := + (harith.smul δ (t-1)).trans (ht1.trans ht) + have h3 : realDegree (v-u+(δ : ℝ)*t) ≤ b := + (harith.add _ _).trans (sup_le hvu hδt) + have h4 : realDegree (v-u+(δ : ℝ)*(t-1)) ≤ b := + (harith.add _ _).trans (sup_le hvu hδt1) + have hvalue : ∀ x : ℝ, realDegree x ≤ b → degree (F x) ≤ π b := by + intro x hx + rw [hF] + exact π.monotone hx + change ((degree (F u) ⊔ degree (F (u-v))) ⊔ degree (F (v-u+(δ : ℝ)*t))) ⊔ + degree (F (v-u+(δ : ℝ)*(t-1))) ≤ π b + exact sup_le (sup_le (sup_le (hvalue _ hu) (hvalue _ huv)) (hvalue _ h3)) (hvalue _ h4) + +theorem inverse_le_realDegree_of_obligations + (hrep : BorelRepresentation) (harith : CutArithmetic) + (hrec : FourValueRecovery) (havoid : CategoryAvoidance) + (π : Degree ≃o Degree) (t : ℝ) (ht : Irrational t) (ht0 : 0 < t) (ht1 : t < 1) : + π.symm (realDegree t) ≤ realDegree t := by + obtain ⟨F, hmeas, hfiber, hF, hadd⟩ := lift_of_representation hrep harith π + obtain ⟨G, hG, hrecovery⟩ := hrec F hmeas hfiber hadd t ht ht0 ht1 + have hgeneric : ∀ p ∈ G, + π.symm (realDegree t) ≤ realDegree t ⊔ realDegree p.1 ⊔ realDegree p.2 := by + intro p hp + obtain ⟨δ, _, _, hδ⟩ := hrecovery p hp + have hle : realDegree t ≤ π (realDegree t ⊔ realDegree p.1 ⊔ realDegree p.2) := + le_trans hδ (fourTuple_bound harith π F hF t p.1 p.2 δ) + simpa using π.symm.monotone hle + by_contra hnle + obtain ⟨Y, hY⟩ := degree_surjective (π.symm (realDegree t)) + have hnred : ¬ Reduces Y (cut t) := by + intro h + apply hnle + rw [← hY] + exact h + have hmeager := havoid (cut t) Y hnred + have hp : ∃ p : ℝ × ℝ, p ∈ G ∧ + ¬ Reduces Y (join (join (cut t) (cut p.1)) (cut p.2)) := + (dense_of_mem_residual (inter_mem hG hmeager)).nonempty + obtain ⟨p, hpG, hpnot⟩ := hp + apply hpnot + change degree Y ≤ realDegree t ⊔ realDegree p.1 ⊔ realDegree p.2 + rw [hY] + exact hgeneric p hpG + +theorem main_of_obligations (hrep : BorelRepresentation) (harith : CutArithmetic) + (hcover : IrrationalDegreeCoverage) (hrec : FourValueRecovery) + (havoid : CategoryAvoidance) : MainTheorem := by + apply order_rigidity_of_inverse_le + intro π a + by_cases ha : a = ⊥ + · subst a + simp + · obtain ⟨t, ht, ht0, ht1, rfl⟩ := hcover a ha + exact inverse_le_realDegree_of_obligations hrep harith hrec havoid π t ht ht0 ht1 + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/AutomorphismName.lean b/lean/OAI/Computability/DegreeRigidity/Representation/AutomorphismName.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c983734713e2a9fa757aeae59b0c0ad9809fb46 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/AutomorphismName.lean @@ -0,0 +1,91 @@ +import OAI.Computability.DegreeRigidity.Representation.AutomorphismUnion +import OAI.Computability.DegreeRigidity.CohenForcing.CohenSymmetry +import OAI.Computability.DegreeRigidity.Representation.SourceEquationTail + +namespace OAI + +namespace TuringRigidity.AutomorphismName +open Set CountableForcing AutomorphismUnion +variable {P Q α : Type*} [Preorder P] [Preorder Q] + +abbrev SetName (P α : Type*) := Set (P × α) + +def interpret (N : SetName P α) (G : GenericFilter P) : Set α := + {x | ∃ p ∈ G.carrier, (p,x) ∈ N} + +def rename (e : P ≃o Q) (N : SetName P α) : SetName Q α := + {t | (e.symm t.1,t.2) ∈ N} + +def mapFilter (e : P ≃o Q) (G : GenericFilter P) : GenericFilter Q where + carrier := {q | e.symm q ∈ G.carrier} + nonempty := by + obtain ⟨p,hp⟩ := G.nonempty + exact ⟨e p,by simpa using hp⟩ + upper := fun hpq hp => G.upper (e.symm.monotone hpq) hp + directed := by + intro p q hp hq + obtain ⟨r,hr,hrp,hrq⟩ := G.directed hp hq + exact ⟨e r,by simpa using hr,by simpa using e.monotone hrp,by simpa using e.monotone hrq⟩ + +theorem interpret_rename (e : P ≃o Q) (N : SetName P α) (G : GenericFilter P) : + interpret (rename e N) (mapFilter e G) = interpret N G := by + ext x + constructor + · rintro ⟨q,hq,hN⟩ + exact ⟨e.symm q,hq,hN⟩ + · rintro ⟨p,hp,hN⟩ + exact ⟨e p,by simpa [mapFilter] using hp,by simpa [rename] using hN⟩ + +def graphName : SetName Approximation (Degree × Degree) := + {t | ∃ ha : t.2.1 ∈ t.1.ideal.carrier, (t.1.map ⟨t.2.1,ha⟩).val = t.2.2} + +theorem interpret_graphName (G : GenericFilter Approximation) (a b : Degree) : + (a,b) ∈ interpret graphName G ↔ Graph G a b := Iff.rfl + +theorem graphName_represents (G : GenericFilter Approximation) (a : Domain G) (b : Degree) : + (a.val,b) ∈ interpret graphName G ↔ (automorphism G a).val = b := + (automorphism_graph G a b).symm + +def liftFirst [OrderTop Q] (N : SetName P α) : SetName (P × Q) α := + {t | t.1.2 = ⊤ ∧ (t.1.1,t.2) ∈ N} + +theorem interpret_liftFirst [OrderTop Q] (N : SetName P α) + (G : GenericFilter P) (H : GenericFilter Q) : + interpret (liftFirst N) (SourceEquationTail.productFilter G H) = interpret N G := by + ext x + constructor + · rintro ⟨⟨p,q⟩,⟨hp,hq⟩,he,hN⟩ + exact ⟨p,hp,hN⟩ + · rintro ⟨p,hp,hN⟩ + obtain ⟨q,hq⟩ := H.nonempty + exact ⟨(p,⊤),⟨hp,H.upper le_top hq⟩,rfl,hN⟩ + +theorem liftFirst_tail_invariant {ι : Type*} (N : SetName P α) (m : ι → Bool) : + rename (CohenSymmetry.tailIso m) (liftFirst N) = liftFirst N := by + ext t + change ((CohenSymmetry.flipIso m).symm t.1.2 = ⊤ ∧ (t.1.1,t.2) ∈ N) ↔ + (t.1.2 = ⊤ ∧ (t.1.1,t.2) ∈ N) + apply and_congr _ Iff.rfl + constructor + · intro h + have he := congrArg (CohenSymmetry.flipIso m) h + simpa using he + · intro h + rw [h] + exact (CohenSymmetry.flipIso m).symm.map_top + +theorem invariant_automorphism_name {ι : Type*} : + ∃ N : SetName (Approximation × CohenSymmetry.Condition ι) (Degree × Degree), + (∀ m, rename (CohenSymmetry.tailIso m) N = N) ∧ + ∀ (G : GenericFilter Approximation) (H : GenericFilter (CohenSymmetry.Condition ι)) + (a : Domain G) (b : Degree), + (a.val,b) ∈ interpret N (SourceEquationTail.productFilter G H) ↔ + (automorphism G a).val = b := by + refine ⟨liftFirst graphName,fun m => liftFirst_tail_invariant graphName m,?_⟩ + intro G H a b + rw [interpret_liftFirst] + exact graphName_represents G a b + +end TuringRigidity.AutomorphismName + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/AutomorphismOutputSentence.lean b/lean/OAI/Computability/DegreeRigidity/Representation/AutomorphismOutputSentence.lean new file mode 100644 index 0000000000000000000000000000000000000000..0fae7d9cc9888bc8587578e71d8a0e9e15a9cc4b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/AutomorphismOutputSentence.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.Representation.AmbientExtensionBody + +namespace OAI + +namespace TuringRigidity.FullSetForcing +open TransitiveNameModel BoundedSetTheory ElementaryModel SentenceForm +open SetDegreeDecoding PersistentRestrictions SetModelSatisfaction +universe u + +noncomputable def outputSentence : SentenceForm := + .ex (.ex (.conj (.member 3 1) + (.conj (.member 4 0) (fromBounded (.pairMem 1 0 2))))) + +theorem outputSentence_raw (M : ZFSet.{u}) (hM : Transitive M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + outputSentence.Sat (M : Set ZFSet) e ↔ + ∃ d ∈ M, ∃ b ∈ M, e 1 ∈ d ∧ e 2 ∈ b ∧ ZFSet.pair d b ∈ e 0 := by + change (∃ d ∈ M, ∃ b ∈ M, e 1 ∈ d ∧ e 2 ∈ b ∧ + (fromBounded (.pairMem 1 0 2)).Sat (M : Set ZFSet) (cons b (cons d e))) ↔ _ + apply exists_congr; intro d + apply and_congr_right; intro hd + apply exists_congr; intro b + apply and_congr_right; intro hb + rw [bounded_sat, Formula.absolute _ M hM _ (by + intro i; rcases i with _|_|i + exact hb + exact hd + exact he i)] + simp only [Formula.eval_pairMem, cons_zero, cons_succ] + +theorem outputSentence_spec (M : ZFSet.{u}) (hM : Transitive M) + (I : CountableIdeal) (hI : idealSet I ∈ M) (σ : I ≃o I) + (A : Oracle) (hA : degree A ∈ I.carrier) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hf : e 0 = automorphismSet σ) (hx : e 1 = realCode A) : + outputSentence.Sat (M : Set ZFSet) e ↔ + ∃ B : Oracle, realCode B = e 2 ∧ degree B = (σ ⟨degree A,hA⟩).val := by + rw [outputSentence_raw M hM e he, hf, hx] + constructor + · rintro ⟨d,_,b,_,had,hbb,hf⟩ + obtain ⟨a,hpair⟩ := (mem_automorphismSet σ _).mp hf + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hpair + have ha : degree A = a.val := (real_mem_degreeSet A a.val).mp had + have ha' : (⟨degree A,hA⟩ : I) = a := Subtype.ext ha + obtain ⟨B,hB,hdeg⟩ := (mem_degreeSet (σ a).val (e 2)).mp hbb + exact ⟨B,hB.symm,by rwa [ha']⟩ + · rintro ⟨B,hB,hdeg⟩ + have hm (a : I) : degreeSet.{u} a.val ∈ M := + hM _ hI _ ((mem_idealSet I _).mpr ⟨a.val,a.property,rfl⟩) + refine ⟨degreeSet (degree A),hm ⟨degree A,hA⟩, + degreeSet (σ ⟨degree A,hA⟩).val,hm (σ ⟨degree A,hA⟩), + (real_mem_degreeSet A _).mpr rfl,?_,?_⟩ + · rw [←hB] + exact (real_mem_degreeSet B _).mpr hdeg + · exact (mem_automorphismSet σ _).mpr ⟨⟨degree A,hA⟩,rfl⟩ + +theorem modelIdeal_internal (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) : idealSet (modelIdeal M hM hT) ∈ M := by + obtain ⟨R,hRM,hR⟩ := internal_power M hM hT.powerSet (sourceT_omega_mem M hM hT) + rw [←ownDegreeUniverse_eq_idealSet M hM hT R hR] + apply internal_degreeUniverse M hM hT R hRM + intro w hw + exact ⟨decodeReal w,realCode_decodeReal ((hR w).mp hw).2⟩ + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/AutomorphismUnion.lean b/lean/OAI/Computability/DegreeRigidity/Representation/AutomorphismUnion.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8c7b8bc052fd8ba6a234a79a0b7875556d81886 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/AutomorphismUnion.lean @@ -0,0 +1,114 @@ +import OAI.Computability.DegreeRigidity.Constructibility.PersistentRestrictions +import OAI.Computability.DegreeRigidity.CohenForcing.CountableForcing + +namespace OAI + +namespace TuringRigidity.AutomorphismUnion +open Set PersistentRestrictions CountableForcing + +structure Approximation where + ideal : CountableIdeal + map : ideal ≃o ideal + +instance : Preorder Approximation where + le p q := ∃ h : q.ideal.carrier ⊆ p.ideal.carrier, Extends h q.map p.map + le_refl p := ⟨fun _ h => h, fun _ => rfl⟩ + le_trans p q r hpq hqr := by + obtain ⟨hpq,epq⟩ := hpq + obtain ⟨hqr,eqr⟩ := hqr + refine ⟨fun _ h => hpq (hqr h), fun a => ?_⟩ + exact (epq ⟨a.val,hqr a.property⟩).trans (eqr a) + +def Domain (G : GenericFilter Approximation) : Set Degree := + {a | ∃ p ∈ G.carrier, a ∈ p.ideal.carrier} + +def Graph (G : GenericFilter Approximation) (a b : Degree) : Prop := + ∃ p ∈ G.carrier, ∃ ha : a ∈ p.ideal.carrier, (p.map ⟨a,ha⟩).val = b + +theorem graph_mono {p q : Approximation} (hpq : p ≤ q) + {a b : Degree} (ha : a ∈ q.ideal.carrier) (hab : (q.map ⟨a,ha⟩).val = b) : + ∃ h : a ∈ p.ideal.carrier, (p.map ⟨a,h⟩).val = b := by + obtain ⟨h,e⟩ := hpq + exact ⟨h ha,(e ⟨a,ha⟩).trans hab⟩ + +theorem graph_domain {G : GenericFilter Approximation} {a b : Degree} + (h : Graph G a b) : a ∈ Domain G ∧ b ∈ Domain G := by + obtain ⟨p,hp,ha,rfl⟩ := h + exact ⟨⟨p,hp,ha⟩,⟨p,hp,(p.map ⟨a,ha⟩).property⟩⟩ + +theorem graph_total (G : GenericFilter Approximation) {a : Degree} (ha : a ∈ Domain G) : + ∃ b, Graph G a b := by + obtain ⟨p,hp,ha⟩ := ha + exact ⟨_,p,hp,ha,rfl⟩ + +theorem graph_surjective (G : GenericFilter Approximation) {b : Degree} (hb : b ∈ Domain G) : + ∃ a, Graph G a b := by + obtain ⟨p,hp,hb⟩ := hb + refine ⟨(p.map.symm ⟨b,hb⟩).val,p,hp,(p.map.symm ⟨b,hb⟩).property,?_⟩ + exact congrArg Subtype.val (p.map.apply_symm_apply ⟨b,hb⟩) + +theorem graph_order (G : GenericFilter Approximation) {a b c d : Degree} + (hab : Graph G a b) (hcd : Graph G c d) : a ≤ c ↔ b ≤ d := by + obtain ⟨p,hp,ha,hab⟩ := hab + obtain ⟨q,hq,hc,hcd⟩ := hcd + obtain ⟨r,hr,hrp,hrq⟩ := G.directed hp hq + obtain ⟨ha',hab'⟩ := graph_mono hrp ha hab + obtain ⟨hc',hcd'⟩ := graph_mono hrq hc hcd + rw [←hab',←hcd'] + exact (@OrderIso.le_iff_le _ _ _ _ r.map ⟨a,ha'⟩ ⟨c,hc'⟩).symm + +theorem graph_unique (G : GenericFilter Approximation) {a b c : Degree} + (hab : Graph G a b) (hac : Graph G a c) : b = c := + le_antisymm ((graph_order G hab hac).mp le_rfl) ((graph_order G hac hab).mp le_rfl) + +theorem graph_injective (G : GenericFilter Approximation) {a b c : Degree} + (hac : Graph G a c) (hbc : Graph G b c) : a = b := + le_antisymm ((graph_order G hac hbc).mpr le_rfl) ((graph_order G hbc hac).mpr le_rfl) + +noncomputable def value (G : GenericFilter Approximation) (a : Domain G) : Domain G := + ⟨Classical.choose (graph_total G a.property), + (graph_domain (Classical.choose_spec (graph_total G a.property))).2⟩ + +theorem value_graph (G : GenericFilter Approximation) (a : Domain G) : + Graph G a.val (value G a).val := Classical.choose_spec (graph_total G a.property) + +noncomputable def inverse (G : GenericFilter Approximation) (b : Domain G) : Domain G := + ⟨Classical.choose (graph_surjective G b.property), + (graph_domain (Classical.choose_spec (graph_surjective G b.property))).1⟩ + +theorem inverse_graph (G : GenericFilter Approximation) (b : Domain G) : + Graph G (inverse G b).val b.val := Classical.choose_spec (graph_surjective G b.property) + +noncomputable def automorphism (G : GenericFilter Approximation) : Domain G ≃o Domain G where + toFun := value G + invFun := inverse G + left_inv a := Subtype.ext (graph_injective G (inverse_graph G (value G a)) (value_graph G a)) + right_inv b := Subtype.ext (graph_unique G (value_graph G (inverse G b)) (inverse_graph G b)) + map_rel_iff' := fun {a b} => (graph_order G (value_graph G a) (value_graph G b)).symm + +theorem automorphism_graph (G : GenericFilter Approximation) (a : Domain G) (b : Degree) : + (automorphism G a).val = b ↔ Graph G a.val b := by + constructor + · rintro rfl; exact value_graph G a + · exact graph_unique G (value_graph G a) + +theorem automorphism_extends (G : GenericFilter Approximation) {p : Approximation} + (hp : p ∈ G.carrier) (a : p.ideal) : + (automorphism G ⟨a.val,⟨p,hp,a.property⟩⟩).val = (p.map a).val := + (automorphism_graph G _ _).mpr ⟨p,hp,a.property,rfl⟩ + +theorem domain_lower (G : GenericFilter Approximation) {a b : Degree} + (hab : a ≤ b) (hb : b ∈ Domain G) : a ∈ Domain G := by + obtain ⟨p,hp,hb⟩ := hb + exact ⟨p,hp,p.ideal.lower hab hb⟩ + +theorem domain_join (G : GenericFilter Approximation) {a b : Degree} + (ha : a ∈ Domain G) (hb : b ∈ Domain G) : a ⊔ b ∈ Domain G := by + obtain ⟨p,hp,ha⟩ := ha + obtain ⟨q,hq,hb⟩ := hb + obtain ⟨r,hr,hrp,hrq⟩ := G.directed hp hq + exact ⟨r,hr,r.ideal.join_mem (hrp.choose ha) (hrq.choose hb)⟩ + +end TuringRigidity.AutomorphismUnion + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/BorelGeneric.lean b/lean/OAI/Computability/DegreeRigidity/Representation/BorelGeneric.lean new file mode 100644 index 0000000000000000000000000000000000000000..488598e4ca9f94b759b6bc208d78135ad62c909a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/BorelGeneric.lean @@ -0,0 +1,107 @@ +import OAI.Computability.DegreeRigidity.Effective.ProgramSelection + +namespace OAI + +namespace TuringRigidity.BorelGeneric +open Set + +def word (n : ℕ) : List Bool := (Encodable.decode (α := List Bool) n).getD [] + +theorem word_surjective : Function.Surjective word := by + intro s + exact ⟨Encodable.encode s,by simp [word]⟩ + +def Ext (s t : ℕ) : Prop := word s <+: word t ∧ (word s).length < (word t).length + +variable {X : Type*} [MeasurableSpace X] +variable (R : X → ℕ → ℕ → Prop) +variable (hd : ∀ x n s, ∃ t, Ext s t ∧ R x n t) + +noncomputable def next (n : ℕ) (z : X × ℕ) : ℕ := + leastSuccess (fun z t => Ext z.2 t ∧ R z.1 n t) (fun z => hd z.1 n z.2) z + +omit [MeasurableSpace X] in +theorem next_spec (n : ℕ) (x : X) (s : ℕ) : + Ext s (next R hd n (x,s)) ∧ R x n (next R hd n (x,s)) := + leastSuccess_spec (fun z : X × ℕ => fun t => Ext z.2 t ∧ R z.1 n t) + (fun z => hd z.1 n z.2) (x,s) + +theorem next_measurable (hR : ∀ n t, MeasurableSet {x | R x n t}) (n : ℕ) : + Measurable (next R hd n) := by + apply leastSuccess_measurable + intro t + exact ((Set.to_countable {s : ℕ | Ext s t}).measurableSet.preimage measurable_snd).inter + ((hR n t).preimage measurable_fst) + +noncomputable def stage : ℕ → X → ℕ + | 0 => fun _ => Encodable.encode ([] : List Bool) + | n+1 => fun x => next R hd n (x,stage n x) + +theorem stage_measurable (hR : ∀ n t, MeasurableSet {x | R x n t}) : + ∀ n, Measurable (stage R hd n) := by + intro n + induction n with + | zero => exact measurable_const + | succ n ih => exact (next_measurable R hd hR n).comp (measurable_id.prodMk ih) + +omit [MeasurableSpace X] in +theorem stage_prefix (x : X) (n : ℕ) : + word (stage R hd n x) <+: word (stage R hd (n+1) x) := + (next_spec R hd n x (stage R hd n x)).1.1 + +omit [MeasurableSpace X] in +theorem stage_length (x : X) (n : ℕ) : n ≤ (word (stage R hd n x)).length := by + induction n with + | zero => omega + | succ n ih => + have h := (next_spec R hd n x (stage R hd n x)).1.2 + change n+1 ≤ (word (next R hd n (x,stage R hd n x))).length + omega + +omit [MeasurableSpace X] in +theorem stage_prefix_of_le (x : X) {n m : ℕ} (h : n ≤ m) : + word (stage R hd n x) <+: word (stage R hd m x) := by + induction m, h using Nat.le_induction with + | base => exact List.prefix_rfl + | succ m h ih => exact ih.trans (stage_prefix R hd x m) + +noncomputable def generic (x : X) : Oracle := + fun i => (word (stage R hd (i+1) x)).getD i false + +theorem generic_measurable (hR : ∀ n t, MeasurableSet {x | R x n t}) : + Measurable (generic R hd) := by + apply Measurable.of_eval + intro i + exact (measurable_of_countable (fun k : ℕ => (word k).getD i false)).comp + (stage_measurable R hd hR (i+1)) + +def Meets (A : Oracle) (s : ℕ) : Prop := + ∀ i, i < (word s).length → A i = (word s).getD i false + +private theorem getD_prefix {s t : List Bool} (h : s <+: t) (i : ℕ) (hi : i < s.length) : + s.getD i false = t.getD i false := by + obtain ⟨u,rfl⟩ := h + simp [List.getD, List.getElem?_append, hi] + +omit [MeasurableSpace X] in +theorem meets_stage (x : X) (n : ℕ) : Meets (generic R hd x) (stage R hd n x) := by + intro i hi + dsimp only [generic] + rcases le_total n (i+1) with hn | hn + · exact (getD_prefix (stage_prefix_of_le R hd x hn) i hi).symm + · exact getD_prefix (stage_prefix_of_le R hd x hn) i (by + have hl := stage_length R hd x (i+1) + omega) + +include hd in + +theorem borel_generic_selection (hR : ∀ n t, MeasurableSet {x | R x n t}) : + ∃ G : X → Oracle, Measurable G ∧ ∀ x n, ∃ t, R x n t ∧ Meets (G x) t := by + refine ⟨generic R hd,generic_measurable R hd hR,?_⟩ + intro x n + exact ⟨stage R hd (n+1) x,(next_spec R hd n x (stage R hd n x)).2, + meets_stage R hd x (n+1)⟩ + +end TuringRigidity.BorelGeneric + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/Category.lean b/lean/OAI/Computability/DegreeRigidity/Representation/Category.lean new file mode 100644 index 0000000000000000000000000000000000000000..e96f314a94f3762ebe4622384a327086d9e7bab6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/Category.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.Recurrence +import Mathlib.Topology.Baire.BaireMeasurable +import Mathlib.Topology.Baire.Lemmas +import Mathlib.Topology.Algebra.Group.Basic + +namespace OAI + +open Set Filter Topology + +namespace TuringRigidity + +theorem measurable_continuousOn_residual {X Y : Type*} + [TopologicalSpace X] [MeasurableSpace X] [BorelSpace X] + [TopologicalSpace Y] [MeasurableSpace Y] [BorelSpace Y] [SecondCountableTopology Y] + (f : X → Y) (hf : Measurable f) : + ∃ D : Set X, D ∈ residual X ∧ ContinuousOn f D := by + obtain ⟨b, hb⟩ := TopologicalSpace.exists_seq_basis Y + have hm : ∀ n : ℕ, MeasurableSet (f ⁻¹' b n) := + fun n => hf ((hb.isOpen (mem_range_self n)).measurableSet) + choose V hVo hVeq using fun n => (hm n).residualEq_isOpen + let D : Set X := {x | ∀ n : ℕ, f x ∈ b n ↔ x ∈ V n} + have hD : D ∈ residual X := by + apply eventually_countable_forall.mpr + intro n + exact Filter.eventuallyEqSet_iff.mp (hVeq n) + refine ⟨D, hD, hb.continuousOn_iff.mpr ?_⟩ + rintro s ⟨n, rfl⟩ + refine ⟨V n, hVo n, ?_⟩ + ext x + constructor + · rintro ⟨hx, hd⟩ + exact ⟨(hd n).mp hx, hd⟩ + · rintro ⟨hx, hd⟩ + exact ⟨(hd n).mpr hx, hd⟩ + +def forwardShift (s a : ℝ) : (ℝ × ℝ) ≃ₜ (ℝ × ℝ) where + toFun p := (p.1 + s, p.2 - p.1 + a) + invFun p := (p.1 - s, p.2 + (p.1 - s) - a) + left_inv p := by ext <;> dsimp <;> ring + right_inv p := by ext <;> dsimp <;> ring + continuous_toFun := + (continuous_fst.add continuous_const).prodMk + ((continuous_snd.sub continuous_fst).add continuous_const) + continuous_invFun := + (continuous_fst.sub continuous_const).prodMk + ((continuous_snd.add (continuous_fst.sub continuous_const)).sub continuous_const) + +def backwardShift (s : ℝ) : (ℝ × ℝ) ≃ₜ (ℝ × ℝ) where + toFun p := (p.2 + s, p.1 - p.2) + invFun p := (p.2 + (p.1 - s), p.1 - s) + left_inv p := by ext <;> dsimp <;> ring + right_inv p := by ext <;> dsimp <;> ring + continuous_toFun := + (continuous_snd.add continuous_const).prodMk (continuous_fst.sub continuous_snd) + continuous_invFun := + (continuous_snd.add (continuous_fst.sub continuous_const)).prodMk + (continuous_fst.sub continuous_const) + +def goodPairs (t : ℝ) (D : Set ℝ) (E : Set (ℝ × ℝ)) : Set (ℝ × ℝ) := + {p | ∀ s ∈ rationalSpan t, + p.1 + s ∈ D ∧ (∀ a ∈ rationalSpan t, (p.1+s, p.2-p.1+a) ∈ E) ∧ + (p.2+s, p.1-p.2) ∈ E} + +theorem goodPairs_residual (t : ℝ) (D : Set ℝ) (E : Set (ℝ × ℝ)) + (hD : D ∈ residual ℝ) (hE : E ∈ residual (ℝ × ℝ)) : + goodPairs t D E ∈ residual (ℝ × ℝ) := by + have : Countable (rationalSpan t) := (rationalSpan_countable t).to_subtype + have hcoord (s : ℝ) : {p : ℝ × ℝ | p.1 + s ∈ D} ∈ residual (ℝ × ℝ) := by + exact tendsto_residual_of_isOpenMap + (continuous_fst.add continuous_const) + ((Homeomorph.addRight s).isOpenMap.comp isOpenMap_fst) hD + have hforward (s a : ℝ) : + {p : ℝ × ℝ | (p.1+s,p.2-p.1+a) ∈ E} ∈ residual (ℝ × ℝ) := by + exact tendsto_residual_of_isOpenMap + (forwardShift s a).continuous (forwardShift s a).isOpenMap hE + have hbackward (s : ℝ) : + {p : ℝ × ℝ | (p.2+s,p.1-p.2) ∈ E} ∈ residual (ℝ × ℝ) := by + exact tendsto_residual_of_isOpenMap + (backwardShift s).continuous (backwardShift s).isOpenMap hE + have h : ∀ᶠ p in residual (ℝ × ℝ), ∀ s : rationalSpan t, + p.1+s.val ∈ D ∧ + (∀ a : rationalSpan t, (p.1+s.val,p.2-p.1+a.val) ∈ E) ∧ + (p.2+s.val,p.1-p.2) ∈ E := by + apply eventually_countable_forall.mpr + intro s + exact Filter.Eventually.and (hcoord s.val) + (Filter.Eventually.and (eventually_countable_forall.mpr + (fun a => hforward s.val a.val)) (hbackward s.val)) + filter_upwards [h] with p hp + intro s hs + exact ⟨(hp ⟨s,hs⟩).1, fun a ha => (hp ⟨s,hs⟩).2.1 ⟨a,ha⟩, (hp ⟨s,hs⟩).2.2⟩ + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/CategoryAvoidance.lean b/lean/OAI/Computability/DegreeRigidity/Representation/CategoryAvoidance.lean new file mode 100644 index 0000000000000000000000000000000000000000..13f38bbe940dc4558937ee95117cd362294e142d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/CategoryAvoidance.lean @@ -0,0 +1,43 @@ +import OAI.Computability.DegreeRigidity.Representation.CategoryReduction +import OAI.Computability.DegreeRigidity.Representation.Assembly + +namespace OAI + +open Set Topology +namespace TuringRigidity.CategorySearch + +theorem rational_rectangle_basis (U : Set (ℝ × ℝ)) (hU : IsOpen U) + (p : ℝ × ℝ) (hp : p ∈ U) : + ∃ l r : ℚ × ℚ, p ∈ rectangle l r ∧ rectangle l r ⊆ U := by + obtain ⟨u,hu,v,hv,huv⟩ := mem_nhds_prod_iff.mp (hU.mem_nhds hp) + obtain ⟨a,b,hab,hsub⟩ := mem_nhds_iff_exists_Ioo_subset.mp hu + obtain ⟨c,d,hcd,hsub'⟩ := mem_nhds_iff_exists_Ioo_subset.mp hv + obtain ⟨l1,hl1,hl1'⟩ := exists_rat_btwn hab.1 + obtain ⟨r1,hr1,hr1'⟩ := exists_rat_btwn hab.2 + obtain ⟨l2,hl2,hl2'⟩ := exists_rat_btwn hcd.1 + obtain ⟨r2,hr2,hr2'⟩ := exists_rat_btwn hcd.2 + refine ⟨(l1,l2),(r1,r2),⟨⟨hl1',hr1⟩,⟨hl2',hr2⟩⟩,?_⟩ + intro q hq + exact huv ⟨hsub ⟨hl1.trans hq.1.1,hq.1.2.trans hr1'⟩, + hsub' ⟨hl2.trans hq.2.1,hq.2.2.trans hr2'⟩⟩ + +theorem success_nowhereDense (A Y : Oracle) (hY : ¬ Reduces Y A) (c : OracleCode) : + IsNowhereDense (success A Y c) := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro p hp + obtain ⟨l,r,hpR,hR⟩ := rational_rectangle_basis _ isOpen_interior p hp + exact hY (reduces_of_dense A Y c l r ⟨p,hpR⟩ (hR.trans interior_subset)) + +theorem category_avoidance : CategoryAvoidance := by + intro A Y hY + have heq : {p : ℝ × ℝ | Reduces Y (join (join A (cut p.1)) (cut p.2))} = + ⋃ c : OracleCode, success A Y c := by + ext p + exact (OracleCode.turingReducible_iff_exists_code (oracleFunction Y) + (oracleFunction (pairOracle A p))).trans (by simp [success]) + rw [heq] + exact isMeagre_iUnion (fun c => (success_nowhereDense A Y hY c).isMeagre) + +end TuringRigidity.CategorySearch + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/CategoryMachine.lean b/lean/OAI/Computability/DegreeRigidity/Representation/CategoryMachine.lean new file mode 100644 index 0000000000000000000000000000000000000000..dacf2bc7774c730a65c0ce95167446172a5f37fd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/CategoryMachine.lean @@ -0,0 +1,103 @@ +import OAI.Computability.DegreeRigidity.Computability.CutTranscript +import OAI.Computability.DegreeRigidity.Computability.RationalCut + +namespace OAI + +namespace TuringRigidity.CategorySearch +open Computable Encodable + +def rationalBit (i k : ℕ) : ℕ := if RationalCoding.ltCode k i then 1 else 0 + +theorem rationalBit_primrec : Primrec₂ rationalBit := + Primrec.ite (RationalCoding.ltCode_primrec.comp Primrec.snd Primrec.fst) + (Primrec.const 1) (Primrec.const 0) + +theorem rationalBit_eq (i k : ℕ) : + Part.some (rationalBit i k) = oracleFunction (cut (rationalEnumeration i : ℝ)) k := by + simp only [rationalBit,oracleFunction,cut_eq_true,RationalCoding.ltCode_iff] + +def sample (i j : ℕ) : ℝ × ℝ := (rationalEnumeration i,rationalEnumeration j) + +def finiteOracle (L : List ℕ) (i j : ℕ) : ℕ →. ℕ := + partialJoin (partialJoin (BranchMachine.lookup L) (fun k => Part.some (rationalBit i k))) + (fun k => Part.some (rationalBit j k)) + +theorem partialJoin_oracle (A B : Oracle) : + partialJoin (oracleFunction A) (oracleFunction B) = oracleFunction (join A B) := by + funext k + cases h : k.bodd <;> simp [partialJoin,oracleFunction,join,h] + +noncomputable def Avalue (A : Oracle) (k : ℕ) : ℕ := if A k then 1 else 0 + +theorem finiteOracle_approximates (A : Oracle) (i j k : ℕ) : + Approximates (oracleFunction (pairOracle A (sample i j)) k) + (fun m => finiteOracle (UniformOracle.oraclePrefix (Avalue A) m) i j k) := by + have hi : (fun k => Part.some (rationalBit i k)) = oracleFunction (cut (rationalEnumeration i : ℝ)) := + funext (rationalBit_eq i) + have hj : (fun k => Part.some (rationalBit j k)) = oracleFunction (cut (rationalEnumeration j : ℝ)) := + funext (rationalBit_eq j) + have h := BranchMachine.partialJoin_approximates + (fun k => BranchMachine.partialJoin_approximates + (UniformOracle.prefix_approximates (Avalue A)) + (fun k => Approximates.const (Part.some (rationalBit i k))) k) + (fun k => Approximates.const (Part.some (rationalBit j k))) k + simpa only [finiteOracle,hi,hj,show (fun k => Part.some (Avalue A k)) = oracleFunction A from rfl, + partialJoin_oracle,pairOracle,sample] using h + +def inside (l r : ℚ × ℚ) (i j : ℕ) : Prop := + RationalCoding.ltCode (encode l.1) i ∧ RationalCoding.ltCode i (encode r.1) ∧ + RationalCoding.ltCode (encode l.2) j ∧ RationalCoding.ltCode j (encode r.2) +instance (l r : ℚ × ℚ) (i j : ℕ) : Decidable (inside l r i j) := inferInstanceAs (Decidable (_ ∧ _)) + +theorem inside_primrec (l r : ℚ × ℚ) : PrimrecRel (inside l r) := + (RationalCoding.ltCode_primrec.comp (Primrec.const (encode l.1)) Primrec.fst).and + ((RationalCoding.ltCode_primrec.comp Primrec.fst (Primrec.const (encode r.1))).and + ((RationalCoding.ltCode_primrec.comp (Primrec.const (encode l.2)) Primrec.snd).and + (RationalCoding.ltCode_primrec.comp Primrec.snd (Primrec.const (encode r.2))))) + +theorem inside_iff (l r : ℚ × ℚ) (i j : ℕ) : + inside l r i j ↔ sample i j ∈ rectangle l r := by + simp [inside,RationalCoding.ltCode_iff,rationalEnumeration,sample,rectangle,and_assoc] + +def finiteRun (c : OracleCode) (l r : ℚ × ℚ) (L : List ℕ) (w : ℕ) : Part ℕ := + let i := (Nat.unpair w).1 + let j := (Nat.unpair (Nat.unpair w).2).1 + let n := (Nat.unpair (Nat.unpair w).2).2 + if inside l r i j then OracleCode.eval (finiteOracle L i j) c n else Part.none + +theorem finiteRun_partrec (c : OracleCode) (l r : ℚ × ℚ) : Partrec₂ (finiteRun c l r) := by + let α := List ℕ × ℕ × ℕ + have hA : Partrec₂ (fun z : α => BranchMachine.lookup z.1) := + BranchMachine.lookup_partrec.comp (fst.comp fst) snd + have hi : Partrec₂ (fun z : α => fun k => Part.some (rationalBit z.2.1 k)) := + (rationalBit_primrec.to_comp.comp (fst.comp (snd.comp fst)) snd) + have hj : Partrec₂ (fun z : α => fun k => Part.some (rationalBit z.2.2 k)) := + (rationalBit_primrec.to_comp.comp (snd.comp (snd.comp fst)) snd) + have hg : Partrec₂ (fun z : α => finiteOracle z.1 z.2.1 z.2.2) := + BranchMachine.partialJoin_partrec (BranchMachine.partialJoin_partrec hA hi) hj + have he : Partrec₂ (fun z : α => OracleCode.eval (finiteOracle z.1 z.2.1 z.2.2) c) := + OracleCode.eval_partrec hg c + have hi' : Computable (fun z : List ℕ × ℕ => (Nat.unpair z.2).1) := + fst.comp (Computable.unpair.comp snd) + have hj' : Computable (fun z : List ℕ × ℕ => (Nat.unpair (Nat.unpair z.2).2).1) := + fst.comp (Computable.unpair.comp (snd.comp (Computable.unpair.comp snd))) + have hn' : Computable (fun z : List ℕ × ℕ => (Nat.unpair (Nat.unpair z.2).2).2) := + snd.comp (Computable.unpair.comp (snd.comp (Computable.unpair.comp snd))) + have hb : Computable (fun z : List ℕ × ℕ => decide (inside l r (Nat.unpair z.2).1 + (Nat.unpair (Nat.unpair z.2).2).1)) := + (inside_primrec l r).decide.to_comp.comp hi' hj' + have hparam : Computable (fun z : List ℕ × ℕ => + (z.1,(Nat.unpair z.2).1,(Nat.unpair (Nat.unpair z.2).2).1)) := + fst.pair (hi'.pair hj') + have hr := he.comp hparam hn' + exact (partrec_cond hb hr Partrec.none).of_eq (fun z => by simp [finiteRun]) + +theorem finiteRun_code (c : OracleCode) (l r : ℚ × ℚ) : + ∃ d : Nat.Partrec.Code, ∀ L w, + d.eval (Nat.pair (encode L) w) = finiteRun c l r L w := by + obtain ⟨d,hd⟩ := partrec_code (finiteRun_partrec c l r) + exact ⟨d,fun L w => hd (L,w)⟩ + +end TuringRigidity.CategorySearch + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/CategoryMain.lean b/lean/OAI/Computability/DegreeRigidity/Representation/CategoryMain.lean new file mode 100644 index 0000000000000000000000000000000000000000..0656749330e6d9d4e3ef7b542914a9ae00f80926 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/CategoryMain.lean @@ -0,0 +1,20 @@ +import OAI.Computability.DegreeRigidity.Representation.Reduction +import OAI.Computability.DegreeRigidity.Representation.CategoryAvoidance + +namespace OAI + +namespace TuringRigidity + +theorem inverse_le_realDegree_of_representation (hrep : BorelRepresentation) + (π : Degree ≃o Degree) (t : ℝ) (ht : Irrational t) (ht0 : 0 < t) (ht1 : t < 1) : + π.symm (realDegree t) ≤ realDegree t := + inverse_le_realDegree_of_obligations hrep cut_arithmetic four_value_recovery + CategorySearch.category_avoidance π t ht ht0 ht1 + +theorem main_of_two_obligations (hrep : BorelRepresentation) + (hcover : IrrationalDegreeCoverage) : MainTheorem := + main_of_three_obligations hrep hcover CategorySearch.category_avoidance + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/CategoryReduction.lean b/lean/OAI/Computability/DegreeRigidity/Representation/CategoryReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..e92fc2f9d14d0c02944daf264ae4cc9599a4f1a6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/CategoryReduction.lean @@ -0,0 +1,109 @@ +import OAI.Computability.DegreeRigidity.Representation.CategoryMachine + +namespace OAI + +namespace TuringRigidity.CategorySearch +open Encodable Set + +def trialInput (z : ℕ) : ℕ := + let n := (Nat.unpair z).1 + let s := (Nat.unpair z).2 + let i := (Nat.unpair s).1 + let j := (Nat.unpair (Nat.unpair s).2).1 + let t := (Nat.unpair (Nat.unpair s).2).2 + Nat.pair (Nat.pair i (Nat.pair j n)) t + +theorem trialInput_primrec : Primrec trialInput := by + have hn := Primrec.fst.comp Primrec.unpair + have hs := Primrec.snd.comp Primrec.unpair + have hi := Primrec.fst.comp (Primrec.unpair.comp hs) + have hj := Primrec.fst.comp (Primrec.unpair.comp (Primrec.snd.comp (Primrec.unpair.comp hs))) + have ht := Primrec.snd.comp (Primrec.unpair.comp (Primrec.snd.comp (Primrec.unpair.comp hs))) + exact Primrec₂.natPair.comp (Primrec₂.natPair.comp hi (Primrec₂.natPair.comp hj hn)) ht + +noncomputable def searchTrial (A : Oracle) (d : Nat.Partrec.Code) (n s : ℕ) : Option ℕ := + UniformOracle.trial (Avalue A) d + (Nat.unpair (trialInput (Nat.pair n s))).1 + (Nat.unpair (trialInput (Nat.pair n s))).2 + +theorem searchTrial_recursive (A : Oracle) (d : Nat.Partrec.Code) : + Nat.RecursiveIn {oracleFunction A} + (fun z => Part.some (encode (searchTrial A d (Nat.unpair z).1 (Nat.unpair z).2))) := by + have h := UniformOracle.total_comp (UniformOracle.trial_recursive (Avalue A) d) + (UniformOracle.total_primrec trialInput_primrec) + have hO : (fun n => Part.some (Avalue A n)) = oracleFunction A := rfl + rw [hO] at h + exact h.of_eq (fun z => by simp only [searchTrial,Nat.pair_unpair]) + +theorem searchTrial_pair (A : Oracle) (d : Nat.Partrec.Code) (n i j m k : ℕ) : + searchTrial A d n (Nat.pair i (Nat.pair j (Nat.pair m k))) = + d.evaln k (Nat.pair (encode (UniformOracle.oraclePrefix (Avalue A) m)) + (Nat.pair i (Nat.pair j n))) := by + simp [searchTrial,trialInput,UniformOracle.trial] + +theorem reduces_of_dense (A Y : Oracle) (c : OracleCode) (l r : ℚ × ℚ) + (hne : (rectangle l r).Nonempty) + (hd : rectangle l r ⊆ closure (success A Y c)) : Reduces Y A := by + obtain ⟨d,hdcode⟩ := finiteRun_code c l r + apply RecursiveIn.iff_nat.mpr + apply UniformOracle.total_search (searchTrial_recursive A d) (Avalue Y) + · intro n s a ha + have hs := Nat.pair_unpair s + generalize hi : (Nat.unpair s).1 = i at * + generalize ht : (Nat.unpair s).2 = t at * + subst s + have ht := Nat.pair_unpair t + generalize hj : (Nat.unpair t).1 = j at * + generalize hu : (Nat.unpair t).2 = u at * + subst t + have hu := Nat.pair_unpair u + generalize hm : (Nat.unpair u).1 = m at * + generalize hk : (Nat.unpair u).2 = k at * + subst u + rw [searchTrial_pair] at ha + have hrun := Nat.Partrec.Code.evaln_sound ha + rw [hdcode] at hrun + simp only [finiteRun,Nat.unpair_pair] at hrun + split at hrun + next hin => + exact dense_sound A Y c l r hd (sample i j) ((inside_iff l r i j).mp hin) n a + ((OracleCode.eval_approximates (finiteOracle_approximates A i j) c n).1 m a hrun) + next => simp at hrun + · intro n + obtain ⟨p,hp⟩ := hne + obtain ⟨z,hzR,hzS⟩ := mem_closure_iff.mp (hd hp) (rectangle l r) + (isOpen_Ioo.prod isOpen_Ioo) hp + have hz : Avalue Y n ∈ OracleCode.eval (oracleFunction (pairOracle A z)) c n := by + rw [hzS] + exact Part.mem_some _ + obtain ⟨q,hqR,hq⟩ := rational_halting A c l r z hzR n (Avalue Y n) hz + let i := encode q.1 + let j := encode q.2 + have hs : sample i j = ((q.1 : ℝ),(q.2 : ℝ)) := by simp [sample,i,j,rationalEnumeration] + have hin : inside l r i j := (inside_iff l r i j).mpr (hs.symm ▸ hqR) + rw [← hs] at hq + obtain ⟨m,hm⟩ := (OracleCode.eval_approximates (finiteOracle_approximates A i j) c n).2 + (Avalue Y n) hq + have hf : Avalue Y n ∈ d.eval (Nat.pair (encode (UniformOracle.oraclePrefix (Avalue A) m)) + (Nat.pair i (Nat.pair j n))) := by + rw [hdcode] + simpa [finiteRun,hin] using hm m le_rfl + obtain ⟨k,hk⟩ := Nat.Partrec.Code.evaln_complete.mp hf + exact ⟨Nat.pair i (Nat.pair j (Nat.pair m k)), Avalue Y n,by rwa [searchTrial_pair]⟩ + +theorem source_irrational_dense_reduces (A Y : Oracle) (c : OracleCode) (l r : ℚ × ℚ) + (hne : (rectangle l r).Nonempty) + (hd : rectangle l r ⊆ closure {p : ℝ × ℝ | + Irrational p.1 ∧ Irrational p.2 ∧ p ∈ success A Y c}) : Reduces Y A := by + apply reduces_of_dense A Y c l r hne + exact hd.trans (closure_mono (fun _ hp => hp.2.2)) + +theorem dense_single_program (A Y : Oracle) (c : OracleCode) (l r : ℚ × ℚ) + (hne : (rectangle l r).Nonempty) + (hd : rectangle l r ⊆ closure (success A Y c)) : + ∃ d : OracleCode, OracleCode.eval (oracleFunction A) d = oracleFunction Y := + (OracleCode.turingReducible_iff_exists_code _ _).mp (reduces_of_dense A Y c l r hne hd) + +end TuringRigidity.CategorySearch + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/CommonExtensionProgram.lean b/lean/OAI/Computability/DegreeRigidity/Representation/CommonExtensionProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..b07fa752146c8e0b024ab873fb951feda6d10227 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/CommonExtensionProgram.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.Syntax.DefinedPrefixRemoval +import OAI.Computability.DegreeRigidity.Representation.OwnSourceEquation + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing RecursiveNames +open CohenColumnRealName ElementaryModel PersistentRestrictions SetDegreeDecoding BoundedForcing +open GenericIdentity +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +def ColumnRealizesExtension (M K a E : ZFSet.{0}) (A : Oracle) : Prop := + ∃ H : GenericFilter (Conditions (poset K)), GroundGeneric M H ∧ + genericExtensionSet M (poset K) H.carrier = E ∧ + (realName K a).val H.carrier = realCode A + +theorem own_program_in_common_extension (M K a : ZFSet.{0}) (δ : Ordinal.{0}) + (Z : ZFSet.{0}) (φ : SentenceForm) (f : Name (Conditions (poset K))) + (hfv : ∀ H : GenericFilter (Conditions (poset K)), GroundGeneric M H → + f.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet M (poset K) H.carrier)) δ) + φ (fun _ : Fin φ.bound => Z)) + (p : OracleCode) (R : Oracle) + (hprog : ∀ H : GenericFilter (Conditions (poset K)), GroundGeneric M H → + ∀ A : Oracle, (realName K a).val H.carrier = realCode A → + OwnProgramAt (genericExtensionSet M (poset K) H.carrier) (f.val H.carrier) p R A) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (A : Oracle) (hA : ColumnRealizesExtension M K a + (genericExtensionSet M (poset K) G.carrier) A) : + OwnProgramAt (genericExtensionSet M (poset K) G.carrier) (f.val G.carrier) p R A := by + obtain ⟨H,hH,he,hv⟩ := hA + have hf := defined_value_extension_eq M (poset K) δ Z φ f hfv H G hH hG he + have h := hprog H hH A hv + rwa [he,hf] at h + +theorem sourceEquation_of_common_extension (M K a : ZFSet.{0}) + (δ : Ordinal.{0}) (Z : ZFSet.{0}) (φ : SentenceForm) (f : Name (Conditions (poset K))) + (hfv : ∀ H : GenericFilter (Conditions (poset K)), GroundGeneric M H → + f.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet M (poset K) H.carrier)) δ) + φ (fun _ : Fin φ.bound => Z)) + (p : OracleCode) (P : Oracle) + (hprog : ∀ H : GenericFilter (Conditions (poset K)), GroundGeneric M H → + ∀ A : Oracle, (realName K a).val H.carrier = realCode A → + OwnProgramAt (genericExtensionSet M (poset K) H.carrier) (f.val H.carrier) p P A) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (hE : Transitive (genericExtensionSet M (poset K) G.carrier)) + (hTE : SourceT (genericExtensionSet M (poset K) G.carrier)) + [Countable (Conditions (genericExtensionSet M (poset K) G.carrier))] + (I : CountableIdeal) (ρ : I ≃o I) + (hOwn : OwnDegreeExtension (genericExtensionSet M (poset K) G.carrier) + (idealSet I) (automorphismSet ρ) (f.val G.carrier)) + (Y L R : Oracle) (hL : GenericCoding.InfiniteOdd L) (hR : GenericCoding.InfiniteOdd R) + (hideal : PrincipalIntersection Y (join Y L) (join Y R)) + (hlifts : ∀ A ∈ ({Y,L,R,GenericCoding.code Y L,GenericCoding.code Y R} : Set Oracle), + ColumnRealizesExtension M K a (genericExtensionSet M (poset K) G.carrier) A) : + SourceEquation p P (Y,L,R) := by + have hrep (A : Oracle) (hA : A ∈ ({Y,L,R,GenericCoding.code Y L,GenericCoding.code Y R} : Set Oracle)) := + own_program_in_common_extension M K a δ Z φ f hfv p P hprog G hG A (hlifts A hA) + exact sourceEquation_of_own_extension _ hE hTE I ρ _ hOwn p P Y L R hL hR hideal + (hrep Y (by simp)) (hrep L (by simp)) (hrep R (by simp)) + (hrep (GenericCoding.code Y L) (by simp)) (hrep (GenericCoding.code Y R) (by simp)) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/CommonGenericModels.lean b/lean/OAI/Computability/DegreeRigidity/Representation/CommonGenericModels.lean new file mode 100644 index 0000000000000000000000000000000000000000..039721f7d566c4254d745bbca83a4d5c3163ac63 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/CommonGenericModels.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalDenseFamily +import OAI.Computability.DegreeRigidity.SetModels.InternalCollapseExistence + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalGeneric +open TransitiveNameModel CountableForcing +universe u + +instance extension_countable (M c : ZFSet.{u}) [Countable (Conditions M)] (G : Set (Conditions c)) : + Countable (Conditions (genericExtensionSet M c G)) := by + have hM : (M : Set ZFSet.{u}).Countable := by + apply (Set.countable_range (label M)).mono + intro x hx + exact label_surjective M hx + have hE : (genericExtensionSet M c G : Set ZFSet.{u}).Countable := by + rw [genericExtensionSet_coe] + exact genericExtension_countable M c hM G + let : Countable (genericExtensionSet M c G : Set ZFSet.{u}) := hE.to_subtype + exact Function.Injective.countable (f := fun p : Conditions (genericExtensionSet M c G) => + (⟨label _ p,label_mem _ p⟩ : (genericExtensionSet M c G : Set ZFSet.{u}))) + (fun x y h => label_injective _ (congrArg (fun z : (genericExtensionSet M c G : Set ZFSet.{u}) => z.val) h)) + +theorem counting_model_with_generic (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) {c o : ZFSet.{u}} [Preorder (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ p q : Conditions c, ZFSet.pair (label c p) (label c q) ∈ o ↔ p ≤ q) + (p₀ : Conditions c) : + ∃ N : ZFSet.{u}, M ⊆ N ∧ Transitive N ∧ SourceT N ∧ Countable (Conditions N) ∧ + ∃ G : GenericFilter (Conditions c), p₀ ∈ G.carrier ∧ + genericFilterSet c G.carrier ∈ N ∧ AtomicForcing.GroundGeneric M G := by + obtain ⟨D,hDM,hD,hcD⟩ := dense_family M hM hT hc hoM ho + obtain ⟨d,hd,_,_,H,_,hMN,hN,hTN,hcount⟩ := + InternalCollapse.exists_internal_counting_extension M hM hT hDM ⟨c,hcD⟩ + let : Preorder (Conditions d) := InternalCollapse.collapsePreorder d + let N := genericExtensionSet M d H.carrier + obtain ⟨G,hp,hGN,hG⟩ := internal_ground_generic M N hM hN hT hTN hMN hc hoM hDM ho hD hcount p₀ + exact ⟨N,hMN,hN,hTN,inferInstance,G,hp,hGN,hG⟩ + +theorem common_generic_model (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) + {c o d v : ZFSet.{u}} [Preorder (Conditions c)] [Preorder (Conditions d)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ p q : Conditions c, ZFSet.pair (label c p) (label c q) ∈ o ↔ p ≤ q) + (hd : d ∈ M) (hvM : v ∈ M) + (hv : ∀ p q : Conditions d, ZFSet.pair (label d p) (label d q) ∈ v ↔ p ≤ q) + (p₀ : Conditions c) (q₀ : Conditions d) : + ∃ N : ZFSet.{u}, M ⊆ N ∧ Transitive N ∧ SourceT N ∧ Countable (Conditions N) ∧ + ∃ G : GenericFilter (Conditions c), ∃ H : GenericFilter (Conditions d), + p₀ ∈ G.carrier ∧ q₀ ∈ H.carrier ∧ genericFilterSet c G.carrier ∈ N ∧ + genericFilterSet d H.carrier ∈ N ∧ AtomicForcing.GroundGeneric M G ∧ + AtomicForcing.GroundGeneric M H := by + obtain ⟨N,hMN,hN,hTN,hcount,G,hp,hGN,hG⟩ := counting_model_with_generic M hM hT hc hoM ho p₀ + let : Countable (Conditions N) := hcount + obtain ⟨K,hNK,hK,hTK,hcountK,H,hq,hHK,hH⟩ := + counting_model_with_generic N hN hTN (hMN hd) (hMN hvM) hv q₀ + refine ⟨K,fun _ hx => hNK (hMN hx),hK,hTK,hcountK,G,H,hp,hq,hNK hGN,hHK,hG,?_⟩ + intro E hEM hE + exact hH E (hMN hEM) hE + +end TuringRigidity.BoundedSetTheory.InternalGeneric + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/CommonIdeal.lean b/lean/OAI/Computability/DegreeRigidity/Representation/CommonIdeal.lean new file mode 100644 index 0000000000000000000000000000000000000000..c92851c4bf0c145216fc9a719951631172eec318 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/CommonIdeal.lean @@ -0,0 +1,182 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteTranscript +import OAI.Computability.DegreeRigidity.Representation.BorelGeneric +import OAI.Computability.DegreeRigidity.Computability.Joins + +namespace OAI + +namespace TuringRigidity.CommonIdeal +open Set Encodable + +def bit (b : Bool) : ℕ := if b then 1 else 0 + +def table (s : List Bool) : ℕ →. ℕ := BranchMachine.lookup (s.map bit) + +def run (A : Oracle) (p : OracleCode) (s : List Bool) : ℕ →. ℕ := + OracleCode.eval (partialJoin (oracleFunction A) (table s)) p + +def Extends (G : Oracle) (s : List Bool) : Prop := + ∀ i, i < s.length → G i = s.getD i false + +theorem table_mono {s t : List Bool} (h : s <+: t) : + ∀ k a, a ∈ table s k → a ∈ table t k := by + obtain ⟨u,rfl⟩ := h + intro k a ha + change a ∈ (((s ++ u).map bit)[k]? : Part ℕ) + change a ∈ ((s.map bit)[k]? : Part ℕ) at ha + have hk : k < s.length := by + by_contra hn + simp [List.getElem?_eq_none (show (s.map bit).length ≤ k by simp; omega)] at ha + simpa [List.map_append, List.getElem?_append, hk] using ha + +theorem table_total {G : Oracle} {s : List Bool} (h : Extends G s) : + ∀ k a, a ∈ table s k → a ∈ oracleFunction G k := by + intro k a ha + change a ∈ ((s.map bit)[k]? : Part ℕ) at ha + have hk : k < s.length := by + by_contra hn + simp [List.getElem?_eq_none (show (s.map bit).length ≤ k by simp; omega)] at ha + have he : (s.map bit)[k]? = some (bit (s.getD k false)) := by + simp [List.getD, hk] + rw [he] at ha + have hv : a = bit (s.getD k false) := by simpa using ha + change a ∈ Part.some (bit (G k)) + rw [h k hk] + exact Part.mem_some_iff.mpr hv + +theorem run_mono {A : Oracle} {p : OracleCode} {s t : List Bool} + (h : s <+: t) (n a : ℕ) (ha : a ∈ run A p s n) : a ∈ run A p t n := by + apply OracleCode.eval_mono (c := p) (n := n) (a := a) ?_ ha + intro k b hb + cases hk : k.bodd with + | false => simpa [partialJoin,hk] using hb + | true => + exact table_mono h _ _ (by simpa [partialJoin,hk] using hb) |> + (fun hh => by simpa [partialJoin,hk] using hh) + +theorem run_total {A G : Oracle} {p : OracleCode} {s : List Bool} + (h : Extends G s) (n a : ℕ) (ha : a ∈ run A p s n) : + a ∈ OracleCode.eval (oracleFunction (join A G)) p n := by + apply OracleCode.eval_mono (c := p) (n := n) (a := a) ?_ ha + intro k b hb + cases hk : k.bodd with + | false => simpa [partialJoin, oracleFunction, join, hk] using hb + | true => + have ht : b ∈ table s (k/2) := by simpa [partialJoin,hk] using hb + simpa [oracleFunction,join,hk] using table_total h _ _ ht + +def initialWord (G : Oracle) (m : ℕ) : List Bool := (List.range m).map G + +@[simp] theorem prefix_length (G : Oracle) (m : ℕ) : (initialWord G m).length = m := by + simp [initialWord] + +@[simp] theorem prefix_getD (G : Oracle) (m i : ℕ) (hi : i < m) : + (initialWord G m).getD i false = G i := by + simp [initialWord,List.getD,List.getElem?_range hi] + +theorem extends_prefix (G : Oracle) (m : ℕ) : Extends G (initialWord G m) := by + intro i hi + exact (prefix_getD G m i (by simpa using hi)).symm + +theorem prefix_mono (G : Oracle) {m n : ℕ} (h : m ≤ n) : initialWord G m <+: initialWord G n := by + apply List.prefix_iff_getElem.mpr + refine ⟨by simpa using h, ?_⟩ + intro i hi + simp [initialWord] + +theorem table_prefix (G : Oracle) (m : ℕ) : + table (initialWord G m) = BranchMachine.lookup (UniformOracle.oraclePrefix (fun k => bit (G k)) m) := by + simp only [table,initialWord,UniformOracle.oraclePrefix,List.map_map,Function.comp_def] + rfl + +theorem run_approximates (A G : Oracle) (p : OracleCode) (n : ℕ) : + Approximates (OracleCode.eval (oracleFunction (join A G)) p n) + (fun m => run A p (initialWord G m) n) := by + have he : partialJoin (oracleFunction A) (oracleFunction G) = oracleFunction (join A G) := by + funext k + cases hk : k.bodd <;> simp [partialJoin,oracleFunction,join,hk] + rw [←he] + apply OracleCode.eval_approximates + intro k + apply BranchMachine.partialJoin_approximates + · intro k; exact Approximates.const _ + · intro k + simpa only [table_prefix,oracleFunction,bit] using UniformOracle.prefix_approximates (fun k => bit (G k)) k + +theorem prefix_of_extends {G : Oracle} {s : List Bool} (h : Extends G s) + {m : ℕ} (hm : s.length ≤ m) : s <+: initialWord G m := by + apply List.prefix_iff_getElem.mpr + refine ⟨by simpa using hm, ?_⟩ + intro i hi + have hh := h i hi + simpa [List.getD,List.getElem?_eq_getElem hi,initialWord,List.getElem_map,List.getElem_range] using hh.symm + +theorem run_finite_extension {A G : Oracle} {p : OracleCode} {s : List Bool} + (h : Extends G s) (n a : ℕ) + (ha : a ∈ OracleCode.eval (oracleFunction (join A G)) p n) : + ∃ t, s <+: t ∧ a ∈ run A p t n := by + obtain ⟨m,hm⟩ := (run_approximates A G p n).2 a ha + exact ⟨initialWord G (max m s.length),prefix_of_extends h (le_max_right _ _), + hm _ (le_max_left _ _)⟩ + +def Disagree (A : Oracle) (p q : OracleCode) (s t : List Bool) : Prop := + ∃ n a b, a ≠ b ∧ a ∈ run A p s n ∧ b ∈ run A q t n + +def Agree (A : Oracle) (p q : OracleCode) (s t : List Bool) : Prop := + ∀ u v n a b, s <+: u → t <+: v → + a ∈ run A p u n → b ∈ run A q v n → a = b + +def Requirement (A : Oracle) (p q : OracleCode) (s t : List Bool) : Prop := + Disagree A p q s t ∨ Agree A p q s t + +theorem requirement_dense (A : Oracle) (p q : OracleCode) (s t : List Bool) : + ∃ u v, s <+: u ∧ t <+: v ∧ Requirement A p q u v := by + classical + by_cases h : ∃ u v, s <+: u ∧ t <+: v ∧ Disagree A p q u v + · obtain ⟨u,v,hu,hv,hh⟩ := h + exact ⟨u,v,hu,hv,Or.inl hh⟩ + · refine ⟨s,t,List.prefix_rfl,List.prefix_rfl,Or.inr ?_⟩ + intro u v n a b hu hv ha hb + by_contra hab + exact h ⟨u,v,hu,hv,n,a,b,hab,ha,hb⟩ + +theorem requirement_mono {A : Oracle} {p q : OracleCode} {s t u v : List Bool} + (hs : s <+: u) (ht : t <+: v) (h : Requirement A p q s t) : + Requirement A p q u v := by + rcases h with ⟨n,a,b,hab,ha,hb⟩ | h + · exact Or.inl ⟨n,a,b,hab,run_mono hs n a ha,run_mono ht n b hb⟩ + · exact Or.inr (fun x y n a b hx hy => h x y n a b (hs.trans hx) (ht.trans hy)) + +theorem agree_of_common_output {A G H Y : Oracle} {p q : OracleCode} {s t : List Bool} + (hs : Extends G s) (ht : Extends H t) (hR : Requirement A p q s t) + (hp : OracleCode.eval (oracleFunction (join A G)) p = oracleFunction Y) + (hq : OracleCode.eval (oracleFunction (join A H)) q = oracleFunction Y) : + Agree A p q s t := by + rcases hR with ⟨n,a,b,hab,ha,hb⟩ | hR + · have ha' := run_total hs n a ha + have hb' := run_total ht n b hb + rw [hp] at ha' + rw [hq] at hb' + exact False.elim (hab (Part.mem_unique ha' hb')) + · exact hR + +theorem agreeing_search_sound {A H Y : Oracle} {p q : OracleCode} {s t : List Bool} + (ht : Extends H t) (h : Agree A p q s t) + (hq : OracleCode.eval (oracleFunction (join A H)) q = oracleFunction Y) + (w : List Bool) (n a : ℕ) (ha : a ∈ run A p (s ++ w) n) : a = bit (Y n) := by + have hb : bit (Y n) ∈ OracleCode.eval (oracleFunction (join A H)) q n := by + rw [hq]; exact Part.mem_some _ + obtain ⟨v,hv,hb'⟩ := run_finite_extension ht n (bit (Y n)) hb + exact h (s ++ w) v n a (bit (Y n)) (List.prefix_append s w) hv ha hb' + +theorem agreeing_search_complete {A G Y : Oracle} {p : OracleCode} {s : List Bool} + (hs : Extends G s) + (hp : OracleCode.eval (oracleFunction (join A G)) p = oracleFunction Y) (n : ℕ) : + ∃ w a, a ∈ run A p (s ++ w) n := by + have ha : bit (Y n) ∈ OracleCode.eval (oracleFunction (join A G)) p n := by + rw [hp]; exact Part.mem_some _ + obtain ⟨u,⟨w,rfl⟩,hu⟩ := run_finite_extension hs n (bit (Y n)) ha + exact ⟨w,bit (Y n),hu⟩ + +end TuringRigidity.CommonIdeal + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/CommonIdealBorel.lean b/lean/OAI/Computability/DegreeRigidity/Representation/CommonIdealBorel.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ee5a68af9ca13267810dfcadafecfa7b07d280c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/CommonIdealBorel.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DegreeRigidity.Representation.CommonIdeal + +namespace OAI + +namespace TuringRigidity.OracleCode +theorem eval_partial_openFiber {X : Type*} [TopologicalSpace X] (O : X → ℕ →. ℕ) + (hO : ∀ n, OpenFiber (fun x => O x n)) (c : OracleCode) : + ∀ n, OpenFiber (fun x => eval (O x) c n) := by + induction c with + | zero => intro n; exact OpenFiber.const _ + | succ => intro n; exact OpenFiber.const _ + | left => intro n; exact OpenFiber.const _ + | right => intro n; exact OpenFiber.const _ + | query => intro n; exact hO n + | pair c d hc hd => intro n; exact (OpenFiber.map (hc n) Nat.pair).seq (hd n) + | comp c d hc hd => intro n; exact (hd n).bind (fun k => hc k) + | prec c d hc hd => + intro p + have hrec : ∀ k : ℕ, OpenFiber (fun x => + Nat.rec (eval (O x) c (Nat.unpair p).1) + (fun y ih => ih.bind (fun i => + eval (O x) d (Nat.pair (Nat.unpair p).1 (Nat.pair y i)))) k) := by + intro k + induction k with + | zero => exact hc _ + | succ k ih => exact ih.bind (fun i => hd _) + exact hrec (Nat.unpair p).2 + | find c hc => + intro n + exact OpenFiber.rfind (fun k => (hc (Nat.pair n k)).map (fun m => decide (m=0))) + +end TuringRigidity.OracleCode +namespace TuringRigidity.CommonIdeal +open Set + +theorem run_open (p : OracleCode) (s : List Bool) (n a : ℕ) : + IsOpen {A : Oracle | a ∈ run A p s n} := by + apply OracleCode.eval_partial_openFiber + intro k + unfold partialJoin + split + · exact OpenFiber.const _ + · apply OpenFiber.some + exact (continuous_of_discreteTopology : Continuous (fun b : Bool => if b then (1 : ℕ) else 0)).comp + (continuous_apply (k/2)) + +theorem disagree_measurable (p q : OracleCode) (s t : List Bool) : + MeasurableSet {A | Disagree A p q s t} := by + simp only [Disagree, Set.ofPred_exists] + apply MeasurableSet.iUnion + intro n + apply MeasurableSet.iUnion + intro a + apply MeasurableSet.iUnion + intro b + by_cases h : a ≠ b + · have he : {A : Oracle | a ≠ b ∧ a ∈ run A p s n ∧ b ∈ run A q t n} = + {A | a ∈ run A p s n} ∩ {A | b ∈ run A q t n} := by + ext A + exact ⟨fun hx => hx.2,fun hx => ⟨h,hx⟩⟩ + rw [he] + exact (run_open p s n a).measurableSet.inter (run_open q t n b).measurableSet + · simp [h] + +theorem agree_measurable (p q : OracleCode) (s t : List Bool) : + MeasurableSet {A | Agree A p q s t} := by + have he : {A | Agree A p q s t} = + (⋃ (u : List Bool) (v : List Bool), {A | s <+: u ∧ t <+: v ∧ Disagree A p q u v})ᶜ := by + ext A + simp only [mem_compl_iff,mem_iUnion,mem_ofPred_eq] + constructor + · intro h ⟨u,v,hu,hv,n,a,b,hab,ha,hb⟩ + exact hab (h u v n a b hu hv ha hb) + · intro h u v n a b hu hv ha hb + by_contra hab + exact h ⟨u,v,hu,hv,n,a,b,hab,ha,hb⟩ + rw [he] + apply MeasurableSet.compl + apply MeasurableSet.iUnion + intro u + apply MeasurableSet.iUnion + intro v + by_cases hs : s <+: u ∧ t <+: v + · simpa [hs.1,hs.2] using disagree_measurable p q u v + · have hfalse : ¬ (s <+: u ∧ t <+: v) := hs + convert MeasurableSet.empty (α := Oracle) using 1 + ext A + simp only [mem_ofPred_eq,mem_empty_iff_false,iff_false,not_and] + intro hsu htv + exact False.elim (hfalse ⟨hsu,htv⟩) + +theorem requirement_measurable (p q : OracleCode) (s t : List Bool) : + MeasurableSet {A | Requirement A p q s t} := + (disagree_measurable p q s t).union (agree_measurable p q s t) + +end TuringRigidity.CommonIdeal + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/CommonIdealSearch.lean b/lean/OAI/Computability/DegreeRigidity/Representation/CommonIdealSearch.lean new file mode 100644 index 0000000000000000000000000000000000000000..622273a1bf9fb2b795f4d036fe8965802d3c71c1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/CommonIdealSearch.lean @@ -0,0 +1,113 @@ +import OAI.Computability.DegreeRigidity.Representation.CommonIdeal + +namespace OAI + +namespace TuringRigidity.CommonIdeal +open Encodable Computable UniformOracle + +theorem bit_primrec : Primrec bit := by + apply (Primrec.cond Primrec.id (Primrec.const 1) (Primrec.const 0)).of_eq + intro b + cases b <;> rfl + +theorem table_partrec : Partrec₂ table := + BranchMachine.lookup_partrec.comp + ((Primrec.list_map Primrec.id (bit_primrec.comp Primrec.snd).to₂).to_comp.comp fst) snd + +def finiteRun (p : OracleCode) (s : List Bool) (L : List ℕ) (w : ℕ) : Part ℕ := + OracleCode.eval (partialJoin (BranchMachine.lookup L) + (table (s ++ BorelGeneric.word (Nat.unpair w).1))) p (Nat.unpair w).2 + +theorem finiteRun_partrec (p : OracleCode) (s : List Bool) : Partrec₂ (finiteRun p s) := by + let α := List ℕ × ℕ + have hword : Computable (fun z : α => s ++ BorelGeneric.word (Nat.unpair z.2).1) := + (Primrec.list_append.comp (Primrec.const s) + (Primrec.option_getD_default.comp (Primrec.decode.comp + (Primrec.fst.comp (Primrec.unpair.comp Primrec.snd))))).to_comp + have hA : Partrec₂ (fun z : α => BranchMachine.lookup z.1) := + BranchMachine.lookup_partrec.comp (fst.comp fst) snd + have hG : Partrec₂ (fun z : α => table (s ++ BorelGeneric.word (Nat.unpair z.2).1)) := + table_partrec.comp (hword.comp fst) snd + exact (OracleCode.eval_partrec (BranchMachine.partialJoin_partrec hA hG) p).comp + Computable.id (snd.comp (Computable.unpair.comp snd)) + +theorem finiteRun_code (p : OracleCode) (s : List Bool) : + ∃ d : Nat.Partrec.Code, ∀ L w, d.eval (Nat.pair (encode L) w) = finiteRun p s L w := by + obtain ⟨d,hd⟩ := partrec_code (finiteRun_partrec p s) + exact ⟨d,fun L w => hd (L,w)⟩ + +theorem finiteRun_approximates (A : Oracle) (p : OracleCode) (s : List Bool) (w n : ℕ) : + Approximates (run A p (s ++ BorelGeneric.word w) n) + (fun m => finiteRun p s (oraclePrefix (fun k => bit (A k)) m) (Nat.pair w n)) := by + simp only [finiteRun,Nat.unpair_pair] + apply OracleCode.eval_approximates + intro k + apply BranchMachine.partialJoin_approximates + · exact prefix_approximates (fun k => bit (A k)) + · intro k; exact Approximates.const _ + +def searchTrial (A : Oracle) (d : Nat.Partrec.Code) (n z : ℕ) : Option ℕ := + d.evaln (Nat.unpair (Nat.unpair z).2).2 + (Nat.pair (encode (oraclePrefix (fun k => bit (A k)) (Nat.unpair z).1)) + (Nat.pair (Nat.unpair (Nat.unpair z).2).1 n)) + +theorem searchTrial_recursive (A : Oracle) (d : Nat.Partrec.Code) : + Nat.RecursiveIn {oracleFunction A} + (fun z => Part.some (encode (searchTrial A d (Nat.unpair z).1 (Nat.unpair z).2))) := by + let O : Set (ℕ →. ℕ) := {oracleFunction A} + have hn := total_primrec (O := O) (Primrec.fst.comp Primrec.unpair) + have hz := Primrec.snd.comp Primrec.unpair + have hm := total_primrec (O := O) (Primrec.fst.comp (Primrec.unpair.comp hz)) + have hw := total_primrec (O := O) (Primrec.fst.comp (Primrec.unpair.comp + (Primrec.snd.comp (Primrec.unpair.comp hz)))) + have hk := total_primrec (O := O) (Primrec.snd.comp (Primrec.unpair.comp + (Primrec.snd.comp (Primrec.unpair.comp hz)))) + have hL := total_comp (prefix_recursive (fun k => bit (A k))) hm + have he := total_primrec (O := O) (Primrec.encode.comp (Nat.Partrec.Code.primrec_evaln.comp + (((Primrec.fst.comp Primrec.unpair).pair (Primrec.const d)).pair + (Primrec.snd.comp Primrec.unpair)))) + exact (total_comp he (total_pair hk (total_pair hL (total_pair hw hn)))).of_eq (fun z => by simp [searchTrial]) + +theorem common_output_reduces {A G H Y : Oracle} {p q : OracleCode} {s t : List Bool} + (hs : Extends G s) (ht : Extends H t) (hR : Requirement A p q s t) + (hp : OracleCode.eval (oracleFunction (join A G)) p = oracleFunction Y) + (hq : OracleCode.eval (oracleFunction (join A H)) q = oracleFunction Y) : + Reduces Y A := by + have hag := agree_of_common_output hs ht hR hp hq + obtain ⟨d,hd⟩ := finiteRun_code p s + apply RecursiveIn.iff_nat.mpr + apply total_search (searchTrial_recursive A d) (fun n => bit (Y n)) + · intro n z a ha + have hfinite := Nat.Partrec.Code.evaln_sound ha + rw [hd] at hfinite + have hactual := (finiteRun_approximates A p s + (Nat.unpair (Nat.unpair z).2).1 n).1 (Nat.unpair z).1 a hfinite + exact agreeing_search_sound ht hag hq _ n a hactual + · intro n + obtain ⟨w,a,ha⟩ := agreeing_search_complete hs hp n + obtain ⟨wcode,hw⟩ := BorelGeneric.word_surjective w + rw [←hw] at ha + obtain ⟨m,hm⟩ := (finiteRun_approximates A p s wcode n).2 a ha + have hfinite := hm m le_rfl + dsimp only at hfinite + rw [←hd] at hfinite + obtain ⟨k,hk⟩ := Nat.Partrec.Code.evaln_complete.mp hfinite + exact ⟨Nat.pair m (Nat.pair wcode k),a,by simpa [searchTrial] using hk⟩ + +theorem ideal_of_meets (A G H : Oracle) + (h : ∀ p q : OracleCode, ∃ s t, Extends G s ∧ Extends H t ∧ Requirement A p q s t) : + ∀ b : Degree, b ≤ degree A ↔ b ≤ degree (join A G) ∧ b ≤ degree (join A H) := by + intro b + obtain ⟨Y,rfl⟩ := degree_surjective b + constructor + · intro hY + exact ⟨reduces_trans hY (reduces_join_left A G),reduces_trans hY (reduces_join_left A H)⟩ + · rintro ⟨hG,hH⟩ + obtain ⟨p,hp⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp hG + obtain ⟨q,hq⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp hH + obtain ⟨s,t,hs,ht,hR⟩ := h p q + exact common_output_reduces hs ht hR hp hq + +end TuringRigidity.CommonIdeal + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/CommonIdealSelection.lean b/lean/OAI/Computability/DegreeRigidity/Representation/CommonIdealSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..1dc86ccd7de291a6d3ebec7f5c8c2c9d92060ef5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/CommonIdealSelection.lean @@ -0,0 +1,171 @@ +import OAI.Computability.DegreeRigidity.Representation.CommonIdealSearch +import OAI.Computability.DegreeRigidity.Representation.CommonIdealBorel + +namespace OAI + +namespace TuringRigidity.CommonIdeal +open Set Encodable + +def even (G : Oracle) : Oracle := fun n => G (2*n) +def odd (G : Oracle) : Oracle := fun n => G (2*n+1) +def pad (s : List Bool) : Oracle := fun n => s.getD n false + +theorem pad_extends (s : List Bool) : Extends (pad s) s := fun _ _ => rfl + +theorem extends_of_prefix {G : Oracle} {s t : List Bool} (h : s <+: t) + (ht : Extends G t) : Extends G s := by + obtain ⟨u,rfl⟩ := h + intro i hi + rw [ht i (by simp; omega)] + simp [List.getD,List.getElem?_append,hi] + +theorem join_columns (G : Oracle) : join (even G) (odd G) = G := by + funext n + have hn := Nat.bodd_add_div2 n + cases hb : n.bodd with + | false => + have he : 2*(n/2) = n := by simpa [hb,Nat.div2_val] using hn + simp [join,even,hb,he] + | true => + have he : 2*(n/2)+1 = n := by simpa [hb,Nat.div2_val,Nat.add_comm] using hn + simp [join,odd,hb,he] + +def Embeds (r s t : List Bool) : Prop := + ∀ G : Oracle, Extends G r → Extends (even G) s ∧ Extends (odd G) t + +theorem embeds_initialWord (s t : List Bool) (M : ℕ) + (hs : 2*s.length ≤ M) (ht : 2*t.length ≤ M) : + Embeds (initialWord (join (pad s) (pad t)) M) s t := by + intro G hG + constructor + · intro i hi + have hh := hG (2*i) (by simp; omega) + rw [prefix_getD _ _ _ (by omega),join_even] at hh + exact hh + · intro i hi + have hh := hG (2*i+1) (by simp; omega) + rw [prefix_getD _ _ _ (by omega),join_odd] at hh + exact hh + +theorem join_extends_input (r u v : List Bool) + (hu : initialWord (even (pad r)) r.length <+: u) + (hv : initialWord (odd (pad r)) r.length <+: v) : + Extends (join (pad u) (pad v)) r := by + have hU := extends_of_prefix hu (pad_extends u) + have hV := extends_of_prefix hv (pad_extends v) + intro n hn + have hhalf : n/2 < r.length := by omega + have hU' := hU (n/2) (by simpa using hhalf) + have hV' := hV (n/2) (by simpa using hhalf) + rw [prefix_getD _ _ _ hhalf] at hU' hV' + have heq : join (pad u) (pad v) n = join (even (pad r)) (odd (pad r)) n := by + unfold join + split + · exact hV' + · exact hU' + rw [heq,join_columns] + rfl + +def family (A : Oracle) (n c : ℕ) : Prop := + ∃ s t : List Bool, Embeds (BorelGeneric.word c) s t ∧ + Requirement A (codeEnumeration (Nat.unpair n).1) (codeEnumeration (Nat.unpair n).2) s t + +theorem family_dense (A : Oracle) (n c : ℕ) : + ∃ d, BorelGeneric.Ext c d ∧ family A n d := by + let r := BorelGeneric.word c + obtain ⟨u,v,hu,hv,hR⟩ := requirement_dense A + (codeEnumeration (Nat.unpair n).1) (codeEnumeration (Nat.unpair n).2) + (initialWord (even (pad r)) r.length) (initialWord (odd (pad r)) r.length) + let M := 2*(u.length+v.length+r.length+1) + let w := initialWord (join (pad u) (pad v)) M + obtain ⟨d,hd⟩ := BorelGeneric.word_surjective w + refine ⟨d,?_,?_⟩ + · constructor + · rw [hd] + exact prefix_of_extends (join_extends_input r u v hu hv) (by dsimp [M]; omega) + · rw [hd] + simp only [w,prefix_length] + dsimp [M,r] + omega + · refine ⟨u,v,?_,hR⟩ + rw [hd] + exact embeds_initialWord u v M (by dsimp [M]; omega) (by dsimp [M]; omega) + +theorem family_measurable (n c : ℕ) : MeasurableSet {A | family A n c} := by + simp only [family,Set.ofPred_exists] + apply MeasurableSet.iUnion + intro s + apply MeasurableSet.iUnion + intro t + by_cases he : Embeds (BorelGeneric.word c) s t + · simpa [he] using requirement_measurable + (codeEnumeration (Nat.unpair n).1) (codeEnumeration (Nat.unpair n).2) s t + · simp [he] + +theorem family_mono {A : Oracle} {n c d : ℕ} + (hcd : BorelGeneric.word c <+: BorelGeneric.word d) (h : family A n c) : + family A n d := by + obtain ⟨s,t,he,hR⟩ := h + exact ⟨s,t,fun G hG => he G (extends_of_prefix hcd hG),hR⟩ + +theorem ideal_of_family (A G : Oracle) + (h : ∀ n, ∃ c, family A n c ∧ BorelGeneric.Meets G c) : + ∀ b : Degree, b ≤ degree A ↔ + b ≤ degree (join A (even G)) ∧ b ≤ degree (join A (odd G)) := by + apply ideal_of_meets + intro p q + obtain ⟨i,hi⟩ := codeEnumeration_surjective p + obtain ⟨j,hj⟩ := codeEnumeration_surjective q + obtain ⟨c,⟨s,t,he,hR⟩,hG⟩ := h (Nat.pair i j) + have hh := he G hG + refine ⟨s,t,hh.1,hh.2,?_⟩ + simpa only [Nat.unpair_pair,hi,hj] using hR + +theorem borel_selected_common_ideal : + ∃ G0 G1 : Oracle → Oracle, Measurable G0 ∧ Measurable G1 ∧ + ∀ (A : Oracle) (b : Degree), b ≤ degree A ↔ + b ≤ degree (join A (G0 A)) ∧ b ≤ degree (join A (G1 A)) := by + obtain ⟨G,hG,hmeet⟩ := BorelGeneric.borel_generic_selection family family_dense family_measurable + refine ⟨fun A => even (G A),fun A => odd (G A),?_,?_,?_⟩ + · apply Measurable.of_eval + intro n + exact (measurable_pi_apply (2*n)).comp hG + · apply Measurable.of_eval + intro n + exact (measurable_pi_apply (2*n+1)).comp hG + · intro A + exact ideal_of_family A (G A) (hmeet A) + +theorem borel_selected_common_ideal_with + (S : Oracle → ℕ → ℕ → Prop) + (hS : ∀ n c, MeasurableSet {A | S A n c}) + (hd : ∀ A n c, ∃ d, BorelGeneric.Ext c d ∧ S A n d) : + ∃ G : Oracle → Oracle, Measurable G ∧ ∀ A, + (∀ b : Degree, b ≤ degree A ↔ + b ≤ degree (join A (even (G A))) ∧ b ≤ degree (join A (odd (G A)))) ∧ + (∀ n, ∃ c, S A n c ∧ BorelGeneric.Meets (G A) c) := by + let R : Oracle → ℕ → ℕ → Prop := fun A n c => + if (Nat.unpair n).1 = 0 then family A (Nat.unpair n).2 c else S A (Nat.unpair n).2 c + have hRd : ∀ A n c, ∃ d, BorelGeneric.Ext c d ∧ R A n d := by + intro A n c + dsimp only [R] + split + · exact family_dense A _ c + · exact hd A _ c + have hRm : ∀ n c, MeasurableSet {A | R A n c} := by + intro n c + dsimp only [R] + split + · exact family_measurable _ c + · exact hS _ c + obtain ⟨G,hG,hm⟩ := BorelGeneric.borel_generic_selection R hRd hRm + refine ⟨G,hG,fun A => ⟨?_,?_⟩⟩ + · apply ideal_of_family + intro n + simpa only [R,Nat.unpair_pair,ite_true] using hm A (Nat.pair 0 n) + · intro n + simpa only [R,Nat.unpair_pair,show ¬ (1 : ℕ) = 0 by omega,ite_false] using hm A (Nat.pair 1 n) + +end TuringRigidity.CommonIdeal + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/CountableGroundGeneric.lean b/lean/OAI/Computability/DegreeRigidity/Representation/CountableGroundGeneric.lean new file mode 100644 index 0000000000000000000000000000000000000000..a58e7e23d6f274e8a5b6f3b7c4cae1e7e10bc06f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/CountableGroundGeneric.lean @@ -0,0 +1,40 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalAtomicTruth + +namespace OAI + + +namespace TuringRigidity.AtomicForcing +open TransitiveNameModel BoundedSetTheory CountableForcing +universe u + +theorem countable_ground_generic (M : ZFSet.{u}) [Countable (Conditions M)] + (hne : ∃ x, x ∈ M) {c : ZFSet.{u}} [Preorder (Conditions c)] (p : Conditions c) : + ∃ G : GenericFilter (Conditions c), p ∈ G.carrier ∧ GroundGeneric M G := by + classical + obtain ⟨x,hx⟩ := hne + obtain ⟨m,_⟩ := label_surjective M hx + let _ : Nonempty (Conditions M) := ⟨m⟩ + obtain ⟨e,he⟩ := exists_surjective_nat (Conditions M) + let D : ℕ → Set (Conditions c) := fun n => + if Dense {q : Conditions c | label c q ∈ label M (e n)} then + {q | label c q ∈ label M (e n)} else Set.univ + have hD : ∀ n, Dense (D n) := by + intro n + dsimp only [D] + split + · assumption + · exact fun q => ⟨q,le_rfl,Set.mem_univ _⟩ + obtain ⟨G,hp,hG⟩ := exists_generic D hD p + refine ⟨G,hp,?_⟩ + intro E hEM hE + obtain ⟨m,hm⟩ := label_surjective M hEM + obtain ⟨n,rfl⟩ := he m + have hd : Dense {q : Conditions c | label c q ∈ label M (e n)} := by + rw [hm]; exact hE + obtain ⟨q,hq,hqn⟩ := hG n + refine ⟨q,hq,?_⟩ + simpa only [D,ite_eq_left hd,Set.mem_ofPred_eq,hm] using hqn + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/CoverageMain.lean b/lean/OAI/Computability/DegreeRigidity/Representation/CoverageMain.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf385ca0d877ee1451f249a55fc991fbe229bc18 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/CoverageMain.lean @@ -0,0 +1,13 @@ +import OAI.Computability.DegreeRigidity.Representation.CategoryMain +import OAI.Computability.DegreeRigidity.Computability.DegreeCoverage + +namespace OAI + +namespace TuringRigidity + +theorem main_of_representation (hrep : BorelRepresentation) : MainTheorem := + main_of_two_obligations hrep irrational_degree_coverage + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/Endpoints.lean b/lean/OAI/Computability/DegreeRigidity/Representation/Endpoints.lean new file mode 100644 index 0000000000000000000000000000000000000000..9dae629245ed76e16e9ca588819a8309eb6f4dd6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/Endpoints.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalPrograms +import Mathlib.Topology.Baire.CompleteMetrizable + +namespace OAI + +open Set Filter Topology +namespace TuringRigidity + +theorem countable_real_meagre (s : Set ℝ) (hs : s.Countable) : IsMeagre s := by + have hsingle : ∀ x : ℝ, IsMeagre ({x} : Set ℝ) := by + intro x + apply IsNowhereDense.isMeagre + simp [IsNowhereDense] + have h := isMeagre_biUnion hs (fun x _ => hsingle x) + simpa using h + +theorem exists_separating_endpoints (F : ℝ → Oracle) + (hfiber : ∀ B, {x | F x = B}.Countable) (D : Set ℝ) (hD : D ∈ residual ℝ) + (u ρ : ℝ) (hρ : 0 < ρ) : + ∃ lo hi : ℝ, -ρ < lo ∧ lo < 0 ∧ 0 < hi ∧ hi < ρ ∧ + u+lo ∈ D ∧ u+hi ∈ D ∧ F (u+lo) ≠ F (u+hi) := by + have hleft : (D ∩ Ioo (u-ρ) u).Nonempty := by + obtain ⟨x,hx,hxD⟩ := (dense_of_mem_residual hD).inter_open_nonempty + (Ioo (u-ρ) u) isOpen_Ioo (nonempty_Ioo.mpr (by linarith)) + exact ⟨x,hxD,hx⟩ + obtain ⟨xm,hxmD,hxmlo,hxmhi⟩ := hleft + have hfib : IsMeagre {x | F x = F xm} := countable_real_meagre _ (hfiber (F xm)) + have hres : D ∩ {x | F x = F xm}ᶜ ∈ residual ℝ := inter_mem hD hfib + have hright : ((D ∩ {x | F x = F xm}ᶜ) ∩ Ioo u (u+ρ)).Nonempty := by + obtain ⟨x,hx,hxD⟩ := (dense_of_mem_residual hres).inter_open_nonempty + (Ioo u (u+ρ)) isOpen_Ioo (nonempty_Ioo.mpr (by linarith)) + exact ⟨x,hxD,hx⟩ + obtain ⟨xp,⟨hxpD,hxpF⟩,hxplo,hxphi⟩ := hright + refine ⟨xm-u,xp-u,by linarith,by linarith,by linarith,by linarith,?_,?_,?_⟩ + · simpa using hxmD + · simpa using hxpD + · simpa [ne_comm] using hxpF + +theorem exists_endpoint_bands (F : ℝ → Oracle) + (hfiber : ∀ B, {x | F x = B}.Countable) (D : Set ℝ) (hD : D ∈ residual ℝ) + (hcont : ContinuousOn F D) (t u ρ : ℝ) (hρ : 0 < ρ) + (hshift : ∀ s ∈ rationalSpan t, u+s ∈ D) : + ∃ (lo hi : ℝ) (j : ℕ) (δ : ℚ), + -ρ < lo ∧ lo < 0 ∧ 0 < hi ∧ hi < ρ ∧ + 0 < δ ∧ (δ : ℝ) < ρ ∧ 3*(δ : ℝ) < hi-lo ∧ + (∀ s ∈ rationalSpan t, s ∈ Icc lo (lo+(δ : ℝ)) → F (u+s) j ≠ F (u+hi) j) ∧ + (∀ s ∈ rationalSpan t, s ∈ Icc (hi-(δ : ℝ)) hi → F (u+s) j = F (u+hi) j) := by + obtain ⟨lo,hi,hloρ,hlo,hhi,hhiρ,hloD,hhiD,hne⟩ := + exists_separating_endpoints F hfiber D hD u ρ hρ + have hbit : ∃ j : ℕ, F (u+lo) j ≠ F (u+hi) j := by + by_contra h + apply hne + funext j + exact not_ne_iff.mp (fun hj => h ⟨j,hj⟩) + obtain ⟨j,hj⟩ := hbit + have hc : ContinuousOn (fun x => F x j) D := (continuous_apply j).comp_continuousOn hcont + obtain ⟨εl,hεl,hlconst⟩ := locally_constant_on_restriction (fun x => F x j) D hc (u+lo) hloD + obtain ⟨εr,hεr,hrconst⟩ := locally_constant_on_restriction (fun x => F x j) D hc (u+hi) hhiD + let b : ℝ := min ρ (min εl (min εr ((hi-lo)/3))) + have hb : 0 < b := lt_min hρ (lt_min hεl (lt_min hεr (by linarith))) + obtain ⟨δ,hδ0,hδb⟩ := exists_rat_btwn hb + have hδρ : (δ : ℝ) < ρ := hδb.trans_le (min_le_left _ _) + have hδl : (δ : ℝ) < εl := hδb.trans_le ((min_le_right _ _).trans (min_le_left _ _)) + have hδr : (δ : ℝ) < εr := hδb.trans_le + ((min_le_right _ _).trans ((min_le_right _ _).trans (min_le_left _ _))) + have hδgap : (δ : ℝ) < (hi-lo)/3 := hδb.trans_le + ((min_le_right _ _).trans ((min_le_right _ _).trans (min_le_right _ _))) + refine ⟨lo,hi,j,δ,hloρ,hlo,hhi,hhiρ,by exact_mod_cast hδ0,hδρ,by linarith,?_,?_⟩ + · intro s hs hband + have hdist : dist (u+s) (u+lo) < εl := by + rw [Real.dist_eq] + have heq : u+s-(u+lo) = s-lo := by ring + rw [heq, abs_of_nonneg (sub_nonneg.mpr hband.1)] + linarith [hband.2] + rw [hlconst _ (hshift s hs) hdist] + exact hj + · intro s hs hband + have hdist : dist (u+s) (u+hi) < εr := by + rw [Real.dist_eq] + have heq : u+s-(u+hi) = s-hi := by ring + rw [heq, abs_of_nonpos (sub_nonpos.mpr hband.2)] + linarith [hband.1] + exact hrconst _ (hshift s hs) hdist + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/FullNativePersistence.lean b/lean/OAI/Computability/DegreeRigidity/Representation/FullNativePersistence.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f0be490cba24cbdf190f7df81ab0c1c63d95904 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/FullNativePersistence.lean @@ -0,0 +1,74 @@ +import OAI.Computability.DegreeRigidity.SetModels.FullSetTruth +import OAI.Computability.DegreeRigidity.Representation.SourceTGenericPersistence + +namespace OAI + + +namespace TuringRigidity.FullSetForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +open ElementaryModel SentenceForm SetModelSatisfaction SetDegreeDecoding SetModelReals +open PersistentRestrictions ArithmeticTree +universe u + +noncomputable def fromInternal : InternalFormula → SentenceForm + | .bounded p => fromBounded p + | .conj p q => .conj (fromInternal p) (fromInternal q) + | .neg p => .neg (fromInternal p) + | .existsSet p => .ex (fromInternal p) + +theorem internal_sat (p : InternalFormula) (M : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (fromInternal p).Sat (M : Set ZFSet) e ↔ p.Realize M e := by + induction p generalizing e with + | bounded p => exact bounded_sat p M e + | conj p q hp hq => exact and_congr (hp e) (hq e) + | neg p hp => exact not_congr (hp e) + | existsSet p hp => + apply exists_congr; intro x + exact and_congr_right (fun _ => hp (cons x e)) + +theorem full_native_persistence_iff (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {D L : ZFSet.{u}} (hDM : D ∈ M) (hLM : L ∈ M) + (hD : ∀ x, x ∈ D ↔ ∃ A ∈ SetModelReals.reals M, x = degreeSet (degree A)) + (hL : ∀ A ∈ SetModelReals.reals M, ∀ B ∈ SetModelReals.reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + (I : CountableIdeal) (hI : idealSet I ∈ M) + (hct : SetModelCountability.InternallyCountable M (idealSet I)) + (ρ : I ≃o I) (hρ : automorphismSet ρ ∈ M) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + (fromInternal persistenceFormula).Sat (M : Set ZFSet) + (cons D (cons L (cons (idealSet I) (cons (automorphismSet ρ) (fun _ => ZFSet.omega))))) ↔ + Persistent I ρ := + (internal_sat persistenceFormula M _).trans + (native_persistence_absolute M hM hT hDM hLM hD hL I hI hct ρ hρ hz) + +theorem generic_full_native_truth (M : ZFSet.{u}) (hM : Transitive M) (hV : Valid M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) (ht : ⊤ ∈ G.carrier) + (e : ℕ → Name (Conditions c)) (he : ∀ i, (e i).encode (label c) ∈ M) + (D L : ZFSet.{u}) (I : CountableIdeal) (ρ : I ≃o I) + (hvals : (fun i => (e i).val G.carrier) = + cons D (cons L (cons (idealSet I) (cons (automorphismSet ρ) (fun _ => ZFSet.omega))))) + (hD : ∀ x, x ∈ D ↔ ∃ A ∈ SetModelReals.reals (genericExtensionSet M c G.carrier), x = degreeSet (degree A)) + (hL : ∀ A ∈ SetModelReals.reals (genericExtensionSet M c G.carrier), + ∀ B ∈ SetModelReals.reals (genericExtensionSet M c G.carrier), + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + (hct : SetModelCountability.InternallyCountable (genericExtensionSet M c G.carrier) (idealSet I)) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + Persistent I ρ ↔ ∃ p ∈ G.carrier, Forces M e (fromInternal persistenceFormula) p := by + let N := genericExtensionSet M c G.carrier + have hN := genericExtensionSet_transitive M c hM G.carrier + have hTN := extension_sourceT M hM (hV.sourceT hM ⟨c,hc⟩) hc hoM ho G hG ht + have hm (i : ℕ) : cons D (cons L (cons (idealSet I) + (cons (automorphismSet ρ) (fun _ => ZFSet.omega)))) i ∈ N := by + rw [←hvals] + exact (mem_extensionSet M c G.carrier _).mpr ⟨e i,he i,rfl⟩ + have hn := full_native_persistence_iff N hN hTN (hm 0) (hm 1) hD hL I (hm 2) hct ρ (hm 3) hz + have hf := full_truth M hM hV hc hoM ho G hG (fromInternal persistenceFormula) e he + rw [hvals] at hf + exact hn.symm.trans hf + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericAssembly.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericAssembly.lean new file mode 100644 index 0000000000000000000000000000000000000000..3bf223a843e59174aaa9f523858d54c961520a14 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericAssembly.lean @@ -0,0 +1,34 @@ +import OAI.Computability.DegreeRigidity.SetModels.IdealSelection + +namespace OAI + +namespace TuringRigidity + +theorem representative_from_generic_coding (π : Degree ≃o Degree) + (F : Oracle → Oracle) (hF : Measurable F) + (C : Oracle → Oracle → Oracle) (hC : Measurable (Function.uncurry C)) + (G : Bool → Oracle → Oracle) (hG : ∀ b, Measurable (G b)) + (hgen : ∀ A b, degree (F (G b A)) = π (degree (G b A))) + (hcoded : ∀ A b, degree (F (C A (G b A))) = π (degree (C A (G b A)))) + (hideal : ∀ A a, a ≤ degree A ↔ + a ≤ degree (join (C A (G false A)) (G false A)) ∧ + a ≤ degree (join (C A (G true A)) (G true A))) : + ∃ H : Oracle → Oracle, Measurable H ∧ ∀ A, degree (H A) = π (degree A) := by + let L : Bool → Oracle → Oracle := fun b A => join (F (C A (G b A))) (F (G b A)) + have hL (b : Bool) : Measurable (L b) := + join_measurable _ _ (hF.comp (hC.comp (measurable_id.prodMk (hG b)))) (hF.comp (hG b)) + have hdegree (A : Oracle) (b : Bool) : + degree (L b A) = π (degree (join (C A (G b A)) (G b A))) := by + dsimp only [L] + change degree (F (C A (G b A))) ⊔ degree (F (G b A)) = + π (degree (C A (G b A)) ⊔ degree (G b A)) + rw [hcoded A b, hgen A b, π.map_sup] + apply borel_of_ideal_intersection (L false) (L true) (hL false) (hL true) + (fun A => π (degree A)) + intro A a + rw [hdegree A false,hdegree A true] + exact common_lower_transport π _ _ _ (hideal A) a + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericCoding.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericCoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..3832f0e32c3d11e0d2b76da2f545a4d7d6d96305 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericCoding.lean @@ -0,0 +1,175 @@ +import OAI.Computability.DegreeRigidity.Computability.BinaryMachine +import OAI.Computability.DegreeRigidity.Computability.BranchFrequency +import OAI.Computability.DegreeRigidity.Effective.ProgramSelection +import Mathlib.Order.Interval.Finset.Basic + +namespace OAI + +namespace TuringRigidity.GenericCoding +open UniformOracle BinarySeries Encodable + +def count (G : Oracle) : ℕ → ℕ := runningSum (fun n => bit G (2*n+1)) + +def code (A G : Oracle) (n : ℕ) : Bool := + if G (2*n+1) then A (count G n) else G (2*(n-count G n)) + +theorem count_le (G : Oracle) (n : ℕ) : count G n ≤ n := by + induction n with + | zero => rfl + | succ n ih => + change count G n + bit G (2*n+1) ≤ n+1 + unfold bit + split <;> omega + +theorem count_mono (G : Oracle) : Monotone (count G) := by + apply monotone_nat_of_le_succ + intro n + change count G n ≤ count G n + bit G (2*n+1) + omega + +def InfiniteOdd (G : Oracle) : Prop := ∀ N, ∃ n, N ≤ n ∧ G (2*n+1) = true + +theorem infiniteOdd_iff (G : Oracle) : InfiniteOdd G ↔ {n | G (2*n+1) = true}.Infinite := by + constructor + · intro h + apply Set.infinite_of_forall_exists_gt + intro N + obtain ⟨n,hn,hb⟩ := h (N+1) + exact ⟨n,hb,by omega⟩ + · intro h N + obtain ⟨n,hb,hn⟩ := h.exists_gt N + exact ⟨n,by omega,hb⟩ + +theorem count_unbounded (G : Oracle) (hG : InfiniteOdd G) (k : ℕ) : + ∃ n, k ≤ count G n := by + induction k with + | zero => exact ⟨0,by simp [count,runningSum]⟩ + | succ k ih => + obtain ⟨n,hn⟩ := ih + obtain ⟨m,hm,hb⟩ := hG n + have hc := count_mono G hm + refine ⟨m+1,?_⟩ + change k+1 ≤ count G m + bit G (2*m+1) + simp only [bit,hb,↓reduceIte] + omega + +theorem exists_insertion (G : Oracle) (hG : InfiniteOdd G) (k : ℕ) : + ∃ n, count G n = k ∧ G (2*n+1) = true := by + have hi : ∀ m, k < count G m → ∃ n, count G n = k ∧ G (2*n+1) = true := by + intro m + induction m with + | zero => simp [count,runningSum] + | succ m ih => + intro hm + by_cases hk : k < count G m + · exact ih hk + · change k < count G m + bit G (2*m+1) at hm + cases hb : G (2*m+1) with + | false => simp [bit,hb] at hm; omega + | true => exact ⟨m,by simp [bit,hb] at hm; omega,hb⟩ + obtain ⟨m,hm⟩ := count_unbounded G hG (k+1) + exact hi m (by omega) + +theorem count_recursive {O : Set (ℕ →. ℕ)} (G : Oracle) + (hG : Nat.RecursiveIn O (oracleFunction G)) : + Nat.RecursiveIn O (fun n => Part.some (count G n)) := + runningSum_recursive (total_comp hG (total_primrec + (Primrec.succ.comp (Primrec.nat_mul.comp (Primrec.const 2) Primrec.id)))) + +theorem code_recursive {O : Set (ℕ →. ℕ)} (A G : Oracle) + (hA : Nat.RecursiveIn O (oracleFunction A)) (hG : Nat.RecursiveIn O (oracleFunction G)) : + Nat.RecursiveIn O (oracleFunction (code A G)) := by + have hc := count_recursive G hG + have ho := total_comp hG (total_primrec + (Primrec.succ.comp (Primrec.nat_mul.comp (Primrec.const 2) Primrec.id))) + have ha := total_comp hA hc + have hi := total_comp (total_primrec (Primrec.nat_mul.comp (Primrec.const 2) + (Primrec.nat_sub.comp (Primrec.fst.comp Primrec.unpair) (Primrec.snd.comp Primrec.unpair)))) + (total_pair (total_primrec Primrec.id) hc) + have he := total_comp hG hi + have hd : Primrec (fun z : ℕ => if (Nat.unpair z).1=1 then + (Nat.unpair (Nat.unpair z).2).1 else (Nat.unpair (Nat.unpair z).2).2) := + Primrec.ite (Primrec.eq.comp (Primrec.fst.comp Primrec.unpair) (Primrec.const 1)) + (Primrec.fst.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair))) + (Primrec.snd.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair))) + exact (total_comp (total_primrec hd) (total_pair ho (total_pair ha he))).of_eq (fun n => by + cases hh : G (2*n+1) <;> simp [code,oracleFunction,hh]) + +theorem code_reduces (A G : Oracle) : Reduces (code A G) (join A G) := by + apply RecursiveIn.iff_nat.mpr + exact code_recursive A G (RecursiveIn.iff_nat.mp (reduces_join_left A G)) + (RecursiveIn.iff_nat.mp (reduces_join_right A G)) + +def recoverDecision (z : ℕ × ℕ × ℕ × ℕ) : Option ℕ := + if z.1=z.2.1 ∧ z.2.2.1=1 then some z.2.2.2 else none + +theorem recoverDecision_primrec : Primrec recoverDecision := + Primrec.ite ((Primrec.eq.comp Primrec.fst (Primrec.fst.comp Primrec.snd)).and + (Primrec.eq.comp (Primrec.fst.comp (Primrec.snd.comp Primrec.snd)) (Primrec.const 1))) + (Primrec.option_some.comp (Primrec.snd.comp (Primrec.snd.comp Primrec.snd))) (Primrec.const none) + +def recoverTrial (A G : Oracle) (k n : ℕ) : Option ℕ := + recoverDecision (k,count G n,bit G (2*n+1),bit (code A G) n) + +theorem recoverTrial_recursive (A G : Oracle) : + Nat.RecursiveIn {oracleFunction (join (code A G) G)} + (fun z => Part.some (encode (recoverTrial A G (Nat.unpair z).1 (Nat.unpair z).2))) := by + let O : Set (ℕ →. ℕ) := {oracleFunction (join (code A G) G)} + have hg : Nat.RecursiveIn O (oracleFunction G) := RecursiveIn.iff_nat.mp (reduces_join_right (code A G) G) + have ha : Nat.RecursiveIn O (oracleFunction (code A G)) := RecursiveIn.iff_nat.mp (reduces_join_left (code A G) G) + have hk := total_primrec (O := O) (Primrec.fst.comp Primrec.unpair) + have hn := total_primrec (O := O) (Primrec.snd.comp Primrec.unpair) + have hc := total_comp (count_recursive G hg) hn + have ho := total_comp hg (total_primrec (Primrec.succ.comp + (Primrec.nat_mul.comp (Primrec.const 2) (Primrec.snd.comp Primrec.unpair)))) + have ha' := total_comp ha hn + have hd := (Primrec.fst.comp Primrec.unpair).pair + (((Primrec.fst.comp Primrec.unpair).pair + (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair))).comp (Primrec.snd.comp Primrec.unpair)) + exact (total_comp (total_primrec (Primrec.encode.comp (recoverDecision_primrec.comp hd))) + (total_pair hk (total_pair hc (total_pair ho ha')))).of_eq (fun z => by simp [recoverTrial,bit]) + +theorem recoverTrial_sound (A G : Oracle) (k n a : ℕ) (ha : a ∈ recoverTrial A G k n) : + a = bit A k := by + unfold recoverTrial recoverDecision at ha + split at ha + · rename_i h + have hg : G (2*n+1) = true := by cases hh : G (2*n+1) <;> simp_all [bit] + have hk : k = count G n := h.1 + simpa [bit,code,hg,←hk] using (Option.mem_def.mp ha).symm + · simp at ha + +theorem recoverTrial_complete (A G : Oracle) (hG : InfiniteOdd G) (k : ℕ) : + ∃ n a, a ∈ recoverTrial A G k n := by + obtain ⟨n,hn,hg⟩ := exists_insertion G hG k + exact ⟨n,bit A k,by simp [recoverTrial,recoverDecision,hn,hg,bit,code]⟩ + +theorem set_reduces_code_join (A G : Oracle) (hG : InfiniteOdd G) : + Reduces A (join (code A G) G) := by + apply RecursiveIn.iff_nat.mpr + exact total_search (recoverTrial_recursive A G) (bit A) (recoverTrial_sound A G) + (recoverTrial_complete A G hG) + +theorem join_degree_eq (A G : Oracle) (hG : InfiniteOdd G) : + degree (join (code A G) G) = degree (join A G) := by + apply (degree_eq_iff _ _).mpr + exact ⟨join_reduces (code_reduces A G) (reduces_join_right A G), + join_reduces (set_reduces_code_join A G hG) (reduces_join_right (code A G) G)⟩ + +theorem source_join_degree_eq (A G : Oracle) (hG : {n | G (2*n+1) = true}.Infinite) : + degree (join (code A G) G) = degree (join A G) := + join_degree_eq A G ((infiniteOdd_iff G).mpr hG) + +theorem forward_single_program (A G : Oracle) : + ∃ p : OracleCode, ∀ n, OracleCode.eval (oracleFunction (join A G)) p n = oracleFunction (code A G) n := by + obtain ⟨p,hp⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp (code_reduces A G) + exact ⟨p,fun n => congrFun hp n⟩ + +theorem inverse_single_program (A G : Oracle) (hG : InfiniteOdd G) : + ∃ p : OracleCode, ∀ n, OracleCode.eval (oracleFunction (join (code A G) G)) p n = oracleFunction A n := by + obtain ⟨p,hp⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp (set_reduces_code_join A G hG) + exact ⟨p,fun n => congrFun hp n⟩ + +end TuringRigidity.GenericCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericCodingBorel.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericCodingBorel.lean new file mode 100644 index 0000000000000000000000000000000000000000..303a228a3d0cf11a8a472949341fe7f416ca7997 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericCodingBorel.lean @@ -0,0 +1,46 @@ +import OAI.Computability.DegreeRigidity.Representation.GenericCoding + +namespace OAI + +namespace TuringRigidity.GenericCoding +open Set UniformOracle BinarySeries + +theorem query_measurable {X : Type*} [MeasurableSpace X] + (A : X → Oracle) (q : X → ℕ) (hA : Measurable A) (hq : Measurable q) : + Measurable (fun x => A x (q x)) := by + apply measurable_to_countable' + intro b + change MeasurableSet {x | A x (q x) = b} + have he : {x | A x (q x) = b} = ⋃ n : ℕ, {x | q x = n} ∩ {x | A x n = b} := by + ext x + simp only [mem_ofPred_eq,mem_iUnion,mem_inter_iff] + exact ⟨fun h => ⟨q x,rfl,h⟩,fun ⟨n,hn,h⟩ => by simpa [hn] using h⟩ + rw [he] + exact MeasurableSet.iUnion (fun n => (measurableSet_eq_fun hq measurable_const).inter + (measurableSet_eq_fun ((measurable_pi_apply n).comp hA) measurable_const)) + +theorem count_measurable (n : ℕ) : Measurable (fun G : Oracle => count G n) := by + induction n with + | zero => exact measurable_const + | succ n ih => + have hb : Measurable (fun G : Oracle => bit G (2*n+1)) := + (measurable_of_countable (fun b : Bool => if b then (1 : ℕ) else 0)).comp + (measurable_pi_apply (2*n+1)) + exact (measurable_of_countable (fun z : ℕ × ℕ => z.1+z.2)).comp (ih.prodMk hb) + +theorem code_measurable : Measurable (Function.uncurry code) := by + apply Measurable.of_eval + intro n + have hc : Measurable (fun p : Oracle × Oracle => count p.2 n) := (count_measurable n).comp measurable_snd + have ha := query_measurable (fun p : Oracle × Oracle => p.1) (fun p => count p.2 n) measurable_fst hc + have hi : Measurable (fun p : Oracle × Oracle => 2*(n-count p.2 n)) := + (measurable_of_countable (fun k : ℕ => 2*(n-k))).comp hc + have he := query_measurable (fun p : Oracle × Oracle => p.2) _ measurable_snd hi + have ho : Measurable (fun p : Oracle × Oracle => p.2 (2*n+1)) := + (measurable_pi_apply (2*n+1)).comp measurable_snd + exact (measurable_of_countable (fun z : Bool × Bool × Bool => if z.1 then z.2.1 else z.2.2)).comp + (ho.prodMk (ha.prodMk he)) + +end TuringRigidity.GenericCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericDescentDefinition.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericDescentDefinition.lean new file mode 100644 index 0000000000000000000000000000000000000000..71a477ab5ecac3f86964f638bf9d225fa15ed0a1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericDescentDefinition.lean @@ -0,0 +1,32 @@ +import OAI.Computability.DegreeRigidity.Representation.GenericPersistenceDescent +import OAI.Computability.DegreeRigidity.Constructibility.PersistentOneRealDefinition + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel SetDegreeDecoding +open PersistentRestrictions ArithmeticTree +universe u + +theorem generically_persistent_ground_graph_definition (M N : ZFSet.{u}) + [Countable (Conditions M)] (hM : Transitive M) (hTM : SourceT M) + (hN : Transitive N) (hTN : SourceT N) (hMN : M ⊆ N) + (ρ : modelIdeal M hM hTM ≃o modelIdeal M hM hTM) + (hρN : automorphismSet ρ ∈ N) + (hgen : SetGenericallyPersistent N (modelIdeal M hM hTM) ρ) : + automorphismSet ρ ∈ relativeModel M (groundReals M) ∧ + ∃ (δ : Ordinal.{u}) (P : Oracle) (p : SentenceForm), + δ.toZFSet ∈ M ∧ P ∈ modelReals M ∧ p.bound ≤ 2 ∧ + realCode P ∈ level (groundReals M) δ ∧ + automorphismSet ρ = definedSubset (level (groundReals M) δ) p + (fun _ : Fin p.bound => realCode P) := by + have hd := generically_persistent_ground_graph_descent M N hM hTM hN hTN hMN ρ hρN hgen + obtain ⟨t,P,hP,hi,ht,hval⟩ := construction_of_relativeModel M hM hTM _ hd + obtain ⟨p,hbound,hdef⟩ := t.cofinal_one_real_definition + obtain ⟨β,_,_,_,hidx,hreal,hset⟩ := hdef M hM hTM P hP ht hi 0 (internal_ordinal_zero M hM hTM) + exact ⟨hd,heightDomainIndex (OrdinalCoding.paddedCode t.ordinalVector β), + P,p,hidx,hP,hbound,hreal,hval ▸ hset⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericFactor.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..66d16dc1c15202b5428ef5d71d3b8aa3bad5418a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericFactor.lean @@ -0,0 +1,113 @@ +import OAI.Computability.DegreeRigidity.Representation.PairGenericSelection + +namespace OAI + +namespace TuringRigidity.GenericFactor +open FiniteShuffle ShuffleRequirements PairGenericSelection GenericTopology Set + +def Rectangle (D : List Bool → Prop) (s t : List Bool) : Prop := + ∀ Y Z, Realizes s Y → Realizes t Z → join Y Z ∈ OpenSet D + +theorem rectangle_dense (D : List Bool → Prop) (hD : DenseOpen D) (s t : List Bool) : + ∃ u v, s <+: u ∧ t <+: v ∧ Rectangle D u v := by + let Y : Oracle := fun i => s.getD i false + let Z : Oracle := fun i => t.getD i false + let n := max s.length t.length + obtain ⟨w,hw,hwD⟩ := hD.1 (initial (join Y Z) (2*n)) + let H : Oracle := fun i => w.getD i false + have hH : Agree (2*n) (join Y Z) H := agree_of_prefix hw + have hlen : 2*n ≤ w.length := by simpa using hw.length_le + refine ⟨initial (column false H) w.length,initial (column true H) w.length,?_,?_,?_⟩ + · rw [←prefix_default s] + apply initial_prefix (n := s.length) (m := w.length) (by dsimp [n] at hlen; omega) + intro i hi + exact (show Y i = H (2*i) from by simpa using hH (2*i) (by dsimp [n]; omega)) + · rw [←prefix_default t] + apply initial_prefix (n := t.length) (m := w.length) (by dsimp [n] at hlen; omega) + intro i hi + exact (show Z i = H (2*i+1) from by simpa using hH (2*i+1) (by dsimp [n]; omega)) + · intro A B hA hB + have ha := (realizes_initial _ _ _).mp hA + have hb := (realizes_initial _ _ _).mp hB + refine ⟨w,hwD,?_⟩ + apply Agree.mono (n := 2*w.length) _ (by omega) + apply agree_of_columns + · intro i hi + simpa [column,H] using ha i hi + · intro i hi + simpa [column,H] using hb i hi + +def First (D : List Bool → Prop) (t s : List Bool) : Prop := + ∃ u, t <+: u ∧ Rectangle D s u + +theorem first_denseOpen (D : List Bool → Prop) (hD : DenseOpen D) (t : List Bool) : + DenseOpen (First D t) := by + constructor + · intro s + obtain ⟨u,v,hs,ht,hr⟩ := rectangle_dense D hD s t + exact ⟨u,hs,v,ht,hr⟩ + · intro s u hsu + rintro ⟨v,ht,hr⟩ + exact ⟨v,ht,fun Y Z hY hZ => hr Y Z (realizes_mono hsu hY) hZ⟩ + +def FirstFamily (D : ℕ → List Bool → Prop) (n : ℕ) : List Bool → Prop := + First (D (Nat.unpair n).1) (BorelGeneric.word (Nat.unpair n).2) + +theorem firstFamily_denseOpen (D : ℕ → List Bool → Prop) (hD : ∀ n, DenseOpen (D n)) : + ∀ n, DenseOpen (FirstFamily D n) := + fun index => first_denseOpen _ (hD (Nat.unpair index).1) _ + +def Fiber (D : ℕ → List Bool → Prop) (Y : Oracle) (n : ℕ) (t : List Bool) : Prop := + ∃ s, Realizes s Y ∧ Rectangle (D n) s t + +theorem fiber_denseOpen (D : ℕ → List Bool → Prop) (Y : Oracle) + (hY : GenericFor (FirstFamily D) Y) (n : ℕ) : DenseOpen (Fiber D Y n) := by + constructor + · intro t + obtain ⟨k,hk⟩ := BorelGeneric.word_surjective t + obtain ⟨s,hs,hYs⟩ := hY (Nat.pair n k) + change First (D (Nat.unpair (Nat.pair n k)).1) + (BorelGeneric.word (Nat.unpair (Nat.pair n k)).2) s at hs + simp only [Nat.unpair_pair,hk] at hs + obtain ⟨u,htu,hr⟩ := hs + exact ⟨u,htu,s,hYs,hr⟩ + · intro t u htu + rintro ⟨s,hYs,hr⟩ + exact ⟨s,hYs,fun A B hA hB => hr A B hA (realizes_mono htu hB)⟩ + +theorem fiber_isOpen (D : ℕ → List Bool → Prop) (n : ℕ) (t : List Bool) : + IsOpen {Y | Fiber D Y n t} := by + have he : {Y | Fiber D Y n t} = + ⋃ s : List Bool, ⋃ (_ : Rectangle (D n) s t), {Y | Realizes s Y} := by + ext Y + simp only [Fiber,mem_ofPred_eq,mem_iUnion] + aesop + rw [he] + exact isOpen_iUnion (fun s => isOpen_iUnion (fun _ => realizes_isOpen s)) + +theorem join_generic (D : ℕ → List Bool → Prop) (Y Z : Oracle) + (hZ : GenericFor (Fiber D Y) Z) : GenericFor D (join Y Z) := by + intro n + obtain ⟨t,⟨s,hYs,hr⟩,hZt⟩ := hZ n + exact hr Y Z hYs hZt + +theorem borel_fiber_selection (D : ℕ → List Bool → Prop) : + ∃ Z : {Y : Oracle // GenericFor (FirstFamily D) Y} → Oracle, Measurable Z ∧ + ∀ Y, GenericFor D (join Y.val (Z Y)) := by + let R := fun Y : {Y : Oracle // GenericFor (FirstFamily D) Y} => + fun n t => Fiber D Y.val n (BorelGeneric.word t) + have hd : ∀ Y n s, ∃ t, BorelGeneric.Ext s t ∧ R Y n t := by + intro Y n s + exact coded_dense _ (fiber_denseOpen D Y.val Y.property n) s + have hm : ∀ n t, MeasurableSet {Y | R Y n t} := by + intro n t + exact (fiber_isOpen D n (BorelGeneric.word t)).measurableSet.preimage measurable_subtype_coe + obtain ⟨Z,hZ,hreq⟩ := BorelGeneric.borel_generic_selection R hd hm + refine ⟨Z,hZ,fun Y => join_generic D Y.val (Z Y) ?_⟩ + intro n + obtain ⟨t,ht,hZt⟩ := hreq Y n + exact ⟨BorelGeneric.word t,ht,(realizes_iff_meets _ _).mpr hZt⟩ + +end TuringRigidity.GenericFactor + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericFiberIdeal.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericFiberIdeal.lean new file mode 100644 index 0000000000000000000000000000000000000000..874bdccba47ffc113fedb01d46c237f9bba5f271 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericFiberIdeal.lean @@ -0,0 +1,56 @@ +import OAI.Computability.DegreeRigidity.Representation.GenericFactor +import OAI.Computability.DegreeRigidity.Representation.CommonIdealSelection + +namespace OAI + +namespace TuringRigidity.GenericFactor +open FiniteShuffle ShuffleRequirements PairGenericSelection Set + +def IdealFiber (D : ℕ → List Bool → Prop) + (Y : {Y : Oracle // GenericFor (FirstFamily D) Y}) (n t : ℕ) : Prop := + if n % 2 = 0 then CommonIdeal.family Y.val (n/2) t + else Fiber D Y.val (n/2) (BorelGeneric.word t) + +theorem idealFiber_dense (D : ℕ → List Bool → Prop) + (Y : {Y : Oracle // GenericFor (FirstFamily D) Y}) (n s : ℕ) : + ∃ t, BorelGeneric.Ext s t ∧ IdealFiber D Y n t := by + unfold IdealFiber + split + · exact CommonIdeal.family_dense Y.val _ s + · exact coded_dense _ (fiber_denseOpen D Y.val Y.property _) s + +theorem idealFiber_measurable (D : ℕ → List Bool → Prop) (n t : ℕ) : + MeasurableSet {Y | IdealFiber D Y n t} := by + unfold IdealFiber + split + · exact (CommonIdeal.family_measurable _ _).preimage measurable_subtype_coe + · exact (fiber_isOpen D _ _).measurableSet.preimage measurable_subtype_coe + +theorem borel_joint_ideal_selection (D E : ℕ → List Bool → Prop) + (hD : ∀ n, DenseOpen (D n)) (hE : ∀ n, DenseOpen (E n)) : + (∀ n, DenseOpen (FirstFamily D n)) ∧ + ∃ Z : {Y : Oracle // GenericFor (FirstFamily D) Y} → Oracle, Measurable Z ∧ + (∀ Y, GenericFor D (join Y.val (Z Y))) ∧ + (∀ Y b, GenericFor E (column b (Z Y)) ∧ GenericCoding.InfiniteOdd (column b (Z Y)) ∧ + ∀ X, GenericFor E (GenericCoding.code X (column b (Z Y)))) ∧ + ∀ Y a, a ≤ degree Y.val ↔ + a ≤ degree (join Y.val (column false (Z Y))) ∧ + a ≤ degree (join Y.val (column true (Z Y))) := by + obtain ⟨Z,hZ,hgen,hR⟩ := borel_pair_selection E hE (IdealFiber D) + (idealFiber_dense D) (idealFiber_measurable D) + refine ⟨firstFamily_denseOpen D hD,Z,hZ,?_,hgen,?_⟩ + · intro Y + apply join_generic + intro n + obtain ⟨t,ht,hZt⟩ := hR Y (2*n+1) + refine ⟨BorelGeneric.word t,?_,(realizes_iff_meets _ _).mpr hZt⟩ + simpa [IdealFiber,Nat.add_div] using ht + · intro Y a + apply CommonIdeal.ideal_of_family Y.val (Z Y) _ a + intro n + obtain ⟨t,ht,hZt⟩ := hR Y (2*n) + exact ⟨t,by simpa [IdealFiber] using ht,hZt⟩ + +end TuringRigidity.GenericFactor + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericFilterName.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericFilterName.lean new file mode 100644 index 0000000000000000000000000000000000000000..a024bc8231df449a19db5f5a9b53c1e6ed61777f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericFilterName.lean @@ -0,0 +1,111 @@ +import OAI.Computability.DegreeRigidity.Representation.GroundInclusion + +namespace OAI + +namespace TuringRigidity.TransitiveNameModel +open RecursiveNames BoundedSetTheory +universe u + +noncomputable def genericFilterName (p : ZFSet.{u}) [Top (Conditions p)] : Name (Conditions p) := + .mk (Conditions p) (fun q => Name.check (label p q)) id + +noncomputable def genericFilterSet (p : ZFSet.{u}) (G : Set (Conditions p)) : ZFSet.{u} := + ZFSet.range (fun q : {q // q ∈ G} => label p q.val) + +theorem mem_genericFilterSet (p : ZFSet.{u}) (G : Set (Conditions p)) (x : ZFSet.{u}) : + x ∈ genericFilterSet p G ↔ ∃ q ∈ G, label p q = x := by + rw [genericFilterSet,ZFSet.mem_range] + exact ⟨fun ⟨q,hq⟩ => ⟨q.val,q.property,hq⟩,fun ⟨q,hq,hx⟩ => ⟨⟨q,hq⟩,hx⟩⟩ + +theorem val_genericFilterName (p : ZFSet.{u}) [Top (Conditions p)] + (G : Set (Conditions p)) (hG : ⊤ ∈ G) : + (genericFilterName p).val G = genericFilterSet p G := by + apply ZFSet.ext; intro x + simp only [genericFilterName,Name.mem_val,Name.val_check G hG,mem_genericFilterSet,id_eq] + +def filterCodeFormula : Formula := + .existsMem 1 (.existsMem 4 (.conj (.pairMem 1 0 4) (.orderedPair 2 0 1))) + +theorem eval_filterCodeFormula (z p f r : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + filterCodeFormula.Eval (cons z (cons p (cons f (cons r e)))) ↔ + ∃ x ∈ p, ∃ v ∈ r, ZFSet.pair x v ∈ f ∧ z = ZFSet.pair v x := by + simp only [filterCodeFormula,Formula.Eval,Formula.eval_pairMem, + Formula.eval_orderedPair,cons_zero,cons_succ] + +noncomputable def filterCode (p f : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ x ∈ p, ∃ v ∈ iterUnion 2 f, + ZFSet.pair x v ∈ f ∧ z = ZFSet.pair v x) (ZFSet.prod (iterUnion 2 f) p) + +theorem mem_filterCode (p f z : ZFSet.{u}) : + z ∈ filterCode p f ↔ ∃ x ∈ p, ∃ v, ZFSet.pair x v ∈ f ∧ z = ZFSet.pair v x := by + rw [filterCode,ZFSet.mem_sep] + constructor + · rintro ⟨_,x,hx,v,_,hv,hz⟩; exact ⟨x,hx,v,hv,hz⟩ + · rintro ⟨x,hx,v,hv,rfl⟩ + have hr := second_mem_doubleUnion hv + exact ⟨ZFSet.mem_prod.mpr ⟨v,hr,x,hx,rfl⟩,x,hx,v,hr,hv,rfl⟩ + +theorem filterCode_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + {p f : ZFSet.{u}} (hp : p ∈ M) (hf : f ∈ M) : filterCode p f ∈ M := by + have hr := iterUnion_mem M hM hU hf 2 + let e := cons p (cons f (cons (iterUnion 2 f) (fun _ => p))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hp + rcases i with _|i; exact hf + rcases i with _|i; exact hr + exact hp + have hs := sep_mem M hM hS filterCodeFormula e he + (product_mem M hM hP hU hPow hS hr hp) + have heq : ZFSet.sep (fun z => filterCodeFormula.Eval (cons z e)) + (ZFSet.prod (iterUnion 2 f) p) = filterCode p f := by + apply ZFSet.ext; intro z + simp only [filterCode,ZFSet.mem_sep] + exact and_congr_right (fun _ => eval_filterCodeFormula z p f _ _) + exact heq ▸ hs + +theorem encode_genericFilterName (p d r f : ZFSet.{u}) [Top (Conditions p)] + (hsub : p ⊆ d) (hf : CheckGraph d r f (label p ⊤)) : + (genericFilterName p).encode (label p) = filterCode p f := by + apply ZFSet.ext; intro z + change z ∈ ZFSet.range _ ↔ _ + rw [ZFSet.mem_range,mem_filterCode] + constructor + · rintro ⟨q,hq⟩ + have hx := hsub (label_mem p q) + obtain ⟨v,hv,hfv,_⟩ := hf.2.2.1 (label p q) hx + have he := hf.correct _ hx v hv hfv + refine ⟨label p q,label_mem p q,v,hfv,?_⟩ + simpa only [genericFilterName,id_eq,encode_check,he] using hq.symm + · rintro ⟨x,hx,v,hfv,hz⟩ + obtain ⟨q,rfl⟩ := label_surjective p hx + have hfr : FunctionGraph d r f := ⟨hf.2.1,hf.2.2.1⟩ + have he := hf.correct _ (hsub hx) v (hfr.value_mem hfv) hfv + exact ⟨q,by simpa only [genericFilterName,id_eq,encode_check,he] using hz.symm⟩ + +theorem genericFilterName_mem (M p : ZFSet.{u}) [Top (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hR : SigmaReplacement M) + (hI : Infinity M) (hp : p ∈ M) : genericFilterName p ∈ names M p := by + obtain ⟨d,hdM,hd,hpd⟩ := internal_transitive_container M hM hP hU hS hR hI hp + obtain ⟨q,hqM,hq⟩ := internal_power M hM hPow hdM + obtain ⟨f,hf,hfg⟩ := internal_checkGraph M d q (label p ⊤) hM hP hU hPow hS hR + hdM hqM (hM p hp _ (label_mem p ⊤)) hd hq p hpd + have hsub : p ⊆ hull d q p := fun x hx => + hull_transitive d q p hd p (self_mem_hull d q hpd) x hx + change (genericFilterName p).encode (label p) ∈ M + rw [encode_genericFilterName p _ _ f hsub hfg] + exact filterCode_mem M hM hP hU hPow hS hp hf + +theorem genericFilterSet_mem_extension (M p : ZFSet.{u}) [Top (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hR : SigmaReplacement M) + (hI : Infinity M) (hp : p ∈ M) (G : Set (Conditions p)) (hG : ⊤ ∈ G) : + genericFilterSet p G ∈ genericExtensionSet M p G := + (mem_extensionSet M p G _).mpr ⟨genericFilterName p, + genericFilterName_mem M p hM hP hU hPow hS hR hI hp,val_genericFilterName p G hG⟩ + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericIdentity.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..43fc2875863dc2d9b520425a92817f17c08fde3f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericIdentity.lean @@ -0,0 +1,105 @@ +import OAI.Computability.DegreeRigidity.SetModels.IdealSelection +import OAI.Computability.DegreeRigidity.Representation.GenericCodingBorel + +namespace OAI + +namespace TuringRigidity.GenericIdentity +open Set + +def PrincipalIntersection (U L R : Oracle) : Prop := + ∀ b : Degree, b ≤ degree U ↔ b ≤ degree L ∧ b ≤ degree R + +theorem principal_iff_countable (U L R : Oracle) : + PrincipalIntersection U L R ↔ Reduces U L ∧ Reduces U R ∧ + ∀ n, Reduces (programOutput (codeEnumeration n) L) L ∧ + Reduces (programOutput (codeEnumeration n) L) R → + Reduces (programOutput (codeEnumeration n) L) U := by + constructor + · intro h + have hh := (h (degree U)).mp le_rfl + exact ⟨hh.1,hh.2,fun n hn => (h (degree (programOutput (codeEnumeration n) L))).mpr hn⟩ + · rintro ⟨hL,hR,h⟩ b + obtain ⟨B,rfl⟩ := degree_surjective b + constructor + · intro hb + exact ⟨reduces_trans hb hL,reduces_trans hb hR⟩ + · rintro ⟨hbL,hbR⟩ + obtain ⟨n,hn⟩ := exists_programOutput L B hbL + have hh := h n (by simpa [hn] using And.intro hbL hbR) + simpa [hn] using hh + +theorem principal_measurable {X : Type*} [MeasurableSpace X] + (U L R : X → Oracle) (hU : Measurable U) (hL : Measurable L) (hR : Measurable R) : + MeasurableSet {x | PrincipalIntersection (U x) (L x) (R x)} := by + have hm : MeasurableSet {x | ∀ n, Reduces (programOutput (codeEnumeration n) (L x)) (L x) ∧ + Reduces (programOutput (codeEnumeration n) (L x)) (R x) → + Reduces (programOutput (codeEnumeration n) (L x)) (U x)} := by + simp only [Set.ofPred_forall] + apply MeasurableSet.iInter + intro n + let C : X → Oracle := fun x => programOutput (codeEnumeration n) (L x) + have hC : Measurable C := (programOutput_measurable _).comp hL + have he : {x | Reduces (C x) (L x) ∧ Reduces (C x) (R x) → Reduces (C x) (U x)} = + ({x | Reduces (C x) (L x)} ∩ {x | Reduces (C x) (R x)})ᶜ ∪ {x | Reduces (C x) (U x)} := by + ext x; simp only [mem_ofPred_eq,mem_union,mem_inter_iff,mem_compl_iff]; tauto + change MeasurableSet {x | Reduces (C x) (L x) ∧ Reduces (C x) (R x) → Reduces (C x) (U x)} + rw [he] + exact ((reduces_measurable C L hC hL).inter (reduces_measurable C R hC hR)).compl.union + (reduces_measurable C U hC hU) + convert (reduces_measurable U L hU hL).inter ((reduces_measurable U R hU hR).inter hm) using 1 + ext x + simp only [mem_inter_iff,mem_ofPred_eq,principal_iff_countable] + +noncomputable def value (p : OracleCode) (P A : Oracle) : Oracle := programOutput p (join A P) + +def Total (p : OracleCode) (P A : Oracle) : Prop := + ∃ B, OracleCode.eval (oracleFunction (join A P)) p = oracleFunction B + +theorem value_measurable (p : OracleCode) (P : Oracle) : Measurable (value p P) := + (programOutput_measurable p).comp (join_measurable _ _ measurable_id measurable_const) + +theorem total_iff (p : OracleCode) (P A : Oracle) : + Total p P A ↔ OracleCode.eval (oracleFunction (join A P)) p = oracleFunction (value p P A) := by + constructor + · rintro ⟨B,hB⟩ + rw [show value p P A = B from programOutput_eq p _ B hB] + exact hB + · intro h; exact ⟨_,h⟩ + +theorem total_measurable (p : OracleCode) (P : Oracle) : MeasurableSet {A | Total p P A} := by + simp only [total_iff] + exact OracleCode.success_measurable p _ _ + (join_measurable _ _ measurable_id measurable_const) (value_measurable p P) + +def SourceEquation (p : OracleCode) (P : Oracle) (z : Oracle × Oracle × Oracle) : Prop := + Total p P z.1 ∧ Total p P z.2.1 ∧ Total p P z.2.2 ∧ + Total p P (GenericCoding.code z.1 z.2.1) ∧ Total p P (GenericCoding.code z.1 z.2.2) ∧ + PrincipalIntersection (value p P z.1) + (join (value p P (GenericCoding.code z.1 z.2.1)) (value p P z.2.1)) + (join (value p P (GenericCoding.code z.1 z.2.2)) (value p P z.2.2)) + +theorem sourceEquation_measurable (p : OracleCode) (P : Oracle) : + MeasurableSet {z | SourceEquation p P z} := by + let X : (Oracle × Oracle × Oracle) → Oracle := fun z => z.1 + let G : (Oracle × Oracle × Oracle) → Oracle := fun z => z.2.1 + let H : (Oracle × Oracle × Oracle) → Oracle := fun z => z.2.2 + have hX : Measurable X := measurable_fst + have hG : Measurable G := measurable_fst.comp measurable_snd + have hH : Measurable H := measurable_snd.comp measurable_snd + have hCG : Measurable (fun z => GenericCoding.code (X z) (G z)) := + GenericCoding.code_measurable.comp (hX.prodMk hG) + have hCH : Measurable (fun z => GenericCoding.code (X z) (H z)) := + GenericCoding.code_measurable.comp (hX.prodMk hH) + have hF := value_measurable p P + have hI := principal_measurable _ _ _ (hF.comp hX) + (join_measurable _ _ (hF.comp hCG) (hF.comp hG)) + (join_measurable _ _ (hF.comp hCH) (hF.comp hH)) + exact ((total_measurable p P).preimage hX).inter + (((total_measurable p P).preimage hG).inter + (((total_measurable p P).preimage hH).inter + (((total_measurable p P).preimage hCG).inter + (((total_measurable p P).preimage hCH).inter hI)))) + +end TuringRigidity.GenericIdentity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericOneRealNames.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericOneRealNames.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4eb100e28cfd812fd2d7ba5ef8cfdc57500e008 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericOneRealNames.lean @@ -0,0 +1,65 @@ +import OAI.Computability.DegreeRigidity.Constructibility.PersistentOneRealDefinition +import OAI.Computability.DegreeRigidity.Syntax.SetSatisfactionBounded +import OAI.Computability.DegreeRigidity.Constructibility.PersistentExtensionName + +namespace OAI + +namespace TuringRigidity.FullSetForcing +open TransitiveNameModel BoundedSetTheory ElementaryModel SetDegreeDecoding +open PersistentRestrictions RecursiveNames CountableForcing AtomicForcing RelativeConstructible +universe u + +theorem persistent_extension_one_real_names + (M : ZFSet.{u}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) (htop : ⊤ ∈ G.carrier) + (I : CountableIdeal) (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (hIM : I.carrier ⊆ (modelIdeal M hM hT).carrier) : + let E := genericExtensionSet M c G.carrier + let hE := genericExtensionSet_transitive M c hM G.carrier + let hTE := extension_sourceT M hM hT hc hoM ho G hG htop + let J := modelIdeal E hE hTE + ∃ hIJ : I.carrier ⊆ J.carrier, ∃ σ : J ≃o J, + Extends hIJ ρ σ ∧ Persistent J σ ∧ + ∃ (δ : Ordinal.{u}) (P : Oracle) (p : SentenceForm), + δ.toZFSet ∈ E ∧ P ∈ modelReals E ∧ p.bound ≤ 2 ∧ + realCode P ∈ level (groundReals E) δ ∧ + automorphismSet σ = definedSubset (level (groundReals E) δ) p + (fun _ : Fin p.bound => realCode P) ∧ + ∃ r d a l f : Name (Conditions c), + r.encode (label c) ∈ M ∧ d.encode (label c) ∈ M ∧ + a.encode (label c) ∈ M ∧ l.encode (label c) ∈ M ∧ f.encode (label c) ∈ M ∧ + r.val G.carrier = groundReals E ∧ d.val G.carrier = δ.toZFSet ∧ + a.val G.carrier = realCode P ∧ l.val G.carrier = level (groundReals E) δ ∧ + f.val G.carrier = automorphismSet σ := by + intro E hE hTE J + have hME := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier htop + have hIJ : I.carrier ⊆ J.carrier := by + intro d hd + obtain ⟨A,hA,rfl⟩ := hIM hd + refine ⟨A,?_,rfl⟩ + change realCode A ∈ E + exact hME hA + obtain ⟨σ,he,hσ,δ,P,p,hδ,hP,hp,hPL,hdef⟩ := + persistent_extension_one_real_definition E hE hTE I ρ hρ hz hIJ + have hrE := groundReals_mem E hE hTE + have hlE := level_mem E _ hE hTE hrE δ hδ + have hfE : automorphismSet σ ∈ E := by + rw [hdef] + exact definedSubset_mem E _ hE hTE.separation.finitePrefix.bounded hlE p + (fun _ => realCode P) (fun _ => hPL) (by omega) + obtain ⟨r,hr,hvr⟩ := (mem_extensionSet M c G.carrier _).mp hrE + obtain ⟨d,hd,hvd⟩ := (mem_extensionSet M c G.carrier _).mp hδ + obtain ⟨a,ha,hva⟩ := (mem_extensionSet M c G.carrier (realCode P)).mp hP + obtain ⟨l,hl,hvl⟩ := (mem_extensionSet M c G.carrier _).mp hlE + obtain ⟨f,hf,hvf⟩ := (mem_extensionSet M c G.carrier _).mp hfE + exact ⟨hIJ,σ,he,hσ,δ,P,p,hδ,hP,hp,hPL,hdef,r,d,a,l,f, + hr,hd,ha,hl,hf,hvr,hvd,hva,hvl,hvf⟩ + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericPersistenceDescent.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericPersistenceDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..41c3c62be2413ddee56774562166eb075ed08bf8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericPersistenceDescent.lean @@ -0,0 +1,66 @@ +import OAI.Computability.DegreeRigidity.Representation.NativeGenericWitness +import OAI.Computability.DegreeRigidity.Constructibility.RelativePersistentDescent +import OAI.Computability.DegreeRigidity.Constructibility.FixedRelativeGround +import OAI.Computability.DegreeRigidity.Representation.CommonGenericModels + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel SetDegreeDecoding +open PersistentRestrictions ArithmeticTree CountableForcing +universe u + +theorem generically_persistent_ground_graph_descent (M N : ZFSet.{u}) + [Countable (Conditions M)] (hM : Transitive M) (hTM : SourceT M) + (hN : Transitive N) (hTN : SourceT N) (hMN : M ⊆ N) + (ρ : modelIdeal M hM hTM ≃o modelIdeal M hM hTM) + (hρN : automorphismSet ρ ∈ N) + (hgen : SetGenericallyPersistent N (modelIdeal M hM hTM) ρ) : + automorphismSet ρ ∈ relativeModel M (groundReals M) := by + have hI := relativeModel_subset M _ (ground_idealSet_mem_relativeModel M hM hTM) + have hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ (modelIdeal M hM hTM).carrier := + ⟨_,sourceT_real_jump M hM hTM (sourceT_zero_real M hM hTM),rfl⟩ + exact persistent_modelIdeal_graph_mem_relativeModel M hM hTM ρ + (hgen.persistent hN hTN (hMN hI) hρN hz) + +theorem generic_extension_graph_descent (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) {c o : ZFSet.{u}} + [Preorder (Conditions c)] [OrderTop (Conditions c)] + (hc : c ∈ M) (ho : o ∈ M) + (hos : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) + (hρG : automorphismSet ρ ∈ genericExtensionSet M c G.carrier) + (hgen : SetGenericallyPersistent (genericExtensionSet M c G.carrier) (modelIdeal M hM hT) ρ) : + automorphismSet ρ ∈ relativeModel M (groundReals M) ∧ + automorphismSet ρ ∈ M ∧ + relativeModel (genericExtensionSet M c G.carrier) (groundReals M) = + relativeModel M (groundReals M) := by + obtain ⟨p,hp⟩ := G.nonempty + have ht := G.upper le_top hp + have hME := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht + have hd := generically_persistent_ground_graph_descent M _ hM hT + (genericExtensionSet_transitive M c hM G.carrier) + (extension_sourceT M hM hT hc ho hos G hG ht) hME ρ hρG hgen + exact ⟨hd,relativeModel_subset M _ hd, + relativeModel_generic_fixed_parameter M hM hT (groundReals_mem M hM hT) hc ho hos G hG⟩ + +theorem generic_persistence_returns_to_ground (M N : ZFSet.{u}) + [Countable (Conditions M)] (hM : Transitive M) (hTM : SourceT M) + (hN : Transitive N) (hTN : SourceT N) (hMN : M ⊆ N) + (ρ : modelIdeal M hM hTM ≃o modelIdeal M hM hTM) + (hρN : automorphismSet ρ ∈ N) + (hgen : SetGenericallyPersistent N (modelIdeal M hM hTM) ρ) : + SetGenericallyPersistent M (modelIdeal M hM hTM) ρ := by + have hI := relativeModel_subset M _ (ground_idealSet_mem_relativeModel M hM hTM) + have hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ (modelIdeal M hM hTM).carrier := + ⟨_,sourceT_real_jump M hM hTM (sourceT_zero_real M hM hTM),rfl⟩ + have hρM := relativeModel_subset M _ + (generically_persistent_ground_graph_descent M N hM hTM hN hTN hMN ρ hρN hgen) + exact (setGenericallyPersistent_iff M hM hTM _ hI ρ hρM hz).mpr + (hgen.persistent hN hTN (hMN hI) hρN hz) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericRealColumnRealization.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericRealColumnRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..c44e152401a027d866208f907746a8154abff362 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericRealColumnRealization.lean @@ -0,0 +1,61 @@ +import OAI.Computability.DegreeRigidity.Effective.PrefixSingletonRealization +import OAI.Computability.DegreeRigidity.CohenForcing.CohenPartitionRealization +import OAI.Computability.DegreeRigidity.CohenForcing.CohenRemainderTransport +import OAI.Computability.DegreeRigidity.Representation.OriginalRealCohenFactorization +import OAI.Computability.DegreeRigidity.Representation.CommonExtensionProgram +import OAI.Computability.DegreeRigidity.SetModels.InternalShuffleGeneric + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing InternalCountableOrdinals +open CohenColumnRealName +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem generic_real_column_realizes (M K a : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) (ha : a ∈ K) + (G : GenericFilter (Conditions (poset K))) (hG : AtomicForcing.GroundGeneric M G) + (A : Oracle) (hAE : realCode A ∈ genericExtensionSet M (poset K) G.carrier) + (hA : AtomicForcing.GroundGeneric M (InternalCohen.pushFilter (CohenBorelForcing.realFilter A))) : + ColumnRealizesExtension M K a (genericExtensionSet M (poset K) G.carrier) A := by + obtain ⟨hN,L,hL,hLe⟩ := OriginalRealCohenFactorization.real_factorization M K hM hT hK + G hG (realCode A) hAE (realCode_subset A) + have haM := hM K hK.2.1 a ha + have hsingle := singleton_mem M hM hT.pairing haM + have hsK : ({a} : ZFSet.{0}) ⊆ K := by + intro x hx + exact ZFSet.mem_singleton.mp hx ▸ ha + obtain ⟨R,hR,hRe⟩ := CohenRemainderTransport.transport_to_remainder M _ K {a} + hM hT hN.1 hN.2.1 hN.2.2.1 hK hsingle hsK + (Or.inr (InternalCountableClosure.singleton_countable M a hM hT haM)) L hL + obtain ⟨J,hJ,hJe,hJA⟩ := PrefixSingletonRealization.singleton_realization M a hM hT haM A hA + have hRJ : AtomicForcing.GroundGeneric (genericExtensionSet M (poset {a}) J.carrier) R := by + rw [hJe] + exact hR + obtain ⟨U,hU,hUe,hUA⟩ := CohenPartitionRealization.reassemble_column M K a hM hT hK.2.1 ha A + J hJ hJA R hRJ + refine ⟨U,hU,hUe.trans ?_,hUA⟩ + rw [hJe] + exact hRe.trans hLe + +theorem shuffled_real_column_realizes (M K a : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) (ha : a ∈ K) + (G : GenericFilter (Conditions (poset K))) (hG : AtomicForcing.GroundGeneric M G) + (Y L : Oracle) + (hYE : realCode Y ∈ genericExtensionSet M (poset K) G.carrier) + (hLE : realCode L ∈ genericExtensionSet M (poset K) G.carrier) + (hL : AtomicForcing.GroundGeneric M (InternalCohen.pushFilter (CohenBorelForcing.realFilter L))) : + ColumnRealizesExtension M K a (genericExtensionSet M (poset K) G.carrier) (GenericCoding.code Y L) := by + obtain ⟨hE,hTE,_,_⟩ := RegularTreeExtension.extension_properties M (poset K) hM hT + (CohenGroundPoset.conditions_mem M _ hM hT + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + hK.2.1 (sourceT_omega_mem M hM hT))) G hG + have hcode := sourceT_real_lower _ hE hTE (sourceT_real_join _ hE hTE hYE hLE) + (GenericCoding.code_reduces Y L) + exact generic_real_column_realizes M K a hM hT hK ha G hG _ hcode + (InternalCohen.groundGeneric_shuffle M hM hT L hL Y) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericRepresentation.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericRepresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3c86c81faa01a56aa1457ae4262be8f0796d798 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericRepresentation.lean @@ -0,0 +1,75 @@ +import OAI.Computability.DegreeRigidity.Representation.PairGenericSelection +import OAI.Computability.DegreeRigidity.Representation.CommonIdealSelection +import OAI.Computability.DegreeRigidity.SetModels.ContinuousCode +import OAI.Computability.DegreeRigidity.Representation.RepresentationEndgame +import OAI.Computability.DegreeRigidity.Representation.CoverageMain + +namespace OAI + +namespace TuringRigidity +open FiniteShuffle ShuffleRequirements PairGenericSelection + +theorem selected_generic_ideal (D : ℕ → List Bool → Prop) (hd : ∀ n, DenseOpen (D n)) : + ∃ G : Bool → Oracle → Oracle, (∀ b, Measurable (G b)) ∧ + (∀ A b, GenericFor D (G b A) ∧ GenericCoding.InfiniteOdd (G b A) ∧ + ∀ Y, GenericFor D (GenericCoding.code Y (G b A))) ∧ + ∀ A a, a ≤ degree A ↔ a ≤ degree (join A (G false A)) ∧ a ≤ degree (join A (G true A)) := by + obtain ⟨Z,hZ,hgeneric,hfamily⟩ := borel_pair_selection D hd CommonIdeal.family + CommonIdeal.family_dense CommonIdeal.family_measurable + refine ⟨fun b A => column b (Z A),fun b => (column_measurable b).comp hZ,hgeneric,?_⟩ + intro A a + exact CommonIdeal.ideal_of_family A (Z A) (hfamily A) a + +def GenericContinuousRepresentation (π : Degree ≃o Degree) : Prop := + ∃ D : ℕ → List Bool → Prop, (∀ n, DenseOpen (D n)) ∧ + ∃ f : Oracle → Oracle, ContinuousOn f {A | GenericFor D A} ∧ + ∀ A, GenericFor D A → degree (f A) = π (degree A) + +theorem generic_continuous_of_subtype (π : Degree ≃o Degree) + (D : ℕ → List Bool → Prop) (hD : ∀ n, DenseOpen (D n)) + (f : {A : Oracle // GenericFor D A} → Oracle) (hf : Continuous f) + (hπ : ∀ A, degree (f A) = π (degree A.val)) : GenericContinuousRepresentation π := by + classical + let F : Oracle → Oracle := fun A => if hA : GenericFor D A then f ⟨A,hA⟩ else fun _ => false + have hF : ContinuousOn F {A | GenericFor D A} := by + apply continuousOn_iff_continuous_domRestrict.mpr + have he : (fun A : {A : Oracle // GenericFor D A} => F A.val) = f := by + funext A + simp [F,A.property] + change Continuous (fun A : {A : Oracle // GenericFor D A} => F A.val) + rw [he] + exact hf + refine ⟨D,hD,F,hF,?_⟩ + intro A hA + simpa [F,hA] using hπ ⟨A,hA⟩ + +def GenericProgramRepresentation (π : Degree ≃o Degree) : Prop := + ∃ D : ℕ → List Bool → Prop, (∀ n, DenseOpen (D n)) ∧ + ∃ P : Oracle, ∃ p : OracleCode, ∀ A, GenericFor D A → + ∃ B, OracleCode.eval (oracleFunction (join A P)) p = oracleFunction B ∧ degree B = π (degree A) + +theorem generic_program_of_continuous (π : Degree ≃o Degree) + (h : GenericContinuousRepresentation π) : GenericProgramRepresentation π := by + obtain ⟨D,hD,f,hf,hπ⟩ := h + obtain ⟨P,p,hp⟩ := ContinuousCode.continuous_uniform_program {A | GenericFor D A} f hf + exact ⟨D,hD,P,p,fun A hA => ⟨f A,hp A hA,hπ A hA⟩⟩ + +theorem borel_of_generic_program (π : Degree ≃o Degree) (h : GenericProgramRepresentation π) : + ∃ H : Oracle → Oracle, Measurable H ∧ ∀ A, degree (H A) = π (degree A) := by + obtain ⟨D,hD,P,p,hp⟩ := h + obtain ⟨G,hG,hgeneric,hideal⟩ := selected_generic_ideal D hD + exact representative_from_generic_program π p P G hG + (fun A b => (hgeneric A b).2.1) + (fun A b => hp (G b A) (hgeneric A b).1) + (fun A b => hp (GenericCoding.code A (G b A)) ((hgeneric A b).2.2 A)) hideal + +theorem borel_of_generic_continuous (π : Degree ≃o Degree) (h : GenericContinuousRepresentation π) : + ∃ H : Oracle → Oracle, Measurable H ∧ ∀ A, degree (H A) = π (degree A) := + borel_of_generic_program π (generic_program_of_continuous π h) + +theorem main_of_generic_continuous (h : ∀ π, GenericContinuousRepresentation π) : MainTheorem := + main_of_representation (fun π => borel_of_generic_continuous π (h π)) + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericSourceTransfer.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericSourceTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..cef9cd5b5e879ee1f584cb15b302728f7cdd516d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericSourceTransfer.lean @@ -0,0 +1,45 @@ +import OAI.Computability.DegreeRigidity.Representation.GenericTruth +import OAI.Computability.DegreeRigidity.Representation.GenericFiberIdeal +import OAI.Computability.DegreeRigidity.Representation.SourceIdentity + +namespace OAI + +namespace TuringRigidity.GenericSourceTransfer +open FiniteShuffle ShuffleRequirements PairGenericSelection GenericFactor GenericIdentity Set + +@[simp] theorem triple_join (Y Z : Oracle) : + GenericTruth.triple (join Y Z) = (Y,column false Z,column true Z) := by + have hl : column false (join Y Z) = Y := by funext n; simp [column] + have hr : column true (join Y Z) = Z := by funext n; simp [column] + simp [GenericTruth.triple,hl,hr] + +theorem selected_borel_truth (p : OracleCode) (P : Oracle) + (E : ℕ → List Bool → Prop) (hE : ∀ n, DenseOpen (E n)) : + ∃ U : Set Oracle, IsOpen U ∧ + ∃ F : ℕ → List Bool → Prop, (∀ n, DenseOpen (F n)) ∧ + ∃ Z : {Y : Oracle // GenericFor F Y} → Oracle, Measurable Z ∧ + (∀ Y b, GenericFor E (column b (Z Y)) ∧ GenericCoding.InfiniteOdd (column b (Z Y)) ∧ + ∀ X, GenericFor E (GenericCoding.code X (column b (Z Y)))) ∧ + (∀ Y a, a ≤ degree Y.val ↔ + a ≤ degree (join Y.val (column false (Z Y))) ∧ + a ≤ degree (join Y.val (column true (Z Y)))) ∧ + ∀ Y, SourceEquation p P (Y.val,column false (Z Y),column true (Z Y)) ↔ + join Y.val (Z Y) ∈ U := by + obtain ⟨U,hU,D,hD,htruth⟩ := GenericTruth.sourceEquation_generic_truth p P + obtain ⟨hF,Z,hZ,hjoint,hgen,hI⟩ := borel_joint_ideal_selection D E hD hE + refine ⟨U,hU,FirstFamily D,hF,Z,hZ,hgen,hI,?_⟩ + intro Y + simpa only [triple_join] using htruth (join Y.val (Z Y)) (hjoint Y) + +theorem recover_at (π : Degree ≃o Degree) (p : OracleCode) (P Y G0 G1 : Oracle) + (hG0 : RepresentsAt π p P G0) (hG1 : RepresentsAt π p P G1) + (hC0 : RepresentsAt π p P (GenericCoding.code Y G0)) + (hC1 : RepresentsAt π p P (GenericCoding.code Y G1)) + (hi0 : GenericCoding.InfiniteOdd G0) (hi1 : GenericCoding.InfiniteOdd G1) + (hI : PrincipalIntersection Y (join Y G0) (join Y G1)) + (he : SourceEquation p P (Y,G0,G1)) : RepresentsAt π p P Y := + (source_5_5_iff π p P Y G0 G1 hG0 hG1 hC0 hC1 hi0 hi1 hI).mp he + +end TuringRigidity.GenericSourceTransfer + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericTopology.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericTopology.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cdac0dbb844ca6b6e4161edc9e664193cb6880b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericTopology.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.SetModels.ShuffleRequirements + +namespace OAI + +namespace TuringRigidity.GenericTopology +open FiniteShuffle ShuffleRequirements GenericCoding Set + +theorem cylinder_basis (U : Set Oracle) (hu : IsOpen U) (G : Oracle) (hg : G ∈ U) : + ∃ n, ∀ H, Agree n G H → H ∈ U := by + classical + obtain ⟨I,u,huI,hsub⟩ := isOpen_pi_iff.mp hu G hg + refine ⟨I.sup id + 1,?_⟩ + intro H hH + apply hsub + intro i hi + have hl : i ≤ I.sup id := Finset.le_sup (f := id) hi + rw [←hH i (by omega)] + exact (huI i hi).2 + +theorem openSet_dense (D : List Bool → Prop) (hd : DenseOpen D) : Dense (OpenSet D) := by + apply dense_iff_inter_open.mpr + rintro U hu ⟨G,hG⟩ + obtain ⟨n,hn⟩ := cylinder_basis U hu G hG + obtain ⟨s,hs,hD⟩ := hd.1 (initial G n) + exact ⟨fun i => s.getD i false,hn _ (agree_of_prefix hs),s,hD,realizes_default s⟩ + +theorem requirements_topology (D : ℕ → List Bool → Prop) (hd : ∀ n, DenseOpen (D n)) (n : ℕ) : + Dense (OpenSet (Requirements D n)) ∧ IsOpen (OpenSet (Requirements D n)) ∧ + MeasurableSet (OpenSet (Requirements D n)) := + ⟨openSet_dense _ (requirements_denseOpen D hd n),openSet_isOpen _,openSet_measurable _⟩ + +def Combined {X : Type*} (D : ℕ → List Bool → Prop) (R : X → ℕ → ℕ → Prop) + (x : X) (n t : ℕ) : Prop := + if n % 2 = 0 then Requirements D (n/2) (BorelGeneric.word t) else R x (n/2) t + +theorem borel_selection_with_requirements {X : Type*} [MeasurableSpace X] + (D : ℕ → List Bool → Prop) (hd : ∀ n, DenseOpen (D n)) + (R : X → ℕ → ℕ → Prop) + (hRd : ∀ x n s, ∃ t, BorelGeneric.Ext s t ∧ R x n t) + (hRm : ∀ n t, MeasurableSet {x | R x n t}) : + ∃ G : X → Oracle, Measurable G ∧ ∀ x, + (GenericFor D (G x) ∧ InfiniteOdd (G x) ∧ ∀ A, GenericFor D (code A (G x))) ∧ + ∀ n, ∃ t, R x n t ∧ BorelGeneric.Meets (G x) t := by + have hc : ∀ x n s, ∃ t, BorelGeneric.Ext s t ∧ Combined D R x n t := by + intro x n s + unfold Combined + split + · exact coded_dense _ (requirements_denseOpen D hd _) s + · exact hRd x _ s + have hm : ∀ n t, MeasurableSet {x | Combined D R x n t} := by + intro n t + unfold Combined + split + · exact requirements_borel D _ _ + · exact hRm _ _ + obtain ⟨G,hG,hreq⟩ := BorelGeneric.borel_generic_selection (Combined D R) hc hm + refine ⟨G,hG,?_⟩ + intro x + constructor + · apply requirements_spec + intro n + obtain ⟨t,ht,hGt⟩ := hreq x (2*n) + exact ⟨BorelGeneric.word t,by simpa [Combined] using ht,(realizes_iff_meets _ _).mpr hGt⟩ + · intro n + obtain ⟨t,ht,hGt⟩ := hreq x (2*n+1) + exact ⟨t,by simpa [Combined,Nat.add_div] using ht,hGt⟩ + +end TuringRigidity.GenericTopology + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericTotality.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericTotality.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b3f01eae51d74a6e1eb08b05b1f26b04e7cd711 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericTotality.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.Effective.ProgramContinuity +import OAI.Computability.DegreeRigidity.Representation.GenericTruth + +namespace OAI + +namespace TuringRigidity.GenericIdentity +open Set FiniteShuffle ShuffleRequirements GenericTruth + +def BinaryHalts (p : OracleCode) (P A : Oracle) (n : ℕ) : Prop := + 0 ∈ OracleCode.eval (oracleFunction (join A P)) p n ∨ + 1 ∈ OracleCode.eval (oracleFunction (join A P)) p n + +theorem total_iff_binaryHalts (p : OracleCode) (P A : Oracle) : + Total p P A ↔ ∀ n, BinaryHalts p P A n := by + constructor + · rintro ⟨B,hB⟩ n + unfold BinaryHalts + rw [hB] + cases B n <;> simp [oracleFunction] + · intro h + apply (total_iff p P A).mpr + apply (OracleCode.eval_eq_oracle_iff p _ _).mpr + intro n + rcases h n with h0 | h1 + · have hv : value p P A n = false := by + have hn : ¬ 1 ∈ OracleCode.eval (oracleFunction (join A P)) p n := by + intro h1 + have he := Part.mem_unique h0 h1 + omega + simp [value,programOutput,hn] + simpa [hv] using h0 + · have hv : value p P A n = true := by + simp [value,programOutput,h1] + simpa [hv] using h1 + +theorem binaryHalts_isOpen (p : OracleCode) (P : Oracle) (n : ℕ) : + IsOpen {A | BinaryHalts p P A n} := by + have hO : Continuous (fun A : Oracle => join A P) := by + apply continuous_pi + intro i + dsimp only [join] + split + · exact continuous_const + · exact continuous_apply _ + exact ((OracleCode.halting_set_open p n 0).union + (OracleCode.halting_set_open p n 1)).preimage hO + +theorem generic_totality_of_dense (p : OracleCode) (P : Oracle) + (hd : Dense {A | Total p P A}) : + ∃ D : ℕ → List Bool → Prop, (∀ n, DenseOpen (D n)) ∧ + (∀ A, GenericFor D A → Total p P A) ∧ + ContinuousOn (value p P) {A | GenericFor D A} := by + let D := fun n => CylinderIn {A | BinaryHalts p P A n} + have hD : ∀ n, DenseOpen (D n) := by + intro n + apply cylinderIn_denseOpen _ (binaryHalts_isOpen p P n) + exact hd.mono (fun A hA => (total_iff_binaryHalts p P A).mp hA n) + have ht : ∀ A, GenericFor D A → Total p P A := by + intro A hA + apply (total_iff_binaryHalts p P A).mpr + intro n + obtain ⟨s,hs,hAs⟩ := hA n + exact hs A hAs + exact ⟨D,hD,ht,value_continuousOn p P _ ht⟩ + +end TuringRigidity.GenericIdentity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GenericTruth.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GenericTruth.lean new file mode 100644 index 0000000000000000000000000000000000000000..4eb0f68a71fb9e6f495b5e74753c2d07dfae2bf3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GenericTruth.lean @@ -0,0 +1,75 @@ +import OAI.Computability.DegreeRigidity.Representation.GenericTopology +import OAI.Computability.DegreeRigidity.Representation.GenericIdentity +import OAI.Computability.DegreeRigidity.Representation.PairGenericSelection +import Mathlib.Topology.Baire.BaireMeasurable + +namespace OAI + +namespace TuringRigidity.GenericTruth +open FiniteShuffle ShuffleRequirements GenericTopology Set Filter Encodable + +def CylinderIn (U : Set Oracle) (s : List Bool) : Prop := ∀ G, Realizes s G → G ∈ U + +theorem cylinderIn_denseOpen (U : Set Oracle) (ho : IsOpen U) (hd : Dense U) : + DenseOpen (CylinderIn U) := by + constructor + · intro s + obtain ⟨H,hs,hHU⟩ := hd.inter_open_nonempty {G | Realizes s G} (realizes_isOpen s) + ⟨fun i => s.getD i false,realizes_default s⟩ + obtain ⟨n,hn⟩ := cylinder_basis U ho H hHU + refine ⟨initial H (max n s.length),?_,?_⟩ + · rw [←prefix_default s] + simpa only [prefix_length] using initial_prefix (n := s.length) (m := max n s.length) (le_max_right _ _) hs + · intro G hG + exact hn G (((realizes_initial H G _).mp hG).mono (le_max_left _ _)) + · intro s t hst hs G hG + exact hs G (realizes_mono hst hG) + +theorem generic_subset_of_residual (S : Set Oracle) (hS : S ∈ residual Oracle) : + ∃ D : ℕ → List Bool → Prop, (∀ n, DenseOpen (D n)) ∧ + ∀ G, GenericFor D G → G ∈ S := by + classical + obtain ⟨T,hTo,hTd,hTc,hsub⟩ := mem_residual_iff.mp hS + let : Countable T := hTc.to_subtype + let : Encodable T := Encodable.ofCountable T + let V : ℕ → Set Oracle := fun n => ((decode (α := T) n).map Subtype.val).getD univ + have hV (n : ℕ) : IsOpen (V n) ∧ Dense (V n) := by + cases he : decode (α := T) n with + | none => simp [V,he] + | some t => simpa [V,he] using And.intro (hTo t.val t.property) (hTd t.val t.property) + refine ⟨fun n => CylinderIn (V n),fun n => cylinderIn_denseOpen _ (hV n).1 (hV n).2,?_⟩ + intro G hG + apply hsub + intro t ht + let k : T := ⟨t,ht⟩ + obtain ⟨s,hs,hGs⟩ := hG (encode k) + have hh := hs G hGs + simpa [V,k] using hh + +theorem borel_generic_truth (S : Set Oracle) (hS : MeasurableSet S) : + ∃ U : Set Oracle, IsOpen U ∧ ∃ D : ℕ → List Bool → Prop, + (∀ n, DenseOpen (D n)) ∧ ∀ G, GenericFor D G → (G ∈ S ↔ G ∈ U) := by + obtain ⟨U,hU,hSU⟩ := hS.residualEq_isOpen + obtain ⟨D,hD,hDS⟩ := generic_subset_of_residual {G | G ∈ S ↔ G ∈ U} + (Filter.eventuallyEqSet_iff.mp hSU) + exact ⟨U,hU,D,hD,hDS⟩ + +def triple (G : Oracle) : Oracle × Oracle × Oracle := + (PairGenericSelection.column false G, + PairGenericSelection.column false (PairGenericSelection.column true G), + PairGenericSelection.column true (PairGenericSelection.column true G)) + +theorem triple_measurable : Measurable triple := + (PairGenericSelection.column_measurable false).prodMk + (((PairGenericSelection.column_measurable false).comp (PairGenericSelection.column_measurable true)).prodMk + ((PairGenericSelection.column_measurable true).comp (PairGenericSelection.column_measurable true))) + +theorem sourceEquation_generic_truth (p : OracleCode) (P : Oracle) : + ∃ U : Set Oracle, IsOpen U ∧ ∃ D : ℕ → List Bool → Prop, + (∀ n, DenseOpen (D n)) ∧ ∀ G, GenericFor D G → + (GenericIdentity.SourceEquation p P (triple G) ↔ G ∈ U) := + borel_generic_truth _ ((GenericIdentity.sourceEquation_measurable p P).preimage triple_measurable) + +end TuringRigidity.GenericTruth + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GlobalArithmeticGenericProgram.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GlobalArithmeticGenericProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fd084c1f5325918c21812c113d09b3a4a44f16b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GlobalArithmeticGenericProgram.lean @@ -0,0 +1,49 @@ +import OAI.Computability.DegreeRigidity.Representation.PrescribedArithmeticGenericProgram +import OAI.Computability.DegreeRigidity.Representation.PrescribedFirstUncountable +import OAI.Computability.DegreeRigidity.CohenForcing.CohenGroundGeneric + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing ElementaryModel PersistentRestrictions +open GenericIdentity OracleJump CohenColumnRealName +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem global_arithmetic_generic_program (π : Degree ≃o Degree) : + ∃ (R : Oracle) (p : OracleCode), + degree R = π.symm (degree (jump FixedArithmetic.zero)) ∧ + ∀ Y : Oracle, ArithmeticPrefixForcing.Generic (fun _ => iterate R 5) Y → + RepresentsAt π p (iterate R 5) Y := by + classical + by_contra hnone + push Not at hnone + let d := π.symm (degree (jump FixedArithmetic.zero)) + let C := {R : Oracle // degree R = d} × OracleCode + let : Countable {R : Oracle // degree R = d} := (countable_degree_fiber d).to_subtype + obtain ⟨R₀,hR₀⟩ := degree_surjective d + let : Nonempty C := ⟨(⟨R₀,hR₀⟩,OracleCode.zero)⟩ + have hw : ∀ c : C, ∃ Y : Oracle, + ArithmeticPrefixForcing.Generic (fun _ => iterate c.1.val 5) Y ∧ + ¬ RepresentsAt π c.2 (iterate c.1.val 5) Y := by + intro c + exact hnone c.1.val c.2 c.1.property + choose W hWg hWbad using hw + obtain ⟨e,he⟩ := exists_surjective_nat C + obtain ⟨M,hM,hT,hcount,_,⟨K,hK⟩,hWM,himages,ρ,hρ,_,_,_⟩ := + PrescribedFirstUncountable.prescribed_covering_model_with_omega_one π (fun n => W (e n)) + let := hcount + have hA := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + hK.2.1 (sourceT_omega_mem M hM hT) + obtain ⟨G,_,hG,hME,_,_,_⟩ := CohenGroundGeneric.exists_extension M (ZFSet.prod K ZFSet.omega) + hM hT hA ⊤ + obtain ⟨R,p,_,hR,_,_,hrep,_⟩ := + prescribed_arithmetic_generic_program π M K hM hT hK himages ρ hρ G hG + let c : C := (⟨R,hR⟩,p) + obtain ⟨n,hn⟩ := he c + have hW : W c ∈ modelReals M := by simpa only [hn] using hWM n + exact hWbad c (hrep (W c) (hME hW) (hWg c)) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GlobalJumpRestriction.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GlobalJumpRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d951d0eef7cd03f32e6299fe38f29e4d4b51972 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GlobalJumpRestriction.lean @@ -0,0 +1,36 @@ +import OAI.Computability.DegreeRigidity.Constructibility.PersistentLocality + +namespace OAI + + +namespace TuringRigidity.PersistentLocality +open IdealInterpretation IdealLocality PersistentRestrictions OracleJump + +def fullIdeal : DegreeIdeal := + ⟨Set.univ,⟨⊥,Set.mem_univ _⟩,fun _ _ => Set.mem_univ _,fun _ _ => Set.mem_univ _⟩ + +def fullEquiv : Degree ≃o fullIdeal where + toFun a := ⟨a,Set.mem_univ _⟩ + invFun a := a.val + left_inv _ := rfl + right_inv _ := rfl + map_rel_iff' := Iff.rfl + +theorem global_jump_restriction (π : Degree ≃o Degree) (J : CountableIdeal) + (hjump : JumpClosed (ideal J)) + (himages : π (degree (jump FixedArithmetic.zero)) ⊔ + π.symm (degree (jump FixedArithmetic.zero)) ∈ J.carrier) : + ∃ ρ : J ≃o J, RestrictsTo π J ρ ∧ Persistent J ρ := by + let τ : fullIdeal ≃o fullIdeal := fullEquiv.symm.trans (π.trans fullEquiv) + let z : fullIdeal := fullEquiv (degree (jump FixedArithmetic.zero)) + obtain ⟨σ,hσ⟩ := source_4_1_4 τ z rfl + (J := ideal J) (fun _ _ => Set.mem_univ _) hjump himages + let ρ := unlift σ + have hρ : RestrictsTo π J ρ := by + intro x + exact (hσ ⟨x.val,x.property⟩).symm + exact ⟨ρ,hρ,persistent_of_global_restriction π J ρ hρ⟩ + +end TuringRigidity.PersistentLocality + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GlobalLocality.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GlobalLocality.lean new file mode 100644 index 0000000000000000000000000000000000000000..297b9fa1a9d87776d89c2ac7ef78af1aa43b530b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GlobalLocality.lean @@ -0,0 +1,47 @@ +import OAI.Computability.DegreeRigidity.SetModels.IdealLocality + +namespace OAI + +namespace TuringRigidity.GlobalLocality +open OracleJump IdealInterpretation IdealLocality +noncomputable section + +def fullIdeal : DegreeIdeal := + ⟨Set.univ,⟨⊥,Set.mem_univ _⟩,fun {_ _} _ _ => Set.mem_univ _,fun {_ _} _ _ => Set.mem_univ _⟩ + +def lift (π : Degree ≃o Degree) : fullIdeal ≃o fullIdeal := + { toEquiv := + { toFun := fun x => ⟨π x.val,Set.mem_univ _⟩ + invFun := fun x => ⟨π.symm x.val,Set.mem_univ _⟩ + left_inv := fun x => Element.ext _ _ (π.symm_apply_apply x.val) + right_inv := fun x => Element.ext _ _ (π.apply_symm_apply x.val) } + map_rel_iff' := by intro a b; exact π.le_iff_le } + +def degreeIterate (x : Degree) : ℕ → Degree + | 0 => x + | n+1 => degreeJump (degreeIterate x n) + +@[simp] theorem degreeIterate_degree (X : Oracle) (n : ℕ) : + degreeIterate (degree X) n = degree (iterate X n) := by + induction n with + | zero => rfl + | succ n ih => simp only [degreeIterate,ih,degreeJump_degree]; rfl + +theorem arithmetic_bound (π : Degree ≃o Degree) (x : Degree) : + π x ≤ degreeIterate (x ⊔ π.symm (degree (jump FixedArithmetic.zero))) 5 := by + let z : fullIdeal := ⟨degree (jump FixedArithmetic.zero),Set.mem_univ _⟩ + let y : fullIdeal := ⟨x,Set.mem_univ _⟩ + obtain ⟨X,Y,hX,hY,hXY⟩ := image_arithmetic (lift π) z rfl y + change degree X = π x at hX + change degree Y = x ⊔ π.symm (degree (jump FixedArithmetic.zero)) at hY + rw [← hX,← hY,degreeIterate_degree] + exact hXY + +theorem source_3_3_1 (π : Degree ≃o Degree) (x : Degree) + (hx : π.symm (degree (jump FixedArithmetic.zero)) ≤ x) : π x ≤ degreeIterate x 5 := by + simpa only [sup_eq_left.mpr hx] using arithmetic_bound π x + +end +end TuringRigidity.GlobalLocality + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GroundArithmeticGeneric.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GroundArithmeticGeneric.lean new file mode 100644 index 0000000000000000000000000000000000000000..556831f5a54e6d9f000dc1ca4d8bf7d47fa7cab7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GroundArithmeticGeneric.lean @@ -0,0 +1,33 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticPrefixForcing +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericalCohenSets +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenFilters + +namespace OAI + + +namespace TuringRigidity.GroundArithmeticGeneric +open TransitiveNameModel BoundedSetTheory UniformArithmetic ArithmeticPrefixForcing +open InternalCohen CohenBorelForcing CountableForcing +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem ground_arithmetic (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (O : Oracles) (hO : ∀ i, realCode (O i) ∈ M) (G : Oracle) + (hG : AtomicForcing.GroundGeneric M (pushFilter (realFilter G))) : + Generic O G := by + intro D hD hd + let A := arithmeticReal (fun O n => D O (EncodedForcing.word n)) O + have hA : realCode A ∈ M := sourceT_arithmetic_comprehension M hM hT hD O hO + have hspec (s : List Bool) : wordCode s ∈ wordImage A ↔ D O s := + wordImage_spec (D O) A (arithmeticReal_true _ O) s + have hden : Dense {q : Condition | wordCode q.word ∈ wordImage A} := by + intro q + obtain ⟨s,hqs,hs⟩ := hd.1 q.word + exact ⟨⟨s⟩,hqs,(hspec s).mpr hs⟩ + obtain ⟨q,hq,hqD⟩ := (groundGeneric_iff M _).mp hG (wordImage A) + (wordImage_mem M hM hT A hA) hden + rw [pull_push] at hq + exact ⟨q.word,(hspec q.word).mp hqD,hq⟩ + +end TuringRigidity.GroundArithmeticGeneric + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GroundDegreeCollapse.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GroundDegreeCollapse.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3f7847cc8c48627a9ed7f2fb73358ad69b439c3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GroundDegreeCollapse.lean @@ -0,0 +1,62 @@ +import OAI.Computability.DegreeRigidity.Representation.GroundDegreePresentation +import OAI.Computability.DegreeRigidity.Representation.GlobalJumpRestriction +import OAI.Computability.DegreeRigidity.Computability.ArithmeticPersistenceDegreeModel + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel PersistentRestrictions PersistentPresentation PersistentCountability OracleJump +open CountableForcing +universe u +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem ground_degree_persistent_collapse (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) (π : Degree ≃o Degree) + (X Y : Oracle) (hX : X ∈ modelReals M) (hY : Y ∈ modelReals M) + (hx : degree X = π (degree (jump FixedArithmetic.zero))) + (hy : degree Y = π.symm (degree (jump FixedArithmetic.zero))) : + ∃ c ∈ M, ∃ G : GenericFilter (Conditions c), AtomicForcing.GroundGeneric M G ∧ + let N := genericExtensionSet M c G.carrier + M ⊆ N ∧ Transitive N ∧ SourceT N ∧ + ∃ I : CountableIdeal, ∃ H ∈ modelReals N, ∃ hH : Presented I H, + (∀ a : Degree, a ∈ I.carrier ↔ ∃ A ∈ modelReals M, degree A = a) ∧ + ∃ ρ : I ≃o I, RestrictsTo π I ρ ∧ Persistent I ρ ∧ + graphOracle hH ρ ∈ modelReals N ∧ + ∃ S ∈ N, degreeUniverse S ∈ N ∧ degreeOrder S ∈ N ∧ + presentationGraph S H (graphOracle hH ρ) ∈ N ∧ + (LevySigma.persistent 0 1 2 3 4).Realize N + (modelDegreeEnv S (presentationSet S H) (presentationGraph S H (graphOracle hH ρ))) := by + classical + obtain ⟨S,hSM,hS,hSd⟩ := internal_real_power M hM hT + have hd : ∀ x ∈ S, ∃ A : Oracle, realCode A = x := by + intro x hx; obtain ⟨A,_,hA⟩ := hSd x hx; exact ⟨A,hA⟩ + have hU := internal_degreeUniverse M hM hT S hSM hd + have hne : ∃ D, D ∈ degreeUniverse S := + ⟨degreeCode S FixedArithmetic.zero,(mem_degreeUniverse S _).mpr + ⟨FixedArithmetic.zero,(hS _).mpr (sourceT_zero_real M hM hT),rfl⟩⟩ + obtain ⟨c,hcM,_,_,G,hG,hMN,hN,hTN,hcount⟩ := + InternalCollapse.exists_internal_counting_extension M hM hT hU hne + let N := genericExtensionSet M c G.carrier + obtain ⟨I,H,hHN,hH,_,_,hI,hz,hjump⟩ := + ground_degree_presentation M N hM hN hT hTN S hS hd (hMN hU) hcount + have himages : π (degree (jump FixedArithmetic.zero)) ⊔ + π.symm (degree (jump FixedArithmetic.zero)) ∈ I.carrier := + I.join_mem ((hI _).mpr ⟨X,hX,hx⟩) ((hI _).mpr ⟨Y,hY,hy⟩) + obtain ⟨ρ,hρ,hp⟩ := PersistentLocality.global_jump_restriction π I hjump himages + have hRN := sourceT_persistent_graph_real N hN hTN hH hHN ρ hp hz + obtain ⟨T,hTNmem,hTr,hTd⟩ := internal_real_power N hN hTN + have htd : ∀ x ∈ T, ∃ A : Oracle, realCode A = x := by + intro x hx; obtain ⟨A,_,hA⟩ := hTd x hx; exact ⟨A,hA⟩ + have hcol : ∀ n, realCode (EncodedForcing.columns H n) ∈ T := + fun n => (hTr _).mpr (sourceT_real_column N hN hTN hHN n) + have hr : ∀ v, graphOracle hH ρ v = true ↔ Graph ρ hH v := by intro v; simp [graphOracle] + have hg := sourceT_arbitrary_persistent_graph N hN hTN T hTNmem hTr htd hH hHN ρ hp hz + (presentationGraph T H (graphOracle hH ρ)) (fun _ h => (ZFSet.mem_sep.mp h).1) + (presentationGraph_actual T hH hcol ρ hr) + exact ⟨c,hcM,G,hG,hMN,hN,hTN,I,H,hHN,hH,hI,ρ,hρ,hp,hRN,T,hTNmem, + internal_degreeUniverse N hN hTN T hTNmem htd,internal_degreeOrder N hN hTN T hTNmem htd,hg⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GroundDegreePresentation.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GroundDegreePresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..50172761f315076986423844df311da0aa07f77d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GroundDegreePresentation.lean @@ -0,0 +1,81 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCollapseExistence +import OAI.Computability.DegreeRigidity.SetModels.ModelIdealInterpretation + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel EncodedForcing PersistentRestrictions PersistentPresentation OracleJump +universe u + +theorem sourceT_zero_real (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + FixedArithmetic.zero ∈ modelReals M := by + have he : realCode.{u} FixedArithmetic.zero = ∅ := by + apply ZFSet.ext; intro x + constructor + · intro hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp (realCode_subset _ hx) + have hn := (natSet_mem_realCode FixedArithmetic.zero n).mp hx + exact Bool.noConfusion hn + · exact fun hx => False.elim (ZFSet.notMem_empty _ hx) + change realCode FixedArithmetic.zero ∈ M + rw [he] + exact hM _ (sourceT_omega_mem M hM hT) _ ZFSet.omega_zero + +theorem degreeCode_in_universe_real (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (S : ZFSet.{u}) (hS : ∀ A : Oracle, realCode A ∈ S ↔ A ∈ modelReals M) + (A : Oracle) (hA : degreeCode S A ∈ degreeUniverse S) : A ∈ modelReals M := by + obtain ⟨B,hB,_⟩ := degreeUniverse_nonempty_member S (degreeCode S A) hA + obtain ⟨hBS,hBA⟩ := (realCode_mem_degreeCode S A B).mp hB + have hAB : degree A ≤ degree B := le_of_eq hBA.symm + exact sourceT_real_lower M hM hT ((hS B).mp hBS) hAB + +theorem ground_degree_presentation (M N : ZFSet.{u}) + (hM : Transitive M) (hN : Transitive N) (hTM : SourceT M) (hTN : SourceT N) + (S : ZFSet.{u}) (hS : ∀ A : Oracle, realCode A ∈ S ↔ A ∈ modelReals M) + (hSd : ∀ x ∈ S, ∃ A : Oracle, realCode A = x) + (hUN : degreeUniverse S ∈ N) (hcount : InternallyCountable N (degreeUniverse S)) : + ∃ I : CountableIdeal, ∃ H ∈ modelReals N, Presented I H ∧ + presentationSet S H = degreeUniverse S ∧ + (∀ n, columns H n ∈ modelReals M) ∧ + (∀ a : Degree, a ∈ I.carrier ↔ ∃ A ∈ modelReals M, degree A = a) ∧ + degree (jump FixedArithmetic.zero) ∈ I.carrier ∧ + IdealLocality.JumpClosed (PersistentLocality.ideal I) := by + obtain ⟨H,hHN,hHU⟩ := internal_countable_degree_presentation N hN hTN S hSd hUN (fun _ h => h) hcount + have hcol (n : ℕ) : columns H n ∈ modelReals M := + degreeCode_in_universe_real M hM hTM S hS (columns H n) + (hHU ▸ (mem_presentationSet S H _).mpr ⟨n,rfl⟩) + have hc : ∀ n, realCode (columns H n) ∈ S := fun n => (hS _).mpr (hcol n) + let C : Set Degree := Set.range (fun n => degree (columns H n)) + have hmem (A : Oracle) : degree A ∈ C ↔ A ∈ modelReals M := by + constructor + · rintro ⟨n,hn⟩ + exact sourceT_real_lower M hM hTM (hcol n) (le_of_eq hn.symm) + · intro hAM + have hAU : degreeCode S A ∈ degreeUniverse S := (mem_degreeUniverse S _).mpr ⟨A,(hS A).mpr hAM,rfl⟩ + exact (degreeCode_mem_presentationSet S H hc A).mp (hHU.symm ▸ hAU) + have hlower : ∀ {a b : Degree}, a ≤ b → b ∈ C → a ∈ C := by + intro a b hab hb + obtain ⟨A,rfl⟩ := degree_surjective a + obtain ⟨B,rfl⟩ := degree_surjective b + exact (hmem A).mpr (sourceT_real_lower M hM hTM ((hmem B).mp hb) hab) + have hjoin : ∀ {a b : Degree}, a ∈ C → b ∈ C → a ⊔ b ∈ C := by + intro a b ha hb + obtain ⟨A,rfl⟩ := degree_surjective a + obtain ⟨B,rfl⟩ := degree_surjective b + exact (hmem (TuringRigidity.join A B)).mpr + (sourceT_real_join M hM hTM ((hmem A).mp ha) ((hmem B).mp hb)) + let I : CountableIdeal := ⟨C,⟨degree (columns H 0),0,rfl⟩,Set.countable_range _,@hlower,@hjoin⟩ + refine ⟨I,H,hHN,fun _ => Iff.rfl,hHU,hcol,?_,?_,?_⟩ + · intro a + obtain ⟨A,rfl⟩ := degree_surjective a + exact ⟨fun h => ⟨A,(hmem A).mp h,rfl⟩, + fun ⟨B,hB,he⟩ => he ▸ (hmem B).mpr hB⟩ + · exact (hmem _).mpr (sourceT_real_jump M hM hTM (sourceT_zero_real M hM hTM)) + · intro a ha + obtain ⟨A,rfl⟩ := degree_surjective a + exact (hmem _).mpr (sourceT_real_jump M hM hTM ((hmem A).mp ha)) + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GroundGenericRequirements.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GroundGenericRequirements.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea74278c8b2bd6aa540d418d935c3d0f85ade0dc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GroundGenericRequirements.lean @@ -0,0 +1,46 @@ +import OAI.Computability.DegreeRigidity.Representation.CountableGroundGeneric + +namespace OAI + + +namespace TuringRigidity.AtomicForcing +open TransitiveNameModel CountableForcing +universe u + +theorem ground_generic_with_requirements (N : ZFSet.{u}) [Countable (Conditions N)] + (hne : ∃ x, x ∈ N) {c : ZFSet.{u}} [Preorder (Conditions c)] + (E : ℕ → Set (Conditions c)) (hE : ∀ n, Dense (E n)) (p : Conditions c) : + ∃ G : GenericFilter (Conditions c), p ∈ G.carrier ∧ GroundGeneric N G ∧ GenericFor E G := by + classical + obtain ⟨x,hx⟩ := hne + obtain ⟨m,_⟩ := label_surjective N hx + let _ : Nonempty (Conditions N) := ⟨m⟩ + obtain ⟨e,he⟩ := exists_surjective_nat (Conditions N) + let D : ℕ → Set (Conditions c) := fun n => + if Dense {q : Conditions c | label c q ∈ label N (e n)} then + {q | label c q ∈ label N (e n)} else Set.univ + have hD : ∀ n, Dense (D n) := by + intro n + dsimp only [D] + split + · assumption + · exact fun q => ⟨q,le_rfl,Set.mem_univ _⟩ + let F : ℕ → Set (Conditions c) := fun n => if n % 2 = 0 then D (n/2) else E (n/2) + have hF : ∀ n, Dense (F n) := by + intro n; dsimp only [F]; split; exact hD _; exact hE _ + obtain ⟨G,hp,hG⟩ := exists_generic F hF p + have hGD : GenericFor D G := by + intro n; simpa [F] using hG (2*n) + have hGE : GenericFor E G := by + intro n; simpa [F,Nat.add_div] using hG (2*n+1) + refine ⟨G,hp,?_,hGE⟩ + intro A hA hd + obtain ⟨m,hm⟩ := label_surjective N hA + obtain ⟨n,rfl⟩ := he m + have hd' : Dense {q : Conditions c | label c q ∈ label N (e n)} := by rw [hm]; exact hd + obtain ⟨q,hq,hqn⟩ := hGD n + exact ⟨q,hq,by simpa only [D,ite_eq_left hd',Set.mem_ofPred_eq,hm] using hqn⟩ + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GroundInclusion.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GroundInclusion.lean new file mode 100644 index 0000000000000000000000000000000000000000..9add7875a9c41c51715aff0fdd4b4b301c400c71 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GroundInclusion.lean @@ -0,0 +1,78 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalContainer +import OAI.Computability.DegreeRigidity.SetModels.InternalCheckRecursion + +namespace OAI + +namespace TuringRigidity.TransitiveNameModel +open RecursiveNames BoundedSetTheory CountableForcing +universe u + +theorem encoded_check_mem (M p : ZFSet.{u}) [Top (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hR : SigmaReplacement M) + (hI : Infinity M) (hp : p ∈ M) {x : ZFSet.{u}} (hx : x ∈ M) : + (Name.check x).encode (label p) ∈ M := by + obtain ⟨d,hdM,hd,hxd⟩ := internal_transitive_container M hM hP hU hS hR hI hx + exact encoded_check_mem_of_container M p d hM hP hU hPow hS hR hp hdM hd hxd + +theorem ground_inclusion (M p : ZFSet.{u}) [Top (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hR : SigmaReplacement M) + (hI : Infinity M) (hp : p ∈ M) (G : Set (Conditions p)) (hG : ⊤ ∈ G) : + (M : Set ZFSet.{u}) ⊆ genericExtension M p G := + ground_subset M p (fun _ hx => encoded_check_mem M p hM hP hU hPow hS hR hI hp hx) G hG + +theorem ground_inclusion_set (M p : ZFSet.{u}) [Top (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hR : SigmaReplacement M) + (hI : Infinity M) (hp : p ∈ M) (G : Set (Conditions p)) (hG : ⊤ ∈ G) : + M ⊆ genericExtensionSet M p G := by + intro x hx + have hx' := ground_inclusion M p hM hP hU hPow hS hR hI hp G hG hx + rw [←genericExtensionSet_coe] at hx' + exact hx' + +theorem infinity_of_omega (M : ZFSet.{u}) (hM : Transitive M) + (hω : ZFSet.omega.{u} ∈ M) : Infinity M := by + refine ⟨ZFSet.omega,hω,⟨∅,hM _ hω _ ZFSet.omega_zero,ZFSet.omega_zero, + fun z _ => ZFSet.notMem_empty z⟩,?_⟩ + intro x _ hx + have hs := ZFSet.omega_succ hx + exact ⟨insert x x,hM _ hω _ hs,hs,fun z _ => ZFSet.mem_insert_iff⟩ + +theorem extension_infinity (M p : ZFSet.{u}) [Top (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hR : SigmaReplacement M) + (hI : Infinity M) (hp : p ∈ M) (G : Set (Conditions p)) (hG : ⊤ ∈ G) : + Infinity (genericExtensionSet M p G) := + infinity_of_omega _ (genericExtensionSet_transitive M p hM G) + (ground_inclusion_set M p hM hP hU hPow hS hR hI hp G hG (omega_mem M hM hS hI)) + +theorem ground_bounded_absolute (M p : ZFSet.{u}) [Top (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hR : SigmaReplacement M) + (hI : Infinity M) (hp : p ∈ M) (G : Set (Conditions p)) (hG : ⊤ ∈ G) + (φ : Formula) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + φ.Realize M e ↔ φ.Realize (genericExtensionSet M p G) e := + (φ.absolute M hM e he).trans + (φ.absolute _ (genericExtensionSet_transitive M p hM G) e + (fun i => ground_inclusion_set M p hM hP hU hPow hS hR hI hp G hG (he i))).symm + +theorem extension_six_axioms (M p r : ZFSet.{u}) + [Preorder (Conditions p)] [Top (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hR : SigmaReplacement M) + (hI : Infinity M) (hp : p ∈ M) (hrM : r ∈ M) + (hr : ∀ q s : Conditions p, ZFSet.pair (label p q) (label p s) ∈ r ↔ q ≤ s) + (G : GenericFilter (Conditions p)) (hG : ⊤ ∈ G.carrier) : + let E := genericExtensionSet M p G.carrier + M ⊆ E ∧ BasicAxioms.Extensionality E ∧ BasicAxioms.EmptySet E ∧ Pairing E ∧ + BoundedSetTheory.Union E ∧ BasicAxioms.Foundation E ∧ Infinity E := by + have hne : M ≠ ∅ := by intro he; exact ZFSet.notMem_empty p (he ▸ hp) + obtain ⟨he,hem,hp',hu,hf⟩ := extension_five_axioms M p r hM hne hP hU hPow hS hp hrM hr G hG + exact ⟨ground_inclusion_set M p hM hP hU hPow hS hR hI hp G.carrier hG,he,hem,hp',hu,hf, + extension_infinity M p hM hP hU hPow hS hR hI hp G.carrier hG⟩ + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GroundIteratedTriple.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GroundIteratedTriple.lean new file mode 100644 index 0000000000000000000000000000000000000000..a91eea4a2d4f99d297b50d05fdba85133b06b16b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GroundIteratedTriple.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticIteratedJoin +import OAI.Computability.DegreeRigidity.Representation.GroundArithmeticGeneric +import OAI.Computability.DegreeRigidity.CohenForcing.CohenPrefixHull +import OAI.Computability.DegreeRigidity.Representation.GenericSourceTransfer + +namespace OAI + + +namespace TuringRigidity.GroundIteratedTriple +open TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open InternalCohen CohenBorelForcing UniformArithmetic +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem generic_triple_of_arithmetic (M : ZFSet.{0}) + (O : Oracles) (hO : ∀ i, realCode (O i) ∈ M) + (Y L R : Oracle) (hY : ArithmeticPrefixForcing.Generic O Y) + (hN : RealGeneratedModel.Contains M (realCode Y) (RealGeneratedModel.hull M (realCode Y))) + (hL : GroundGeneric (RealGeneratedModel.hull M (realCode Y)) (pushFilter (realFilter L))) + (hR : GroundGeneric (genericExtensionSet (RealGeneratedModel.hull M (realCode Y)) conditions + (pushFilter (realFilter L)).carrier) (pushFilter (realFilter R))) : + ArithmeticPrefixForcing.Generic O (join Y (join L R)) := by + let N := RealGeneratedModel.hull M (realCode Y) + let OY : Oracles := fun i => if i = 0 then Y else O (i - 1) + have hOY : ∀ i, realCode (OY i) ∈ N := by + intro i + dsimp only [OY] + split + · exact hN.2.2.2 + · exact hN.2.2.1 (hO _) + obtain ⟨hF,hTF,hNF,_⟩ := RegularTreeExtension.extension_properties N conditions hN.1 hN.2.1 + (conditions_mem N hN.1 hN.2.1) (pushFilter (realFilter L)) hL + have hLF : realCode L ∈ genericExtensionSet N conditions (pushFilter (realFilter L)).carrier := + (mem_extensionSet _ _ _ _).mpr ⟨realName,realName_internal N hN.1 hN.2.1,val_realName L⟩ + have hOL : ∀ i, realCode ((fun i => if i = 0 then L else OY (i - 1)) i) ∈ + genericExtensionSet N conditions (pushFilter (realFilter L)).carrier := by + intro i + dsimp only + split + · exact hLF + · exact hNF (hOY _) + have hLa := GroundArithmeticGeneric.ground_arithmetic N hN.1 hN.2.1 OY hOY L hL + have hRa := GroundArithmeticGeneric.ground_arithmetic _ hF hTF _ hOL R hR + exact ArithmeticIteratedJoin.generic_join O Y (join L R) hY + (ArithmeticIteratedJoin.generic_join OY L R hLa hRa) + +theorem generic_triple (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (O : Oracles) (hO : ∀ i, realCode (O i) ∈ M) + (Y L R : Oracle) (hY : GroundGeneric M (pushFilter (realFilter Y))) + (hN : RealGeneratedModel.Contains M (realCode Y) (RealGeneratedModel.hull M (realCode Y))) + (hL : GroundGeneric (RealGeneratedModel.hull M (realCode Y)) (pushFilter (realFilter L))) + (hR : GroundGeneric (genericExtensionSet (RealGeneratedModel.hull M (realCode Y)) conditions + (pushFilter (realFilter L)).carrier) (pushFilter (realFilter R))) : + ArithmeticPrefixForcing.Generic O (join Y (join L R)) := + generic_triple_of_arithmetic M O hO Y L R + (GroundArithmeticGeneric.ground_arithmetic M hM hT O hO Y hY) hN hL hR + +theorem triple_join (Y L R : Oracle) : GenericTruth.triple (join Y (join L R)) = (Y,L,R) := by + rw [GenericSourceTransfer.triple_join] + have hl : PairGenericSelection.column false (join L R) = L := by + funext n; simp [PairGenericSelection.column] + have hr : PairGenericSelection.column true (join L R) = R := by + funext n; simp [PairGenericSelection.column] + rw [hl,hr] + +end TuringRigidity.GroundIteratedTriple + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GroundPrefixOverwrite.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GroundPrefixOverwrite.lean new file mode 100644 index 0000000000000000000000000000000000000000..aaed3cebc44369be99931baa639581731d091598 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GroundPrefixOverwrite.lean @@ -0,0 +1,32 @@ +import OAI.Computability.DegreeRigidity.Effective.PrefixSingletonRealization +import OAI.Computability.DegreeRigidity.CohenForcing.CohenPrefixOverwrite + +namespace OAI + + +namespace TuringRigidity.GroundPrefixOverwrite +open TransitiveNameModel BoundedSetTheory CountableForcing CohenColumnRealName +open FiniteOverwrite +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem overwrite_generic (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (A : Oracle) (hA : AtomicForcing.GroundGeneric M + (InternalCohen.pushFilter (CohenBorelForcing.realFilter A))) (s : List Bool) : + AtomicForcing.GroundGeneric M + (InternalCohen.pushFilter (CohenBorelForcing.realFilter (overwrite s A))) := by + have ha : natSet 0 ∈ M := hM _ (sourceT_omega_mem M hM hT) _ + ((mem_omega _).mpr ⟨0,rfl⟩) + have hs := singleton_mem M hM hT.pairing ha + have hm : natSet 0 ∈ ({natSet 0} : ZFSet.{0}) := ZFSet.mem_singleton.mpr rfl + obtain ⟨J,hJ,_,hJA⟩ := PrefixSingletonRealization.singleton_realization M (natSet 0) hM hT ha A hA + obtain ⟨hF,_,hFA⟩ := CohenFiniteFlip.prefixFilter_properties M {natSet 0} (natSet 0) + hM hT hs hm s A J hJ hJA + exact selected_real_prefix_generic M {natSet 0} (natSet 0) hM hT hs hm _ hF _ hFA + +theorem overwrite_realizes (s : List Bool) (A : Oracle) : + ShuffleRequirements.Realizes s (overwrite s A) := + fun n hn => (overwrite_below s A n hn).symm + +end TuringRigidity.GroundPrefixOverwrite + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/GroundSeedOrdinalHeight.lean b/lean/OAI/Computability/DegreeRigidity/Representation/GroundSeedOrdinalHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce7b63fa0c649abe0a34a30019ac503b2d2c9d65 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/GroundSeedOrdinalHeight.lean @@ -0,0 +1,74 @@ +import OAI.Computability.DegreeRigidity.Constructibility.InternalHeightDomains +import OAI.Computability.DegreeRigidity.Constructibility.RelativeConstruction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +theorem natSet_isOrdinal (n : ℕ) : (natSet.{u} n).IsOrdinal := by + induction n with + | zero => exact ZFSet.isOrdinal_empty + | succ n ih => exact ZFSet.isOrdinal_succ ih + +theorem omega_isOrdinal : ZFSet.omega.{u}.IsOrdinal := by + apply ZFSet.isOrdinal_iff_forall_mem_isOrdinal.mpr + refine ⟨omega_transitive,?_⟩ + intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + exact natSet_isOrdinal n + +theorem omega_mem_groundReals (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ZFSet.omega ∈ groundReals M := + (mem_groundReals M _).mpr ⟨sourceT_omega_mem M hM hT,fun _ h => h⟩ + +theorem groundReals_not_isOrdinal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ¬ (groundReals M).IsOrdinal := by + let s : ZFSet.{u} := {natSet 1} + have h1ω : natSet.{u} 1 ∈ ZFSet.omega := (mem_omega _).mpr ⟨1,rfl⟩ + have hsM : s ∈ M := singleton_mem M hM hT.pairing + (hM _ (sourceT_omega_mem M hM hT) _ h1ω) + have hsR : s ∈ groundReals M := (mem_groundReals M s).mpr ⟨hsM,by + intro x hx + obtain rfl := ZFSet.mem_singleton.mp hx + exact h1ω⟩ + intro h + have hs := h.mem hsR + have hz : natSet.{u} 0 ∈ s := hs.isTransitive.mem_trans ((natSet_mem_natSet 0 1).mpr (by decide)) + (ZFSet.mem_singleton.mpr rfl) + have he : (0 : ℕ) = 1 := natSet_injective (ZFSet.mem_singleton.mp hz) + exact Nat.zero_ne_one he + +theorem ordinalCut_ground_seed (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ordinalCut (seed (groundReals M)) = insert ZFSet.omega ZFSet.omega := by + apply ZFSet.ext; intro x + rw [mem_ordinalCut,ground_seed_shape M hM] + constructor + · rintro ⟨hx,ho⟩ + rcases ZFSet.mem_insert_iff.mp hx with rfl|hx + · exact False.elim (groundReals_not_isOrdinal M hM hT ho) + · exact ZFSet.mem_insert_iff.mpr + ((ho.subset_iff_eq_or_mem omega_isOrdinal).mp ((mem_groundReals M x).mp hx).2) + · intro hx + rcases ZFSet.mem_insert_iff.mp hx with rfl|hx + · exact ⟨ZFSet.mem_insert_of_mem _ (omega_mem_groundReals M hM hT),omega_isOrdinal⟩ + · have hxR : x ∈ groundReals M := (mem_groundReals M x).mpr + ⟨hM _ (sourceT_omega_mem M hM hT) _ hx,fun y hy => omega_transitive x hx y hy⟩ + exact ⟨ZFSet.mem_insert_of_mem _ hxR,omega_isOrdinal.mem hx⟩ + +theorem ordinalHeight_ground_seed (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ordinalHeight (seed (groundReals M)) = (insert ZFSet.omega ZFSet.omega : ZFSet.{u}).rank := by + unfold ordinalHeight + rw [ordinalCut_ground_seed M hM hT] + +theorem ground_level_height_independent (M N : ZFSet.{u}) + (hM : Transitive M) (hTM : SourceT M) (hN : Transitive N) (hTN : SourceT N) + (o : Ordinal.{u}) : + ordinalHeight (level (groundReals M) o) = ordinalHeight (level (groundReals N) o) := by + rw [ordinalHeight_level,ordinalHeight_level,ordinalHeight_ground_seed M hM hTM, + ordinalHeight_ground_seed N hN hTN] + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/HomogeneousDegreeExtension.lean b/lean/OAI/Computability/DegreeRigidity/Representation/HomogeneousDegreeExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b1db0ed28143fc79d0aefad18103208455088bf --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/HomogeneousDegreeExtension.lean @@ -0,0 +1,81 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformDegreeOrderName +import OAI.Computability.DegreeRigidity.SetModels.InternalHomogeneousTruth +import OAI.Computability.DegreeRigidity.SetModels.SetModelActionSatisfaction + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open RelativeConstructible SetModelSatisfaction +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +def OwnDegreeExtension (E I ρ f : ZFSet.{0}) : Prop := + IsAction f (degreeUniverse (groundReals E)) (degreeOrder (groundReals E)) ∧ + I ⊆ degreeUniverse (groundReals E) ∧ ρ ⊆ f + +def degreeExtensionFormula : BoundedSetTheory.Formula := + .conj (actionFormula 0 1 2) (.conj (.subset 3 1) (.subset 4 0)) + +theorem degreeExtensionFormula_spec (f D L I ρ : ZFSet.{0}) : + degreeExtensionFormula.Eval (cons f (cons D (cons L (cons I (fun _ => ρ))))) ↔ + IsAction f D L ∧ I ⊆ D ∧ ρ ⊆ f := by + simp only [degreeExtensionFormula,Formula.Eval,eval_actionFormula,Formula.eval_subset, + cons_zero,cons_succ] + +theorem degree_extension_all_generics (M c I ρ : ZFSet.{0}) + [OrderTop (Conditions c)] (hM : Transitive M) (hT : SourceT M) + (hct : (M : Set ZFSet.{0}).Countable) (hc : c ∈ M) (hI : I ∈ M) (hρ : ρ ∈ M) + (hom : ∀ p q : Conditions c, ∃ w ∈ M, ∃ a : Conditions c ≃o Conditions c, + (∀ s t, ZFSet.pair (label c s) (label c t) ∈ w ↔ t = a s) ∧ + ∃ r, r ≤ a p ∧ r ≤ q) + (f : Name (Conditions c)) (hf : f.encode (label c) ∈ M) + (hinv : ∀ w ∈ M, ∀ a : Conditions c ≃o Conditions c, + (∀ s t, ZFSet.pair (label c s) (label c t) ∈ w ↔ t = a s) → + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → + f.val (AutomorphismName.mapFilter a G).carrier = f.val G.carrier) + (G₀ : GenericFilter (Conditions c)) (hG₀ : GroundGeneric M G₀) + (h₀ : OwnDegreeExtension (genericExtensionSet M c G₀.carrier) I ρ (f.val G₀.carrier)) : + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → + OwnDegreeExtension (genericExtensionSet M c G.carrier) I ρ (f.val G.carrier) := by + have hoM := InternalCollapse.orderSet_mem M hM hT hc + have ho := InternalCollapse.orderSet_pair c + obtain ⟨D,hD,hDv⟩ := uniform_degreeUniverse_name M hM hT hc hoM ho + obtain ⟨L,hL,hLv⟩ := uniform_degreeOrder_name M hM hT hc hoM ho + have hcheck {x : ZFSet.{0}} (hx : x ∈ M) : + (Name.check x : Name (Conditions c)).encode (label c) ∈ M := + encoded_check_mem M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc hx + let e := push f (push D (push L (push (Name.check I) (fun _ => Name.check ρ)))) + have he (i : ℕ) : (e i).encode (label c) ∈ M := by + rcases i with _|_|_|_|i + exact hf; exact hD; exact hL; exact hcheck hI; exact hcheck hρ + have hs (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) : + degreeExtensionFormula.Eval (fun i => (e i).val G.carrier) ↔ + OwnDegreeExtension (genericExtensionSet M c G.carrier) I ρ (f.val G.carrier) := by + obtain ⟨q,hq⟩ := G.nonempty + have ht := G.upper le_top hq + have hv : (fun i => (e i).val G.carrier) = + cons (f.val G.carrier) (cons (D.val G.carrier) (cons (L.val G.carrier) + (cons I (fun _ => ρ)))) := by + funext i; rcases i with _|_|_|_|i + rfl; rfl; rfl + exact Name.val_check G.carrier ht _ + exact Name.val_check G.carrier ht _ + rw [hv,degreeExtensionFormula_spec,hDv G hG ht,hLv G hG ht] + rfl + have hsym : ∀ w ∈ M, ∀ a : Conditions c ≃o Conditions c, + (∀ s t, ZFSet.pair (label c s) (label c t) ∈ w ↔ t = a s) → + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → + (degreeExtensionFormula.Eval (fun i => (e i).val (AutomorphismName.mapFilter a G).carrier) ↔ + degreeExtensionFormula.Eval (fun i => (e i).val G.carrier)) := by + intro w hw a ha G hG + have hH := InternalOrderIsoTransport.map_ground_generic M c c w hM hT hc hc hw a ha G hG + rw [hs _ hH,hs G hG,InternalOrderIsoTransport.extension_eq M c c w hM hT hc hc hw a ha G hG, + hinv w hw a ha G hG] + have hall := (all_generics_of_internal_symmetry M c hM hT hct hc hom + degreeExtensionFormula e he hsym G₀ hG₀ ((hs G₀ hG₀).mpr h₀)).2 + exact fun G hG => (hs G hG).mp (hall G hG) + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/IteratedGenericCommonIdeal.lean b/lean/OAI/Computability/DegreeRigidity/Representation/IteratedGenericCommonIdeal.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2df872258f20e08aa0e1b96e41efbd54843fde5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/IteratedGenericCommonIdeal.lean @@ -0,0 +1,60 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCommonRequirements +import OAI.Computability.DegreeRigidity.CohenForcing.TaggedProductGeneric +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenFilters + +namespace OAI + + +namespace TuringRigidity.IteratedGenericCommonIdeal +open TransitiveNameModel BoundedSetTheory InternalCohen CountableForcing AtomicForcing +open CohenProductSplitting CohenBorelForcing InternalCommonRequirements +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem meets_requirements (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (A : Oracle) (hA : A ∈ modelReals M) (L R : Oracle) + (hL : GroundGeneric M (pushFilter (realFilter L))) + (hR : GroundGeneric (genericExtensionSet M conditions (pushFilter (realFilter L)).carrier) + (pushFilter (realFilter R))) : + ∀ p q : OracleCode, ∃ s t : List Bool, + CommonIdeal.Extends L s ∧ CommonIdeal.Extends R t ∧ CommonIdeal.Requirement A p q s t := by + have hcnd := conditions_mem M hM hT + obtain ⟨c,hc,hcs,_⟩ := TaggedProductConditions.internal_product M conditions conditions hM hT hcnd hcnd + let J := pushFilter (realFilter L) + let H := pushFilter (realFilter R) + have hJoint := TaggedProductGeneric.joint_ground_generic M conditions conditions c + hM hT hcnd hcnd hcs J hL H hR + intro p q + obtain ⟨x,hx,hxD⟩ := hJoint (denseSet c A p q) + (denseSet_mem M c hM hT hc A hA p q) (denseSet_dense c hcs A p q) + let I := productIso conditions conditions c hcs + let uv := I.symm x + have hx' : productMap conditions conditions c hcs uv ∈ + (TaggedProductGeneric.joint conditions conditions c hcs J H).carrier := by + change I uv ∈ _ + simpa only [uv,OrderIso.apply_symm_apply] using hx + have huv := (TaggedProductGeneric.joint_mem conditions conditions c hcs J H uv.1 uv.2).mp hx' + let s := conditionEquiv.symm uv.1 + let t := conditionEquiv.symm uv.2 + have hs : CommonIdeal.Extends L s.word := fun i hi => (huv.1 i hi).symm + have ht : CommonIdeal.Extends R t.word := fun i hi => (huv.2 i hi).symm + have hlabel (r : Conditions conditions) : + label conditions r = wordCode (conditionEquiv.symm r).word := by + rw [←label_encodeCondition] + exact congrArg (label conditions) (conditionEquiv.apply_symm_apply r).symm + have hxD' : label c (I uv) ∈ denseSet c A p q := by + simpa only [uv,OrderIso.apply_symm_apply] using hxD + change label c (productMap conditions conditions c hcs uv) ∈ denseSet c A p q at hxD' + rw [label_productMap,hlabel,hlabel,denseSet_spec c hcs] at hxD' + exact ⟨s.word,t.word,hs,ht,hxD'⟩ + +theorem ideal_of_iterated_generics (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (A : Oracle) (hA : A ∈ modelReals M) (L R : Oracle) + (hL : GroundGeneric M (pushFilter (realFilter L))) + (hR : GroundGeneric (genericExtensionSet M conditions (pushFilter (realFilter L)).carrier) + (pushFilter (realFilter R))) : + ∀ b : Degree, b ≤ degree A ↔ b ≤ degree (join A L) ∧ b ≤ degree (join A R) := + CommonIdeal.ideal_of_meets A L R (meets_requirements M hM hT A hA L R hL hR) + +end TuringRigidity.IteratedGenericCommonIdeal + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/NativeGenericWitness.lean b/lean/OAI/Computability/DegreeRigidity/Representation/NativeGenericWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..49d931de16a260a878ae1cfea5cb41c849caae2f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/NativeGenericWitness.lean @@ -0,0 +1,66 @@ +import OAI.Computability.DegreeRigidity.Representation.NativeModelCompatibility +import OAI.Computability.DegreeRigidity.Representation.GroundGenericRequirements + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open BoundedSetTheory TransitiveNameModel SetDegreeDecoding PersistentRestrictions +open CountableForcing AtomicForcing +universe u + +def SetGenericallyPersistent (M : ZFSet.{u}) (I : CountableIdeal) (ρ : I ≃o I) : Prop := + ∃ c o : ZFSet.{u}, ∃ ord : Preorder (Conditions c), + letI := ord + ∃ ot : OrderTop (Conditions c), + letI := ot + c ∈ M ∧ o ∈ M ∧ + (∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) ∧ + ∃ G : GenericFilter (Conditions c), GroundGeneric M G ∧ + SetModelCountability.InternallyCountable (genericExtensionSet M c G.carrier) (idealSet I) ∧ + NativePersistent (genericExtensionSet M c G.carrier) I ρ + +theorem SetGenericallyPersistent.persistent {M : ZFSet.{u}} + (hM : Transitive M) (hT : SourceT M) {I : CountableIdeal} + (hI : idealSet I ∈ M) {ρ : I ≃o I} (hρ : automorphismSet ρ ∈ M) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (h : SetGenericallyPersistent M I ρ) : Persistent I ρ := by + obtain ⟨c,o,ord,ot,hc,ho,hos,G,hG,hct,hn⟩ := h + let := ord + let := ot + obtain ⟨p,hp⟩ := G.nonempty + exact (generic_nativePersistent_iff M hM hT hc ho hos G hG + (G.upper le_top hp) I hI ρ hρ hz hct).mp hn + +theorem setGenericallyPersistent_iff (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) (I : CountableIdeal) + (hI : idealSet I ∈ M) (ρ : I ≃o I) (hρ : automorphismSet ρ ∈ M) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + SetGenericallyPersistent M I ρ ↔ Persistent I ρ := by + constructor + · exact SetGenericallyPersistent.persistent hM hT hI hρ hz + · intro hp + obtain ⟨c,hc,hdef⟩ := InternalCollapse.conditions_exist M hM hT hI + have h0 : (∅ : ZFSet.{u}) ∈ c := (hdef ∅).mpr + ⟨hM _ (sourceT_omega_mem M hM hT) _ ZFSet.omega_zero,InternalCollapse.prefix_empty _⟩ + let := InternalCollapse.order c + let := InternalCollapse.collapsePreorder c + let := InternalCollapse.top c h0 + have ho := InternalCollapse.orderSet_mem M hM hT hc + obtain ⟨G,ht,hG⟩ := AtomicForcing.countable_ground_generic M ⟨c,hc⟩ (⊤ : Conditions c) + have hne : ∃ x, x ∈ idealSet.{u} I := by + obtain ⟨d,hd⟩ := I.nonempty + exact ⟨degreeSet d,(mem_idealSet I _).mpr ⟨d,hd,rfl⟩⟩ + have hcount := InternalCollapse.internal_counting M hM hT hI hc hdef hne G hG + have hE := genericExtensionSet_transitive M c hM G.carrier + have hTE := extension_sourceT M hM hT hc ho (InternalCollapse.orderSet_pair c) G hG ht + have hME := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht + have hct := (native_countability_iff _ hE hTE (hME hI)).mpr hcount + exact ⟨c,InternalCollapse.orderSet c,inferInstance,inferInstance,hc,ho, + InternalCollapse.orderSet_pair c,G,hG,hct, + (generic_nativePersistent_iff M hM hT hc ho (InternalCollapse.orderSet_pair c) + G hG ht I hI ρ hρ hz hct).mpr hp⟩ + +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/NativeModelCompatibility.lean b/lean/OAI/Computability/DegreeRigidity/Representation/NativeModelCompatibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..14d086febf2ad5fcd844b1e1c3d4a848a241d496 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/NativeModelCompatibility.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTGenericPersistence +import OAI.Computability.DegreeRigidity.Constructibility.ParameterPersistentCollapse + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel SetModelReals SetDegreeDecoding PersistentRestrictions PersistentPresentation +universe u + +theorem realCode_eq_realSet (A : Oracle) : realCode.{u} A = realSet A := rfl + +theorem modelReals_eq_reals (M : ZFSet.{u}) : modelReals M = reals M := rfl + +theorem native_countability_iff (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {a : ZFSet.{u}} (ha : a ∈ M) : + SetModelCountability.InternallyCountable M a ↔ InternallyCountable M a := by + unfold SetModelCountability.InternallyCountable InternallyCountable + apply exists_congr; intro f + apply and_congr_right; intro hf + have he : ∀ i, cons f (cons ZFSet.omega (fun _ => a)) i ∈ M := by + intro i; rcases i with _|_|i + · exact hf + · exact sourceT_omega_mem M hM hT + · exact ha + rw [Formula.absolute _ M hM _ he,SetModelCountability.eval_ontoFormula] + rfl + +theorem degreeCode_eq_degreeSet (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (S : ZFSet.{u}) (hS : ∀ A : Oracle, realCode A ∈ S ↔ A ∈ modelReals M) + {A : Oracle} (hA : A ∈ modelReals M) : degreeCode S A = degreeSet (degree A) := by + apply ZFSet.ext; intro x + rw [degreeCode,ZFSet.mem_sep,mem_degreeSet] + constructor + · rintro ⟨_,B,hB,hBA⟩ + exact ⟨B,hB,hBA⟩ + · rintro ⟨B,rfl,hBA⟩ + have hB := sourceT_real_lower M hM hT hA ((degree_eq_iff B A).mp hBA).1 + exact ⟨(hS B).mpr hB,B,rfl,hBA⟩ + +theorem presentationSet_eq_idealSet (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (S : ZFSet.{u}) (hS : ∀ A : Oracle, realCode A ∈ S ↔ A ∈ modelReals M) + {I : CountableIdeal} {H : Oracle} (hH : Presented I H) (hHM : H ∈ modelReals M) : + presentationSet S H = idealSet I := by + have eq (n : ℕ) := degreeCode_eq_degreeSet M hM hT S hS (sourceT_real_column M hM hT hHM n) + apply ZFSet.ext; intro x + rw [mem_presentationSet,mem_idealSet] + constructor + · rintro ⟨n,rfl⟩ + exact ⟨_,(hH _).mpr ⟨n,rfl⟩,eq n⟩ + · rintro ⟨a,ha,rfl⟩ + obtain ⟨n,hn⟩ := (hH a).mp ha + exact ⟨n,by rw [eq,hn]⟩ + +theorem presentationGraph_eq_automorphismSet (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (S : ZFSet.{u}) (hS : ∀ A : Oracle, realCode A ∈ S ↔ A ∈ modelReals M) + {I : CountableIdeal} {H : Oracle} (hH : Presented I H) (hHM : H ∈ modelReals M) + (ρ : I ≃o I) (R : Oracle) (hR : ∀ v, R v = true ↔ Graph ρ hH v) : + presentationGraph S H R = automorphismSet ρ := by + have eq (n : ℕ) := degreeCode_eq_degreeSet M hM hT S hS (sourceT_real_column M hM hT hHM n) + apply ZFSet.ext; intro z + rw [mem_presentationGraph,mem_automorphismSet] + constructor + · rintro ⟨n,m,rfl,hr⟩ + have hg := (hR (Nat.pair n m)).mp hr + simp only [PersistentPresentation.Graph,Nat.unpair_pair] at hg + refine ⟨entry hH n,?_⟩ + rw [eq n,eq m,hg] + rfl + · rintro ⟨b,rfl⟩ + obtain ⟨n,hn⟩ := (hH b.val).mp b.property + obtain ⟨m,hm⟩ := (hH (ρ b).val).mp (ρ b).property + have hb : entry hH n = b := Subtype.ext hn + refine ⟨n,m,?_,(hR (Nat.pair n m)).mpr ?_⟩ + · rw [eq n,eq m,hn,hm] + · simp only [PersistentPresentation.Graph,Nat.unpair_pair,hb,hm] + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/NativePersistenceSyntax.lean b/lean/OAI/Computability/DegreeRigidity/Representation/NativePersistenceSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec465e1ec7047522533a5c42987331931babc42d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/NativePersistenceSyntax.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTNativeComparison + +namespace OAI + +namespace TuringRigidity.SetModelSatisfaction +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions SetModelSyntax +open SetDegreeDecoding PersistentRestrictions SetModelCountability ArithmeticTree +universe u +noncomputable section + +def InternalFormula.rename : InternalFormula → (ℕ → ℕ) → InternalFormula + | .bounded p, v => .bounded (p.rename v) + | .conj p q, v => .conj (p.rename v) (q.rename v) + | .neg p, v => .neg (p.rename v) + | .existsSet p, v => .existsSet (p.rename (liftMap v)) + +theorem InternalFormula.realize_rename (p : InternalFormula) (M : ZFSet.{u}) + (v : ℕ → ℕ) (e : ℕ → ZFSet.{u}) : + (p.rename v).Realize M e ↔ p.Realize M (e ∘ v) := by + induction p generalizing v e with + | bounded p => exact p.realize_rename M v e + | conj p q hp hq => exact and_congr (hp v e) (hq v e) + | neg p hp => exact not_congr (hp v e) + | existsSet p hp => + change (∃ x ∈ M, (p.rename (liftMap v)).Realize M (cons x e)) ↔ _ + apply exists_congr + intro x + apply and_congr_right + intro _ + have he : cons x e ∘ liftMap v = cons x (e ∘ v) := by funext i; cases i <;> rfl + exact (hp (liftMap v) (cons x e)).trans (he ▸ Iff.rfl) + +def setMovedFormula (f i : ℕ) : Formula := + .existsMem i (.existsMem (i+1) (.conj (.pairMem 1 0 (f+2)) (.neg (.equal 1 0)))) + +@[simp] theorem eval_setMovedFormula (f i : ℕ) (e : ℕ → ZFSet.{u}) : + (setMovedFormula f i).Eval e ↔ SetMoved (e f) (e i) := by + simp only [setMovedFormula,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,SetMoved] + +private def nativeSlots : ℕ → ℕ + | 0 => 1 | 1 => 2 | 2 => 3 | 3 => 0 | _+4 => 4 + +def nonidentityFormula : InternalFormula := + .existsSet (.conj (.bounded (actionFormula 0 3 2)) + (.conj (.bounded (setMovedFormula 0 3)) (persistenceFormula.rename nativeSlots))) + +theorem realize_nonidentityFormula (M : ZFSet.{u}) (hM : Transitive M) + (D L i : ZFSet.{u}) (hD : D ∈ M) (hL : L ∈ M) (hi : i ∈ M) (hω : ZFSet.omega.{u} ∈ M) : + nonidentityFormula.Realize M (cons D (cons L (cons i (fun _ => ZFSet.omega)))) ↔ + NativeNonidentity M D L i := by + change (∃ f ∈ M, _) ↔ ∃ f ∈ M, _ + apply exists_congr + intro f + apply and_congr_right + intro hf + let e := cons f (cons D (cons L (cons i (fun _ => ZFSet.omega)))) + have he : ∀ j, e j ∈ M := by + intro j + rcases j with _|_|_|_|j <;> simp [e,hf,hD,hL,hi,hω] + have hr : e ∘ nativeSlots = cons D (cons L (cons i (cons f (fun _ => ZFSet.omega)))) := by + funext j + rcases j with _|_|_|_|j <;> rfl + change ((actionFormula 0 3 2).Realize M e ∧ + (setMovedFormula 0 3).Realize M e ∧ (persistenceFormula.rename nativeSlots).Realize M e) ↔ _ + rw [(actionFormula 0 3 2).absolute M hM e he,eval_actionFormula, + (setMovedFormula 0 3).absolute M hM e he,eval_setMovedFormula, + InternalFormula.realize_rename,hr] + rfl + +end +end TuringRigidity.SetModelSatisfaction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealCohenFactorization.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealCohenFactorization.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d714098d36d07b3b025dde3c0d563da3704bc23 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealCohenFactorization.lean @@ -0,0 +1,62 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.CohenManyAbsorption +import OAI.Computability.DegreeRigidity.CohenForcing.CohenUnusedTransport +import OAI.Computability.DegreeRigidity.Representation.OriginalRealFullIteration + +namespace OAI + +namespace TuringRigidity.OriginalRealCohenFactorization +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames +open CohenGroundPoset InternalCountableOrdinals +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem original_name_factorization (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (τ : Name (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hτ : τ.encode (label (conditions (ZFSet.prod K ZFSet.omega))) ∈ M) + (G : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hG : AtomicForcing.GroundGeneric M G) (hreal : τ.val G.carrier ⊆ ZFSet.omega) : + let X := τ.val G.carrier + let N := RealGeneratedModel.hull M X + RealGeneratedModel.Contains M X N ∧ + ∃ GX : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega))), + AtomicForcing.GroundGeneric N GX ∧ + genericExtensionSet N (conditions (ZFSet.prod K ZFSet.omega)) GX.carrier = + genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier ∧ + modelReals (genericExtensionSet N (conditions (ZFSet.prod K ZFSet.omega)) GX.carrier) = + modelReals (genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier) := by + obtain ⟨C,hC,hCK,hct,E,hgraph,hE,B,hB,Q,hQ,A,hA,hBs,hQs,hAe,hclosed,σ,hσ,hBA,hall⟩ := + OriginalRealFullIteration.original_name_full_iteration M K hM hT hK.2.1 τ hτ + obtain ⟨a,ha,hSa,_,_⟩ := CohenFreshColumn.fresh_column M K C hM hT hK hC hCK hct + obtain ⟨H,hH,hval,hHull,hprop,hq,ho,hcount,Gq,hGq,hext,hcode,hL,hiter,_,hcone⟩ := hall G hG hreal + have haM := hM K hK.2.1 a (ZFSet.mem_sdiff.mp ha).1 + have hω := sourceT_omega_mem M hM hT + have hKM := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hK.2.1 hω + have hCM := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hC hω + have hD := InternalCohenPartition.complement_mem M _ _ hM hT hKM hCM + obtain ⟨U,hU,hUe⟩ := CohenManyAbsorption.same_generics_absorption + (RealGeneratedModel.hull M (τ.val G.carrier)) _ _ a hprop.1 hprop.2.1 + hq hcount (hprop.2.2.1 hD) (hprop.2.2.1 haM) hSa Gq hGq _ hL + obtain ⟨GX,hGX,hGXe⟩ := CohenUnusedTransport.transport M _ K C hM hT hprop.1 hprop.2.1 + hprop.2.2.1 hK hC hCK hct U hU + have hfinal := hGXe.trans (hUe.trans hiter) + exact ⟨hprop,GX,hGX,hfinal,congrArg modelReals hfinal⟩ + +theorem real_factorization (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (G : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hG : AtomicForcing.GroundGeneric M G) (X : ZFSet.{0}) + (hX : X ∈ genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier) + (hreal : X ⊆ ZFSet.omega) : + RealGeneratedModel.Contains M X (RealGeneratedModel.hull M X) ∧ + ∃ GX : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega))), + AtomicForcing.GroundGeneric (RealGeneratedModel.hull M X) GX ∧ + genericExtensionSet (RealGeneratedModel.hull M X) + (conditions (ZFSet.prod K ZFSet.omega)) GX.carrier = + genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier := by + obtain ⟨τ,hτ,hτX⟩ := (mem_extensionSet _ _ _ X).mp hX + obtain ⟨hprop,GX,hGX,hEq,_⟩ := original_name_factorization M K hM hT hK τ hτ G hG (hτX.symm ▸ hreal) + exact hτX ▸ ⟨hprop,GX,hGX,hEq⟩ + +end TuringRigidity.OriginalRealCohenFactorization + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealDefinitionTransport.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealDefinitionTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..ddf57bec80b1fafc24c88b350c62f149a75d5981 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealDefinitionTransport.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.Representation.OriginalRealCohenFactorization +import OAI.Computability.DegreeRigidity.Constructibility.OneRealDefinitionSentence +import OAI.Computability.DegreeRigidity.Representation.GroundInclusion + +namespace OAI + +namespace TuringRigidity.OriginalRealDefinitionTransport +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames +open CohenGroundPoset InternalCountableOrdinals RelativeConstructible ElementaryModel +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder +attribute [local instance] CohenNiceNameConstruction.cohenTop + +def Transported (M K : ZFSet.{0}) + (G : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (f : Name (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (X : ZFSet.{0}) (δ : Ordinal.{0}) (φ : SentenceForm) : Prop := + let c := conditions (ZFSet.prod K ZFSet.omega) + let N := RealGeneratedModel.hull M X + RealGeneratedModel.Contains M X N ∧ + ∃ GX : GenericFilter (Conditions c), AtomicForcing.GroundGeneric N GX ∧ + genericExtensionSet N c GX.carrier = genericExtensionSet M c G.carrier ∧ + ∃ fX : Name (Conditions c), fX.encode (label c) ∈ N ∧ + fX.val GX.carrier = f.val G.carrier ∧ + (Name.check δ.toZFSet : Name (Conditions c)).encode (label c) ∈ N ∧ + (Name.check X : Name (Conditions c)).encode (label c) ∈ N ∧ + (Name.check δ.toZFSet : Name (Conditions c)).val GX.carrier = δ.toZFSet ∧ + (Name.check X : Name (Conditions c)).val GX.carrier = X ∧ + X ∈ level (groundReals (genericExtensionSet N c GX.carrier)) δ ∧ + fX.val GX.carrier = definedSubset + (level (groundReals (genericExtensionSet N c GX.carrier)) δ) + φ (fun _ : Fin φ.bound => X) + +theorem original_definition_transport (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (τ f : Name (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hτ : τ.encode (label (conditions (ZFSet.prod K ZFSet.omega))) ∈ M) + (hf : f.encode (label (conditions (ZFSet.prod K ZFSet.omega))) ∈ M) + (G : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hG : AtomicForcing.GroundGeneric M G) (hreal : τ.val G.carrier ⊆ ZFSet.omega) + (δ : Ordinal.{0}) (hδ : δ.toZFSet ∈ M) (φ : SentenceForm) + (hX : τ.val G.carrier ∈ level (groundReals + (genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier)) δ) + (hdef : f.val G.carrier = definedSubset (level (groundReals + (genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier)) δ) + φ (fun _ : Fin φ.bound => τ.val G.carrier)) : + Transported M K G f (τ.val G.carrier) δ φ := by + let X := τ.val G.carrier + unfold Transported + intro c N + obtain ⟨hN,GX,hGX,hE,_⟩ := + OriginalRealCohenFactorization.original_name_factorization M K hM hT hK τ hτ G hG hreal + have hA := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hK.2.1 (sourceT_omega_mem M hM hT) + have hc : c ∈ N := hN.2.2.1 (conditions_mem M _ hM hT hA) + have hcheck {z : ZFSet.{0}} (hz : z ∈ N) : + (Name.check z : Name (Conditions c)).encode (label c) ∈ N := + encoded_check_mem N c hN.1 hN.2.1.pairing hN.2.1.union hN.2.1.powerSet + hN.2.1.separation.finitePrefix.bounded hN.2.1.replacement.finitePrefix + hN.2.1.infinity hc hz + have ht : (⊤ : Conditions c) ∈ GX.carrier := by + obtain ⟨q,hq⟩ := GX.nonempty + exact GX.upper le_top hq + have hfE : f.val G.carrier ∈ genericExtensionSet N c GX.carrier := by + rw [hE] + exact (mem_extensionSet M c G.carrier _).mpr ⟨f,hf,rfl⟩ + obtain ⟨fX,hfX,hval⟩ := (mem_extensionSet N c GX.carrier _).mp hfE + exact ⟨hN,GX,hGX,hE,fX,hfX,hval,hcheck (hN.2.2.1 hδ),hcheck hN.2.2.2, + Name.val_check GX.carrier ht δ.toZFSet,Name.val_check GX.carrier ht X, + hE.symm ▸ hX,hval.trans (hE.symm ▸ hdef)⟩ + +end TuringRigidity.OriginalRealDefinitionTransport + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealFullIteration.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealFullIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3fefcda083d8093404effae9fe7e25b70593a09 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealFullIteration.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.SetModels.CountedOriginalRealQuotient +import OAI.Computability.DegreeRigidity.CohenForcing.CohenFactorIteration + +namespace OAI + +namespace TuringRigidity.OriginalRealFullIteration +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames +open CohenGroundPoset InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax +open InternalProjectedGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop +attribute [local instance] codeOrder codePreorder + +theorem original_name_full_iteration (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : K ∈ M) + (τ : Name (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hτ : τ.encode (label (conditions (ZFSet.prod K ZFSet.omega))) ∈ M) : + ∃ C ∈ M, ∃ _hCK : C ⊆ K, (C = ∅ ∨ InternallyCountable M C) ∧ + ∃ E : ℕ → ZFSet.{0}, orbitGraph E ∈ M ∧ + (∀ n, E n ∈ M ∧ E n ⊆ conditions (ZFSet.prod C ZFSet.omega)) ∧ + ∃ B ∈ M, ∃ Q ∈ M, ∃ A ∈ M, + (∀ U, U ∈ B ↔ U ∈ M ∧ IsCode (conditions (ZFSet.prod C ZFSet.omega)) U) ∧ + (∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) ∧ + A = InternalGeneratedAlgebra.generated (conditions (ZFSet.prod C ZFSet.omega)) B Q + (InternalBooleanBits.seeds (conditions (ZFSet.prod C ZFSet.omega)) B E) ∧ + Closed (conditions (ZFSet.prod C ZFSet.omega)) B Q A ∧ + ∃ σ : Name (Conditions (positive A)), σ.encode (label (positive A)) ∈ M ∧ + ∃ hBA : ZFSet.prod C ZFSet.omega ⊆ ZFSet.prod K ZFSet.omega, + ∀ G : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega))), + AtomicForcing.GroundGeneric M G → τ.val G.carrier ⊆ ZFSet.omega → + let J := InternalCohenProjectedGeneric.projected _ _ hBA G + let X := τ.val G.carrier + let D := ZFSet.prod K ZFSet.omega \ ZFSet.prod C ZFSet.omega + let L := InternalCohenProjectedGeneric.projected _ D + (fun _ h => (ZFSet.mem_sdiff.mp h).1) G + ∃ H : GenericFilter (Conditions (positive A)), AtomicForcing.GroundGeneric M H ∧ + σ.val H.carrier = X ∧ + genericExtensionSet M (positive A) H.carrier = RealGeneratedModel.hull M X ∧ + RealGeneratedModel.Contains M X (RealGeneratedModel.hull M X) ∧ + let q := InternalQuotientConditions.conditions (conditions (ZFSet.prod C ZFSet.omega)) A + (genericFilterSet (positive A) H.carrier) + q ∈ RealGeneratedModel.hull M X ∧ InternalCollapse.orderSet q ∈ RealGeneratedModel.hull M X ∧ + InternallyCountable (RealGeneratedModel.hull M X) q ∧ + ∃ Gq : GenericFilter (Conditions q), AtomicForcing.GroundGeneric (RealGeneratedModel.hull M X) Gq ∧ + genericExtensionSet (RealGeneratedModel.hull M X) q Gq.carrier = + genericExtensionSet M (conditions (ZFSet.prod C ZFSet.omega)) J.carrier ∧ + genericFilterSet q Gq.carrier = + genericFilterSet (conditions (ZFSet.prod C ZFSet.omega)) J.carrier ∧ + AtomicForcing.GroundGeneric + (genericExtensionSet (RealGeneratedModel.hull M X) q Gq.carrier) L ∧ + genericExtensionSet (genericExtensionSet (RealGeneratedModel.hull M X) q Gq.carrier) + (conditions D) L.carrier = + genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier ∧ + modelReals (genericExtensionSet + (genericExtensionSet (RealGeneratedModel.hull M X) q Gq.carrier) + (conditions D) L.carrier) = + modelReals (genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier) ∧ + ∀ p ∈ G.carrier, ∃ r ∈ Gq.carrier, + label q r = label _ (InternalCohenFactor.project _ _ hBA p) := by + obtain ⟨C,hC,hCK,hct,E,hgraph,hE,B,hBM,Q,hQM,A,hAM,hB,hQ,hAe,hA,σ,hσ,hBA,hall⟩ := + CountedOriginalRealQuotient.original_name_counted_quotient M K hM hT hK τ hτ + have hω := sourceT_omega_mem M hM hT + have hKM := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hK hω + have hCM := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hC hω + refine ⟨C,hC,hCK,hct,E,hgraph,hE,B,hBM,Q,hQM,A,hAM,hB,hQ,hAe,hA,σ,hσ,hBA,?_⟩ + intro G hG hreal + obtain ⟨H,hHG,hval,hHull,hprop,hq,ho,hcount,Gq,hGq,hext,hcode,_,hcond⟩ := hall G hG hreal + refine ⟨H,hHG,hval,hHull,hprop,hq,ho,hcount,Gq,hGq,hext,hcode,?_,?_,?_,hcond⟩ + · rw [hext] + exact CohenUntouchedGeneric.untouched_ground_generic M _ _ hM hT hKM hCM hBA G hG + · rw [hext] + exact CohenFactorIteration.extension_eq M _ _ hM hT hKM hCM hBA G hG + · rw [hext] + exact congrArg modelReals (CohenFactorIteration.extension_eq M _ _ hM hT hKM hCM hBA G hG) + +end TuringRigidity.OriginalRealFullIteration + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealGeneratedModel.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealGeneratedModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..02e199b763afc6595bda13c2502f3907be783edd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealGeneratedModel.lean @@ -0,0 +1,83 @@ +import OAI.Computability.DegreeRigidity.Representation.RealGeneratedModel +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenBooleanReading + +namespace OAI + +namespace TuringRigidity.OriginalRealGeneratedModel +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames +open CohenGroundPoset InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax +open InternalProjectedGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop codeOrder codePreorder + +theorem original_name_hull (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : K ∈ M) + (τ : Name (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hτ : τ.encode (label (conditions (ZFSet.prod K ZFSet.omega))) ∈ M) : + ∃ C ∈ M, ∃ _hCK : C ⊆ K, (C = ∅ ∨ InternallyCountable M C) ∧ + ∃ E : ℕ → ZFSet.{0}, orbitGraph E ∈ M ∧ + (∀ n, E n ∈ M ∧ E n ⊆ conditions (ZFSet.prod C ZFSet.omega)) ∧ + ∃ B ∈ M, ∃ Q ∈ M, ∃ A ∈ M, + (∀ U, U ∈ B ↔ U ∈ M ∧ IsCode (conditions (ZFSet.prod C ZFSet.omega)) U) ∧ + (∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) ∧ + A = InternalGeneratedAlgebra.generated (conditions (ZFSet.prod C ZFSet.omega)) B Q + (InternalBooleanBits.seeds (conditions (ZFSet.prod C ZFSet.omega)) B E) ∧ + Closed (conditions (ZFSet.prod C ZFSet.omega)) B Q A ∧ + positive A ∈ M ∧ InternalBooleanGraph.inclusionOrder (positive A) ∈ M ∧ + ∃ σ : Name (Conditions (positive A)), σ.encode (label (positive A)) ∈ M ∧ + ∃ hBA : ZFSet.prod C ZFSet.omega ⊆ ZFSet.prod K ZFSet.omega, + ∀ G : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega))), + AtomicForcing.GroundGeneric M G → τ.val G.carrier ⊆ ZFSet.omega → + ∃ H : GenericFilter (Conditions (positive A)), AtomicForcing.GroundGeneric M H ∧ + (∀ q, q ∈ H.carrier ↔ InternalBooleanGeneric.Hit + (InternalCohenProjectedGeneric.projected _ _ hBA G) (label (positive A) q)) ∧ + σ.val H.carrier = τ.val G.carrier ∧ + genericExtensionSet M (positive A) H.carrier = RealGeneratedModel.hull M (τ.val G.carrier) ∧ + RealGeneratedModel.Contains M (τ.val G.carrier) (RealGeneratedModel.hull M (τ.val G.carrier)) ∧ + genericFilterSet (positive A) H.carrier ∈ RealGeneratedModel.hull M (τ.val G.carrier) ∧ + RealGeneratedModel.hull M (τ.val G.carrier) ⊆ + genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier ∧ + ∀ p ∈ G.carrier, ∃ q ∈ H.carrier, + label (positive A) q = InternalBooleanProjection.project + (conditions (ZFSet.prod C ZFSet.omega)) A + (InternalBooleanDense.basicCode (conditions (ZFSet.prod C ZFSet.omega)) + (label _ (InternalCohenFactor.project _ _ hBA p))) := by + obtain ⟨C,hCM,hCK,hcount,E,hgraph,hE,_,hBA,hread⟩ := + InternalCohenColumnReading.internal_column_reading M K hM hT hK τ hτ + have hω := sourceT_omega_mem M hM hT + have hKM := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hK hω + have hDM := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hCM hω + have hcM := conditions_mem M _ hM hT hDM + obtain ⟨B,hBM,Q,hQM,A,hAM,hB,hQ,heq,hA,σ,hσ,hall⟩ := + InternalBooleanIntermediate.internal_boolean_intermediate M _ hM hT hcM E hE hgraph + refine ⟨C,hCM,hCK,hcount,E,hgraph,hE,B,hBM,Q,hQM,A,hAM,hB,hQ,heq,hA, + positive_mem M A hM hT hAM,(projected_order_code M A hM hT hAM).1,σ,hσ,hBA,?_⟩ + intro G hG hreal + obtain ⟨hJG,hJval,_,_⟩ := hread G hG hreal + let J := InternalCohenProjectedGeneric.projected _ _ hBA G + obtain ⟨p,hp⟩ := J.nonempty + have hJtop : ⊤ ∈ J.carrier := J.upper le_top hp + obtain ⟨H,hHG,hhit,hval,hN,hTN,hMN,hXN,hHN,hNJ⟩ := hall J hJG hJtop + have hv : σ.val H.carrier = τ.val G.carrier := hval.trans hJval + have hcar : H.carrier = (projected M _ B Q A hM hT hcM hBM hAM hB hQ hA J).carrier := + Set.ext (fun q => hhit q) + have hHull : genericExtensionSet M (positive A) H.carrier = RealGeneratedModel.hull M (τ.val G.carrier) := by + rw [hcar,RealGeneratedModel.projected_extension_eq_hull M _ B Q A hM hT hcM hBM hQM hAM hB hQ hA + E hE hgraph heq J hJG hJtop,hJval] + refine ⟨H,hHG,hhit,hv,hHull,?_,hHull ▸ hHN,?_,?_⟩ + · rw [←hHull] + exact ⟨hN,hTN,hMN,hv ▸ hXN⟩ + · intro x hx + have hxH : x ∈ genericExtensionSet M (positive A) H.carrier := hHull.symm ▸ hx + exact InternalColumnExtension.column_extension_subset M _ _ hM hT hKM hDM hBA G hG (hNJ hxH) + · intro p hp + have hpJ := InternalCohenProjectedGeneric.projected_contains _ _ hBA G hp + obtain ⟨q,hq,hproj⟩ := InternalSameNameGeneric.projected_condition M _ B Q A + hM hT hcM hBM hAM hB hQ hA J _ hpJ + exact ⟨q,(hhit q).mpr hq,hproj⟩ + +end TuringRigidity.OriginalRealGeneratedModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealQuotientModel.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealQuotientModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d73e26f5e07cb9d0ca86239193d971e82c6c410 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealQuotientModel.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.Representation.RealHullQuotient +import OAI.Computability.DegreeRigidity.Representation.OriginalRealGeneratedModel + +namespace OAI + +namespace TuringRigidity.OriginalRealQuotientModel +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames +open CohenGroundPoset InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax +open InternalProjectedGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop +attribute [local instance] codeOrder codePreorder + +theorem original_name_quotient (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : K ∈ M) + (τ : Name (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hτ : τ.encode (label (conditions (ZFSet.prod K ZFSet.omega))) ∈ M) : + ∃ C ∈ M, ∃ _hCK : C ⊆ K, (C = ∅ ∨ InternallyCountable M C) ∧ + ∃ E : ℕ → ZFSet.{0}, orbitGraph E ∈ M ∧ + (∀ n, E n ∈ M ∧ E n ⊆ conditions (ZFSet.prod C ZFSet.omega)) ∧ + ∃ B ∈ M, ∃ Q ∈ M, ∃ A ∈ M, + (∀ U, U ∈ B ↔ U ∈ M ∧ IsCode (conditions (ZFSet.prod C ZFSet.omega)) U) ∧ + (∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) ∧ + A = InternalGeneratedAlgebra.generated (conditions (ZFSet.prod C ZFSet.omega)) B Q + (InternalBooleanBits.seeds (conditions (ZFSet.prod C ZFSet.omega)) B E) ∧ + Closed (conditions (ZFSet.prod C ZFSet.omega)) B Q A ∧ + ∃ σ : Name (Conditions (positive A)), σ.encode (label (positive A)) ∈ M ∧ + ∃ hBA : ZFSet.prod C ZFSet.omega ⊆ ZFSet.prod K ZFSet.omega, + ∀ G : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega))), + AtomicForcing.GroundGeneric M G → τ.val G.carrier ⊆ ZFSet.omega → + let J := InternalCohenProjectedGeneric.projected _ _ hBA G + let X := τ.val G.carrier + ∃ H : GenericFilter (Conditions (positive A)), AtomicForcing.GroundGeneric M H ∧ + σ.val H.carrier = X ∧ + genericExtensionSet M (positive A) H.carrier = RealGeneratedModel.hull M X ∧ + RealGeneratedModel.Contains M X (RealGeneratedModel.hull M X) ∧ + let q := InternalQuotientConditions.conditions (conditions (ZFSet.prod C ZFSet.omega)) A + (genericFilterSet (positive A) H.carrier) + q ∈ RealGeneratedModel.hull M X ∧ InternalCollapse.orderSet q ∈ RealGeneratedModel.hull M X ∧ + ∃ Gq : GenericFilter (Conditions q), AtomicForcing.GroundGeneric (RealGeneratedModel.hull M X) Gq ∧ + genericExtensionSet (RealGeneratedModel.hull M X) q Gq.carrier = + genericExtensionSet M (conditions (ZFSet.prod C ZFSet.omega)) J.carrier ∧ + genericFilterSet q Gq.carrier = + genericFilterSet (conditions (ZFSet.prod C ZFSet.omega)) J.carrier ∧ + genericExtensionSet (RealGeneratedModel.hull M X) q Gq.carrier ⊆ + genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier ∧ + ∀ p ∈ G.carrier, ∃ r ∈ Gq.carrier, + label q r = label _ (InternalCohenFactor.project _ _ hBA p) := by + obtain ⟨C,hCM,hCK,hcount,E,hgraph,hE,_,hBA,hread⟩ := + InternalCohenColumnReading.internal_column_reading M K hM hT hK τ hτ + have hω := sourceT_omega_mem M hM hT + have hKM := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hK hω + have hDM := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hCM hω + have hcM := conditions_mem M _ hM hT hDM + obtain ⟨B,hBM,Q,hQM,A,hAM,hB,hQ,heq,hA,σ,hσ,hall⟩ := + InternalBooleanIntermediate.internal_boolean_intermediate M _ hM hT hcM E hE hgraph + refine ⟨C,hCM,hCK,hcount,E,hgraph,hE,B,hBM,Q,hQM,A,hAM,hB,hQ,heq,hA,σ,hσ,hBA,?_⟩ + intro G hG hreal + obtain ⟨hJG,hJval,_,_⟩ := hread G hG hreal + let J := InternalCohenProjectedGeneric.projected _ _ hBA G + obtain ⟨p,hp⟩ := J.nonempty + have hJtop : ⊤ ∈ J.carrier := J.upper le_top hp + obtain ⟨H,hHG,hhit,hval,_,_,_,_,_,_⟩ := hall J hJG hJtop + have hv : σ.val H.carrier = τ.val G.carrier := hval.trans hJval + have hcar : H.carrier = (projected M _ B Q A hM hT hcM hBM hAM hB hQ hA J).carrier := + Set.ext (fun q => hhit q) + have hHull : genericExtensionSet M (positive A) H.carrier = RealGeneratedModel.hull M (τ.val G.carrier) := by + rw [hcar,RealGeneratedModel.projected_extension_eq_hull M _ B Q A hM hT hcM hBM hQM hAM hB hQ hA + E hE hgraph heq J hJG hJtop,hJval] + have hprop := (RealGeneratedModel.hull_properties M _ B Q A hM hT hcM hBM hQM hAM hB hQ hA + E hE hgraph heq J hJG hJtop).1 + rw [hJval] at hprop + refine ⟨H,hHG,hv,hHull,hprop,?_⟩ + dsimp only + rw [hcar] + have hfactor := RealHullQuotient.quotient_over_hull M _ B Q A hM hT hcM hBM hQM hAM hB hQ hA + E hE hgraph heq J hJG hJtop + dsimp only at hfactor + rw [hJval] at hfactor + obtain ⟨hq,ho,hGq,hext,hcode,hcond⟩ := hfactor + refine ⟨hq,ho,InternalQuotientGeneric.quotient M _ B Q A hM hT hcM hBM hAM hB hQ hA J, + hGq,hext,hcode,?_,?_⟩ + · rw [hext] + exact InternalColumnExtension.column_extension_subset M _ _ hM hT hKM hDM hBA G hG + · intro p hp + exact hcond _ (InternalCohenProjectedGeneric.projected_contains _ _ hBA G hp) + +end TuringRigidity.OriginalRealQuotientModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealUniformDefinition.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealUniformDefinition.lean new file mode 100644 index 0000000000000000000000000000000000000000..907e10948d426824631652a3fda082b8b7a96bab --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealUniformDefinition.lean @@ -0,0 +1,57 @@ +import OAI.Computability.DegreeRigidity.Representation.OriginalRealDefinitionTransport +import OAI.Computability.DegreeRigidity.Constructibility.UniformOrdinalDefinitionName + +namespace OAI + +namespace TuringRigidity.OriginalRealDefinitionTransport +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames +open CohenGroundPoset InternalCountableOrdinals RelativeConstructible ElementaryModel +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem original_uniform_definition (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (τ f : Name (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hτ : τ.encode (label (conditions (ZFSet.prod K ZFSet.omega))) ∈ M) + (hf : f.encode (label (conditions (ZFSet.prod K ZFSet.omega))) ∈ M) + (G : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hG : AtomicForcing.GroundGeneric M G) (hreal : τ.val G.carrier ⊆ ZFSet.omega) + (δ : Ordinal.{0}) (hδ : δ.toZFSet ∈ M) (φ : SentenceForm) + (hX : τ.val G.carrier ∈ level (groundReals + (genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier)) δ) + (hdef : f.val G.carrier = definedSubset (level (groundReals + (genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier)) δ) + φ (fun _ : Fin φ.bound => τ.val G.carrier)) : + let c := conditions (ZFSet.prod K ZFSet.omega) + let X := τ.val G.carrier + let N := RealGeneratedModel.hull M X + RealGeneratedModel.Contains M X N ∧ + ∃ fX : Name (Conditions c), fX.encode (label c) ∈ N ∧ + (∀ H : GenericFilter (Conditions c), AtomicForcing.GroundGeneric N H → + fX.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet N c H.carrier)) δ) + φ (fun _ : Fin φ.bound => X)) ∧ + ∃ GX : GenericFilter (Conditions c), AtomicForcing.GroundGeneric N GX ∧ + genericExtensionSet N c GX.carrier = genericExtensionSet M c G.carrier ∧ + fX.val GX.carrier = f.val G.carrier ∧ + X ∈ level (groundReals (genericExtensionSet N c GX.carrier)) δ := by + intro c X N + obtain ⟨hN,GX,hGX,hExt,f₀,_,hf₀,_,_,_,_,hXL,hdef₀⟩ := + original_definition_transport M K hM hT hK τ f hτ hf G hG hreal δ hδ φ hX hdef + have hA := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hK.2.1 (sourceT_omega_mem M hM hT) + have hc : c ∈ N := hN.2.2.1 (conditions_mem M _ hM hT hA) + obtain ⟨fX,hfX,hfv⟩ := uniform_ordinal_definition_name N hN.1 hN.2.1 hc + (InternalCollapse.orderSet_mem N hN.1 hN.2.1 hc) (InternalCollapse.orderSet_pair c) + δ (hN.2.2.1 hδ) X hN.2.2.2 φ + have hall (H : GenericFilter (Conditions c)) (hH : AtomicForcing.GroundGeneric N H) : + fX.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet N c H.carrier)) δ) + φ (fun _ : Fin φ.bound => X) := by + obtain ⟨q,hq⟩ := H.nonempty + exact hfv H hH (H.upper le_top hq) + exact ⟨hN,fX,hfX,hall,GX,hGX,hExt,(hall GX hGX).trans (hdef₀.symm.trans hf₀),hXL⟩ + +end TuringRigidity.OriginalRealDefinitionTransport + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealUniformExtension.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealUniformExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..b155244b57d4ee8c15e7fc838f5281a85a011073 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OriginalRealUniformExtension.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.Representation.OriginalRealUniformDefinition +import OAI.Computability.DegreeRigidity.Effective.UniformCohenDefinitionExtension + +namespace OAI + +namespace TuringRigidity.OriginalRealDefinitionTransport +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames AtomicForcing BoundedForcing +open CohenGroundPoset InternalCountableOrdinals RelativeConstructible ElementaryModel +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem original_uniform_extension (M K I ρ : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hct : (M : Set ZFSet.{0}).Countable) + (hK : FirstUncountable M K) (hI : I ∈ M) (hρ : ρ ∈ M) + (τ f : Name (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hτ : τ.encode (label (conditions (ZFSet.prod K ZFSet.omega))) ∈ M) + (hf : f.encode (label (conditions (ZFSet.prod K ZFSet.omega))) ∈ M) + (G : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hG : GroundGeneric M G) (hreal : τ.val G.carrier ⊆ ZFSet.omega) + (δ : Ordinal.{0}) (hδ : δ.toZFSet ∈ M) (φ : SentenceForm) + (hX : τ.val G.carrier ∈ level (groundReals + (genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier)) δ) + (hdef : f.val G.carrier = definedSubset (level (groundReals + (genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier)) δ) + φ (fun _ : Fin φ.bound => τ.val G.carrier)) + (hext : OwnDegreeExtension + (genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier) I ρ (f.val G.carrier)) : + let c := conditions (ZFSet.prod K ZFSet.omega) + let X := τ.val G.carrier + let N := RealGeneratedModel.hull M X + RealGeneratedModel.Contains M X N ∧ (N : Set ZFSet.{0}).Countable ∧ + ∃ fX : Name (Conditions c), fX.encode (label c) ∈ N ∧ + (∀ H : GenericFilter (Conditions c), GroundGeneric N H → + fX.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet N c H.carrier)) δ) + φ (fun _ : Fin φ.bound => X) ∧ + OwnDegreeExtension (genericExtensionSet N c H.carrier) I ρ (fX.val H.carrier)) ∧ + ∃ GX : GenericFilter (Conditions c), GroundGeneric N GX ∧ + genericExtensionSet N c GX.carrier = genericExtensionSet M c G.carrier ∧ + fX.val GX.carrier = f.val G.carrier := by + intro c X N + obtain ⟨hN,f₀,_,hf₀,GX,hGX,hExt,hval₀,_⟩ := + original_uniform_definition M K hM hT hK τ f hτ hf G hG hreal δ hδ φ hX hdef + have hA := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hK.2.1 (sourceT_omega_mem M hM hT) + have hc : c ∈ N := hN.2.2.1 (conditions_mem M _ hM hT hA) + have hNE : N ⊆ genericExtensionSet M c G.carrier := by + rw [←hExt] + obtain ⟨q,hq⟩ := GX.nonempty + exact ground_inclusion_set N c hN.1 hN.2.1.pairing hN.2.1.union hN.2.1.powerSet + hN.2.1.separation.finitePrefix.bounded hN.2.1.replacement.finitePrefix hN.2.1.infinity + hc GX.carrier (GX.upper le_top hq) + have hNct : (N : Set ZFSet.{0}).Countable := by + have hEct : (genericExtensionSet M c G.carrier : Set ZFSet.{0}).Countable := by + rw [genericExtensionSet_coe] + exact genericExtension_countable M c hct G.carrier + exact hEct.mono hNE + have h₀ : OwnDegreeExtension (genericExtensionSet N c GX.carrier) I ρ + (definedSubset (level (groundReals (genericExtensionSet N c GX.carrier)) δ) + φ (fun _ : Fin φ.bound => X)) := by + rw [←hf₀ GX hGX,hval₀,hExt] + exact hext + obtain ⟨fX,hfX,hfv⟩ := uniform_cohen_definition_extension N (ZFSet.prod K ZFSet.omega) I ρ + hN.1 hN.2.1 hNct (hN.2.2.1 hA) (hN.2.2.1 hI) (hN.2.2.1 hρ) + δ (hN.2.2.1 hδ) X hN.2.2.2 φ GX hGX h₀ + exact ⟨hN,hNct,fX,hfX,hfv,GX,hGX,hExt, + (hfv GX hGX).1.trans ((hf₀ GX hGX).symm.trans hval₀)⟩ + +end TuringRigidity.OriginalRealDefinitionTransport + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OwnDegreeExtensionMeaning.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OwnDegreeExtensionMeaning.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c7e975ed3527f0d517a9610995284f2c57db07c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OwnDegreeExtensionMeaning.lean @@ -0,0 +1,39 @@ +import OAI.Computability.DegreeRigidity.Representation.HomogeneousDegreeExtension +import OAI.Computability.DegreeRigidity.Representation.AmbientExtensionBody + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open TransitiveNameModel BoundedSetTheory SetDegreeDecoding PersistentRestrictions SetModelSatisfaction +open RelativeConstructible FullSetForcing ElementaryModel +universe u + +theorem own_degree_extension_iff (E : ZFSet.{0}) [Countable (Conditions E)] + (hE : Transitive E) (hTE : SourceT E) (I : CountableIdeal) (ρ : I ≃o I) (f : ZFSet.{0}) : + OwnDegreeExtension E (idealSet I) (automorphismSet ρ) f ↔ + ∃ hIJ : I.carrier ⊆ (modelIdeal E hE hTE).carrier, + ∃ σ : modelIdeal E hE hTE ≃o modelIdeal E hE hTE, + automorphismSet σ = f ∧ Extends hIJ ρ σ := by + have hr : ∀ w ∈ groundReals E, ∃ A : Oracle, realCode A = w := by + intro w hw + exact ⟨decodeReal w,realCode_decodeReal ((mem_groundReals E w).mp hw).2⟩ + have hD := internal_degreeUniverse E hE hTE _ (groundReals_mem E hE hTE) hr + have hd := ownDegreeUniverse_eq_idealSet E hE hTE (groundReals E) (mem_groundReals E) + have hl := ownDegreeOrder_actual E hE hTE (groundReals E) (mem_groundReals E) + unfold OwnDegreeExtension + rw [hd] + constructor + · rintro ⟨ha,hij,hext⟩ + have hij' := ideal_subset_iff.mp hij + obtain ⟨σ,hσ⟩ := decode_action (ArithmeticTree.sourceContext E hE hTE) hl + (modelIdeal E hE hTE) (hd ▸ hD) ha + refine ⟨hij',σ,hσ,(extends_sets_iff hij' ρ σ).mp ?_⟩ + rwa [hσ] + · rintro ⟨hij,σ,hσ,hext⟩ + rw [←hσ] + exact ⟨action_satisfaction (ArithmeticTree.sourceContext E hE hTE) hl (hd ▸ hD) σ, + ideal_subset hij,extends_sets hext⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OwnProgramValue.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OwnProgramValue.lean new file mode 100644 index 0000000000000000000000000000000000000000..aaa73222ec5256dde6d088a6de4a7de86efd7e29 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OwnProgramValue.lean @@ -0,0 +1,56 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformTableSimulation +import OAI.Computability.DegreeRigidity.Syntax.BoundedAutomorphismOutput +import OAI.Computability.DegreeRigidity.Representation.GenericIdentity +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleGroundReals + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory PersistentRestrictions SetDegreeDecoding +open GenericIdentity TableIndices IndexMatrix + +def OwnProgramAt (E f : ZFSet.{0}) (p : OracleCode) (R A : Oracle) : Prop := + Total p R A ∧ + ∃ u ∈ degreeUniverse (groundReals E), ∃ v ∈ degreeUniverse (groundReals E), + realCode A ∈ u ∧ realCode (value p R A) ∈ v ∧ ZFSet.pair u v ∈ f + +theorem own_program_of_table (d : ℕ) : + ∃ p : OracleCode, ∀ (E f : ZFSet.{0}) (R A : Oracle), + (∃ X : Oracle, Represents (join A R) (machine d) X ∧ + ∃ u ∈ degreeUniverse (groundReals E), ∃ v ∈ degreeUniverse (groundReals E), + realCode A ∈ u ∧ realCode X ∈ v ∧ ZFSet.pair u v ∈ f) → OwnProgramAt E f p R A := by + obtain ⟨p,hp⟩ := UniformPrograms.table_program d + refine ⟨p,fun E f R A ⟨X,hX,hrel⟩ => ?_⟩ + have he := hp (join A R) X hX + refine ⟨⟨X,he⟩,?_⟩ + have hv : value p R A = X := programOutput_eq p (join A R) X he + rwa [hv] + +theorem graph_pair_action (I : CountableIdeal) (σ : I ≃o I) (A B : Oracle) + (u v : ZFSet.{0}) (hAu : realCode A ∈ u) (hBv : realCode B ∈ v) + (hpair : ZFSet.pair u v ∈ automorphismSet σ) : + ∃ hA : degree A ∈ I.carrier, degree B = (σ ⟨degree A,hA⟩).val := by + obtain ⟨a,he⟩ := (mem_automorphismSet σ _).mp hpair + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + have ha : degree A = a.val := (real_mem_degreeSet A a.val).mp hAu + have hA : degree A ∈ I.carrier := ha.symm ▸ a.property + have he' : (⟨degree A,hA⟩ : I) = a := Subtype.ext ha + exact ⟨hA,by rw [he']; exact (real_mem_degreeSet B _).mp hBv⟩ + +theorem OwnProgramAt.action (E : ZFSet.{0}) (I : CountableIdeal) (σ : I ≃o I) + (p : OracleCode) (R A : Oracle) (h : OwnProgramAt E (automorphismSet σ) p R A) : + ∃ hA : degree A ∈ I.carrier, degree (value p R A) = (σ ⟨degree A,hA⟩).val := by + obtain ⟨u,_,v,_,hAu,hBv,hpair⟩ := h.2 + exact graph_pair_action I σ A (value p R A) u v hAu hBv hpair + +theorem OwnProgramAt.prescribed (E : ZFSet.{0}) (I : CountableIdeal) (σ : I ≃o I) + (π : Degree ≃o Degree) (hσ : RestrictsTo π I σ) + (p : OracleCode) (R A : Oracle) (h : OwnProgramAt E (automorphismSet σ) p R A) : + Total p R A ∧ degree (value p R A) = π (degree A) := by + obtain ⟨hA,hval⟩ := h.action E I σ p R A + exact ⟨h.1,hval.trans (hσ ⟨degree A,hA⟩).symm⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OwnRealsConstruction.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OwnRealsConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f7a99d0bf9dcdeb8f6219d5fc0755b8e940c88b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OwnRealsConstruction.lean @@ -0,0 +1,84 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.CanonicalRealsSyntax +import OAI.Computability.DegreeRigidity.Computability.ArithmeticFreeConstruction +import OAI.Computability.DegreeRigidity.Constructibility.FiniteStageDefinition + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def Construction.ownRealsSlots (t : Construction.{u}) : ℕ → ℕ + | 0 => 1 + | 1 => 0 + | 2 => 2 + | k+3 => match t.ordinalData k with | none => 0 | some _ => k+3 + +noncomputable def Construction.ownRealsMembership (t : Construction.{u}) : SentenceForm := + .ex (.conj (canonicalReals 0) (t.arithmeticFreeMembership.rename t.ownRealsSlots)) + +noncomputable def Construction.ownRealsInputs (t : Construction.{u}) (R : ZFSet.{u}) + (P : Oracle) : ℕ → ZFSet.{u} := + cons (realCode P) (fun k => match t.ordinalData k with + | none => realCode P + | some o => level R o) + +theorem Construction.ownRealsSlots_env (t : Construction.{u}) (R : ZFSet.{u}) + (P : Oracle) (z : ZFSet.{u}) : + (fun i => cons R (cons z (t.ownRealsInputs R P)) (t.ownRealsSlots i)) = + cons z (t.arithmeticFreeInputs R P) := by + funext i + rcases i with _|_|_|i + · rfl + · rfl + · rfl + · change (cons R (cons z (t.ownRealsInputs R P))) + (match t.ordinalData i with | none => 0 | some _ => i+3) = t.stageInputs R i + rw [t.stageInputs_eq] + cases hidx : t.ordinalData i <;> simp [Construction.ownRealsInputs,hidx,cons,stageParameter] + +theorem Construction.ownRealsInputs_mem (t : Construction.{u}) (M R : ZFSet.{u}) + (P : Oracle) (he : ∀ i, t.singleInputs R P i ∈ M) : ∀ i, t.ownRealsInputs R P i ∈ M := by + intro i + cases i with + | zero => exact he 1 + | succ k => + have hs : t.stageInputs R k ∈ M := he (k+5) + rw [t.stageInputs_eq] at hs + change (match t.ordinalData k with | none => realCode P | some o => level R o) ∈ M + cases hidx : t.ordinalData k with + | none => exact he 1 + | some o => simpa only [hidx,stageParameter] using hs + +theorem Construction.ownRealsMembership_spec (t : Construction.{u}) (M R : ZFSet.{u}) + (hM : Transitive M) (hR : groundReals M = R) (P : Oracle) (ht : t.Certified R P) + (he : ∀ i, t.singleInputs R P i ∈ M) (hv : t.value R P ∈ M) + (z : ZFSet.{u}) (hz : z ∈ M) : + t.ownRealsMembership.Sat (M : Set ZFSet) (cons z (t.ownRealsInputs R P)) ↔ z ∈ t.value R P := by + let e := cons z (t.ownRealsInputs R P) + have he' (i : ℕ) : e i ∈ M := by + cases i; exact hz; exact t.ownRealsInputs_mem M R P he _ + have hf (r : ZFSet.{u}) (hr : r ∈ M) : + (canonicalReals 0).Sat (M : Set ZFSet) (cons r e) ↔ r = R := by + rw [canonicalReals_spec M hM (he 2) 0 _ + (by intro i; cases i; exact hr; exact he' _),hR] + rfl + have hb : (t.arithmeticFreeMembership.rename t.ownRealsSlots).Sat (M : Set ZFSet) (cons R e) ↔ + z ∈ t.value R P := by + rw [SentenceForm.sat_rename] + change t.arithmeticFreeMembership.Sat (M : Set ZFSet) + (fun i => cons R (cons z (t.ownRealsInputs R P)) (t.ownRealsSlots i)) ↔ _ + rw [t.ownRealsSlots_env] + exact t.arithmeticFreeMembership_spec M R hM P ht he hv z hz + change (∃ r ∈ M, (canonicalReals 0).Sat (M : Set ZFSet) (cons r e) ∧ + (t.arithmeticFreeMembership.rename t.ownRealsSlots).Sat (M : Set ZFSet) (cons r e)) ↔ _ + constructor + · rintro ⟨r,hr,hrS,hp⟩ + obtain rfl := (hf r hr).mp hrS + exact hb.mp hp + · intro hp + exact ⟨R,he 0,(hf R (he 0)).mpr rfl,hb.mpr hp⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OwnRealsLevelDefinition.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OwnRealsLevelDefinition.lean new file mode 100644 index 0000000000000000000000000000000000000000..8fc57b3dbe43c92b8aff4402e916d8013931de0e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OwnRealsLevelDefinition.lean @@ -0,0 +1,56 @@ +import OAI.Computability.DegreeRigidity.Representation.OwnRealsConstruction +import OAI.Computability.DegreeRigidity.Constructibility.FiniteDefinitionTransfer +import OAI.Computability.DegreeRigidity.OrdinalCodes.LevelSubsetDefinition + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SetDegreeDecoding PersistentRestrictions +universe u + +theorem Construction.ownReals_at_level (t : Construction.{u}) (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (P : Oracle) + (hP : P ∈ modelReals M) (ht : t.Certified (groundReals M) P) (hi : t.Indexed M) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ + t.value (groundReals M) P ∈ level (groundReals M) γ ∧ + (∀ i, t.ownRealsInputs (groundReals M) P i ∈ level (groundReals M) γ) ∧ + ∀ z ∈ level (groundReals M) γ, + t.ownRealsMembership.Sat (level (groundReals M) γ : Set ZFSet) + (cons z (t.ownRealsInputs (groundReals M) P)) ↔ z ∈ t.value (groundReals M) P := by + obtain ⟨γ,hγ,hv,he,_⟩ := t.inlined_at_level M hM hT P hP ht hi + have hR := groundReals_mem M hM hT + have hsame := groundReals_between M (level (groundReals M) γ) + (level_transitive _ γ) (level_subset_model M _ hM hT hR γ hγ) (he 0) + exact ⟨γ,hγ,hv,t.ownRealsInputs_mem _ _ P he, + t.ownRealsMembership_spec _ _ (level_transitive _ γ) hsame P ht he hv⟩ + +theorem Construction.ownReals_subset_at_level (t : Construction.{u}) (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) (P : Oracle) + (hP : P ∈ modelReals M) (ht : t.Certified (groundReals M) P) (hi : t.Indexed M) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ + (∀ i, t.ownRealsInputs (groundReals M) P i ∈ level (groundReals M) γ) ∧ + t.value (groundReals M) P = definedSubset (level (groundReals M) γ) t.ownRealsMembership + (fun i : Fin t.ownRealsMembership.bound => t.ownRealsInputs (groundReals M) P i) := by + obtain ⟨γ,hγ,hv,he,hf⟩ := t.ownReals_at_level M hM hT P hP ht hi + exact ⟨γ,hγ,he,definedSubset_of_membership _ _ (level_transitive _ γ) hv + t.ownRealsMembership (t.ownRealsInputs (groundReals M) P) hf⟩ + +theorem persistent_extension_ownReals_subset (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) + (I : CountableIdeal) (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (hIM : I.carrier ⊆ (modelIdeal M hM hT).carrier) : + ∃ σ : modelIdeal M hM hT ≃o modelIdeal M hM hT, + Extends hIM ρ σ ∧ Persistent (modelIdeal M hM hT) σ ∧ + ∃ (t : Construction.{u}) (P : Oracle) (γ : Ordinal.{u}), + P ∈ modelReals M ∧ t.Indexed M ∧ t.Certified (groundReals M) P ∧ γ.toZFSet ∈ M ∧ + (∀ i, t.ownRealsInputs (groundReals M) P i ∈ level (groundReals M) γ) ∧ + automorphismSet σ = definedSubset (level (groundReals M) γ) t.ownRealsMembership + (fun i : Fin t.ownRealsMembership.bound => t.ownRealsInputs (groundReals M) P i) := by + obtain ⟨σ,he,hσ,t,P,hP,hi,ht,hval⟩ := persistent_extension_construction M hM hT I ρ hρ hz hIM + obtain ⟨γ,hγ,hin,hdef⟩ := t.ownReals_subset_at_level M hM hT P hP ht hi + exact ⟨σ,he,hσ,t,P,γ,hP,hi,ht,hγ,hin,hval ▸ hdef⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OwnSourceEquation.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OwnSourceEquation.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f941ce98bba1b4a0063b2af280cd41f5db23aee --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OwnSourceEquation.lean @@ -0,0 +1,62 @@ +import OAI.Computability.DegreeRigidity.Representation.OwnProgramValue +import OAI.Computability.DegreeRigidity.Representation.OwnDegreeExtensionMeaning +import OAI.Computability.DegreeRigidity.Effective.LocalSourceEquation + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory PersistentRestrictions SetDegreeDecoding +open GenericIdentity ElementaryModel BoundedForcing LocalSourceEquation + +theorem sourceEquation_of_own_graph (E : ZFSet.{0}) (I : CountableIdeal) (σ : I ≃o I) + (p : OracleCode) (P Y L R : Oracle) + (hL : GenericCoding.InfiniteOdd L) (hR : GenericCoding.InfiniteOdd R) + (hideal : PrincipalIntersection Y (join Y L) (join Y R)) + (hY : OwnProgramAt E (automorphismSet σ) p P Y) + (hGL : OwnProgramAt E (automorphismSet σ) p P L) + (hGR : OwnProgramAt E (automorphismSet σ) p P R) + (hCL : OwnProgramAt E (automorphismSet σ) p P (GenericCoding.code Y L)) + (hCR : OwnProgramAt E (automorphismSet σ) p P (GenericCoding.code Y R)) : + SourceEquation p P (Y,L,R) := by + obtain ⟨hy,hyv⟩ := hY.action E I σ p P Y + obtain ⟨hl,hlv⟩ := hGL.action E I σ p P L + obtain ⟨hr,hrv⟩ := hGR.action E I σ p P R + obtain ⟨hcl,hclv⟩ := hCL.action E I σ p P (GenericCoding.code Y L) + obtain ⟨hcr,hcrv⟩ := hCR.action E I σ p P (GenericCoding.code Y R) + have hleft : (σ (⟨degree (join Y L),I.join_mem hy hl⟩ : I)).val = + degree (join (value p P (GenericCoding.code Y L)) (value p P L)) := by + have he : (⟨degree (join Y L),I.join_mem hy hl⟩ : I) = + (⟨degree (GenericCoding.code Y L),hcl⟩ : I) ⊔ ⟨degree L,hl⟩ := + Subtype.ext (GenericCoding.join_degree_eq Y L hL).symm + rw [he,local_map_join,←hclv,←hlv] + rfl + have hright : (σ (⟨degree (join Y R),I.join_mem hy hr⟩ : I)).val = + degree (join (value p P (GenericCoding.code Y R)) (value p P R)) := by + have he : (⟨degree (join Y R),I.join_mem hy hr⟩ : I) = + (⟨degree (GenericCoding.code Y R),hcr⟩ : I) ⊔ ⟨degree R,hr⟩ := + Subtype.ext (GenericCoding.join_degree_eq Y R hR).symm + rw [he,local_map_join,←hcrv,←hrv] + rfl + refine ⟨hY.1,hGL.1,hGR.1,hCL.1,hCR.1,?_⟩ + have h := local_intersection I σ ⟨degree Y,hy⟩ + ⟨degree (join Y L),I.join_mem hy hl⟩ ⟨degree (join Y R),I.join_mem hy hr⟩ hideal + rw [←hyv,hleft,hright] at h + exact h + +theorem sourceEquation_of_own_extension (E : ZFSet.{0}) [Countable (Conditions E)] + (hE : Transitive E) (hTE : SourceT E) (I : CountableIdeal) (ρ : I ≃o I) + (f : ZFSet.{0}) (hf : OwnDegreeExtension E (idealSet I) (automorphismSet ρ) f) + (p : OracleCode) (P Y L R : Oracle) + (hL : GenericCoding.InfiniteOdd L) (hR : GenericCoding.InfiniteOdd R) + (hideal : PrincipalIntersection Y (join Y L) (join Y R)) + (hY : OwnProgramAt E f p P Y) (hGL : OwnProgramAt E f p P L) + (hGR : OwnProgramAt E f p P R) + (hCL : OwnProgramAt E f p P (GenericCoding.code Y L)) + (hCR : OwnProgramAt E f p P (GenericCoding.code Y R)) : SourceEquation p P (Y,L,R) := by + obtain ⟨_,σ,rfl,_⟩ := (own_degree_extension_iff E hE hTE I ρ f).mp hf + exact sourceEquation_of_own_graph E _ σ p P Y L R hL hR hideal hY hGL hGR hCL hCR + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/OwnStageSourceTheory.lean b/lean/OAI/Computability/DegreeRigidity/Representation/OwnStageSourceTheory.lean new file mode 100644 index 0000000000000000000000000000000000000000..758d80bf4d980adf64a7c18bf34f937de20ce16e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/OwnStageSourceTheory.lean @@ -0,0 +1,65 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalInputSyntax + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding SetModelFunctions +universe u + +theorem seedBoundStage_sourceT (M x A : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hx : x ∈ M) : + SeedBoundStage M ZFSet.omega (ZFSet.prod ZFSet.omega ZFSet.omega) + (groundReals M) x A ↔ A = stage (groundReals M) x := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + constructor + · exact SeedBoundStage.sound hM + (family_mem M hM hT.pairing hT.union C.omega_mem) + (supportGraph_mem M hM hT.pairing hT.union C.omega_mem) + · rintro rfl + have hR := groundReals_mem M hM hT + obtain ⟨d,hd,f,hf,hxd,hg⟩ := internal_hierarchy_cover M _ x hM hT hR hx + exact ⟨seed (groundReals M),seed_mem M _ hM hT hR,d,hd,f,hf,_, + iterUnion_mem M hM hT.union hf 2,ground_seed_shape M hM,hxd, + (checkedHierarchyGraph_of_context M _ _ _ _ C).mpr hg, + (hg.stageStep_iff x hxd _).mpr rfl⟩ + +theorem own_stage_sourceT_formula : + ∃ s : SentenceForm, ∀ M : ZFSet.{u}, Transitive M → SourceT M → + ∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ M) → + (s.Sat (M : Set ZFSet) e ↔ e 0 = stage (groundReals M) (e 1)) := by + obtain ⟨p,hp⟩ := NumericSyntax.stage_formula.{u} + refine ⟨ownStageFormula p,?_⟩ + intro M hM hT e he + have hw := sourceT_omega_mem M hM hT + have hR := groundReals_mem M hM hT + have hsq := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hw hw + obtain ⟨B,hB,hbound,_⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union + hT.powerSet hT.separation.finitePrefix.bounded hw + have hf (r : ZFSet.{u}) (hr : r ∈ M) : + (canonicalReals 0).Sat (M : Set ZFSet) (cons r e) ↔ r = groundReals M := + canonicalReals_spec M hM hw 0 _ (by intro i; cases i; exact hr; exact he _) + have hs : p.Sat (M : Set ZFSet) (cons (e 0) (cons (e 1) (fun _ => groundReals M))) ↔ + e 0 = stage (groundReals M) (e 1) := by + rw [hp M hM hw hsq (finiteNaturalGraph_mem M hM hT.pairing hT.union hw) + ⟨B,hB,hbound⟩ _ (by intro i; rcases i with _|_|i; exact he 0; exact he 1; exact hR)] + exact seedBoundStage_sourceT M _ _ hM hT (he 1) + change (∃ r ∈ M, (canonicalReals 0).Sat _ (cons r e) ∧ + (p.rename _).Sat _ (cons r e)) ↔ _ + simp only [SentenceForm.sat_rename] + constructor + · rintro ⟨r,hr,h,hp⟩ + obtain rfl := (hf r hr).mp h + apply hs.mp + convert hp using 1 + funext i + rcases i with _|_|i <;> rfl + · intro h + refine ⟨_,hR,(hf _ hR).mpr rfl,?_⟩ + convert hs.mpr h using 1 + funext i + rcases i with _|_|i <;> rfl + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/PairGenericSelection.lean b/lean/OAI/Computability/DegreeRigidity/Representation/PairGenericSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..cde2f7e1690b1e46e973cffef8756743b2053cb6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/PairGenericSelection.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DegreeRigidity.Representation.GenericTopology + +namespace OAI + +namespace TuringRigidity.PairGenericSelection +open FiniteShuffle ShuffleRequirements GenericTopology GenericCoding Set + +def column (b : Bool) (G : Oracle) : Oracle := + fun n => if b then G (2*n+1) else G (2*n) + +theorem column_agree (b : Bool) {n : ℕ} {G H : Oracle} (h : Agree (2*n) G H) : + Agree n (column b G) (column b H) := by + intro i hi + cases b <;> simp only [column,Bool.false_eq_true,↓reduceIte] <;> apply h <;> omega + +theorem column_measurable (b : Bool) : Measurable (column b) := by + apply Measurable.of_eval + intro n + cases b <;> exact measurable_pi_apply _ + +def ColumnRequirement (D : List Bool → Prop) (b : Bool) (s : List Bool) : Prop := + ∃ t, D t ∧ ∀ G, Realizes s G → Realizes t (column b G) + +theorem column_denseOpen (D : List Bool → Prop) (hd : DenseOpen D) (b : Bool) : + DenseOpen (ColumnRequirement D b) := by + constructor + · intro s + let G : Oracle := fun i => s.getD i false + let n := s.length+1 + obtain ⟨t,ht,hD⟩ := hd.1 (initial (column b G) n) + let T : Oracle := fun i => t.getD i false + let H : Oracle := if b then join (column false G) T else join T (column true G) + have hcol : column b H = T := by + funext i + cases b <;> simp [H,column] + have hl : n ≤ t.length := by simpa only [prefix_length] using ht.length_le + have hpair : Agree (2*n) G H := by + apply agree_of_columns + · intro i hi + cases b + · simpa [H,column,T] using agree_of_prefix ht i hi + · simp [H,column] + · intro i hi + cases b + · simp [H,column] + · simpa [H,column,T] using agree_of_prefix ht i hi + refine ⟨initial H (2*t.length),?_,t,hD,?_⟩ + · rw [←prefix_default s] + exact initial_prefix (n := s.length) (m := 2*t.length) (by dsimp [n] at hl; omega) + (hpair.mono (by dsimp [n]; omega)) + · intro K hK + have hc := column_agree b ((realizes_initial H K (2*t.length)).mp hK) + rw [hcol] at hc + exact hc + · intro s t hst + rintro ⟨u,hD,hu⟩ + exact ⟨u,hD,fun G hG => hu G (realizes_mono hst hG)⟩ + +def PairRequirements (D : ℕ → List Bool → Prop) (n : ℕ) : List Bool → Prop := + ColumnRequirement (Requirements D (n/2)) (decide (n%2 = 1)) + +theorem pair_requirements_denseOpen (D : ℕ → List Bool → Prop) (hd : ∀ n, DenseOpen (D n)) + (n : ℕ) : DenseOpen (PairRequirements D n) := + column_denseOpen _ (requirements_denseOpen D hd _) _ + +theorem pair_requirements_spec (D : ℕ → List Bool → Prop) (G : Oracle) + (hg : GenericFor (PairRequirements D) G) (b : Bool) : + GenericFor D (column b G) ∧ InfiniteOdd (column b G) ∧ + ∀ A, GenericFor D (code A (column b G)) := by + apply requirements_spec + intro n + have h : G ∈ OpenSet (ColumnRequirement (Requirements D n) b) := by + cases b + · simpa [OpenSet,PairRequirements] using hg (2*n) + · simpa [OpenSet,PairRequirements,Nat.add_div] using hg (2*n+1) + obtain ⟨s,⟨t,ht,hcol⟩,hs⟩ := h + exact ⟨t,ht,hcol G hs⟩ + +theorem borel_pair_selection {X : Type*} [MeasurableSpace X] + (D : ℕ → List Bool → Prop) (hd : ∀ n, DenseOpen (D n)) + (R : X → ℕ → ℕ → Prop) + (hRd : ∀ x n s, ∃ t, BorelGeneric.Ext s t ∧ R x n t) + (hRm : ∀ n t, MeasurableSet {x | R x n t}) : + ∃ Z : X → Oracle, Measurable Z ∧ + (∀ x b, GenericFor D (column b (Z x)) ∧ InfiniteOdd (column b (Z x)) ∧ + ∀ A, GenericFor D (code A (column b (Z x)))) ∧ + ∀ x n, ∃ t, R x n t ∧ BorelGeneric.Meets (Z x) t := by + obtain ⟨Z,hZ,hreq⟩ := borel_selection_with_requirements (PairRequirements D) + (pair_requirements_denseOpen D hd) R hRd hRm + exact ⟨Z,hZ,fun x b => pair_requirements_spec D (Z x) (hreq x).1.1 b, + fun x => (hreq x).2⟩ + +end TuringRigidity.PairGenericSelection + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/ParameterCoveringModels.lean b/lean/OAI/Computability/DegreeRigidity/Representation/ParameterCoveringModels.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfbdafb47bd0a332ac7976cec82714315bb4a7f9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/ParameterCoveringModels.lean @@ -0,0 +1,61 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementarySchemas + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel RelationCollapse +universe u + +noncomputable def realSeed (A : ℕ → Oracle) (n : ℕ) : ZFSet.{u} := + if n.unpair.1 = 0 then natSet n.unpair.2 else realCode (A n.unpair.2) + +theorem seed_naturals (A : ℕ → Oracle) (n : ℕ) : natSet.{u} n ∈ hullSet (realSeed A) := by + apply (mem_hullSet _ _).mpr + have h := parameter_mem (realSeed.{u} A) (Nat.pair 0 n) + simpa [realSeed] using h + +theorem seed_reals (A : ℕ → Oracle) (n : ℕ) : realCode.{u} (A n) ∈ hullSet (realSeed A) := by + apply (mem_hullSet _ _).mpr + have h := parameter_mem (realSeed.{u} A) (Nat.pair 1 n) + simpa [realSeed] using h + +theorem collapse_nat_fixed (A : ℕ → Oracle) (n : ℕ) : + structureMap (hullSet (realSeed.{u} A)) (natSet n) = natSet n := by + apply structureMap_fixed omega_transitive + · intro z hz + obtain ⟨i,rfl⟩ := (mem_omega z).mp hz + exact seed_naturals A i + · exact (mem_omega _).mpr ⟨n,rfl⟩ + +theorem collapse_real_fixed (A : ℕ → Oracle) (n : ℕ) : + structureMap (hullSet (realSeed.{u} A)) (realCode (A n)) = realCode (A n) := by + apply collapse_fixed _ _ (seed_reals A n) + intro y hy + obtain ⟨i,rfl⟩ := (mem_omega y).mp (realCode_subset (A n) hy) + exact ⟨seed_naturals A i,collapse_nat_fixed A i⟩ + +theorem collapsed_hull_elementary (a : ℕ → ZFSet.{u}) (p : SentenceForm) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ hullSet a) : + p.Sat (collapsed (hullSet a) : Set ZFSet) (fun i => structureMap (hullSet a) (e i)) ↔ + p.Sat Set.univ e := by + rw [←p.collapse_sat (hullSet a) (hullSet_extensional a) e he] + have hh : (hullSet a : Set ZFSet) = hull a := by ext x; exact mem_hullSet a x + rw [hh] + exact hull_elementary a p e (fun i => (mem_hullSet a _).mp (he i)) + +theorem collapsed_hull_sourceT (a : ℕ → ZFSet.{u}) : SourceT (collapsed (hullSet a)) := by + apply (collapsed_hull_valid a).sourceT (collapsed_transitive _) + exact ⟨_,(mem_collapsed _ _).mpr ⟨a 0,(mem_hullSet a _).mpr (parameter_mem a 0),rfl⟩⟩ + +theorem parameter_covering_models (A : ℕ → Oracle) : + ∃ M : ZFSet.{u}, Transitive M ∧ SourceT M ∧ Countable (Conditions M) ∧ + ∀ n, A n ∈ modelReals M := by + let M := collapsed (hullSet (realSeed.{u} A)) + refine ⟨M,collapsed_transitive _,collapsed_hull_sourceT _,inferInstance,?_⟩ + intro n + exact (mem_collapsed _ _).mpr ⟨realCode (A n),seed_reals A n,(collapse_real_fixed A n).symm⟩ + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedArithmeticGenericProgram.lean b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedArithmeticGenericProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9c9117f7ce5b852a895974ed2b44f85bcc139d9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedArithmeticGenericProgram.lean @@ -0,0 +1,44 @@ +import OAI.Computability.DegreeRigidity.Representation.RealHullPrescribedTruth +import OAI.Computability.DegreeRigidity.Representation.PrescribedOracleValue + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open CohenColumnRealName InternalCountableOrdinals ElementaryModel PersistentRestrictions +open GenericIdentity OracleJump +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem prescribed_arithmetic_generic_program (π : Degree ≃o Degree) + (M K : ZFSet.{0}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (hK : FirstUncountable M K) + (himages : π (degree (jump FixedArithmetic.zero)) ⊔ + π.symm (degree (jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) (hρ : RestrictsTo π _ ρ) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) : + ∃ (R : Oracle) (p : OracleCode), realCode R ∈ M ∧ + degree R = π.symm (degree (jump FixedArithmetic.zero)) ∧ + (∀ H : Oracle, ArithmeticPrefixForcing.Generic (fun _ => iterate R 5) H → + SourceEquation p (iterate R 5) (GenericTruth.triple H)) ∧ + (∃ D : ArithmeticPrefixForcing.PrefixPredicate, ArithmeticPrefixForcing.ArithmeticPrefix D ∧ + (∀ n, FiniteShuffle.DenseOpen (D (fun _ => iterate R 5) n)) ∧ + ∀ H : Oracle, ShuffleRequirements.GenericFor (D (fun _ => iterate R 5)) H → + SourceEquation p (iterate R 5) (GenericTruth.triple H)) ∧ + (∀ Y : Oracle, realCode Y ∈ genericExtensionSet M (poset K) G.carrier → + ArithmeticPrefixForcing.Generic (fun _ => iterate R 5) Y → + RepresentsAt π p (iterate R 5) Y) ∧ + ∃ D : ℕ → List Bool → Prop, (∀ n, FiniteShuffle.DenseOpen (D n)) ∧ + (∀ A, ShuffleRequirements.GenericFor D A → Total p (iterate R 5) A) ∧ + ContinuousOn (value p (iterate R 5)) {A | ShuffleRequirements.GenericFor D A} := by + obtain ⟨a,ha⟩ := InternalCountableOrdinals.nonempty M K hK + obtain ⟨δ,X,φ,R,hδ,hφ,hX,hRM,hR,hN,hNct,fX,hfX,hall,GX,hGX,hExt,hσ,A₀,p,hA₀,hown,hsem,hcont⟩ := + prescribed_oracle_value π M K a hM hT hK ha himages ρ hρ G hG + have hP := sourceT_real_iterate _ hN.1 hN.2.1 (hN.2.2.1 hRM) 5 + obtain ⟨_,ht,hfinite,hrep⟩ := real_hull_prescribed_transfer M K a hM hT hK ha G hG + X hX π p (iterate R 5) hP hsem + exact ⟨R,p,hRM,hR,ht,hfinite,hrep,hcont⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedColumnPrefixProgram.lean b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedColumnPrefixProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0bdcee57c9fcc526f35038f7147b0995ada8a94 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedColumnPrefixProgram.lean @@ -0,0 +1,75 @@ +import OAI.Computability.DegreeRigidity.SetModels.SelectedColumnPrefixProgram +import OAI.Computability.DegreeRigidity.Representation.PrescribedRealHullExtension + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames AtomicForcing BoundedForcing +open CohenGroundPoset InternalCountableOrdinals ElementaryModel SetDegreeDecoding PersistentRestrictions +open FullSetForcing CohenColumnRealName OracleJump TableIndices IndexMatrix +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem prescribed_column_prefix_program (π : Degree ≃o Degree) + (M K a : ZFSet.{0}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (hK : FirstUncountable M K) (ha : a ∈ K) + (himages : π (degree (jump FixedArithmetic.zero)) ⊔ + π.symm (degree (jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) (hρ : RestrictsTo π _ ρ) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) : + let c := poset K + let E := genericExtensionSet M c G.carrier + let hE := genericExtensionSet_transitive M c hM G.carrier + let hTE := extension_sourceT M hM hT (manyColumn_internal M K hM hT hK.2.1).1 + (manyColumn_internal M K hM hT hK.2.1).2 (InternalCollapse.orderSet_pair c) + G hG (G.upper le_top G.nonempty.choose_spec) + let I := modelIdeal M hM hT + let J := modelIdeal E hE hTE + ∃ (δ : Ordinal.{0}) (P : Oracle) (φ : SentenceForm) (R : Oracle), + δ.toZFSet ∈ M ∧ φ.bound ≤ 2 ∧ P ∈ modelReals E ∧ + realCode R ∈ M ∧ degree R = π.symm (degree (jump FixedArithmetic.zero)) ∧ + let N := RealGeneratedModel.hull M (realCode P) + RealGeneratedModel.Contains M (realCode P) N ∧ (N : Set ZFSet.{0}).Countable ∧ + ∃ fX : Name (Conditions c), fX.encode (label c) ∈ N ∧ + (∀ H : GenericFilter (Conditions c), GroundGeneric N H → + fX.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet N c H.carrier)) δ) + φ (fun _ : Fin φ.bound => realCode P) ∧ + OwnDegreeExtension (genericExtensionSet N c H.carrier) + (idealSet I) (automorphismSet ρ) (fX.val H.carrier)) ∧ + ∃ GX : GenericFilter (Conditions c), GroundGeneric N GX ∧ + genericExtensionSet N c GX.carrier = E ∧ + (∃ σ : J ≃o J, RestrictsTo π J σ ∧ fX.val GX.carrier = automorphismSet σ) ∧ + ∃ A₀ : Oracle, ∃ d ℓ : ℕ, + (realName K a).val GX.carrier = realCode A₀ ∧ + ∀ H : GenericFilter (Conditions c), GroundGeneric N H → + ∀ A : Oracle, (realName K a).val H.carrier = realCode A → + (∀ n < ℓ, A n = A₀ n) → ∃ X : Oracle, + Represents (iterate (join A R) 5) (machine d) X ∧ + ∃ u ∈ degreeUniverse (groundReals (genericExtensionSet N c H.carrier)), + ∃ v ∈ degreeUniverse (groundReals (genericExtensionSet N c H.carrier)), + realCode A ∈ u ∧ realCode X ∈ v ∧ ZFSet.pair u v ∈ fX.val H.carrier := by + intro c E hE hTE I J + have hz : degree (jump FixedArithmetic.zero) ∈ I.carrier := + ⟨jump FixedArithmetic.zero,sourceT_real_jump M hM hT (sourceT_zero_real M hM hT),rfl⟩ + obtain ⟨R,hRM,hR⟩ := (modelIdeal_mem M hM hT _).mp (ρ.symm ⟨_,hz⟩).property + have hRglobal : degree R = π.symm (degree (jump FixedArithmetic.zero)) := by + apply π.injective + rw [hR,π.apply_symm_apply] + simpa only [ρ.apply_symm_apply] using hρ (ρ.symm ⟨_,hz⟩) + obtain ⟨δ,P,φ,hδ,hφ,hP,hN,hNct,fX,hfX,hall,GX,hGX,hExt,σ,hσ,hval⟩ := + prescribed_real_hull_extension π M K hM hT hK himages ρ hρ G hG + let N := RealGeneratedModel.hull M (realCode P) + let : Countable (N : Set ZFSet.{0}) := hNct.to_subtype + let : Countable (Conditions N) := Function.Injective.countable + (f := fun p : Conditions N => (⟨label N p,label_mem N p⟩ : (N : Set ZFSet.{0}))) + (fun x y he => label_injective N (congrArg (fun z : (N : Set ZFSet.{0}) => z.val) he)) + obtain ⟨A₀,d,ℓ,hA₀,hprog⟩ := selected_column_prefix_program N K a hN.1 hN.2.1 + (hN.2.2.1 hK.2.1) ha δ (realCode P) φ I ρ hz R (hN.2.2.1 hRM) hR + fX hfX (fun H hH => (hall H hH).1) GX hGX (hall GX hGX).2 + exact ⟨δ,P,φ,R,hδ,hφ,hP,hRM,hRglobal,hN,hNct,fX,hfX,hall,GX,hGX,hExt, + ⟨σ,hσ,hval⟩,A₀,d,ℓ,hA₀,hprog⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedCoveringModel.lean b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedCoveringModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1e793197f5a959f69ccbea2650bc8550cc72201 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedCoveringModel.lean @@ -0,0 +1,38 @@ +import OAI.Computability.DegreeRigidity.Representation.PrescribedModelRestriction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel RelationCollapse SetDegreeDecoding +open PersistentRestrictions ArithmeticTree +universe u + +theorem prescribed_covering_model (π : Degree ≃o Degree) (A : ℕ → Oracle) : + ∃ M : ZFSet.{u}, ∃ hM : Transitive M, ∃ hT : SourceT M, + ∃ hcount : Countable (Conditions M), + letI := hcount + Valid M ∧ (∀ n, A n ∈ modelReals M) ∧ + (π (degree (OracleJump.jump FixedArithmetic.zero)) ⊔ + π.symm (degree (OracleJump.jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) ∧ + ∃ ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT, + RestrictsTo π _ ρ ∧ Persistent _ ρ ∧ + automorphismSet ρ ∈ relativeModel M (groundReals M) ∧ + SetGenericallyPersistent M _ ρ := by + obtain ⟨B,hB⟩ := degree_surjective + (π (degree (OracleJump.jump FixedArithmetic.zero)) ⊔ + π.symm (degree (OracleJump.jump FixedArithmetic.zero))) + let S : ℕ → Oracle | 0 => B | n+1 => A n + let M := collapsed (hullSet (realSeed.{u} S)) + have hM : Transitive M := collapsed_transitive _ + have hT : SourceT M := collapsed_hull_sourceT _ + have hs (n : ℕ) : S n ∈ modelReals M := + (mem_collapsed _ _).mpr ⟨realCode (S n),seed_reals S n,(collapse_real_fixed S n).symm⟩ + have hi : π (degree (OracleJump.jump FixedArithmetic.zero)) ⊔ + π.symm (degree (OracleJump.jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier := + ⟨B,hs 0,hB⟩ + exact ⟨M,hM,hT,inferInstance,collapsed_hull_valid _,fun n => hs (n+1),hi, + prescribed_model_restriction π M hM hT hi⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedFirstUncountable.lean b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedFirstUncountable.lean new file mode 100644 index 0000000000000000000000000000000000000000..f39b3efc03bacbcb827c674ae068fc8dbafa6878 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedFirstUncountable.lean @@ -0,0 +1,27 @@ +import OAI.Computability.DegreeRigidity.SetModels.ValidFirstUncountable +import OAI.Computability.DegreeRigidity.Representation.PrescribedCoveringModel + +namespace OAI + +namespace TuringRigidity.PrescribedFirstUncountable +open TransitiveNameModel BoundedSetTheory ElementaryModel RelativeConstructible SetDegreeDecoding +open PersistentRestrictions ArithmeticTree + +theorem prescribed_covering_model_with_omega_one (π : Degree ≃o Degree) (A : ℕ → Oracle) : + ∃ M : ZFSet.{0}, ∃ hM : Transitive M, ∃ hT : SourceT M, + ∃ hcount : Countable (Conditions M), + letI := hcount + Valid M ∧ (∃ K, InternalCountableOrdinals.FirstUncountable M K) ∧ (∀ n, A n ∈ modelReals M) ∧ + (π (degree (OracleJump.jump FixedArithmetic.zero)) ⊔ + π.symm (degree (OracleJump.jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) ∧ + ∃ ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT, + RestrictsTo π _ ρ ∧ Persistent _ ρ ∧ + automorphismSet ρ ∈ relativeModel M (groundReals M) ∧ + SetGenericallyPersistent M _ ρ := by + obtain ⟨M,hM,hT,hcount,hV,hA,hi,hρ⟩ := prescribed_covering_model.{0} π A + have hK := ValidFirstUncountable.firstUncountable_exists M hM hV ⟨realCode (A 0),hA 0⟩ + exact ⟨M,hM,hT,hcount,hV,hK,hA,hi,hρ⟩ + +end TuringRigidity.PrescribedFirstUncountable + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedGenericRestriction.lean b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedGenericRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7c23e9bbee91ddfa7564dfb7e73543d37fa6218 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedGenericRestriction.lean @@ -0,0 +1,72 @@ +import OAI.Computability.DegreeRigidity.Representation.PrescribedModelRestriction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel SetDegreeDecoding +open PersistentRestrictions ArithmeticTree CountableForcing +universe u + +theorem modelIdeal_inclusion (M N : ZFSet.{u}) + [Countable (Conditions M)] [Countable (Conditions N)] + (hM : Transitive M) (hTM : SourceT M) (hN : Transitive N) (hTN : SourceT N) + (hMN : M ⊆ N) : (modelIdeal M hM hTM).carrier ⊆ (modelIdeal N hN hTN).carrier := by + rintro d ⟨A,hA,rfl⟩ + refine ⟨A,?_,rfl⟩ + change realCode A ∈ N + exact hMN hA + +theorem prescribed_restrictions_coherent (π : Degree ≃o Degree) (I J : CountableIdeal) + (ρ : I ≃o I) (σ : J ≃o J) (hρ : RestrictsTo π I ρ) (hσ : RestrictsTo π J σ) + (d : Degree) (hi : d ∈ I.carrier) (hj : d ∈ J.carrier) : + (ρ ⟨d,hi⟩).val = (σ ⟨d,hj⟩).val := (hρ ⟨d,hi⟩).symm.trans (hσ ⟨d,hj⟩) + +theorem prescribed_restrictions_extend (π : Degree ≃o Degree) (I J : CountableIdeal) + (ρ : I ≃o I) (σ : J ≃o J) (hρ : RestrictsTo π I ρ) (hσ : RestrictsTo π J σ) + (hIJ : I.carrier ⊆ J.carrier) : Extends hIJ ρ σ := by + intro d + exact (prescribed_restrictions_coherent π I J ρ σ hρ hσ d.val d.property (hIJ d.property)).symm + +theorem prescribed_supermodel_extension (π : Degree ≃o Degree) (M N : ZFSet.{u}) + [Countable (Conditions M)] [Countable (Conditions N)] + (hM : Transitive M) (hTM : SourceT M) (hN : Transitive N) (hTN : SourceT N) + (hMN : M ⊆ N) + (himages : π (degree (OracleJump.jump FixedArithmetic.zero)) ⊔ + π.symm (degree (OracleJump.jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hTM).carrier) + (ρ : modelIdeal M hM hTM ≃o modelIdeal M hM hTM) (hρ : RestrictsTo π _ ρ) : + ∃ σ : modelIdeal N hN hTN ≃o modelIdeal N hN hTN, + RestrictsTo π _ σ ∧ Extends (modelIdeal_inclusion M N hM hTM hN hTN hMN) ρ σ ∧ + Persistent _ σ ∧ automorphismSet σ ∈ relativeModel N (groundReals N) ∧ + SetGenericallyPersistent N _ σ := by + have hIJ := modelIdeal_inclusion M N hM hTM hN hTN hMN + obtain ⟨σ,hr,hp,hd,hg⟩ := prescribed_model_restriction π N hN hTN (hIJ himages) + exact ⟨σ,hr,prescribed_restrictions_extend π _ _ ρ σ hρ hr hIJ,hp,hd,hg⟩ + +theorem prescribed_generic_extension (π : Degree ≃o Degree) + (M : ZFSet.{u}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (himages : π (degree (OracleJump.jump FixedArithmetic.zero)) ⊔ + π.symm (degree (OracleJump.jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (ho : o ∈ M) + (hos : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (ht : ⊤ ∈ G.carrier) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) (hρ : RestrictsTo π _ ρ) : + let E := genericExtensionSet M c G.carrier + let hE := genericExtensionSet_transitive M c hM G.carrier + let hTE := extension_sourceT M hM hT hc ho hos G hG ht + ∃ σ : modelIdeal E hE hTE ≃o modelIdeal E hE hTE, + RestrictsTo π _ σ ∧ + (∀ d, ∀ hd : d ∈ (modelIdeal M hM hT).carrier, + ∀ he : d ∈ (modelIdeal E hE hTE).carrier, (σ ⟨d,he⟩).val = (ρ ⟨d,hd⟩).val) ∧ + Persistent _ σ ∧ automorphismSet σ ∈ relativeModel E (groundReals E) ∧ + SetGenericallyPersistent E _ σ := by + intro E hE hTE + have hME := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht + obtain ⟨σ,hr,_,hp,hd,hg⟩ := prescribed_supermodel_extension π M E hM hT hE hTE hME himages ρ hρ + exact ⟨σ,hr,fun d hi hj => (prescribed_restrictions_coherent π _ _ ρ σ hρ hr d hi hj).symm, + hp,hd,hg⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedGroundOracleProgram.lean b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedGroundOracleProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3d05afa50852bdcd1ab1ba6c1f051a0df1b97a5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedGroundOracleProgram.lean @@ -0,0 +1,65 @@ +import OAI.Computability.DegreeRigidity.Representation.PrescribedColumnPrefixProgram +import OAI.Computability.DegreeRigidity.CohenForcing.CohenGroundProgram + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames AtomicForcing BoundedForcing +open CohenGroundPoset InternalCountableOrdinals ElementaryModel SetDegreeDecoding PersistentRestrictions +open FullSetForcing CohenColumnRealName OracleJump TableIndices IndexMatrix +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem prescribed_ground_oracle_program (π : Degree ≃o Degree) + (M K a : ZFSet.{0}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (hK : FirstUncountable M K) (ha : a ∈ K) + (himages : π (degree (jump FixedArithmetic.zero)) ⊔ + π.symm (degree (jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) (hρ : RestrictsTo π _ ρ) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) : + let c := poset K + let E := genericExtensionSet M c G.carrier + let hE := genericExtensionSet_transitive M c hM G.carrier + let hTE := extension_sourceT M hM hT (manyColumn_internal M K hM hT hK.2.1).1 + (manyColumn_internal M K hM hT hK.2.1).2 (InternalCollapse.orderSet_pair c) + G hG (G.upper le_top G.nonempty.choose_spec) + let I := modelIdeal M hM hT + let J := modelIdeal E hE hTE + ∃ (δ : Ordinal.{0}) (P : Oracle) (φ : SentenceForm) (R : Oracle), + δ.toZFSet ∈ M ∧ φ.bound ≤ 2 ∧ P ∈ modelReals E ∧ + realCode R ∈ M ∧ degree R = π.symm (degree (jump FixedArithmetic.zero)) ∧ + let N := RealGeneratedModel.hull M (realCode P) + RealGeneratedModel.Contains M (realCode P) N ∧ (N : Set ZFSet.{0}).Countable ∧ + ∃ fX : Name (Conditions c), fX.encode (label c) ∈ N ∧ + (∀ H : GenericFilter (Conditions c), GroundGeneric N H → + fX.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet N c H.carrier)) δ) + φ (fun _ : Fin φ.bound => realCode P) ∧ + OwnDegreeExtension (genericExtensionSet N c H.carrier) + (idealSet I) (automorphismSet ρ) (fX.val H.carrier)) ∧ + ∃ GX : GenericFilter (Conditions c), GroundGeneric N GX ∧ + genericExtensionSet N c GX.carrier = E ∧ + (∃ σ : J ≃o J, RestrictsTo π J σ ∧ fX.val GX.carrier = automorphismSet σ) ∧ + ∃ A₀ : Oracle, ∃ d ℓ : ℕ, + (realName K a).val GX.carrier = realCode A₀ ∧ + ∀ H : GenericFilter (Conditions c), GroundGeneric N H → + ∀ A : Oracle, (realName K a).val H.carrier = realCode A → + (∀ n < ℓ, A n = A₀ n) → ∃ X : Oracle, + Represents (join A (iterate R 5)) (machine d) X ∧ + ∃ u ∈ degreeUniverse (groundReals (genericExtensionSet N c H.carrier)), + ∃ v ∈ degreeUniverse (groundReals (genericExtensionSet N c H.carrier)), + realCode A ∈ u ∧ realCode X ∈ v ∧ ZFSet.pair u v ∈ fX.val H.carrier := by + intro c E hE hTE I J + obtain ⟨δ,P,φ,R,hδ,hφ,hP,hRM,hR,hN,hNct,fX,hfX,hall,GX,hGX,hExt,hσ,A₀,d,ℓ,hA₀,hprog⟩ := + prescribed_column_prefix_program π M K a hM hT hK ha himages ρ hρ G hG + let N := RealGeneratedModel.hull M (realCode P) + obtain ⟨e,he⟩ := InternalCohen.selected_column_table_simulation N K a hN.1 hN.2.1 + (hN.2.2.1 hK.2.1) ha R (hN.2.2.1 hRM) 5 d + refine ⟨δ,P,φ,R,hδ,hφ,hP,hRM,hR,hN,hNct,fX,hfX,hall,GX,hGX,hExt,hσ,A₀,e,ℓ,hA₀,?_⟩ + intro H hH A hv hprefix + obtain ⟨X,hX,hrel⟩ := hprog H hH A hv hprefix + exact ⟨X,he H hH A hv X hX,hrel⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedModelRestriction.lean b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedModelRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..22c2fd42fa2bf1aff67e767bd05ca04798bb4e4f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedModelRestriction.lean @@ -0,0 +1,51 @@ +import OAI.Computability.DegreeRigidity.Representation.GlobalJumpRestriction +import OAI.Computability.DegreeRigidity.Representation.GenericDescentDefinition + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory ElementaryModel SetDegreeDecoding +open PersistentRestrictions ArithmeticTree +universe u + +theorem prescribed_model_restriction (π : Degree ≃o Degree) + (M : ZFSet.{u}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (himages : π (degree (OracleJump.jump FixedArithmetic.zero)) ⊔ + π.symm (degree (OracleJump.jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) : + ∃ ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT, + RestrictsTo π _ ρ ∧ Persistent _ ρ ∧ + automorphismSet ρ ∈ relativeModel M (groundReals M) ∧ + SetGenericallyPersistent M _ ρ := by + obtain ⟨ρ,hr,hp⟩ := PersistentLocality.global_jump_restriction π _ + (modelIdeal_jump M hM hT) himages + have hd := persistent_modelIdeal_graph_mem_relativeModel M hM hT ρ hp + have hI := relativeModel_subset M _ (ground_idealSet_mem_relativeModel M hM hT) + have hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ (modelIdeal M hM hT).carrier := + ⟨_,sourceT_real_jump M hM hT (sourceT_zero_real M hM hT),rfl⟩ + exact ⟨ρ,hr,hp,hd,(setGenericallyPersistent_iff M hM hT _ hI ρ + (relativeModel_subset M _ hd) hz).mpr hp⟩ + +theorem prescribed_restriction_unique (π : Degree ≃o Degree) (I : CountableIdeal) + (ρ σ : I ≃o I) (hρ : RestrictsTo π I ρ) (hσ : RestrictsTo π I σ) : ρ = σ := by + apply DFunLike.ext + intro x + exact Subtype.ext ((hρ x).symm.trans (hσ x)) + +theorem prescribed_model_one_real_definition (π : Degree ≃o Degree) + (M : ZFSet.{u}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (himages : π (degree (OracleJump.jump FixedArithmetic.zero)) ⊔ + π.symm (degree (OracleJump.jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) : + ∃ ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT, + RestrictsTo π _ ρ ∧ SetGenericallyPersistent M _ ρ ∧ + automorphismSet ρ ∈ relativeModel M (groundReals M) ∧ + ∃ (δ : Ordinal.{u}) (P : Oracle) (p : SentenceForm), + δ.toZFSet ∈ M ∧ P ∈ modelReals M ∧ p.bound ≤ 2 ∧ + realCode P ∈ level (groundReals M) δ ∧ + automorphismSet ρ = definedSubset (level (groundReals M) δ) p + (fun _ : Fin p.bound => realCode P) := by + obtain ⟨ρ,hr,hp,hd,hg⟩ := prescribed_model_restriction π M hM hT himages + exact ⟨ρ,hr,hg,hd,persistent_graph_one_real_definition M hM hT ρ hp⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedOneRealNames.lean b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedOneRealNames.lean new file mode 100644 index 0000000000000000000000000000000000000000..f503e8cda5cb8935418273dca29516d9b2ce1e91 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedOneRealNames.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.Representation.PrescribedGenericRestriction +import OAI.Computability.DegreeRigidity.Representation.GenericOneRealNames +import OAI.Computability.DegreeRigidity.SetModels.NoNewOrdinals + +namespace OAI + +namespace TuringRigidity.FullSetForcing +open TransitiveNameModel BoundedSetTheory ElementaryModel SetDegreeDecoding +open PersistentRestrictions RecursiveNames CountableForcing AtomicForcing RelativeConstructible ArithmeticTree +universe u + +theorem prescribed_one_real_names (π : Degree ≃o Degree) + (M : ZFSet.{u}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (himages : π (degree (OracleJump.jump FixedArithmetic.zero)) ⊔ + π.symm (degree (OracleJump.jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (ho : o ∈ M) + (hos : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) (ht : ⊤ ∈ G.carrier) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) (hρ : RestrictsTo π _ ρ) : + let E := genericExtensionSet M c G.carrier + let hE := genericExtensionSet_transitive M c hM G.carrier + let hTE := extension_sourceT M hM hT hc ho hos G hG ht + let J := modelIdeal E hE hTE + ∃ hIJ : (modelIdeal M hM hT).carrier ⊆ J.carrier, ∃ σ : J ≃o J, + RestrictsTo π J σ ∧ Extends hIJ ρ σ ∧ SetGenericallyPersistent E J σ ∧ + ∃ (δ : Ordinal.{u}) (P : Oracle) (p : SentenceForm), + δ.toZFSet ∈ M ∧ P ∈ modelReals E ∧ p.bound ≤ 2 ∧ + realCode P ∈ level (groundReals E) δ ∧ + automorphismSet σ = definedSubset (level (groundReals E) δ) p + (fun _ : Fin p.bound => realCode P) ∧ + ∃ f a : Name (Conditions c), + f.encode (label c) ∈ M ∧ a.encode (label c) ∈ M ∧ + f.val G.carrier = automorphismSet σ ∧ a.val G.carrier = realCode P := by + intro E hE hTE J + have hME := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht + have hIJ := modelIdeal_inclusion M E hM hT hE hTE hME + obtain ⟨σ,hr,he,hp,hd,hg⟩ := prescribed_supermodel_extension π M E hM hT hE hTE hME himages ρ hρ + obtain ⟨δ,P,p,hδ,hP,hpB,hPL,hdef⟩ := persistent_graph_one_real_definition E hE hTE σ hp + have hδM := extension_ordinal_ground M c hM hT G.carrier δ hδ + obtain ⟨f,hf,hfv⟩ := (mem_extensionSet M c G.carrier _).mp (relativeModel_subset E _ hd) + obtain ⟨a,ha,hav⟩ := (mem_extensionSet M c G.carrier (realCode P)).mp hP + exact ⟨hIJ,σ,hr,he,hg,δ,P,p,hδM,hP,hpB,hPL,hdef,f,a,hf,ha,hfv,hav⟩ + +theorem prescribed_output_name (π : Degree ≃o Degree) + (M : ZFSet.{u}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (himages : π (degree (OracleJump.jump FixedArithmetic.zero)) ⊔ + π.symm (degree (OracleJump.jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (ho : o ∈ M) + (hos : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) (ht : ⊤ ∈ G.carrier) + (A : Oracle) (hA : A ∈ modelReals (genericExtensionSet M c G.carrier)) : + ∃ B : Oracle, ∃ t : Name (Conditions c), + t.encode (label c) ∈ M ∧ t.val G.carrier = realCode B ∧ degree B = π (degree A) := by + have hE := genericExtensionSet_transitive M c hM G.carrier + have hTE := extension_sourceT M hM hT hc ho hos G hG ht + have hME := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht + obtain ⟨σ,hr,_,_,_⟩ := prescribed_model_restriction π _ hE hTE + (modelIdeal_inclusion M _ hM hT hE hTE hME himages) + obtain ⟨B,t,ht,hv,hd⟩ := model_automorphism_output_name M c G.carrier hE hTE σ A hA + exact ⟨B,t,ht,hv,hd.trans (hr ⟨degree A,⟨A,hA,rfl⟩⟩).symm⟩ + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedOracleValue.lean b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedOracleValue.lean new file mode 100644 index 0000000000000000000000000000000000000000..cdf09dfa3c8b355d9c76d0a78fd25130b98def8e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedOracleValue.lean @@ -0,0 +1,82 @@ +import OAI.Computability.DegreeRigidity.Representation.PrescribedUnrestrictedGroundProgram +import OAI.Computability.DegreeRigidity.Representation.OwnProgramValue +import OAI.Computability.DegreeRigidity.CohenForcing.CohenProgramTotality + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames AtomicForcing BoundedForcing +open CohenGroundPoset InternalCountableOrdinals ElementaryModel SetDegreeDecoding PersistentRestrictions +open FullSetForcing CohenColumnRealName OracleJump TableIndices IndexMatrix +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem prescribed_oracle_value (π : Degree ≃o Degree) + (M K a : ZFSet.{0}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (hK : FirstUncountable M K) (ha : a ∈ K) + (himages : π (degree (jump FixedArithmetic.zero)) ⊔ + π.symm (degree (jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) (hρ : RestrictsTo π _ ρ) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) : + let c := poset K + let E := genericExtensionSet M c G.carrier + let hE := genericExtensionSet_transitive M c hM G.carrier + let hTE := extension_sourceT M hM hT (manyColumn_internal M K hM hT hK.2.1).1 + (manyColumn_internal M K hM hT hK.2.1).2 (InternalCollapse.orderSet_pair c) + G hG (G.upper le_top G.nonempty.choose_spec) + let I := modelIdeal M hM hT + let J := modelIdeal E hE hTE + ∃ (δ : Ordinal.{0}) (P : Oracle) (φ : SentenceForm) (R : Oracle), + δ.toZFSet ∈ M ∧ φ.bound ≤ 2 ∧ P ∈ modelReals E ∧ + realCode R ∈ M ∧ degree R = π.symm (degree (jump FixedArithmetic.zero)) ∧ + let N := RealGeneratedModel.hull M (realCode P) + RealGeneratedModel.Contains M (realCode P) N ∧ (N : Set ZFSet.{0}).Countable ∧ + ∃ fX : Name (Conditions c), fX.encode (label c) ∈ N ∧ + (∀ H : GenericFilter (Conditions c), GroundGeneric N H → + fX.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet N c H.carrier)) δ) + φ (fun _ : Fin φ.bound => realCode P) ∧ + OwnDegreeExtension (genericExtensionSet N c H.carrier) + (idealSet I) (automorphismSet ρ) (fX.val H.carrier)) ∧ + ∃ GX : GenericFilter (Conditions c), GroundGeneric N GX ∧ + genericExtensionSet N c GX.carrier = E ∧ + (∃ σ : J ≃o J, RestrictsTo π J σ ∧ fX.val GX.carrier = automorphismSet σ) ∧ + ∃ (A₀ : Oracle) (p : OracleCode), + (realName K a).val GX.carrier = realCode A₀ ∧ + (∀ H : GenericFilter (Conditions c), GroundGeneric N H → + ∀ A : Oracle, (realName K a).val H.carrier = realCode A → + OwnProgramAt (genericExtensionSet N c H.carrier) (fX.val H.carrier) + p (iterate R 5) A) ∧ + (∀ H : GenericFilter (Conditions c), GroundGeneric N H → + genericExtensionSet N c H.carrier = E → + ∀ A : Oracle, (realName K a).val H.carrier = realCode A → + GenericIdentity.Total p (iterate R 5) A ∧ + degree (GenericIdentity.value p (iterate R 5) A) = π (degree A)) ∧ + ∃ D : ℕ → List Bool → Prop, (∀ n, FiniteShuffle.DenseOpen (D n)) ∧ + (∀ A, ShuffleRequirements.GenericFor D A → GenericIdentity.Total p (iterate R 5) A) ∧ + ContinuousOn (GenericIdentity.value p (iterate R 5)) + {A | ShuffleRequirements.GenericFor D A} := by + intro c E hE hTE I J + obtain ⟨δ,P,φ,R,hδ,hφ,hP,hRM,hR,hN,hNct,fX,hfX,hall,GX,hGX,hExt,hσ,A₀,d,hA₀,hprog⟩ := + prescribed_unrestricted_ground_program π M K a hM hT hK ha himages ρ hρ G hG + let N := RealGeneratedModel.hull M (realCode P) + obtain ⟨p,hp⟩ := own_program_of_table d + have hown : ∀ H : GenericFilter (Conditions c), GroundGeneric N H → + ∀ A : Oracle, (realName K a).val H.carrier = realCode A → + OwnProgramAt (genericExtensionSet N c H.carrier) (fX.val H.carrier) p (iterate R 5) A := by + intro H hH A hv + exact hp _ _ _ _ (hprog H hH A hv) + refine ⟨δ,P,φ,R,hδ,hφ,hP,hRM,hR,hN,hNct,fX,hfX,hall,GX,hGX,hExt,hσ,A₀,p,hA₀,hown,?_,?_⟩ + · intro H hH he A hv + obtain ⟨σ,hσπ,hσf⟩ := hσ + have hfEq := defined_value_extension_eq N c δ (realCode P) φ fX + (fun H hH => (hall H hH).1) H GX hH hGX (he.trans hExt.symm) + have hA := hown H hH A hv + rw [he,hfEq,hσf] at hA + exact hA.prescribed E J σ π hσπ p (iterate R 5) A + · exact column_program_generic_totality N K a hN.1 hN.2.1 (hN.2.2.1 hK.2.1) ha GX hGX + p (iterate R 5) (fun H hH A hv => (hown H hH A hv).1) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedRealHullExtension.lean b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedRealHullExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..49130f3db512c4be5a4c7638df7187e01b297d5d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedRealHullExtension.lean @@ -0,0 +1,72 @@ +import OAI.Computability.DegreeRigidity.Representation.OriginalRealUniformExtension +import OAI.Computability.DegreeRigidity.Representation.OwnDegreeExtensionMeaning +import OAI.Computability.DegreeRigidity.Representation.PrescribedOneRealNames + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames AtomicForcing BoundedForcing +open CohenGroundPoset InternalCountableOrdinals ElementaryModel SetDegreeDecoding PersistentRestrictions +open FullSetForcing OriginalRealDefinitionTransport +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem prescribed_real_hull_extension (π : Degree ≃o Degree) + (M K : ZFSet.{0}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (hK : FirstUncountable M K) + (himages : π (degree (OracleJump.jump FixedArithmetic.zero)) ⊔ + π.symm (degree (OracleJump.jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) (hρ : RestrictsTo π _ ρ) + (G : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hG : GroundGeneric M G) : + let c := conditions (ZFSet.prod K ZFSet.omega) + let E := genericExtensionSet M c G.carrier + let hE := genericExtensionSet_transitive M c hM G.carrier + let hTE := extension_sourceT M hM hT (manyColumn_internal M K hM hT hK.2.1).1 + (manyColumn_internal M K hM hT hK.2.1).2 (InternalCollapse.orderSet_pair c) + G hG (G.upper le_top G.nonempty.choose_spec) + let I := modelIdeal M hM hT + let J := modelIdeal E hE hTE + ∃ (δ : Ordinal.{0}) (P : Oracle) (φ : SentenceForm), + δ.toZFSet ∈ M ∧ φ.bound ≤ 2 ∧ P ∈ modelReals E ∧ + let N := RealGeneratedModel.hull M (realCode P) + RealGeneratedModel.Contains M (realCode P) N ∧ (N : Set ZFSet.{0}).Countable ∧ + ∃ fX : Name (Conditions c), fX.encode (label c) ∈ N ∧ + (∀ H : GenericFilter (Conditions c), GroundGeneric N H → + fX.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet N c H.carrier)) δ) + φ (fun _ : Fin φ.bound => realCode P) ∧ + OwnDegreeExtension (genericExtensionSet N c H.carrier) + (idealSet I) (automorphismSet ρ) (fX.val H.carrier)) ∧ + ∃ GX : GenericFilter (Conditions c), GroundGeneric N GX ∧ + genericExtensionSet N c GX.carrier = E ∧ + ∃ σ : J ≃o J, RestrictsTo π J σ ∧ fX.val GX.carrier = automorphismSet σ := by + intro c E hE hTE I J + have hc := (manyColumn_internal M K hM hT hK.2.1).1 + have ho := (manyColumn_internal M K hM hT hK.2.1).2 + have ht : (⊤ : Conditions c) ∈ G.carrier := G.upper le_top G.nonempty.choose_spec + have hI : idealSet I ∈ M := relativeModel_subset M _ (ground_idealSet_mem_relativeModel M hM hT) + have hρM : automorphismSet ρ ∈ M := relativeModel_subset M _ + (persistent_modelIdeal_graph_mem_relativeModel M hM hT ρ + (persistent_of_global_restriction π I ρ hρ)) + have hct : (M : Set ZFSet.{0}).Countable := by + apply (Set.countable_range (label M)).mono + intro x hx; exact label_surjective M hx + obtain ⟨hIJ,σ,hr,he,_,δ,P,φ,hδ,hP,hφ,hPL,hdef,f,a,hf,ha,hfv,hav⟩ := + prescribed_one_real_names π M hM hT himages hc ho (InternalCollapse.orderSet_pair c) G hG ht ρ hρ + have hreal : a.val G.carrier ⊆ ZFSet.omega := hav.symm ▸ realCode_subset P + have hX : a.val G.carrier ∈ level (groundReals E) δ := hav.symm ▸ hPL + have hdef' : f.val G.carrier = definedSubset (level (groundReals E) δ) φ + (fun _ : Fin φ.bound => a.val G.carrier) := by + rw [hav,hfv]; exact hdef + have hext : OwnDegreeExtension E (idealSet I) (automorphismSet ρ) (f.val G.carrier) := + (own_degree_extension_iff E hE hTE I ρ _).mpr ⟨hIJ,σ,hfv.symm,he⟩ + obtain ⟨hN,hNct,fX,hfX,hall,GX,hGX,hExt,hval⟩ := + original_uniform_extension M K (idealSet I) (automorphismSet ρ) hM hT hct hK hI hρM + a f ha hf G hG hreal δ hδ φ hX hdef' hext + rw [hav] at hN hNct hfX hall hGX hExt + exact ⟨δ,P,φ,hδ,hφ,hP,hN,hNct,fX,hfX,hall,GX,hGX,hExt,σ,hr,hval.trans hfv⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedUnrestrictedGroundProgram.lean b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedUnrestrictedGroundProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d8ec67d2ae04c9d3da5db4e00ea882b51fda3d9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/PrescribedUnrestrictedGroundProgram.lean @@ -0,0 +1,63 @@ +import OAI.Computability.DegreeRigidity.Representation.PrescribedGroundOracleProgram +import OAI.Computability.DegreeRigidity.Syntax.DefinedPrefixRemoval + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames AtomicForcing BoundedForcing +open CohenGroundPoset InternalCountableOrdinals ElementaryModel SetDegreeDecoding PersistentRestrictions +open FullSetForcing CohenColumnRealName OracleJump TableIndices IndexMatrix +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem prescribed_unrestricted_ground_program (π : Degree ≃o Degree) + (M K a : ZFSet.{0}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (hK : FirstUncountable M K) (ha : a ∈ K) + (himages : π (degree (jump FixedArithmetic.zero)) ⊔ + π.symm (degree (jump FixedArithmetic.zero)) ∈ (modelIdeal M hM hT).carrier) + (ρ : modelIdeal M hM hT ≃o modelIdeal M hM hT) (hρ : RestrictsTo π _ ρ) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) : + let c := poset K + let E := genericExtensionSet M c G.carrier + let hE := genericExtensionSet_transitive M c hM G.carrier + let hTE := extension_sourceT M hM hT (manyColumn_internal M K hM hT hK.2.1).1 + (manyColumn_internal M K hM hT hK.2.1).2 (InternalCollapse.orderSet_pair c) + G hG (G.upper le_top G.nonempty.choose_spec) + let I := modelIdeal M hM hT + let J := modelIdeal E hE hTE + ∃ (δ : Ordinal.{0}) (P : Oracle) (φ : SentenceForm) (R : Oracle), + δ.toZFSet ∈ M ∧ φ.bound ≤ 2 ∧ P ∈ modelReals E ∧ + realCode R ∈ M ∧ degree R = π.symm (degree (jump FixedArithmetic.zero)) ∧ + let N := RealGeneratedModel.hull M (realCode P) + RealGeneratedModel.Contains M (realCode P) N ∧ (N : Set ZFSet.{0}).Countable ∧ + ∃ fX : Name (Conditions c), fX.encode (label c) ∈ N ∧ + (∀ H : GenericFilter (Conditions c), GroundGeneric N H → + fX.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet N c H.carrier)) δ) + φ (fun _ : Fin φ.bound => realCode P) ∧ + OwnDegreeExtension (genericExtensionSet N c H.carrier) + (idealSet I) (automorphismSet ρ) (fX.val H.carrier)) ∧ + ∃ GX : GenericFilter (Conditions c), GroundGeneric N GX ∧ + genericExtensionSet N c GX.carrier = E ∧ + (∃ σ : J ≃o J, RestrictsTo π J σ ∧ fX.val GX.carrier = automorphismSet σ) ∧ + ∃ A₀ : Oracle, ∃ d : ℕ, + (realName K a).val GX.carrier = realCode A₀ ∧ + ∀ H : GenericFilter (Conditions c), GroundGeneric N H → + ∀ A : Oracle, (realName K a).val H.carrier = realCode A → + ∃ X : Oracle, + Represents (join A (iterate R 5)) (machine d) X ∧ + ∃ u ∈ degreeUniverse (groundReals (genericExtensionSet N c H.carrier)), + ∃ v ∈ degreeUniverse (groundReals (genericExtensionSet N c H.carrier)), + realCode A ∈ u ∧ realCode X ∈ v ∧ ZFSet.pair u v ∈ fX.val H.carrier := by + intro c E hE hTE I J + obtain ⟨δ,P,φ,R,hδ,hφ,hP,hRM,hR,hN,hNct,fX,hfX,hall,GX,hGX,hExt,hσ,A₀,d,ℓ,hA₀,hprog⟩ := + prescribed_ground_oracle_program π M K a hM hT hK ha himages ρ hρ G hG + let N := RealGeneratedModel.hull M (realCode P) + obtain ⟨e,he⟩ := remove_defined_program_prefix N K a hN.1 hN.2.1 + (hN.2.2.1 hK.2.1) ha δ (realCode P) φ fX (fun H hH => (hall H hH).1) + (iterate R 5) A₀ d ℓ hprog + exact ⟨δ,P,φ,R,hδ,hφ,hP,hRM,hR,hN,hNct,fX,hfX,hall,GX,hGX,hExt,hσ,A₀,e,hA₀,he⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/RealCollapseReconstruction.lean b/lean/OAI/Computability/DegreeRigidity/Representation/RealCollapseReconstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..898c7e6558c2042f87e9483f368c374ad2231cc5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/RealCollapseReconstruction.lean @@ -0,0 +1,42 @@ +import OAI.Computability.DegreeRigidity.SetModels.CountedRealsPresentation +import OAI.Computability.DegreeRigidity.Syntax.WeakExtensionContext +import OAI.Computability.DegreeRigidity.SetModels.CollapseInternalCountingWithoutChoice + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory.InternalCollapse +open TransitiveNameModel CountableForcing AtomicForcing SetDegreeDecoding +open PersistentRestrictions +universe u +attribute [local instance] order collapsePreorder + +theorem real_collapse_reconstructs (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) + {R c : ZFSet.{u}} (hRM : R ∈ M) (hcM : c ∈ M) + (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix R p) (hne : ∃ x, x ∈ R) + (hreal : ∀ x ∈ R, ∃ B : Oracle, SetModelReals.realSet B = x) + (I : CountableIdeal) + (hIR : ∀ d, d ∈ I.carrier ↔ ∃ B : Oracle, SetModelReals.realSet B ∈ R ∧ degree B = d) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) : + automorphismSet ρ ∈ genericExtensionSet M c G.carrier := by + have hω := omega_mem M hM hS.bounded hI + have h0 : (∅ : ZFSet.{u}) ∈ c := + (hc ∅).mpr ⟨hM _ hω _ ZFSet.omega_zero,prefix_empty R⟩ + let _ := top c h0 + have htop : ⊤ ∈ G.carrier := by + obtain ⟨p,hp⟩ := G.nonempty + exact G.upper le_top hp + have ho := orderSet_mem_without_choice M hM hP hU hPow hS.bounded hcM + have C := BoundedForcing.extension_context_without_choice M hM hP hU hPow hS hR hI + hcM ho (orderSet_pair c) G hG htop + have hME := ground_inclusion_set M c hM hP hU hPow hS.bounded hR hI hcM G.carrier htop + have hcount := internal_counting_without_choice M hM hP hU hPow hS.bounded hR hI + hRM hcM hc hne G hG + exact SetModelCountability.persistent_mem_of_counted_reals C (hME hRM) hreal hcount I hIR ρ hρ hz + +end TuringRigidity.BoundedSetTheory.InternalCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/RealGeneratedModel.lean b/lean/OAI/Computability/DegreeRigidity/Representation/RealGeneratedModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..98b9b60989c47ece36eb6a948da01c2e86d4d51a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/RealGeneratedModel.lean @@ -0,0 +1,88 @@ +import OAI.Computability.DegreeRigidity.Syntax.BooleanFilterReconstruction + +namespace OAI + +namespace TuringRigidity.RealGeneratedModel +open TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax InternalBooleanBits +open InternalGeneratedAlgebra InternalProjectedGeneric InternalBooleanTop + +def Contains (M X N : ZFSet.{0}) : Prop := + Transitive N ∧ SourceT N ∧ M ⊆ N ∧ X ∈ N + +noncomputable def hull (M X : ZFSet.{0}) : ZFSet.{0} := by + classical + exact if h : ∃ N, Contains M X N then + h.choose.sep (fun z => ∀ N, Contains M X N → z ∈ N) + else ∅ + +theorem mem_hull (M X z : ZFSet.{0}) (h : ∃ N, Contains M X N) : + z ∈ hull M X ↔ ∀ N, Contains M X N → z ∈ N := by + rw [hull,dite_eq_left h,ZFSet.mem_sep] + exact ⟨fun hz => hz.2,fun hz => ⟨hz h.choose h.choose_spec,hz⟩⟩ + +theorem hull_eq_of_least (M X H : ZFSet.{0}) (hH : Contains M X H) + (hleast : ∀ N, Contains M X N → H ⊆ N) : hull M X = H := by + apply ZFSet.ext; intro z + rw [mem_hull M X z ⟨H,hH⟩] + exact ⟨fun hz => hz H hH,fun hz N hN => hleast N hN hz⟩ + +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + codeOrder codePreorder + +theorem projected_extension_eq_hull (M c B Q A : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hAM : A ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) (hA : Closed c B Q A) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) + (hAe : A = generated c B Q (seeds c B E)) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (hGt : ⊤ ∈ G.carrier) : + genericExtensionSet M (positive A) (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier = + hull M ((InternalNiceName.nice E : RecursiveNames.Name (Conditions c)).val G.carrier) := by + have hcA := top_mem_part M c B Q A hM hT hc hBM hB hQ hA + have hc0 : c ≠ ∅ := fun he => ZFSet.notMem_empty _ + (Eq.mp (congrArg (fun d => label c ⊤ ∈ d) he) (label_mem c ⊤)) + let _ := booleanTop c A hcA hc0 + have ht : label (positive A) ⊤ = c := label_booleanTop c A hcA hc0 + have hbits (n : ℕ) : bitCode c (E n) ∈ A := by + rw [hAe] + exact seeds_subset c B Q _ (fun _ h => (ZFSet.mem_sep.mp h).1) + (bit_mem_seeds M c B hM hT hc hB E (fun n => (hE n).1) n) + obtain ⟨hN,hTN,hMN,hXN,_,_⟩ := InternalBooleanExtension.projected_extension_sandwich + M c B Q A hM hT hc hBM hAM hB hQ hA ht E hE hgraph hbits G hG hGt + symm + apply hull_eq_of_least M _ _ ⟨hN,hTN,hMN,hXN⟩ + intro N hN + exact BooleanFilterReconstruction.projected_extension_least_for_real M N c B Q A hM hT + hN.1 hN.2.1 hN.2.2.1 hc hBM hQM hAM hB hQ hA E hE hgraph hAe G hG hGt hN.2.2.2 + +theorem hull_properties (M c B Q A : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hAM : A ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) (hA : Closed c B Q A) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) + (hAe : A = generated c B Q (seeds c B E)) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (hGt : ⊤ ∈ G.carrier) : + let X := (InternalNiceName.nice E : RecursiveNames.Name (Conditions c)).val G.carrier + Contains M X (hull M X) ∧ + genericFilterSet (positive A) (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier ∈ hull M X ∧ + hull M X ⊆ genericExtensionSet M c G.carrier := by + have hcA := top_mem_part M c B Q A hM hT hc hBM hB hQ hA + have hc0 : c ≠ ∅ := fun he => ZFSet.notMem_empty _ + (Eq.mp (congrArg (fun d => label c ⊤ ∈ d) he) (label_mem c ⊤)) + let _ := booleanTop c A hcA hc0 + have ht : label (positive A) ⊤ = c := label_booleanTop c A hcA hc0 + have hbits (n : ℕ) : bitCode c (E n) ∈ A := by + rw [hAe] + exact seeds_subset c B Q _ (fun _ h => (ZFSet.mem_sep.mp h).1) + (bit_mem_seeds M c B hM hT hc hB E (fun n => (hE n).1) n) + obtain ⟨hN,hTN,hMN,hXN,hHN,hNG⟩ := InternalBooleanExtension.projected_extension_sandwich + M c B Q A hM hT hc hBM hAM hB hQ hA ht E hE hgraph hbits G hG hGt + have he := projected_extension_eq_hull M c B Q A hM hT hc hBM hQM hAM hB hQ hA E hE hgraph hAe G hG hGt + dsimp only + rw [←he] + exact ⟨⟨hN,hTN,hMN,hXN⟩,hHN,hNG⟩ + +end TuringRigidity.RealGeneratedModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/RealGeneratedPart.lean b/lean/OAI/Computability/DegreeRigidity/Representation/RealGeneratedPart.lean new file mode 100644 index 0000000000000000000000000000000000000000..ffbfdf655e2ac40d2353e70a3767c0ed8e9b9411 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/RealGeneratedPart.lean @@ -0,0 +1,96 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularProjection +import OAI.Computability.DegreeRigidity.SetModels.GeneratedBooleanPart + +namespace OAI + +namespace TuringRigidity.RealGeneratedPart +open Set CountableForcing ForcingProjection RegularCompletion BooleanProjection +open GeneratedBooleanPart RegularProjection +universe u +variable {P : Type u} [Preorder P] + +def tagLower (U : Set P) : LowerSet P where + carrier := {p | ∃ q ∈ U, p ≤ q} + lower' := by rintro p q hpq ⟨r,hr,hqr⟩; exact ⟨r,hr,hpq.trans hqr⟩ + +def bit (N : ℕ → Set P) (n : ℕ) : Algebra P := + Heyting.Regular.toRegular (tagLower (N n)) + +noncomputable def part (N : ℕ → Set P) : CompleteSublattice (Algebra P) := + generated (Set.range (bit N)) + +theorem bit_mem_part (N : ℕ → Set P) (n : ℕ) : bit N n ∈ part N := + subset_generated _ ⟨n,rfl⟩ + +theorem part_compl (N : ℕ → Set P) (a : Algebra P) (ha : a ∈ part N) : aᶜ ∈ part N := + generated_compl _ a ha + +noncomputable def projection (N : ℕ → Set P) : Projection P (PartPositive (part N)) := + originalProjection (part N) (part_compl N) + +def decision (N : ℕ → Set P) (n : ℕ) : Set P := + {p | p ∈ tagLower (N n) ∨ p ∈ (tagLower (N n))ᶜ} + +theorem decision_dense (N : ℕ → Set P) (n : ℕ) : Dense (decision N n) := by + classical + intro p + by_cases h : ∃ q, q ≤ p ∧ q ∈ tagLower (N n) + · obtain ⟨q,hqp,hq⟩ := h + exact ⟨q,hqp,Or.inl hq⟩ + · exact ⟨p,le_rfl,Or.inr ((mem_compl _ p).mpr (fun q hqp hq => h ⟨q,hqp,hq⟩))⟩ + +def value (N : ℕ → Set P) (G : GenericFilter P) : Set ℕ := + {n | ∃ p ∈ G.carrier, p ∈ N n} + +theorem bit_hit_iff (N : ℕ → Set P) (G : GenericFilter P) + (hG : GenericFor (decision N) G) (n : ℕ) : + (∃ p ∈ G.carrier, p ∈ (bit N n : LowerSet P)) ↔ n ∈ value N G := by + constructor + · rintro ⟨p,hp,hpbit⟩ + obtain ⟨q,hq,hqdec⟩ := hG n + rcases hqdec with ⟨r,hr,hqr⟩ | hqneg + · exact ⟨r,G.upper hqr hq,hr⟩ + · obtain ⟨r,_,hrp,hrq⟩ := G.directed hp hq + have hrbit : r ∈ (bit N n : LowerSet P) := (bit N n : LowerSet P).lower hrp hpbit + have hrneg := ((tagLower (N n))ᶜ).lower hrq hqneg + exact False.elim ((mem_compl ((tagLower (N n))ᶜ) r).mp hrbit r le_rfl hrneg) + · rintro ⟨p,hp,hpN⟩ + exact ⟨p,hp,(show tagLower (N n) ≤ ((bit N n : LowerSet P)) from le_compl_compl) + ⟨p,hpN,le_rfl⟩⟩ + +theorem projected_bit_iff (N : ℕ → Set P) (G : GenericFilter P) + (hG : GenericFor (decision N) G) (n : ℕ) : + (∃ hn : bit N n ≠ ⊥, + (⟨bit N n,bit_mem_part N n,hn⟩ : PartPositive (part N)) ∈ + (imageFilter (projection N) G).carrier) ↔ n ∈ value N G := by + constructor + · rintro ⟨hn,hmem⟩ + exact (bit_hit_iff N G hG n).mp + ((image_mem_iff (part N) (part_compl N) G ⟨bit N n,bit_mem_part N n,hn⟩).mp hmem) + · intro hv + obtain ⟨p,hp,hpb⟩ := (bit_hit_iff N G hG n).mpr hv + have hn : bit N n ≠ ⊥ := by + intro h + rw [h] at hpb + exact hpb + exact ⟨hn,(image_mem_iff (part N) (part_compl N) G + ⟨bit N n,bit_mem_part N n,hn⟩).mpr ⟨p,hp,hpb⟩⟩ + +theorem same_real_generators (N : ℕ → Set P) (G H : GenericFilter P) + (hG : GenericFor (decision N) G) (hH : GenericFor (decision N) H) + (heq : value N G = value N H) (n : ℕ) : + (∃ hn : bit N n ≠ ⊥, + (⟨bit N n,bit_mem_part N n,hn⟩ : PartPositive (part N)) ∈ + (imageFilter (projection N) G).carrier) ↔ + (∃ hn : bit N n ≠ ⊥, + (⟨bit N n,bit_mem_part N n,hn⟩ : PartPositive (part N)) ∈ + (imageFilter (projection N) H).carrier) := by + rw [projected_bit_iff N G hG,projected_bit_iff N H hH,heq] + +theorem projected_countable_presentation [Countable P] (N : ℕ → Set P) : + (Set.range (projection N).map).Countable ∧ Dense (Set.range (projection N).map) := + originalProjection_countable_dense (part N) (part_compl N) + +end TuringRigidity.RealGeneratedPart + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/RealHullColumnRealization.lean b/lean/OAI/Computability/DegreeRigidity/Representation/RealHullColumnRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c2bdce0771302def9b48fabaa23d66e3e4b816b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/RealHullColumnRealization.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.SetModels.TwoRealHull +import OAI.Computability.DegreeRigidity.Representation.GenericRealColumnRealization + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing InternalCountableOrdinals +open CohenColumnRealName +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem real_hull_generic_column_realizes (M K a : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) (ha : a ∈ K) + (G : GenericFilter (Conditions (poset K))) (hG : AtomicForcing.GroundGeneric M G) + (X A : Oracle) + (hXE : realCode X ∈ genericExtensionSet M (poset K) G.carrier) + (hAE : realCode A ∈ genericExtensionSet M (poset K) G.carrier) + (hA : AtomicForcing.GroundGeneric (RealGeneratedModel.hull M (realCode X)) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter A))) : + ColumnRealizesExtension (RealGeneratedModel.hull M (realCode X)) K a + (genericExtensionSet M (poset K) G.carrier) A := by + obtain ⟨hN,hH,L,hL,hLE⟩ := TwoRealHull.joined_factorization M K hM hT hK G hG X A hXE hAE + let N := RealGeneratedModel.hull M (realCode X) + have haM := hM K hK.2.1 a ha + have hsingle := singleton_mem M hM hT.pairing haM + have hsK : ({a} : ZFSet.{0}) ⊆ K := fun _ hx => ZFSet.mem_singleton.mp hx ▸ ha + obtain ⟨R,hR,hRE⟩ := CohenRemainderTransport.transport_to_remainder M _ K {a} + hM hT hH.1 hH.2.1 (fun _ hz => hH.2.2.1 (hN.2.2.1 hz)) hK hsingle hsK + (Or.inr (InternalCountableClosure.singleton_countable M a hM hT haM)) L hL + obtain ⟨J,hJ,hJE,hJA⟩ := PrefixSingletonRealization.singleton_realization N a + hN.1 hN.2.1 (hN.2.2.1 haM) A hA + have hRJ : AtomicForcing.GroundGeneric (genericExtensionSet N (poset {a}) J.carrier) R := by + rw [hJE] + exact hR + obtain ⟨U,hU,hUE,hUA⟩ := CohenPartitionRealization.reassemble_column N K a + hN.1 hN.2.1 (hN.2.2.1 hK.2.1) ha A J hJ hJA R hRJ + refine ⟨U,hU,hUE.trans ?_,hUA⟩ + rw [hJE] + exact hRE.trans hLE + +theorem real_hull_shuffled_column_realizes (M K a : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) (ha : a ∈ K) + (G : GenericFilter (Conditions (poset K))) (hG : AtomicForcing.GroundGeneric M G) + (X Y L : Oracle) + (hXE : realCode X ∈ genericExtensionSet M (poset K) G.carrier) + (hYE : realCode Y ∈ genericExtensionSet M (poset K) G.carrier) + (hLE : realCode L ∈ genericExtensionSet M (poset K) G.carrier) + (hL : AtomicForcing.GroundGeneric (RealGeneratedModel.hull M (realCode X)) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L))) : + ColumnRealizesExtension (RealGeneratedModel.hull M (realCode X)) K a + (genericExtensionSet M (poset K) G.carrier) (GenericCoding.code Y L) := by + obtain ⟨hE,hTE,_,_⟩ := RegularTreeExtension.extension_properties M (poset K) hM hT + (CohenGroundPoset.conditions_mem M _ hM hT + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + hK.2.1 (sourceT_omega_mem M hM hT))) G hG + obtain ⟨hN,_,_,_⟩ := OriginalRealCohenFactorization.real_factorization M K hM hT hK + G hG (realCode X) hXE (realCode_subset X) + exact real_hull_generic_column_realizes M K a hM hT hK ha G hG X _ hXE + (sourceT_real_lower _ hE hTE (sourceT_real_join _ hE hTE hYE hLE) (GenericCoding.code_reduces Y L)) + (InternalCohen.groundGeneric_shuffle _ hN.1 hN.2.1 L hL Y) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/RealHullGenericTriple.lean b/lean/OAI/Computability/DegreeRigidity/Representation/RealHullGenericTriple.lean new file mode 100644 index 0000000000000000000000000000000000000000..b05dc92721beb2d3e2c0c204943eac9fe9cf072f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/RealHullGenericTriple.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DegreeRigidity.Representation.RealHullIteration +import OAI.Computability.DegreeRigidity.Representation.SameExtensionGenericTriple + +namespace OAI + + +namespace TuringRigidity.RealHullGenericTriple +open TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open CohenColumnRealName InternalCountableOrdinals UniformArithmetic +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem exists_prefix_real (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (X : Oracle) (hX : realCode X ∈ genericExtensionSet M (poset K) G.carrier) + (s : List Bool) : ∃ Y : Oracle, + realCode Y ∈ genericExtensionSet M (poset K) G.carrier ∧ + GroundGeneric (RealGeneratedModel.hull M (realCode X)) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter Y)) ∧ + ShuffleRequirements.Realizes s Y := by + obtain ⟨hN,U,hU,hUE⟩ := OriginalRealCohenFactorization.real_factorization M K hM hT hK + G hG (realCode X) hX (realCode_subset X) + let N := RealGeneratedModel.hull M (realCode X) + obtain ⟨a,ha⟩ := InternalCountableOrdinals.nonempty M K hK + obtain ⟨Y,hYv,_,hYE⟩ := generic_real_value N K a hN.1 hN.2.1 (hN.2.2.1 hK.2.1) ha U hU + have hYg := selected_real_prefix_generic N K a hN.1 hN.2.1 (hN.2.2.1 hK.2.1) ha U hU Y hYv + obtain ⟨hE,hTE,_,_⟩ := RegularTreeExtension.extension_properties N (poset K) hN.1 hN.2.1 + (CohenGroundPoset.conditions_mem N _ hN.1 hN.2.1 + (product_mem N hN.1 hN.2.1.pairing hN.2.1.union hN.2.1.powerSet + hN.2.1.separation.finitePrefix.bounded (hN.2.2.1 hK.2.1) + (sourceT_omega_mem N hN.1 hN.2.1))) U hU + exact ⟨FiniteOverwrite.overwrite s Y, + hUE ▸ sourceT_real_lower _ hE hTE hYE (FiniteOverwrite.overwrite_reduces s Y), + GroundPrefixOverwrite.overwrite_generic N hN.1 hN.2.1 Y hYg s, + GroundPrefixOverwrite.overwrite_realizes s Y⟩ + +theorem exists_generic_prefix_triple (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (X : Oracle) (hX : realCode X ∈ genericExtensionSet M (poset K) G.carrier) + (O : Oracles) (hO : ∀ i, realCode (O i) ∈ RealGeneratedModel.hull M (realCode X)) + (s : List Bool) : ∃ Y L R : Oracle, + (∀ A ∈ ({Y,L,R} : Set Oracle), + realCode A ∈ genericExtensionSet M (poset K) G.carrier ∧ + GroundGeneric (RealGeneratedModel.hull M (realCode X)) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter A))) ∧ + GenericCoding.InfiniteOdd L ∧ GenericCoding.InfiniteOdd R ∧ + GenericIdentity.PrincipalIntersection Y (join Y L) (join Y R) ∧ + ArithmeticPrefixForcing.Generic O (join Y (join L R)) ∧ + ShuffleRequirements.Realizes s (join Y (join L R)) := by + obtain ⟨Y,hYE,hYg,hYs⟩ := exists_prefix_real M K hM hT hK G hG X hX (TriplePrefix.prefixes s).1 + obtain ⟨hN,hH,L,R,hLE,hRE,hL,hR,hLs,hRs⟩ := + RealHullIteration.exists_iterated_prefix_pair M K hM hT hK G hG X Y hX hYE + (TriplePrefix.prefixes s).2.1 (TriplePrefix.prefixes s).2.2 + let N := RealGeneratedModel.hull M (realCode X) + let H := RealGeneratedModel.hull N (realCode Y) + obtain ⟨_,_,hHF,_⟩ := RegularTreeExtension.extension_properties H InternalCohen.conditions + hH.1 hH.2.1 (InternalCohen.conditions_mem H hH.1 hH.2.1) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) hL + have hLN : GroundGeneric N (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) := + fun D hD hd => hL D (hH.2.2.1 hD) hd + have hRN : GroundGeneric N (InternalCohen.pushFilter (CohenBorelForcing.realFilter R)) := + fun D hD hd => hR D (hHF (hH.2.2.1 hD)) hd + have hideal := IteratedGenericCommonIdeal.ideal_of_iterated_generics H hH.1 hH.2.1 + Y hH.2.2.2 L R hL hR + refine ⟨Y,L,R,?_,InternalCohen.groundGeneric_infiniteOdd N hN.1 hN.2.1 L hLN, + InternalCohen.groundGeneric_infiniteOdd N hN.1 hN.2.1 R hRN,hideal, + GroundIteratedTriple.generic_triple N hN.1 hN.2.1 O hO Y L R hYg hH hL hR, + TriplePrefix.realizes_join hYs hLs hRs⟩ + intro A hA + simp only [Set.mem_insert_iff,Set.mem_singleton_iff] at hA + rcases hA with hA|hA|hA <;> rw [hA] + · exact ⟨hYE,hYg⟩ + · exact ⟨hLE,hLN⟩ + · exact ⟨hRE,hRN⟩ + +end TuringRigidity.RealHullGenericTriple + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/RealHullIteration.lean b/lean/OAI/Computability/DegreeRigidity/Representation/RealHullIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9d95030222fa07179c40e9f844fafd41a5150e8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/RealHullIteration.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DegreeRigidity.SetModels.TwoRealHull +import OAI.Computability.DegreeRigidity.Representation.SameExtensionIteration + +namespace OAI + + +namespace TuringRigidity.RealHullIteration +open TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open CohenColumnRealName InternalCountableOrdinals RealGeneratedModel +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem exists_iterated_pair (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (X Y : Oracle) + (hX : realCode X ∈ genericExtensionSet M (poset K) G.carrier) + (hY : realCode Y ∈ genericExtensionSet M (poset K) G.carrier) : + let N := RealGeneratedModel.hull M (realCode X) + let H := RealGeneratedModel.hull N (realCode Y) + Contains M (realCode X) N ∧ Contains N (realCode Y) H ∧ ∃ L R : Oracle, + realCode L ∈ genericExtensionSet M (poset K) G.carrier ∧ + realCode R ∈ genericExtensionSet M (poset K) G.carrier ∧ + GroundGeneric H (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) ∧ + GroundGeneric (genericExtensionSet H InternalCohen.conditions + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)).carrier) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter R)) := by + dsimp only + obtain ⟨hN,hH,U,hU,hUE⟩ := TwoRealHull.joined_factorization M K hM hT hK G hG X Y hX hY + obtain ⟨a,ha⟩ := InternalCountableOrdinals.nonempty M K hK + have haM := hM K hK.2.1 a ha + have hsingle := singleton_mem M hM hT.pairing haM + have hsub : ({a} : ZFSet.{0}) ⊆ K := fun _ h => (ZFSet.mem_singleton.mp h) ▸ ha + obtain ⟨b,hb,_,_,_⟩ := CohenFreshColumn.fresh_column M K {a} hM hT hK hsingle hsub + (Or.inr (InternalCountableClosure.singleton_countable M a hM hT haM)) + have hbK := (ZFSet.mem_sdiff.mp hb).1 + have hba : b ≠ a := fun he => (ZFSet.mem_sdiff.mp hb).2 (ZFSet.mem_singleton.mpr he) + obtain ⟨L,R,hLE,hRE,hL,hR⟩ := CohenDisjointPrefixPair.exists_iterated_pair + _ K a b hH.1 hH.2.1 (hH.2.2.1 (hN.2.2.1 hK.2.1)) ha hbK hba U hU + exact ⟨hN,hH,L,R,hUE ▸ hLE,hUE ▸ hRE,hL,hR⟩ + +theorem exists_iterated_prefix_pair (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (X Y : Oracle) + (hX : realCode X ∈ genericExtensionSet M (poset K) G.carrier) + (hY : realCode Y ∈ genericExtensionSet M (poset K) G.carrier) (s t : List Bool) : + let N := RealGeneratedModel.hull M (realCode X) + let H := RealGeneratedModel.hull N (realCode Y) + Contains M (realCode X) N ∧ Contains N (realCode Y) H ∧ ∃ L R : Oracle, + realCode L ∈ genericExtensionSet M (poset K) G.carrier ∧ + realCode R ∈ genericExtensionSet M (poset K) G.carrier ∧ + GroundGeneric H (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) ∧ + GroundGeneric (genericExtensionSet H InternalCohen.conditions + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)).carrier) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter R)) ∧ + ShuffleRequirements.Realizes s L ∧ ShuffleRequirements.Realizes t R := by + dsimp only + obtain ⟨hN,hH,L,R,hLE,hRE,hL,hR⟩ := exists_iterated_pair M K hM hT hK G hG X Y hX hY + let H := RealGeneratedModel.hull (RealGeneratedModel.hull M (realCode X)) (realCode Y) + obtain ⟨hE,hTE,_,_⟩ := RegularTreeExtension.extension_properties M (poset K) hM hT + (CohenGroundPoset.conditions_mem M _ hM hT + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + hK.2.1 (sourceT_omega_mem M hM hT))) G hG + obtain ⟨hF,hTF,_,_⟩ := RegularTreeExtension.extension_properties H InternalCohen.conditions + hH.1 hH.2.1 (InternalCohen.conditions_mem H hH.1 hH.2.1) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) hL + have hLs := GroundPrefixOverwrite.overwrite_generic H hH.1 hH.2.1 L hL s + have hRt := GroundPrefixOverwrite.overwrite_generic _ hF hTF R hR t + have he := FiniteOverwriteHull.overwrite_extension H hH.1 hH.2.1 L hL s + refine ⟨hN,hH,FiniteOverwrite.overwrite s L,FiniteOverwrite.overwrite t R, + sourceT_real_lower _ hE hTE hLE (FiniteOverwrite.overwrite_reduces s L), + sourceT_real_lower _ hE hTE hRE (FiniteOverwrite.overwrite_reduces t R), + hLs,?_,GroundPrefixOverwrite.overwrite_realizes s L,GroundPrefixOverwrite.overwrite_realizes t R⟩ + rw [he] + exact hRt + +end TuringRigidity.RealHullIteration + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/RealHullPrescribedTruth.lean b/lean/OAI/Computability/DegreeRigidity/Representation/RealHullPrescribedTruth.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0d46370fb7d3089e3e4524ace97274dbd78099c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/RealHullPrescribedTruth.lean @@ -0,0 +1,91 @@ +import OAI.Computability.DegreeRigidity.Representation.RealHullGenericTriple +import OAI.Computability.DegreeRigidity.Representation.RealHullColumnRealization +import OAI.Computability.DegreeRigidity.Computability.ArithmeticFiniteTruthTransfer + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open CohenColumnRealName InternalCountableOrdinals GenericIdentity +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem real_hull_prescribed_transfer (M K a : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) (ha : a ∈ K) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (X : Oracle) (hX : realCode X ∈ genericExtensionSet M (poset K) G.carrier) + (π : Degree ≃o Degree) (p : OracleCode) (P : Oracle) + (hP : realCode P ∈ RealGeneratedModel.hull M (realCode X)) + (hsem : ∀ H : GenericFilter (Conditions (poset K)), + GroundGeneric (RealGeneratedModel.hull M (realCode X)) H → + genericExtensionSet (RealGeneratedModel.hull M (realCode X)) (poset K) H.carrier = + genericExtensionSet M (poset K) G.carrier → + ∀ A : Oracle, (realName K a).val H.carrier = realCode A → RepresentsAt π p P A) : + (∀ s : List Bool, ∃ H : Oracle, + ArithmeticPrefixForcing.Generic (fun _ => P) H ∧ + ShuffleRequirements.Realizes s H ∧ SourceEquation p P (GenericTruth.triple H)) ∧ + (∀ H : Oracle, ArithmeticPrefixForcing.Generic (fun _ => P) H → + SourceEquation p P (GenericTruth.triple H)) ∧ + (∃ D : ArithmeticPrefixForcing.PrefixPredicate, ArithmeticPrefixForcing.ArithmeticPrefix D ∧ + (∀ n, FiniteShuffle.DenseOpen (D (fun _ => P) n)) ∧ + ∀ H : Oracle, ShuffleRequirements.GenericFor (D (fun _ => P)) H → + SourceEquation p P (GenericTruth.triple H)) ∧ + ∀ Y : Oracle, realCode Y ∈ genericExtensionSet M (poset K) G.carrier → + ArithmeticPrefixForcing.Generic (fun _ => P) Y → RepresentsAt π p P Y := by + let N := RealGeneratedModel.hull M (realCode X) + have hrep : ∀ A : Oracle, + ColumnRealizesExtension N K a (genericExtensionSet M (poset K) G.carrier) A → + RepresentsAt π p P A := by + rintro A ⟨H,hH,he,hA⟩ + exact hsem H hH he A hA + have hordinary : ∀ A : Oracle, realCode A ∈ genericExtensionSet M (poset K) G.carrier → + GroundGeneric N (InternalCohen.pushFilter (CohenBorelForcing.realFilter A)) → + RepresentsAt π p P A := fun A hAE hA => hrep A + (real_hull_generic_column_realizes M K a hM hT hK ha G hG X A hX hAE hA) + have hshuffle : ∀ Y L : Oracle, + realCode Y ∈ genericExtensionSet M (poset K) G.carrier → + realCode L ∈ genericExtensionSet M (poset K) G.carrier → + GroundGeneric N (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) → + RepresentsAt π p P (GenericCoding.code Y L) := fun Y L hYE hLE hL => hrep _ + (real_hull_shuffled_column_realizes M K a hM hT hK ha G hG X Y L hX hYE hLE hL) + have hd : ∀ s : List Bool, ∃ H : Oracle, + ArithmeticPrefixForcing.Generic (fun _ => P) H ∧ + ShuffleRequirements.Realizes s H ∧ SourceEquation p P (GenericTruth.triple H) := by + intro s + obtain ⟨Y,L,R,hbase,hL,hR,hi,hg,hs⟩ := RealHullGenericTriple.exists_generic_prefix_triple + M K hM hT hK G hG X hX (fun _ => P) (fun _ => hP) s + have hy := hbase Y (by simp) + have hl := hbase L (by simp) + have hr := hbase R (by simp) + refine ⟨join Y (join L R),hg,hs,?_⟩ + rw [GroundIteratedTriple.triple_join] + exact (source_5_5_iff π p P Y L R (hordinary L hl.1 hl.2) (hordinary R hr.1 hr.2) + (hshuffle Y L hy.1 hl.1 hl.2) (hshuffle Y R hy.1 hr.1 hr.2) hL hR hi).mpr + (hordinary Y hy.1 hy.2) + have ht := ArithmeticSourceTruth.source_equation_of_dense p P hd + refine ⟨hd,ht,ArithmeticFiniteTruthTransfer.source_equation_finite_family p P hd,?_⟩ + intro Y hYE hY + obtain ⟨hN,hH,L,R,hLE,hRE,hL,hR⟩ := + RealHullIteration.exists_iterated_pair M K hM hT hK G hG X Y hX hYE + let H := RealGeneratedModel.hull N (realCode Y) + obtain ⟨_,_,hHF,_⟩ := RegularTreeExtension.extension_properties H InternalCohen.conditions + hH.1 hH.2.1 (InternalCohen.conditions_mem H hH.1 hH.2.1) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) hL + have hLN : GroundGeneric N (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) := + fun D hD hd => hL D (hH.2.2.1 hD) hd + have hRN : GroundGeneric N (InternalCohen.pushFilter (CohenBorelForcing.realFilter R)) := + fun D hD hd => hR D (hHF (hH.2.2.1 hD)) hd + have hi := IteratedGenericCommonIdeal.ideal_of_iterated_generics H hH.1 hH.2.1 + Y hH.2.2.2 L R hL hR + have heq := ht (join Y (join L R)) + (GroundIteratedTriple.generic_triple_of_arithmetic N (fun _ => P) (fun _ => hP) + Y L R hY hH hL hR) + rw [GroundIteratedTriple.triple_join] at heq + exact (source_5_5_iff π p P Y L R (hordinary L hLE hLN) (hordinary R hRE hRN) + (hshuffle Y L hYE hLE hLN) (hshuffle Y R hYE hRE hRN) + (InternalCohen.groundGeneric_infiniteOdd N hN.1 hN.2.1 L hLN) + (InternalCohen.groundGeneric_infiniteOdd N hN.1 hN.2.1 R hRN) hi).mp heq + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/RealHullQuotient.lean b/lean/OAI/Computability/DegreeRigidity/Representation/RealHullQuotient.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b7ea108b29914b98025af1215a3b4e1ec1665f5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/RealHullQuotient.lean @@ -0,0 +1,60 @@ +import OAI.Computability.DegreeRigidity.Representation.RealGeneratedModel +import OAI.Computability.DegreeRigidity.SetModels.InternalQuotientExtension + +namespace OAI + +namespace TuringRigidity.RealHullQuotient +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames +open InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax InternalBooleanBits +open InternalGeneratedAlgebra InternalProjectedGeneric InternalQuotientGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder +attribute [local instance] codeOrder codePreorder + +theorem quotient_over_hull (M c B Q A : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hAM : A ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) (hA : Closed c B Q A) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) + (hAe : A = generated c B Q (seeds c B E)) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (hGt : ⊤ ∈ G.carrier) : + let X := (InternalNiceName.nice E : Name (Conditions c)).val G.carrier + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + let q := InternalQuotientConditions.conditions c A (genericFilterSet (positive A) H.carrier) + let K := quotient M c B Q A hM hT hc hBM hAM hB hQ hA G + q ∈ RealGeneratedModel.hull M X ∧ InternalCollapse.orderSet q ∈ RealGeneratedModel.hull M X ∧ + AtomicForcing.GroundGeneric (RealGeneratedModel.hull M X) K ∧ + genericExtensionSet (RealGeneratedModel.hull M X) q K.carrier = genericExtensionSet M c G.carrier ∧ + genericFilterSet q K.carrier = genericFilterSet c G.carrier ∧ + ∀ p ∈ G.carrier, ∃ r ∈ K.carrier, label q r = label c p := by + have he := RealGeneratedModel.projected_extension_eq_hull M c B Q A + hM hT hc hBM hQM hAM hB hQ hA E hE hgraph hAe G hG hGt + obtain ⟨_,_,_,_,hq,ho⟩ := InternalQuotientExtension.intermediate_properties M c B Q A + hM hT hc hBM hAM hB hQ hA G hG + dsimp only + rw [←he] + exact ⟨hq,ho,quotient_ground_generic M c B Q A hM hT hc hBM hAM hB hQ hA G hG, + InternalQuotientExtension.extension_eq M c B Q A hM hT hc hBM hAM hB hQ hA G hG hGt, + RestrictedForcingFilter.filterSet_eq c _ (InternalQuotientConditions.conditions_subset c A _) G + (InternalQuotientConditions.original_condition_mem M c B Q A hM hT hc hBM hAM hB hQ hA G), + RestrictedForcingFilter.original_condition c _ (InternalQuotientConditions.conditions_subset c A _) G + (InternalQuotientConditions.original_condition_mem M c B Q A hM hT hc hBM hAM hB hQ hA G)⟩ + +theorem own_reals_eq (M c B Q A : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hAM : A ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) (hA : Closed c B Q A) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) + (hAe : A = generated c B Q (seeds c B E)) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (hGt : ⊤ ∈ G.carrier) : + let X := (InternalNiceName.nice E : Name (Conditions c)).val G.carrier + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + let q := InternalQuotientConditions.conditions c A (genericFilterSet (positive A) H.carrier) + let K := quotient M c B Q A hM hT hc hBM hAM hB hQ hA G + modelReals (genericExtensionSet (RealGeneratedModel.hull M X) q K.carrier) = + modelReals (genericExtensionSet M c G.carrier) := by + have he := (quotient_over_hull M c B Q A hM hT hc hBM hQM hAM hB hQ hA E hE hgraph hAe G hG hGt).2.2.2.1 + exact congrArg modelReals he + +end TuringRigidity.RealHullQuotient + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/Reduction.lean b/lean/OAI/Computability/DegreeRigidity/Representation/Reduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..6338e15603804d865dc5bbcdc0e77c0f74e5b46f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/Reduction.lean @@ -0,0 +1,14 @@ +import OAI.Computability.DegreeRigidity.Computability.CutArithmetic +import OAI.Computability.DegreeRigidity.Computability.EffectiveRecovery + +namespace OAI + +namespace TuringRigidity + +theorem main_of_three_obligations (hrep : BorelRepresentation) + (hcover : IrrationalDegreeCoverage) (havoid : CategoryAvoidance) : MainTheorem := + main_of_obligations hrep cut_arithmetic hcover four_value_recovery havoid + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/RepresentationEndgame.lean b/lean/OAI/Computability/DegreeRigidity/Representation/RepresentationEndgame.lean new file mode 100644 index 0000000000000000000000000000000000000000..69caa22535bbc085cdcfb385d490eeab7afc48dc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/RepresentationEndgame.lean @@ -0,0 +1,54 @@ +import OAI.Computability.DegreeRigidity.Representation.GenericAssembly +import OAI.Computability.DegreeRigidity.Representation.GenericCodingBorel +import OAI.Computability.DegreeRigidity.Representation.BorelGeneric + +namespace OAI + +namespace TuringRigidity + +theorem representative_from_selected_generics (π : Degree ≃o Degree) + (F : Oracle → Oracle) (hF : Measurable F) + (G : Bool → Oracle → Oracle) (hG : ∀ b, Measurable (G b)) + (hinfinite : ∀ A b, GenericCoding.InfiniteOdd (G b A)) + (hgen : ∀ A b, degree (F (G b A)) = π (degree (G b A))) + (hcoded : ∀ A b, degree (F (GenericCoding.code A (G b A))) = + π (degree (GenericCoding.code A (G b A)))) + (hideal : ∀ A a, a ≤ degree A ↔ + a ≤ degree (join A (G false A)) ∧ a ≤ degree (join A (G true A))) : + ∃ H : Oracle → Oracle, Measurable H ∧ ∀ A, degree (H A) = π (degree A) := by + apply representative_from_generic_coding π F hF GenericCoding.code GenericCoding.code_measurable + G hG hgen hcoded + intro A a + rw [GenericCoding.join_degree_eq A (G false A) (hinfinite A false), + GenericCoding.join_degree_eq A (G true A) (hinfinite A true)] + exact hideal A a + +theorem representative_from_generic_program (π : Degree ≃o Degree) (p : OracleCode) (P : Oracle) + (G : Bool → Oracle → Oracle) (hG : ∀ b, Measurable (G b)) + (hinfinite : ∀ A b, GenericCoding.InfiniteOdd (G b A)) + (hgen : ∀ A b, ∃ B, OracleCode.eval (oracleFunction (join (G b A) P)) p = oracleFunction B ∧ + degree B = π (degree (G b A))) + (hcoded : ∀ A b, ∃ B, OracleCode.eval (oracleFunction (join (GenericCoding.code A (G b A)) P)) p = + oracleFunction B ∧ degree B = π (degree (GenericCoding.code A (G b A)))) + (hideal : ∀ A a, a ≤ degree A ↔ + a ≤ degree (join A (G false A)) ∧ a ≤ degree (join A (G true A))) : + ∃ H : Oracle → Oracle, Measurable H ∧ ∀ A, degree (H A) = π (degree A) := by + let F : Oracle → Oracle := fun Y => programOutput p (join Y P) + have hF : Measurable F := (programOutput_measurable p).comp + (join_measurable _ _ measurable_id measurable_const) + apply representative_from_selected_generics π F hF G hG hinfinite + · intro A b + obtain ⟨B,hp,hB⟩ := hgen A b + change degree (programOutput p (join (G b A) P)) = _ + rw [programOutput_eq p _ B hp] + exact hB + · intro A b + obtain ⟨B,hp,hB⟩ := hcoded A b + change degree (programOutput p (join (GenericCoding.code A (G b A)) P)) = _ + rw [programOutput_eq p _ B hp] + exact hB + · exact hideal + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SameExtensionCommonIdeal.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SameExtensionCommonIdeal.lean new file mode 100644 index 0000000000000000000000000000000000000000..f86558615292a398e8768e6ade5add2c8e8a35b5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SameExtensionCommonIdeal.lean @@ -0,0 +1,53 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.CohenDisjointPrefixPair +import OAI.Computability.DegreeRigidity.Representation.IteratedGenericCommonIdeal +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenOddHits +import OAI.Computability.DegreeRigidity.Representation.OriginalRealCohenFactorization + +namespace OAI + + +namespace TuringRigidity.SameExtensionCommonIdeal +open TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open CohenColumnRealName InternalCountableOrdinals +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem exists_common_ideal_pair (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (Y : Oracle) (hY : realCode Y ∈ genericExtensionSet M (poset K) G.carrier) : + ∃ L R : Oracle, + realCode L ∈ genericExtensionSet M (poset K) G.carrier ∧ + realCode R ∈ genericExtensionSet M (poset K) G.carrier ∧ + GroundGeneric M (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) ∧ + GroundGeneric M (InternalCohen.pushFilter (CohenBorelForcing.realFilter R)) ∧ + GenericCoding.InfiniteOdd L ∧ GenericCoding.InfiniteOdd R ∧ + GenericIdentity.PrincipalIntersection Y (join Y L) (join Y R) := by + obtain ⟨hN,U,hU,hUE⟩ := OriginalRealCohenFactorization.real_factorization M K hM hT hK + G hG (realCode Y) hY (realCode_subset Y) + let N := RealGeneratedModel.hull M (realCode Y) + obtain ⟨a,ha⟩ := InternalCountableOrdinals.nonempty M K hK + have haM := hM K hK.2.1 a ha + have hsingle := singleton_mem M hM hT.pairing haM + have hsub : ({a} : ZFSet.{0}) ⊆ K := fun _ h => (ZFSet.mem_singleton.mp h) ▸ ha + obtain ⟨b,hb,_,_,_⟩ := CohenFreshColumn.fresh_column M K {a} hM hT hK hsingle hsub + (Or.inr (InternalCountableClosure.singleton_countable M a hM hT haM)) + have hbK := (ZFSet.mem_sdiff.mp hb).1 + have hba : b ≠ a := fun he => (ZFSet.mem_sdiff.mp hb).2 (ZFSet.mem_singleton.mpr he) + obtain ⟨L,R,hLE,hRE,hL,hR⟩ := CohenDisjointPrefixPair.exists_iterated_pair N K a b + hN.1 hN.2.1 (hN.2.2.1 hK.2.1) ha hbK hba U hU + have hideal := IteratedGenericCommonIdeal.ideal_of_iterated_generics N hN.1 hN.2.1 + Y hN.2.2.2 L R hL hR + obtain ⟨_,_,hNP,_⟩ := RegularTreeExtension.extension_properties N InternalCohen.conditions + hN.1 hN.2.1 (InternalCohen.conditions_mem N hN.1 hN.2.1) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) hL + have hLM : GroundGeneric M (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) := + fun D hD hd => hL D (hN.2.2.1 hD) hd + have hRM : GroundGeneric M (InternalCohen.pushFilter (CohenBorelForcing.realFilter R)) := + fun D hD hd => hR D (hNP (hN.2.2.1 hD)) hd + exact ⟨L,R,hUE ▸ hLE,hUE ▸ hRE,hLM,hRM, + InternalCohen.groundGeneric_infiniteOdd M hM hT L hLM, + InternalCohen.groundGeneric_infiniteOdd M hM hT R hRM,hideal⟩ + +end TuringRigidity.SameExtensionCommonIdeal + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SameExtensionGenericTriple.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SameExtensionGenericTriple.lean new file mode 100644 index 0000000000000000000000000000000000000000..222b29de7463447e077ab2c634b2dcf37f86f1a1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SameExtensionGenericTriple.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.Representation.SameExtensionIteration +import OAI.Computability.DegreeRigidity.Representation.GroundIteratedTriple +import OAI.Computability.DegreeRigidity.Effective.TriplePrefix + +namespace OAI + + +namespace TuringRigidity.SameExtensionGenericTriple +open TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open CohenColumnRealName InternalCountableOrdinals UniformArithmetic +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem exists_prefix_real (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (s : List Bool) : ∃ Y : Oracle, + realCode Y ∈ genericExtensionSet M (poset K) G.carrier ∧ + GroundGeneric M (InternalCohen.pushFilter (CohenBorelForcing.realFilter Y)) ∧ + ShuffleRequirements.Realizes s Y := by + obtain ⟨a,ha⟩ := InternalCountableOrdinals.nonempty M K hK + obtain ⟨Y,hYv,_,hYE⟩ := generic_real_value M K a hM hT hK.2.1 ha G hG + have hYg := selected_real_prefix_generic M K a hM hT hK.2.1 ha G hG Y hYv + obtain ⟨hE,hTE,_,_⟩ := RegularTreeExtension.extension_properties M (poset K) hM hT + (CohenGroundPoset.conditions_mem M _ hM hT + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + hK.2.1 (sourceT_omega_mem M hM hT))) G hG + exact ⟨FiniteOverwrite.overwrite s Y, + sourceT_real_lower _ hE hTE hYE (FiniteOverwrite.overwrite_reduces s Y), + GroundPrefixOverwrite.overwrite_generic M hM hT Y hYg s, + GroundPrefixOverwrite.overwrite_realizes s Y⟩ + +theorem exists_generic_prefix_triple (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (O : Oracles) (hO : ∀ i, realCode (O i) ∈ M) (s : List Bool) : + ∃ Y L R : Oracle, + (∀ A ∈ ({Y,L,R} : Set Oracle), + realCode A ∈ genericExtensionSet M (poset K) G.carrier ∧ + GroundGeneric M (InternalCohen.pushFilter (CohenBorelForcing.realFilter A))) ∧ + GenericCoding.InfiniteOdd L ∧ GenericCoding.InfiniteOdd R ∧ + GenericIdentity.PrincipalIntersection Y (join Y L) (join Y R) ∧ + ArithmeticPrefixForcing.Generic O (join Y (join L R)) ∧ + ShuffleRequirements.Realizes s (join Y (join L R)) := by + obtain ⟨Y,hYE,hYg,hYs⟩ := exists_prefix_real M K hM hT hK G hG (TriplePrefix.prefixes s).1 + obtain ⟨hN,L,R,hLE,hRE,hL,hR,hLs,hRs⟩ := + SameExtensionIteration.exists_iterated_prefix_pair M K hM hT hK G hG Y hYE + (TriplePrefix.prefixes s).2.1 (TriplePrefix.prefixes s).2.2 + let N := RealGeneratedModel.hull M (realCode Y) + obtain ⟨_,_,hNF,_⟩ := RegularTreeExtension.extension_properties N InternalCohen.conditions + hN.1 hN.2.1 (InternalCohen.conditions_mem N hN.1 hN.2.1) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) hL + have hLM : GroundGeneric M (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) := + fun D hD hd => hL D (hN.2.2.1 hD) hd + have hRM : GroundGeneric M (InternalCohen.pushFilter (CohenBorelForcing.realFilter R)) := + fun D hD hd => hR D (hNF (hN.2.2.1 hD)) hd + have hideal := IteratedGenericCommonIdeal.ideal_of_iterated_generics N hN.1 hN.2.1 + Y hN.2.2.2 L R hL hR + refine ⟨Y,L,R,?_,InternalCohen.groundGeneric_infiniteOdd M hM hT L hLM, + InternalCohen.groundGeneric_infiniteOdd M hM hT R hRM,hideal, + GroundIteratedTriple.generic_triple M hM hT O hO Y L R hYg hN hL hR, + TriplePrefix.realizes_join hYs hLs hRs⟩ + intro A hA + simp only [Set.mem_insert_iff,Set.mem_singleton_iff] at hA + rcases hA with hA|hA|hA <;> rw [hA] + · exact ⟨hYE,hYg⟩ + · exact ⟨hLE,hLM⟩ + · exact ⟨hRE,hRM⟩ + +end TuringRigidity.SameExtensionGenericTriple + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SameExtensionIteration.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SameExtensionIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..a10d402ea42db83751a0069c6b7b4cbd1deffac0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SameExtensionIteration.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.Representation.SameExtensionCommonIdeal +import OAI.Computability.DegreeRigidity.Effective.FiniteOverwriteHull + +namespace OAI + + +namespace TuringRigidity.SameExtensionIteration +open TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open CohenColumnRealName InternalCountableOrdinals RealGeneratedModel +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem exists_iterated_pair (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (Y : Oracle) (hY : realCode Y ∈ genericExtensionSet M (poset K) G.carrier) : + Contains M (realCode Y) (RealGeneratedModel.hull M (realCode Y)) ∧ ∃ L R : Oracle, + realCode L ∈ genericExtensionSet M (poset K) G.carrier ∧ + realCode R ∈ genericExtensionSet M (poset K) G.carrier ∧ + GroundGeneric (RealGeneratedModel.hull M (realCode Y)) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) ∧ + GroundGeneric (genericExtensionSet (RealGeneratedModel.hull M (realCode Y)) InternalCohen.conditions + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)).carrier) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter R)) := by + obtain ⟨hN,U,hU,hUE⟩ := OriginalRealCohenFactorization.real_factorization M K hM hT hK + G hG (realCode Y) hY (realCode_subset Y) + obtain ⟨a,ha⟩ := InternalCountableOrdinals.nonempty M K hK + have haM := hM K hK.2.1 a ha + have hsingle := singleton_mem M hM hT.pairing haM + have hsub : ({a} : ZFSet.{0}) ⊆ K := fun _ h => (ZFSet.mem_singleton.mp h) ▸ ha + obtain ⟨b,hb,_,_,_⟩ := CohenFreshColumn.fresh_column M K {a} hM hT hK hsingle hsub + (Or.inr (InternalCountableClosure.singleton_countable M a hM hT haM)) + have hbK := (ZFSet.mem_sdiff.mp hb).1 + have hba : b ≠ a := fun he => (ZFSet.mem_sdiff.mp hb).2 (ZFSet.mem_singleton.mpr he) + obtain ⟨L,R,hLE,hRE,hL,hR⟩ := CohenDisjointPrefixPair.exists_iterated_pair + (RealGeneratedModel.hull M (realCode Y)) K a b hN.1 hN.2.1 (hN.2.2.1 hK.2.1) ha hbK hba U hU + exact ⟨hN,L,R,hUE ▸ hLE,hUE ▸ hRE,hL,hR⟩ + +theorem exists_iterated_prefix_pair (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (Y : Oracle) (hY : realCode Y ∈ genericExtensionSet M (poset K) G.carrier) + (s t : List Bool) : + Contains M (realCode Y) (RealGeneratedModel.hull M (realCode Y)) ∧ ∃ L R : Oracle, + realCode L ∈ genericExtensionSet M (poset K) G.carrier ∧ + realCode R ∈ genericExtensionSet M (poset K) G.carrier ∧ + GroundGeneric (RealGeneratedModel.hull M (realCode Y)) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) ∧ + GroundGeneric (genericExtensionSet (RealGeneratedModel.hull M (realCode Y)) InternalCohen.conditions + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)).carrier) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter R)) ∧ + ShuffleRequirements.Realizes s L ∧ ShuffleRequirements.Realizes t R := by + obtain ⟨hN,L,R,hLE,hRE,hL,hR⟩ := exists_iterated_pair M K hM hT hK G hG Y hY + let N := RealGeneratedModel.hull M (realCode Y) + obtain ⟨hE,hTE,_,_⟩ := RegularTreeExtension.extension_properties M (poset K) hM hT + (CohenGroundPoset.conditions_mem M _ hM hT + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + hK.2.1 (sourceT_omega_mem M hM hT))) G hG + obtain ⟨hF,hTF,_,_⟩ := RegularTreeExtension.extension_properties N InternalCohen.conditions + hN.1 hN.2.1 (InternalCohen.conditions_mem N hN.1 hN.2.1) + (InternalCohen.pushFilter (CohenBorelForcing.realFilter L)) hL + have hLs := GroundPrefixOverwrite.overwrite_generic N hN.1 hN.2.1 L hL s + have hRt := GroundPrefixOverwrite.overwrite_generic _ hF hTF R hR t + have he := FiniteOverwriteHull.overwrite_extension N hN.1 hN.2.1 L hL s + refine ⟨hN,FiniteOverwrite.overwrite s L,FiniteOverwrite.overwrite t R, + sourceT_real_lower _ hE hTE hLE (FiniteOverwrite.overwrite_reduces s L), + sourceT_real_lower _ hE hTE hRE (FiniteOverwrite.overwrite_reduces t R), + hLs,?_,GroundPrefixOverwrite.overwrite_realizes s L,GroundPrefixOverwrite.overwrite_realizes t R⟩ + rw [he] + exact hRt + +end TuringRigidity.SameExtensionIteration + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SameRealBooleanFilter.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SameRealBooleanFilter.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac3cd069cc018d97a012767dbbef0fb73ddb2901 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SameRealBooleanFilter.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.Syntax.BooleanExpressionCoverage +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanIntermediate + +namespace OAI + +namespace TuringRigidity.SameRealBooleanFilter +open TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax +open InternalGeneratedAlgebra InternalBooleanBits InternalBooleanGeneric +open InternalProjectedGeneric BooleanExpressionCertificate +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder codeOrder codePreorder + +theorem generated_agreement (M c B Q S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hSM : S ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) (hSB : S ⊆ B) + (G H : GenericFilter (Conditions c)) + (hG : AtomicForcing.GroundGeneric M G) (hH : AtomicForcing.GroundGeneric M H) + (hseed : ∀ U ∈ S, Hit G U ↔ Hit H U) : + ∀ U ∈ generated c B Q S, Hit G U ↔ Hit H U := by + intro U hU + obtain ⟨K,_,_,g,_,hg,t,_,hp⟩ := + generated_certificate M c B Q S U hM hT hc hBM hQM hSM hB hQ hSB hU + exact hg.generic_agreement M c B Q S K g hM hT hc hB hQ G H hG hH hseed t U hp + +theorem same_real_hits (M c B Q : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) + (G H : GenericFilter (Conditions c)) + (hG : AtomicForcing.GroundGeneric M G) (hH : AtomicForcing.GroundGeneric M H) + (hGt : ⊤ ∈ G.carrier) (hHt : ⊤ ∈ H.carrier) + (heq : (InternalNiceName.nice E : RecursiveNames.Name (Conditions c)).val G.carrier = + (InternalNiceName.nice E : RecursiveNames.Name (Conditions c)).val H.carrier) : + ∀ U ∈ generated c B Q (seeds c B E), Hit G U ↔ Hit H U := by + apply generated_agreement M c B Q (seeds c B E) hM hT hc hBM hQM + (seeds_mem M c B hM hT hc hBM E hE hgraph) hB hQ + (fun _ h => (ZFSet.mem_sep.mp h).1) G H hG hH + intro U hU + obtain ⟨_,n,rfl⟩ := ZFSet.mem_sep.mp hU + rw [hit_bit_iff M c hM hT hc E hE G hG hGt n, + hit_bit_iff M c hM hT hc E hE H hH hHt n,heq] + +theorem same_real_projected_filter (M c B Q A : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hAM : A ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) (hA : Closed c B Q A) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) + (hAe : A = generated c B Q (seeds c B E)) + (G H : GenericFilter (Conditions c)) + (hG : AtomicForcing.GroundGeneric M G) (hH : AtomicForcing.GroundGeneric M H) + (hGt : ⊤ ∈ G.carrier) (hHt : ⊤ ∈ H.carrier) + (heq : (InternalNiceName.nice E : RecursiveNames.Name (Conditions c)).val G.carrier = + (InternalNiceName.nice E : RecursiveNames.Name (Conditions c)).val H.carrier) : + genericFilterSet (positive A) (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier = + genericFilterSet (positive A) (projected M c B Q A hM hT hc hBM hAM hB hQ hA H).carrier := by + have hhit := same_real_hits M c B Q hM hT hc hBM hQM hB hQ E hE hgraph G H hG hH hGt hHt heq + have hfilters : (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier = + (projected M c B Q A hM hT hc hBM hAM hB hQ hA H).carrier := by + apply Set.ext; intro q + change Hit G (label (positive A) q) ↔ Hit H (label (positive A) q) + apply hhit + rw [←hAe] + exact (ZFSet.mem_sep.mp (label_mem (positive A) q)).1 + rw [hfilters] + +end TuringRigidity.SameRealBooleanFilter + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SetAutomorphismReconstruction.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SetAutomorphismReconstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..244afe41bd4a72b4fb318fed29f41cadee1d8b90 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SetAutomorphismReconstruction.lean @@ -0,0 +1,74 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelAutomorphismInterpretation + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel EncodedForcing PersistentRestrictions PersistentPresentation +open NumericalAutomorphism +universe u + +noncomputable def setGraphReal (R H F : ZFSet.{u}) : Oracle := fun v => by + classical + exact decide (ZFSet.pair (degreeCode R (columns (decodeReal H) (Nat.unpair v).1)) + (degreeCode R (columns (decodeReal H) (Nat.unpair v).2)) ∈ F) + +theorem setGraphReal_bit (R F : ZFSet.{u}) (H : Oracle) (n m : ℕ) : + setGraphReal R (realCode H) F (Nat.pair n m) = true ↔ + ZFSet.pair (degreeCode R (columns H n)) (degreeCode R (columns H m)) ∈ F := by + classical + simp [setGraphReal,decodeReal_realCode] + +theorem setGraphReal_action (R : ZFSet.{u}) {H : Oracle} + (hc : ∀ n, realCode (columns H n) ∈ R) + (F : ZFSet.{u}) (hF : SetAutomorphism (presentationSet R H) (degreeOrder R) F) : + Action H (fun v => setGraphReal R (realCode H) F v = true) := by + have hi (n : ℕ) : degreeCode R (columns H n) ∈ presentationSet R H := + (mem_presentationSet _ _ _).mpr ⟨n,rfl⟩ + constructor + · intro n + obtain ⟨D,hD,hn,_⟩ := hF.1.2 _ (hi n) + obtain ⟨m,rfl⟩ := (mem_presentationSet _ _ _).mp hD + exact ⟨m,(setGraphReal_bit R F H n m).mpr hn⟩ + · intro m + obtain ⟨D,hD,hm⟩ := hF.2.1 _ (hi m) + obtain ⟨n,rfl⟩ := (mem_presentationSet _ _ _).mp hD + exact ⟨n,(setGraphReal_bit R F H n m).mpr hm⟩ + · intro n m n' m' hnm hn'm' + have h := hF.2.2 _ (hi n) _ (hi n') _ (hi m) _ (hi m') + ((setGraphReal_bit R F H n m).mp hnm) ((setGraphReal_bit R F H n' m').mp hn'm') + rwa [degreeOrder_actual R (hc n) (hc n'),degreeOrder_actual R (hc m) (hc m')] at h + · intro n m m' hnm hmm + apply (setGraphReal_bit R F H n m').mpr + rw [←(degreeCode_equal R (hc m)).mpr hmm] + exact (setGraphReal_bit R F H n m).mp hnm + +theorem setGraphReal_decodes (R : ZFSet.{u}) (H : Oracle) (F : ZFSet.{u}) + (hF : F ⊆ ZFSet.prod (presentationSet R H) (presentationSet R H)) : + presentationGraph R H (setGraphReal R (realCode H) F) = F := by + apply ZFSet.ext; intro z + constructor + · intro hz + obtain ⟨n,m,rfl,hnm⟩ := (mem_presentationGraph _ _ _ _).mp hz + exact (setGraphReal_bit R F H n m).mp hnm + · intro hz + obtain ⟨D,hD,E,hE,rfl⟩ := ZFSet.mem_prod.mp (hF hz) + obtain ⟨n,rfl⟩ := (mem_presentationSet _ _ _).mp hD + obtain ⟨m,rfl⟩ := (mem_presentationSet _ _ _).mp hE + exact (mem_presentationGraph _ _ _ _).mpr ⟨n,m,rfl,(setGraphReal_bit R F H n m).mpr hz⟩ + +theorem setAutomorphism_reconstruct (R : ZFSet.{u}) {J : CountableIdeal} {H : Oracle} + (hH : Presented J H) (hc : ∀ n, realCode (columns H n) ∈ R) + (F : ZFSet.{u}) (hF : SetAutomorphism (presentationSet R H) (degreeOrder R) F) : + ∃ ρ : J ≃o J, ∀ x y : J, + ZFSet.pair (presentedDegreeCode R hH x) (presentedDegreeCode R hH y) ∈ F ↔ ρ x = y := by + obtain ⟨ρ,hρ⟩ := reconstruct hH (setGraphReal_action R hc F hF) + refine ⟨ρ,?_⟩ + have he := setGraphReal_decodes R H F (fun z hz => ZFSet.mem_prod.mpr (hF.1.1 z hz)) + intro x y + rw [←he] + exact presentationGraph_actual R hH hc ρ hρ x y + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceEquationTail.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceEquationTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5ecfea2efe76c00c21e6ac3099d73c181fa067c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceEquationTail.lean @@ -0,0 +1,81 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.CohenBorelForcing +import OAI.Computability.DegreeRigidity.CohenForcing.ForcingSymmetry + +namespace OAI + +namespace TuringRigidity.SourceEquationTail +open Set CountableForcing +variable {P Q : Type*} [Preorder P] [Preorder Q] + +def productFilter (G : GenericFilter P) (H : GenericFilter Q) : GenericFilter (P × Q) where + carrier := {p | p.1 ∈ G.carrier ∧ p.2 ∈ H.carrier} + nonempty := by + obtain ⟨p,hp⟩ := G.nonempty + obtain ⟨q,hq⟩ := H.nonempty + exact ⟨(p,q),hp,hq⟩ + upper := fun hpq hp => ⟨G.upper hpq.1 hp.1,H.upper hpq.2 hp.2⟩ + directed := by + intro p q hp hq + obtain ⟨r,hr,hrp,hrq⟩ := G.directed hp.1 hq.1 + obtain ⟨s,hs,hsp,hsq⟩ := H.directed hp.2 hq.2 + exact ⟨(r,s),⟨hr,hs⟩,⟨hrp,hsp⟩,⟨hrq,hsq⟩⟩ + +theorem truth_liftFirst [OrderTop Q] (a : Sentence P) + (G : GenericFilter P) (H : GenericFilter Q) : + Sentence.Truth (productFilter G H) (Sentence.liftFirst a) ↔ Sentence.Truth G a := by + induction a with + | ground a => exact Iff.rfl + | member p => + obtain ⟨q,hq⟩ := H.nonempty + exact ⟨fun h => h.1,fun h => ⟨h,H.upper le_top hq⟩⟩ + | conj a b ha hb => exact and_congr ha hb + | existsNat a ha => exact exists_congr ha + | neg a ha => exact not_congr ha + +theorem requirements_liftFirst [OrderTop Q] (a : Sentence P) (n : ℕ) (p : P) (q : Q) : + (p,q) ∈ Sentence.Requirements (Sentence.liftFirst a) n ↔ + p ∈ Sentence.Requirements a n := by + induction a generalizing n with + | ground a => exact Iff.rfl + | member r => exact Iff.rfl + | conj a b ha hb => + simp only [Sentence.liftFirst,Sentence.Requirements] + split <;> first | exact ha _ | exact hb _ + | existsNat a ha => exact ha _ _ + | neg a ha => + simp only [Sentence.liftFirst,Sentence.Requirements] + split + · exact or_congr (Sentence.forces_liftFirst a p q) (Sentence.forces_liftFirst (.neg a) p q) + · exact ha _ + +theorem generic_product_liftFirst [OrderTop Q] (a : Sentence P) + (G : GenericFilter P) (H : GenericFilter Q) + (hG : GenericFor a.Requirements G) : + GenericFor (Sentence.Requirements (Sentence.liftFirst a)) (productFilter G H) := by + obtain ⟨q,hq⟩ := H.nonempty + intro n + obtain ⟨p,hp,hpn⟩ := hG n + exact ⟨(p,q),⟨hp,hq⟩,(requirements_liftFirst a n p q).mpr hpn⟩ + +theorem sourceEquation_tail_invariance (c : OracleCode) (R : Oracle) : + ∃ a : Sentence CohenBorelForcing.Condition, + (∀ A, Sentence.Truth (CohenBorelForcing.realFilter A) a ↔ + GenericIdentity.SourceEquation c R (GenericTruth.triple A)) ∧ + (∀ (Q : Type) [Preorder Q] [OrderTop Q] + (A : Oracle) (H : GenericFilter Q), + Sentence.Truth (productFilter (CohenBorelForcing.realFilter A) H) + (Sentence.liftFirst a) ↔ GenericIdentity.SourceEquation c R (GenericTruth.triple A)) ∧ + ∀ (Q : Type) [Preorder Q] [OrderTop Q] + (p : CohenBorelForcing.Condition) (q : Q), + Sentence.WeakForces (p,q) (Sentence.liftFirst a) ↔ Sentence.WeakForces p a := by + obtain ⟨a,ha⟩ := CohenBorelForcing.borel_represented _ + ((GenericIdentity.sourceEquation_measurable c R).preimage GenericTruth.triple_measurable) + refine ⟨a,ha,?_,?_⟩ + · intro Q _ _ A H + exact (truth_liftFirst a _ H).trans (ha A) + · intro Q _ _ p q + exact Sentence.weak_liftFirst a p q + +end TuringRigidity.SourceEquationTail + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceIdentity.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf8e662d981eadab30563db86b4e717b9e0b82bd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceIdentity.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.Representation.GenericIdentity +import OAI.Computability.DegreeRigidity.Representation.GenericRepresentation + +namespace OAI + +namespace TuringRigidity.GenericIdentity + +def RepresentsAt (π : Degree ≃o Degree) (p : OracleCode) (P A : Oracle) : Prop := + Total p P A ∧ degree (value p P A) = π (degree A) + +noncomputable def ImageJoin (p : OracleCode) (P Y G : Oracle) : Oracle := + join (value p P (GenericCoding.code Y G)) (value p P G) + +theorem imageJoin_degree (π : Degree ≃o Degree) (p : OracleCode) (P Y G : Oracle) + (hG : RepresentsAt π p P G) (hC : RepresentsAt π p P (GenericCoding.code Y G)) + (hi : GenericCoding.InfiniteOdd G) : + degree (ImageJoin p P Y G) = π (degree (join Y G)) := by + change degree (value p P (GenericCoding.code Y G)) ⊔ degree (value p P G) = _ + rw [hC.2,hG.2,←π.map_sup] + exact congrArg π (GenericCoding.join_degree_eq Y G hi) + +theorem source_5_4 (π : Degree ≃o Degree) (p : OracleCode) (P Y G0 G1 : Oracle) + (hG0 : RepresentsAt π p P G0) (hG1 : RepresentsAt π p P G1) + (hC0 : RepresentsAt π p P (GenericCoding.code Y G0)) + (hC1 : RepresentsAt π p P (GenericCoding.code Y G1)) + (hi0 : GenericCoding.InfiniteOdd G0) (hi1 : GenericCoding.InfiniteOdd G1) + (hI : PrincipalIntersection Y (join Y G0) (join Y G1)) : + ∀ b : Degree, b ≤ π (degree Y) ↔ + b ≤ degree (ImageJoin p P Y G0) ∧ b ≤ degree (ImageJoin p P Y G1) := by + rw [imageJoin_degree π p P Y G0 hG0 hC0 hi0, + imageJoin_degree π p P Y G1 hG1 hC1 hi1] + exact common_lower_transport π _ _ _ hI + +theorem source_5_5_iff (π : Degree ≃o Degree) (p : OracleCode) (P Y G0 G1 : Oracle) + (hG0 : RepresentsAt π p P G0) (hG1 : RepresentsAt π p P G1) + (hC0 : RepresentsAt π p P (GenericCoding.code Y G0)) + (hC1 : RepresentsAt π p P (GenericCoding.code Y G1)) + (hi0 : GenericCoding.InfiniteOdd G0) (hi1 : GenericCoding.InfiniteOdd G1) + (hI : PrincipalIntersection Y (join Y G0) (join Y G1)) : + SourceEquation p P (Y,G0,G1) ↔ RepresentsAt π p P Y := by + have h := source_5_4 π p P Y G0 G1 hG0 hG1 hC0 hC1 hi0 hi1 hI + constructor + · rintro ⟨hY,_,_,_,_,he⟩ + refine ⟨hY,le_antisymm ?_ ?_⟩ + · exact (h _).mpr ((he _).mp le_rfl) + · exact (he _).mpr ((h _).mp le_rfl) + · rintro ⟨hY,hdeg⟩ + refine ⟨hY,hG0.1,hG1.1,hC0.1,hC1.1,?_⟩ + intro b + change b ≤ degree (value p P Y) ↔ _ + rw [hdeg] + exact h b + +theorem selected_source_equation (D : ℕ → List Bool → Prop) + (hD : ∀ n, FiniteShuffle.DenseOpen (D n)) : + ∃ G : Bool → Oracle → Oracle, (∀ b, Measurable (G b)) ∧ + (∀ Y b, ShuffleRequirements.GenericFor D (G b Y) ∧ + ∀ X, ShuffleRequirements.GenericFor D (GenericCoding.code X (G b Y))) ∧ + ∀ (π : Degree ≃o Degree) p P Y, + (∀ b, RepresentsAt π p P (G b Y)) → + (∀ b, RepresentsAt π p P (GenericCoding.code Y (G b Y))) → + (SourceEquation p P (Y,G false Y,G true Y) ↔ RepresentsAt π p P Y) := by + obtain ⟨G,hG,hgen,hI⟩ := selected_generic_ideal D hD + refine ⟨G,hG,fun Y b => ⟨(hgen Y b).1,(hgen Y b).2.2⟩,?_⟩ + intro π p P Y hg hc + exact source_5_5_iff π p P Y (G false Y) (G true Y) (hg false) (hg true) + (hc false) (hc true) (hgen Y false).2.1 (hgen Y true).2.1 (hI Y) + +end TuringRigidity.GenericIdentity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTAbsolutenessEndpoint.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTAbsolutenessEndpoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..0116926319bf57d0cf1d72867c54daa5e5f94d22 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTAbsolutenessEndpoint.lean @@ -0,0 +1,36 @@ +import OAI.Computability.DegreeRigidity.Representation.NativePersistenceSyntax + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic ArithmeticPersistence BoundedSetTheory TransitiveNameModel +open SetModelReals SetModelFunctions SetModelSyntax SetDegreeDecoding SetModelCountability +open SetModelSatisfaction PersistentRestrictions +universe u +noncomputable section + +theorem source_4_2_2_transitive_countable (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) + (I : CountableIdeal) (hI : idealSet I ∈ M) (hct : InternallyCountable M (idealSet I)) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + ∃ D ∈ M, ∃ L ∈ M, + (∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A)) ∧ + (∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) ∧ + (∀ ρ : I ≃o I, automorphismSet ρ ∈ M → + (persistenceFormula.Realize M (cons D (cons L (cons (idealSet I) + (cons (automorphismSet ρ) (fun _ => ZFSet.omega))))) ↔ Persistent I ρ)) ∧ + (nonidentityFormula.Realize M (cons D (cons L (cons (idealSet I) (fun _ => ZFSet.omega)))) ↔ + ∃ ρ : I ≃o I, Persistent I ρ ∧ ∃ x : I, ρ x ≠ x) := by + let C := sourceContext M hM hT + obtain ⟨D,hDM,hD⟩ := degree_universe C + obtain ⟨L,hLM,hL⟩ := degree_order C + exact ⟨D,hDM,L,hLM,hD,hL, + fun ρ hρ => native_persistence_absolute M hM hT hDM hLM hD hL I hI hct ρ hρ hz, + (realize_nonidentityFormula M hM D L (idealSet I) hDM hLM hI C.omega_mem).trans + (native_nonidentity_absolute M hM hT hDM hLM hD hL I hI hct hz)⟩ + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTArithmeticAbsoluteness.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTArithmeticAbsoluteness.lean new file mode 100644 index 0000000000000000000000000000000000000000..979ed6b9922314dfbba204a173d652dafeb932ba --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTArithmeticAbsoluteness.lean @@ -0,0 +1,76 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelArithmeticTreeDescent + +namespace OAI + + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic BoundedSetTheory TransitiveNameModel ArithmeticPersistence ArithmeticHierarchy +universe u +noncomputable section + +theorem sourceT_exists_arithmetic_real (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {Q : Predicate} (hQ : Arith Q) (A R : Oracle) + (hA : A ∈ modelReals M) (hR : R ∈ modelReals M) (v : ℕ) : + (∃ H : Oracle, Q (parameters A R H) v) ↔ + ∃ H ∈ modelReals M, Q (parameters A R H) v := by + constructor + · rintro ⟨H,hH⟩ + obtain ⟨t,ht⟩ := (arithmetic_tests hQ).1 + have htest : ∃ H : Oracle, ∃ f : ℕ → ℕ, + ∀ n, t.eval (parameters A R H) f (Nat.pair v n) := + ⟨H,(ht (parameters A R H) v).mp hH⟩ + have hz : (fun _ : ℕ => false) ∈ modelReals M := + sourceT_arithmetic_real M hM hT (equal (Primrec.const 0) (Primrec.const 1)) + (fun _ => A) (fun _ => hA) _ (by intro n; simp) + have hO : ∀ i, parameters A R (fun _ => false) i ∈ modelReals M := by + intro i; rcases i with _|i; exact hA + rcases i with _|i; exact hR + exact hz + obtain ⟨s,G,hGM,hG,hs⟩ := t.mergeReal.sourceT_chain M hM hT + (parameters A R (fun _ => false)) hO v ((t.exists_mergeReal A R v).mp htest) + obtain ⟨F,hFM,hF⟩ := sourceT_chainGraph M hM hT s hGM hG + refine ⟨Test.realPart (chainValue s),sourceT_realPart M hM hT _ hFM hF,?_⟩ + exact (ht _ v).mpr ⟨Test.witnessPart (chainValue s), + fun n => (t.mergeReal_eval A R (chainValue s) (Nat.pair v n)).mp (hs n)⟩ + · rintro ⟨H,_,hH⟩ + exact ⟨H,hH⟩ + +theorem sourceT_forall_arithmetic_real (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {Q : Predicate} (hQ : Arith Q) (A R : Oracle) + (hA : A ∈ modelReals M) (hR : R ∈ modelReals M) (v : ℕ) : + (∀ H ∈ modelReals M, Q (parameters A R H) v) ↔ + ∀ H : Oracle, Q (parameters A R H) v := by + classical + constructor + · intro h H + by_contra hn + obtain ⟨K,hKM,hK⟩ := (sourceT_exists_arithmetic_real M hM hT hQ.neg A R hA hR v).mp ⟨H,hn⟩ + exact hK (h K hKM) + · exact fun h H _ => h H + +theorem sourceT_piOneOne (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {P : Oracle → Oracle → Prop} {Q : Predicate} (hQ : Arith Q) + (hiff : ∀ A R, P A R ↔ ∀ H : Oracle, Q (parameters A R H) 0) + (A R : Oracle) (hA : A ∈ modelReals M) (hR : R ∈ modelReals M) : + (∀ H ∈ modelReals M, Q (parameters A R H) 0) ↔ P A R := + (sourceT_forall_arithmetic_real M hM hT hQ A R hA hR 0).trans (hiff A R).symm + +theorem sourceT_persistence_presentation (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (A R : Oracle) (hA : A ∈ modelReals M) (hR : R ∈ modelReals M) : + (∀ H ∈ modelReals M, Base A R ∧ Matrix (parameters A R H) 0) ↔ Property A R := by + apply sourceT_piOneOne M hM hT (base_arith.and matrix_arith) _ A R hA hR + intro A R + rw [property_iff] + change Base A R ∧ Criterion A R ↔ ∀ H, Base A R ∧ + (NumericalIdeal.JumpCode H → NumericalIdeal.Includes A H → + ∃ e, NumericalAutomorphism.Action H + (fun v => tableOracle (OracleJump.iterate H 11) e v = true) ∧ + NumericalExtension.Compatible A H (fun v => R v = true) + (fun v => tableOracle (OracleJump.iterate H 11) e v = true)) + exact ⟨fun h H => ⟨h.1,h.2 H⟩, + fun h => ⟨(h FixedArithmetic.zero).1,fun H => (h H).2⟩⟩ + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTCountability.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTCountability.lean new file mode 100644 index 0000000000000000000000000000000000000000..9fb8dd5201ab8576d204f43b98e2bfedd79121c3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTCountability.lean @@ -0,0 +1,60 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTTreeAbsoluteness +import OAI.Computability.DegreeRigidity.SetModels.SetModelCountablePresentation +import OAI.Computability.DegreeRigidity.SetModels.SetModelPersistentSatisfaction + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic ArithmeticPersistence BoundedSetTheory TransitiveNameModel +open SetModelReals SetModelFunctions SetModelCountability SetModelSyntax SetDegreeDecoding +open PersistentPresentation PersistentRestrictions SetModelSatisfaction +universe u +noncomputable section + +theorem sourceT_internalChoice (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + SetModelCountability.InternalChoice M := by + intro a ha hne + obtain ⟨f,hf,hfg⟩ := hT.choice a ha (fun x hx => by + obtain ⟨y,_,hy⟩ := hne x (hM a ha x hx) hx + exact ⟨y,hy⟩) + have hu := union_mem M hM hT.union ha + have he : ∀ i, cons f (cons a (fun _ => ZFSet.sUnion a)) i ∈ M := by + intro i + rcases i with _|_|i <;> simp [hf,ha,hu] + refine ⟨f,hf,((choiceFormula 0 1 2).absolute M hM _ he).mpr ?_⟩ + rw [eval_choiceFormula] + change SetModelCountability.FunctionGraph f a (ZFSet.sUnion a) ∧ ∀ x ∈ a, ∃ y ∈ x, ZFSet.pair x y ∈ f + refine ⟨⟨?_,?_⟩,?_⟩ + · intro z hz + obtain ⟨x,hx,y,hy,heq⟩ := hfg.1 z hz + exact ⟨x,hx,y,ZFSet.mem_sUnion.mpr ⟨x,hx,hy⟩,heq⟩ + · intro x hx + obtain ⟨y,hy,hxy,_⟩ := hfg.2 x hx + exact ⟨y,ZFSet.mem_sUnion.mpr ⟨x,hx,hy⟩,hxy, + fun z _ hxz => hfg.functional hxz hxy⟩ + · intro x hx + obtain ⟨y,hy,hxy,_⟩ := hfg.2 x hx + exact ⟨y,hy,hxy⟩ + +theorem sourceT_countable_presentation (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (I : CountableIdeal) (hI : idealSet I ∈ M) (hct : InternallyCountable M (idealSet I)) : + ∃ A ∈ reals M, Presented I A := + countable_presentation (sourceContext M hM hT) (sourceT_internalChoice M hM hT) I hI hct + +theorem sourceT_native_persistence (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (I : CountableIdeal) (hI : idealSet I ∈ M) (hct : InternallyCountable M (idealSet I)) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + ∃ D ∈ M, ∃ L ∈ M, + (∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A)) ∧ + (∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) ∧ + automorphismSet ρ ∈ M ∧ + persistenceFormula.Realize M (cons D (cons L (cons (idealSet I) + (cons (automorphismSet ρ) (fun _ => ZFSet.omega))))) := + source_4_2_5_transitive (sourceContext M hM hT) (sourceT_internalChoice M hM hT) I hI hct ρ hρ hz + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTDependentChoice.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTDependentChoice.lean new file mode 100644 index 0000000000000000000000000000000000000000..fdcc5881a4d12abd13a2d15c3b35bc6f08cc5983 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTDependentChoice.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalFunctionOrbit +import OAI.Computability.DegreeRigidity.SetModels.InternalSerialSelection +import OAI.Computability.DegreeRigidity.Representation.SourceTWellFounded + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse InternalWellOrder +universe u + +theorem sourceT_dependent_choice (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {d r x : ZFSet.{u}} (hd : d ∈ M) (hr : r ∈ M) (hx : x ∈ d) + (hser : ∀ x ∈ d, ∃ y ∈ d, ZFSet.pair y x ∈ r) : + ∃ a : ℕ → ZFSet.{u}, a 0 = x ∧ (∀ n, a n ∈ d) ∧ orbitGraph a ∈ M ∧ + ∀ n, ZFSet.pair (a (n+1)) (a n) ∈ r := by + classical + obtain ⟨F,hFM,hF,hrel⟩ := internal_serial_function M hM hT hd hr hser + let next (y : ZFSet.{u}) : ZFSet.{u} := if hy : y ∈ d then (hF.2 y hy).choose else y + have hn (y : ZFSet.{u}) (hy : y ∈ d) : next y ∈ d ∧ ZFSet.pair y (next y) ∈ F := by + simp only [next,dite_eq_left hy] + exact ⟨(hF.2 y hy).choose_spec.1,(hF.2 y hy).choose_spec.2.1⟩ + let a : ℕ → ZFSet.{u} := Nat.rec x (fun _ y => next y) + have ha : ∀ n, a n ∈ d := by + intro n + induction n with + | zero => exact hx + | succ n ih => exact (hn (a n) ih).1 + have hstep : ∀ n, ZFSet.pair (a n) (a (n+1)) ∈ F := fun n => (hn (a n) (ha n)).2 + exact ⟨a,rfl,ha,internal_orbitGraph M hM hT hd hFM hF a ha hstep, + fun n => hrel _ _ (hstep n)⟩ + +theorem sourceT_internal_descent (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {d r : ZFSet.{u}} (hd : d ∈ M) (hr : r ∈ M) (hon : On d r) + (hw : ¬ WellFounded (Rel d r)) : + ∃ a : ℕ → ZFSet.{u}, (∀ n, a n ∈ d) ∧ orbitGraph a ∈ M ∧ + ∀ n, ZFSet.pair (a (n+1)) (a n) ∈ r := by + classical + have hn : ¬ InternallyWellFounded M d r := fun h => hw (sourceT_wellFounded M hM hT hd hr hon h) + change ¬ (∀ b ∈ M, b ⊆ d → (∃ x, x ∈ b) → ∃ x, MinimalIn r b x) at hn + simp only [not_forall] at hn + obtain ⟨b,hb,hbd,hne,hbad⟩ := hn + obtain ⟨x,hx⟩ := hne + have hser : ∀ x ∈ b, ∃ y ∈ b, ZFSet.pair y x ∈ r := by + intro y hy + by_contra hn + exact hbad ⟨y,hy,fun z hz hzy => hn ⟨z,hz,hzy⟩⟩ + obtain ⟨a,_,ha,hAM,hstep⟩ := sourceT_dependent_choice M hM hT hb hr hx hser + exact ⟨a,fun n => hbd (ha n),hAM,hstep⟩ + +theorem wellFounded_no_descent (d r : ZFSet.{u}) (hw : WellFounded (Rel d r)) + (a : ℕ → ZFSet.{u}) (ha : ∀ n, a n ∈ d) + (hstep : ∀ n, ZFSet.pair (a (n+1)) (a n) ∈ r) : False := by + have hno (x : ZFSet.{u}) : Acc (Rel d r) x → ∀ n, a n = x → False := by + intro hx + induction hx with + | intro x _ ih => + intro n he + exact ih (a (n+1)) ⟨ha (n+1),he ▸ hstep n⟩ (n+1) rfl + exact hno (a 0) (hw.apply (a 0)) 0 rfl + +theorem sourceT_descent_absolute (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {d r : ZFSet.{u}} (hd : d ∈ M) (hr : r ∈ M) (hon : On d r) : + (∃ a : ℕ → ZFSet.{u}, (∀ n, a n ∈ d) ∧ orbitGraph a ∈ M ∧ + ∀ n, ZFSet.pair (a (n+1)) (a n) ∈ r) ↔ ¬ WellFounded (Rel d r) := by + constructor + · rintro ⟨a,ha,_,hstep⟩ hw + exact wellFounded_no_descent d r hw a ha hstep + · exact sourceT_internal_descent M hM hT hd hr hon + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTGenericExistence.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTGenericExistence.lean new file mode 100644 index 0000000000000000000000000000000000000000..460edd8b1f3ef2123f6471436a9706df0987396a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTGenericExistence.lean @@ -0,0 +1,54 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTGenericPresentation + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic ArithmeticPersistence BoundedSetTheory TransitiveNameModel +open SetModelReals CountableForcing +universe u +noncomputable section + +theorem countable_ground_generic (M : ZFSet.{u}) + (hct : (M : Set ZFSet.{u}).Countable) (hne : (M : Set ZFSet.{u}).Nonempty) + {c : ZFSet.{u}} [Preorder (Conditions c)] (p : Conditions c) : + ∃ G : GenericFilter (Conditions c), p ∈ G.carrier ∧ AtomicForcing.GroundGeneric M G := by + classical + obtain ⟨e,he⟩ := hct.exists_eq_range hne + let D : ℕ → Set (Conditions c) := fun n => + if Dense {q | label c q ∈ e n} then {q | label c q ∈ e n} else Set.univ + have hd : ∀ n, Dense (D n) := by + intro n + dsimp only [D] + split + · assumption + · exact fun q => ⟨q,le_rfl,Set.mem_univ q⟩ + obtain ⟨G,hp,hG⟩ := exists_generic D hd p + refine ⟨G,hp,?_⟩ + intro a ha had + have har : a ∈ Set.range e := he ▸ ha + obtain ⟨n,rfl⟩ := har + obtain ⟨q,hq,hqd⟩ := hG n + exact ⟨q,hq,by simpa only [D,ite_eq_left had,Set.mem_ofPred_eq] using hqd⟩ + +theorem sourceT_generic_exists (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hct : (M : Set ZFSet.{u}).Countable) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [OrderTop (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (p : Conditions c) : + ∃ G : GenericFilter (Conditions c), p ∈ G.carrier ∧ AtomicForcing.GroundGeneric M G ∧ + M ⊆ genericExtensionSet M c G.carrier ∧ + Transitive (genericExtensionSet M c G.carrier) ∧ + SourceT (genericExtensionSet M c G.carrier) := by + obtain ⟨G,hp,hG⟩ := countable_ground_generic M hct ⟨c,hc⟩ p + have ht : ⊤ ∈ G.carrier := G.upper le_top hp + exact ⟨G,hp,hG, + ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht, + genericExtensionSet_transitive M c hM G.carrier, + extension_sourceT M hM hT hc hoM ho G hG ht⟩ + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTGenericPersistence.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTGenericPersistence.lean new file mode 100644 index 0000000000000000000000000000000000000000..947f334adf539e09f0d55e940b694b1d72a0f2a6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTGenericPersistence.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTAbsolutenessEndpoint +import OAI.Computability.DegreeRigidity.Representation.SourceTGenericExistence + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic ArithmeticPersistence BoundedSetTheory TransitiveNameModel +open SetModelReals SetModelFunctions SetModelSyntax SetDegreeDecoding SetModelCountability +open SetModelSatisfaction PersistentRestrictions CountableForcing +universe u +noncomputable section + +def NativePersistent (M : ZFSet.{u}) (I : CountableIdeal) (ρ : I ≃o I) : Prop := + ∃ D ∈ M, ∃ L ∈ M, + (∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A)) ∧ + (∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) ∧ + persistenceFormula.Realize M (cons D (cons L (cons (idealSet I) + (cons (automorphismSet ρ) (fun _ => ZFSet.omega))))) + +theorem nativePersistent_iff (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (I : CountableIdeal) (hI : idealSet I ∈ M) (hct : InternallyCountable M (idealSet I)) + (ρ : I ≃o I) (hρ : automorphismSet ρ ∈ M) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + NativePersistent M I ρ ↔ Persistent I ρ := by + constructor + · rintro ⟨D,hDM,L,hLM,hD,hL,hp⟩ + exact (native_persistence_absolute M hM hT hDM hLM hD hL I hI hct ρ hρ hz).mp hp + · intro hp + obtain ⟨D,hDM,L,hLM,hD,hL,hpD,_⟩ := source_4_2_2_transitive_countable M hM hT I hI hct hz + exact ⟨D,hDM,L,hLM,hD,hL,(hpD ρ hρ).mpr hp⟩ + +theorem generic_nativePersistent_iff (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (ht : ⊤ ∈ G.carrier) + (I : CountableIdeal) (hI : idealSet I ∈ M) (ρ : I ≃o I) (hρ : automorphismSet ρ ∈ M) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (hct : InternallyCountable (genericExtensionSet M c G.carrier) (idealSet I)) : + NativePersistent (genericExtensionSet M c G.carrier) I ρ ↔ Persistent I ρ := by + have hsub := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht + exact nativePersistent_iff _ (genericExtensionSet_transitive M c hM G.carrier) + (extension_sourceT M hM hT hc hoM ho G hG ht) I (hsub hI) hct ρ (hsub hρ) hz + +theorem generic_persistence_transfer (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o d v : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + [Preorder (Conditions d)] [Top (Conditions d)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (hd : d ∈ M) (hvM : v ∈ M) + (hv : ∀ r s : Conditions d, ZFSet.pair (label d r) (label d s) ∈ v ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (htG : ⊤ ∈ G.carrier) + (H : GenericFilter (Conditions d)) (hH : AtomicForcing.GroundGeneric M H) (htH : ⊤ ∈ H.carrier) + (I : CountableIdeal) (hI : idealSet I ∈ M) (ρ : I ≃o I) (hρ : automorphismSet ρ ∈ M) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (hctG : InternallyCountable (genericExtensionSet M c G.carrier) (idealSet I)) + (hctH : InternallyCountable (genericExtensionSet M d H.carrier) (idealSet I)) : + NativePersistent (genericExtensionSet M c G.carrier) I ρ ↔ + NativePersistent (genericExtensionSet M d H.carrier) I ρ := + (generic_nativePersistent_iff M hM hT hc hoM ho G hG htG I hI ρ hρ hz hctG).trans + (generic_nativePersistent_iff M hM hT hd hvM hv H hH htH I hI ρ hρ hz hctH).symm + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTGenericPresentation.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTGenericPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..51a149d7622f626df1575a8ebc3811f7520bfde7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTGenericPresentation.lean @@ -0,0 +1,33 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTPresentationComparison + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic ArithmeticPersistence BoundedSetTheory TransitiveNameModel +open SetModelReals +universe u +noncomputable section + +theorem generic_presentation_comparison (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : CountableForcing.GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) + (htop : ⊤ ∈ G.carrier) (A R : Oracle) (hA : A ∈ reals M) (hR : R ∈ reals M) : + (InternalPresentation M A R ↔ InternalPresentation (genericExtensionSet M c G.carrier) A R) ∧ + (InternalNonidentity M A ↔ InternalNonidentity (genericExtensionSet M c G.carrier) A) := by + have hsub := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier htop + have hAE : A ∈ reals (genericExtensionSet M c G.carrier) := by + change realSet.{u} A ∈ genericExtensionSet M c G.carrier + exact hsub hA + have hRE : R ∈ reals (genericExtensionSet M c G.carrier) := by + change realSet.{u} R ∈ genericExtensionSet M c G.carrier + exact hsub hR + exact presentation_comparison M _ hM (genericExtensionSet_transitive M c hM G.carrier) + hT (extension_sourceT M hM hT hc hoM ho G hG htop) A R hA hAE hR hRE + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTModelBridge.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTModelBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..8867f908402ff5737a816f3ac5504d1f590e9f8d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTModelBridge.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTPersistentDecoding +import OAI.Computability.DegreeRigidity.Representation.SetAutomorphismReconstruction + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel EncodedForcing PersistentRestrictions PersistentPresentation OracleJump +universe u + +noncomputable def modelDegreeEnv (R I F : ZFSet.{u}) : ℕ → ZFSet.{u} := + cons ZFSet.omega (cons (degreeUniverse R) (cons (degreeOrder R) (cons I (fun _ => F)))) + +theorem sourceT_arbitrary_persistent_graph (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ A : Oracle, realCode A ∈ R ↔ A ∈ modelReals M) + (hRd : ∀ w ∈ R, ∃ B : Oracle, realCode B = w) + {J : CountableIdeal} {A : Oracle} (hA : Presented J A) (hAM : A ∈ modelReals M) + (ρ : J ≃o J) (hp : Persistent J ρ) (hz : degree (jump FixedArithmetic.zero) ∈ J.carrier) + (F : ZFSet.{u}) (hshape : F ⊆ ZFSet.prod (presentationSet R A) (presentationSet R A)) + (hF : ∀ x y : J, ZFSet.pair (presentedDegreeCode R hA x) (presentedDegreeCode R hA y) ∈ F ↔ ρ x = y) : + F ∈ M ∧ (LevySigma.persistent 0 1 2 3 4).Realize M (modelDegreeEnv R (presentationSet R A) F) := by + have hc : ∀ n, realCode (columns A n) ∈ R := fun n => (hR _).mpr (sourceT_real_column M hM hT hAM n) + have hg : ∀ v, PersistentCountability.graphOracle hA ρ v = true ↔ Graph ρ hA v := by + intro v; simp [PersistentCountability.graphOracle] + have hEq := presentationGraph_unique R hA hc ρ hg F hshape hF + have hFM : F ∈ M := hEq.symm ▸ (sourceT_persistent_graph_set M hM hT R hRM hR hRd hA hAM ρ hp hz).1 + refine ⟨hFM,?_⟩ + have he : ∀ i, modelDegreeEnv R (presentationSet R A) F i ∈ M := by + intro i + rcases i with _|i; exact sourceT_omega_mem M hM hT + rcases i with _|i; exact internal_degreeUniverse M hM hT R hRM hRd + rcases i with _|i; exact internal_degreeOrder M hM hT R hRM hRd + rcases i with _|i; exact internal_presentationSet M hM hT R hRM hR hRd hAM + exact hFM + apply (LevySigma.realize_persistent M hM 0 1 2 3 4 _ he rfl).mpr + change ModelPersistent M (degreeUniverse R) (degreeOrder R) (presentationSet R A) F + rw [hEq] + exact sourceT_presentation_modelPersistent M hM hT R hRM hR hRd hA hAM ρ hp hz + +theorem source_4_2_4_4_2_5_transitive (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ∃ R ∈ M, degreeUniverse R ∈ M ∧ degreeOrder R ∈ M ∧ + ∀ I ∈ M, + (Formula.setIdeal 1 2 3).Realize M (modelDegreeEnv R I I) → + (LevySigma.countable 0 3).Realize M (modelDegreeEnv R I I) → + degreeCode R (jump FixedArithmetic.zero) ∈ I → + ∃ J : CountableIdeal, ∃ A ∈ modelReals M, ∃ hA : Presented J A, + presentationSet R A = I ∧ + (Function.Injective (presentedDegreeCode R hA)) ∧ + (∀ D ∈ I, ∃ x : J, presentedDegreeCode R hA x = D) ∧ + (∀ x y : J, ZFSet.pair (presentedDegreeCode R hA x) (presentedDegreeCode R hA y) ∈ degreeOrder R ↔ x ≤ y) ∧ + ∀ F : ZFSet.{u}, SetAutomorphism I (degreeOrder R) F → + ∃ ρ : J ≃o J, + (∀ x y : J, ZFSet.pair (presentedDegreeCode R hA x) (presentedDegreeCode R hA y) ∈ F ↔ ρ x = y) ∧ + (Persistent J ρ → F ∈ M ∧ (LevySigma.persistent 0 1 2 3 4).Realize M (modelDegreeEnv R I F)) := by + obtain ⟨R,hRM,hR,hRd'⟩ := internal_real_power M hM hT + have hRd : ∀ w ∈ R, ∃ B : Oracle, realCode B = w := fun w hw => by + obtain ⟨B,_,hB⟩ := hRd' w hw; exact ⟨B,hB⟩ + have hU := internal_degreeUniverse M hM hT R hRM hRd + have hL := internal_degreeOrder M hM hT R hRM hRd + refine ⟨R,hRM,hU,hL,?_⟩ + intro I hIM hIf hcf hz + have he : ∀ i, modelDegreeEnv R I I i ∈ M := by + intro i + rcases i with _|i; exact sourceT_omega_mem M hM hT + rcases i with _|i; exact hU + rcases i with _|i; exact hL + rcases i with _|i; exact hIM + exact hIM + have hI := (Formula.realize_setIdeal M hM 1 2 3 _ he).mp hIf + have hc := (LevySigma.realize_countable M hM 0 3 _ he rfl).mp hcf + obtain ⟨J,A,hAM,hA,hAI⟩ := sourceT_countable_ideal_presentation M hM hT R hR hRd hIM hI hc + have hcA : ∀ n, realCode (columns A n) ∈ R := fun n => (hR _).mpr (sourceT_real_column M hM hT hAM n) + have hzJ : degree (jump FixedArithmetic.zero) ∈ J.carrier := (hA _).mpr + ((degreeCode_mem_presentationSet R A hcA _).mp (hAI.symm ▸ hz)) + refine ⟨J,A,hAM,hA,hAI,presentedDegreeCode_injective R hA hcA,?_,presentedDegreeCode_order R hA hcA,?_⟩ + · intro D hD + exact presentedDegreeCode_onto R hA hcA D (hAI.symm ▸ hD) + · intro F hF + have hFa : SetAutomorphism (presentationSet R A) (degreeOrder R) F := hAI.symm ▸ hF + obtain ⟨ρ,hρ⟩ := setAutomorphism_reconstruct R hA hcA F hFa + refine ⟨ρ,hρ,fun hp => ?_⟩ + have h := sourceT_arbitrary_persistent_graph M hM hT R hRM hR hRd hA hAM ρ hp hzJ F + (fun z hz => ZFSet.mem_prod.mpr (hFa.1.1 z hz)) hρ + rwa [hAI] at h + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTNativeAbsoluteness.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTNativeAbsoluteness.lean new file mode 100644 index 0000000000000000000000000000000000000000..842cbe6627e2cee568f4754131fa9fef214374d8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTNativeAbsoluteness.lean @@ -0,0 +1,76 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTPresentationComparison +import OAI.Computability.DegreeRigidity.Representation.SourceTCountability +import OAI.Computability.DegreeRigidity.SetModels.SetModelPersistenceDecoding + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic ArithmeticPersistence BoundedSetTheory TransitiveNameModel +open SetModelReals SetModelFunctions SetModelSyntax SetDegreeDecoding SetModelCountability +open SetModelSatisfaction PersistentRestrictions PersistentPresentation PersistentCountability +open NumericalAutomorphism NumericalIdeal NumericalExtension +universe u +noncomputable section + +theorem native_internal_matrix {M : ZFSet.{u}} (C : Context M) + {D L : ZFSet.{u}} (hDM : D ∈ M) (hLM : L ∈ M) + (hD : ∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A)) + (hL : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + (I : CountableIdeal) (hI : idealSet I ∈ M) (ρ : I ≃o I) (hρ : automorphismSet ρ ∈ M) + {A R : Oracle} (hA : Presented I A) + (hR : ∀ n, R n = true ↔ Graph ρ hA n) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + (hp : persistenceFormula.Realize M (cons D (cons L (cons (idealSet I) + (cons (automorphismSet ρ) (fun _ => ZFSet.omega)))))) : + ∀ H ∈ reals M, Matrix (parameters A R H) 0 := by + intro H hHM hcode hincl + let J := decode H hcode + have hJ : Presented J H := decoded_presentation H hcode + have hIJ : I.carrier ⊆ J.carrier := (includes_iff hA hJ).mp hincl + let K₀ := JumpIdeal.generated (degree H) + let B := JumpIdealPresentation.presentation H + have hB : Presented K₀ B := JumpIdealPresentation.presents H + have hBM : B ∈ reals M := (realClosure C).presentation hHM + obtain ⟨K,hIK,τ,hBK,he⟩ := decode_persistence_extension C hDM hLM hD hL I hI ρ hρ hp hBM + have hK₀K : K₀.carrier ⊆ K.carrier := by + intro x hx + obtain ⟨n,rfl⟩ := (hB x).mp hx + exact K.lower (CodingExtraction.column_projection_reduces B n) hBK + have hJK₀ : J.carrier ⊆ K₀.carrier := by + intro x hx + obtain ⟨n,rfl⟩ := (hJ x).mp hx + exact K₀.lower (CodingExtraction.column_projection_reduces H n) (JumpIdeal.includes _) + have hJK : J.carrier ⊆ K.carrier := fun x hx => hK₀K (hJK₀ hx) + obtain ⟨σ,hσ,_,hr⟩ := PersistentRestrictionCode.restriction ρ τ hIK he hz hIJ hJK + (decoded_closed H hcode) hJ hK₀K + obtain ⟨e,hg⟩ := graph_program hJ σ hr + refine ⟨e,(PersistenceCriterion.action_congr hg).mpr (action_of_automorphism hJ σ),?_⟩ + intro i j n m hr hp hin + exact ((compatible_iff hA hJ hIJ ρ σ).mpr hσ) i j n m ((hR _).mp hr) ((hg _).mp hp) hin + +theorem sourceT_native_persistence_iff (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {D L : ZFSet.{u}} (hDM : D ∈ M) (hLM : L ∈ M) + (hD : ∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A)) + (hL : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + (I : CountableIdeal) (hI : idealSet I ∈ M) (hct : InternallyCountable M (idealSet I)) + (ρ : I ≃o I) (hρ : automorphismSet ρ ∈ M) + {A R : Oracle} (hA : Presented I A) (hAM : A ∈ reals M) (hRM : R ∈ reals M) + (hR : ∀ n, R n = true ↔ Graph ρ hA n) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + persistenceFormula.Realize M (cons D (cons L (cons (idealSet I) + (cons (automorphismSet ρ) (fun _ => ZFSet.omega))))) ↔ Persistent I ρ := by + let C := sourceContext M hM hT + constructor + · intro hp + have hi := native_internal_matrix C hDM hLM hD hL I hI ρ hρ hA hR hz hp + have he := (sourceT_piOneOne_matrix M hM hT matrix_arith A R hAM hRM 0).mp hi + exact (ArithmeticPersistence.persistent_iff hA ρ hz hR).mpr he + · intro hp + exact persistent_satisfaction C (sourceT_internalChoice M hM hT) hDM hLM hD hL I hI hct ρ hp hz + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTNativeComparison.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTNativeComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..490617d09aca68f7f9b80daa439792cf9aa680c8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTNativeComparison.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTNativeAbsoluteness +import OAI.Computability.DegreeRigidity.SetModels.SetModelGraphPresentation + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic ArithmeticPersistence BoundedSetTheory TransitiveNameModel +open SetModelReals SetModelFunctions SetModelSyntax SetDegreeDecoding SetModelCountability +open SetModelSatisfaction PersistentRestrictions PersistentPresentation PersistentCountability +universe u +noncomputable section + +theorem native_persistence_absolute (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {D L : ZFSet.{u}} (hDM : D ∈ M) (hLM : L ∈ M) + (hD : ∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A)) + (hL : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + (I : CountableIdeal) (hI : idealSet I ∈ M) (hct : InternallyCountable M (idealSet I)) + (ρ : I ≃o I) (hρ : automorphismSet ρ ∈ M) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + persistenceFormula.Realize M (cons D (cons L (cons (idealSet I) + (cons (automorphismSet ρ) (fun _ => ZFSet.omega))))) ↔ Persistent I ρ := by + obtain ⟨A,hAM,hA⟩ := sourceT_countable_presentation M hM hT I hI hct + have hRM := internal_graph_presentation (sourceContext M hM hT) hA hAM hI ρ hρ + exact sourceT_native_persistence_iff M hM hT hDM hLM hD hL I hI hct ρ hρ hA hAM hRM + (fun n => by simp [graphOracle]) hz + +def SetMoved (f i : ZFSet.{u}) : Prop := ∃ x ∈ i, ∃ y ∈ i, ZFSet.pair x y ∈ f ∧ x ≠ y + +theorem setMoved_iff (I : CountableIdeal) (ρ : I ≃o I) : + SetMoved (automorphismSet.{u} ρ) (idealSet I) ↔ ∃ x : I, ρ x ≠ x := by + constructor + · rintro ⟨x,hx,y,hy,hxy,hne⟩ + obtain ⟨a,ha,rfl⟩ := (mem_idealSet I x).mp hx + obtain ⟨b,hb,rfl⟩ := (mem_idealSet I y).mp hy + have hab := (action_code ρ ⟨a,ha⟩ ⟨b,hb⟩).mp hxy + refine ⟨⟨a,ha⟩,fun he => hne ?_⟩ + exact congrArg (fun x : I => degreeSet.{u} x.val) (he.symm.trans hab) + · rintro ⟨a,ha⟩ + exact ⟨degreeSet a.val,(mem_idealSet I _).mpr ⟨_,a.property,rfl⟩, + degreeSet (ρ a).val,(mem_idealSet I _).mpr ⟨_,(ρ a).property,rfl⟩, + (action_code ρ a (ρ a)).mpr rfl, + fun he => ha (Subtype.ext (degreeSet_injective he).symm)⟩ + +def NativeNonidentity (M D L i : ZFSet.{u}) : Prop := + ∃ f ∈ M, IsAction f i L ∧ SetMoved f i ∧ + persistenceFormula.Realize M (cons D (cons L (cons i (cons f (fun _ => ZFSet.omega))))) + +theorem native_nonidentity_absolute (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {D L : ZFSet.{u}} (hDM : D ∈ M) (hLM : L ∈ M) + (hD : ∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A)) + (hL : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + (I : CountableIdeal) (hI : idealSet I ∈ M) (hct : InternallyCountable M (idealSet I)) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + NativeNonidentity M D L (idealSet I) ↔ ∃ ρ : I ≃o I, Persistent I ρ ∧ ∃ x : I, ρ x ≠ x := by + let C := sourceContext M hM hT + constructor + · rintro ⟨f,hf,ha,hm,hp⟩ + obtain ⟨ρ,rfl⟩ := decode_action C hL I hI ha + exact ⟨ρ,(native_persistence_absolute M hM hT hDM hLM hD hL I hI hct ρ hf hz).mp hp, + (setMoved_iff I ρ).mp hm⟩ + · rintro ⟨ρ,hp,hm⟩ + have hρ := persistent_mem_of_countable C (sourceT_internalChoice M hM hT) I hI hct ρ hp hz + exact ⟨automorphismSet ρ,hρ,action_satisfaction C hL hI ρ,(setMoved_iff I ρ).mpr hm, + (native_persistence_absolute M hM hT hDM hLM hD hL I hI hct ρ hρ hz).mpr hp⟩ + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTPersistentDecoding.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTPersistentDecoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..c20584e1105fd2f8bd11e09893e5a228549cfe5b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTPersistentDecoding.lean @@ -0,0 +1,77 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelPersistenceSatisfaction + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel EncodedForcing PersistentRestrictions PersistentPresentation OracleJump +open NumericalIdeal NumericalAutomorphism NumericalExtension +universe u + +theorem sourceT_presentation_modelPersistent (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ A : Oracle, realCode A ∈ R ↔ A ∈ modelReals M) + (hRd : ∀ w ∈ R, ∃ B : Oracle, realCode B = w) + {I : CountableIdeal} {A : Oracle} (hA : Presented I A) (hAM : A ∈ modelReals M) + (ρ : I ≃o I) (hp : Persistent I ρ) (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) : + ModelPersistent M (degreeUniverse R) (degreeOrder R) (presentationSet R A) + (presentationGraph R A (PersistentCountability.graphOracle hA ρ)) := by + let G := PersistentCountability.graphOracle hA ρ + have hG : ∀ v, G v = true ↔ Graph ρ hA v := by intro v; simp [G,PersistentCountability.graphOracle] + have hcA : ∀ n, realCode (columns A n) ∈ R := fun n => (hR _).mpr (sourceT_real_column M hM hT hAM n) + refine ⟨presentationGraph_automorphism R hA hcA ρ hG,?_⟩ + intro D hD + obtain ⟨X,hX,rfl⟩ := (mem_degreeUniverse R D).mp hD + obtain ⟨H,hHM,S,hSM,hJ,hin,hXH,ha,hcompat⟩ := + sourceT_persistent_extension_reals M hM hT hA hAM ρ hp hz hG ((hR X).mp hX) + have hH := decoded_presentation H hJ + have hcH : ∀ n, realCode (columns H n) ∈ R := fun n => (hR _).mpr (sourceT_real_column M hM hT hHM n) + obtain ⟨hJM,E,hEM,hE,honto⟩ := internal_presentation_countable M hM hT R hRM hR hRd hHM + refine ⟨presentationSet R H,hJM,presentationGraph R H S, + internal_presentationGraph M hM hT R hRM hR hRd hHM hSM,E,hEM, + presentationSet_ideal R hH hcH,⟨hE,honto⟩,presentationGraph_action R hH hcH ha, + presentationSet_subset_of_includes R hcA hin,?_, + presentationGraph_subset_of_compatible R hcA hin ha hcompat⟩ + obtain ⟨n,hn⟩ := hXH + exact (mem_presentationSet R H _).mpr ⟨n,(degreeCode_equal R hX).mpr hn⟩ + +theorem sourceT_persistent_decoding (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ A : Oracle, realCode A ∈ R ↔ A ∈ modelReals M) + (hRd : ∀ w ∈ R, ∃ B : Oracle, realCode B = w) + {I : ZFSet.{u}} (hIM : I ∈ M) + (hI : SetIdeal (degreeUniverse R) (degreeOrder R) I) (hcount : InternallyCountable M I) + (hz : degreeCode R (jump FixedArithmetic.zero) ∈ I) : + ∃ J : CountableIdeal, ∃ A ∈ modelReals M, ∃ hA : Presented J A, presentationSet R A = I ∧ + ∀ ρ : J ≃o J, Persistent J ρ → + let F := presentationGraph R A (PersistentCountability.graphOracle hA ρ) + F ∈ M ∧ ModelPersistent M (degreeUniverse R) (degreeOrder R) I F := by + obtain ⟨J,A,hAM,hA,hAI⟩ := sourceT_countable_ideal_presentation M hM hT R hR hRd hIM hI hcount + have hcA : ∀ n, realCode (columns A n) ∈ R := fun n => (hR _).mpr (sourceT_real_column M hM hT hAM n) + have hzJ : degree (jump FixedArithmetic.zero) ∈ J.carrier := by + apply (hA _).mpr + exact (degreeCode_mem_presentationSet R A hcA _).mp (hAI.symm ▸ hz) + refine ⟨J,A,hAM,hA,hAI,?_⟩ + intro ρ hp + refine ⟨(sourceT_persistent_graph_set M hM hT R hRM hR hRd hA hAM ρ hp hzJ).1,?_⟩ + rw [←hAI] + exact sourceT_presentation_modelPersistent M hM hT R hRM hR hRd hA hAM ρ hp hzJ + +theorem sourceT_internal_degrees_and_decoding (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ∃ R ∈ M, (∀ A : Oracle, realCode A ∈ R ↔ A ∈ modelReals M) ∧ + degreeUniverse R ∈ M ∧ degreeOrder R ∈ M ∧ + ∀ I ∈ M, SetIdeal (degreeUniverse R) (degreeOrder R) I → InternallyCountable M I → + degreeCode R (jump FixedArithmetic.zero) ∈ I → + ∃ J : CountableIdeal, ∃ A ∈ modelReals M, ∃ hA : Presented J A, presentationSet R A = I ∧ + ∀ ρ : J ≃o J, Persistent J ρ → + let F := presentationGraph R A (PersistentCountability.graphOracle hA ρ) + F ∈ M ∧ ModelPersistent M (degreeUniverse R) (degreeOrder R) I F := by + obtain ⟨R,hRM,hR,hRd⟩ := internal_real_power M hM hT + have hd : ∀ w ∈ R, ∃ B : Oracle, realCode B = w := fun w hw => by + obtain ⟨B,_,hB⟩ := hRd w hw; exact ⟨B,hB⟩ + exact ⟨R,hRM,hR,internal_degreeUniverse M hM hT R hRM hd,internal_degreeOrder M hM hT R hRM hd, + fun I hIM hI hc hz => sourceT_persistent_decoding M hM hT R hRM hR hd hIM hI hc hz⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTPresentationComparison.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTPresentationComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..a9f971e93b03d914ee7cf5be62b96b68d7508266 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTPresentationComparison.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTTreeAbsoluteness +import OAI.Computability.DegreeRigidity.SetModels.SetModelArithmeticDischarge + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic ArithmeticPersistence BoundedSetTheory TransitiveNameModel +open SetModelFunctions SetModelReals SetModelSyntax PersistentPresentation +universe u +noncomputable section +attribute [local instance] Classical.propDecidable + +def PresentationMatrix (O : Oracles) (v : ℕ) : Prop := Base (O 0) (O 1) ∧ Matrix O v + +theorem presentationMatrix_arith : Arith PresentationMatrix := base_arith.and matrix_arith + +theorem presentationMatrix_iff (A R : Oracle) : + (∀ H : Oracle, PresentationMatrix (parameters A R H) 0) ↔ Property A R := by + rw [property_iff] + change (∀ H, Base A R ∧ Matrix (parameters A R H) 0) ↔ Base A R ∧ Criterion A R + exact ⟨fun h => ⟨(h (fun _ => false)).1,fun H => (h H).2⟩,fun h H => ⟨h.1,h.2 H⟩⟩ + +def InternalPresentation (M : ZFSet.{u}) (A R : Oracle) : Prop := + ∀ H ∈ reals M, PresentationMatrix (parameters A R H) 0 + +def InternalNonidentity (M : ZFSet.{u}) (A : Oracle) : Prop := + ∃ R ∈ reals M, InternalPresentation M A R ∧ Moved A R + +theorem internalPresentation_iff (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (A R : Oracle) (hA : A ∈ reals M) (hR : R ∈ reals M) : + InternalPresentation M A R ↔ Property A R := + (sourceT_piOneOne_matrix M hM hT presentationMatrix_arith A R hA hR 0).trans + (presentationMatrix_iff A R) + +theorem persistent_presentation_mem {M : ZFSet.{u}} (C : Context M) + {A R : Oracle} (hA : A ∈ reals M) (hR : Property A R) : R ∈ reals M := by + obtain ⟨I,hIA,hz,ρ,hgraph,hp⟩ := hR + have hg := PersistenceRealClosure.graph_mem (realClosure C) hIA hA ρ hp hz + have he : R = PersistentCountability.graphOracle hIA ρ := by + funext n + have hi : R n = true ↔ PersistentCountability.graphOracle hIA ρ n = true := + (hgraph n).trans (by simp [PersistentCountability.graphOracle]) + cases hr : R n <;> cases hg : PersistentCountability.graphOracle hIA ρ n <;> simp_all + exact he.symm ▸ hg + +theorem internalNonidentity_iff (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (A : Oracle) (hA : A ∈ reals M) : + InternalNonidentity M A ↔ ∃ R : Oracle, Property A R ∧ Moved A R := by + constructor + · rintro ⟨R,hR,hp,hm⟩ + exact ⟨R,(internalPresentation_iff M hM hT A R hA hR).mp hp,hm⟩ + · rintro ⟨R,hp,hm⟩ + have hR := persistent_presentation_mem (sourceContext M hM hT) hA hp + exact ⟨R,hR,(internalPresentation_iff M hM hT A R hA hR).mpr hp,hm⟩ + +theorem presentation_comparison (M N : ZFSet.{u}) + (hM : Transitive M) (hN : Transitive N) (hTM : SourceT M) (hTN : SourceT N) + (A R : Oracle) (hAM : A ∈ reals M) (hAN : A ∈ reals N) + (hRM : R ∈ reals M) (hRN : R ∈ reals N) : + (InternalPresentation M A R ↔ InternalPresentation N A R) ∧ + (InternalNonidentity M A ↔ InternalNonidentity N A) := + ⟨(internalPresentation_iff M hM hTM A R hAM hRM).trans + (internalPresentation_iff N hN hTN A R hAN hRN).symm, + (internalNonidentity_iff M hM hTM A hAM).trans + (internalNonidentity_iff N hN hTN A hAN).symm⟩ + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTTreeAbsoluteness.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTTreeAbsoluteness.lean new file mode 100644 index 0000000000000000000000000000000000000000..a91e1ed85bfbf135aef54788207f3d45d8f74030 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTTreeAbsoluteness.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticTreeDescent +import OAI.Computability.DegreeRigidity.SetModels.InternalNaturalRelationReal + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic ArithmeticPersistence BoundedSetTheory TransitiveNameModel +open SetModelFunctions SetModelReals SetModelSyntax RelationCollapse +universe u +noncomputable section +attribute [local instance] Classical.propDecidable + +theorem sourceContext (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : Context M := + ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + +theorem modelReals_eq (M : ZFSet.{u}) : modelReals M = reals M := rfl + +private theorem zero_real_mem {M : ZFSet.{u}} (C : Context M) : (fun _ => false) ∈ reals M := by + have he : realSet.{u} (fun _ => false) = ∅ := by + apply ZFSet.ext + intro x + simp [realSet] + change realSet _ ∈ M + rw [he] + exact C.nat_mem 0 + +private theorem relationSet_on (B : Oracle) : On ZFSet.omega.{u} (relationSet B) := + fun _ hz => (ZFSet.mem_sep.mp hz).1 + +theorem Test.illFounded_edges (t : Test) (O : Oracles) (v : ℕ) + (r : ZFSet.{u}) (hr : ∀ n m, ZFSet.pair (natSet n) (natSet m) ∈ r ↔ t.edgePredicate O v n m) + (hw : ∃ f : ℕ → ℕ, ∀ n, t.eval O f (Nat.pair v n)) : + ¬ WellFounded (Rel ZFSet.omega r) := by + rintro hf + obtain ⟨f,hf'⟩ := hw + let nodes : ℕ → ZFSet.{u} := fun n => natSet (Encodable.encode (initialSegment f n)) + have hc : ∀ n, Rel ZFSet.omega r (nodes (n+1)) (nodes n) := by + intro n + refine ⟨(mem_omega _).mpr ⟨_,rfl⟩,(hr _ _).mpr ?_⟩ + refine ⟨⟨by simp,?_⟩,⟨by simp,?_⟩,f n,?_⟩ + · simpa only [decodeNode_encode] using + (show t.accepts O v (initialSegment f (n+1)) from (t.branch_iff O v f).mpr hf' (n+1)) + · simpa only [decodeNode_encode] using + (show t.accepts O v (initialSegment f n) from (t.branch_iff O v f).mpr hf' n) + · simp only [decodeNode_encode,prefix_succ] + exact (wellFounded_iff_isEmpty_descending_chain.mp hf).false ⟨nodes,hc⟩ + +theorem sourceT_merge_witness (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (t : Test) (A R : Oracle) (hA : A ∈ reals M) (hR : R ∈ reals M) (v : ℕ) + (hw : ∃ H : Oracle, ∃ f : ℕ → ℕ, ∀ n, t.eval (parameters A R H) f (Nat.pair v n)) : + ∃ H ∈ reals M, ∃ f : ℕ → ℕ, ∀ n, t.eval (parameters A R H) f (Nat.pair v n) := by + let C := sourceContext M hM hT + let O := parameters A R (fun _ => false) + have hO : ∀ i, O i ∈ reals M := by + intro i + rcases i with _|_|i + · exact hA + · exact hR + · exact zero_real_mem C + let B : Oracle := fun n => decide (t.mergeReal.edgePredicate O v (left n) (right n)) + have hB : B ∈ reals M := arithmetic_comprehension C (t.mergeReal.edge_arith v) O hO B + (fun n => by simp [B]) + let r := relationSet.{u} B + have hr : ∀ n m, ZFSet.pair (natSet n) (natSet m) ∈ r ↔ t.mergeReal.edgePredicate O v n m := by + intro n m + simp [r,relationSet_pair,B,left,right] + have hwf : ¬ WellFounded (Rel ZFSet.omega r) := + t.mergeReal.illFounded_edges O v r hr ((t.exists_mergeReal A R v).mp hw) + obtain ⟨c,G,hG,hGc,hc⟩ := sourceT_natural_descent_real M hM hT + (relationSet_mem C hB) (relationSet_on B) hwf + have hGcM : G ∈ reals M := by simpa only [modelReals_eq] using hG + have he : ∀ n, t.mergeReal.edgePredicate O v (c (n+1)) (c n) := fun n => (hr _ _).mp (hc n) + refine ⟨Test.realPart (unionRead c),union_real_mem C G hGcM c hGc,Test.witnessPart (unionRead c),?_⟩ + intro n + exact (t.mergeReal_eval A R (unionRead c) (Nat.pair v n)).mp (t.mergeReal.eval_of_descent O v c he n) + +theorem sourceT_piOneOne_matrix (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {Q : Predicate} (hQ : Arith Q) (A R : Oracle) (hA : A ∈ reals M) (hR : R ∈ reals M) (v : ℕ) : + (∀ H ∈ reals M, Q (parameters A R H) v) ↔ ∀ H : Oracle, Q (parameters A R H) v := by + constructor + · intro h H + by_contra hnot + obtain ⟨t,ht⟩ := (arithmetic_tests hQ).2 + obtain ⟨f,hf⟩ := (ht (parameters A R H) v).mp hnot + obtain ⟨K,hKM,g,hg⟩ := sourceT_merge_witness M hM hT t A R hA hR v ⟨H,f,hf⟩ + exact ((ht (parameters A R K) v).mpr ⟨g,hg⟩) (h K hKM) + · exact fun h H _ => h H + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTWellFounded.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTWellFounded.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c83cf5a9ae296382defe7cfec2c50a3d88c2dde --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTWellFounded.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.SelectorOrdinalEnumeration + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse +universe u +namespace InternalWellOrder + +theorem sourceT_internal_ordinal_ranking (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {d r : ZFSet.{u}} (hd : d ∈ M) (hr : r ∈ M) (hw : InternallyWellFounded M d r) : + ∃ δ ∈ M, δ.IsOrdinal ∧ ∃ F ∈ M, TransitiveNameModel.FunctionGraph δ d F ∧ + (∀ x ∈ d, ∃ i ∈ δ, ZFSet.pair i x ∈ F) ∧ + (∀ i ∈ δ, ∀ j ∈ δ, ∀ x y, ZFSet.pair i x ∈ F → ZFSet.pair j y ∈ F → + ZFSet.pair y x ∈ r → j ∈ i) := by + obtain ⟨q,hq,s,hsM,hs,hqdef,hmin⟩ := internal_minimal_selector M hM hT hd hr hw + obtain ⟨δ,hδM,hδ,F,hFM,hF,honto,hinj,hchoice⟩ := internal_enumeration_from_selector M hM + hT.pairing hT.union hT.powerSet hT.separation.finitePrefix hT.replacement.finitePrefix + hT.infinity hd hq hsM hs hqdef + refine ⟨δ,hδM,hδ,F,hFM,hF,honto,?_⟩ + intro i hi j hj x y hix hjy hyx + have hx := hF.value_mem hix + have hy := hF.value_mem hjy + obtain ⟨a,_,hrem,hax⟩ := hchoice i hi x hx hix + by_contra hji + have hya : y ∈ a := (hrem.2 y hy).mpr (by + rintro ⟨k,hki,hky⟩ + have hkj := hinj k (hδ.subset_of_mem hi hki) j hj y hky hjy + exact hji (hkj ▸ hki)) + exact (hmin a x hax).2 y hya hyx + +theorem sourceT_wellFounded (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {d r : ZFSet.{u}} (hd : d ∈ M) (hr : r ∈ M) (hon : On d r) + (hw : InternallyWellFounded M d r) : WellFounded (Rel d r) := by + classical + obtain ⟨δ,_,_,F,_,_,honto,hrank⟩ := sourceT_internal_ordinal_ranking M hM hT hd hr hw + let index (x : ZFSet.{u}) : ZFSet.{u} := if hx : x ∈ d then (honto x hx).choose else ∅ + have hi (x : ZFSet.{u}) (hx : x ∈ d) : index x ∈ δ ∧ ZFSet.pair (index x) x ∈ F := by + simp only [index,dite_eq_left hx] + exact (honto x hx).choose_spec + apply (show WellFounded (fun y x => index y ∈ index x) from InvImage.wf index ZFSet.mem_wf).mono + intro y x hyx + have hx : x ∈ d := by + obtain ⟨y',_,x',hx,he⟩ := ZFSet.mem_prod.mp (hon hyx.2) + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact hx + exact hrank _ (hi x hx).1 _ (hi y hyx.1).1 x y (hi x hx).2 (hi y hyx.1).2 hyx.2 + +theorem internallyWellFounded_of_wellFounded (M d r : ZFSet.{u}) + (hw : WellFounded (Rel d r)) : InternallyWellFounded M d r := by + classical + intro a _ had hne + have find (x : ZFSet.{u}) : x ∈ a → ∃ y, MinimalIn r a y := by + induction x using hw.induction with + | h x ih => + intro hx + by_cases he : ∃ y ∈ a, ZFSet.pair y x ∈ r + · obtain ⟨y,hy,hyx⟩ := he + exact ih y ⟨had hy,hyx⟩ hy + · exact ⟨x,hx,fun y hy hyx => he ⟨y,hy,hyx⟩⟩ + obtain ⟨x,hx⟩ := hne + exact find x hx + +theorem sourceT_wellFounded_absolute (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {d r : ZFSet.{u}} (hd : d ∈ M) (hr : r ∈ M) (hon : On d r) : + InternallyWellFounded M d r ↔ WellFounded (Rel d r) := + ⟨sourceT_wellFounded M hM hT hd hr hon,internallyWellFounded_of_wellFounded M d r⟩ + +end InternalWellOrder +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Representation/SourceTheory.lean b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTheory.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c4e8b32fe2bd77fbfd15e42d9255451cfdb9328 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Representation/SourceTheory.lean @@ -0,0 +1,56 @@ +import OAI.Computability.DegreeRigidity.Syntax.LevySigmaSchemas +import OAI.Computability.DegreeRigidity.SetModels.ExtensionChoice + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +structure SourceT (M : ZFSet.{u}) : Prop where + extensionality : BasicAxioms.Extensionality M + empty : BasicAxioms.EmptySet M + pairing : Pairing M + union : BoundedSetTheory.Union M + powerSet : PowerSet M + infinity : Infinity M + foundation : BasicAxioms.Foundation M + choice : Choice M + separation : LevySigmaSeparation M + replacement : LevySigmaReplacement M + +theorem sourceT_of_finite_schemas (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) : SourceT M := by + obtain ⟨hLS,hLR⟩ := levy_sigma_schemas M hM hP hU hPow hS hR hI hAC + have hω := omega_mem M hM hS.bounded hI + have h0 := hM _ hω _ ZFSet.omega_zero + exact ⟨BasicAxioms.extensionality M hM,⟨∅,h0,fun x _ => ZFSet.notMem_empty x⟩, + hP,hU,hPow,hI,BasicAxioms.foundation M hM,hAC,hLS,hLR⟩ + +theorem extension_sourceT (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : CountableForcing.GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) + (htop : ⊤ ∈ G.carrier) : + SourceT (genericExtensionSet M c G.carrier) := by + have hS := hT.separation.finitePrefix + have hR := hT.replacement.finitePrefix + have hP := hT.pairing + have hU := hT.union + have hPow := hT.powerSet + have hI := hT.infinity + have hAC := hT.choice + apply sourceT_of_finite_schemas _ (genericExtensionSet_transitive M c hM G.carrier) + (extension_pairing M c hM hP hc G.carrier htop) + (extension_union M c o hM hP hU hPow hS.bounded hc hoM ho G) + (AtomicForcing.extension_powerSet M hM hP hU hPow hS.bounded hR hI hc hoM ho G hG htop) + (BoundedForcing.extension_sigmaSeparation M hM hP hU hPow hS hR hI hc hoM ho G hG) + (BoundedForcing.extension_sigmaReplacement M hM hP hU hPow hS hR hI hAC hc hoM ho G hG) + (extension_infinity M c hM hP hU hPow hS.bounded hR hI hc G.carrier htop) + (BoundedForcing.extension_choice M hM hP hU hPow hS hR hI hAC hc hoM ho G hG htop) + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/BindCanonicalArithmetic.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/BindCanonicalArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b0a80a7691776af474a319b172cef73eb63f29e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/BindCanonicalArithmetic.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.CanonicalAdditionSyntax + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SetModelArithmetic +universe u + +def squareFormula (w d : ℕ) : Formula := + .conj (.allMem d (.existsMem (w+1) (.existsMem (w+2) (.orderedPair 2 1 0)))) + (.allMem w (.allMem (w+1) (.existsMem (d+2) (.orderedPair 0 2 1)))) + +theorem squareFormula_spec (w d : ℕ) (e : ℕ → ZFSet.{u}) : + (squareFormula w d).Eval e ↔ e d = ZFSet.prod (e w) (e w) := by + simp only [squareFormula,Formula.Eval,Formula.eval_allMem,Formula.eval_orderedPair,cons_zero,cons_succ] + constructor + · rintro ⟨h1,h2⟩ + apply ZFSet.ext; intro x + constructor + · intro hx + exact ZFSet.mem_prod.mpr (h1 x hx) + · intro hx + obtain ⟨a,ha,b,hb,rfl⟩ := ZFSet.mem_prod.mp hx + obtain ⟨z,hz,rfl⟩ := h2 a ha b hb + exact hz + · intro h + rw [h] + exact ⟨fun _ hx => ZFSet.mem_prod.mp hx, + fun a ha b hb => ⟨ZFSet.pair a b,ZFSet.pair_mem_prod.mpr ⟨ha,hb⟩,rfl⟩⟩ + +noncomputable def bindArithmetic (p : SentenceForm) : SentenceForm := + .ex (.conj (canonicalOmega 0) + (.ex (.conj (fromBounded (squareFormula 1 0)) + (.ex (.conj (fromBounded (additionSystemFormula 2 1 0)) p))))) + +theorem bindArithmetic_spec (M : ZFSet.{u}) (hM : Transitive M) + (hw : ZFSet.omega.{u} ∈ M) (hd : pairNumbers.{u} ∈ M) (ha : additionSet.{u} ∈ M) + (p : SentenceForm) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (bindArithmetic p).Sat (M : Set ZFSet) e ↔ + p.Sat (M : Set ZFSet) (cons additionSet (cons pairNumbers (cons ZFSet.omega e))) := by + have hc (x : ZFSet.{u}) (hx : x ∈ M) : ∀ i, cons x e i ∈ M := by + intro i; cases i; exact hx; exact he _ + have hwf (x : ZFSet.{u}) (hx : x ∈ M) := canonicalOmega_spec M hM hw 0 (cons x e) (hc x hx) + have hdf (d : ZFSet.{u}) (hdM : d ∈ M) : + (fromBounded (squareFormula 1 0)).Sat (M : Set ZFSet) (cons d (cons ZFSet.omega e)) ↔ d = pairNumbers := by + rw [bounded_sat,Formula.absolute _ M hM _ + (by intro i; rcases i with _|_|i; exact hdM; exact hw; exact he i),squareFormula_spec] + rfl + have haf (a : ZFSet.{u}) (haM : a ∈ M) : + (fromBounded (additionSystemFormula 2 1 0)).Sat (M : Set ZFSet) + (cons a (cons pairNumbers (cons ZFSet.omega e))) ↔ a = additionSet := by + rw [bounded_sat,Formula.absolute _ M hM _ + (by intro i; rcases i with _|_|_|i; exact haM; exact hd; exact hw; exact he i)] + exact additionSystemFormula_unique 2 1 0 _ rfl rfl + change (∃ w ∈ M, (canonicalOmega 0).Sat (M : Set ZFSet) (cons w e) ∧ + ∃ d ∈ M, (fromBounded (squareFormula 1 0)).Sat (M : Set ZFSet) (cons d (cons w e)) ∧ + ∃ a ∈ M, (fromBounded (additionSystemFormula 2 1 0)).Sat (M : Set ZFSet) (cons a (cons d (cons w e))) ∧ + p.Sat (M : Set ZFSet) (cons a (cons d (cons w e)))) ↔ _ + constructor + · rintro ⟨w,hwM,hwS,d,hdM,hdS,a,haM,haS,hp⟩ + obtain rfl := (hwf w hwM).mp hwS + obtain rfl := (hdf d hdM).mp hdS + obtain rfl := (haf a haM).mp haS + exact hp + · intro hp + exact ⟨_,hw,(hwf _ hw).mpr rfl,_,hd,(hdf _ hd).mpr rfl,_,ha,(haf _ ha).mpr rfl,hp⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ChoiceFromOrdinalCover.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ChoiceFromOrdinalCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6b76c91d8b080b6bb87de375664da926629c255 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ChoiceFromOrdinalCover.lean @@ -0,0 +1,104 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalOrdinalEnumeration + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace InternalWellOrder + +def LeastValue (δ V F H x y : ZFSet.{u}) : Prop := y ∈ x ∧ + ∃ i ∈ δ, ∃ v ∈ V, ZFSet.pair i v ∈ F ∧ ZFSet.pair v y ∈ H ∧ + ∀ j ∈ i, ∀ w ∈ V, ∀ z ∈ x, ¬ (ZFSet.pair j w ∈ F ∧ ZFSet.pair w z ∈ H) + +theorem leastValue_exists {δ V F H x : ZFSet.{u}} (hδ : δ.IsOrdinal) + (hex : ∃ i ∈ δ, ∃ v ∈ V, ∃ y ∈ x, ZFSet.pair i v ∈ F ∧ ZFSet.pair v y ∈ H) : + ∃ y ∈ x, LeastValue δ V F H x y := by + classical + have minimal (i : ZFSet.{u}) : i ∈ δ → + (∃ v ∈ V, ∃ y ∈ x, ZFSet.pair i v ∈ F ∧ ZFSet.pair v y ∈ H) → + ∃ y ∈ x, LeastValue δ V F H x y := by + induction i using ZFSet.inductionOn with + | h i ih => + intro hi hs + by_cases hp : ∃ j ∈ i, ∃ w ∈ V, ∃ z ∈ x, ZFSet.pair j w ∈ F ∧ ZFSet.pair w z ∈ H + · obtain ⟨j,hji,hw⟩ := hp + exact ih j hji (hδ.subset_of_mem hi hji) hw + · obtain ⟨v,hv,y,hy,hiv,hvy⟩ := hs + exact ⟨y,hy,hy,i,hi,v,hv,hiv,hvy,fun j hj w hw z hz hp' => hp ⟨j,hj,w,hw,z,hz,hp'⟩⟩ + obtain ⟨i,hi,hs⟩ := hex + exact minimal i hi hs + +theorem LeastValue.unique {δ V F H x y z : ZFSet.{u}} (hδ : δ.IsOrdinal) + (hF : TransitiveNameModel.FunctionGraph δ V F) (hH : FiniteTerm.Functional H) + (hy : LeastValue δ V F H x y) (hz : LeastValue δ V F H x z) : y = z := by + obtain ⟨hyx,i,hi,v,hv,hiv,hvy,hmin⟩ := hy + obtain ⟨hzx,j,hj,w,hw,hjw,hwz,hmin'⟩ := hz + rcases (hδ.mem hi).mem_trichotomous (hδ.mem hj) with hij|he|hji + · exact False.elim (hmin' i hij v hv y hyx ⟨hiv,hvy⟩) + · subst j + have hvw := hF.functional hi hiv hjw + subst w + exact hH v y z hvy hwz + · exact False.elim (hmin j hji w hw z hzx ⟨hjw,hwz⟩) + +open Formula +def leastValueFormula (δ V F H x y : ℕ) : Formula := .conj (.member y x) + (.existsMem δ (.existsMem (V+1) (.conj (.pairMem 1 0 (F+2)) + (.conj (.pairMem 0 (y+2) (H+2)) + (allMem 1 (allMem (V+3) (allMem (x+4) + (.neg (.conj (.pairMem 2 1 (F+5)) (.pairMem 1 0 (H+5))))))))))) + +theorem eval_leastValueFormula (δ V F H x y : ℕ) (e : ℕ → ZFSet.{u}) : + (leastValueFormula δ V F H x y).Eval e ↔ + LeastValue (e δ) (e V) (e F) (e H) (e x) (e y) := by + simp only [leastValueFormula,LeastValue,Formula.Eval,eval_pairMem,eval_allMem,cons_zero,cons_succ] + +def selectionFormula : Formula := .existsMem 1 (.existsMem 3 + (.conj (.orderedPair 2 1 0) (leastValueFormula 5 6 7 8 1 0))) + +theorem internal_choice_of_ordinal_cover (E : ZFSet.{u}) (hE : Transitive E) + (hP : Pairing E) (hU : BoundedSetTheory.Union E) (hPow : PowerSet E) (hS : Separation E) + {a δ V F H : ZFSet.{u}} (ha : a ∈ E) (hδE : δ ∈ E) (hV : V ∈ E) (hFE : F ∈ E) (hHE : H ∈ E) + (hδ : δ.IsOrdinal) (hF : TransitiveNameModel.FunctionGraph δ V F) (hH : FiniteTerm.Functional H) + (hcover : ∀ x ∈ a, ∃ i ∈ δ, ∃ v ∈ V, ∃ y ∈ x, ZFSet.pair i v ∈ F ∧ ZFSet.pair v y ∈ H) : + ∃ f ∈ E, ChoiceGraph a f := by + let u := ZFSet.sUnion a + have hu : u ∈ E := union_mem E hE hU ha + let e := cons a (cons u (cons δ (cons V (cons F (fun _ => H))))) + have he : ∀ i, e i ∈ E := by + intro i; rcases i with _|i; exact ha + rcases i with _|i; exact hu + rcases i with _|i; exact hδE + rcases i with _|i; exact hV + rcases i with _|i; exact hFE + exact hHE + let f := ZFSet.sep (fun z => selectionFormula.Eval (cons z e)) (ZFSet.prod a u) + have hf : f ∈ E := sep_mem E hE hS selectionFormula e he (product_mem E hE hP hU hPow hS ha hu) + have hmem (z : ZFSet.{u}) : z ∈ f ↔ + ∃ x ∈ a, ∃ y ∈ x, z = ZFSet.pair x y ∧ LeastValue δ V F H x y := by + simp only [f,ZFSet.mem_sep,selectionFormula,Formula.Eval,eval_orderedPair, + eval_leastValueFormula,cons_zero,cons_succ,e] + constructor + · rintro ⟨_,x,hx,y,_,hz,hmin⟩ + exact ⟨x,hx,y,hmin.1,hz,hmin⟩ + · rintro ⟨x,hx,y,hy,rfl,hmin⟩ + have hyu : y ∈ u := ZFSet.mem_sUnion.mpr ⟨x,hx,hy⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨x,hx,y,hyu,rfl⟩,x,hx,y,hyu,rfl,hmin⟩ + refine ⟨f,hf,?_,?_⟩ + · intro z hz + obtain ⟨x,hx,y,hy,hz,_⟩ := (hmem z).mp hz + exact ⟨x,hx,y,hy,hz⟩ + · intro x hx + obtain ⟨y,hy,hmin⟩ := leastValue_exists hδ (hcover x hx) + refine ⟨y,hy,(hmem _).mpr ⟨x,hx,y,hy,rfl,hmin⟩,?_⟩ + intro z _ hz + obtain ⟨x',_,z',_,heq,hmin'⟩ := (hmem _).mp hz + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + exact hmin'.unique hδ hF hH hmin + +end InternalWellOrder +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ChoiceTrace.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ChoiceTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..63e39cd52b1f80b2ba411082d7a4c6d4da90195d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ChoiceTrace.lean @@ -0,0 +1,124 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalHartogs +import OAI.Computability.DegreeRigidity.SetModels.InternalChoice +import OAI.Computability.DegreeRigidity.Syntax.TermFunctionality + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace InternalWellOrder + +def Remaining (a f i r : ZFSet.{u}) : Prop := r ⊆ a ∧ + ∀ x ∈ a, x ∈ r ↔ ¬ ∃ j ∈ i, ZFSet.pair j x ∈ f + +structure Trace (α a q s f : ZFSet.{u}) : Prop where + shape : ∀ z ∈ f, ∃ i ∈ α, ∃ x ∈ a, z = ZFSet.pair i x + initial : ∀ i ∈ α, ∀ x ∈ a, ZFSet.pair i x ∈ f → + ∀ j ∈ i, ∃ y ∈ a, ZFSet.pair j y ∈ f + choice : ∀ i ∈ α, ∀ x ∈ a, ZFSet.pair i x ∈ f → + ∃ r ∈ q, Remaining a f i r ∧ ZFSet.pair r x ∈ s + +theorem Trace.pair_mem {α a q s f i x : ZFSet.{u}} (hf : Trace α a q s f) + (hix : ZFSet.pair i x ∈ f) : i ∈ α ∧ x ∈ a := by + obtain ⟨j,hj,y,hy,he⟩ := hf.shape _ hix + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hj,hy⟩ + +theorem choice_value_mem {q s r x : ZFSet.{u}} (hs : ChoiceGraph q s) + (hrx : ZFSet.pair r x ∈ s) : x ∈ r := by + obtain ⟨r',_,x',hx,he⟩ := hs.1 _ hrx + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact hx + +theorem Remaining.eq {a f g i r t : ZFSet.{u}} (hr : Remaining a f i r) + (ht : Remaining a g i t) + (hfg : ∀ j ∈ i, ∀ x ∈ a, ZFSet.pair j x ∈ f ↔ ZFSet.pair j x ∈ g) : r = t := by + apply ZFSet.ext; intro x + constructor + · intro hx + have hxa := hr.1 hx + apply (ht.2 x hxa).mpr + rintro ⟨j,hji,hjx⟩ + exact (hr.2 x hxa).mp hx ⟨j,hji,(hfg j hji x hxa).mpr hjx⟩ + · intro hx + have hxa := ht.1 hx + apply (hr.2 x hxa).mpr + rintro ⟨j,hji,hjx⟩ + exact (ht.2 x hxa).mp hx ⟨j,hji,(hfg j hji x hxa).mp hjx⟩ + +theorem Trace.compatible {α a q s f g : ZFSet.{u}} (_hα : Transitive α) + (hs : ChoiceGraph q s) (hf : Trace α a q s f) (hg : Trace α a q s g) + (i x y : ZFSet.{u}) (hix : ZFSet.pair i x ∈ f) (hiy : ZFSet.pair i y ∈ g) : x = y := by + induction i using ZFSet.inductionOn generalizing x y with + | h i ih => + have hi := (hf.pair_mem hix).1 + have hx := (hf.pair_mem hix).2 + have hy := (hg.pair_mem hiy).2 + obtain ⟨r,_,hr,hrx⟩ := hf.choice i hi x hx hix + obtain ⟨t,_,ht,hty⟩ := hg.choice i hi y hy hiy + have heq : r = t := hr.eq ht (by + intro j hji z _ + constructor + · intro hjz + obtain ⟨w,_,hjw⟩ := hg.initial i hi y hy hiy j hji + have hzw := ih j hji z w hjz hjw + exact hzw.symm ▸ hjw + · intro hjz + obtain ⟨w,_,hjw⟩ := hf.initial i hi x hx hix j hji + have hwz := ih j hji w z hjw hjz + exact hwz ▸ hjw) + rw [heq] at hrx + exact hs.functional hrx hty + +theorem Trace.functional {α a q s f : ZFSet.{u}} (hα : Transitive α) + (hs : ChoiceGraph q s) (hf : Trace α a q s f) : FiniteTerm.Functional f := + fun i x y hx hy => hf.compatible hα hs hf i x y hx hy + +theorem Trace.injective {α a q s f : ZFSet.{u}} (hα : α.IsOrdinal) + (hs : ChoiceGraph q s) (hf : Trace α a q s f) + (i j x : ZFSet.{u}) (hix : ZFSet.pair i x ∈ f) (hjx : ZFSet.pair j x ∈ f) : i = j := by + have hi := (hf.pair_mem hix).1 + have hj := (hf.pair_mem hjx).1 + have hx := (hf.pair_mem hix).2 + rcases (hα.mem hi).mem_trichotomous (hα.mem hj) with hij|he|hji + · obtain ⟨r,_,hr,hrx⟩ := hf.choice j hj x hx hjx + exact False.elim ((hr.2 x hx).mp (choice_value_mem hs hrx) ⟨i,hij,hix⟩) + · exact he + · obtain ⟨r,_,hr,hrx⟩ := hf.choice i hi x hx hix + exact False.elim ((hr.2 x hx).mp (choice_value_mem hs hrx) ⟨j,hji,hjx⟩) + +theorem Trace.sUnion {α a q s C : ZFSet.{u}} (hα : Transitive α) + (hs : ChoiceGraph q s) (hC : ∀ f ∈ C, Trace α a q s f) : + Trace α a q s (ZFSet.sUnion C) := by + have from_pair (i x : ZFSet.{u}) (hix : ZFSet.pair i x ∈ ZFSet.sUnion C) : + ∃ f ∈ C, ZFSet.pair i x ∈ f := ZFSet.mem_sUnion.mp hix + refine ⟨?_,?_,?_⟩ + · intro z hz + obtain ⟨f,hf,hzf⟩ := ZFSet.mem_sUnion.mp hz + exact (hC f hf).shape z hzf + · intro i hi x hx hix j hji + obtain ⟨f,hf,hif⟩ := from_pair i x hix + obtain ⟨y,hy,hjy⟩ := (hC f hf).initial i hi x hx hif j hji + exact ⟨y,hy,ZFSet.mem_sUnion.mpr ⟨f,hf,hjy⟩⟩ + · intro i hi x hx hix + obtain ⟨f,hf,hif⟩ := from_pair i x hix + obtain ⟨r,hr,hrdef,hrx⟩ := (hC f hf).choice i hi x hx hif + refine ⟨r,hr,⟨hrdef.1,?_⟩,hrx⟩ + intro y hy + rw [hrdef.2 y hy] + apply not_congr + constructor + · rintro ⟨j,hji,hjy⟩ + exact ⟨j,hji,ZFSet.mem_sUnion.mpr ⟨f,hf,hjy⟩⟩ + · rintro ⟨j,hji,hjy⟩ + obtain ⟨g,hg,hjg⟩ := from_pair j y hjy + obtain ⟨z,_,hjz⟩ := (hC f hf).initial i hi x hx hif j hji + have hzy := (hC f hf).compatible hα hs (hC g hg) j z y hjz hjg + exact ⟨j,hji,hzy ▸ hjz⟩ + +end InternalWellOrder +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ChoiceTraceExtension.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ChoiceTraceExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..cfc657dc54a7b8fece52a0c8bf7b3b14e933aaaa --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ChoiceTraceExtension.lean @@ -0,0 +1,90 @@ +import OAI.Computability.DegreeRigidity.SetModels.ChoiceTraceFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse +universe u +namespace InternalWellOrder + +theorem adjoin_prior (f i x k y : ZFSet.{u}) (hk : k ∈ i) : + ZFSet.pair k y ∈ f ∪ ({ZFSet.pair i x} : ZFSet.{u}) ↔ ZFSet.pair k y ∈ f := by + rw [ZFSet.mem_union,ZFSet.mem_singleton] + constructor + · rintro (h|h) + · exact h + · obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp h + exact False.elim ((lt_irrefl _) (ZFSet.rank_lt_of_mem hk)) + · exact Or.inl + +theorem Trace.adjoin {α a q s f i x r : ZFSet.{u}} (hf : Trace α a q s f) + (hi : i ∈ α) (hit : Transitive i) (hx : x ∈ a) (hr : r ∈ q) + (hrem : Remaining a f i r) (hrx : ZFSet.pair r x ∈ s) + (hprev : ∀ j ∈ i, ∃ y ∈ a, ZFSet.pair j y ∈ f) + (hdom : ∀ j y, ZFSet.pair j y ∈ f → j ∈ i) : + Trace α a q s (f ∪ ({ZFSet.pair i x} : ZFSet.{u})) := by + refine ⟨?_,?_,?_⟩ + · intro z hz + rcases ZFSet.mem_union.mp hz with hz|hz + · exact hf.shape z hz + · obtain rfl := ZFSet.mem_singleton.mp hz + exact ⟨i,hi,x,hx,rfl⟩ + · intro j hj y hy hjy k hkj + rcases ZFSet.mem_union.mp hjy with hjy|hjy + · obtain ⟨z,hz,hkz⟩ := hf.initial j hj y hy hjy k hkj + exact ⟨z,hz,ZFSet.mem_union.mpr (Or.inl hkz)⟩ + · have he := ZFSet.mem_singleton.mp hjy + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + obtain ⟨z,hz,hkz⟩ := hprev k hkj + exact ⟨z,hz,ZFSet.mem_union.mpr (Or.inl hkz)⟩ + · intro j hj y hy hjy + rcases ZFSet.mem_union.mp hjy with hjy|hjy + · obtain ⟨b,hb,hbrem,hby⟩ := hf.choice j hj y hy hjy + refine ⟨b,hb,⟨hbrem.1,?_⟩,hby⟩ + intro z hz + rw [hbrem.2 z hz] + apply not_congr + apply exists_congr; intro k + apply and_congr_right; intro hkj + exact (adjoin_prior f i x k z (hit j (hdom j y hjy) k hkj)).symm + · have he := ZFSet.mem_singleton.mp hjy + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + refine ⟨r,hr,⟨hrem.1,?_⟩,hrx⟩ + intro z hz + rw [hrem.2 z hz] + apply not_congr + apply exists_congr; intro k + apply and_congr_right; intro hki + exact (adjoin_prior f j y k z hki).symm + +theorem Trace.domain_before {α a q s f i : ZFSet.{u}} (hα : α.IsOrdinal) + (hf : Trace α a q s f) (hi : i ∈ α) (hmissing : ¬ ∃ x ∈ a, ZFSet.pair i x ∈ f) + (j y : ZFSet.{u}) (hjy : ZFSet.pair j y ∈ f) : j ∈ i := by + have hj := (hf.pair_mem hjy).1 + have hy := (hf.pair_mem hjy).2 + rcases (hα.mem hj).mem_trichotomous (hα.mem hi) with hji|he|hij + · exact hji + · subst j; exact False.elim (hmissing ⟨y,hy,hjy⟩) + · exact False.elim (hmissing (hf.initial j hj y hy hjy i hij)) + +theorem FunctionGraph.exists_presentation {d r f : ZFSet.{u}} (hf : TransitiveNameModel.FunctionGraph d r f) : + ∃ j : ZFSet.{u} → ZFSet.{u}, Presents d f j ∧ ∀ x ∈ d, j x ∈ r := by + classical + let j := fun x => if hx : x ∈ d then (hf.2 x hx).choose else ∅ + have hj (x : ZFSet.{u}) (hx : x ∈ d) : j x ∈ r ∧ ZFSet.pair x (j x) ∈ f := by + simp only [j,dite_eq_left hx] + exact ⟨(hf.2 x hx).choose_spec.1,(hf.2 x hx).choose_spec.2.1⟩ + refine ⟨j,?_,fun x hx => (hj x hx).1⟩ + intro z + constructor + · intro hz + obtain ⟨x,hx,y,_,rfl⟩ := hf.1 z hz + exact ⟨x,hx,congrArg (ZFSet.pair x) (hf.functional hx hz (hj x hx).2)⟩ + · rintro ⟨x,hx,rfl⟩ + exact (hj x hx).2 + +end InternalWellOrder +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ChoiceTraceFormula.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ChoiceTraceFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ff9ccffd7f127f5e7cf27d71bf1ab14ad5e5aae --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ChoiceTraceFormula.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.SetModels.ChoiceTrace + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace InternalWellOrder +open Formula + +def remainingFormula (a f i r : ℕ) : Formula := + .conj (.subset r a) (.allMem a (.iff (.member 0 (r+1)) + (.neg (.existsMem (i+1) (.pairMem 0 1 (f+2)))))) + +theorem eval_remainingFormula (a f i r : ℕ) (e : ℕ → ZFSet.{u}) : + (remainingFormula a f i r).Eval e ↔ Remaining (e a) (e f) (e i) (e r) := by + simp only [remainingFormula,Remaining,Formula.Eval,eval_subset,eval_allMem,eval_iff, + eval_pairMem,cons_zero,cons_succ] + +def traceFormula (α a q s f : ℕ) : Formula := .conj + (.allMem f (.existsMem (α+1) (.existsMem (a+2) (.orderedPair 2 1 0)))) + (.conj + (.allMem α (.allMem (a+1) (.imp (.pairMem 1 0 (f+2)) + (.allMem 1 (.existsMem (a+3) (.pairMem 1 0 (f+4))))))) + (.allMem α (.allMem (a+1) (.imp (.pairMem 1 0 (f+2)) + (.existsMem (q+2) (.conj (remainingFormula (a+3) (f+3) 2 0) (.pairMem 0 1 (s+3)))))))) + +theorem eval_traceFormula (α a q s f : ℕ) (e : ℕ → ZFSet.{u}) : + (traceFormula α a q s f).Eval e ↔ Trace (e α) (e a) (e q) (e s) (e f) := by + simp only [traceFormula,Formula.Eval,eval_allMem,eval_imp,eval_orderedPair, + eval_pairMem,eval_remainingFormula,cons_zero,cons_succ] + exact ⟨fun ⟨hshape,hinitial,hchoice⟩ => ⟨hshape,hinitial,hchoice⟩, + fun h => ⟨h.shape,h.initial,h.choice⟩⟩ + +theorem Trace.subset {α a q s f : ZFSet.{u}} (hf : Trace α a q s f) : f ⊆ ZFSet.prod α a := + fun z hz => ZFSet.mem_prod.mpr (hf.shape z hz) + +theorem internal_maximal_trace (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + {α a q s : ZFSet.{u}} (hαM : α ∈ M) (ha : a ∈ M) (hq : q ∈ M) (hsM : s ∈ M) + (hα : Transitive α) (hs : ChoiceGraph q s) : + ∃ F ∈ M, Trace α a q s F ∧ ∀ f ∈ M, Trace α a q s f → f ⊆ F := by + have hp := product_mem M hM hP hU hPow hS hαM ha + obtain ⟨P,hP0,hPdef⟩ := internal_power M hM hPow hp + let e := cons α (cons a (cons q (fun _ => s))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hαM + rcases i with _|i; exact ha + rcases i with _|i; exact hq + exact hsM + let C := ZFSet.sep (fun f => (traceFormula 1 2 3 4 0).Eval (cons f e)) P + have hC : C ∈ M := sep_mem M hM hS (traceFormula 1 2 3 4 0) e he hP0 + have hCdef (f : ZFSet.{u}) : f ∈ C ↔ f ∈ M ∧ Trace α a q s f := by + rw [ZFSet.mem_sep,hPdef,eval_traceFormula] + constructor + · rintro ⟨⟨hf,_⟩,ht⟩; exact ⟨hf,ht⟩ + · rintro ⟨hf,ht⟩; exact ⟨⟨hf,ht.subset⟩,ht⟩ + refine ⟨ZFSet.sUnion C,union_mem M hM hU hC,Trace.sUnion hα hs (fun f hf => ((hCdef f).mp hf).2),?_⟩ + intro f hf htrace z hz + exact ZFSet.mem_sUnion.mpr ⟨f,(hCdef f).mpr ⟨hf,htrace⟩,hz⟩ + +noncomputable def residual (a f i : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun x => ¬ ∃ j ∈ i, ZFSet.pair j x ∈ f) a + +theorem residual_remaining (a f i : ZFSet.{u}) : Remaining a f i (residual a f i) := by + refine ⟨fun _ hx => (ZFSet.mem_sep.mp hx).1,?_⟩ + intro x hx + exact ZFSet.mem_sep.trans (and_iff_right hx) + +theorem residual_mem (M : ZFSet.{u}) (hM : Transitive M) (hS : Separation M) + {a f i : ZFSet.{u}} (ha : a ∈ M) (hf : f ∈ M) (hi : i ∈ M) : residual a f i ∈ M := by + simpa only [residual,Formula.Eval,eval_pairMem,cons_zero,cons_succ] using + sep_mem M hM hS (.neg (.existsMem 2 (.pairMem 0 1 2))) (cons f (fun _ => i)) + (by intro j; cases j <;> assumption) ha + +end InternalWellOrder +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ClosedPaddingCertificates.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ClosedPaddingCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a086b0af984d7039646f111ce9d6eb59ce24339 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ClosedPaddingCertificates.lean @@ -0,0 +1,48 @@ +import OAI.Computability.DegreeRigidity.SetModels.RecursiveOmegaBound +import OAI.Computability.DegreeRigidity.Constructibility.InternalOmegaFixedPoint +import OAI.Computability.DegreeRigidity.OrdinalCodes.VectorCodeLevels + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem padded_certificates_of_lower_closure (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hβ : Order.IsSuccLimit β) (hoff : realSeedOffset+β=β) (hv : vectorCode v < β) + (hvec : VectorCodeCertificates (level (groundReals M) β) v) + (hpow : ∀ c < β, (Ordinal.omega0 ^ c).toZFSet ∈ level (groundReals M) β ∧ + OmegaPowerCertificates (level (groundReals M) β) c.toZFSet) : + PaddedCodeCertificates (level (groundReals M) (heightDomainIndex (paddedCode v β))) v β := by + let R := groundReals M + let c := paddedCode v β + let δ := heightDomainIndex c + have hβpos : 0 < β := hβ.bot_lt + have hβc : β < c := padding_lt_paddedCode v β + have hcodeabs := offset_absorbed_above realSeedOffset β c hoff hβc.le + have hδ : δ=c+1 := heightDomainIndex_of_absorbed c hcodeabs + have hβδ : β ≤ δ := hβc.le.trans (hδ ▸ le_self_add) + have hcut : ordinalHeight (seed R)+c=c := by rw [ground_seed_offset M hM hT]; exact hcodeabs + have hmem (a : Ordinal.{u}) (ha : a ≤ c) : a.toZFSet ∈ level R δ := by + rw [hδ,ordinal_mem_level_iff,← add_assoc,hcut] + exact Order.lt_add_one_iff.mpr ha + have hb1 : β+1 ≤ c := Order.add_one_le_iff.mpr hβc + have hu : Ordinal.omega0 ^ (β+1) < c := by + change Ordinal.omega0 ^ (β+1) < pairCode β (vectorCode v) + rw [pairCode,ite_eq_left hv.le] + simpa only [add_zero] using (add_lt_add_iff_left (Ordinal.omega0 ^ (β+1))).mpr + (Ordinal.opow_pos (vectorCode v) Ordinal.omega0_pos) + have hvpow := level_mono R hβδ (hpow (vectorCode v) hv).1 + have hcβ := padded_omega_boundary_certificates M hM hT v β hβ hoff hv.le hpow + (omega_boundary_product_without_offset M hM hT β hβpos) + have hck := (hpow (vectorCode v) hv).2.mono (level_mono R hβδ) + have hsum := padded_final_sum_certificates M hM hT v β hβpos hoff hv.le + refine ⟨hmem β hβc.le,hmem (vectorCode v) (hv.trans hβc).le,?_,hvec.mono (level_mono R hβδ)⟩ + rw [PairCodeCertificates,ite_eq_left hv.le] + exact ⟨hmem (β+1) hb1,hmem _ hu.le,hvpow,hmem _ hu.le,hcβ,hck, + fun h => Bool.noConfusion h,hsum⟩ + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CofinalPaddedDecoder.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CofinalPaddedDecoder.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4c0942aa177693bccebc64d084c55373acd8d64 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CofinalPaddedDecoder.lean @@ -0,0 +1,59 @@ +import OAI.Computability.DegreeRigidity.SetModels.ClosedPaddingCertificates + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem cofinal_padded_code_certificates (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) {n : ℕ} (v : Fin n → Ordinal.{u}) + (hv : ∀ i, (v i).toZFSet ∈ M) (θ : Ordinal.{u}) (hθ : θ.toZFSet ∈ M) : + ∃ β : Ordinal.{u}, β.toZFSet ∈ M ∧ θ < β ∧ realSeedOffset < β ∧ + (heightDomainIndex (paddedCode v β)).toZFSet ∈ M ∧ + PaddedCodeCertificates (level (groundReals M) (heightDomainIndex (paddedCode v β))) v β := by + obtain ⟨τ,hτ,homega⟩ := internal_explicit_omega_threshold M hM hT + obtain ⟨η,hη,hvec⟩ := vectorCode_certificates_at_levels M hM hT v hv + have hk := vectorCode_internal M hM hT v hv + have hoffM : realSeedOffset.toZFSet ∈ M := by + rw [← ground_seed_offset M hM hT] + exact ordinalHeight_mem_model M _ hM hT.separation.finitePrefix.bounded + (seed_mem M _ hM hT (groundReals_mem M hM hT)) (seed_transitive _) + let γ := max θ (max τ (max η (max realSeedOffset (vectorCode v)))) + have hγ : γ.toZFSet ∈ M := internal_ordinal_max M hθ + (internal_ordinal_max M hτ (internal_ordinal_max M hη (internal_ordinal_max M hoffM hk))) + obtain ⟨β,hβM,hγβ,hβ,hfix⟩ := cofinal_internal_omega_fixed_points M hM hT γ hγ + have hθβ : θ < β := (le_max_left _ _).trans_lt hγβ + have htail : max τ (max η (max realSeedOffset (vectorCode v))) < β := + (le_max_right _ _).trans_lt hγβ + have hτβ : τ < β := (le_max_left _ _).trans_lt htail + have htail' : max η (max realSeedOffset (vectorCode v)) < β := (le_max_right _ _).trans_lt htail + have hηβ : η < β := (le_max_left _ _).trans_lt htail' + have hlast : max realSeedOffset (vectorCode v) < β := (le_max_right _ _).trans_lt htail' + have hoffβ : realSeedOffset < β := (le_max_left _ _).trans_lt hlast + have hkβ : vectorCode v < β := (le_max_right _ _).trans_lt hlast + have hoff : realSeedOffset+β=β := by + have h := Ordinal.add_omega0_opow (a := realSeedOffset) (b := β) (by rw [hfix]; exact hoffβ) + simpa only [hfix] using h + have hpow := lower_omega_closure_of_fixed_point M τ β homega hβ hτβ hfix + have hc := padded_certificates_of_lower_closure M hM hT v β hβ hoff hkβ + (hvec β hηβ.le).2 hpow + exact ⟨β,hβM,hθβ,hoffβ,padded_height_index_from_inputs M hM hT v β hv hβM,hc⟩ + +theorem cofinal_largest_entry_decoder (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) {n : ℕ} (v : Fin n → Ordinal.{u}) + (hv : ∀ i, (v i).toZFSet ∈ M) (θ : Ordinal.{u}) (hθ : θ.toZFSet ∈ M) : + ∃ β : Ordinal.{u}, β.toZFSet ∈ M ∧ θ < β ∧ realSeedOffset < β ∧ + (heightDomainIndex (paddedCode v β)).toZFSet ∈ M ∧ + ∀ (k : Fin n) (e : ℕ → ZFSet.{u}), + e 0 ∈ level (groundReals M) (heightDomainIndex (paddedCode v β)) → + ((largestPaddedEntrySentence n k).Sat + (level (groundReals M) (heightDomainIndex (paddedCode v β)) : Set ZFSet) e ↔ + e 0 = (v k).toZFSet) := by + obtain ⟨β,hβ,hθβ,hoff,hidx,hcert⟩ := cofinal_padded_code_certificates M hM hT v hv θ hθ + exact ⟨β,hβ,hθβ,hoff,hidx,fun k e he => + largestPaddedEntrySentence_of_certificates M hM hT n k v β hoff.le e he hcert⟩ + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseCertificate.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..8884fc998e2157afcf516981e922db42ce6da089 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseCertificate.lean @@ -0,0 +1,101 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalRelationCollapse + +namespace OAI + + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory +universe u + +theorem internal_graph (M d r : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) + (hd : d ∈ M) (hr : r ∈ M) (wf : WellFounded (Rel d r)) : + ∃ f ∈ M, Graph d r d (iterUnion 2 f) f := by + obtain ⟨q,hqM,hq⟩ := internal_power M hM hPow hd + let e := cons q (cons d (cons r (fun _ => d))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hqM + rcases i with _|i; exact hd + rcases i with _|i; exact hr + exact hd + have cert (x f : ZFSet.{u}) (hx : x ∈ d) (hf : f ∈ M) : + certificate.Realize M (cons f (cons x e)) ↔ + ∃ b ∈ M, Graph d r (RelationHull.hull d r q x) b f := + realize_certificate M d r q hM hS hd hr hqM hq hx hf + obtain ⟨B,hB,hBdef⟩ := hR certificate e he d hd (by + intro x hx + obtain ⟨f,hf,hfg⟩ := internal_hull_graph M d r q hM hP hU hS hR hd hr hqM hq wf x hx + refine ⟨f,hf,(cert x f hx hf).mpr ⟨_,iterUnion_mem M hM hU hf 2,hfg⟩,?_⟩ + intro g hg hcg + obtain ⟨b,_,hgg⟩ := (cert x g hx hg).mp hcg + exact hgg.unique wf hfg) + have hBg (f : ZFSet.{u}) : f ∈ B ↔ + ∃ x ∈ d, ∃ b ∈ M, Graph d r (RelationHull.hull d r q x) b f := by + constructor + · intro hf + have hfM := hM B hB f hf + obtain ⟨x,hx,hc⟩ := (hBdef f hfM).mp hf + exact ⟨x,hx,(cert x f hx hfM).mp hc⟩ + · rintro ⟨x,hx,b,hb,hg⟩ + obtain ⟨g,hgM,hgg⟩ := internal_hull_graph M d r q hM hP hU hS hR hd hr hqM hq wf x hx + have hfM : f ∈ M := hg.unique wf hgg ▸ hgM + exact (hBdef f hfM).mpr ⟨x,hx,(cert x f hx hfM).mpr ⟨b,hb,hg⟩⟩ + refine ⟨ZFSet.sUnion B,union_mem M hM hU hB, + graph_of_mem_iff d r d _ wf (fun _ h => h) (fun _ _ _ h _ => h) ?_⟩ + intro z + rw [ZFSet.mem_sUnion] + constructor + · rintro ⟨f,hf,hzf⟩ + obtain ⟨x,_,b,_,hfg⟩ := (hBg f).mp hf + obtain ⟨y,hy,hz⟩ := (hfg.mem_iff wf z).mp hzf + exact ⟨y,RelationHull.hull_subset d r q x hy,hz⟩ + · rintro ⟨x,hx,hz⟩ + obtain ⟨f,hf,hfg⟩ := internal_hull_graph M d r q hM hP hU hS hR hd hr hqM hq wf x hx + exact ⟨f,(hBg f).mpr ⟨x,hx,_,iterUnion_mem M hM hU hf 2,hfg⟩, + (hfg.mem_iff wf z).mpr ⟨x,RelationHull.self_mem d r q hx,hz⟩⟩ + +def On (d r : ZFSet.{u}) : Prop := r ⊆ ZFSet.prod d d + +theorem right_mem {d r x y : ZFSet.{u}} (hr : On d r) (hyx : ZFSet.pair y x ∈ r) : x ∈ d := by + obtain ⟨a,_,b,hb,heq⟩ := ZFSet.mem_prod.mp (hr hyx) + exact (ZFSet.pair_inj.mp heq).2 ▸ hb + +theorem Graph.wellFounded {d r b f : ZFSet.{u}} (hr : On d r) + (hg : Graph d r d b f) : WellFounded (Rel d r) := by + classical + let F : ZFSet.{u} → ZFSet.{u} := fun x => + if hx : x ∈ d then (hg.2.2.2.1 x hx).choose else ∅ + have hF (x : ZFSet.{u}) (hx : x ∈ d) : + F x ∈ b ∧ ZFSet.pair x (F x) ∈ f := by + simpa only [F,dite_eq_left hx] using (hg.2.2.2.1 x hx).choose_spec |>.imp_right And.left + have wf : WellFounded (fun y x => F y ∈ F x) := InvImage.wf F ZFSet.mem_wf + apply wf.mono + intro y x hyx + have hx := right_mem hr hyx.2 + exact (hg.2.2.2.2 x hx (F x) (hF x hx).1 (hF x hx).2).2 + y hyx.1 hyx.2 (F y) (hF y hyx.1).1 (hF y hyx.1).2 + +namespace Code + +def full (d r f : ℕ) : SigmaFormula := + .existsSet (.bounded (graph (d+1) (r+1) (d+1) 0 (f+1))) + +theorem realize_full (M : ZFSet.{u}) (hM : Transitive M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (d r f : ℕ) : + (full d r f).Realize M e ↔ ∃ b ∈ M, Graph (e d) (e r) (e d) b (e f) := by + change (∃ b ∈ M, _) ↔ _ + apply exists_congr + intro b + apply and_congr_right + intro hb + simp only [SigmaFormula.Realize] + rw [Formula.absolute _ M hM _ (by intro i; cases i with + | zero => exact hb + | succ i => exact he i)] + exact eval_graph (d+1) (r+1) (d+1) 0 (f+1) _ +end Code + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseCoding.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseCoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbcd20e2c2945b75721e4148eb7b6f1adfbfc53c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseCoding.lean @@ -0,0 +1,120 @@ +import OAI.Computability.DegreeRigidity.SetModels.CollapseCollection + +namespace OAI + + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory +universe u + +def Presents (a f : ZFSet.{u}) (j : ZFSet.{u} → ZFSet.{u}) : Prop := + ∀ z, z ∈ f ↔ ∃ x ∈ a, z = ZFSet.pair x (j x) + +theorem Presents.pair_iff {a f : ZFSet.{u}} {j : ZFSet.{u} → ZFSet.{u}} + (hf : Presents a f j) (x y : ZFSet.{u}) : + ZFSet.pair x y ∈ f ↔ x ∈ a ∧ y = j x := by + rw [hf] + constructor + · rintro ⟨z,hz,he⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hz,rfl⟩ + · rintro ⟨hx,rfl⟩ + exact ⟨x,hx,rfl⟩ + +noncomputable def codedRelation (d a f : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ u ∈ d, ∃ v ∈ d, z = ZFSet.pair u v ∧ + ∃ x ∈ a, ∃ y ∈ a, x ∈ y ∧ ZFSet.pair x u ∈ f ∧ ZFSet.pair y v ∈ f) (ZFSet.prod d d) + +def codedFormula : Formula := + .existsMem 1 (.existsMem 2 (.conj (.orderedPair 2 1 0) + (.existsMem 4 (.existsMem 5 (.conj (.member 1 0) + (.conj (.pairMem 1 3 7) (.pairMem 0 2 7))))))) + +theorem codedRelation_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + {d a f : ZFSet.{u}} (hd : d ∈ M) (ha : a ∈ M) (hf : f ∈ M) : + codedRelation d a f ∈ M := by + let e := cons d (cons a (cons f (fun _ => d))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hd + rcases i with _|i; exact ha + rcases i with _|i; exact hf + exact hd + simpa only [codedFormula,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + e,cons_zero,cons_succ,codedRelation] using + sep_mem M hM hS codedFormula e he (product_mem M hM hP hU hPow hS hd hd) + +theorem codedRelation_on (d a f : ZFSet.{u}) : On d (codedRelation d a f) := + fun _ hz => (ZFSet.mem_sep.mp hz).1 + +theorem codedRelation_pair {d a f : ZFSet.{u}} {j : ZFSet.{u} → ZFSet.{u}} + (hf : Presents a f j) (hj : ∀ x ∈ a, j x ∈ d) (u v : ZFSet.{u}) : + ZFSet.pair u v ∈ codedRelation d a f ↔ + ∃ x ∈ a, ∃ y ∈ a, x ∈ y ∧ u = j x ∧ v = j y := by + rw [codedRelation,ZFSet.mem_sep] + constructor + · rintro ⟨_,u',_,v',_,hp,x,hx,y,hy,hxy,hxu,hyv⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact ⟨x,hx,y,hy,hxy,((hf.pair_iff x u).mp hxu).2,((hf.pair_iff y v).mp hyv).2⟩ + · rintro ⟨x,hx,y,hy,hxy,rfl,rfl⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨_,hj x hx,_,hj y hy,rfl⟩, + _,hj x hx,_,hj y hy,rfl,x,hx,y,hy,hxy, + (hf.pair_iff x _).mpr ⟨hx,rfl⟩,(hf.pair_iff y _).mpr ⟨hy,rfl⟩⟩ + +theorem codedRelation_wellFounded {d a f : ZFSet.{u}} {j : ZFSet.{u} → ZFSet.{u}} + (hf : Presents a f j) (hj : ∀ x ∈ a, j x ∈ d) + (hi : ∀ x ∈ a, ∀ y ∈ a, j x = j y → x = y) : + WellFounded (Rel d (codedRelation d a f)) := by + classical + let F : ZFSet.{u} → ZFSet.{u} := fun u => + if h : ∃ x ∈ a, j x = u then h.choose else ∅ + have hF (x : ZFSet.{u}) (hx : x ∈ a) : F (j x) = x := by + have h : ∃ y ∈ a, j y = j x := ⟨x,hx,rfl⟩ + simp only [F,dite_eq_left h] + exact hi _ h.choose_spec.1 x hx h.choose_spec.2 + apply (show WellFounded (fun y x => F y ∈ F x) from InvImage.wf F ZFSet.mem_wf).mono + intro u v huv + obtain ⟨x,hx,y,hy,hxy,rfl,rfl⟩ := (codedRelation_pair hf hj u v).mp huv.2 + simpa only [hF x hx,hF y hy] using hxy + +theorem codedRelation_value {d a f : ZFSet.{u}} {j : ZFSet.{u} → ZFSet.{u}} + (ha : Transitive a) (hf : Presents a f j) (hj : ∀ x ∈ a, j x ∈ d) + (hi : ∀ x ∈ a, ∀ y ∈ a, j x = j y → x = y) + (wf : WellFounded (Rel d (codedRelation d a f))) + (x : ZFSet.{u}) (hx : x ∈ a) : value d (codedRelation d a f) wf (j x) = x := by + induction x using ZFSet.inductionOn with + | h x ih => + apply ZFSet.ext + intro z + rw [mem_value] + constructor + · rintro ⟨u,_,hux,hz⟩ + obtain ⟨y,hy,w,hw,hyw,rfl,hwx⟩ := (codedRelation_pair hf hj u (j x)).mp hux + have hwx' : x = w := hi x hx w hw hwx + subst w + rw [ih y hyw hy] at hz + exact hz ▸ hyw + · intro hz + have hza := ha x hx z hz + refine ⟨j z,hj z hza,(codedRelation_pair hf hj _ _).mpr + ⟨z,hza,x,hx,hz,rfl,rfl⟩,?_⟩ + exact (ih z hz hza).symm + +theorem internal_small_transitive_bound (M d : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hd : d ∈ M) : + ∃ W ∈ M, ∀ a ∈ M, Transitive a → ∀ f ∈ M, ∀ j : ZFSet.{u} → ZFSet.{u}, + Presents a f j → (∀ x ∈ a, j x ∈ d) → + (∀ x ∈ a, ∀ y ∈ a, j x = j y → x = y) → a ⊆ W := by + obtain ⟨W,hW,hbound⟩ := internal_value_bound M d hM hP hU hPow hS hR hd + refine ⟨W,hW,?_⟩ + intro a ha hat f hf j hfj hj hi x hx + have hr := codedRelation_mem M hM hP hU hPow hS.bounded hd ha hf + have wf := codedRelation_wellFounded hfj hj hi + have hv := hbound _ hr (codedRelation_on d a f) wf (j x) (hj x hx) + rw [codedRelation_value hat hfj hj hi wf x hx] at hv + exact hv + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseCollection.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseCollection.lean new file mode 100644 index 0000000000000000000000000000000000000000..caeae73682a857013d9105538cd45d3890852bbd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseCollection.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.SetModels.CollapseCertificate +import OAI.Computability.DegreeRigidity.Syntax.SigmaSeparationName + +namespace OAI + + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory +universe u + +theorem collect_graphs (M d : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hd : d ∈ M) : + ∃ B ∈ M, ∀ f, f ∈ B ↔ f ∈ M ∧ ∃ r ∈ M, On d r ∧ ∃ b ∈ M, Graph d r d b f := by + obtain ⟨q,hq,hqdef⟩ := internal_power M hM hPow + (product_mem M hM hP hU hPow hS.bounded hd hd) + let e := fun _ : ℕ => d + let success := SigmaFormula.existsSet (Code.full 2 1 0) + let a := ZFSet.sep (fun r => success.Realize M (cons r e)) q + have ha : a ∈ M := sigma_sep_mem M hM hS success e (fun _ => hd) hq + have cert (r f : ZFSet.{u}) (hr : r ∈ M) (hf : f ∈ M) : + (Code.full 2 1 0).Realize M (cons f (cons r e)) ↔ ∃ b ∈ M, Graph d r d b f := + Code.realize_full M hM _ (by + intro i; rcases i with _|i; exact hf + rcases i with _|i; exact hr + exact hd) 2 1 0 + have ha_def (r : ZFSet.{u}) : r ∈ a ↔ + r ∈ M ∧ On d r ∧ ∃ f ∈ M, ∃ b ∈ M, Graph d r d b f := by + rw [ZFSet.mem_sep,hqdef] + change (r ∈ M ∧ On d r) ∧ (∃ f ∈ M, _) ↔ _ + constructor + · rintro ⟨⟨hr,hrd⟩,f,hf,hc⟩ + exact ⟨hr,hrd,f,hf,(cert r f hr hf).mp hc⟩ + · rintro ⟨hr,hrd,f,hf,b,hb,hg⟩ + exact ⟨⟨hr,hrd⟩,f,hf,(cert r f hr hf).mpr ⟨b,hb,hg⟩⟩ + obtain ⟨B,hB,hBdef⟩ := hR (Code.full 2 1 0) e (fun _ => hd) a ha (by + intro r hr + obtain ⟨hrM,hrd,f,hf,b,hb,hfg⟩ := (ha_def r).mp hr + refine ⟨f,hf,(cert r f hrM hf).mpr ⟨b,hb,hfg⟩,?_⟩ + intro g hg hcg + obtain ⟨b',_,hgg⟩ := (cert r g hrM hg).mp hcg + exact hgg.unique (hfg.wellFounded hrd) hfg) + refine ⟨B,hB,fun f => ?_⟩ + constructor + · intro hf + have hfM := hM B hB f hf + obtain ⟨r,hr,hc⟩ := (hBdef f hfM).mp hf + obtain ⟨hrM,hrd,_⟩ := (ha_def r).mp hr + exact ⟨hfM,r,hrM,hrd,(cert r f hrM hfM).mp hc⟩ + · rintro ⟨hf,r,hr,hrd,b,hb,hg⟩ + exact (hBdef f hf).mpr ⟨r,(ha_def r).mpr ⟨hr,hrd,f,hf,b,hb,hg⟩, + (cert r f hr hf).mpr ⟨b,hb,hg⟩⟩ + +theorem internal_value_bound (M d : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hd : d ∈ M) : + ∃ W ∈ M, ∀ r ∈ M, On d r → ∀ wf : WellFounded (Rel d r), + ∀ x ∈ d, value d r wf x ∈ W := by + obtain ⟨B,hB,hBdef⟩ := collect_graphs M d hM hP hU hPow hS hR hd + let W := iterUnion 2 (ZFSet.sUnion B) + have hW : W ∈ M := iterUnion_mem M hM hU (union_mem M hM hU hB) 2 + refine ⟨W,hW,?_⟩ + intro r hr hrd wf x hx + obtain ⟨f,hf,hfg⟩ := internal_graph M d r hM hP hU hPow hS.bounded hR hd hr wf + have hfB := (hBdef f).mpr ⟨hf,r,hr,hrd,_,iterUnion_mem M hM hU hf 2,hfg⟩ + have hpair := (hfg.mem_iff wf _).mpr ⟨x,hx,rfl⟩ + exact second_mem_doubleUnion (ZFSet.mem_sUnion.mpr ⟨f,hfB,hpair⟩) + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseCountWithoutChoice.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseCountWithoutChoice.lean new file mode 100644 index 0000000000000000000000000000000000000000..3de4563eb24c0452ad7c6c96cecf5b558ddaafa4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseCountWithoutChoice.lean @@ -0,0 +1,53 @@ +import OAI.Computability.DegreeRigidity.SetModels.CollapseDenseWithoutChoice +import OAI.Computability.DegreeRigidity.SetModels.InternalCollapseCounting + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalCollapse +open TransitiveNameModel CountableForcing +universe u +attribute [local instance] order collapsePreorder + +theorem unionGraph_total_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hS : Separation M) (hω : ZFSet.omega.{u} ∈ M) + {A c : ZFSet.{u}} (hA : A ∈ M) (hcM : c ∈ M) + (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) (hne : ∃ x, x ∈ A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (n : ℕ) : + ∃ x ∈ A, ZFSet.pair (natSet n) x ∈ unionGraph G := by + obtain ⟨p,hp,hpn⟩ := hG (definedAt c A n) (definedAt_mem_without_choice M hM hS hω hcM hA n) + (definedAt_dense_without_choice M hM hP hU hω hA hc hne n) + obtain ⟨_,x,hx,hnx⟩ := ZFSet.mem_sep.mp hpn + exact ⟨x,hx,(mem_unionGraph G _).mpr ⟨p,hp,hnx⟩⟩ + +theorem unionGraph_onto_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hS : Separation M) (hω : ZFSet.omega.{u} ∈ M) + {A c : ZFSet.{u}} (hA : A ∈ M) (hcM : c ∈ M) + (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + ∀ x ∈ A, ∃ n ∈ ZFSet.omega, ZFSet.pair n x ∈ unionGraph G := by + intro x hx + obtain ⟨p,hp,hpx⟩ := hG (covers c x) (covers_mem_without_choice M hM hS hω hcM (hM _ hA _ hx)) + (covers_dense_without_choice M hM hP hU hω hA hc hx) + obtain ⟨_,n,hn,hnx⟩ := ZFSet.mem_sep.mp hpx + exact ⟨n,hn,(mem_unionGraph G _).mpr ⟨p,hp,hnx⟩⟩ + +theorem unionGraph_function_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hS : Separation M) (hω : ZFSet.omega.{u} ∈ M) + {A c : ZFSet.{u}} (hA : A ∈ M) (hcM : c ∈ M) + (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) (hne : ∃ x, x ∈ A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + TransitiveNameModel.FunctionGraph ZFSet.omega A (unionGraph G) := by + have hcP : ∀ p ∈ c, Prefix A p := fun p hp => ((hc p).mp hp).2 + constructor + · intro z hz + obtain ⟨p,_,hzp⟩ := (mem_unionGraph G z).mp hz + exact ZFSet.mem_prod.mp (prefix_subset (hcP _ (label_mem c p)) hzp) + · intro i hi + obtain ⟨n,rfl⟩ := (mem_omega i).mp hi + obtain ⟨x,hx,hnx⟩ := unionGraph_total_without_choice M hM hP hU hS hω hA hcM hc hne G hG n + exact ⟨x,hx,hnx,fun y _ hny => unionGraph_functional hcP G hny hnx⟩ + +end TuringRigidity.BoundedSetTheory.InternalCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseDenseWithoutChoice.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseDenseWithoutChoice.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6505b54e7ed777bb8c5cdb6ec784d5cf8e8045b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseDenseWithoutChoice.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DegreeRigidity.SetModels.CollapseWithoutChoice +import OAI.Computability.DegreeRigidity.SetModels.InternalCollapseDense + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalCollapse +open TransitiveNameModel CountableForcing +universe u +attribute [local instance] order collapsePreorder + +theorem extend_length_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hω : ZFSet.omega.{u} ∈ M) + {A p : ZFSet.{u}} (hA : A ∈ M) (hpM : p ∈ M) (hp : Prefix A p) + (hne : ∃ x, x ∈ A) (m : ℕ) : + ∃ q ∈ M, ∃ k : ℕ, m ≤ k ∧ TransitiveNameModel.FunctionGraph (natSet k) A q ∧ p ⊆ q := by + obtain ⟨x,hx⟩ := hne + induction m with + | zero => + obtain ⟨k,hk⟩ := hp + exact ⟨p,hpM,k,Nat.zero_le _,hk,fun _ h => h⟩ + | succ m ih => + obtain ⟨q,hqM,k,hk,hq,hpq⟩ := ih + by_cases hmk : m+1 ≤ k + · exact ⟨q,hqM,k,hmk,hq,hpq⟩ + · refine ⟨append q k x,append_mem_without_choice M hM hP hU hω hqM (hM _ hA _ hx) k,k+1,by omega, + append_function hq hx,fun z hz => ?_⟩ + exact (mem_append _ _ _ _).mpr (Or.inl (hpq hz)) + +theorem covers_mem_without_choice (M : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hω : ZFSet.omega.{u} ∈ M) + {c x : ZFSet.{u}} (hc : c ∈ M) (hx : x ∈ M) : covers c x ∈ M := by + let e := cons ZFSet.omega (fun _ => x) + have he : ∀ i, e i ∈ M := by intro i; cases i <;> first | exact hω | exact hx + simpa only [covers,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] using + sep_mem M hM hS (.existsMem 1 (.pairMem 0 3 1)) e he hc + +theorem definedAt_mem_without_choice (M : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hω : ZFSet.omega.{u} ∈ M) + {c A : ZFSet.{u}} (hc : c ∈ M) (hA : A ∈ M) (n : ℕ) : definedAt c A n ∈ M := by + let e := cons A (fun _ => natSet.{u} n) + have he : ∀ i, e i ∈ M := by + intro i; cases i + · exact hA + · exact hM _ (hω) _ ((mem_omega _).mpr ⟨n,rfl⟩) + simpa only [definedAt,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] using + sep_mem M hM hS (.existsMem 1 (.pairMem 3 0 1)) e he hc + +theorem covers_dense_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hω : ZFSet.omega.{u} ∈ M) + {A c : ZFSet.{u}} (hA : A ∈ M) (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) + {x : ZFSet.{u}} (hx : x ∈ A) : Dense {p : Conditions c | label c p ∈ covers c x} := by + intro p + obtain ⟨hpM,n,hp⟩ := (hc _).mp (label_mem c p) + let q := append (label c p) n x + have hq : q ∈ c := (hc q).mpr ⟨append_mem_without_choice M hM hP hU hω hpM (hM _ hA _ hx) n,n+1,append_function hp hx⟩ + obtain ⟨r,hr⟩ := label_surjective c hq + refine ⟨r,?_,?_⟩ + · change label c p ⊆ label c r + rw [hr] + exact fun z hz => (mem_append _ _ _ _).mpr (Or.inl hz) + · change label c r ∈ covers c x + rw [hr,covers,ZFSet.mem_sep] + exact ⟨hq,natSet n,(mem_omega _).mpr ⟨n,rfl⟩,(mem_append _ _ _ _).mpr (Or.inr rfl)⟩ + +theorem definedAt_dense_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hω : ZFSet.omega.{u} ∈ M) + {A c : ZFSet.{u}} (hA : A ∈ M) (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) + (hne : ∃ x, x ∈ A) (n : ℕ) : Dense {p : Conditions c | label c p ∈ definedAt c A n} := by + intro p + obtain ⟨hpM,hp⟩ := (hc _).mp (label_mem c p) + obtain ⟨q,hqM,k,hnk,hq,hpq⟩ := extend_length_without_choice M hM hP hU hω hA hpM hp hne (n+1) + have hqc : q ∈ c := (hc q).mpr ⟨hqM,k,hq⟩ + obtain ⟨r,hr⟩ := label_surjective c hqc + obtain ⟨x,hx,hnx,_⟩ := hq.2 (natSet n) ((natSet_mem_natSet n k).mpr (by omega)) + refine ⟨r,?_,?_⟩ + · change label c p ⊆ label c r + rw [hr]; exact hpq + · change label c r ∈ definedAt c A n + rw [hr,definedAt,ZFSet.mem_sep] + exact ⟨hqc,x,hx,hnx⟩ + +end TuringRigidity.BoundedSetTheory.InternalCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseInternalCountingWithoutChoice.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseInternalCountingWithoutChoice.lean new file mode 100644 index 0000000000000000000000000000000000000000..97a0d6418a8d9b504e54c5314b3b622fd9dd3554 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseInternalCountingWithoutChoice.lean @@ -0,0 +1,42 @@ +import OAI.Computability.DegreeRigidity.SetModels.CollapseCountWithoutChoice + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalCollapse +open TransitiveNameModel CountableForcing +universe u +attribute [local instance] order collapsePreorder + +theorem unionGraph_mem_extension_without_choice (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) + {c : ZFSet.{u}} (hcM : c ∈ M) (h0 : (∅ : ZFSet.{u}) ∈ c) + (G : GenericFilter (Conditions c)) : + unionGraph G ∈ genericExtensionSet M c G.carrier := by + let _ := top c h0 + have htop : ⊤ ∈ G.carrier := by + obtain ⟨p,hp⟩ := G.nonempty + exact G.upper le_top hp + have hEU := extension_union M c (orderSet c) hM hP hU hPow hS hcM + (orderSet_mem_without_choice M hM hP hU hPow hS hcM) (orderSet_pair c) G + apply union_mem _ (genericExtensionSet_transitive M c hM G.carrier) hEU + exact genericFilterSet_mem_extension M c hM hP hU hPow hS hR hI hcM G.carrier htop + +theorem internal_counting_without_choice (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) + {A c : ZFSet.{u}} (hA : A ∈ M) (hcM : c ∈ M) + (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) (hne : ∃ x, x ∈ A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + InternallyCountable (genericExtensionSet M c G.carrier) A := by + have hω := omega_mem M hM hS hI + have h0 : (∅ : ZFSet.{u}) ∈ c := + (hc ∅).mpr ⟨hM _ hω _ ZFSet.omega_zero,prefix_empty A⟩ + exact ⟨unionGraph G,unionGraph_mem_extension_without_choice M hM hP hU hPow hS hR hI hcM h0 G, + unionGraph_function_without_choice M hM hP hU hS hω hA hcM hc hne G hG, + unionGraph_onto_without_choice M hM hP hU hS hω hA hcM hc G hG⟩ + +end TuringRigidity.BoundedSetTheory.InternalCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CollapsePrefixAbsolute.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapsePrefixAbsolute.lean new file mode 100644 index 0000000000000000000000000000000000000000..397ae28c7b7b224b67abccc6b2a9bf602cd5f8c0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapsePrefixAbsolute.lean @@ -0,0 +1,61 @@ +import OAI.Computability.DegreeRigidity.SetModels.CollapseWithoutChoice + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalCollapse +open TransitiveNameModel +universe u + +theorem prefix_mem_without_choice (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hω : ZFSet.omega.{u} ∈ M) + {A p : ZFSet.{u}} (hA : A ∈ M) (hp : Prefix A p) : p ∈ M := by + classical + obtain ⟨n,hp⟩ := hp + have h0 : (∅ : ZFSet.{u}) ∈ M := hM _ hω _ ZFSet.omega_zero + cases n with + | zero => + have eq : p = ∅ := by + apply ZFSet.ext; intro z + constructor + · intro hz + obtain ⟨i,hi,_,_,_⟩ := hp.1 z hz + exact False.elim (ZFSet.notMem_empty i hi) + · exact fun hz => False.elim (ZFSet.notMem_empty z hz) + exact eq ▸ h0 + | succ n => + obtain ⟨v,hv,hva⟩ := InternalWellOrder.FunctionGraph.exists_presentation hp + let f : ℕ → ZFSet.{u} := fun i => if i ≤ n then v (natSet i) else ∅ + have hf : ∀ i, f i ∈ M := by + intro i + dsimp only [f] + split_ifs with hi + · exact hM A hA _ (hva _ ((natSet_mem_natSet i (n+1)).mpr (by omega))) + · exact h0 + have eq : p = finiteModelGraph f n := by + apply ZFSet.ext; intro z + rw [mem_finiteModelGraph] + constructor + · intro hz + obtain ⟨j,hj,y,_,rfl⟩ := hp.1 z hz + obtain ⟨i,hi,rfl⟩ := (mem_natSet (n+1) j).mp hj + have hin : i ≤ n := by omega + have hy := ((hv.pair_iff _ _).mp hz).2 + exact ⟨i,hin,by rw [hy]; simp only [f,ite_eq_left hin]⟩ + · rintro ⟨i,hi,rfl⟩ + apply (hv.pair_iff _ _).mpr + exact ⟨(natSet_mem_natSet i (n+1)).mpr (by omega),by simp only [f,ite_eq_left hi]⟩ + rw [eq] + exact finiteModelGraph_mem M hM hP hU hω f hf n + +theorem conditions_exist_absolute_without_choice (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hω : ZFSet.omega.{u} ∈ M) {A : ZFSet.{u}} (hA : A ∈ M) : + ∃ c ∈ M, ∀ p, p ∈ c ↔ Prefix A p := by + obtain ⟨c,hc,hcdef⟩ := conditions_exist_without_choice M hM hP hU hPow hS hω hA + exact ⟨c,hc,fun p => (hcdef p).trans + ⟨And.right,fun hp => ⟨prefix_mem_without_choice M hM hP hU hω hA hp,hp⟩⟩⟩ + +end TuringRigidity.BoundedSetTheory.InternalCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseWithoutChoice.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseWithoutChoice.lean new file mode 100644 index 0000000000000000000000000000000000000000..376cc286e95557badaea8c9b6911f616c6b6b81c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CollapseWithoutChoice.lean @@ -0,0 +1,42 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCollapseConditions + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalCollapse +open TransitiveNameModel CountableForcing +universe u +attribute [local instance] order + +theorem append_mem_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hω : ZFSet.omega.{u} ∈ M) + {p x : ZFSet.{u}} (hp : p ∈ M) (hx : x ∈ M) (n : ℕ) : append p n x ∈ M := + binary_union_mem M hM hP hU hp + (singleton_mem M hM hP (orderedPair_mem M hM hP + (hM _ (hω) _ ((mem_omega _).mpr ⟨n,rfl⟩)) hx)) + +theorem conditions_exist_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hω : ZFSet.omega.{u} ∈ M) + {A : ZFSet.{u}} (hA : A ∈ M) : + ∃ c ∈ M, ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p := by + obtain ⟨Q,hQM,hQ⟩ := internal_power M hM hPow + (product_mem M hM hP hU hPow hS hω hA) + let e := cons ZFSet.omega (fun _ => A) + have he : ∀ i, e i ∈ M := by intro i; cases i <;> assumption + let c := ZFSet.sep (fun p => (prefixFormula 1 2 0).Eval (cons p e)) Q + refine ⟨c,sep_mem M hM hS _ e he hQM,fun p => ?_⟩ + rw [ZFSet.mem_sep,eval_prefixFormula 1 2 0 (cons p e) rfl,hQ] + exact ⟨fun h => ⟨h.1.1,h.2⟩,fun h => ⟨⟨h.1,prefix_subset h.2⟩,h.2⟩⟩ + +theorem orderSet_mem_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) + {c : ZFSet.{u}} (hc : c ∈ M) : orderSet c ∈ M := by + let e : ℕ → ZFSet.{u} := fun _ => c + simpa only [orderSet,Formula.Eval,Formula.eval_orderedPair,Formula.eval_subset,cons_zero,cons_succ,e] using + sep_mem M hM hS + (.existsMem 1 (.existsMem 2 (.conj (.orderedPair 2 1 0) (.subset 0 1)))) e (fun _ => hc) + (product_mem M hM hP hU hPow hS hc hc) + +end TuringRigidity.BoundedSetTheory.InternalCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ColumnSetFormula.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ColumnSetFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..3001bfc3a677d10450febc86ca1de7303e98f9c5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ColumnSetFormula.lean @@ -0,0 +1,60 @@ +import OAI.Computability.DegreeRigidity.SetModels.DegreeSetFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open EncodedForcing +universe u +namespace Formula + +def columnBit (o Q n H k : ℕ) : Formula := .existsMem o + (.conj (naturalPair (o+1) (Q+1) (n+1) (k+1) 0) (.member 0 (H+1))) + +theorem columnBit_spec (o Q n H k : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ i, finiteNaturalGraph f i ∈ e Q) + (A : Oracle) (hA : e H = realCode A) (N K : ℕ) (hn : e n = natSet N) (hk : e k = natSet K) : + (columnBit o Q n H k).Eval e ↔ columns A N K = true := by + simp only [columnBit,Formula.Eval,cons_zero,cons_succ] + constructor + · rintro ⟨v,_,hp,hm⟩ + have hv : v = natSet (Nat.pair N K) := + (naturalPair_spec (o+1) (Q+1) (n+1) (k+1) 0 (cons v e) ho hQ N K hn hk).mp hp + rw [hv,hA,natSet_mem_realCode] at hm + exact hm + · intro h + refine ⟨natSet (Nat.pair N K),?_,?_,?_⟩ + · rw [ho]; exact (mem_omega _).mpr ⟨Nat.pair N K,rfl⟩ + · exact (naturalPair_spec (o+1) (Q+1) (n+1) (k+1) 0 (cons (natSet (Nat.pair N K)) e) + ho hQ N K hn hk).mpr rfl + · rw [hA,natSet_mem_realCode]; exact h + +def columnSet (o Q n H B : ℕ) : Formula := .conj (.subset B o) + (allMem o (iff (.member 0 (B+1)) (columnBit (o+1) (Q+1) (n+1) (H+1) 0))) + +theorem columnSet_spec (o Q n H B : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ i, finiteNaturalGraph f i ∈ e Q) + (A : Oracle) (hA : e H = realCode A) (N : ℕ) (hn : e n = natSet N) : + (columnSet o Q n H B).Eval e ↔ e B = realCode (columns A N) := by + simp only [columnSet,Formula.Eval,eval_subset,eval_allMem,eval_iff,cons_zero,cons_succ] + rw [ho] + constructor + · rintro ⟨hsub,h⟩ + apply ZFSet.ext; intro w + by_cases hw : w ∈ ZFSet.omega.{u} + · obtain ⟨k,rfl⟩ := (mem_omega w).mp hw + rw [natSet_mem_realCode] + exact (h _ ((mem_omega _).mpr ⟨k,rfl⟩)).trans + (columnBit_spec (o+1) (Q+1) (n+1) (H+1) 0 (cons (natSet k) e) ho hQ A hA N k hn rfl) + · exact ⟨fun h => False.elim (hw (hsub h)),fun h => False.elim (hw (realCode_subset _ h))⟩ + · intro hb + refine ⟨hb.symm ▸ realCode_subset (columns A N),?_⟩ + intro w hw + obtain ⟨k,rfl⟩ := (mem_omega w).mp hw + rw [hb,natSet_mem_realCode] + exact (columnBit_spec (o+1) (Q+1) (n+1) (H+1) 0 (cons (natSet k) e) ho hQ A hA N k hn rfl).symm +end Formula + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ConservativeExtension.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ConservativeExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..88ce3794159823ac76fba9fdc1604edb0ccac1c1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ConservativeExtension.lean @@ -0,0 +1,127 @@ +import OAI.Computability.DegreeRigidity.Representation.CommonIdealSearch + +namespace OAI + +namespace TuringRigidity.ConservativeExtension +open CommonIdeal + +def Decide (A Y : Oracle) (e : OracleCode) (s : List Bool) : Prop := + (∃ n a, a ∈ run A e s n ∧ a ≠ bit (Y n)) ∨ + ∀ t, s <+: t → ∀ n a, a ∈ run A e t n → a = bit (Y n) + +theorem decide_dense (A Y : Oracle) (e : OracleCode) (s : List Bool) : + ∃ t, s <+: t ∧ Decide A Y e t := by + by_cases h : ∃ t, s <+: t ∧ ∃ n a, a ∈ run A e t n ∧ a ≠ bit (Y n) + · obtain ⟨t, ht, h⟩ := h + exact ⟨t, ht, Or.inl h⟩ + · refine ⟨s, List.prefix_rfl, Or.inr ?_⟩ + intro t ht n a ha + by_contra hn + exact h ⟨t, ht, n, a, ha, hn⟩ + +theorem removes_oracle {A Y G : Oracle} {e : OracleCode} {s : List Bool} + (hG : Extends G s) (hD : Decide A Y e s) + (he : OracleCode.eval (oracleFunction (join A G)) e = oracleFunction Y) : + Reduces Y A := by + have hu : ∀ t, s <+: t → ∀ n a, a ∈ run A e t n → a = bit (Y n) := by + rcases hD with ⟨n, a, ha, hn⟩ | hD + · have hh := run_total hG n a ha + rw [he] at hh + exact False.elim (hn (Part.mem_some_iff.mp hh)) + · exact hD + apply common_output_reduces (G := G) (H := G) (p := e) (q := e) + (s := s) (t := s) hG hG (Or.inr ?_) he he + intro u v n a b hu' hv' ha hb + exact (hu u hu' n a ha).trans (hu v hv' n b hb).symm + +def Diagonal (B : Oracle) (e : OracleCode) (s : List Bool) : Prop := + ∃ n, n < s.length ∧ + OracleCode.eval (oracleFunction B) e n ≠ Part.some (bit (s.getD n false)) + +theorem diagonal_dense (B : Oracle) (e : OracleCode) (s : List Bool) : + ∃ t, s <+: t ∧ Diagonal B e t := by + have hex : ∃ b : Bool, OracleCode.eval (oracleFunction B) e s.length ≠ Part.some (bit b) := by + by_cases h : OracleCode.eval (oracleFunction B) e s.length = Part.some (bit false) + · exact ⟨true, by rw [h]; simp [bit]⟩ + · exact ⟨false, h⟩ + obtain ⟨b, hb⟩ := hex + refine ⟨s ++ [b], List.prefix_append _ _, s.length, by simp, ?_⟩ + simpa [List.getD_eq_getElem?_getD, List.getElem?_append] using hb + +theorem meets_countable {ι : Type*} [Countable ι] (R : ι → List Bool → Prop) + (hR : ∀ i s, ∃ t, s <+: t ∧ R i t) : + ∃ G : Oracle, ∀ i, ∃ s, Extends G s ∧ R i s := by + classical + let := Encodable.ofCountable ι + let Q : Unit → ℕ → ℕ → Prop := fun _ n c => + ∀ i, Encodable.decode n = some i → R i (BorelGeneric.word c) + have hd : ∀ x n s, ∃ t, BorelGeneric.Ext s t ∧ Q x n t := by + intro x n s + let u := BorelGeneric.word s ++ [false] + have hs : BorelGeneric.word s <+: u := List.prefix_append _ _ + have hl : (BorelGeneric.word s).length < u.length := by simp [u] + cases hh : Encodable.decode (α := ι) n with + | none => + obtain ⟨t, ht⟩ := BorelGeneric.word_surjective u + refine ⟨t, ⟨ht ▸ hs, ht ▸ hl⟩, ?_⟩ + intro i hi + simp [hh] at hi + | some i => + obtain ⟨v, huv, hv⟩ := hR i u + obtain ⟨t, ht⟩ := BorelGeneric.word_surjective v + refine ⟨t, ⟨ht ▸ hs.trans huv, ht ▸ hl.trans_le huv.length_le⟩, ?_⟩ + intro j hj + have he : i = j := Option.some.inj (hh.symm.trans hj) + subst j + simpa [ht] using hv + refine ⟨BorelGeneric.generic Q hd (), ?_⟩ + intro i + let n := Encodable.encode i + let t := BorelGeneric.stage Q hd (n+1) () + refine ⟨BorelGeneric.word t, BorelGeneric.meets_stage Q hd () (n+1), ?_⟩ + exact (BorelGeneric.next_spec Q hd n () (BorelGeneric.stage Q hd n ())).2 i + (by simp [n]) + +theorem exists_conservative_extension (B : Oracle) : + ∃ C : Oracle, ¬ Reduces C B ∧ + ∀ A Y : Oracle, Reduces A B → Reduces Y B → + Reduces Y (join A C) → Reduces Y A := by + let L := {A : Oracle // Reduces A B} + have : Countable L := (countable_reduces B).to_subtype + let I := Sum OracleCode (L × L × OracleCode) + let R : I → List Bool → Prop := fun i s => match i with + | .inl e => Diagonal B e s + | .inr (A, Y, e) => Decide A.val Y.val e s + have hR : ∀ i s, ∃ t, s <+: t ∧ R i t := by + intro i s + cases i with + | inl e => exact diagonal_dense B e s + | inr v => exact decide_dense v.1.val v.2.1.val v.2.2 s + obtain ⟨C, hC⟩ := meets_countable R hR + refine ⟨C, ?_, ?_⟩ + · intro h + obtain ⟨e, he⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h + obtain ⟨s, hs, n, hn, hne⟩ := hC (.inl e) + apply hne + rw [he] + change Part.some (bit (C n)) = _ + rw [hs n hn] + · intro A Y hA hY h + obtain ⟨e, he⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h + obtain ⟨s, hs, hd⟩ := hC (.inr (⟨A, hA⟩, ⟨Y, hY⟩, e)) + exact removes_oracle hs hd he + +theorem exists_conservative_degree (b : Degree) : + ∃ c : Degree, ¬ c ≤ b ∧ + ∀ a y : Degree, a ≤ b → y ≤ b → y ≤ a ⊔ c → y ≤ a := by + obtain ⟨B, rfl⟩ := degree_surjective b + obtain ⟨C, hC, h⟩ := exists_conservative_extension B + refine ⟨degree C, hC, ?_⟩ + intro a y ha hy hr + obtain ⟨A, rfl⟩ := degree_surjective a + obtain ⟨Y, rfl⟩ := degree_surjective y + exact h A Y ha hy hr + +end TuringRigidity.ConservativeExtension + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ContinuousCode.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ContinuousCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..be6ccfefa2ca878b106ff76f0933a74a62f2e7a2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ContinuousCode.lean @@ -0,0 +1,115 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformPrograms +import OAI.Computability.DegreeRigidity.Representation.GenericTopology + +namespace OAI + +namespace TuringRigidity.ContinuousCode +open UniformPrograms UniformOracle BinarySeries FiniteShuffle GenericTopology Set Encodable + +theorem table_agreement {A B : Oracle} {n : ℕ} + (h : oraclePrefix (bit A) n = oraclePrefix (bit B) n) : Agree n A B := by + intro i hi + have hh := congrArg (fun L : List ℕ => L.getD i 0) h + have hb : bit A i = bit B i := by simpa [oraclePrefix,List.getD,hi] using hh + cases ha : A i <;> cases hb' : B i <;> simp_all [bit] + +def LocalAnswer (U : Set Oracle) (f : Oracle → Oracle) (n : ℕ) (L : List ℕ) (a : ℕ) : Prop := + ∀ A ∈ U, oraclePrefix (bit A) L.length = L → bit (f A) n = a + +noncomputable def parameter (U : Set Oracle) (f : Oracle → Oracle) : Oracle := by + classical + exact fun k => decide (LocalAnswer U f (Nat.unpair k).1 + ((decode (α := List ℕ) (Nat.unpair (Nat.unpair k).2).1).getD []) + (Nat.unpair (Nat.unpair k).2).2) + +def queryIndex (A : Oracle) (n k : ℕ) : ℕ := + Nat.pair n (Nat.pair (encode (oraclePrefix (bit A) (Nat.unpair k).1)) (Nat.unpair k).2) + +def trial (A P : Oracle) (n k : ℕ) : Option ℕ := + if P (queryIndex A n k) then some (Nat.unpair k).2 else none + +theorem trial_sound (U : Set Oracle) (f : Oracle → Oracle) (A : Oracle) (hA : A ∈ U) + (n k a : ℕ) (ha : a ∈ trial A (parameter U f) n k) : a = bit (f A) n := by + unfold trial at ha + split at ha + · rename_i hp + have hval : a = (Nat.unpair k).2 := by symm; simpa using ha + have hl : LocalAnswer U f n (oraclePrefix (bit A) (Nat.unpair k).1) (Nat.unpair k).2 := by + simp only [parameter, decide_eq_true_eq] at hp + simpa [queryIndex] using hp + have hs := hl A hA (by simp [oraclePrefix]) + exact hval.trans hs.symm + · simp at ha + +private def choiceValue (z : ℕ × ℕ) : Option ℕ := if z.1=1 then some z.2 else none +private theorem choiceValue_primrec : Primrec choiceValue := + Primrec.ite ((Primrec.eq.comp Primrec.fst (Primrec.const 1))) + (Primrec.option_some.comp Primrec.snd) (Primrec.const none) + +theorem trial_program (P : Oracle) : + Runs (fun A : Oracle => oracleFunction (join A P)) + (fun A z => Part.some (encode (trial A P (Nat.unpair z).1 (Nat.unpair z).2))) := by + let O : Oracle → ℕ →. ℕ := fun A => oracleFunction (join A P) + have hO : Runs O (fun A n => Part.some (bit (join A P) n)) := query + have hA : Runs O (fun A n => Part.some (bit A n)) := + (UniformPrograms.total_comp hO (primrec (Primrec.nat_mul.comp (Primrec.const 2) Primrec.id))).of_eq + (fun A n => by simp [bit]) + have hP : Runs O (fun _ n => Part.some (bit P n)) := + (UniformPrograms.total_comp hO (primrec (Primrec.succ.comp + (Primrec.nat_mul.comp (Primrec.const 2) Primrec.id)))).of_eq + (fun A n => by simp [bit]) + have hn := primrec (O := O) (Primrec.fst.comp Primrec.unpair) + have hm := primrec (O := O) (Primrec.fst.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have ha := primrec (O := O) (Primrec.snd.comp (Primrec.unpair.comp + (Primrec.snd.comp Primrec.unpair))) + have hL := UniformPrograms.total_comp (initial_program (fun A => bit A) hA) hm + have hq := UniformPrograms.total_pair hn (UniformPrograms.total_pair hL ha) + have hb := UniformPrograms.total_comp hP hq + have hd := primrec (O := O) (Primrec.encode.comp (choiceValue_primrec.comp Primrec.unpair)) + exact (UniformPrograms.total_comp hd (UniformPrograms.total_pair hb ha)).of_eq (fun A z => by + cases hp : P (queryIndex A (Nat.unpair z).1 (Nat.unpair z).2) <;> + simp [trial,choiceValue,queryIndex,bit] at hp ⊢ <;> rfl) + +theorem local_answer_exists (U : Set Oracle) (f : Oracle → Oracle) (hf : ContinuousOn f U) + (A : Oracle) (hA : A ∈ U) (n : ℕ) : + ∃ m, LocalAnswer U f n (oraclePrefix (bit A) m) (bit (f A) n) := by + have hc : ContinuousWithinAt (fun B => f B n) U A := + (continuous_apply n).continuousAt.comp_continuousWithinAt (hf A hA) + have hp : {B | f B n = f A n} ∈ nhdsWithin A U := + hc ((isOpen_discrete ({f A n} : Set Bool)).mem_nhds (by simp)) + obtain ⟨V,hV,hAV,hsub⟩ := mem_nhdsWithin.mp hp + obtain ⟨m,hm⟩ := cylinder_basis V hV A hAV + refine ⟨m,?_⟩ + intro B hB htable + have ht : oraclePrefix (bit B) m = oraclePrefix (bit A) m := by + simpa only [oraclePrefix,List.length_map,List.length_range] using htable + have he : f B n = f A n := hsub ⟨hm B (table_agreement ht).symm,hB⟩ + simp [bit,he] + +theorem trial_complete (U : Set Oracle) (f : Oracle → Oracle) (hf : ContinuousOn f U) + (A : Oracle) (hA : A ∈ U) (n : ℕ) : + ∃ k a, a ∈ trial A (parameter U f) n k := by + obtain ⟨m,hm⟩ := local_answer_exists U f hf A hA n + refine ⟨Nat.pair m (bit (f A) n),bit (f A) n,?_⟩ + have hp : parameter U f (queryIndex A n (Nat.pair m (bit (f A) n))) = true := by + simp only [parameter, decide_eq_true_eq] + simpa [queryIndex] using hm + simp [trial,hp] + +theorem continuous_uniform_program (U : Set Oracle) (f : Oracle → Oracle) (hf : ContinuousOn f U) : + ∃ P : Oracle, ∃ p : OracleCode, ∀ A ∈ U, + OracleCode.eval (oracleFunction (join A P)) p = oracleFunction (f A) := by + let P := parameter U f + let O : U → ℕ →. ℕ := fun A => oracleFunction (join A.val P) + have he : Runs O (fun A z => Part.some (encode (trial A.val P (Nat.unpair z).1 (Nat.unpair z).2))) := by + obtain ⟨p,hp⟩ := trial_program P + exact ⟨p,fun A => hp A.val⟩ + obtain ⟨p,hp⟩ := UniformPrograms.total_search he (fun A => bit (f A.val)) + (fun A => trial_sound U f A.val A.property) + (fun A => trial_complete U f hf A.val A.property) + exact ⟨P,p,fun A hA => hp ⟨A,hA⟩⟩ + +end TuringRigidity.ContinuousCode + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CountableBound.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CountableBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..34c4f18138190edd740395bdb52aaf1009195fa9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CountableBound.lean @@ -0,0 +1,33 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformOracle +import OAI.Computability.DegreeRigidity.Computability.Joins + +namespace OAI + +namespace TuringRigidity.CountableBound +open UniformOracle + +def sum (A : ℕ → Oracle) : Oracle := fun n => A (Nat.unpair n).1 (Nat.unpair n).2 + +theorem reduces_sum (A : ℕ → Oracle) (k : ℕ) : Reduces (A k) (sum A) := by + apply RecursiveIn.iff_nat.mpr + have hO : Nat.RecursiveIn {oracleFunction (sum A)} (oracleFunction (sum A)) := + .oracle _ (Set.mem_singleton _) + have h := total_comp hO (total_pair (total_primrec (Primrec.const k)) (total_primrec Primrec.id)) + exact h.of_eq (fun n => by simp [oracleFunction, sum]) + +theorem countable_bounded (S : Set Degree) (hS : S.Countable) : + ∃ b : Degree, ∀ x ∈ S, x ≤ b := by + by_cases hne : S.Nonempty + · obtain ⟨f, hf⟩ := hS.exists_eq_range hne + choose A hA using (fun n => degree_surjective (f n)) + refine ⟨degree (sum A), ?_⟩ + intro x hx + rw [hf] at hx + obtain ⟨n, rfl⟩ := hx + rw [← hA n] + exact reduces_sum A n + · exact ⟨⊥, fun x hx => False.elim (hne ⟨x, hx⟩)⟩ + +end TuringRigidity.CountableBound + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CountableElementaryHull.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CountableElementaryHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..c062d3ea367a44e4b3e6a77bb4a7a15aa3343993 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CountableElementaryHull.lean @@ -0,0 +1,129 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementaryLanguage +import Mathlib.Data.Set.Countable + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory +universe u + +noncomputable def listEnv : List ZFSet.{u} → ℕ → ZFSet.{u} + | [], _ => ∅ + | x :: _, 0 => x + | _ :: xs, n+1 => listEnv xs n + +noncomputable def envPrefix : ℕ → (ℕ → ZFSet.{u}) → List ZFSet.{u} + | 0, _ => [] + | n+1, e => e 0 :: envPrefix n (fun i => e (i+1)) + +theorem prefix_agrees (n : ℕ) (e : ℕ → ZFSet.{u}) : + ∀ i, i < n → listEnv (envPrefix n e) i = e i := by + induction n generalizing e with + | zero => omega + | succ n ih => + intro i hi + cases i with + | zero => rfl + | succ i => exact ih (fun j => e (j+1)) i (by omega) + +theorem prefix_members (n : ℕ) (e : ℕ → ZFSet.{u}) (D : Set ZFSet.{u}) + (he : ∀ i, e i ∈ D) : ∀ x ∈ envPrefix n e, x ∈ D := by + induction n generalizing e with + | zero => simp [envPrefix] + | succ n ih => + intro x hx + rcases List.mem_cons.mp hx with rfl|hx + · exact he 0 + · exact ih _ (fun i => he (i+1)) x hx + +noncomputable def witness (p : SentenceForm) (xs : List ZFSet.{u}) : ZFSet.{u} := by + classical + exact if h : ∃ x : ZFSet.{u}, p.Sat Set.univ (cons x (listEnv xs)) then Classical.choose h else ∅ + +theorem witness_spec (p : SentenceForm) (xs : List ZFSet.{u}) + (h : ∃ x : ZFSet.{u}, p.Sat Set.univ (cons x (listEnv xs))) : + p.Sat Set.univ (cons (witness p xs) (listEnv xs)) := by + classical + simp only [witness,dite_eq_left h] + exact Classical.choose_spec h + +noncomputable def stage (a : ℕ → ZFSet.{u}) : ℕ → Set ZFSet.{u} + | 0 => Set.range a + | n+1 => stage a n ∪ {x | ∃ p : SentenceForm, ∃ xs : List ZFSet.{u}, + (∀ y ∈ xs, y ∈ stage a n) ∧ x = witness p xs} + +noncomputable def hull (a : ℕ → ZFSet.{u}) : Set ZFSet.{u} := ⋃ n, stage a n + +theorem stage_mono (a : ℕ → ZFSet.{u}) : Monotone (stage a) := by + apply monotone_nat_of_le_succ + intro n x hx + exact Or.inl hx + +theorem stage_countable (a : ℕ → ZFSet.{u}) (n : ℕ) : (stage a n).Countable := by + induction n with + | zero => exact Set.countable_range a + | succ n ih => + apply ih.union + let : Countable (stage a n) := ih.to_subtype + have hc := Set.countable_range (fun z : SentenceForm × List (stage a n) => + witness z.1 (z.2.map Subtype.val)) + apply hc.mono + rintro x ⟨p,xs,hxs,rfl⟩ + let ys : List (stage a n) := xs.attach.map (fun y => ⟨y.val,hxs y.val y.property⟩) + have hy : ys.map Subtype.val = xs := by simp [ys,List.map_map] + exact ⟨(p,ys),by simp only [hy]⟩ + +theorem hull_countable (a : ℕ → ZFSet.{u}) : (hull a).Countable := + Set.countable_iUnion (stage_countable a) + +theorem parameter_mem (a : ℕ → ZFSet.{u}) (n : ℕ) : a n ∈ hull a := + Set.mem_iUnion.mpr ⟨0,⟨n,rfl⟩⟩ + +theorem list_in_stage (a : ℕ → ZFSet.{u}) (xs : List ZFSet.{u}) + (hxs : ∀ x ∈ xs, x ∈ hull a) : ∃ n, ∀ x ∈ xs, x ∈ stage a n := by + induction xs with + | nil => exact ⟨0,by simp⟩ + | cons x xs ih => + obtain ⟨n,hn⟩ := Set.mem_iUnion.mp (hxs x (by simp)) + obtain ⟨m,hm⟩ := ih (fun y hy => hxs y (by simp [hy])) + refine ⟨max n m,?_⟩ + intro y hy + rcases List.mem_cons.mp hy with rfl|hy + · exact stage_mono a (Nat.le_max_left n m) hn + · exact stage_mono a (Nat.le_max_right n m) (hm y hy) + +theorem witness_mem (a : ℕ → ZFSet.{u}) (p : SentenceForm) (xs : List ZFSet.{u}) + (hxs : ∀ x ∈ xs, x ∈ hull a) : witness p xs ∈ hull a := by + obtain ⟨n,hn⟩ := list_in_stage a xs hxs + exact Set.mem_iUnion.mpr ⟨n+1,Or.inr ⟨p,xs,hn,rfl⟩⟩ + +theorem hull_elementary (a : ℕ → ZFSet.{u}) : Elementary (hull a) := by + intro p + induction p with + | equal => intros; rfl + | member => intros; rfl + | conj p q ihp ihq => intro e he; exact and_congr (ihp e he) (ihq e he) + | neg p ih => intro e he; exact not_congr (ih e he) + | ex p ih => + intro e he + constructor + · rintro ⟨x,hx,hp⟩ + exact ⟨x,Set.mem_univ x,(ih (cons x e) (by intro i; cases i <;> simp [cons,he,hx])).mp hp⟩ + · rintro ⟨x,_,hp⟩ + let xs := envPrefix p.bound e + have eq (y : ZFSet.{u}) : p.Sat Set.univ (cons y (listEnv xs)) ↔ + p.Sat Set.univ (cons y e) := by + apply p.finite_support + intro i hi + cases i with + | zero => rfl + | succ i => exact prefix_agrees p.bound e i (by omega) + have hw := witness_mem a p xs (prefix_members p.bound e (hull a) he) + have hs := (eq _).mp (witness_spec p xs ⟨x,(eq x).mpr hp⟩) + exact ⟨_,hw,(ih (cons (witness p xs) e) + (by intro i; cases i <;> simp [cons,he,hw])).mpr hs⟩ + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CountableNameAvoidance.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CountableNameAvoidance.lean new file mode 100644 index 0000000000000000000000000000000000000000..98b16a946064d569fbf00313a0fdb1349b3dd459 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CountableNameAvoidance.lean @@ -0,0 +1,83 @@ +import OAI.Computability.DegreeRigidity.SetModels.NameDifferenceDense +import OAI.Computability.DegreeRigidity.Representation.GroundGenericRequirements + +namespace OAI + + +namespace TuringRigidity.FullSetForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] [OrderTop (Conditions c)] + +omit [Preorder (Conditions c)] [OrderTop (Conditions c)] in + +theorem ground_name_sequence (M N : ZFSet.{u}) [Countable (Conditions N)] (hMN : M ⊆ N) + (t₀ : Name (Conditions c)) (ht₀ : t₀.encode (label c) ∈ M) : + ∃ ts : ℕ → Name (Conditions c), (∀ n, (ts n).encode (label c) ∈ M) ∧ + ∀ t : Name (Conditions c), t.encode (label c) ∈ M → + ∃ n, (ts n).encode (label c) = t.encode (label c) := by + classical + obtain ⟨m,_⟩ := label_surjective N (hMN ht₀) + let _ : Nonempty (Conditions N) := ⟨m⟩ + obtain ⟨e,he⟩ := exists_surjective_nat (Conditions N) + have pick (n : ℕ) : ∃ s : Name (Conditions c), s.encode (label c) ∈ M ∧ + ∀ t : Name (Conditions c), t.encode (label c) ∈ M → + t.encode (label c) = label N (e n) → s.encode (label c) = t.encode (label c) := by + by_cases h : ∃ t : Name (Conditions c), t.encode (label c) ∈ M ∧ + t.encode (label c) = label N (e n) + · obtain ⟨t,ht,heq⟩ := h + exact ⟨t,ht,fun s _ hs => heq.trans hs.symm⟩ + · exact ⟨t₀,ht₀,fun t ht heq => False.elim (h ⟨t,ht,heq⟩)⟩ + choose ts hts using pick + refine ⟨ts,fun n => (hts n).1,?_⟩ + intro t ht + obtain ⟨m,hm⟩ := label_surjective N (hMN ht) + obtain ⟨n,rfl⟩ := he m + exact ⟨n,(hts n).2 t ht hm.symm⟩ + +theorem exists_generic_omitting_subset (M N : ZFSet.{u}) [Countable (Conditions N)] + (hM : Transitive M) (hT : SourceT M) (hMN : M ⊆ N) + (hc : c ∈ M) {o a S : ZFSet.{u}} (hoM : o ∈ M) (ha : a ∈ M) + (hSa : S ⊆ a) (hSM : S ∉ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (p : Conditions c) : + ∃ G : GenericFilter (Conditions c), p ∈ G.carrier ∧ GroundGeneric N G ∧ + S ∉ genericExtensionSet M c G.carrier := by + have ht₀ := encoded_check_mem M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc hc + obtain ⟨ts,hts,hcover⟩ := ground_name_sequence M N hMN (Name.check c) ht₀ + let E : ℕ → Set (Conditions c) := fun n => NameDifference a S (ts n) + have hE : ∀ n, Dense (E n) := fun n => + nameDifference_dense M hM hT hc hoM ha hSa hSM ho (ts n) (hts n) + obtain ⟨G,hp,hG,hGE⟩ := ground_generic_with_requirements N ⟨c,hMN hc⟩ E hE p + refine ⟨G,hp,hG,?_⟩ + intro hSG + obtain ⟨t,ht,hval⟩ := (mem_extensionSet M c G.carrier S).mp hSG + obtain ⟨n,hn⟩ := hcover t ht + obtain ⟨q,hq,hqn⟩ := hGE n + have hGM : GroundGeneric M G := fun D hD hd => hG D (hMN hD) hd + have hne := nameDifference_ne_value M hM hT hc hoM ha ho (ts n) (hts n) G hGM hq hqn + apply hne + exact (Name.val_eq_of_encode_eq (label c) (label_injective c) G.carrier (ts n) t hn).trans hval + +theorem subset_mem_iff_all_generic_extensions (M N : ZFSet.{u}) [Countable (Conditions N)] + (hM : Transitive M) (hT : SourceT M) (hMN : M ⊆ N) + (hc : c ∈ M) {o a S : ZFSet.{u}} (hoM : o ∈ M) (ha : a ∈ M) (hSa : S ⊆ a) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (p : Conditions c) : + S ∈ M ↔ ∀ G : GenericFilter (Conditions c), GroundGeneric N G → p ∈ G.carrier → + S ∈ genericExtensionSet M c G.carrier := by + classical + constructor + · intro hSM G _ hp + exact ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc + G.carrier (G.upper le_top hp) hSM + · intro h + by_contra hSM + obtain ⟨G,hp,hG,hSG⟩ := exists_generic_omitting_subset M N hM hT hMN hc hoM ha hSa hSM ho p + exact hSG (h G hG hp) + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CountableSetReal.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CountableSetReal.lean new file mode 100644 index 0000000000000000000000000000000000000000..16c695a3e9ba98fed798c241a8cd5150f79b97ed --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CountableSetReal.lean @@ -0,0 +1,123 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelDegreeUniverse +import OAI.Computability.DegreeRigidity.SetModels.InternalPresentationEnumeration + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel EncodedForcing +universe u + +namespace Formula +def selectedEnumerationBit (o Q I E F v : ℕ) : Formula := + .existsMem o (.existsMem (o+1) (.conj (naturalPair (o+2) (Q+2) 1 0 (v+2)) + (.existsMem (I+2) (.conj (.pairMem 2 0 (E+3)) + (.existsMem 0 (.conj (.pairMem 1 0 (F+4)) (.member 2 0))))))) + +theorem selectedEnumerationBit_spec (o Q I E F v : ℕ) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) + (N K : ℕ) (hv : e v = natSet (Nat.pair N K)) : + (selectedEnumerationBit o Q I E F v).Eval e ↔ + ∃ D ∈ e I, ZFSet.pair (natSet N) D ∈ e E ∧ + ∃ A ∈ D, ZFSet.pair D A ∈ e F ∧ natSet K ∈ A := by + simp only [selectedEnumerationBit,Formula.Eval,eval_pairMem,cons_zero,cons_succ] + rw [ho] + constructor + · rintro ⟨n,hn,k,hk,hp,hrest⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + obtain ⟨k,rfl⟩ := (mem_omega k).mp hk + have hp' := (naturalPair_spec (o+2) (Q+2) 1 0 (v+2) + (cons (natSet k) (cons (natSet n) e)) ho hQ n k rfl rfl).mp hp + have hnk : Nat.pair N K = Nat.pair n k := natSet_injective (hv.symm.trans hp') + have he := congrArg Nat.unpair hnk + simp only [Nat.unpair_pair,Prod.mk.injEq] at he + obtain ⟨rfl,rfl⟩ := he + exact hrest + · intro h + refine ⟨natSet N,(mem_omega _).mpr ⟨N,rfl⟩,natSet K,(mem_omega _).mpr ⟨K,rfl⟩,?_,h⟩ + exact (naturalPair_spec (o+2) (Q+2) 1 0 (v+2) + (cons (natSet K) (cons (natSet N) e)) ho hQ N K rfl rfl).mpr hv +end Formula + +theorem internal_selected_enumeration_real (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {I E F : ZFSet.{u}} (hIM : I ∈ M) (hEM : E ∈ M) (hFM : F ∈ M) + (hE : TransitiveNameModel.FunctionGraph ZFSet.omega I E) (hF : ChoiceGraph I F) : + ∃ H ∈ modelReals M, ∀ n, ∀ D ∈ I, ZFSet.pair (natSet n) D ∈ E → + ∀ A : Oracle, realCode A ∈ D → ZFSet.pair D (realCode A) ∈ F → columns H n = A := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω + let e := cons ZFSet.omega (cons Q (cons I (cons E (fun _ => F)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hQM + rcases i with _|i; exact hIM + rcases i with _|i; exact hEM + exact hFM + let B := ZFSet.sep (fun v => (Formula.selectedEnumerationBit 1 2 3 4 5 0).Eval (cons v e)) ZFSet.omega + have hBM : B ∈ M := sep_mem M hM hS _ e he hω + have hsub : B ⊆ ZFSet.omega := fun _ h => (ZFSet.mem_sep.mp h).1 + have hB : realCode (decodeReal B) = B := realCode_decodeReal hsub + refine ⟨decodeReal B,?_,?_⟩ + · change realCode (decodeReal B) ∈ M + rw [hB]; exact hBM + · intro n D hD hn A hA hDA + funext k + have hbit : columns (decodeReal B) n k = true ↔ A k = true := by + change decodeReal B (Nat.pair n k) = true ↔ A k = true + rw [decodeReal_true] + change natSet (Nat.pair n k) ∈ ZFSet.sep _ ZFSet.omega ↔ _ + rw [ZFSet.mem_sep,Formula.selectedEnumerationBit_spec 1 2 3 4 5 0 + (cons (natSet (Nat.pair n k)) e) rfl hQ n k rfl] + constructor + · rintro ⟨_,D',_,hn',A',_,hDA',hk⟩ + have hDD := hE.functional ((mem_omega _).mpr ⟨n,rfl⟩) hn hn' + subst D' + have hAA := hF.functional hDA hDA' + rw [←hAA,natSet_mem_realCode] at hk + exact hk + · intro hk + exact ⟨(mem_omega _).mpr ⟨Nat.pair n k,rfl⟩,D,hD,hn,realCode A,hA,hDA, + (natSet_mem_realCode A k).mpr hk⟩ + cases hx : columns (decodeReal B) n k <;> cases hy : A k <;> simp_all + +def InternallyCountable (M I : ZFSet.{u}) : Prop := + ∃ E ∈ M, TransitiveNameModel.FunctionGraph ZFSet.omega I E ∧ + ∀ D ∈ I, ∃ n ∈ ZFSet.omega, ZFSet.pair n D ∈ E + +theorem internal_countable_degree_presentation (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hR : ∀ w ∈ R, ∃ A : Oracle, realCode A = w) + {I : ZFSet.{u}} (hIM : I ∈ M) (hI : I ⊆ degreeUniverse R) + (hcount : InternallyCountable M I) : + ∃ H ∈ modelReals M, presentationSet R H = I := by + obtain ⟨E,hEM,hE,honto⟩ := hcount + obtain ⟨F,hFM,hF⟩ := hT.choice I hIM (fun D hD => by + obtain ⟨A,hA,_⟩ := degreeUniverse_nonempty_member R D (hI hD) + exact ⟨realCode A,hA⟩) + obtain ⟨H,hHM,hH⟩ := internal_selected_enumeration_real M hM hT hIM hEM hFM hE hF + have hentry (n : ℕ) (D : ZFSet.{u}) (hD : D ∈ I) (hn : ZFSet.pair (natSet n) D ∈ E) : + degreeCode R (columns H n) = D := by + obtain ⟨a,ha,hDa,_⟩ := hF.2 D hD + obtain ⟨B,hB,hDB⟩ := (mem_degreeUniverse R D).mp (hI hD) + have har : a ∈ R := degreeCode_subset R B (hDB ▸ ha) + obtain ⟨A,rfl⟩ := hR a har + rw [hH n D hD hn A ha hDa] + have heq := ((realCode_mem_degreeCode R B A).mp (hDB ▸ ha)).2 + exact ((degreeCode_equal R har).mpr heq).trans hDB.symm + refine ⟨H,hHM,?_⟩ + apply ZFSet.ext; intro D + constructor + · intro hD + obtain ⟨n,rfl⟩ := (mem_presentationSet R H D).mp hD + obtain ⟨D,hD,hn,_⟩ := hE.2 (natSet n) ((mem_omega _).mpr ⟨n,rfl⟩) + rw [hentry n D hD hn] + exact hD + · intro hD + obtain ⟨n,hn,hDn⟩ := honto D hD + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + exact (mem_presentationSet R H D).mpr ⟨n,(hentry n D hD hDn).symm⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CountedOriginalRealQuotient.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CountedOriginalRealQuotient.lean new file mode 100644 index 0000000000000000000000000000000000000000..360c561edd953ff139348daaa7833cf9f2f1834e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CountedOriginalRealQuotient.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.Representation.OriginalRealQuotientModel +import OAI.Computability.DegreeRigidity.CohenForcing.CountedCohenConditions +import OAI.Computability.DegreeRigidity.SetModels.InternalQuotientCountability + +namespace OAI + +namespace TuringRigidity.CountedOriginalRealQuotient +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames +open CohenGroundPoset InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax +open InternalProjectedGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop +attribute [local instance] codeOrder codePreorder + +theorem original_name_counted_quotient (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : K ∈ M) + (τ : Name (Conditions (conditions (ZFSet.prod K ZFSet.omega)))) + (hτ : τ.encode (label (conditions (ZFSet.prod K ZFSet.omega))) ∈ M) : + ∃ C ∈ M, ∃ _hCK : C ⊆ K, (C = ∅ ∨ InternallyCountable M C) ∧ + ∃ E : ℕ → ZFSet.{0}, orbitGraph E ∈ M ∧ + (∀ n, E n ∈ M ∧ E n ⊆ conditions (ZFSet.prod C ZFSet.omega)) ∧ + ∃ B ∈ M, ∃ Q ∈ M, ∃ A ∈ M, + (∀ U, U ∈ B ↔ U ∈ M ∧ IsCode (conditions (ZFSet.prod C ZFSet.omega)) U) ∧ + (∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) ∧ + A = InternalGeneratedAlgebra.generated (conditions (ZFSet.prod C ZFSet.omega)) B Q + (InternalBooleanBits.seeds (conditions (ZFSet.prod C ZFSet.omega)) B E) ∧ + Closed (conditions (ZFSet.prod C ZFSet.omega)) B Q A ∧ + ∃ σ : Name (Conditions (positive A)), σ.encode (label (positive A)) ∈ M ∧ + ∃ hBA : ZFSet.prod C ZFSet.omega ⊆ ZFSet.prod K ZFSet.omega, + ∀ G : GenericFilter (Conditions (conditions (ZFSet.prod K ZFSet.omega))), + AtomicForcing.GroundGeneric M G → τ.val G.carrier ⊆ ZFSet.omega → + let J := InternalCohenProjectedGeneric.projected _ _ hBA G + let X := τ.val G.carrier + ∃ H : GenericFilter (Conditions (positive A)), AtomicForcing.GroundGeneric M H ∧ + σ.val H.carrier = X ∧ + genericExtensionSet M (positive A) H.carrier = RealGeneratedModel.hull M X ∧ + RealGeneratedModel.Contains M X (RealGeneratedModel.hull M X) ∧ + let q := InternalQuotientConditions.conditions (conditions (ZFSet.prod C ZFSet.omega)) A + (genericFilterSet (positive A) H.carrier) + q ∈ RealGeneratedModel.hull M X ∧ InternalCollapse.orderSet q ∈ RealGeneratedModel.hull M X ∧ + InternallyCountable (RealGeneratedModel.hull M X) q ∧ + ∃ Gq : GenericFilter (Conditions q), AtomicForcing.GroundGeneric (RealGeneratedModel.hull M X) Gq ∧ + genericExtensionSet (RealGeneratedModel.hull M X) q Gq.carrier = + genericExtensionSet M (conditions (ZFSet.prod C ZFSet.omega)) J.carrier ∧ + genericFilterSet q Gq.carrier = + genericFilterSet (conditions (ZFSet.prod C ZFSet.omega)) J.carrier ∧ + genericExtensionSet (RealGeneratedModel.hull M X) q Gq.carrier ⊆ + genericExtensionSet M (conditions (ZFSet.prod K ZFSet.omega)) G.carrier ∧ + ∀ p ∈ G.carrier, ∃ r ∈ Gq.carrier, + label q r = label _ (InternalCohenFactor.project _ _ hBA p) := by + obtain ⟨C,hC,hCK,hct,E,hgraph,hE,B,hBM,Q,hQM,A,hAM,hB,hQ,hAe,hA,σ,hσ,hBA,hall⟩ := + OriginalRealQuotientModel.original_name_quotient M K hM hT hK τ hτ + have hcM := (manyColumn_internal M C hM hT hC).1 + have hcount := CountedCohenConditions.many_column_conditions_countable M C hM hT hC hct + refine ⟨C,hC,hCK,hct,E,hgraph,hE,B,hBM,Q,hQM,A,hAM,hB,hQ,hAe,hA,σ,hσ,hBA,?_⟩ + intro G hG hreal + obtain ⟨H,hHG,hval,hHull,hprop,hq,ho,Gq,hGq,hext,hcode,hsub,hcond⟩ := hall G hG hreal + refine ⟨H,hHG,hval,hHull,hprop,hq,ho,?_,Gq,hGq,hext,hcode,hsub,hcond⟩ + apply InternalCountableClosure.countable_subset _ _ _ hprop.1 hprop.2.1 + (hprop.2.2.1 hcM) hq (InternalQuotientConditions.conditions_subset _ A _) + (InternalQuotientCountability.countability_upward M _ _ hprop.2.2.1 hcount) + obtain ⟨p,_⟩ := Gq.nonempty + exact ⟨label _ p,label_mem _ p⟩ + +end TuringRigidity.CountedOriginalRealQuotient + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CountedRealsPresentation.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CountedRealsPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ab06770ddadf8b043ffcd8817e7d8b8bec5fce1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CountedRealsPresentation.lean @@ -0,0 +1,81 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelArithmeticDischarge +import OAI.Computability.DegreeRigidity.SetModels.CountableSetReal + +namespace OAI + + +namespace TuringRigidity.SetModelCountability +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions +open SetModelSequences SetDegreeDecoding PersistentRestrictions PersistentPresentation +open EncodedForcing SetModelArithmetic +universe u + +theorem counted_reals_columns {M R : ZFSet.{u}} (C : Context M) (hR : R ∈ M) + (hreal : ∀ x ∈ R, ∃ B : Oracle, realSet B = x) + (hcount : BoundedSetTheory.InternallyCountable M R) : + ∃ A ∈ reals M, ∀ B : Oracle, (∃ n, columns A n = B) ↔ realSet B ∈ R := by + classical + obtain ⟨q,hq,hqf,hqo⟩ := hcount + have hex (n : ℕ) : ∃ B : Oracle, realSet B ∈ R ∧ + ZFSet.pair (natSet n) (realSet B) ∈ q := by + obtain ⟨x,hx,hnx,_⟩ := hqf.2 (natSet n) ((mem_omega _).mpr ⟨n,rfl⟩) + obtain ⟨B,rfl⟩ := hreal x hx + exact ⟨B,hx,hnx⟩ + choose B hB using hex + have hseq : q = sequenceSet B := by + apply ZFSet.ext; intro z + constructor + · intro hz + obtain ⟨x,hx,y,_,rfl⟩ := hqf.1 z hz + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + have hy := hqf.functional ((mem_omega _).mpr ⟨n,rfl⟩) hz (hB n).2 + exact (mem_sequenceSet B _).mpr ⟨n,by rw [hy]⟩ + · intro hz + obtain ⟨n,rfl⟩ := (mem_sequenceSet B z).mp hz + exact (hB n).2 + have hBM (n : ℕ) : B n ∈ reals M := C.transitive R hR _ (hB n).1 + obtain ⟨r,hr,hrc⟩ := internal_reals M C.transitive C.power C.separation C.infinity + let A : Oracle := fun v => B (Nat.unpair v).1 (Nat.unpair v).2 + have hAM : A ∈ reals M := flatten_mem M C.transitive C.pairing C.union C.power + C.separation C.infinity hr hrc C.pairing_mem pairingSet_code B hBM (hseq ▸ hq) + have hcol (n : ℕ) : columns A n = B n := by + funext k; simp only [columns,A,Nat.unpair_pair] + refine ⟨A,hAM,fun X => ?_⟩ + constructor + · rintro ⟨n,rfl⟩; rw [hcol]; exact (hB n).1 + · intro hX + obtain ⟨n,hn,hnX⟩ := hqo _ hX + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + have he := hqf.functional ((mem_omega _).mpr ⟨n,rfl⟩) (hB n).2 hnX + refine ⟨n,?_⟩ + rw [hcol] + exact realSet_injective he + +theorem presentation_of_counted_reals {M R : ZFSet.{u}} (C : Context M) (hR : R ∈ M) + (hreal : ∀ x ∈ R, ∃ B : Oracle, realSet B = x) + (hcount : BoundedSetTheory.InternallyCountable M R) (I : CountableIdeal) + (hI : ∀ d, d ∈ I.carrier ↔ ∃ B : Oracle, realSet B ∈ R ∧ degree B = d) : + ∃ A ∈ reals M, Presented I A := by + obtain ⟨A,hA,hcols⟩ := counted_reals_columns C hR hreal hcount + refine ⟨A,hA,fun d => ?_⟩ + rw [hI] + constructor + · rintro ⟨B,hB,hBd⟩ + obtain ⟨n,hn⟩ := (hcols B).mpr hB + exact ⟨n,by rw [hn,hBd]⟩ + · rintro ⟨n,hn⟩ + exact ⟨columns A n,(hcols _).mp ⟨n,rfl⟩,hn⟩ + +theorem persistent_mem_of_counted_reals {M R : ZFSet.{u}} (C : Context M) (hR : R ∈ M) + (hreal : ∀ x ∈ R, ∃ B : Oracle, realSet B = x) + (hcount : BoundedSetTheory.InternallyCountable M R) (I : CountableIdeal) + (hI : ∀ d, d ∈ I.carrier ↔ ∃ B : Oracle, realSet B ∈ R ∧ degree B = d) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + automorphismSet ρ ∈ M := by + obtain ⟨A,hAM,hA⟩ := presentation_of_counted_reals C hR hreal hcount I hI + exact (SetModelSyntax.persistent_sets C hA hAM ρ hρ hz).2 + +end TuringRigidity.SetModelCountability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/CountedRegularBasis.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/CountedRegularBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..5bf57b584bce2dc8c836efec9b11757201094855 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/CountedRegularBasis.lean @@ -0,0 +1,113 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanDense +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableMap + +namespace OAI + +namespace TuringRigidity.CountedRegularBasis +open TransitiveNameModel BoundedSetTheory InternalRegularOperations InternalRegularAlgebra +open InternalBooleanDense + +def basicFormula (B p U : ℕ) : Formula := + .conj (.member U B) (.conj (.member p U) + (.allMem B (.imp (.member (p+1) 0) (.subset (U+1) 0)))) + +theorem basicFormula_spec (M c B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (b p U : ℕ) (e : ℕ → ZFSet.{0}) (hb : e b = B) (hp : e p ∈ c) : + (basicFormula b p U).Eval e ↔ e U = basicCode c (e p) := by + have hbasic : basicCode c (e p) ∈ B := + (hB _).mpr ⟨basicCode_mem M c _ hM hT hc hp,regular_isCode c _⟩ + simp only [basicFormula,Formula.Eval,Formula.eval_allMem,Formula.eval_imp, + Formula.eval_subset,cons_zero,cons_succ,hb] + constructor + · rintro ⟨hU,hpU,hmin⟩ + have h₁ := hmin _ hbasic (mem_basicCode c _ hp) + have h₂ := (basicCode_le_iff c _ _ hp ((hB _).mp hU).2).mpr hpU + exact ZFSet.ext (fun z => ⟨fun hz => h₁ hz,fun hz => h₂ hz⟩) + · rintro h; rw [h] + exact ⟨hbasic,mem_basicCode c _ hp,fun V hV hpV => + (basicCode_le_iff c _ V hp ((hB V).mp hV).2).mpr hpV⟩ + +theorem internal_basis (M c : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) : + ∃ B ∈ M, (∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) ∧ + ∃ S ∈ M, (∀ U, U ∈ S ↔ ∃ p ∈ c, U = basicCode c p) ∧ + ∃ g ∈ M, FunctionGraph c S g ∧ + (∀ p ∈ c, ∀ U, ZFSet.pair p U ∈ g ↔ U = basicCode c p) ∧ + (∀ U ∈ S, ∃ p ∈ c, ZFSet.pair p U ∈ g) := by + obtain ⟨B,hBM,hB⟩ := internal_algebra M c hM hT hc + let e := cons c (fun _ => B) + have he : ∀ i, e i ∈ M := by intro i; cases i; exact hc; exact hBM + let S := B.sep (fun U => ∃ p ∈ c, U = basicCode c p) + have hs (U : ZFSet.{0}) : U ∈ S ↔ ∃ p ∈ c, U = basicCode c p := by + change (U ∈ B.sep _) ↔ _ + rw [ZFSet.mem_sep] + exact ⟨And.right,fun h@⟨p,hp,hU⟩ => ⟨hU ▸ (hB _).mpr + ⟨basicCode_mem M c p hM hT hc hp,regular_isCode c _⟩,h⟩⟩ + have hφ (U : ZFSet.{0}) : (Formula.existsMem 1 (basicFormula 3 0 1)).Eval (cons U e) ↔ + ∃ p ∈ c, U = basicCode c p := by + change (∃ p ∈ c, (basicFormula 3 0 1).Eval (cons p (cons U e))) ↔ _ + exact exists_congr (fun p => and_congr_right (fun hp => + basicFormula_spec M c B hM hT hc hB 3 0 1 _ rfl hp)) + have hSM : S ∈ M := by + simpa only [hφ,S] using sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (basicFormula 3 0 1)) e he hBM + let v := cons c (cons S (fun _ => B)) + have hv : ∀ i, v i ∈ M := by + intro i; rcases i with _|_|i; exact hc; exact hSM; exact hBM + let ψ : Formula := .existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) (basicFormula 5 1 0))) + let g := (ZFSet.prod c S).sep (fun z => ψ.Eval (cons z v)) + have hgM : g ∈ M := sep_mem M hM hT.separation.finitePrefix.bounded ψ v hv + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hc hSM) + have hψ (z : ZFSet.{0}) : ψ.Eval (cons z v) ↔ + ∃ p ∈ c, ∃ U ∈ S, z = ZFSet.pair p U ∧ U = basicCode c p := by + simp only [ψ,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,v] + apply exists_congr; intro p + apply and_congr_right; intro hp + apply exists_congr; intro U + apply and_congr_right; intro _ + exact and_congr_right (fun _ => basicFormula_spec M c B hM hT hc hB 5 1 0 _ rfl hp) + have hgs (p U : ZFSet.{0}) (hp : p ∈ c) : + ZFSet.pair p U ∈ g ↔ U = basicCode c p := by + simp only [g,ZFSet.mem_sep,hψ] + constructor + · rintro ⟨_,p',_,U',_,he,hU⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact hU + · intro hU + have hUS := (hs U).mpr ⟨p,hp,hU⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨hp,hUS⟩,p,hp,U,hUS,rfl,hU⟩ + refine ⟨B,hBM,hB,S,hSM,hs,g,hgM,⟨?_,?_⟩,(fun p hp U => hgs p U hp),?_⟩ + · intro z hz; exact ZFSet.mem_prod.mp (ZFSet.mem_sep.mp hz).1 + · intro p hp + exact ⟨basicCode c p,(hs _).mpr ⟨p,hp,rfl⟩,(hgs p _ hp).mpr rfl, + fun U _ hU => (hgs p U hp).mp hU⟩ + · intro U hU + obtain ⟨p,hp,he⟩ := (hs U).mp hU + exact ⟨p,hp,(hgs p U hp).mpr he⟩ + +theorem counted_basis (M c : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hct : InternallyCountable M c) : + ∃ S ∈ M, InternallyCountable M S ∧ + (∀ U, U ∈ S ↔ ∃ p ∈ c, U = basicCode c p) ∧ + (∀ U ∈ S, IsCode c U ∧ U ≠ ∅) ∧ + (∀ U, IsCode c U → U ≠ ∅ → ∃ V ∈ S, V ⊆ U) := by + classical + obtain ⟨B,_,_,S,hS,hSs,g,hg,hgf,_,hgo⟩ := internal_basis M c hM hT hc + refine ⟨S,hS,InternalCountableMap.countable_of_surjection M c S g hM hT hc hS hg hgf hgo hct, + hSs,?_,?_⟩ + · intro U hU + obtain ⟨p,hp,rfl⟩ := (hSs U).mp hU + exact ⟨regular_isCode c _,fun h => ZFSet.notMem_empty p (h ▸ mem_basicCode c p hp)⟩ + · intro U hU hne + have hex : ∃ p, p ∈ U := by + by_contra h + exact hne (ZFSet.ext (fun p => ⟨fun hp => False.elim (h ⟨p,hp⟩), + fun hp => False.elim (ZFSet.notMem_empty p hp)⟩)) + obtain ⟨p,hp⟩ := hex + exact ⟨basicCode c p,(hSs _).mpr ⟨p,hU.1 hp,rfl⟩, + (basicCode_le_iff c p U (hU.1 hp) hU).mpr hp⟩ + +end TuringRigidity.CountedRegularBasis + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/DecodingTheorem.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/DecodingTheorem.lean new file mode 100644 index 0000000000000000000000000000000000000000..5e38d33c3e7793e55f4696428afbf18f88374a68 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/DecodingTheorem.lean @@ -0,0 +1,52 @@ +import OAI.Computability.DegreeRigidity.SetModels.RelationPresentation +import OAI.Computability.DegreeRigidity.Computability.OracleJump + +namespace OAI + +namespace TuringRigidity.DecodingTheorem +open IndexPresentation IndexTuples ArithmeticHierarchy RelationPresentation +open SetCoding RelationCoding BoundedDecoding OracleJump + +def Presented {n} (Y : Oracle) (p : RelationCode n) (t : ℕ) : Prop := + (∀ i : Fin n, Dom Y (entry i.val t)) ∧ p.Holds (fun i => value Y (entry i.val t)) + +theorem presentation_exact {n} (Y : Oracle) (p : RelationCode n) + (hp : RelationBelow p (degree Y)) (v : Fin n → Degree) : + p.Holds v ↔ ∃ t, Presented Y p t ∧ ∀ i, value Y (entry i.val t) = v i := by + constructor + · intro hv + have hb : ∀ i, v i ≤ degree Y := by + obtain ⟨c,hc,_⟩ := hv + exact fun i => (graph_bounded (hp.1 i) (hc i)).1 + choose e he hev using (fun i => value_surjective Y (v i) (hb i)) + obtain ⟨t,ht⟩ := tuple_surjective e + have hv' : (fun i : Fin n => value Y (entry i.val t)) = v := by + funext i + rw [ht i, hev i] + exact ⟨t, ⟨fun i => (ht i) ▸ he i, hv' ▸ hv⟩, fun i => congrFun hv' i⟩ + · rintro ⟨t,⟨_,ht⟩,hv⟩ + exact (funext hv) ▸ ht + +theorem sigma5_normal_form {Y P} (h : Sigma Y 5 P) : + ∃ M : ℕ → Prop, RecursivePred Y M ∧ ∀ x, + P x ↔ ∃ a, ∀ b, ∃ c, ∀ d, ∃ e, + M (Nat.pair (Nat.pair (Nat.pair (Nat.pair (Nat.pair x a) b) c) d) e) := by + obtain ⟨A,hA,eA⟩ := h + obtain ⟨B,hB,eB⟩ := hA + obtain ⟨C,hC,eC⟩ := hB + obtain ⟨D,hD,eD⟩ := hC + obtain ⟨M,hM,eM⟩ := hD + refine ⟨M,hM,fun x => ?_⟩ + simp only [eA, eB, eC, eD, eM, Quant, Bool.not_true, Bool.not_false, Bool.false_eq_true, ↓reduceIte] + +theorem decoding_theorem {n} (Y : Oracle) (R : Set (Fin n → Degree)) (p : RelationCode n) + (hp : RelationBelow p (degree Y)) (hcode : ∀ v, p.Holds v ↔ v ∈ R) : + ∃ P : ℕ → Prop, Sigma Y 5 P ∧ RecursivePred (iterate Y 5) P ∧ + ∀ v, v ∈ R ↔ ∃ t, P t ∧ ∀ i, value Y (entry i.val t) = v i := by + have h := sigma5_decoding Y p hp + refine ⟨Presented Y p, h, form_recursive h, fun v => ?_⟩ + exact (hcode v).symm.trans (presentation_exact Y p hp v) + +end TuringRigidity.DecodingTheorem + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/DegreeSetFormula.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/DegreeSetFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..345f097e443e08a0e4ec5eb7126cb398f6de47d1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/DegreeSetFormula.lean @@ -0,0 +1,45 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelDegreeCodes + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +universe u + +def DegreeEqualityFormula (φ : Formula) : Prop := ∀ o Q z x y : ℕ, ∀ e : ℕ → ZFSet.{u}, + e o = ZFSet.omega → (∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) → + e z = natSet 0 → ∀ A B : Oracle, e x = realCode A → e y = realCode B → + ((Formula.twoOracles φ o Q z x y).Eval e ↔ degree A = degree B) + +namespace Formula +def degreeSet (φ : Formula) (o Q z R A D : ℕ) : Formula := + .conj (.subset D R) (allMem R (iff (.member 0 (D+1)) (twoOracles φ (o+1) (Q+1) (z+1) 0 (A+1)))) + +theorem degreeSet_spec {φ : Formula} (hφ : DegreeEqualityFormula.{u} φ) + (o Q z R x D : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) (hz : e z = natSet 0) + (hR : ∀ w ∈ e R, ∃ B : Oracle, realCode B = w) + (A : Oracle) (hA : e x = realCode A) : + (degreeSet φ o Q z R x D).Eval e ↔ e D = degreeCode (e R) A := by + simp only [degreeSet,Formula.Eval,eval_subset,eval_allMem,eval_iff,cons_zero,cons_succ] + constructor + · rintro ⟨hsub,h⟩ + apply ZFSet.ext; intro w + by_cases hw : w ∈ e R + · obtain ⟨B,rfl⟩ := hR w hw + rw [realCode_mem_degreeCode] + have hh := (h _ hw).trans (hφ (o+1) (Q+1) (z+1) 0 (x+1) (cons (realCode B) e) + ho hQ hz B A rfl hA) + exact hh.trans (and_iff_right hw).symm + · exact ⟨fun h => False.elim (hw (hsub h)),fun h => False.elim (hw (degreeCode_subset _ _ h))⟩ + · intro hd + refine ⟨hd.symm ▸ degreeCode_subset (e R) A,?_⟩ + intro w hw + obtain ⟨B,rfl⟩ := hR w hw + rw [hd,realCode_mem_degreeCode,and_iff_right hw] + exact (hφ (o+1) (Q+1) (z+1) 0 (x+1) (cons (realCode B) e) ho hQ hz B A rfl hA).symm +end Formula + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/DegreeUniverseWithoutChoice.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/DegreeUniverseWithoutChoice.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0812585cb16d10750cf8feb64e304f114269fbc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/DegreeUniverseWithoutChoice.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelDegreeUniverse + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +theorem internal_degreeCode_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hω : ZFSet.omega.{u} ∈ M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ x ∈ R, ∃ B : Oracle, realCode B = x) + {A : Oracle} (hA : A ∈ modelReals M) : degreeCode R A ∈ M := by + have hz : natSet.{u} 0 ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨0,rfl⟩) + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hP hU hPow hS hω + obtain ⟨φ,hφ⟩ := degree_equality_bounded.{u} + let e := cons ZFSet.omega (cons Q (cons (natSet 0) (fun _ => realCode A))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hQM + rcases i with _|i; exact hz + exact hA + let D := ZFSet.sep (fun x => (Formula.twoOracles φ 1 2 3 0 4).Eval (cons x e)) R + have hD : D ∈ M := sep_mem M hM hS _ e he hRM + have hcode : degreeCode R A = D := by + apply ZFSet.ext; intro x + by_cases hx : x ∈ R + · obtain ⟨B,rfl⟩ := hR x hx + rw [realCode_mem_degreeCode,ZFSet.mem_sep] + rw [hφ 1 2 3 0 4 (cons (realCode B) e) rfl hQ rfl B A rfl rfl] + · simp only [degreeCode,D,ZFSet.mem_sep,hx,false_and] + rw [hcode] + exact hD + +theorem internal_degreeUniverse_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hω : ZFSet.omega.{u} ∈ M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ w ∈ R, ∃ B : Oracle, realCode B = w) : degreeUniverse R ∈ M := by + have hz : natSet.{u} 0 ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨0,rfl⟩) + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hP hU hPow hS hω + obtain ⟨P,hPM,hPdef⟩ := internal_power M hM hPow hRM + obtain ⟨φ,hφ⟩ := degree_equality_bounded.{u} + have hsub : degreeUniverse R ⊆ P := by + intro D hD + obtain ⟨A,hA,rfl⟩ := (mem_degreeUniverse R D).mp hD + exact (hPdef _).mpr ⟨internal_degreeCode_without_choice M hM hP hU hPow hS hω R hRM hR (hM _ hRM _ hA), + degreeCode_subset R A⟩ + let e := cons ZFSet.omega (cons Q (cons (natSet 0) (fun _ => R))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hQM + rcases i with _|i; exact hz + exact hRM + have hs := sep_mem M hM hS (Formula.degreeUniverseMember φ 1 2 3 4 0) e he hPM + have heq : ZFSet.sep (fun D => (Formula.degreeUniverseMember φ 1 2 3 4 0).Eval (cons D e)) P = + degreeUniverse R := by + apply ZFSet.ext; intro D + rw [ZFSet.mem_sep,Formula.degreeUniverseMember_spec hφ 1 2 3 4 0 (cons D e) rfl hQ rfl hR] + exact ⟨And.right,fun h => ⟨hsub h,h⟩⟩ + exact heq ▸ hs + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/Degrees.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/Degrees.lean new file mode 100644 index 0000000000000000000000000000000000000000..777fb0cc033a306ac9f4ca4c466ce7e77d376b47 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/Degrees.lean @@ -0,0 +1,35 @@ +import OAI.Computability.DegreeRigidity.Model +import Mathlib.Computability.TuringDegree +import Mathlib.Order.Hom.Basic + +namespace OAI + +namespace TuringRigidity + +theorem reduces_refl (A : Oracle) : Reduces A A := TuringReducible.refl _ +theorem reduces_trans {A B C : Oracle} (h : Reduces A B) (k : Reduces B C) : + Reduces A C := TuringReducible.trans h k + +def degree (A : Oracle) : Degree := toAntisymmetrization Reduces A + +@[simp] theorem degree_le_iff (A B : Oracle) : degree A ≤ degree B ↔ Reduces A B := Iff.rfl + +theorem degree_eq_iff (A B : Oracle) : + degree A = degree B ↔ Reduces A B ∧ Reduces B A := by + exact Quotient.eq + +theorem degree_surjective : Function.Surjective degree := by + intro a + exact ⟨ofAntisymmetrization Reduces a, toAntisymmetrization_ofAntisymmetrization _ a⟩ + +theorem order_rigidity_of_inverse_le {α : Type*} [PartialOrder α] + (h : ∀ π : α ≃o α, ∀ a, π.symm a ≤ a) : + ∀ π : α ≃o α, ∀ a, π a = a := by + intro π a + apply le_antisymm + · simpa using h π.symm a + · simpa using π.monotone (h π a) + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/DenseInclusionExtension.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/DenseInclusionExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..1dd06e29a0306bcb3db72dfdbdc15c22cffa7b6e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/DenseInclusionExtension.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalDenseInclusion + +namespace OAI + +namespace TuringRigidity.DenseInclusionExtension +open TransitiveNameModel BoundedSetTheory CountableForcing InternalDenseInclusion +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +noncomputable def upperSet (b g : ZFSet.{0}) : ZFSet.{0} := + b.sep (fun q => ∃ p ∈ g, q ⊆ p) + +noncomputable def restrictSet (a k : ZFSet.{0}) : ZFSet.{0} := a.sep (fun p => p ∈ k) + +theorem upperSet_mem (N b g : ZFSet.{0}) (hN : Transitive N) (hT : SourceT N) + (hb : b ∈ N) (hg : g ∈ N) : upperSet b g ∈ N := by + let e := fun _ : ℕ => g + simpa only [upperSet,Formula.Eval,Formula.eval_subset,cons_zero,cons_succ,e] using + sep_mem N hN hT.separation.finitePrefix.bounded + (.existsMem 1 (.subset 1 0)) e (fun _ => hg) hb + +theorem restrictSet_mem (N a k : ZFSet.{0}) (hN : Transitive N) (hT : SourceT N) + (ha : a ∈ N) (hk : k ∈ N) : restrictSet a k ∈ N := by + let e := fun _ : ℕ => k + simpa only [restrictSet,Formula.Eval,cons_zero,cons_succ,e] using + sep_mem N hN hT.separation.finitePrefix.bounded (.member 0 1) e (fun _ => hk) ha + +theorem pushFilterSet_eq (a b : ZFSet.{0}) (hab : a ⊆ b) (G : GenericFilter (Conditions a)) : + genericFilterSet b (push a b hab G).carrier = upperSet b (genericFilterSet a G.carrier) := by + apply ZFSet.ext; intro x + constructor + · intro hx + obtain ⟨q,⟨p,hp,hpq⟩,rfl⟩ := (mem_genericFilterSet _ _ x).mp hx + refine ZFSet.mem_sep.mpr ⟨label_mem b q,label a p, + (mem_genericFilterSet _ _ _).mpr ⟨p,hp,rfl⟩,?_⟩ + change label b q ⊆ label b (embed a b hab p) at hpq + rwa [label_embed] at hpq + · intro hx + obtain ⟨hxb,p,hpg,hxp⟩ := ZFSet.mem_sep.mp hx + obtain ⟨q,rfl⟩ := label_surjective b hxb + obtain ⟨p,hp,rfl⟩ := (mem_genericFilterSet _ _ p).mp hpg + exact (mem_genericFilterSet _ _ _).mpr ⟨q,⟨p,hp,by + change label b q ⊆ label b (embed a b hab p); rwa [label_embed]⟩,rfl⟩ + +theorem originalFilterSet_eq (a b : ZFSet.{0}) (hab : a ⊆ b) (G : GenericFilter (Conditions a)) : + genericFilterSet a G.carrier = restrictSet a (genericFilterSet b (push a b hab G).carrier) := by + apply ZFSet.ext; intro x + constructor + · intro hx + obtain ⟨p,hp,rfl⟩ := (mem_genericFilterSet _ _ x).mp hx + exact ZFSet.mem_sep.mpr ⟨label_mem a p,(mem_genericFilterSet _ _ _).mpr + ⟨embed a b hab p,(embed_mem_push a b hab G p).mpr hp,label_embed a b hab p⟩⟩ + · intro hx + obtain ⟨hxa,hxk⟩ := ZFSet.mem_sep.mp hx + obtain ⟨p,rfl⟩ := label_surjective a hxa + obtain ⟨q,hq,hqe⟩ := (mem_genericFilterSet _ _ _).mp hxk + have he : q = embed a b hab p := label_injective b (hqe.trans (label_embed a b hab p).symm) + exact (mem_genericFilterSet _ _ _).mpr ⟨p,(embed_mem_push a b hab G p).mp (he ▸ hq),rfl⟩ + +theorem extension_eq (M a b : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) (hb : b ∈ M) (hab : a ⊆ b) + (hd : ∀ q ∈ b, ∃ p ∈ a, q ⊆ p) + (G : GenericFilter (Conditions a)) (hG : AtomicForcing.GroundGeneric M G) : + genericExtensionSet M b (push a b hab G).carrier = genericExtensionSet M a G.carrier := by + let K := push a b hab G + have hK := push_ground_generic M a b hM hT ha hb hab hd G hG + obtain ⟨hN,hTN,hMN,hgN⟩ := RegularTreeExtension.extension_properties M a hM hT ha G hG + obtain ⟨hV,hTV,hMV,hkV⟩ := RegularTreeExtension.extension_properties M b hM hT hb K hK + have hkN : genericFilterSet b K.carrier ∈ genericExtensionSet M a G.carrier := by + rw [pushFilterSet_eq] + exact upperSet_mem _ b _ hN hTN (hMN hb) hgN + have hgV : genericFilterSet a G.carrier ∈ genericExtensionSet M b K.carrier := by + rw [originalFilterSet_eq a b hab G] + exact restrictSet_mem _ a _ hV hTV (hMV ha) hkV + apply ZFSet.ext; intro x + exact ⟨fun hx => InternalNameEvaluation.extension_subset M _ hN hTN hMN K.carrier hkN hx, + fun hx => InternalNameEvaluation.extension_subset M _ hV hTV hMV G.carrier hgV hx⟩ + +end TuringRigidity.DenseInclusionExtension + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryAxioms.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryAxioms.lean new file mode 100644 index 0000000000000000000000000000000000000000..59c54ac12eef299aa78bd399630f584e301e97b9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryAxioms.lean @@ -0,0 +1,104 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementarySatisfaction + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel SentenceForm +universe u + +theorem Valid.pairing {M : ZFSet.{u}} (hv : Valid M) : Pairing M := by + intro a ha b hb + let p := ex (all (iff (.member 0 1) (disj (.equal 0 2) (.equal 0 3)))) + have hp : ∀ e : ℕ → ZFSet.{u}, p.Sat Set.univ e := by + intro e + simp only [p,Sat,sat_all,sat_iff,sat_disj,cons_zero,cons_succ,Set.mem_univ,true_and,forall_const] + exact ⟨{e 0,e 1},fun x => ZFSet.mem_pair⟩ + have h := hv p hp (cons a (fun _ => b)) (by intro i; cases i <;> assumption) + simpa only [p,Sat,sat_all,sat_iff,sat_disj,cons_zero,cons_succ,SetLike.mem_coe] using h + +theorem Valid.union {M : ZFSet.{u}} (hv : Valid M) : BoundedSetTheory.Union M := by + intro a ha + let p := ex (all (iff (.member 0 1) (ex (.conj (.member 0 3) (.member 1 0))))) + have hp : ∀ e : ℕ → ZFSet.{u}, p.Sat Set.univ e := by + intro e + simp only [p,Sat,sat_all,sat_iff,cons_zero,cons_succ,Set.mem_univ,true_and,forall_const] + exact ⟨ZFSet.sUnion (e 0),fun x => ZFSet.mem_sUnion⟩ + have h := hv p hp (fun _ => a) (fun _ => ha) + simpa only [p,Sat,sat_all,sat_iff,cons_zero,cons_succ,SetLike.mem_coe] using h + +theorem Valid.powerSet {M : ZFSet.{u}} (hv : Valid M) : PowerSet M := by + intro a ha + let p := ex (all (iff (.member 0 1) (all (imp (.member 0 1) (.member 0 3))))) + have hp : ∀ e : ℕ → ZFSet.{u}, p.Sat Set.univ e := by + intro e + simp only [p,Sat,sat_all,sat_iff,sat_imp,cons_zero,cons_succ,Set.mem_univ,true_and,forall_const] + exact ⟨ZFSet.powerset (e 0),fun x => ZFSet.mem_powerset⟩ + have h := hv p hp (fun _ => a) (fun _ => ha) + simpa only [p,Sat,sat_all,sat_iff,sat_imp,cons_zero,cons_succ,SetLike.mem_coe] using h + +theorem Valid.empty {M : ZFSet.{u}} (hv : Valid M) (hne : ∃ a, a ∈ M) : BasicAxioms.EmptySet M := by + obtain ⟨a,ha⟩ := hne + let p := ex (all (.neg (.member 0 1))) + have hp : ∀ e : ℕ → ZFSet.{u}, p.Sat Set.univ e := by + intro e + simp only [p,Sat,sat_all,cons_zero,cons_succ,Set.mem_univ,true_and,forall_const] + exact ⟨∅,ZFSet.notMem_empty⟩ + have h := hv p hp (fun _ => a) (fun _ => ha) + simpa only [BasicAxioms.EmptySet,p,Sat,sat_all,cons_zero,cons_succ,SetLike.mem_coe] using h + +theorem Valid.infinity {M : ZFSet.{u}} (hv : Valid M) (hne : ∃ a, a ∈ M) : Infinity M := by + obtain ⟨a,ha⟩ := hne + let p := ex (.conj (ex (.conj (.member 0 1) (all (.neg (.member 0 1))))) + (all (imp (.member 0 1) (ex (.conj (.member 0 2) + (all (iff (.member 0 1) (disj (.equal 0 2) (.member 0 2))))))))) + have hp : ∀ e : ℕ → ZFSet.{u}, p.Sat Set.univ e := by + intro e + simp only [p,Sat,sat_all,sat_iff,sat_imp,sat_disj,cons_zero,cons_succ,Set.mem_univ,true_and,forall_const] + refine ⟨ZFSet.omega,⟨∅,ZFSet.omega_zero,ZFSet.notMem_empty⟩,?_⟩ + intro x hx + exact ⟨insert x x,ZFSet.omega_succ hx,fun z => ZFSet.mem_insert_iff⟩ + have h := hv p hp (fun _ => a) (fun _ => ha) + simpa only [Infinity,p,Sat,sat_all,sat_iff,sat_imp,sat_disj,cons_zero,cons_succ,SetLike.mem_coe] using h + +theorem ambient_choice_graph (a : ZFSet.{u}) (hn : ∀ x ∈ a, ∃ y, y ∈ x) : + ∃ f : ZFSet.{u}, ChoiceGraph a f := by + classical + let pick (x : Conditions a) := Classical.choose (hn (label a x) (label_mem a x)) + have hp (x : Conditions a) : pick x ∈ label a x := Classical.choose_spec (hn _ (label_mem a x)) + let f := ZFSet.range (fun x : Conditions a => ZFSet.pair (label a x) (pick x)) + refine ⟨f,?_,?_⟩ + · intro z hz + obtain ⟨x,rfl⟩ := ZFSet.mem_range.mp hz + exact ⟨_,label_mem _ x,_,hp x,rfl⟩ + · intro x hx + obtain ⟨i,rfl⟩ := label_surjective a hx + refine ⟨pick i,hp i,ZFSet.mem_range_self i,?_⟩ + intro z _ hz + obtain ⟨j,hj⟩ := ZFSet.mem_range.mp hz + obtain ⟨he,hz⟩ := ZFSet.pair_inj.mp hj + have hj : j = i := label_injective a he + exact hz.symm.trans (congrArg pick hj) + +theorem Valid.choice {M : ZFSet.{u}} (hv : Valid M) (hM : Transitive M) : Choice M := by + intro a ha hn + let p := imp (all (imp (.member 0 1) (ex (.member 0 1)))) + (ex (fromBounded (ChoiceCode.graph 1 0))) + have hp : ∀ e : ℕ → ZFSet.{u}, p.Sat Set.univ e := by + intro e + simp only [p,sat_imp,sat_all,Sat,bounded_univ,ChoiceCode.eval_graph, + cons_zero,cons_succ,Set.mem_univ,true_and,forall_const] + exact ambient_choice_graph (e 0) + have h := hv p hp (fun _ => a) (fun _ => ha) + simp only [p,sat_imp,sat_all,Sat,bounded_sat,cons_zero,cons_succ] at h + obtain ⟨f,hf,hfg⟩ := h (fun x hx hxa => by + obtain ⟨y,hy⟩ := hn x hxa + exact ⟨y,hM x hx y hy,hy⟩) + refine ⟨f,hf,?_⟩ + have hb := (Formula.absolute (ChoiceCode.graph 1 0) M hM (cons f (fun _ => a)) + (by intro i; cases i <;> assumption)).mp hfg + exact (ChoiceCode.eval_graph 1 0 _).mp hb + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryCheckedCode.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryCheckedCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..072824127c5baad2249c4e8e60d7a725fbdb30e5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryCheckedCode.lean @@ -0,0 +1,105 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementaryCollapsePoset +import OAI.Computability.DegreeRigidity.Syntax.CheckGraphConstruction + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel RelationCollapse SentenceForm +universe u + +theorem ambient_transitive_container (x : ZFSet.{u}) : + ∃ d : ZFSet.{u}, TransitiveNameModel.Transitive d ∧ x ∈ d := by + let b := ZFSet.range (fun n : ℕ => iterUnion n x) + let d := ({x} : ZFSet.{u}) ∪ ZFSet.sUnion b + refine ⟨d,?_,ZFSet.mem_union.mpr (Or.inl (ZFSet.mem_singleton.mpr rfl))⟩ + intro y hy z hz + apply ZFSet.mem_union.mpr + apply Or.inr + rcases ZFSet.mem_union.mp hy with hy|hy + · have hyx : y = x := ZFSet.mem_singleton.mp hy + subst y + exact ZFSet.mem_sUnion.mpr ⟨x,ZFSet.mem_range.mpr ⟨0,rfl⟩,hz⟩ + · obtain ⟨c,hc,hyc⟩ := ZFSet.mem_sUnion.mp hy + obtain ⟨n,rfl⟩ := ZFSet.mem_range.mp hc + exact ZFSet.mem_sUnion.mpr ⟨iterUnion (n+1) x,ZFSet.mem_range.mpr ⟨n+1,rfl⟩, + ZFSet.mem_sUnion.mpr ⟨y,hyc,hz⟩⟩ + +theorem ambient_checkGraph (d t : ZFSet.{u}) (hd : Transitive d) : + ∃ r f, CheckGraph d r f t := by + let f := ZFSet.range (fun i : Conditions d => ZFSet.pair (label d i) (checkedCode t (label d i))) + refine ⟨iterUnion 2 f,f,checkGraph_of_mem_iff d f t hd ?_⟩ + intro z + rw [ZFSet.mem_range] + constructor + · rintro ⟨i,hi⟩ + exact ⟨label d i,label_mem d i,hi.symm⟩ + · rintro ⟨x,hx,hz⟩ + obtain ⟨i,rfl⟩ := label_surjective d hx + exact ⟨i,hz.symm⟩ + +noncomputable def checkedValueFormula : SentenceForm := + .ex (.ex (.ex (fromBounded (.conj (CheckFormula.graph 2 1 0 5) + (.conj (.member 4 2) (.conj (.member 3 1) (.pairMem 4 3 0))))))) + +theorem checkedValue_univ (v x t : ZFSet.{u}) : + checkedValueFormula.Sat Set.univ (cons v (cons x (fun _ => t))) ↔ v = checkedCode t x := by + simp only [checkedValueFormula,Sat,bounded_univ,Formula.Eval,CheckFormula.eval_graph, + Formula.eval_pairMem,cons_zero,cons_succ,Set.mem_univ,true_and] + constructor + · rintro ⟨d,r,f,hg,hx,hv,hf⟩ + exact hg.correct x hx v hv hf + · intro hv + obtain ⟨d,hd,hx⟩ := ambient_transitive_container x + obtain ⟨r,f,hg⟩ := ambient_checkGraph d t hd + obtain ⟨w,hw,hf,_⟩ := hg.2.2.1 x hx + have he : w = v := (hg.correct x hx w hw hf).trans hv.symm + exact ⟨d,r,f,hg,hx,he ▸ hw,he ▸ hf⟩ + +theorem checkedValue_sound (M : ZFSet.{u}) (hM : Transitive M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (h : checkedValueFormula.Sat (M : Set ZFSet) e) : e 0 = checkedCode (e 2) (e 1) := by + obtain ⟨d,hd,r,hr,f,hf,h⟩ := h + have hi : ∀ i, cons f (cons r (cons d e)) i ∈ M := by + intro i; rcases i with _|_|_|i + exact hf + exact hr + exact hd + exact he i + rw [bounded_sat,Formula.absolute _ M hM _ hi] at h + simp only [Formula.Eval,CheckFormula.eval_graph,Formula.eval_pairMem,cons_zero,cons_succ] at h + exact h.1.correct (e 1) h.2.1 (e 0) h.2.2.1 h.2.2.2 + +theorem checkedCode_mem_hull (a : ℕ → ZFSet.{u}) {t x : ZFSet.{u}} + (ht : t ∈ hullSet a) (hx : x ∈ hullSet a) : checkedCode t x ∈ hullSet a := by + exact unique_definable_mem a checkedValueFormula (cons x (fun _ => t)) + (by intro i; cases i <;> assumption) _ ((checkedValue_univ _ x t).mpr rfl) + (fun v hv => (checkedValue_univ v x t).mp hv) + +theorem collapse_checkedCode (a : ℕ → ZFSet.{u}) {t x : ZFSet.{u}} + (ht : t ∈ hullSet a) (hx : x ∈ hullSet a) : + structureMap (hullSet a) (checkedCode t x) = + checkedCode (structureMap (hullSet a) t) (structureMap (hullSet a) x) := by + let e := cons (checkedCode t x) (cons x (fun _ => t)) + have he : ∀ i, e i ∈ hullSet a := by + intro i; rcases i with _|_|i + exact checkedCode_mem_hull a ht hx + exact hx + exact ht + have hs := (collapsed_hull_elementary a checkedValueFormula e he).mpr + ((checkedValue_univ _ x t).mpr rfl) + exact checkedValue_sound _ (collapsed_transitive _) _ + (fun i => (mem_collapsed _ _).mpr ⟨e i,he i,rfl⟩) hs + +theorem collapse_encoded_check (a : ℕ → ZFSet.{u}) + {c c' : ZFSet.{u}} [Top (Conditions c)] [Top (Conditions c')] + (ht : label c ⊤ ∈ hullSet a) + (ht' : structureMap (hullSet a) (label c ⊤) = label c' ⊤) + {x : ZFSet.{u}} (hx : x ∈ hullSet a) : + structureMap (hullSet a) ((RecursiveNames.Name.check x).encode (label c)) = + (RecursiveNames.Name.check (structureMap (hullSet a) x)).encode (label c') := by + rw [encode_check,encode_check,collapse_checkedCode a ht hx,ht'] + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryCollapse.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryCollapse.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac0f52dbf7cca2a6e72d0a929996cbac3eceb3a3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryCollapse.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.SetModels.CountableElementaryHull +import OAI.Computability.DegreeRigidity.SetModels.InternalStructureCollapse +import OAI.Computability.DegreeRigidity.SetModels.ModelReals + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel RelationCollapse +universe u + +noncomputable def hullSet (a : ℕ → ZFSet.{u}) : ZFSet.{u} := by + letI : Countable (hull a) := (hull_countable a).to_subtype + letI : Small.{u} (hull a) := Countable.toSmall _ + exact ZFSet.range (fun x : hull a => x.val) + +theorem mem_hullSet (a : ℕ → ZFSet.{u}) (x : ZFSet.{u}) : x ∈ hullSet a ↔ x ∈ hull a := by + classical + simp only [hullSet,ZFSet.mem_range] + exact ⟨fun ⟨y,hy⟩ => hy ▸ y.property,fun hx => ⟨⟨x,hx⟩,rfl⟩⟩ + +instance hullSet_countable (a : ℕ → ZFSet.{u}) : Countable (Conditions (hullSet a)) := by + let : Countable (hull a) := (hull_countable a).to_subtype + exact Function.Injective.countable (f := fun x : Conditions (hullSet a) => + (⟨label _ x,(mem_hullSet a _).mp (label_mem _ x)⟩ : hull a)) + (fun x y h => label_injective (hullSet a) (congrArg (fun z : hull a => z.val) h)) + +theorem hullSet_extensional (a : ℕ → ZFSet.{u}) : StructureExtensional (hullSet a) := by + intro x hx y hy he + let e := cons x (fun _ => y) + have hen : ∀ i, e i ∈ hull a := by + intro i; cases i <;> simp only [e,cons_zero,cons_succ] + · exact (mem_hullSet a x).mp hx + · exact (mem_hullSet a y).mp hy + let p := SentenceForm.all (SentenceForm.iff (.member 0 1) (.member 0 2)) + have hs : p.Sat (hull a) e := by + simp only [p,SentenceForm.sat_all,SentenceForm.sat_iff,SentenceForm.Sat, + cons_zero,cons_succ,e] + exact fun z hz => he z ((mem_hullSet a z).mpr hz) + have ht := (hull_elementary a p e hen).mp hs + simp only [p,SentenceForm.sat_all,SentenceForm.sat_iff,SentenceForm.Sat, + cons_zero,cons_succ,e,Set.mem_univ,forall_const] at ht + exact ZFSet.ext ht + +noncomputable def collapsed (d : ZFSet.{u}) : ZFSet.{u} := + ZFSet.range (fun x : Conditions d => structureMap d (label d x)) + +theorem mem_collapsed (d z : ZFSet.{u}) : + z ∈ collapsed d ↔ ∃ x ∈ d, z = structureMap d x := by + rw [collapsed,ZFSet.mem_range] + constructor + · rintro ⟨x,rfl⟩; exact ⟨_,label_mem _ x,rfl⟩ + · rintro ⟨x,hx,rfl⟩ + obtain ⟨i,rfl⟩ := label_surjective d hx + exact ⟨i,rfl⟩ + +theorem collapsed_transitive (d : ZFSet.{u}) : Transitive (collapsed d) := by + intro x hx y hy + obtain ⟨z,_,rfl⟩ := (mem_collapsed d x).mp hx + obtain ⟨w,hw,_,rfl⟩ := (mem_value d (membershipRelation d) _ z y).mp hy + exact (mem_collapsed d _).mpr ⟨w,hw,rfl⟩ + +instance collapsed_countable (d : ZFSet.{u}) [Countable (Conditions d)] : + Countable (Conditions (collapsed d)) := by + let f : Conditions (collapsed d) → Conditions d := fun z => Classical.choose + (ZFSet.mem_range.mp (show label (collapsed d) z ∈ collapsed d from label_mem _ z)) + have hf (z : Conditions (collapsed d)) : structureMap d (label d (f z)) = label _ z := + Classical.choose_spec (ZFSet.mem_range.mp (label_mem _ z)) + exact Function.Injective.countable (f := f) (fun x y h => + label_injective _ ((hf x).symm.trans ((congrArg (fun z => structureMap d (label d z)) h).trans (hf y)))) + +theorem collapse_injective (d : ZFSet.{u}) (he : StructureExtensional d) + (x : ZFSet.{u}) (hx : x ∈ d) (y : ZFSet.{u}) (hy : y ∈ d) + (h : structureMap d x = structureMap d y) : x = y := + value_injective (membershipRelation_wellFounded d) (membershipRelation_extensional he) x hx y hy h + +theorem collapse_membership (d : ZFSet.{u}) (he : StructureExtensional d) + (x : ZFSet.{u}) (hx : x ∈ d) (y : ZFSet.{u}) (hy : y ∈ d) : + structureMap d x ∈ structureMap d y ↔ x ∈ y := by + rw [structureMap,value_mem_iff (membershipRelation_wellFounded d) + (membershipRelation_extensional he) hx,membershipRelation_pair] + simp only [hx,hy,true_and] + +theorem collapse_fixed (d x : ZFSet.{u}) (hx : x ∈ d) + (h : ∀ y ∈ x, y ∈ d ∧ structureMap d y = y) : structureMap d x = x := by + apply ZFSet.ext; intro y + rw [structureMap,mem_value] + constructor + · rintro ⟨z,_,hz,hy⟩ + have hzx := ((membershipRelation_pair d z x).mp hz).2.2 + change y = structureMap d z at hy + rw [(h z hzx).2] at hy + exact hy ▸ hzx + · intro hy + refine ⟨y,(h y hy).1,(membershipRelation_pair d y x).mpr ⟨(h y hy).1,hx,hy⟩,?_⟩ + exact (h y hy).2.symm + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryCollapsePoset.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryCollapsePoset.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8af5e08aed2a31c95aad0d8a48b447d560c0dc3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryCollapsePoset.lean @@ -0,0 +1,129 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementaryDefinableSets +import OAI.Computability.DegreeRigidity.Representation.AmbientDegreeSyntax +import OAI.Computability.DegreeRigidity.SetModels.InternalCollapseConditions + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel RelationCollapse SentenceForm +open FullSetForcing InternalCollapse +universe u + +theorem definedSet_univ (s : ℕ) (p : Formula) (e : ℕ → ZFSet.{u}) : + (definedSet s p).Sat Set.univ e ↔ ∀ x, x ∈ e s ↔ p.Eval (cons x e) := by + simp only [definedSet,sat_all,sat_iff,Sat,bounded_univ,cons_zero,cons_succ, + Set.mem_univ,forall_const] + +theorem collapse_bounded_eval (a : ℕ → ZFSet.{u}) (p : Formula) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ hullSet a) : + p.Eval (fun i => structureMap (hullSet a) (e i)) ↔ p.Eval e := by + have h := collapsed_hull_elementary a (fromBounded p) e he + rw [bounded_sat,Formula.absolute _ _ (collapsed_transitive _) _ + (fun i => (mem_collapsed _ _).mpr ⟨e i,he i,rfl⟩),bounded_univ] at h + exact h + +noncomputable def ambientConditions (A : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (Prefix A) (ZFSet.powerset (ZFSet.prod ZFSet.omega A)) + +theorem mem_ambientConditions (A p : ZFSet.{u}) : p ∈ ambientConditions A ↔ Prefix A p := by + rw [ambientConditions,ZFSet.mem_sep] + exact ⟨And.right,fun h => ⟨ZFSet.mem_powerset.mpr (prefix_subset h),h⟩⟩ + +theorem ambientConditions_def (A c : ZFSet.{u}) : + (definedSet 0 (prefixFormula 3 2 0)).Sat Set.univ + (cons c (cons A (fun _ => ZFSet.omega))) ↔ c = ambientConditions A := by + rw [definedSet_univ] + have hs (p : ZFSet.{u}) := eval_prefixFormula 3 2 0 + (cons p (cons c (cons A (fun _ => ZFSet.omega)))) rfl + simp only [hs,cons_zero,cons_succ] + exact ⟨fun h => ZFSet.ext (fun p => (h p).trans (mem_ambientConditions A p).symm), + fun h p => h ▸ mem_ambientConditions A p⟩ + +theorem ambientConditions_mem_hull (a : ℕ → ZFSet.{u}) + (hω : ZFSet.omega ∈ hullSet a) {A : ZFSet.{u}} (hA : A ∈ hullSet a) : + ambientConditions A ∈ hullSet a := by + exact unique_definable_mem a (definedSet 0 (prefixFormula 3 2 0)) + (cons A (fun _ => ZFSet.omega)) (by intro i; cases i <;> assumption) + _ ((ambientConditions_def A _).mpr rfl) (fun c hc => (ambientConditions_def A c).mp hc) + +theorem collapse_ambientConditions (a : ℕ → ZFSet.{u}) + (hn : ∀ n, natSet.{u} n ∈ hullSet a) (hω : ZFSet.omega ∈ hullSet a) + {A : ZFSet.{u}} (hA : A ∈ hullSet a) : + ∀ p, p ∈ structureMap (hullSet a) (ambientConditions A) ↔ + p ∈ collapsed (hullSet a) ∧ Prefix (structureMap (hullSet a) A) p := by + let e := cons (ambientConditions A) (cons A (fun _ => ZFSet.omega)) + have hc := ambientConditions_mem_hull a hω hA + have he : ∀ i, e i ∈ hullSet a := by + intro i; rcases i with _|_|i + exact hc + exact hA + exact hω + have ht := (collapsed_hull_elementary a (definedSet 0 (prefixFormula 3 2 0)) e he).mpr + ((ambientConditions_def A _).mpr rfl) + have hm := collapsed_transitive (hullSet a) + have hei : ∀ i, structureMap (hullSet a) (e i) ∈ collapsed (hullSet a) := + fun i => (mem_collapsed _ _).mpr ⟨e i,he i,rfl⟩ + have h := (definedSet_spec _ hm 0 _ _ hei).mp ht + have hω' := hull_omega_fixed a hn hω + have hs (p : ZFSet.{u}) (hp : p ∈ collapsed (hullSet a)) : + p ∈ structureMap (hullSet a) (ambientConditions A) ↔ + Prefix (structureMap (hullSet a) A) p := + (h p hp).trans (eval_prefixFormula 3 2 0 + (cons p (fun i => structureMap (hullSet a) (e i))) hω') + intro p + exact ⟨fun hp => ⟨hm _ (hei 0) _ hp,(hs p (hm _ (hei 0) _ hp)).mp hp⟩, + fun hp => (hs p hp.1).mpr hp.2⟩ + +def orderMember (c z : ℕ) : Formula := + .existsMem c (.existsMem (c+1) (.conj (.orderedPair (z+2) 1 0) (.subset 0 1))) + +theorem eval_orderMember (c z : ℕ) (e : ℕ → ZFSet.{u}) : + (orderMember c z).Eval e ↔ e z ∈ orderSet (e c) := by + simp only [orderMember,Formula.Eval,Formula.eval_orderedPair,Formula.eval_subset, + cons_zero,cons_succ,orderSet,ZFSet.mem_sep] + exact ⟨fun ⟨p,hp,q,hq,hz,hpq⟩ => + ⟨hz ▸ ZFSet.mem_prod.mpr ⟨p,hp,q,hq,rfl⟩,p,hp,q,hq,hz,hpq⟩,And.right⟩ + +theorem orderSet_mem_hull (a : ℕ → ZFSet.{u}) {c : ZFSet.{u}} (hc : c ∈ hullSet a) : + orderSet c ∈ hullSet a := by + have hs (x : ZFSet.{u}) : (definedSet 0 (orderMember 2 0)).Sat Set.univ + (cons x (fun _ => c)) ↔ x = orderSet c := by + rw [definedSet_univ] + simp only [eval_orderMember,cons_zero,cons_succ] + exact ZFSet.ext_iff.symm + exact unique_definable_mem a (definedSet 0 (orderMember 2 0)) + (fun _ => c) (fun _ => hc) _ ((hs _).mpr rfl) (fun x hx => (hs x).mp hx) + +theorem collapse_orderSet (a : ℕ → ZFSet.{u}) {c : ZFSet.{u}} (hc : c ∈ hullSet a) : + structureMap (hullSet a) (orderSet c) = orderSet (structureMap (hullSet a) c) := by + let e := cons (orderSet c) (fun _ => c) + have he : ∀ i, e i ∈ hullSet a := by + intro i; cases i + exact orderSet_mem_hull a hc + exact hc + have hi : ∀ i, structureMap (hullSet a) (e i) ∈ collapsed (hullSet a) := + fun i => (mem_collapsed _ _).mpr ⟨e i,he i,rfl⟩ + have hs : (definedSet 0 (orderMember 2 0)).Sat Set.univ e := by + rw [definedSet_univ] + intro x + exact (eval_orderMember 2 0 (cons x e)).symm + have ht := (collapsed_hull_elementary a _ e he).mpr hs + exact (definedSet_unique _ (collapsed_transitive _) 0 _ _ hi + (orderSet (structureMap (hullSet a) c)) + (orderSet_mem _ (collapsed_transitive _) (collapsed_hull_sourceT a) (hi 1)) + (fun x _ => eval_orderMember 2 0 _)).mp ht + +theorem collapse_selected_condition (a : ℕ → ZFSet.{u}) + (hn : ∀ n, natSet.{u} n ∈ hullSet a) (hω : ZFSet.omega ∈ hullSet a) + {A p : ZFSet.{u}} (hA : A ∈ hullSet a) (hp : p ∈ hullSet a) + (hpc : p ∈ ambientConditions A) : + structureMap (hullSet a) p ∈ structureMap (hullSet a) (ambientConditions A) ∧ + Prefix (structureMap (hullSet a) A) (structureMap (hullSet a) p) := by + have h := (collapse_membership _ (hullSet_extensional a) _ hp _ + (ambientConditions_mem_hull a hω hA)).mpr hpc + exact ⟨h,((collapse_ambientConditions a hn hω hA _).mp h).2⟩ + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryDefinableSets.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryDefinableSets.lean new file mode 100644 index 0000000000000000000000000000000000000000..18e0ce6cac4075f6306e05e36eaa2aa31826bc76 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryDefinableSets.lean @@ -0,0 +1,104 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementaryRealModel +import OAI.Computability.DegreeRigidity.Representation.NativeModelCompatibility + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel RelationCollapse SentenceForm SetDegreeDecoding +universe u + +theorem unique_definable_mem (a : ℕ → ZFSet.{u}) (p : SentenceForm) (e : ℕ → ZFSet.{u}) + (he : ∀ i, e i ∈ hullSet a) (b : ZFSet.{u}) (hb : p.Sat Set.univ (cons b e)) + (hu : ∀ x, p.Sat Set.univ (cons x e) → x = b) : b ∈ hullSet a := by + have hen : ∀ i, e i ∈ hull a := fun i => (mem_hullSet a _).mp (he i) + have hs := (hull_elementary a (.ex p) e hen).mpr ⟨b,Set.mem_univ _,hb⟩ + obtain ⟨x,hx,hp⟩ := hs + have ht := (hull_elementary a p (cons x e) + (by intro i; cases i <;> simp [cons,hen,hx])).mp hp + exact hu x ht ▸ (mem_hullSet a x).mpr hx + +theorem unorderedPair_mem_hull (a : ℕ → ZFSet.{u}) {x y : ZFSet.{u}} + (hx : x ∈ hullSet a) (hy : y ∈ hullSet a) : ({x,y} : ZFSet.{u}) ∈ hullSet a := by + apply unique_definable_mem a (fromBounded (.unorderedPair 0 1 2)) (cons x (fun _ => y)) + (by intro i; cases i <;> assumption) + · exact (bounded_univ _ _).mpr ((Formula.eval_unorderedPair _ _ _ _).mpr rfl) + · intro z hz + exact (Formula.eval_unorderedPair _ _ _ _).mp ((bounded_univ _ _).mp hz) + +theorem orderedPair_mem_hull (a : ℕ → ZFSet.{u}) {x y : ZFSet.{u}} + (hx : x ∈ hullSet a) (hy : y ∈ hullSet a) : ZFSet.pair x y ∈ hullSet a := by + have hxx := unorderedPair_mem_hull a hx hx + have hxy := unorderedPair_mem_hull a hx hy + simpa [ZFSet.pair] using unorderedPair_mem_hull a hxx hxy + +theorem collapse_unorderedPair (a : ℕ → ZFSet.{u}) {x y : ZFSet.{u}} + (hx : x ∈ hullSet a) (hy : y ∈ hullSet a) : + structureMap (hullSet a) ({x,y} : ZFSet.{u}) = + ({structureMap (hullSet a) x,structureMap (hullSet a) y} : ZFSet.{u}) := by + apply ZFSet.ext; intro z + rw [structureMap,mem_value,ZFSet.mem_pair] + constructor + · rintro ⟨w,_,hw,hzw⟩ + have hwp := ((membershipRelation_pair _ _ _).mp hw).2.2 + rcases ZFSet.mem_pair.mp hwp with rfl|rfl + · exact Or.inl hzw + · exact Or.inr hzw + · intro hz + have hp := unorderedPair_mem_hull a hx hy + rcases hz with hxz|hyz + · exact ⟨x,hx,(membershipRelation_pair _ _ _).mpr ⟨hx,hp,ZFSet.mem_pair.mpr (Or.inl rfl)⟩,hxz⟩ + · exact ⟨y,hy,(membershipRelation_pair _ _ _).mpr ⟨hy,hp,ZFSet.mem_pair.mpr (Or.inr rfl)⟩,hyz⟩ + +theorem collapse_orderedPair (a : ℕ → ZFSet.{u}) {x y : ZFSet.{u}} + (hx : x ∈ hullSet a) (hy : y ∈ hullSet a) : + structureMap (hullSet a) (ZFSet.pair x y) = + ZFSet.pair (structureMap (hullSet a) x) (structureMap (hullSet a) y) := by + have hxx := unorderedPair_mem_hull a hx hx + have hxy := unorderedPair_mem_hull a hx hy + have hh := collapse_unorderedPair a hxx hxy + rw [collapse_unorderedPair a hx hx,collapse_unorderedPair a hx hy] at hh + simpa [ZFSet.pair] using hh + +noncomputable def ambientRealSet : ZFSet.{u} := ZFSet.powerset ZFSet.omega +noncomputable def ambientGraphBound : ZFSet.{u} := ZFSet.powerset (ZFSet.prod ZFSet.omega ZFSet.omega) + +theorem ambient_real_decode (x : ZFSet.{u}) (hx : x ∈ ambientRealSet) : + ∃ B : Oracle, realCode B = x := + ⟨decodeReal x,realCode_decodeReal (ZFSet.mem_powerset.mp hx)⟩ + +theorem ambient_graph_bound (f : ℕ → ℕ) (k : ℕ) : finiteNaturalGraph.{u} f k ∈ ambientGraphBound := by + apply ZFSet.mem_powerset.mpr + intro x hx + obtain ⟨n,_,rfl⟩ := (mem_finiteNaturalGraph f k x).mp hx + exact ZFSet.mem_prod.mpr ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩, + natSet (f n),(mem_omega _).mpr ⟨f n,rfl⟩,rfl⟩ + +theorem ambient_degreeCode (A : Oracle) : degreeCode ambientRealSet.{u} A = degreeSet (degree A) := by + apply ZFSet.ext; intro x + rw [degreeCode,ZFSet.mem_sep,mem_degreeSet] + exact ⟨And.right,fun ⟨B,hB,hBA⟩ => + ⟨hB.symm ▸ ZFSet.mem_powerset.mpr (realCode_subset B),B,hB,hBA⟩⟩ + +theorem degreeSet_mem_hull (a : ℕ → ZFSet.{u}) + (hω : ZFSet.omega ∈ hullSet a) (h0 : natSet 0 ∈ hullSet a) + (hR : ambientRealSet ∈ hullSet a) (hQ : ambientGraphBound ∈ hullSet a) + {A : Oracle} (hA : realCode A ∈ hullSet a) : degreeSet (degree A) ∈ hullSet a := by + obtain ⟨φ,hφ⟩ := degree_equality_bounded.{u} + let e := cons ZFSet.omega (cons ambientGraphBound (cons (natSet 0) (cons ambientRealSet (fun _ => realCode A)))) + have he : ∀ i, e i ∈ hullSet a := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hQ + rcases i with _|i; exact h0 + rcases i with _|i; exact hR + exact hA + let p := fromBounded (Formula.degreeSet φ 1 2 3 4 5 0) + have hp (x : ZFSet.{u}) : p.Sat Set.univ (cons x e) ↔ x = degreeSet (degree A) := by + rw [bounded_univ,Formula.degreeSet_spec hφ 1 2 3 4 5 0 _ rfl ambient_graph_bound rfl ambient_real_decode A rfl] + simp only [cons_zero,cons_succ,e,ambient_degreeCode] + exact unique_definable_mem a p e he _ ((hp _).mpr rfl) (fun x hx => (hp x).mp hx) + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryDegreeHull.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryDegreeHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..528f92524d56338893cfedb124b86ee7d634e4ba --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryDegreeHull.lean @@ -0,0 +1,109 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementaryDefinableSets + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel RelationCollapse SentenceForm SetDegreeDecoding +universe u + +theorem witness_in_hull (a : ℕ → ZFSet.{u}) (p : SentenceForm) (e : ℕ → ZFSet.{u}) + (he : ∀ i, e i ∈ hullSet a) (hex : ∃ x : ZFSet.{u}, p.Sat Set.univ (cons x e)) : + ∃ x ∈ hullSet a, p.Sat Set.univ (cons x e) := by + have hen : ∀ i, e i ∈ hull a := fun i => (mem_hullSet a _).mp (he i) + obtain ⟨x,hx⟩ := hex + have hs := (hull_elementary a (.ex p) e hen).mpr ⟨x,Set.mem_univ _,hx⟩ + obtain ⟨y,hy,hp⟩ := hs + exact ⟨y,(mem_hullSet a _).mpr hy,(hull_elementary a p (cons y e) + (by intro i; cases i <;> simp [cons,hen,hy])).mp hp⟩ + +theorem degree_representative_in_hull (a : ℕ → ZFSet.{u}) (b : Degree) + (hb : degreeSet b ∈ hullSet a) : ∃ A : Oracle, realCode A ∈ hullSet a ∧ degree A = b := by + obtain ⟨B,hB⟩ := degree_surjective b + obtain ⟨x,hx,hxb⟩ := witness_in_hull a (.member 0 1) (fun _ => degreeSet b) (fun _ => hb) + ⟨realCode B,(real_mem_degreeSet B b).mpr hB⟩ + obtain ⟨A,he,hA⟩ := (mem_degreeSet b x).mp hxb + change x = realCode A at he + exact ⟨A,he ▸ hx,hA⟩ + +theorem degreeSet_fixed (a : ℕ → ZFSet.{u}) + (hn : ∀ n, natSet.{u} n ∈ hullSet a) (hω : ZFSet.omega ∈ hullSet a) + (b : Degree) (hb : degreeSet b ∈ hullSet a) : + structureMap (hullSet a) (degreeSet b) = degreeSet b := by + obtain ⟨A,hA,hAb⟩ := degree_representative_in_hull a b hb + have hAM := (collapsed_hull_reals a hn hω A).mpr hA + apply collapse_fixed _ _ hb + intro x hx + obtain ⟨B,rfl,hBb⟩ := (mem_degreeSet b x).mp hx + have hBM := sourceT_real_lower _ (collapsed_transitive _) (collapsed_hull_sourceT a) hAM + (le_of_eq (hBb.trans hAb.symm)) + have hB := (collapsed_hull_reals a hn hω B).mp hBM + exact ⟨hB,hull_real_fixed a hn hB⟩ + +theorem pair_components_mem_hull (a : ℕ → ZFSet.{u}) {x y : ZFSet.{u}} + (hp : ZFSet.pair x y ∈ hullSet a) : x ∈ hullSet a ∧ y ∈ hullSet a := by + constructor + · apply unique_definable_mem a (.ex (fromBounded (.orderedPair 2 1 0))) + (fun _ => ZFSet.pair x y) (fun _ => hp) + · exact ⟨y,Set.mem_univ _,(bounded_univ _ _).mpr ((Formula.eval_orderedPair _ _ _ _).mpr rfl)⟩ + · intro z hz + obtain ⟨w,_,hw⟩ := hz + have he := (Formula.eval_orderedPair _ _ _ _).mp ((bounded_univ _ _).mp hw) + exact (ZFSet.pair_inj.mp he).1.symm + · apply unique_definable_mem a (.ex (fromBounded (.orderedPair 2 0 1))) + (fun _ => ZFSet.pair x y) (fun _ => hp) + · exact ⟨x,Set.mem_univ _,(bounded_univ _ _).mpr ((Formula.eval_orderedPair _ _ _ _).mpr rfl)⟩ + · intro z hz + obtain ⟨w,_,hw⟩ := hz + have he := (Formula.eval_orderedPair _ _ _ _).mp ((bounded_univ _ _).mp hw) + exact (ZFSet.pair_inj.mp he).2.symm + +noncomputable def globalGraph (π : Degree ≃o Degree) : ZFSet.{u} := + ZFSet.range (fun b : Degree => ZFSet.pair (degreeSet b) (degreeSet (π b))) + +theorem mem_globalGraph (π : Degree ≃o Degree) (z : ZFSet.{u}) : + z ∈ globalGraph π ↔ ∃ b : Degree, z = ZFSet.pair (degreeSet b) (degreeSet (π b)) := by + rw [globalGraph,ZFSet.mem_range] + exact ⟨fun ⟨b,hb⟩ => ⟨b,hb.symm⟩,fun ⟨b,hb⟩ => ⟨b,hb.symm⟩⟩ + +theorem globalGraph_pair (π : Degree ≃o Degree) (b : Degree) (x : ZFSet.{u}) : + ZFSet.pair (degreeSet b) x ∈ globalGraph π ↔ x = degreeSet (π b) := by + rw [mem_globalGraph] + constructor + · rintro ⟨c,hc⟩ + obtain ⟨hbc,hx⟩ := ZFSet.pair_inj.mp hc + have hbc := degreeSet_injective hbc + exact hbc.symm ▸ hx + · intro hx; exact ⟨b,congrArg (ZFSet.pair (degreeSet b)) hx⟩ + +theorem globalGraph_inverse_pair (π : Degree ≃o Degree) (b : Degree) (x : ZFSet.{u}) : + ZFSet.pair x (degreeSet b) ∈ globalGraph π ↔ x = degreeSet (π.symm b) := by + rw [mem_globalGraph] + constructor + · rintro ⟨c,hc⟩ + obtain ⟨hx,hbc⟩ := ZFSet.pair_inj.mp hc + have hb := degreeSet_injective hbc + have hc' : c = π.symm b := by rw [hb,π.symm_apply_apply] + exact hx.trans (congrArg degreeSet hc') + · intro hx + refine ⟨π.symm b,?_⟩ + rw [hx,π.apply_symm_apply] + +theorem image_degreeSet_mem_hull (a : ℕ → ZFSet.{u}) (π : Degree ≃o Degree) + (hπ : globalGraph π ∈ hullSet a) (b : Degree) (hb : degreeSet b ∈ hullSet a) : + degreeSet (π b) ∈ hullSet a ∧ degreeSet (π.symm b) ∈ hullSet a := by + have he : ∀ i, cons (degreeSet b) (fun _ => globalGraph π) i ∈ hullSet a := by + intro i; cases i <;> assumption + constructor + · apply unique_definable_mem a (fromBounded (.pairMem 1 0 2)) _ he + · exact (bounded_univ _ _).mpr ((Formula.eval_pairMem _ _ _ _).mpr ((globalGraph_pair π b _).mpr rfl)) + · intro x hx + exact (globalGraph_pair π b x).mp ((Formula.eval_pairMem _ _ _ _).mp ((bounded_univ _ _).mp hx)) + · apply unique_definable_mem a (fromBounded (.pairMem 0 1 2)) _ he + · exact (bounded_univ _ _).mpr ((Formula.eval_pairMem _ _ _ _).mpr ((globalGraph_inverse_pair π b _).mpr rfl)) + · intro x hx + exact (globalGraph_inverse_pair π b x).mp ((Formula.eval_pairMem _ _ _ _).mp ((bounded_univ _ _).mp hx)) + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryLanguage.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryLanguage.lean new file mode 100644 index 0000000000000000000000000000000000000000..11118df2a741386cb39bcf202416ff0ddba848b2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryLanguage.lean @@ -0,0 +1,102 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedSetTheory +import Mathlib.Tactic.DeriveEncodable + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory +universe u + +inductive SentenceForm where + | equal (i j : ℕ) + | member (i j : ℕ) + | conj (p q : SentenceForm) + | neg (p : SentenceForm) + | ex (p : SentenceForm) + deriving Encodable + +namespace SentenceForm + +def Sat (D : Set ZFSet.{u}) (e : ℕ → ZFSet.{u}) : SentenceForm → Prop + | .equal i j => e i = e j + | .member i j => e i ∈ e j + | .conj p q => p.Sat D e ∧ q.Sat D e + | .neg p => ¬ p.Sat D e + | .ex p => ∃ x ∈ D, p.Sat D (cons x e) + +def bound : SentenceForm → ℕ + | .equal i j | .member i j => max i j + 1 + | .conj p q => max p.bound q.bound + | .neg p => p.bound + | .ex p => p.bound - 1 + +theorem finite_support (p : SentenceForm) (D : Set ZFSet.{u}) + (e f : ℕ → ZFSet.{u}) (h : ∀ i, i < p.bound → e i = f i) : + p.Sat D e ↔ p.Sat D f := by + induction p generalizing e f with + | equal i j => + have hi := h i (by simp only [bound]; omega) + have hj := h j (by simp only [bound]; omega) + simp only [Sat,hi,hj] + | member i j => + have hi := h i (by simp only [bound]; omega) + have hj := h j (by simp only [bound]; omega) + simp only [Sat,hi,hj] + | conj p q ihp ihq => + exact and_congr (ihp e f (fun i hi => h i (by simp only [bound]; omega))) + (ihq e f (fun i hi => h i (by simp only [bound]; omega))) + | neg p ih => exact not_congr (ih e f h) + | ex p ih => + apply exists_congr; intro x + apply and_congr_right; intro _ + apply ih + intro i hi + cases i with + | zero => rfl + | succ i => exact h i (by simp only [bound] at h ⊢; omega) + +def disj (p q : SentenceForm) : SentenceForm := .neg (.conj (.neg p) (.neg q)) +def imp (p q : SentenceForm) : SentenceForm := .neg (.conj p (.neg q)) +def iff (p q : SentenceForm) : SentenceForm := .conj (imp p q) (imp q p) +def all (p : SentenceForm) : SentenceForm := .neg (.ex (.neg p)) + +@[simp] theorem sat_disj (p q : SentenceForm) (D : Set ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (disj p q).Sat D e ↔ p.Sat D e ∨ q.Sat D e := by classical simp only [disj,Sat]; tauto +@[simp] theorem sat_imp (p q : SentenceForm) (D : Set ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (imp p q).Sat D e ↔ (p.Sat D e → q.Sat D e) := by classical simp [imp,Sat] +@[simp] theorem sat_iff (p q : SentenceForm) (D : Set ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (iff p q).Sat D e ↔ (p.Sat D e ↔ q.Sat D e) := by simp [iff,Sat,iff_def] +@[simp] theorem sat_all (p : SentenceForm) (D : Set ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (all p).Sat D e ↔ ∀ x ∈ D, p.Sat D (cons x e) := by classical simp [all,Sat] + +def rename (v : ℕ → ℕ) : SentenceForm → SentenceForm + | .equal i j => .equal (v i) (v j) + | .member i j => .member (v i) (v j) + | .conj p q => .conj (p.rename v) (q.rename v) + | .neg p => .neg (p.rename v) + | .ex p => .ex (p.rename (fun i => match i with | 0 => 0 | j+1 => v j+1)) + +theorem sat_rename (p : SentenceForm) (v : ℕ → ℕ) + (D : Set ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (p.rename v).Sat D e ↔ p.Sat D (fun i => e (v i)) := by + induction p generalizing v e with + | equal => rfl + | member => rfl + | conj p q ihp ihq => exact and_congr (ihp v e) (ihq v e) + | neg p ih => exact not_congr (ih v e) + | ex p ih => + apply exists_congr; intro x + apply and_congr_right; intro _ + have he : (fun i => cons x e (match i with | 0 => 0 | j+1 => v j+1)) = + cons x (fun i => e (v i)) := by funext i; cases i <;> rfl + exact (ih _ _).trans (he ▸ Iff.rfl) +end SentenceForm + +def Elementary (D : Set ZFSet.{u}) : Prop := + ∀ p : SentenceForm, ∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ D) → + (p.Sat D e ↔ p.Sat Set.univ e) + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryModelIdeal.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryModelIdeal.lean new file mode 100644 index 0000000000000000000000000000000000000000..08fd0340cb508939f7b17d78083d86abbb0d3b10 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryModelIdeal.lean @@ -0,0 +1,65 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementaryDegreeHull + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel RelationCollapse SetDegreeDecoding PersistentRestrictions OracleJump +universe u + +theorem model_reals_countable (M : ZFSet.{u}) [Countable (Conditions M)] : (modelReals M).Countable := by + have hc : (M : Set ZFSet.{u}).Countable := by + apply (Set.countable_range (label M)).mono + intro x hx; exact label_surjective M hx + apply (hc.image decodeReal).mono + intro A hA + exact ⟨realCode A,hA,decodeReal_realCode A⟩ + +noncomputable def modelIdeal (M : ZFSet.{u}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) : + CountableIdeal where + carrier := {b | ∃ A ∈ modelReals M, degree A = b} + nonempty := ⟨degree FixedArithmetic.zero,FixedArithmetic.zero,sourceT_zero_real M hM hT,rfl⟩ + countable := (model_reals_countable M).image degree + lower := by + intro a b hab hb + obtain ⟨A,rfl⟩ := degree_surjective a + obtain ⟨B,hB,rfl⟩ := hb + exact ⟨A,sourceT_real_lower M hM hT hB hab,rfl⟩ + join_mem := by + rintro a b ⟨A,hA,rfl⟩ ⟨B,hB,rfl⟩ + exact ⟨TuringRigidity.join A B,sourceT_real_join M hM hT hA hB,rfl⟩ + +theorem modelIdeal_mem (M : ZFSet.{u}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) + (b : Degree) : b ∈ (modelIdeal M hM hT).carrier ↔ ∃ A ∈ modelReals M, degree A = b := Iff.rfl + +theorem modelIdeal_jump (M : ZFSet.{u}) [Countable (Conditions M)] (hM : Transitive M) (hT : SourceT M) : + IdealLocality.JumpClosed (PersistentLocality.ideal (modelIdeal M hM hT)) := by + rintro b ⟨A,hA,rfl⟩ + exact ⟨jump A,sourceT_real_jump M hM hT hA,rfl⟩ + +theorem hull_degree_iff (a : ℕ → ZFSet.{u}) + (hn : ∀ n, natSet.{u} n ∈ hullSet a) (hω : ZFSet.omega ∈ hullSet a) + (hR : ambientRealSet ∈ hullSet a) (hQ : ambientGraphBound ∈ hullSet a) (b : Degree) : + b ∈ (modelIdeal (collapsed (hullSet a)) (collapsed_transitive _) (collapsed_hull_sourceT a)).carrier ↔ + degreeSet b ∈ hullSet a := by + constructor + · rintro ⟨A,hA,rfl⟩ + exact degreeSet_mem_hull a hω (hn 0) hR hQ ((collapsed_hull_reals a hn hω A).mp hA) + · intro hb + obtain ⟨A,hA,hAb⟩ := degree_representative_in_hull a b hb + exact ⟨A,(collapsed_hull_reals a hn hω A).mpr hA,hAb⟩ + +theorem hull_ideal_invariant (a : ℕ → ZFSet.{u}) + (hn : ∀ n, natSet.{u} n ∈ hullSet a) (hω : ZFSet.omega ∈ hullSet a) + (hR : ambientRealSet ∈ hullSet a) (hQ : ambientGraphBound ∈ hullSet a) + (π : Degree ≃o Degree) (hπ : globalGraph π ∈ hullSet a) : + let I := modelIdeal (collapsed (hullSet a)) (collapsed_transitive _) (collapsed_hull_sourceT a) + ∀ b ∈ I.carrier, π b ∈ I.carrier ∧ π.symm b ∈ I.carrier := by + intro I b hb + have hd := (hull_degree_iff a hn hω hR hQ b).mp hb + have hi := image_degreeSet_mem_hull a π hπ b hd + exact ⟨(hull_degree_iff a hn hω hR hQ _).mpr hi.1,(hull_degree_iff a hn hω hR hQ _).mpr hi.2⟩ + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryRealModel.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryRealModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..121cf7181c990b3ffc5ec7cc5a1ba1cf509f75d8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementaryRealModel.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DegreeRigidity.Representation.ParameterCoveringModels + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel RelationCollapse SentenceForm +universe u + +theorem hull_real_fixed (a : ℕ → ZFSet.{u}) + (hn : ∀ n, natSet.{u} n ∈ hullSet a) {A : Oracle} (hA : realCode A ∈ hullSet a) : + structureMap (hullSet a) (realCode A) = realCode A := by + apply collapse_fixed _ _ hA + intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp (realCode_subset A hx) + refine ⟨hn n,structureMap_fixed omega_transitive ?_ _ ((mem_omega _).mpr ⟨n,rfl⟩)⟩ + intro y hy + obtain ⟨m,rfl⟩ := (mem_omega y).mp hy + exact hn m + +theorem hull_omega_fixed (a : ℕ → ZFSet.{u}) + (hn : ∀ n, natSet.{u} n ∈ hullSet a) (hω : ZFSet.omega ∈ hullSet a) : + structureMap (hullSet a) ZFSet.omega = ZFSet.omega := by + apply collapse_fixed _ _ hω + intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + refine ⟨hn n,structureMap_fixed omega_transitive ?_ _ ((mem_omega _).mpr ⟨n,rfl⟩)⟩ + intro y hy + obtain ⟨m,rfl⟩ := (mem_omega y).mp hy + exact hn m + +theorem collapsed_hull_reals (a : ℕ → ZFSet.{u}) + (hn : ∀ n, natSet.{u} n ∈ hullSet a) (hω : ZFSet.omega ∈ hullSet a) (A : Oracle) : + A ∈ modelReals (collapsed (hullSet a)) ↔ realCode A ∈ hullSet a := by + constructor + · intro hA + obtain ⟨x,hx,heq⟩ := (mem_collapsed (hullSet a) (realCode A)).mp hA + let e := cons x (fun _ => ZFSet.omega) + have hen : ∀ i, e i ∈ hullSet a := by intro i; cases i <;> assumption + let p := all (imp (.member 0 1) (.member 0 2)) + have hs : p.Sat (collapsed (hullSet a) : Set ZFSet) (fun i => structureMap (hullSet a) (e i)) := by + simp only [p,sat_all,sat_imp,Sat,cons_zero,cons_succ,e] + intro y _ hy + rw [←heq] at hy + rw [hull_omega_fixed a hn hω] + exact realCode_subset A hy + have ht := (collapsed_hull_elementary a p e hen).mp hs + simp only [p,sat_all,sat_imp,Sat,cons_zero,cons_succ,e,Set.mem_univ,forall_const] at ht + have hxreal : realCode (decodeReal x) = x := realCode_decodeReal ht + have hfix : structureMap (hullSet a) x = x := by + rw [←hxreal] + exact hull_real_fixed a hn (hxreal.symm ▸ hx) + exact heq.symm ▸ hfix.symm ▸ hx + · intro hA + exact (mem_collapsed _ _).mpr ⟨realCode A,hA,(hull_real_fixed a hn hA).symm⟩ + +noncomputable def mixedSeed (a : ℕ → ZFSet.{u}) (A : ℕ → Oracle) (n : ℕ) : ZFSet.{u} := + match n.unpair.1 with + | 0 => natSet n.unpair.2 + | 1 => realCode (A n.unpair.2) + | 2 => a n.unpair.2 + | _ => ZFSet.omega + +theorem mixed_naturals (a : ℕ → ZFSet.{u}) (A : ℕ → Oracle) (n : ℕ) : + natSet.{u} n ∈ hullSet (mixedSeed a A) := by + apply (mem_hullSet _ _).mpr + simpa [mixedSeed] using parameter_mem (mixedSeed a A) (Nat.pair 0 n) + +theorem mixed_omega (a : ℕ → ZFSet.{u}) (A : ℕ → Oracle) : + ZFSet.omega.{u} ∈ hullSet (mixedSeed a A) := by + apply (mem_hullSet _ _).mpr + simpa [mixedSeed] using parameter_mem (mixedSeed a A) (Nat.pair 3 0) + +theorem parameter_models_with_elementarity (a : ℕ → ZFSet.{u}) (A : ℕ → Oracle) : + ∃ d M : ZFSet.{u}, Transitive M ∧ SourceT M ∧ Countable (Conditions M) ∧ + StructureExtensional d ∧ (∀ n, a n ∈ d) ∧ + (∀ n, realCode (A n) ∈ d ∧ structureMap d (realCode (A n)) = realCode (A n)) ∧ + (∀ n, structureMap d (a n) ∈ M) ∧ + (∀ B : Oracle, B ∈ modelReals M ↔ realCode B ∈ d) ∧ + (∀ p : SentenceForm, ∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ d) → + (p.Sat (M : Set ZFSet) (fun i => structureMap d (e i)) ↔ p.Sat Set.univ e)) := by + let b := mixedSeed a A + have hn := mixed_naturals a A + have hω := mixed_omega a A + have ha (n : ℕ) : a n ∈ hullSet b := by + apply (mem_hullSet _ _).mpr + simpa [b,mixedSeed] using parameter_mem b (Nat.pair 2 n) + have hA (n : ℕ) : realCode (A n) ∈ hullSet b := by + apply (mem_hullSet _ _).mpr + simpa [b,mixedSeed] using parameter_mem b (Nat.pair 1 n) + refine ⟨hullSet b,collapsed (hullSet b),collapsed_transitive _,collapsed_hull_sourceT _, + inferInstance,hullSet_extensional _,ha,(fun n => ⟨hA n,hull_real_fixed b hn (hA n)⟩), + (fun n => (mem_collapsed _ _).mpr ⟨a n,ha n,rfl⟩),collapsed_hull_reals b hn hω,?_⟩ + exact collapsed_hull_elementary b + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ElementarySatisfaction.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementarySatisfaction.lean new file mode 100644 index 0000000000000000000000000000000000000000..389b9e6c7236a5c77da3296ab6bb2ab312f19249 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementarySatisfaction.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementaryCollapse + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel RelationCollapse +universe u + +theorem SentenceForm.collapse_sat (p : SentenceForm) (d : ZFSet.{u}) + (hd : StructureExtensional d) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ d) : + p.Sat (d : Set ZFSet) e ↔ p.Sat (collapsed d : Set ZFSet) (fun i => structureMap d (e i)) := by + induction p generalizing e with + | equal i j => exact ⟨congrArg (structureMap d),collapse_injective d hd _ (he i) _ (he j)⟩ + | member i j => exact (collapse_membership d hd _ (he i) _ (he j)).symm + | conj p q ihp ihq => exact and_congr (ihp e he) (ihq e he) + | neg p ih => exact not_congr (ih e he) + | ex p ih => + have hen (x : ZFSet.{u}) (hx : x ∈ d) : ∀ i, cons x e i ∈ d := by + intro i; cases i <;> simp [cons,he,hx] + constructor + · rintro ⟨x,hx,hp⟩ + refine ⟨_,(mem_collapsed d _).mpr ⟨x,hx,rfl⟩,?_⟩ + have h := (ih (cons x e) (hen x hx)).mp hp + rwa [map_cons] at h + · rintro ⟨y,hy,hp⟩ + obtain ⟨x,hx,rfl⟩ := (mem_collapsed d y).mp hy + refine ⟨x,hx,(ih (cons x e) (hen x hx)).mpr ?_⟩ + rwa [map_cons] + +def Valid (M : ZFSet.{u}) : Prop := + ∀ p : SentenceForm, (∀ e : ℕ → ZFSet.{u}, p.Sat Set.univ e) → + ∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ M) → p.Sat (M : Set ZFSet) e + +theorem collapsed_hull_valid (a : ℕ → ZFSet.{u}) : Valid (collapsed (hullSet a)) := by + intro p hp e he + choose f hf heq using fun i => (mem_collapsed (hullSet a) (e i)).mp (he i) + have hfe : (fun i => structureMap (hullSet a) (f i)) = e := by + funext i; exact (heq i).symm + have hh : (hullSet a : Set ZFSet) = hull a := by ext x; exact mem_hullSet a x + have hs : p.Sat (hullSet a : Set ZFSet) f := by + rw [hh] + exact (hull_elementary a p f (fun i => (mem_hullSet a _).mp (hf i))).mpr (hp f) + have ht := (p.collapse_sat (hullSet a) (hullSet_extensional a) f hf).mp hs + rwa [hfe] at ht + +noncomputable def fromBounded : Formula → SentenceForm + | .equal i j => .equal i j + | .member i j => .member i j + | .conj p q => .conj (fromBounded p) (fromBounded q) + | .neg p => .neg (fromBounded p) + | .existsMem i p => .ex (.conj (.member 0 (i+1)) (fromBounded p)) + +theorem bounded_sat (p : Formula) (M : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (fromBounded p).Sat (M : Set ZFSet) e ↔ p.Realize M e := by + induction p generalizing e with + | equal => rfl + | member => rfl + | conj p q ihp ihq => exact and_congr (ihp e) (ihq e) + | neg p ih => exact not_congr (ih e) + | existsMem i p ih => + simp only [fromBounded,SentenceForm.Sat,Formula.Realize,cons_zero,cons_succ] + apply exists_congr; intro x + exact and_congr_right (fun _ => and_congr_right (fun _ => ih (cons x e))) + +theorem bounded_univ (p : Formula) (e : ℕ → ZFSet.{u}) : + (fromBounded p).Sat Set.univ e ↔ p.Eval e := by + induction p generalizing e with + | equal => rfl + | member => rfl + | conj p q ihp ihq => exact and_congr (ihp e) (ihq e) + | neg p ih => exact not_congr (ih e) + | existsMem i p ih => + simp only [fromBounded,SentenceForm.Sat,Formula.Eval,cons_zero,cons_succ,Set.mem_univ,true_and] + apply exists_congr; intro x + exact and_congr_right (fun _ => ih (cons x e)) + +noncomputable def fromSigma : SigmaFormula → SentenceForm + | .bounded p => fromBounded p + | .existsSet p => .ex (fromSigma p) + +theorem sigma_sat (p : SigmaFormula) (M : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (fromSigma p).Sat (M : Set ZFSet) e ↔ p.Realize M e := by + induction p generalizing e with + | bounded p => exact bounded_sat p M e + | existsSet p ih => + apply exists_congr; intro x + exact and_congr_right (fun _ => ih (cons x e)) + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ElementarySchemas.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementarySchemas.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe73a13d372bb074777ce758efb20642b1571bbf --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ElementarySchemas.lean @@ -0,0 +1,126 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementaryAxioms + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel SentenceForm +universe u + +private def sepMap : ℕ → ℕ | 0 => 0 | i+1 => i+3 +private def relationMap : ℕ → ℕ | 0 => 0 | 1 => 1 | i+2 => i+3 +private def uniqueMap : ℕ → ℕ | 0 => 0 | 1 => 2 | i+2 => i+4 +private def imageMap : ℕ → ℕ | 0 => 1 | 1 => 0 | i+2 => i+4 + +private theorem sat_sepMap (q : SentenceForm) (D : Set ZFSet.{u}) + (x b a : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (q.rename sepMap).Sat D (cons x (cons b (cons a e))) ↔ q.Sat D (cons x e) := by + rw [sat_rename] + have he : (fun i => cons x (cons b (cons a e)) (sepMap i)) = cons x e := by + funext i; cases i <;> rfl + rw [he] + +private theorem sat_relationMap (q : SentenceForm) (D : Set ZFSet.{u}) + (y x a : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (q.rename relationMap).Sat D (cons y (cons x (cons a e))) ↔ q.Sat D (cons y (cons x e)) := by + rw [sat_rename] + have he : (fun i => cons y (cons x (cons a e)) (relationMap i)) = cons y (cons x e) := by + funext i; rcases i with _|_|i <;> rfl + rw [he] + +private theorem sat_uniqueMap (q : SentenceForm) (D : Set ZFSet.{u}) + (z y x a : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (q.rename uniqueMap).Sat D (cons z (cons y (cons x (cons a e)))) ↔ q.Sat D (cons z (cons x e)) := by + rw [sat_rename] + have he : (fun i => cons z (cons y (cons x (cons a e))) (uniqueMap i)) = cons z (cons x e) := by + funext i; rcases i with _|_|i <;> rfl + rw [he] + +private theorem sat_imageMap (q : SentenceForm) (D : Set ZFSet.{u}) + (x y b a : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (q.rename imageMap).Sat D (cons x (cons y (cons b (cons a e)))) ↔ q.Sat D (cons y (cons x e)) := by + rw [sat_rename] + have he : (fun i => cons x (cons y (cons b (cons a e))) (imageMap i)) = cons y (cons x e) := by + funext i; rcases i with _|_|i <;> rfl + rw [he] + +theorem Valid.separate {M : ZFSet.{u}} (hv : Valid M) (q : SentenceForm) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (a : ZFSet.{u}) (ha : a ∈ M) : + ∃ b ∈ M, ∀ x ∈ M, x ∈ b ↔ x ∈ a ∧ q.Sat (M : Set ZFSet) (cons x e) := by + let p := ex (all (iff (.member 0 1) (.conj (.member 0 2) (q.rename sepMap)))) + have hp : ∀ v : ℕ → ZFSet.{u}, p.Sat Set.univ v := by + intro v + let e' := fun i => v (i+1) + have hv' : v = cons (v 0) e' := by funext i; cases i <;> rfl + rw [hv'] + simp only [p,Sat,sat_all,sat_iff,sat_sepMap,cons_zero,cons_succ,Set.mem_univ,true_and,forall_const] + exact ⟨ZFSet.sep (fun x => q.Sat Set.univ (cons x e')) (v 0),fun x => ZFSet.mem_sep⟩ + have h := hv p hp (cons a e) (by intro i; cases i <;> simp [cons,he,ha]) + simpa only [p,Sat,sat_all,sat_iff,sat_sepMap,cons_zero,cons_succ,SetLike.mem_coe] using h + +theorem ambient_image (a : ZFSet.{u}) (R : ZFSet.{u} → ZFSet.{u} → Prop) + (ht : ∀ x ∈ a, ∃ y, R x y ∧ ∀ z, R x z → z = y) : + ∃ b : ZFSet.{u}, ∀ y, y ∈ b ↔ ∃ x ∈ a, R x y := by + classical + let f (i : Conditions a) := Classical.choose (ht (label a i) (label_mem a i)) + have hf (i : Conditions a) : R (label a i) (f i) ∧ ∀ z, R (label a i) z → z = f i := + Classical.choose_spec (ht _ (label_mem a i)) + refine ⟨ZFSet.range f,?_⟩ + intro y; rw [ZFSet.mem_range] + constructor + · rintro ⟨i,rfl⟩; exact ⟨_,label_mem a i,(hf i).1⟩ + · rintro ⟨x,hx,hr⟩ + obtain ⟨i,rfl⟩ := label_surjective a hx + exact ⟨i,((hf i).2 y hr).symm⟩ + +theorem Valid.replace {M : ZFSet.{u}} (hv : Valid M) (hM : Transitive M) (q : SentenceForm) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (a : ZFSet.{u}) (ha : a ∈ M) + (ht : ∀ x ∈ a, ∃ y ∈ M, q.Sat (M : Set ZFSet) (cons y (cons x e)) ∧ + ∀ z ∈ M, q.Sat (M : Set ZFSet) (cons z (cons x e)) → z = y) : + ∃ b ∈ M, ∀ y ∈ M, y ∈ b ↔ ∃ x ∈ a, q.Sat (M : Set ZFSet) (cons y (cons x e)) := by + let p := imp + (all (imp (.member 0 1) (ex (.conj (q.rename relationMap) + (all (imp (q.rename uniqueMap) (.equal 0 1))))))) + (ex (all (iff (.member 0 1) (ex (.conj (.member 0 3) (q.rename imageMap)))))) + have hp : ∀ v : ℕ → ZFSet.{u}, p.Sat Set.univ v := by + intro v + let e' := fun i => v (i+1) + have hv' : v = cons (v 0) e' := by funext i; cases i <;> rfl + rw [hv'] + simp only [p,Sat,sat_all,sat_iff,sat_imp,sat_relationMap,sat_uniqueMap,sat_imageMap, + cons_zero,cons_succ,Set.mem_univ,true_and,forall_const] + exact ambient_image (v 0) (fun x y => q.Sat Set.univ (cons y (cons x e'))) + have h := hv p hp (cons a e) (by intro i; cases i <;> simp [cons,he,ha]) + simp only [p,Sat,sat_all,sat_iff,sat_imp,sat_relationMap,sat_uniqueMap,sat_imageMap, + cons_zero,cons_succ] at h + obtain ⟨b,hb,hbdef⟩ := h (fun x _ hx => ht x hx) + refine ⟨b,hb,?_⟩ + intro y hy + rw [hbdef y hy] + exact ⟨fun ⟨x,_,hx,hr⟩ => ⟨x,hx,hr⟩,fun ⟨x,hx,hr⟩ => ⟨x,hM a ha x hx,hx,hr⟩⟩ + +theorem Valid.sigmaSeparation {M : ZFSet.{u}} (hv : Valid M) : SigmaSeparation M := by + intro p e he a ha + obtain ⟨b,hb,h⟩ := hv.separate (fromSigma p) e he a ha + exact ⟨b,hb,fun x hx => (h x hx).trans (and_congr_right (fun _ => sigma_sat p M _))⟩ + +theorem Valid.sigmaReplacement {M : ZFSet.{u}} (hv : Valid M) (hM : Transitive M) : SigmaReplacement M := by + intro p e he a ha ht + obtain ⟨b,hb,h⟩ := hv.replace hM (fromSigma p) e he a ha (by + intro x hx + obtain ⟨y,hy,hp,hu⟩ := ht x hx + exact ⟨y,hy,(sigma_sat p M _).mpr hp,fun z hz hpz => hu z hz ((sigma_sat p M _).mp hpz)⟩) + refine ⟨b,hb,?_⟩ + intro y hy + rw [h y hy] + apply exists_congr; intro x + exact and_congr_right (fun _ => sigma_sat p M _) + +theorem Valid.sourceT {M : ZFSet.{u}} (hv : Valid M) (hM : Transitive M) + (hne : ∃ a, a ∈ M) : SourceT M := + sourceT_of_finite_schemas M hM hv.pairing hv.union hv.powerSet hv.sigmaSeparation + (hv.sigmaReplacement hM) (hv.infinity hne) (hv.choice hM) + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/EnumerationConstruction.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/EnumerationConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..45fd0797b03de82db686ea6bb8a7111859f37786 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/EnumerationConstruction.lean @@ -0,0 +1,61 @@ +import OAI.Computability.DegreeRigidity.SetModels.EnumerationDecoding +import OAI.Computability.DegreeRigidity.SetModels.FixedArithmetic + +namespace OAI + +namespace TuringRigidity.EnumerationConstruction +open Encodable EncodedForcing ArithmeticHierarchy UniformOracle OracleJump +open ArithmeticModelDecoding SetCoding RelationCoding BoundedDecoding EnumerationDecoding + +def rows (C H : Oracle) : Oracle := fun v => + if (Nat.unpair (Nat.unpair v).1).1 = 0 then C (Nat.pair (Nat.unpair (Nat.unpair v).1).2 (Nat.unpair v).2) + else H (Nat.pair (Nat.unpair (Nat.unpair v).1).2 (Nat.unpair v).2) + +theorem rows_reduces (C H : Oracle) : Reduces (rows C H) (join C H) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let p := Primrec₂.natPair.comp (r.comp f) r + let even := Primrec.nat_mul.comp (Primrec.const 2) p + have hi := Primrec.ite (Primrec.eq.comp (f.comp f) (Primrec.const 0)) even (Primrec.succ.comp even) + have hh := EffectiveFamilies.reindex_reduces (join C H) hi + convert hh using 1 + funext v + by_cases h : (Nat.unpair (Nat.unpair v).1).1 = 0 + · simp only [rows,ite_eq_left h,join_even] + · simp only [rows,ite_eq_right h,join_odd] + +@[simp] theorem row_zero (C H : Oracle) (k : ℕ) : columns (rows C H) (Nat.pair 0 k) = columns C k := by + funext n; simp [columns,rows] + +@[simp] theorem row_one (C H : Oracle) (k : ℕ) : columns (rows C H) (Nat.pair 1 k) = columns H k := by + funext n; simp [columns,rows] + +theorem payload_code {C H : Oracle} (hC : Reduces C H) : ∃ p : RelationCode 2, + RelationBelow p (degree (jump H)) ∧ ∀ a b, + p.Holds (two a b) ↔ ∃ k, a = degree (columns C k) ∧ b = degree (columns H k) := by + have hP : RecursivePred (rows C H) (fun _ => True) := by + exact (total_primrec (Primrec.const 1)).of_eq (fun n => by simp) + obtain ⟨p,hp,hcode⟩ := EffectivePresentation.effective_coding (rows C H) (fun _ => True) hP 2 + have hb := reduces_trans (rows_reduces C H) (join_reduces hC (reduces_refl H)) + refine ⟨p,hp.mono (jump_mono hb),fun a b => ?_⟩ + rw [hcode] + constructor + · rintro ⟨k,_,hk⟩ + exact ⟨k,by simpa [two] using (hk 0).symm,by simpa [two] using (hk 1).symm⟩ + · rintro ⟨k,rfl,rfl⟩ + refine ⟨k,trivial,fun i => ?_⟩ + fin_cases i <;> simp [two] + +theorem enumeration_exists (H : Oracle) (hz : Reduces (jump FixedArithmetic.zero) H) : + ∃ c : Enumeration, c.output = (fun k => degree (columns H k)) ∧ + RelationBelow c.successor (degree (jump H)) ∧ RelationBelow c.payload (degree (jump H)) := by + obtain ⟨K⟩ := FixedArithmetic.frame_exists + have hC : Reduces K.C H := reduces_trans (reduces_jump K.C) (reduces_trans K.low hz) + obtain ⟨P,hP,hspec⟩ := payload_code hC + let c : Enumeration := ⟨fun k => degree (columns K.C k),K.injective, + fun k => degree (columns H k),K.successor,P,K.spec,hspec⟩ + exact ⟨c,rfl,K.below.mono (reduces_trans hz (reduces_jump H)),hP⟩ + +end TuringRigidity.EnumerationConstruction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/EnumerationDecoding.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/EnumerationDecoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d7a9c0b43ad053c5616c79bdf0b72e7657a942d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/EnumerationDecoding.lean @@ -0,0 +1,113 @@ +import OAI.Computability.DegreeRigidity.Effective.CodingBounds +import OAI.Computability.DegreeRigidity.Effective.LocalColumnIndices + +namespace OAI + +namespace TuringRigidity.EnumerationDecoding +open IndexPresentation IndexTuples ArithmeticHierarchy DecodingTheorem +open SetCoding RelationCoding BoundedDecoding OracleJump ArithmeticModelDecoding + +structure Enumeration where + node : ℕ → Degree + injective : Function.Injective node + output : ℕ → Degree + successor : RelationCode 2 + payload : RelationCode 2 + successor_spec : ∀ a b, successor.Holds (two a b) ↔ ∃ k, a = node k ∧ b = node (k+1) + payload_spec : ∀ a b, payload.Holds (two a b) ↔ ∃ k, a = node k ∧ b = output k + +theorem path_node {Y} (c : Enumeration) {z : ℕ} (hz : Dom Y z) (he : value Y z = c.node 0) + {n t : ℕ} (hpath : Path Y c.successor z n t) : + ∀ i, i ≤ n → Dom Y (item t i) ∧ value Y (item t i) = c.node i := by + intro i hi + induction i with + | zero => + exact ⟨hpath.1, (le_antisymm ((le_iff hpath.1 hz).mp hpath.2.1) + ((le_iff hz hpath.1).mp hpath.2.2.1)).trans he⟩ + | succ i ih => + have hprev := ih (by omega) + have hs := hpath.2.2.2 i (by omega) + have hnext : Dom Y (item t (i+1)) := by + simpa [twoIndex,entry] using hs.1 (1 : Fin 2) + obtain ⟨k,hk,hkn⟩ := (c.successor_spec _ _).mp ((presented_two hprev.1 hnext).mp hs) + have hki : k = i := c.injective (hk.symm.trans hprev.2) + exact ⟨hnext, by simpa [hki] using hkn⟩ + +theorem node_below (Y : Oracle) (c : Enumeration) + (hS : RelationBelow c.successor (degree Y)) (n : ℕ) : c.node n ≤ degree Y := by + have hs := (c.successor_spec (c.node n) (c.node (n+1))).mpr ⟨n,rfl,rfl⟩ + obtain ⟨d,hd,_⟩ := hs + exact (graph_bounded (hS.1 0) (hd 0)).1 + +theorem path_sigma (Y : Oracle) (S : RelationCode 2) (z : ℕ) + (hS : RelationBelow S (degree Y)) : Sigma Y 5 (fun v => Path Y S z (Nat.unpair v).1 (Nat.unpair v).2) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + let start := item_primrec.comp r (Primrec.const 0) + have hd : Sigma Y 5 (fun v => Dom Y (item (Nat.unpair v).2 0)) := + (dom_pi Y start).switch.raise.raise + have hl := (le_sigma Y start (Primrec.const z)).raise.raise + have hr := (le_sigma Y (Primrec.const z) start).raise.raise + have hs := ((RelationPresentation.sigma5_decoding Y S hS).comp + (twoIndex_primrec.comp (item_primrec.comp (r.comp f) r) + (item_primrec.comp (r.comp f) (Primrec.succ.comp r)))).bounded_all f + exact (hd.and (hl.and (hr.and hs))).congr (fun v => by + simp only [ArithmeticModelDecoding.Path,Presented,Nat.unpair_pair]) + +def Defined (Y : Oracle) (S P : RelationCode 2) (z n j : ℕ) : Prop := + ∃ t, Path Y S z n t ∧ Presented Y P (twoIndex (item t n) j) + +theorem defined_sigma (Y : Oracle) (S P : RelationCode 2) (z : ℕ) + (hS : RelationBelow S (degree Y)) (hP : RelationBelow P (degree Y)) : + Sigma Y 5 (fun v => Defined Y S P z (Nat.unpair v).1 (Nat.unpair v).2) := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + have hs := (path_sigma Y S z hS).comp (Primrec₂.natPair.comp (f.comp f) r) + have hp := (RelationPresentation.sigma5_decoding Y P hP).comp + (twoIndex_primrec.comp (item_primrec.comp r (f.comp f)) (r.comp f)) + exact ((hs.and hp).ex).congr (fun v => by simp only [Defined,Presented,Nat.unpair_pair]) + +theorem defined_iff {Y} (c : Enumeration) {z j : ℕ} (hz : Dom Y z) (hj : Dom Y j) + (he : value Y z = c.node 0) (hS : RelationBelow c.successor (degree Y)) (n : ℕ) : + Defined Y c.successor c.payload z n j ↔ c.output n = value Y j := by + constructor + · rintro ⟨t,hpath,hp⟩ + have hn := path_node c hz he hpath n le_rfl + obtain ⟨k,hk,hval⟩ := (c.payload_spec _ _).mp ((presented_two hn.1 hj).mp hp) + have hkn := c.injective (hk.symm.trans hn.2) + exact hkn ▸ hval.symm + · intro hU + choose e hd hev using (fun i => value_surjective Y (c.node i) (node_below Y c hS i)) + obtain ⟨t,ht⟩ := (exists_items (n+1) (fun i a => a = e i)).mp + (fun i _ => ⟨e i,rfl⟩) + have hdom (i : ℕ) (hi : i ≤ n) : Dom Y (item t i) := by rw [ht i (by omega)]; exact hd i + have hval (i : ℕ) (hi : i ≤ n) : value Y (item t i) = c.node i := by + rw [ht i (by omega),hev i] + refine ⟨t,⟨hdom 0 (by omega),?_,?_,?_⟩,?_⟩ + · apply (le_iff (hdom 0 (by omega)) hz).mpr + rw [hval 0 (by omega),he] + · apply (le_iff hz (hdom 0 (by omega))).mpr + rw [hval 0 (by omega),he] + · intro i hi + apply (presented_two (hdom i (by omega)) (hdom (i+1) (by omega))).mpr + exact (c.successor_spec _ _).mpr ⟨i,hval i (by omega),hval (i+1) (by omega)⟩ + · apply (presented_two (hdom n le_rfl) hj).mpr + exact (c.payload_spec _ _).mpr ⟨n,hval n le_rfl,hU.symm⟩ + +theorem graph_sigma {H Y : Oracle} (hHY : Reduces H Y) (c : Enumeration) + (hS : RelationBelow c.successor (degree Y)) (hP : RelationBelow c.payload (degree Y)) : + Sigma Y 5 (fun v => c.output (Nat.unpair v).1 = degree (EncodedForcing.columns H (Nat.unpair v).2)) := by + obtain ⟨z,hz,he⟩ := value_surjective Y (c.node 0) (node_below Y c hS 0) + obtain ⟨idx,hidx,hrep⟩ := LocalColumnIndices.uniform_indices hHY + have hi := (defined_sigma Y c.successor c.payload z hS hP).comp + (Primrec₂.natPair.comp (Primrec.fst.comp Primrec.unpair) + (hidx.comp (Primrec.snd.comp Primrec.unpair))) + apply hi.congr + intro v + simp only [Nat.unpair_pair] + rw [defined_iff c hz ((TableIndices.valid_iff_represents _ _).mpr ⟨_,hrep _⟩) he hS] + rw [value_eq (hrep _)] + +end TuringRigidity.EnumerationDecoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/EnumerationTransport.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/EnumerationTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..81dc62d3371d374c96c80496c94a30380f395e87 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/EnumerationTransport.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.SetModels.EnumerationConstruction +import OAI.Computability.DegreeRigidity.Representation.GlobalLocality + +namespace OAI + +namespace TuringRigidity.EnumerationTransport +open SetCoding RelationCoding BoundedDecoding ArithmeticModelDecoding EnumerationDecoding +open IdealInterpretation GlobalLocality +noncomputable section + +def elem (a : Degree) : fullIdeal := ⟨a,Set.mem_univ _⟩ +def liftAntichain (p : AntichainCode) : ACode fullIdeal := ⟨elem p.bound,elem p.left,elem p.right⟩ +def liftSet (p : SetCode) : SCode fullIdeal := ⟨elem p.bound,liftAntichain p.tags,liftAntichain p.decorated⟩ +def liftRelation {n : ℕ} (p : RelationCode n) : RCode fullIdeal n := + ⟨fun i => liftSet (p.coordinates i),liftAntichain p.tuples⟩ + +@[simp] theorem lift_external {n : ℕ} (p : RelationCode n) : (liftRelation p).external = p := by cases p; rfl + +def mapRelation {n : ℕ} (π : Degree ≃o Degree) (p : RelationCode n) : RelationCode n := + ((liftRelation p).map (GlobalLocality.lift π)).external + +theorem map_below {n : ℕ} (π : Degree ≃o Degree) (p : RelationCode n) (b : Degree) + (hp : RelationBelow p b) : RelationBelow (mapRelation π p) (π b) := by + exact (liftRelation p).map_below (GlobalLocality.lift π) (elem b) (by simpa only [lift_external,elem] using hp) + +theorem map_two (π : Degree ≃o Degree) (p : RelationCode 2) (a b : Degree) : + (mapRelation π p).Holds (two (π a) (π b)) ↔ p.Holds (two a b) := by + have hv (x : Degree) : ((GlobalLocality.lift π) (elem x)).val = π x := rfl + have he (x : Degree) : (elem x).val = x := rfl + simpa only [lift_external,hv,he,mapRelation] using (liftRelation p).transport_two (GlobalLocality.lift π) (elem a) (elem b) + +theorem inverse_eq (π : Degree ≃o Degree) (a b : Degree) : π.symm a = b ↔ a = π b := by + constructor + · intro h + have hh := congrArg π h + simpa only [π.apply_symm_apply] using hh + · intro h + rw [h,π.symm_apply_apply] + +def mapEnumeration (π : Degree ≃o Degree) (c : Enumeration) : Enumeration where + node := fun n => π (c.node n) + injective := π.injective.comp c.injective + output := fun n => π (c.output n) + successor := mapRelation π c.successor + payload := mapRelation π c.payload + successor_spec := by + intro a b + have hh := map_two π c.successor (π.symm a) (π.symm b) + simp only [π.apply_symm_apply] at hh + rw [hh,c.successor_spec] + exact exists_congr (fun k => and_congr (inverse_eq π a (c.node k)) (inverse_eq π b (c.node (k+1)))) + payload_spec := by + intro a b + have hh := map_two π c.payload (π.symm a) (π.symm b) + simp only [π.apply_symm_apply] at hh + rw [hh,c.payload_spec] + exact exists_congr (fun k => and_congr (inverse_eq π a (c.node k)) (inverse_eq π b (c.output k))) + +theorem mapEnumeration_below (π : Degree ≃o Degree) (c : Enumeration) (b : Degree) + (hS : RelationBelow c.successor b) (hP : RelationBelow c.payload b) : + RelationBelow (mapEnumeration π c).successor (π b) ∧ RelationBelow (mapEnumeration π c).payload (π b) := + ⟨map_below π _ b hS,map_below π _ b hP⟩ + +end +end TuringRigidity.EnumerationTransport + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/EvaluationNameCode.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/EvaluationNameCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..468e9b19d574b5b39ad2b81f6153fb96f3c6ec03 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/EvaluationNameCode.lean @@ -0,0 +1,69 @@ +import OAI.Computability.DegreeRigidity.SetModels.OrderedNameCode + +namespace OAI + + +namespace TuringRigidity.TransitiveNameModel +open RecursiveNames BoundedSetTheory +universe u + +def evaluationOutputFormula : SigmaFormula := .existsSet + (.andBounded (.conj (.member 0 4) (.pairMem 2 0 3)) + (NameCodeFormula.orderedName 5 0 2 1)) + +theorem internal_evaluation_name_codes (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) + {V t : ZFSet.{u}} (hV : V ∈ M) (ht : t ∈ M) : + ∃ B ∈ M, ∀ z, z ∈ B ↔ ∃ x ∈ V, + orderedNameCode t (checkedCode t x) x = z := by + obtain ⟨d,hdM,hd,hVd⟩ := internal_transitive_container M hM hP hU hS hR hI hV + obtain ⟨q,hqM,hq⟩ := internal_power M hM hPow hdM + obtain ⟨F,hF,hfg⟩ := internal_checkGraph M d q t hM hP hU hPow hS hR + hdM hqM ht hd hq V hVd + let r := iterUnion 2 F + have hr : r ∈ M := iterUnion_mem M hM hU hF 2 + have hxdom (x : ZFSet.{u}) (hx : x ∈ V) : x ∈ hull d q V := + (hull_transitive d q V hd) V (self_mem_hull d q hVd) x hx + have check (x : ZFSet.{u}) (hx : x ∈ V) : + checkedCode t x ∈ r ∧ ZFSet.pair x (checkedCode t x) ∈ F := by + obtain ⟨y,hy,hxy,_⟩ := hfg.2.2.1 x (hxdom x hx) + have he := hfg.correct x (hxdom x hx) y hy hxy + exact he ▸ ⟨hy,hxy⟩ + let e := cons F (cons r (fun _ => t)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hF + rcases i with _|i; exact hr + exact ht + apply replacement_image M hM hR evaluationOutputFormula e he hV + (fun x => orderedNameCode t (checkedCode t x) x) + · intro x hx + exact orderedNameCode_mem M hM hP ht (hM r hr _ (check x hx).1) (hM V hV x hx) + · intro x hx z hz + have hxM := hM V hV x hx + have matrix (w : ZFSet.{u}) (hw : w ∈ M) : + (SigmaFormula.andBounded (.conj (.member 0 4) (.pairMem 2 0 3)) + (NameCodeFormula.orderedName 5 0 2 1)).Realize M (cons w (cons z (cons x e))) ↔ + w ∈ r ∧ ZFSet.pair x w ∈ F ∧ z = orderedNameCode t w x := by + have he' : ∀ i, cons w (cons z (cons x e)) i ∈ M := by + intro i; rcases i with _|i; exact hw + rcases i with _|i; exact hz + rcases i with _|i; exact hxM + exact he i + rw [SigmaFormula.realize_andBounded,Formula.absolute _ M hM _ he', + NameCodeFormula.realize_orderedName M hM hP _ _ _ _ _ he'] + simp only [Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] + exact and_assoc + change (∃ w ∈ M, _) ↔ _ + constructor + · rintro ⟨w,hw,h⟩ + obtain ⟨hwr,hxw,hz⟩ := (matrix w hw).mp h + rw [hfg.correct x (hxdom x hx) w hwr hxw] at hz + exact hz + · intro hz + have hwM := hM r hr _ (check x hx).1 + exact ⟨_,hwM,(matrix _ hwM).mpr ⟨(check x hx).1,(check x hx).2,hz⟩⟩ + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ExactOmegaGraph.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ExactOmegaGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..38f3f568bb4cc3508b48116bcfa43d33f9826cf4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ExactOmegaGraph.lean @@ -0,0 +1,54 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaPowerCertificates + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +universe u + +theorem omegaGraph_of_exact_pairs (M d f : ZFSet.{u}) (hd : d.IsOrdinal) + (hf : ∀ z, z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (omegaNext x)) + (hval : ∀ x ∈ d, (Ordinal.omega0 ^ x.rank).toZFSet ∈ M) : + OmegaGraph M d (iterUnion 2 f) f := by + have hpair (x v : ZFSet.{u}) : ZFSet.pair x v ∈ f ↔ x ∈ d ∧ v = omegaNext x := by + rw [hf] + constructor + · rintro ⟨y,hy,he⟩ + obtain ⟨rfl,hv⟩ := ZFSet.pair_inj.mp he + exact ⟨hy,hv⟩ + · rintro ⟨hx,rfl⟩; exact ⟨x,hx,rfl⟩ + refine ⟨hd,⟨?_,?_⟩,?_⟩ + · intro z hz + obtain ⟨x,hx,rfl⟩ := (hf z).mp hz + exact ⟨x,hx,_,second_mem_doubleUnion hz,rfl⟩ + · intro x hx + have hp := (hpair x _).mpr ⟨hx,rfl⟩ + exact ⟨_,second_mem_doubleUnion hp,hp,fun v _ hv => (hpair x v).mp hv |>.2⟩ + · intro x hx v _ hv + have he := (hpair x v).mp hv |>.2 + subst v + refine ⟨(Ordinal.omega0 ^ x.rank).toZFSet, + hval x hx,?_,ZFSet.isOrdinal_toZFSet _,?_⟩ + · refine ⟨?_,?_,?_⟩ + · intro z hz; exact (omegaPower_members x.rank z).mpr (Or.inl hz) + · intro z hz + rcases (omegaPower_members x.rank z).mp hz with hz|⟨y,hy,hz⟩ + · exact Or.inl hz + · rw [(hd.mem hx).toZFSet_rank_eq] at hy + have hp := (hpair y _).mpr ⟨hd.subset_of_mem hx hy,rfl⟩ + exact Or.inr ⟨y,hy,_,second_mem_doubleUnion hp,hp,hz⟩ + · intro y hy w _ hw z hz + rw [(hpair y w).mp hw |>.2] at hz + exact (omegaPower_members x.rank z).mpr + (Or.inr ⟨y,(hd.mem hx).toZFSet_rank_eq.symm ▸ hy,hz⟩) + · rw [omegaNext,Ordinal.opow_add_one,Ordinal.rank_toZFSet] + +theorem OmegaGraph.union_value_mem {M d r f : ZFSet.{u}} (hg : OmegaGraph M d r f) + {x : ZFSet.{u}} (hx : x ∈ d) : (Ordinal.omega0 ^ x.rank).toZFSet ∈ M := by + obtain ⟨v,hv,hfv,_⟩ := hg.2.1.2 x hx + obtain ⟨A,hA,hs,_,_⟩ := hg.2.2 x hx v hv hfv + exact (omegaStageStep_exact hg hx hs) ▸ hA + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionArithmeticRepresentative.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionArithmeticRepresentative.lean new file mode 100644 index 0000000000000000000000000000000000000000..97fbfa22d12af69b75706881348a37909d4df7c2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionArithmeticRepresentative.lean @@ -0,0 +1,40 @@ +import OAI.Computability.DegreeRigidity.Constructibility.PersistentLocality +import OAI.Computability.DegreeRigidity.Computability.JumpProperties + +namespace OAI + +namespace TuringRigidity.ExtensionArithmeticRepresentative +open OracleJump IdealInterpretation IdealLocality PersistentRestrictions PersistentLocality + +theorem literal_join_program {I : DegreeIdeal} (σ : I ≃o I) (z x : I) + (hz : z.val = degree (jump FixedArithmetic.zero)) (A R : Oracle) + (hA : degree A = x.val) (hR : degree R = (σ.symm z).val) : + ∃ X : Oracle, degree X = (σ x).val ∧ Reduces X (iterate (join A R) 5) ∧ + ∃ e : OracleCode, + OracleCode.eval (oracleFunction (iterate (join A R) 5)) e = oracleFunction X := by + obtain ⟨X,Y,hX,hY,hXY⟩ := image_arithmetic σ z hz x + have hjoin : degree Y = degree (join A R) := by + change degree Y = degree A ⊔ degree R + rw [hA,hR]; exact hY + have hred : Reduces X (iterate (join A R) 5) := + TuringReducible.trans hXY (iterate_mono ((degree_eq_iff _ _).mp hjoin).1 5) + exact ⟨X,hX,hred,OracleCode.exists_code (RecursiveIn.iff_nat.mp hred)⟩ + +theorem extension_literal_join_program (I J : CountableIdeal) + (hIJ : I.carrier ⊆ J.carrier) (ρ : I ≃o I) (σ : J ≃o J) + (he : Extends hIJ ρ σ) (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (A R : Oracle) (hA : degree A ∈ J.carrier) + (hR : degree R = (ρ.symm ⟨degree (jump FixedArithmetic.zero),hz⟩).val) : + ∃ X : Oracle, degree X = (σ ⟨degree A,hA⟩).val ∧ Reduces X (iterate (join A R) 5) ∧ + ∃ e : OracleCode, + OracleCode.eval (oracleFunction (iterate (join A R) 5)) e = oracleFunction X := by + let z : I := ⟨degree (jump FixedArithmetic.zero),hz⟩ + let zJ : ideal J := ⟨z.val,hIJ z.property⟩ + let x : ideal J := ⟨degree A,hA⟩ + have hpre : degree R = ((lift σ).symm zJ).val := + hR.trans (extends_symm he z).symm + exact literal_join_program (lift σ) zJ x rfl A R rfl hpre + +end TuringRigidity.ExtensionArithmeticRepresentative + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionBasicAxioms.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionBasicAxioms.lean new file mode 100644 index 0000000000000000000000000000000000000000..0effe9e0b0471292422aeac5d170b9429c8e7e71 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionBasicAxioms.lean @@ -0,0 +1,161 @@ +import OAI.Computability.DegreeRigidity.SetModels.NameUnionCode + +namespace OAI + +namespace TuringRigidity.TransitiveNameModel +open Set RecursiveNames BoundedSetTheory CountableForcing +universe u + +namespace BasicAxioms + +def Extensionality (M : ZFSet.{u}) : Prop := + ∀ a ∈ M, ∀ b ∈ M, (∀ x ∈ M, x ∈ a ↔ x ∈ b) → a = b + +def EmptySet (M : ZFSet.{u}) : Prop := ∃ a ∈ M, ∀ x ∈ M, x ∉ a + +def Foundation (M : ZFSet.{u}) : Prop := + ∀ a ∈ M, (∃ x ∈ M, x ∈ a) → + ∃ y ∈ M, y ∈ a ∧ ∀ z ∈ M, ¬ (z ∈ y ∧ z ∈ a) + +theorem extensionality (M : ZFSet.{u}) (hM : Transitive M) : Extensionality M := by + intro a ha b hb h + apply ZFSet.ext + intro x + exact ⟨fun hx => (h x (hM a ha x hx)).mp hx, + fun hx => (h x (hM b hb x hx)).mpr hx⟩ + +theorem foundation (M : ZFSet.{u}) (hM : Transitive M) : Foundation M := by + rintro a ha ⟨x,_,hxa⟩ + have hne : a ≠ ∅ := by intro h; exact ZFSet.notMem_empty x (h ▸ hxa) + obtain ⟨y,hya,hy⟩ := ZFSet.regularity a hne + refine ⟨y,hM a ha y hya,hya,fun z _ hz => ?_⟩ + have hz' : z ∈ a ∩ y := ZFSet.mem_inter.mpr ⟨hz.2,hz.1⟩ + exact ZFSet.notMem_empty z (hy ▸ hz') + +end BasicAxioms + +theorem empty_mem_ground (M : ZFSet.{u}) (hM : Transitive M) (hne : M ≠ ∅) : + (∅ : ZFSet.{u}) ∈ M := by + obtain ⟨a,ha,hmin⟩ := ZFSet.regularity M hne + have he : a = ∅ := by + apply ZFSet.ext + intro x + constructor + · intro hx + have hi : x ∈ M ∩ a := ZFSet.mem_inter.mpr ⟨hM a ha x hx,hx⟩ + exact hmin ▸ hi + · exact fun hx => False.elim (ZFSet.notMem_empty x hx) + exact he ▸ ha + +def emptyName (P : Type u) : Name P := + .mk (ULift Empty) (fun i => i.down.elim) (fun i => i.down.elim) + +theorem encode_emptyName {P : Type u} (l : P → ZFSet.{u}) : + (emptyName P).encode l = ∅ := by + apply ZFSet.ext + intro x + simp [emptyName,Name.encode] + +theorem val_emptyName {P : Type u} (G : Set P) : Name.val G (emptyName P) = ∅ := by + apply ZFSet.ext + intro x + simp [emptyName,Name.mem_val] + +theorem mem_extensionSet (M p : ZFSet.{u}) (G : Set (Conditions p)) (x : ZFSet.{u}) : + x ∈ genericExtensionSet M p G ↔ + ∃ τ : Name (Conditions p), τ.encode (label p) ∈ M ∧ τ.val G = x := by + change x ∈ (genericExtensionSet M p G : Set ZFSet.{u}) ↔ _ + rw [genericExtensionSet_coe] + rfl + +theorem extension_empty_mem (M p : ZFSet.{u}) (hM : Transitive M) (hne : M ≠ ∅) + (G : Set (Conditions p)) : (∅ : ZFSet.{u}) ∈ genericExtensionSet M p G := by + apply (mem_extensionSet M p G _).mpr + refine ⟨emptyName _,?_,val_emptyName G⟩ + rw [encode_emptyName] + exact empty_mem_ground M hM hne + +theorem encode_pair {P : Type u} [Top P] (l : P → ZFSet.{u}) (σ τ : Name P) : + (Name.pair σ τ).encode l = + ({ZFSet.pair (σ.encode l) (l ⊤),ZFSet.pair (τ.encode l) (l ⊤)} : ZFSet.{u}) := by + apply ZFSet.ext + intro x + change x ∈ ZFSet.range _ ↔ _ + rw [ZFSet.mem_range,ZFSet.mem_pair] + constructor + · rintro ⟨⟨b⟩,hb⟩ + cases b + · exact Or.inr hb.symm + · exact Or.inl hb.symm + · rintro (hx|hx) + · exact ⟨⟨true⟩,hx.symm⟩ + · exact ⟨⟨false⟩,hx.symm⟩ + +theorem names_pair_closed (M p : ZFSet.{u}) [Top (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hp : p ∈ M) + {σ τ : Name (Conditions p)} (hσ : σ ∈ names M p) (hτ : τ ∈ names M p) : + Name.pair σ τ ∈ names M p := by + have ht := hM p hp (label p ⊤) (label_mem p ⊤) + change (Name.pair σ τ).encode (label p) ∈ M + rw [encode_pair] + exact pair_mem M hM hP (orderedPair_mem M hM hP hσ ht) (orderedPair_mem M hM hP hτ ht) + +theorem extension_pairing (M p : ZFSet.{u}) [Top (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hp : p ∈ M) + (G : Set (Conditions p)) (hG : ⊤ ∈ G) : Pairing (genericExtensionSet M p G) := by + intro a ha b hb + obtain ⟨σ,hσ,rfl⟩ := (mem_extensionSet M p G a).mp ha + obtain ⟨τ,hτ,rfl⟩ := (mem_extensionSet M p G b).mp hb + refine ⟨({σ.val G,τ.val G} : ZFSet.{u}),?_,fun x _ => ZFSet.mem_pair⟩ + exact (mem_extensionSet M p G _).mpr + ⟨Name.pair σ τ,names_pair_closed M p hM hP hp hσ hτ,Name.val_pair G hG σ τ⟩ + +theorem names_union_closed (M p r : ZFSet.{u}) [Preorder (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hp : p ∈ M) (hrM : r ∈ M) + (hr : ∀ q s : Conditions p, ZFSet.pair (label p q) (label p s) ∈ r ↔ q ≤ s) + {τ : Name (Conditions p)} (hτ : τ ∈ names M p) : + Name.union τ ∈ names M p := by + change (Name.union τ).encode (label p) ∈ M + rw [encode_union p r hr] + exact unionCode_mem M hM hP hU hPow hS hτ hp hrM + +theorem extension_union (M p r : ZFSet.{u}) [Preorder (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hp : p ∈ M) (hrM : r ∈ M) + (hr : ∀ q s : Conditions p, ZFSet.pair (label p q) (label p s) ∈ r ↔ q ≤ s) + (G : GenericFilter (Conditions p)) : BoundedSetTheory.Union (genericExtensionSet M p G.carrier) := by + intro a ha + obtain ⟨τ,hτ,rfl⟩ := (mem_extensionSet M p G.carrier a).mp ha + refine ⟨ZFSet.sUnion (τ.val G.carrier),?_,?_⟩ + · exact (mem_extensionSet M p G.carrier _).mpr + ⟨Name.union τ,names_union_closed M p r hM hP hU hPow hS hp hrM hr hτ,Name.val_union G τ⟩ + · intro x _ + rw [ZFSet.mem_sUnion] + constructor + · rintro ⟨y,hy,hxy⟩ + exact ⟨y,genericExtensionSet_transitive M p hM G.carrier _ ha y hy,hy,hxy⟩ + · rintro ⟨y,_,hy,hxy⟩ + exact ⟨y,hy,hxy⟩ + +theorem extension_five_axioms (M p r : ZFSet.{u}) + [Preorder (Conditions p)] [Top (Conditions p)] + (hM : Transitive M) (hne : M ≠ ∅) (hP : Pairing M) + (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hp : p ∈ M) (hrM : r ∈ M) + (hr : ∀ q s : Conditions p, ZFSet.pair (label p q) (label p s) ∈ r ↔ q ≤ s) + (G : GenericFilter (Conditions p)) (hG : ⊤ ∈ G.carrier) : + let E := genericExtensionSet M p G.carrier + BasicAxioms.Extensionality E ∧ BasicAxioms.EmptySet E ∧ + Pairing E ∧ BoundedSetTheory.Union E ∧ BasicAxioms.Foundation E := by + dsimp + have hE := genericExtensionSet_transitive M p hM G.carrier + exact ⟨BasicAxioms.extensionality _ hE, + ⟨∅,extension_empty_mem M p hM hne G.carrier,fun x _ => ZFSet.notMem_empty x⟩, + extension_pairing M p hM hP hp G.carrier hG, + extension_union M p r hM hP hU hPow hS hp hrM hr G, + BasicAxioms.foundation _ hE⟩ + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionChoice.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionChoice.lean new file mode 100644 index 0000000000000000000000000000000000000000..e64db4e2187ec14e61ea09b73c7cccdc156baa0a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionChoice.lean @@ -0,0 +1,69 @@ +import OAI.Computability.DegreeRigidity.SetModels.ChoiceFromOrdinalCover +import OAI.Computability.DegreeRigidity.SetModels.NameEvaluationGraph +import OAI.Computability.DegreeRigidity.SetModels.ExtensionSigmaReplacement +import OAI.Computability.DegreeRigidity.SetModels.ExtensionPowerSet + +namespace OAI + + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + +theorem extension_choice (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) (htop : ⊤ ∈ G.carrier) : + Choice (genericExtensionSet M c G.carrier) := by + classical + let E := genericExtensionSet M c G.carrier + have hET : Transitive E := genericExtensionSet_transitive M c hM G.carrier + have hEP : Pairing E := extension_pairing M c hM hP hc G.carrier htop + have hEU : BoundedSetTheory.Union E := extension_union M c o hM hP hU hPow hS.bounded hc hoM ho G + have hEPow : PowerSet E := extension_powerSet M hM hP hU hPow hS.bounded hR hI hc hoM ho G hG htop + have hES : Separation E := (extension_sigmaSeparation M hM hP hU hPow hS hR hI hc hoM ho G hG).bounded + have hground : M ⊆ E := ground_inclusion_set M c hM hP hU hPow hS.bounded hR hI hc G.carrier htop + intro X hX hnonempty + obtain ⟨a,ha,rfl⟩ := (mem_extensionSet M c G.carrier X).mp hX + obtain ⟨d,hdM,hd,had⟩ := internal_transitive_container M hM hP hU hS.bounded hR hI ha + let V := ZFSet.sep (fun x => (NameValidity.Code.valid 1 0).Realize M (cons x (fun _ => c))) d + have hV : V ∈ M := sigma_sep_mem M hM hS (NameValidity.Code.valid 1 0) (fun _ => c) (fun _ => hc) hdM + have valid (x : ZFSet.{u}) (hx : x ∈ M) : + (NameValidity.Code.valid 1 0).Realize M (cons x (fun _ => c)) ↔ + ∃ b : Name (Conditions c), b.encode (label c) = x := + NameValidity.realize_valid M hM hP hU hPow hS.bounded hR hI _ + (by intro i; cases i <;> assumption) 1 0 + have hvalid (x : ZFSet.{u}) (hx : x ∈ V) : ∃ b : Name (Conditions c), b.encode (label c) = x := + (valid x (hM V hV x hx)).mp (ZFSet.mem_sep.mp hx).2 + have code_mem (b : Name (Conditions c)) (hb : b.encode (label c) ∈ d) : b.encode (label c) ∈ V := + ZFSet.mem_sep.mpr ⟨hb,(valid _ (hM d hdM _ hb)).mpr ⟨b,rfl⟩⟩ + obtain ⟨δ,hδM,hδ,F,hFM,hF,hsurj,_⟩ := + InternalWellOrder.internal_ordinal_enumeration M hM hP hU hPow hS hR hI hAC hV + obtain ⟨N,hN,hNdef⟩ := internal_name_evaluation_graph M hM hP hU hPow hS.bounded hR hI hc + hV hvalid G.carrier htop + have hNE : N.val G.carrier ∈ E := (mem_extensionSet M c G.carrier _).mpr ⟨N,hN,rfl⟩ + have hNfun : FiniteTerm.Functional (N.val G.carrier) := by + intro v x y hx hy + obtain ⟨v',_,b,hb,he⟩ := (hNdef _).mp hx + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + obtain ⟨v'',_,b',hb',he'⟩ := (hNdef _).mp hy + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he' + exact Name.val_eq_of_encode_eq (label c) (label_injective c) G.carrier _ _ (hb.trans hb'.symm) + apply InternalWellOrder.internal_choice_of_ordinal_cover E hET hEP hEU hEPow hES + hX (hground hδM) (hground hV) (hground hFM) hNE hδ hF hNfun + intro x hx + obtain ⟨y,hy⟩ := hnonempty x hx + obtain ⟨b,hbd,hbx⟩ := name_of_value_member d hd a had G.carrier x hx + have hyb : y ∈ b.val G.carrier := hbx.symm ▸ hy + obtain ⟨s,hsd,hsy⟩ := name_of_value_member d hd b hbd G.carrier y hyb + have hsV := code_mem s hsd + obtain ⟨i,hi,hif⟩ := hsurj _ hsV + refine ⟨i,hi,s.encode (label c),hsV,y,hy,hif,(hNdef _).mpr ?_⟩ + exact ⟨_,hsV,s,rfl,congrArg (ZFSet.pair (s.encode (label c))) hsy.symm⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionPowerSet.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionPowerSet.lean new file mode 100644 index 0000000000000000000000000000000000000000..5da7e4a395d6afb8fcad6697e42bc20001d5adf1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionPowerSet.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.SetModels.IntersectionName + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + +noncomputable def powerName (a : Name (Conditions c)) (W : ZFSet.{u}) : Name (Conditions c) := + .mk (Conditions W) (fun s => a.restrict (label c) (label W s)) (fun _ => ⊤) + +theorem encode_powerName (a : Name (Conditions c)) (W : ZFSet.{u}) + (hW : ∀ B ∈ W, B ⊆ a.support (label c)) : + (powerName a W).encode (label c) = ZFSet.prod W ({label c ⊤} : ZFSet.{u}) := by + apply ZFSet.ext + intro z + change z ∈ ZFSet.range _ ↔ _ + rw [ZFSet.mem_range] + constructor + · rintro ⟨s,hs⟩ + rw [Name.encode_restrict _ _ _ (hW _ (label_mem W s))] at hs + exact ZFSet.mem_prod.mpr ⟨_,label_mem W s,_,ZFSet.mem_singleton.mpr rfl,hs.symm⟩ + · intro hz + obtain ⟨B,hB,t,ht,hz⟩ := ZFSet.mem_prod.mp hz + obtain rfl := ZFSet.mem_singleton.mp ht + obtain ⟨s,rfl⟩ := label_surjective W hB + exact ⟨s,by rw [Name.encode_restrict _ _ _ (hW _ hB)]; exact hz.symm⟩ + +theorem mem_val_powerName (a : Name (Conditions c)) (W : ZFSet.{u}) + (G : Set (Conditions c)) (hG : ⊤ ∈ G) (x : ZFSet.{u}) : + x ∈ (powerName a W).val G ↔ ∃ B ∈ W, (a.restrict (label c) B).val G = x := by + rw [powerName,Name.mem_val] + constructor + · rintro ⟨s,_,hs⟩ + exact ⟨_,label_mem W s,hs⟩ + · rintro ⟨B,hB,hx⟩ + obtain ⟨s,rfl⟩ := label_surjective W hB + exact ⟨s,hG,hx⟩ + +theorem extension_powerSet (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) (htop : ⊤ ∈ G.carrier) : + PowerSet (genericExtensionSet M c G.carrier) := by + intro x hx + obtain ⟨a,ha,rfl⟩ := (mem_extensionSet M c G.carrier x).mp hx + have hsupport := support_mem M hM hP hU hPow hS hc hoM ho a ha + obtain ⟨W,hW,hWdef⟩ := internal_power M hM hPow hsupport + have hWsub : ∀ B ∈ W, B ⊆ a.support (label c) := fun B hB => ((hWdef B).mp hB).2 + have hpower : (powerName a W).encode (label c) ∈ M := by + rw [encode_powerName a W hWsub] + exact product_mem M hM hP hU hPow hS hW + (singleton_mem M hM hP (hM c hc _ (label_mem c ⊤))) + refine ⟨(powerName a W).val G.carrier,(mem_extensionSet M c G.carrier _).mpr + ⟨_,hpower,rfl⟩,?_⟩ + intro z hz + constructor + · intro hzPower y _ hyz + obtain ⟨B,hB,hBz⟩ := (mem_val_powerName a W G.carrier htop z).mp hzPower + rw [←hBz] at hyz + exact a.val_restrict_subset (label c) B G hyz + · intro hsub + obtain ⟨b,hb,rfl⟩ := (mem_extensionSet M c G.carrier z).mp hz + have hba : b.val G.carrier ⊆ a.val G.carrier := fun y hy => hsub y + (genericExtensionSet_transitive M c hM G.carrier _ + ((mem_extensionSet M c G.carrier _).mpr ⟨b,hb,rfl⟩) y hy) hy + obtain ⟨B,hBM,hBS,hBval⟩ := internal_intersection_name M hM hP hU hPow hS hR hI hc hoM ho G hG a b ha hb + apply (mem_val_powerName a W G.carrier htop _).mpr + refine ⟨B,(hWdef B).mpr ⟨hBM,hBS⟩,hBval.trans ?_⟩ + apply ZFSet.ext + intro y + rw [ZFSet.mem_inter] + exact ⟨And.right,fun hy => ⟨hba hy,hy⟩⟩ + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionSeparation.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..86cae5792d74cd2fd54da8adc9fb1dc11753fbec --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionSeparation.lean @@ -0,0 +1,39 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedSeparationName + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem extension_boundedSeparation (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) : + Separation (genericExtensionSet M c G.carrier) := by + classical + intro φ env henv x hx + obtain ⟨a,ha,rfl⟩ := (mem_extensionSet M c G.carrier x).mp hx + have names_exist (i) := (mem_extensionSet M c G.carrier (env i)).mp (henv i) + choose e he hval using names_exist + obtain ⟨B,hB,hBS,hBval⟩ := separation_name M hM hP hU hPow hS hR hI hc hoM ho G hG φ a ha e he + have hcode : (a.restrict (label c) B).encode (label c) ∈ M := by + rw [Name.encode_restrict _ _ _ hBS] + exact hB + refine ⟨(a.restrict (label c) B).val G.carrier, + (mem_extensionSet M c G.carrier _).mpr ⟨_,hcode,rfl⟩,?_⟩ + intro z hz + rw [hBval z] + have hev : (fun i => (e i).val G.carrier) = env := funext hval + rw [hev] + apply and_congr_right + intro _ + exact (φ.absolute _ (genericExtensionSet_transitive M c hM G.carrier) (cons z env) + (by intro i; cases i <;> simp only [cons_zero,cons_succ]; exact hz; exact henv _)).symm + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionSigmaReplacement.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionSigmaReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..ffa3fb4a3e0b68a4125321f28130459a3023d94d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionSigmaReplacement.lean @@ -0,0 +1,82 @@ +import OAI.Computability.DegreeRigidity.SetModels.ExtensionWitnessCover +import OAI.Computability.DegreeRigidity.SetModels.ExtensionSigmaSeparation + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace SigmaFormula + +def imageVars : ℕ → ℕ + | 0 => 1 + | 1 => 0 + | i+2 => i+3 + +def image (φ : SigmaFormula) : SigmaFormula := + .existsSet (andBounded (.member 0 2) (φ.rename imageVars)) + +theorem realize_image (φ : SigmaFormula) (M a y : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + φ.image.Realize M (cons y (cons a e)) ↔ + ∃ x ∈ M, x ∈ a ∧ φ.Realize M (cons y (cons x e)) := by + simp only [image,Realize,realize_andBounded,realize_rename,Formula.Realize,cons_zero,cons_succ] + apply exists_congr; intro x + apply and_congr_right; intro _ + apply and_congr_right; intro _ + have he : (fun i => cons x (cons y (cons a e)) (imageVars i)) = cons y (cons x e) := by + funext i; rcases i with _|i; rfl + rcases i with _|i <;> rfl + rw [he] +end SigmaFormula +end TuringRigidity.BoundedSetTheory + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem extension_sigmaReplacement (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) : + SigmaReplacement (genericExtensionSet M c G.carrier) := by + classical + intro φ env henv X hX htotal + obtain ⟨a,ha,rfl⟩ := (mem_extensionSet M c G.carrier X).mp hX + have names_exist (i) := (mem_extensionSet M c G.carrier (env i)).mp (henv i) + choose e he hval using names_exist + have hev : (fun i => (e i).val G.carrier) = env := funext hval + obtain ⟨N,hN,hcover⟩ := extension_witness_cover M hM hP hU hPow hS hR hI hAC hc hoM ho G hG φ e he a ha + rw [hev] at hcover + have hNExt := (mem_extensionSet M c G.carrier _).mpr ⟨N,hN,rfl⟩ + have hAExt := (mem_extensionSet M c G.carrier _).mpr ⟨a,ha,rfl⟩ + have hExtT := genericExtensionSet_transitive M c hM G.carrier + have hcovered : ∀ x ∈ a.val G.carrier, ∃ y ∈ N.val G.carrier, + φ.Realize (genericExtensionSet M c G.carrier) (cons y (cons x env)) := by + intro x hx + obtain ⟨y,hy,hφ,_⟩ := htotal x hx + exact hcover x hx ⟨y,hy,hφ⟩ + have hsep := extension_sigmaSeparation M hM hP hU hPow hS hR hI hc hoM ho G hG + have he' : ∀ i, cons (a.val G.carrier) env i ∈ genericExtensionSet M c G.carrier := by + intro i; cases i with + | zero => exact hAExt + | succ i => exact henv i + obtain ⟨b,hb,hbdef⟩ := hsep φ.image (cons (a.val G.carrier) env) he' (N.val G.carrier) hNExt + refine ⟨b,hb,?_⟩ + intro y hy + rw [hbdef y hy,SigmaFormula.realize_image] + constructor + · rintro ⟨_,x,_,hx,hφ⟩ + exact ⟨x,hx,hφ⟩ + · rintro ⟨x,hx,hφ⟩ + obtain ⟨z,hz,hφz⟩ := hcovered x hx + obtain ⟨v,_,_,hu⟩ := htotal x hx + have hzy : z = y := (hu z (hExtT _ hNExt z hz) hφz).trans (hu y hy hφ).symm + exact ⟨hzy ▸ hz,x,hExtT _ hAExt x hx,hx,hφ⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionSigmaSeparation.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionSigmaSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd12a9745906e0f2e2703c198a69c6b9265e6aed --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionSigmaSeparation.lean @@ -0,0 +1,36 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaSeparationName + +namespace OAI + + +namespace TuringRigidity.BoundedForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem extension_sigmaSeparation (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : SigmaSeparation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) : + SigmaSeparation (genericExtensionSet M c G.carrier) := by + classical + intro φ env henv x hx + obtain ⟨a,ha,rfl⟩ := (mem_extensionSet M c G.carrier x).mp hx + have names_exist (i) := (mem_extensionSet M c G.carrier (env i)).mp (henv i) + choose e he hval using names_exist + obtain ⟨B,hB,hBS,hBval⟩ := sigma_separation_name M hM hP hU hPow hS hR hI hc hoM ho G hG φ a ha e he + have hcode : (a.restrict (label c) B).encode (label c) ∈ M := by + rw [Name.encode_restrict _ _ _ hBS] + exact hB + refine ⟨(a.restrict (label c) B).val G.carrier, + (mem_extensionSet M c G.carrier _).mpr ⟨_,hcode,rfl⟩,?_⟩ + intro z _ + rw [hBval z] + have hev : (fun i => (e i).val G.carrier) = env := funext hval + rw [hev] + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionWitnessCover.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionWitnessCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..244d498cedeb3f83014f935e9d873b000c7f54d5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ExtensionWitnessCover.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.ForcingWitnessCollection +import OAI.Computability.DegreeRigidity.SetModels.NameValueCover + +namespace OAI + + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} + +theorem name_of_value_member (d : ZFSet.{u}) (hd : Transitive d) + (a : Name (Conditions c)) (ha : a.encode (label c) ∈ d) (G : Set (Conditions c)) + (x : ZFSet.{u}) (hx : x ∈ a.val G) : + ∃ b : Name (Conditions c), b.encode (label c) ∈ d ∧ b.val G = x := by + cases a with + | mk ι child tag => + rw [Name.mem_val] at hx + obtain ⟨i,_,hval⟩ := hx + exact ⟨child i,names_childClosed d c hd (.mk ι child tag) ha (child i) ⟨i,rfl⟩,hval⟩ + +variable [Preorder (Conditions c)] + +theorem extension_witness_cover (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) + (φ : SigmaFormula) (e : ℕ → Name (Conditions c)) (he : ∀ i, (e i).encode (label c) ∈ M) + (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) : + ∃ N : Name (Conditions c), N.encode (label c) ∈ M ∧ + ∀ x ∈ a.val G.carrier, + (∃ y ∈ genericExtensionSet M c G.carrier, + φ.Realize (genericExtensionSet M c G.carrier) (cons y (cons x (fun i => (e i).val G.carrier)))) → + ∃ y ∈ N.val G.carrier, + φ.Realize (genericExtensionSet M c G.carrier) (cons y (cons x (fun i => (e i).val G.carrier))) := by + obtain ⟨d,hd,hdt,had⟩ := internal_transitive_container M hM hP hU hS.bounded hR hI ha + obtain ⟨W,hW,hbound⟩ := forcing_witness_bound M hM hP hU hPow hS hR hI hAC hc hoM ho φ e he hd + obtain ⟨N,hN,hcover⟩ := internal_name_value_cover M hM hP hU hPow hS hR hI hc hW G + refine ⟨N,hN,?_⟩ + intro x hx hw + obtain ⟨b,hbd,rfl⟩ := name_of_value_member d hdt a had G.carrier x hx + have hb := hM d hd _ hbd + obtain ⟨y,hy,hφ⟩ := hw + obtain ⟨v,hv,rfl⟩ := (mem_extensionSet M c G.carrier y).mp hy + have env (v : Name (Conditions c)) (hv : v.encode (label c) ∈ M) : + ∀ i, (push v (push b e) i).encode (label c) ∈ M := by + intro i; rcases i with _|i; exact hv + rcases i with _|i; exact hb + exact he i + have values (v : Name (Conditions c)) : (fun i => (push v (push b e) i).val G.carrier) = + cons (v.val G.carrier) (cons (b.val G.carrier) (fun i => (e i).val G.carrier)) := by + funext i; rcases i with _|i; rfl + rcases i with _|i <;> rfl + rw [← values v] at hφ + obtain ⟨p,hp,hforce⟩ := (internal_sigma_truth M hM hP hU hPow hS.bounded hR hI hc hoM ho G hG + φ (push v (push b e)) (env v hv)).mp hφ + obtain ⟨w,hw,hforcew⟩ := hbound b hbd p ⟨v,hv,hforce⟩ + have hwM := hM W hW _ hw + have hφw := (internal_sigma_truth M hM hP hU hPow hS.bounded hR hI hc hoM ho G hG + φ (push w (push b e)) (env w hwM)).mpr ⟨p,hp,hforcew⟩ + rw [values w] at hφw + exact ⟨w.val G.carrier,hcover w hw,hφw⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/FiniteClosure.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/FiniteClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..fee9c1afdcf1e49d6d8cef0de2f3c7b55d848cbc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/FiniteClosure.lean @@ -0,0 +1,86 @@ +import OAI.Computability.DegreeRigidity.Effective.TupleRelation + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace FiniteTuple + +def Closed (n : ℕ) (g h : ZFSet.{u}) : Prop := + ∀ xs : List ZFSet.{u}, xs.length = n → (∀ x ∈ xs, x ∈ h) → + ∀ y, ZFSet.pair (code xs) y ∈ g → y ∈ h + +def memberPrefix : ℕ → ℕ → Formula + | 0,_ => .equal 0 0 + | n+1,h => .conj (memberPrefix n h) (.member n h) + +theorem eval_memberPrefix (n h : ℕ) (e : ℕ → ZFSet.{u}) : + (memberPrefix n h).Eval e ↔ ∀ i, i < n → e i ∈ e h := by + induction n with + | zero => simp [memberPrefix,Formula.Eval] + | succ n ih => + simp only [memberPrefix,Formula.Eval,ih] + constructor + · rintro ⟨ha,hb⟩ i hi + rcases Nat.lt_succ_iff_lt_or_eq.mp hi with hi|rfl + · exact ha i hi + · exact hb + · intro ha; exact ⟨fun i hi => ha i (Nat.lt_succ_of_lt hi),ha n (Nat.lt_succ_self n)⟩ + +theorem prepend_members (xs : List ZFSet.{u}) (e : ℕ → ZFSet.{u}) (h : ZFSet.{u}) : + (∀ i, i < xs.length → prepend xs e i ∈ h) ↔ ∀ x ∈ xs, x ∈ h := by + induction xs with + | nil => simp + | cons x xs ih => + constructor + · intro ha y hy + rcases List.mem_cons.mp hy with rfl|hy + · exact ha 0 (Nat.zero_lt_succ _) + · exact ih.mp (fun i hi => ha (i+1) (Nat.succ_lt_succ hi)) y hy + · intro ha i hi + cases i with + | zero => exact ha x (by simp) + | succ i => exact ih.mpr (fun y hy => ha y (by simp [hy])) i (Nat.lt_of_succ_lt_succ hi) + +def closedFormula (n a d c z g h : ℕ) : Formula := + .allMem a (.allMem (d+1) (.imp (.pairMem 1 0 (g+2)) + (.imp (unpack n 1 (c+2) (z+2) (memberPrefix n (n+h+2))) (.member 0 (h+2))))) + +theorem eval_closedFormula (n a d c z g h : ℕ) (e : ℕ → ZFSet.{u}) + (ha : e a = space (e d) n) (hc : Transitive (e c)) + (hac : space (e d) n ⊆ e c) (hz : e z = ∅) + (hg : e g ⊆ ZFSet.prod (space (e d) n) (e d)) (hh : e h ⊆ e d) : + (closedFormula n a d c z g h).Eval e ↔ Closed n (e g) (e h) := by + simp only [closedFormula,Formula.eval_allMem,Formula.eval_imp,Formula.eval_pairMem, + Formula.Eval,cons_zero,cons_succ,ha] + have decode (xs : List ZFSet.{u}) (hlen : xs.length = n) (hxs : ∀ x ∈ xs, x ∈ e d) + (y : ZFSet.{u}) : + (unpack n 1 (c+2) (z+2) (memberPrefix n (n+h+2))).Eval (cons y (cons (code xs) e)) ↔ + ∀ x ∈ xs, x ∈ e h := by + subst n + rw [eval_unpack xs 1 (c+2) (z+2) _ _ rfl hc (hac (code_mem_space _ xs hxs)) hz, + eval_memberPrefix] + have hp : prepend xs (cons y (cons (code xs) e)) (xs.length+h+2) = e h := by + rw [show xs.length+h+2 = xs.length+(h+2) by omega,prepend_tail] + rfl + rw [hp] + exact prepend_members xs _ _ + constructor + · intro hf xs hlen hxs y hy + have hxd : ∀ x ∈ xs, x ∈ e d := fun x hx => hh (hxs x hx) + have hyD : y ∈ e d := by + obtain ⟨t,_,v,hv,hp⟩ := ZFSet.mem_prod.mp (hg hy) + obtain ⟨_,rfl⟩ := ZFSet.pair_inj.mp hp + exact hv + have ht : code xs ∈ space (e d) n := hlen ▸ code_mem_space _ xs hxd + exact hf _ ht y hyD hy ((decode xs hlen hxd y).mpr hxs) + · intro hf t ht y _ hty hhx + obtain ⟨xs,hlen,hxs,rfl⟩ := (mem_space (e d) t n).mp ht + exact hf xs hlen ((decode xs hlen hxs y).mp hhx) y hty + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/FiniteOrdinalCode.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/FiniteOrdinalCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..22cd0b3af3db8b71f557a670b4c1e92b09e5c85b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/FiniteOrdinalCode.lean @@ -0,0 +1,102 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalPairCode + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +universe u + +noncomputable def vectorCode : {n : ℕ} → (Fin n → Ordinal.{u}) → Ordinal.{u} + | 0, _ => 1 + | _+1, v => pairCode (v 0) (vectorCode (fun i => v i.succ)) + +noncomputable def vectorDecode : (n : ℕ) → Ordinal.{u} → Fin n → Ordinal.{u} + | 0, _, i => Fin.elim0 i + | n+1, a, i => Fin.cases (unpairCode a).1 + (vectorDecode n (unpairCode a).2) i + +theorem vectorDecode_vectorCode {n : ℕ} (v : Fin n → Ordinal.{u}) : + vectorDecode n (vectorCode v) = v := by + induction n with + | zero => funext i; exact Fin.elim0 i + | succ n ih => + funext i + refine Fin.cases ?_ (fun j => ?_) i + · simp only [vectorCode,vectorDecode,unpairCode_pairCode,Fin.cases_zero] + · simpa only [vectorCode,vectorDecode,unpairCode_pairCode,Fin.cases_succ] using + congrFun (ih (fun k => v k.succ)) j + +theorem vectorCode_injective (n : ℕ) : + Function.Injective (vectorCode (n := n) : (Fin n → Ordinal.{u}) → Ordinal.{u}) := by + intro v w h + have h' := congrArg (vectorDecode n) h + simpa only [vectorDecode_vectorCode] using h' + +theorem entry_lt_vectorCode {n : ℕ} (v : Fin n → Ordinal.{u}) (i : Fin n) : + v i < vectorCode v := by + induction n with + | zero => exact Fin.elim0 i + | succ n ih => + refine Fin.cases ?_ (fun j => ?_) i + · exact left_lt_pairCode _ _ + · exact (ih (fun k => v k.succ) j).trans (right_lt_pairCode _ _) + +theorem vectorCode_pos {n : ℕ} (v : Fin n → Ordinal.{u}) : 0 < vectorCode v := by + cases n with + | zero => exact zero_lt_one + | succ n => exact (show 0 ≤ v 0 from zero_le).trans_lt (left_lt_pairCode _ _) + +noncomputable def paddedCode {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) : Ordinal.{u} := + pairCode β (vectorCode v) + +noncomputable def paddedDecode (n : ℕ) (a : Ordinal.{u}) : Fin n → Ordinal.{u} := + vectorDecode n (unpairCode a).2 + +theorem paddedDecode_paddedCode {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) : + paddedDecode n (paddedCode v β) = v := by + simp only [paddedDecode,paddedCode,unpairCode_pairCode,vectorDecode_vectorCode] + +theorem padding_recovered {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) : + (unpairCode (paddedCode v β)).1 = β := by + simp only [paddedCode,unpairCode_pairCode] + +theorem padding_lt_paddedCode {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) : + β < paddedCode v β := left_lt_pairCode _ _ + +theorem entry_lt_paddedCode {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) (i : Fin n) : + v i < paddedCode v β := (entry_lt_vectorCode v i).trans (right_lt_pairCode _ _) + +theorem paddedCode_inj {n : ℕ} (v w : Fin n → Ordinal.{u}) (β γ : Ordinal.{u}) : + paddedCode v β = paddedCode w γ ↔ β = γ ∧ v = w := by + rw [paddedCode,paddedCode,pairCode_inj] + exact and_congr Iff.rfl (vectorCode_injective n).eq_iff + +theorem paddedCode_cofinal {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) : + ∃ a : Ordinal.{u}, β < a ∧ paddedDecode n a = v ∧ (∀ i, v i < a) := + ⟨paddedCode v β,padding_lt_paddedCode v β,paddedDecode_paddedCode v β, + entry_lt_paddedCode v β⟩ + +theorem pairCode_isSuccLimit (x y : Ordinal.{u}) (hx : 0 < x) (hy : 0 < y) : + Order.IsSuccLimit (pairCode x y) := by + unfold pairCode + split + · exact Ordinal.isSuccLimit_add _ (Ordinal.isSuccLimit_opow_left + Ordinal.isSuccLimit_omega0 (ne_of_gt hy)) + · exact Ordinal.isSuccLimit_add _ (Ordinal.isSuccLimit_opow_left + Ordinal.isSuccLimit_omega0 (ne_of_gt hx)) + +theorem paddedCode_isSuccLimit {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hβ : 0 < β) : Order.IsSuccLimit (paddedCode v β) := + pairCode_isSuccLimit β (vectorCode v) hβ (vectorCode_pos v) + +theorem finite_margin_lt_paddedCode {n : ℕ} (v : Fin n → Ordinal.{u}) (β c : Ordinal.{u}) + (hβ : 0 < β) (hc : c < paddedCode v β) (k : ℕ) : + c + (k : Ordinal.{u}) < paddedCode v β := by + induction k with + | zero => simpa only [Nat.cast_zero,add_zero] using hc + | succ k ih => + have h := (paddedCode_isSuccLimit v β hβ).succ_lt ih + simpa only [Order.succ_eq_add_one,Nat.cast_add,Nat.cast_one,add_assoc] using h + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/FinitePresentation.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/FinitePresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..319c2c1f14b176fe198c0a24101f46e913c7277d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/FinitePresentation.lean @@ -0,0 +1,37 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.TrimmedPresentation + +namespace OAI + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory ElementaryModel RelativeConstructible OrdinalArithmetic +universe u + +theorem presentation_graph_at_successor_of_pairs (R : ZFSet.{u}) (γ : Ordinal.{u}) + (d r : ZFSet.{u}) (o : Ordinal.{u}) + (j : ZFSet.{u} → ZFSet.{u}) + (hpairs : ∀ x ∈ d, ZFSet.pair x (j x) ∈ level R γ) + (hj : ∀ x ∈ d, j x ∈ o.toZFSet) + (hs : ∀ z ∈ o.toZFSet, ∃ x ∈ d, j x = z) + (he : ∀ x ∈ d, ∀ y ∈ d, ZFSet.pair x y ∈ r ↔ j x ∈ j y) + (p : SentenceForm) (e : ℕ → ZFSet.{u}) (henv : ∀ i, e i ∈ level R γ) + (hp : ∀ z ∈ level R γ, p.Sat (level R γ : Set ZFSet) (cons z e) ↔ + ∃ x ∈ d, z = ZFSet.pair x (j x)) : + ∃ f ∈ level R (γ+1), OrderTypeCertificate d r o.toZFSet f := by + let A := level R γ + let f := A.sep (fun z => p.Sat (A : Set ZFSet) (cons z e)) + have hf : f ∈ level R (γ+1) := by + rw [level_succ] + exact separation_mem_definablePower A p e (fun i _ => henv i) + have hexact (z : ZFSet.{u}) : z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (j x) := by + change z ∈ A.sep _ ↔ _ + rw [ZFSet.mem_sep] + constructor + · rintro ⟨hz,h⟩; exact (hp z hz).mp h + · rintro ⟨x,hx,rfl⟩ + have hz := hpairs x hx + exact ⟨hz,(hp _ hz).mpr ⟨x,hx,rfl⟩⟩ + exact ⟨f,hf,order_certificate_of_exact_pairs d r f o j hj hs he hexact⟩ + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/FiniteSkolem.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/FiniteSkolem.lean new file mode 100644 index 0000000000000000000000000000000000000000..59678e96954c61fddc58a434f85f3a2cb4dba260 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/FiniteSkolem.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.Effective.TupleRelation +import OAI.Computability.DegreeRigidity.SetModels.InternalUniformization + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace FiniteTuple + +noncomputable def requests (d : ZFSet.{u}) (n : ℕ) (r : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun t => ∃ y ∈ d, ZFSet.pair t y ∈ r) (space d n) + +theorem requests_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) {d r : ZFSet.{u}} (hd : d ∈ M) (hr : r ∈ M) (n : ℕ) : + requests d n r ∈ M := by + simpa only [requests,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ] using + sep_mem M hM hS (.existsMem 1 (.pairMem 1 0 3)) + (cons d (fun _ => r)) (by intro i; cases i <;> assumption) + (space_mem M hM hP hU hPow hS hd n) + +def SkolemGraph (d : ZFSet.{u}) (n : ℕ) (φ : Formula) + (e : ℕ → ZFSet.{u}) (g : ZFSet.{u}) : Prop := + g ⊆ relation d n φ e ∧ + ∀ xs : List ZFSet.{u}, xs.length = n → (∀ x ∈ xs, x ∈ d) → + (∃ y ∈ d, φ.Eval (cons y (prepend xs e))) → + ∃ y ∈ d, ZFSet.pair (code xs) y ∈ g ∧ + ∀ z ∈ d, ZFSet.pair (code xs) z ∈ g → z = y + +theorem internal_skolem_graph (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) + {d : ZFSet.{u}} (hd : d ∈ M) (n : ℕ) (φ : Formula) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + ∃ g ∈ M, SkolemGraph d n φ e g := by + have hr := relation_mem M hM hP hU hPow hS hR hI hd n φ e he + have ha := requests_mem M hM hP hU hPow hS hd hr n + obtain ⟨g,hg,hgr,_,hsel⟩ := internal_relation_choice M hM hP hU hPow hS hAC ha hd hr + (fun t ht => (ZFSet.mem_sep.mp ht).2) + refine ⟨g,hg,hgr,?_⟩ + intro xs hlen hxs hw + subst n + have ht : code xs ∈ requests d xs.length (relation d xs.length φ e) := by + obtain ⟨y,hy,hφ⟩ := hw + exact ZFSet.mem_sep.mpr ⟨code_mem_space d xs hxs,y,hy, + (relation_pair d y xs φ e).mpr ⟨hxs,hy,hφ⟩⟩ + exact hsel _ ht + +theorem SkolemGraph.correct {d g : ZFSet.{u}} {n : ℕ} {φ : Formula} + {e : ℕ → ZFSet.{u}} (hg : SkolemGraph d n φ e g) + (xs : List ZFSet.{u}) (hlen : xs.length = n) {y : ZFSet.{u}} + (hy : ZFSet.pair (code xs) y ∈ g) : + (∀ x ∈ xs, x ∈ d) ∧ y ∈ d ∧ φ.Eval (cons y (prepend xs e)) := by + subst n + exact (relation_pair d y xs φ e).mp (hg.1 hy) + +theorem SkolemGraph.functional {d g : ZFSet.{u}} {n : ℕ} {φ : Formula} + {e : ℕ → ZFSet.{u}} (hg : SkolemGraph d n φ e g) + (xs : List ZFSet.{u}) (hlen : xs.length = n) {y z : ZFSet.{u}} + (hy : ZFSet.pair (code xs) y ∈ g) (hz : ZFSet.pair (code xs) z ∈ g) : y = z := by + have hy' := hg.correct xs hlen hy + have hz' := hg.correct xs hlen hz + obtain ⟨w,_,_,hu⟩ := hg.2 xs hlen hy'.1 ⟨y,hy'.2⟩ + exact (hu y hy'.2.1 hy).trans (hu z hz'.2.1 hz).symm + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/FiniteSupport.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/FiniteSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..a85628a168748267d6b19b45fecff5b7ca65c2d7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/FiniteSupport.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.Effective.GuardedPair + +namespace OAI + +namespace TuringRigidity.FiniteSupport +open ArithmeticHierarchy Encodable EncodedForcing CodingForcing UniformProgram IndexMatrix + +theorem codingLocation_iff {F H : ℕ → Oracle} {p : Condition} + (h : ∀ k, k < p.active → F k = H k) (m : ℕ) : + CodingLocation F p m ↔ CodingLocation H p m := by + constructor + · rintro ⟨hl,hk,ha⟩ + exact ⟨hl,hk,by rwa [← h _ hk]⟩ + · rintro ⟨hl,hk,ha⟩ + exact ⟨hl,hk,by rwa [h _ hk]⟩ + +theorem extends_iff {F H : ℕ → Oracle} {p : Condition} + (h : ∀ k, k < p.active → F k = H k) (q : Condition) : + Extends F p q ↔ Extends H p q := by + constructor + · rintro ⟨hl,hr,hk,hc⟩ + exact ⟨hl,hr,hk,fun m hm hn => hc m ((codingLocation_iff h m).mpr hm) hn⟩ + · rintro ⟨hl,hr,hk,hc⟩ + exact ⟨hl,hr,hk,fun m hm hn => hc m ((codingLocation_iff h m).mp hm) hn⟩ + +theorem run_eq {A B : Oracle} {x : ℕ} + (hb : OracleCode.eval (oracleFunction A) (meaning (machine (item x 0))) = + OracleCode.eval (oracleFunction B) (meaning (machine (item x 0)))) + (i : ℕ) (s : List Bool) (n : ℕ) : + UniformRun.run A (machine (item x 0)) (machine (item x i)) s n = + UniformRun.run B (machine (item x 0)) (machine (item x i)) s n := by + simp only [UniformRun.run,hb] + +theorem noDisagreement_iff {A B : Oracle} {x : ℕ} {p : Condition} + (hb : OracleCode.eval (oracleFunction A) (meaning (machine (item x 0))) = + OracleCode.eval (oracleFunction B) (meaning (machine (item x 0)))) + (hc : ∀ k, k < p.active → columns A k = columns B k) : + UniformAgreement.NoDisagreement A x p ↔ UniformAgreement.NoDisagreement B x p := by + have hd (q : Condition) : UniformAgreement.Disagreement A x q ↔ UniformAgreement.Disagreement B x q := by + simp only [UniformAgreement.Disagreement,run_eq hb] + simp only [UniformAgreement.NoDisagreement,extends_iff hc,hd] + +theorem badCert_iff {A B : Oracle} {x : ℕ} {p : Condition} + (hb : OracleCode.eval (oracleFunction A) (meaning (machine (item x 0))) = + OracleCode.eval (oracleFunction B) (meaning (machine (item x 0)))) + (hc : ∀ k, k < p.active → columns A k = columns B k) (w : ℕ) : + GuardedPair.BadCert A (Nat.pair (Nat.pair x (code p)) w) ↔ + GuardedPair.BadCert B (Nat.pair (Nat.pair x (code p)) w) := by + have hp : UniformSplit.PointCert A (Nat.pair (UniformPair.request (Nat.pair x (code p))) w) ↔ + UniformSplit.PointCert B (Nat.pair (UniformPair.request (Nat.pair x (code p))) w) := by + simp only [item] at hb + simp only [UniformSplit.PointCert,UniformSplit.start,UniformSplit.base,UniformSplit.program, + UniformPair.request,item,encodek,Option.getD_some,List.getD_cons_zero,List.getD_cons_succ, + Nat.unpair_pair,UniformRun.run,hb] + simp only [GuardedPair.BadCert,Nat.unpair_pair,UniformPair.IsCoding,condition_code,hp, + codingLocation_iff hc] + +theorem noBad_iff {A B : Oracle} {x : ℕ} {p : Condition} + (hb : OracleCode.eval (oracleFunction A) (meaning (machine (item x 0))) = + OracleCode.eval (oracleFunction B) (meaning (machine (item x 0)))) + (hc : ∀ k, k < p.active → columns A k = columns B k) : + GuardedPair.NoBad A x p ↔ GuardedPair.NoBad B x p := by + simp only [GuardedPair.NoBad,badCert_iff hb hc] + +end TuringRigidity.FiniteSupport + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/FixedArithmetic.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/FixedArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..b226f97f44a04008a40f79b24bb57919cccca16b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/FixedArithmetic.lean @@ -0,0 +1,74 @@ +import OAI.Computability.DegreeRigidity.Effective.EffectivePresentation +import OAI.Computability.DegreeRigidity.Effective.CodingBounds + +namespace OAI + +namespace TuringRigidity.FixedArithmetic +open Encodable EncodedForcing ArithmeticHierarchy UniformOracle OracleJump +open ArithmeticModelDecoding SetCoding RelationCoding BoundedDecoding + +def zero : Oracle := fun _ => false + +theorem low_columns : ∃ C : Oracle, + Reduces C (jump zero) ∧ Reduces (jump C) (jump zero) ∧ + Function.Injective (fun k => degree (columns C k)) := by + obtain ⟨C,hC,hlow,hind⟩ := CohenColumns.uniform_low_independent zero + refine ⟨C,hC,?_,?_⟩ + · have h : degree (jump C) ≤ degree (jump (join zero C)) := jump_mono (reduces_join_right zero C) + change degree (jump C) ≤ degree (jump zero) + rw [← hlow] + exact h + · intro i j he + have h := (hind ⊥ ⊥ bot_le bot_le i {j}).mp (by simpa using he.le) + simpa only [Finset.mem_singleton] using h.2 + +def rows (C : Oracle) : Oracle := fun v => + C (Nat.pair (if (Nat.unpair (Nat.unpair v).1).1 = 0 then (Nat.unpair (Nat.unpair v).1).2 + else (Nat.unpair (Nat.unpair v).1).2+1) (Nat.unpair v).2) + +theorem rows_reduces (C : Oracle) : Reduces (rows C) C := by + let f := Primrec.fst.comp Primrec.unpair + let r := Primrec.snd.comp Primrec.unpair + exact EffectiveFamilies.reindex_reduces C (Primrec₂.natPair.comp + (Primrec.ite (Primrec.eq.comp (f.comp f) (Primrec.const 0)) (r.comp f) (Primrec.succ.comp (r.comp f))) r) + +@[simp] theorem row_zero (C : Oracle) (k : ℕ) : columns (rows C) (Nat.pair 0 k) = columns C k := by + funext n + simp [columns,rows] + +@[simp] theorem row_one (C : Oracle) (k : ℕ) : columns (rows C) (Nat.pair 1 k) = columns C (k+1) := by + funext n + simp [columns,rows] + +theorem successor_code (C : Oracle) : ∃ p : RelationCode 2, + RelationBelow p (degree (jump C)) ∧ ∀ a b, + p.Holds (two a b) ↔ ∃ k, a = degree (columns C k) ∧ b = degree (columns C (k+1)) := by + have hP : RecursivePred (rows C) (fun _ => True) := by + exact (total_primrec (Primrec.const 1)).of_eq (fun n => by simp) + obtain ⟨p,hp,hcode⟩ := EffectivePresentation.effective_coding (rows C) (fun _ => True) hP 2 + refine ⟨p,hp.mono (jump_mono (rows_reduces C)),fun a b => ?_⟩ + rw [hcode] + constructor + · rintro ⟨k,_,hk⟩ + exact ⟨k,by simpa [two] using (hk 0).symm,by simpa [two] using (hk 1).symm⟩ + · rintro ⟨k,rfl,rfl⟩ + refine ⟨k,trivial,fun i => ?_⟩ + fin_cases i <;> simp [two] + +structure Frame where + C : Oracle + low : Reduces (jump C) (jump zero) + injective : Function.Injective (fun k => degree (columns C k)) + successor : RelationCode 2 + below : RelationBelow successor (degree (jump zero)) + spec : ∀ a b, successor.Holds (two a b) ↔ + ∃ k, a = degree (columns C k) ∧ b = degree (columns C (k+1)) + +theorem frame_exists : Nonempty Frame := by + obtain ⟨C,_,hlow,hinj⟩ := low_columns + obtain ⟨S,hS,hs⟩ := successor_code C + exact ⟨⟨C,hlow,hinj,S,hS.mono hlow,hs⟩⟩ + +end TuringRigidity.FixedArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/FixedArithmeticTailCone.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/FixedArithmeticTailCone.lean new file mode 100644 index 0000000000000000000000000000000000000000..e08129697658e029d4c40ed028da9f075683f663 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/FixedArithmeticTailCone.lean @@ -0,0 +1,114 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticOutputSyntax +import OAI.Computability.DegreeRigidity.Syntax.DefinedOutputTailCone + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open CohenGroundPoset InternalCohenRestriction InternalCohenProjectedGeneric +open InternalCohenProjectionSymmetry InternalCohenFactor OracleJump TableIndices IndexMatrix +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem fixed_arithmetic_tail_cone (M C B : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hct : (M : Set ZFSet.{0}).Countable) + (hC : C ∈ M) (hB : B ∈ M) (hBC : B ⊆ C) + (x y : Name (Conditions (conditions C))) + (hx : x.encode (label (conditions C)) ∈ M) + (hy : y.encode (label (conditions C)) ∈ M) + (hxfix : ∀ a : Conditions (conditions C) ≃o Conditions (conditions C), + (∀ s, restrict B (label _ (a s)) = restrict B (label _ s)) → + ∀ H : GenericFilter (Conditions (conditions C)), + x.val (AutomorphismName.mapFilter a H).carrier = x.val H.carrier) + (hyfix : ∀ a : Conditions (conditions C) ≃o Conditions (conditions C), + (∀ s, restrict B (label _ (a s)) = restrict B (label _ s)) → + ∀ H : GenericFilter (Conditions (conditions C)), + y.val (AutomorphismName.mapFilter a H).carrier = y.val H.carrier) + (R : Oracle) (hR : realCode R ∈ M) (d k : ℕ) + (G : GenericFilter (Conditions (conditions C))) (hG : GroundGeneric M G) + (A X : Oracle) (hxv : x.val G.carrier = realCode A) (hyv : y.val G.carrier = realCode X) + (hprog : Represents (iterate (join A R) k) (machine d) X) + (p₀ : Conditions (conditions C)) (hp₀ : p₀ ∈ G.carrier) : + ∃ p ∈ G.carrier, p ≤ p₀ ∧ + ∀ H : GenericFilter (Conditions (conditions C)), GroundGeneric M H → + project C B hBC p ∈ (projected C B hBC H).carrier → + ∃ A' X' : Oracle, x.val H.carrier = realCode A' ∧ y.val H.carrier = realCode X' ∧ + Represents (iterate (join A' R) k) (machine d) X' := by + have hc := conditions_mem M C hM hT hC + have ho := InternalCollapse.orderSet_mem M hM hT hc + have ht (H : GenericFilter (Conditions (conditions C))) : ⊤ ∈ H.carrier := by + obtain ⟨q,hq⟩ := H.nonempty; exact H.upper le_top hq + have hω := sourceT_omega_mem M hM hT + have hz : natSet.{0} 0 ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨0,rfl⟩) + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union + hT.powerSet hT.separation.finitePrefix.bounded hω + have hcheck {z : ZFSet.{0}} (hz : z ∈ M) : + (Name.check z : Name (Conditions (conditions C))).encode (label (conditions C)) ∈ M := + encoded_check_mem M _ hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc hz + obtain ⟨φ,hφ⟩ := ExtensionArithmeticRepresentative.fixed_output_bounded d k + let ψ : BoundedSetTheory.Formula := .conj (.subset 3 1) (.conj (.subset 5 1) φ) + let e := push (Name.check (natSet 0)) (push (Name.check ZFSet.omega) + (push (Name.check Q) (push x (push (Name.check (realCode R)) (fun _ => y))))) + have he (i : ℕ) : (e i).encode (label (conditions C)) ∈ M := by + rcases i with _|_|_|_|_|i + exact hcheck hz; exact hcheck hω; exact hcheck hQM; exact hx; exact hcheck hR; exact hy + have hev (H : GenericFilter (Conditions (conditions C))) : (fun i => (e i).val H.carrier) = + cons (natSet 0) (cons ZFSet.omega (cons Q + (cons (x.val H.carrier) (cons (realCode R) (fun _ => y.val H.carrier))))) := by + funext i; rcases i with _|_|_|_|_|i + exact Name.val_check _ (ht H) _ + exact Name.val_check _ (ht H) _ + exact Name.val_check _ (ht H) _ + rfl + exact Name.val_check _ (ht H) _ + rfl + have hspec (A' X' : Oracle) : + φ.Eval (cons (natSet 0) (cons ZFSet.omega (cons Q + (cons (realCode A') (cons (realCode R) (fun _ => realCode X')))))) ↔ + Represents (iterate (join A' R) k) (machine d) X' := by + have henv : arithmeticEnv Q (push A' (push R (fun _ => X'))) 0 = + cons (natSet 0) (cons ZFSet.omega (cons Q + (cons (realCode A') (cons (realCode R) (fun _ => realCode X'))))) := by + funext i; rcases i with _|_|_|_|_|i <;> rfl + simpa only [henv,push] using hφ Q hQ (push A' (push R (fun _ => X'))) 0 + have meaning (H : GenericFilter (Conditions (conditions C))) : + ψ.Eval (fun i => (e i).val H.carrier) ↔ + ∃ A' X' : Oracle, x.val H.carrier = realCode A' ∧ y.val H.carrier = realCode X' ∧ + Represents (iterate (join A' R) k) (machine d) X' := by + rw [hev H] + simp only [ψ,Formula.Eval,Formula.eval_subset,cons_zero,cons_succ] + constructor + · rintro ⟨hxs,hys,hformula⟩ + let A' := decodeReal (x.val H.carrier) + let X' := decodeReal (y.val H.carrier) + have hxa : x.val H.carrier = realCode A' := (realCode_decodeReal hxs).symm + have hya : y.val H.carrier = realCode X' := (realCode_decodeReal hys).symm + refine ⟨A',X',hxa,hya,?_⟩ + rw [hxa,hya] at hformula + exact (hspec A' X').mp hformula + · rintro ⟨A',X',hxa,hya,hpr⟩ + rw [hxa,hya] + exact ⟨realCode_subset A',realCode_subset X', + (hspec A' X').mpr hpr⟩ + have hinv : ∀ w ∈ M, ∀ a : Conditions (conditions C) ≃o Conditions (conditions C), + (∀ s t, ZFSet.pair (label _ s) (label _ t) ∈ w ↔ t = a s) → + (∀ s, restrict B (label _ (a s)) = restrict B (label _ s)) → + ∀ H : GenericFilter (Conditions (conditions C)), GroundGeneric M H → + (ψ.Eval (fun i => (e i).val (AutomorphismName.mapFilter a H).carrier) ↔ + ψ.Eval (fun i => (e i).val H.carrier)) := by + intro w hw a ha hfix H hH + rw [hev _,hev H,hxfix a hfix H,hyfix a hfix H] + have hv := (meaning G).mpr ⟨A,X,hxv,hyv,hprog⟩ + obtain ⟨r,hr,hrφ⟩ := (internal_bounded_truth M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc ho + (InternalCollapse.orderSet_pair _) G hG ψ e he).mp hv + obtain ⟨p,hp,hp₀',hpr⟩ := G.directed hp₀ hr + refine ⟨p,hp,hp₀',?_⟩ + intro H hH hpH + exact (meaning H).mp (cone_truth_of_internal_tail_symmetry M C B hM hT hct hC hB hBC + ψ e he hinv p (forces_mono _ e hpr hrφ) H hH ((projected_cone_iff C B hBC H p).mp hpH)) + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/FragmentHull.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/FragmentHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e7e4632b5056132434223550b573b61e84f9683 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/FragmentHull.lean @@ -0,0 +1,130 @@ +import OAI.Computability.DegreeRigidity.Syntax.FiniteFragment +import OAI.Computability.DegreeRigidity.SetModels.FiniteSkolem +import OAI.Computability.DegreeRigidity.SetModels.SkolemHull +import OAI.Computability.DegreeRigidity.SetModels.InternalStructureCollapse + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace FiniteTuple + +theorem internal_skolem_family (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) + {d : ZFSet.{u}} (hd : d ∈ M) (n : ℕ) (fs : List Formula) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + ∃ g ∈ M, g ⊆ ZFSet.prod (space d n) d ∧ + ∀ φ ∈ fs, ∃ f ∈ M, f ⊆ g ∧ SkolemGraph d n φ e f := by + induction fs with + | nil => + have h0 : (∅ : ZFSet.{u}) ∈ M := hM _ (omega_mem M hM hS hI) _ ZFSet.omega_zero + exact ⟨∅,h0,by simp,by simp⟩ + | cons φ fs ih => + obtain ⟨g,hg,hgp,hgs⟩ := ih + obtain ⟨f,hf,hfg⟩ := internal_skolem_graph M hM hP hU hPow hS hR hI hAC hd n φ e he + refine ⟨f ∪ g,binary_union_mem M hM hP hU hf hg,?_,?_⟩ + · intro z hz + rcases ZFSet.mem_union.mp hz with hz|hz + · exact (ZFSet.mem_sep.mp (hfg.1 hz)).1 + · exact hgp hz + · intro ψ hψ + rcases List.mem_cons.mp hψ with rfl|hψ + · exact ⟨f,hf,fun z hz => ZFSet.mem_union.mpr (Or.inl hz),hfg⟩ + · obtain ⟨v,hv,hvg,hvφ⟩ := hgs ψ hψ + exact ⟨v,hv,fun z hz => ZFSet.mem_union.mpr (Or.inr (hvg hz)),hvφ⟩ + +theorem closed_witnesses (d h g : ZFSet.{u}) (n : ℕ) (φ : Formula) + (hn : φ.width ≤ n) (hhd : h ⊆ d) (hcl : Closed n g h) + (hgs : ∀ ψ ∈ fragment n φ, ∃ f, f ⊆ g ∧ SkolemGraph d n ψ (fun _ => d) f) : + Witnesses d h φ := by + intro i ψ hm e he hw + have hbounds := occurrence_width φ i ψ hm + have hin : i < n := lt_of_lt_of_le hbounds.1 hn + have hψn : ψ.scope ≤ n+1 := by omega + have hbmem : witnessBody n i ψ ∈ fragment n φ := List.mem_map.mpr ⟨(i,ψ),hm,rfl⟩ + obtain ⟨f,hfg,hf⟩ := hgs _ hbmem + let xs := takeEnv n e + have hxs : ∀ x ∈ xs, x ∈ h := takeEnv_mem n e h he + have hxsd : ∀ x ∈ xs, x ∈ d := fun x hx => hhd (hxs x hx) + have hlen : xs.length = n := length_takeEnv n e + have hsuccess : ∃ y ∈ d, (witnessBody n i ψ).Eval (cons y (prepend xs (fun _ => d))) := by + obtain ⟨y,hy,hyi,hψ⟩ := hw + exact ⟨y,hy,(eval_witnessBody n i ψ hin hψn d y e).mpr ⟨hyi,hψ⟩⟩ + obtain ⟨y,_,hy,_⟩ := hf.2 xs hlen hxsd hsuccess + have hyh := hcl xs hlen hxs y (hfg hy) + have hb := (hf.correct xs hlen hy).2.2 + exact ⟨y,hyh,(eval_witnessBody n i ψ hin hψn d y e).mp hb⟩ + +def differenceBody : Formula := .neg (.iff (.member 0 1) (.member 0 2)) + +theorem eval_differenceBody (x y z : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + differenceBody.Eval (cons z (cons x (cons y e))) ↔ ¬ (z ∈ x ↔ z ∈ y) := by + simp only [differenceBody,Formula.Eval,Formula.eval_iff,cons_zero,cons_succ] + +theorem closed_extensional (d h g : ZFSet.{u}) (n : ℕ) (hn : 2 ≤ n) + (hd : Transitive d) (hhd : h ⊆ d) (hcl : Closed n g h) + (hgs : ∃ f, f ⊆ g ∧ SkolemGraph d n differenceBody (fun _ => d) f) : + RelationCollapse.StructureExtensional h := by + classical + intro x hx y hy hext + by_contra hne + have hdiff : ∃ z, ¬ (z ∈ x ↔ z ∈ y) := by + by_contra hnz + apply hne + apply ZFSet.ext; intro z + exact Classical.byContradiction (fun hz => hnz ⟨z,hz⟩) + obtain ⟨z,hz⟩ := hdiff + have hzd : z ∈ d := by + by_cases hzx : z ∈ x + · exact hd x (hhd hx) z hzx + · have hzy : z ∈ y := by + by_contra hzy + exact hz ⟨fun h => False.elim (hzx h),fun h => False.elim (hzy h)⟩ + exact hd y (hhd hy) z hzy + let e := cons x (cons y (fun _ => x)) + let xs := takeEnv n e + have heh : ∀ i, e i ∈ h := by + intro i; rcases i with _|i; exact hx + rcases i with _|i; exact hy + exact hx + have hxs : ∀ v ∈ xs, v ∈ h := takeEnv_mem n e h heh + have hlen : xs.length = n := length_takeEnv n e + have eval (v : ZFSet.{u}) : differenceBody.Eval (cons v (prepend xs (fun _ => d))) ↔ + ¬ (v ∈ x ↔ v ∈ y) := by + simp only [differenceBody,Formula.Eval,Formula.eval_iff,cons_zero,cons_succ] + rw [takeEnv_agree n e _ 0 (by omega),takeEnv_agree n e _ 1 (by omega)] + rfl + obtain ⟨f,hfg,hf⟩ := hgs + obtain ⟨v,_,hv,_⟩ := hf.2 xs hlen (fun v hv => hhd (hxs v hv)) ⟨z,hzd,(eval z).mpr hz⟩ + have hvh := hcl xs hlen hxs v (hfg hv) + exact (eval v).mp (hf.correct xs hlen hv).2.2 (hext v hvh) + +theorem internal_fragment_hull (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) + {d s : ZFSet.{u}} (hdM : d ∈ M) (hsM : s ∈ M) (hd : Transitive d) + (hsd : s ⊆ d) (φ : Formula) : + ∃ h ∈ M, s ⊆ h ∧ h ⊆ d ∧ RelationCollapse.StructureExtensional h ∧ + ∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ h) → (φ.Realize h e ↔ φ.Realize d e) := by + let n := max 2 φ.width + obtain ⟨g,hg,hgp,hgs⟩ := internal_skolem_family M hM hP hU hPow hS hR hI hAC hdM n + (differenceBody :: fragment n φ) (fun _ => d) (fun _ => hdM) + obtain ⟨h,hh,hsh,hhd,hcl,_⟩ := internal_finite_hull M hM hP hU hPow hS hR hI hdM hsM hg n hsd hgp + have hext := closed_extensional d h g n (Nat.le_max_left _ _) hd hhd hcl (by + obtain ⟨f,_,hfg,hf⟩ := hgs differenceBody List.mem_cons_self + exact ⟨f,hfg,hf⟩) + refine ⟨h,hh,hsh,hhd,hext,?_⟩ + intro e he + apply realize_of_witnesses d h hhd φ _ e he + apply closed_witnesses d h g n φ (Nat.le_max_right _ _) hhd hcl + intro ψ hψ + obtain ⟨f,_,hfg,hf⟩ := hgs ψ (List.mem_cons_of_mem _ hψ) + exact ⟨f,hfg,hf⟩ + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/FullSetTruth.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/FullSetTruth.lean new file mode 100644 index 0000000000000000000000000000000000000000..a636738b07c921fa729271d0b62590ff6f08f517 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/FullSetTruth.lean @@ -0,0 +1,104 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.FullSetForcing + +namespace OAI + + +namespace TuringRigidity.FullSetForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +open ElementaryModel SentenceForm BoundedForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +def Decision (M : ZFSet.{u}) (e : ℕ → Name (Conditions c)) (φ : SentenceForm) : Set (Conditions c) := + {p | Forces M e φ p ∨ Forces M e (.neg φ) p} + +theorem decision_dense (M : ZFSet.{u}) (e : ℕ → Name (Conditions c)) (φ : SentenceForm) : + Dense (Decision M e φ) := by + classical + intro p + by_cases h : ∃ q, q ≤ p ∧ Forces M e φ q + · obtain ⟨q,hqp,hq⟩ := h; exact ⟨q,hqp,Or.inl hq⟩ + · exact ⟨p,le_rfl,Or.inr (fun q hq hf => h ⟨q,hq,hf⟩)⟩ + +theorem internal_decision (M : ZFSet.{u}) (hM : Transitive M) (hV : Valid M) + (hc : c ∈ M) {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (φ : SentenceForm) (e : ℕ → Name (Conditions c)) + (he : ∀ i, (e i).encode (label c) ∈ M) : + ∃ D ∈ M, ∀ q, label c q ∈ D ↔ q ∈ Decision M e φ := by + let env := cons c (cons o (fun i => (e i).encode (label c))) + have henv : ∀ i, env i ∈ M := by intro i; rcases i with _|_|i; exact hc; exact hoM; exact he i + let ψ := disj (code φ 1 2 0 (fun i => i+3)) (code (.neg φ) 1 2 0 (fun i => i+3)) + obtain ⟨D,hD,hdef⟩ := hV.separate ψ env henv c hc + refine ⟨D,hD,?_⟩ + intro q + have hqm := hM c hc _ (label_mem c q) + have sub (χ : SentenceForm) := realize_code M hM (hV.sourceT hM ⟨c,hc⟩) ho χ e q + (cons (label c q) env) (by intro i; cases i; exact hqm; exact henv _) + 1 2 0 (fun i => i+3) rfl rfl rfl (fun _ => rfl) + rw [hdef _ hqm] + simp only [label_mem c q,true_and,ψ,sat_disj,sub] + rfl + +theorem full_truth (M : ZFSet.{u}) (hM : Transitive M) (hV : Valid M) + (hc : c ∈ M) {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) + (φ : SentenceForm) (e : ℕ → Name (Conditions c)) + (he : ∀ i, (e i).encode (label c) ∈ M) : + φ.Sat (genericExtensionSet M c G.carrier : Set ZFSet) (fun i => (e i).val G.carrier) ↔ + ∃ p ∈ G.carrier, Forces M e φ p := by + have hT := hV.sourceT hM ⟨c,hc⟩ + have hS := hT.separation.finitePrefix.bounded + have hR := hT.replacement.finitePrefix + induction φ generalizing e with + | equal i j => + exact BoundedForcing.internal_bounded_truth M hM hT.pairing hT.union hT.powerSet hS hR hT.infinity + hc hoM ho G hG (.equal i j) e he + | member i j => + exact BoundedForcing.internal_bounded_truth M hM hT.pairing hT.union hT.powerSet hS hR hT.infinity + hc hoM ho G hG (.member i j) e he + | conj φ ψ ihφ ihψ => + constructor + · rintro ⟨hφ,hψ⟩ + obtain ⟨p,hp,hφ⟩ := (ihφ e he).mp hφ + obtain ⟨q,hq,hψ⟩ := (ihψ e he).mp hψ + obtain ⟨r,hr,hrp,hrq⟩ := G.directed hp hq + exact ⟨r,hr,forces_mono M φ e hrp hφ,forces_mono M ψ e hrq hψ⟩ + · rintro ⟨p,hp,hφ,hψ⟩ + exact ⟨(ihφ e he).mpr ⟨p,hp,hφ⟩,(ihψ e he).mpr ⟨p,hp,hψ⟩⟩ + | neg φ ih => + constructor + · intro hn + obtain ⟨D,hD,hdef⟩ := internal_decision M hM hV hc hoM ho φ e he + have hd : Dense {q | label c q ∈ D} := by + intro p; obtain ⟨q,hq,hf⟩ := decision_dense M e φ p + exact ⟨q,hq,(hdef q).mpr hf⟩ + obtain ⟨p,hp,hpd⟩ := hG D hD hd + rcases (hdef p).mp hpd with hf|hf + · exact False.elim (hn ((ih e he).mpr ⟨p,hp,hf⟩)) + · exact ⟨p,hp,hf⟩ + · rintro ⟨p,hp,hf⟩ htruth + obtain ⟨q,hq,hqf⟩ := (ih e he).mp htruth + obtain ⟨r,_,hrp,hrq⟩ := G.directed hp hq + exact hf r hrp (forces_mono M φ e hrq hqf) + | ex φ ih => + have hep (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) : + ∀ i, (push a e i).encode (label c) ∈ M := by + intro i; cases i; exact ha; exact he _ + have env (a : Name (Conditions c)) : (fun i => (push a e i).val G.carrier) = + cons (a.val G.carrier) (fun i => (e i).val G.carrier) := by funext i; cases i <;> rfl + constructor + · rintro ⟨x,hx,hφ⟩ + obtain ⟨a,ha,rfl⟩ := (mem_extensionSet M c G.carrier x).mp hx + rw [←env a] at hφ + obtain ⟨p,hp,hf⟩ := (ih _ (hep a ha)).mp hφ + exact ⟨p,hp,a,ha,hf⟩ + · rintro ⟨p,hp,a,ha,hf⟩ + refine ⟨a.val G.carrier,(mem_extensionSet M c G.carrier _).mpr ⟨a,ha,rfl⟩,?_⟩ + rw [←env a] + exact (ih _ (hep a ha)).mpr ⟨p,hp,hf⟩ + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/GeneratedBooleanPart.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/GeneratedBooleanPart.lean new file mode 100644 index 0000000000000000000000000000000000000000..70b7f2a563b5282affb70ac171fdce5ffb75527d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/GeneratedBooleanPart.lean @@ -0,0 +1,36 @@ +import OAI.Computability.DegreeRigidity.Syntax.BooleanProjection + +namespace OAI + +namespace TuringRigidity.GeneratedBooleanPart +open Set BooleanProjection +universe u +variable {B : Type u} [CompleteBooleanAlgebra B] + +def carrier (S : Set B) : Set B := + {b | ∀ A : CompleteSublattice B, (∀ a ∈ A, aᶜ ∈ A) → S ⊆ A → b ∈ A} + +noncomputable def generated (S : Set B) : CompleteSublattice B := + CompleteSublattice.mk' (carrier S) + (fun _ ht A hc hs => A.sSupClosed (fun _ hb => ht hb A hc hs)) + (fun _ ht A hc hs => A.sInfClosed (fun _ hb => ht hb A hc hs)) + +theorem subset_generated (S : Set B) : S ⊆ generated S := + fun _ hb _ _ hs => hs hb + +theorem generated_compl (S : Set B) (b : B) (hb : b ∈ generated S) : + bᶜ ∈ generated S := fun A hc hs => hc b (hb A hc hs) + +theorem generated_le (S : Set B) (A : CompleteSublattice B) + (hc : ∀ a ∈ A, aᶜ ∈ A) (hs : S ⊆ A) : generated S ≤ A := + fun _ hb => hb A hc hs + +theorem generated_mono {S T : Set B} (h : S ⊆ T) : generated S ≤ generated T := + generated_le S (generated T) (generated_compl T) (h.trans (subset_generated T)) + +theorem generated_congr {S T : Set B} (h : S = T) : generated S = generated T := + congrArg generated h + +end TuringRigidity.GeneratedBooleanPart + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/GeneratedHull.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/GeneratedHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0ed62a770ecbcb5f74482814a97126609c08eee --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/GeneratedHull.lean @@ -0,0 +1,111 @@ +import OAI.Computability.DegreeRigidity.SetModels.SkolemOperations + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse +universe u +namespace FiniteTerm + +theorem internal_leaf_graph (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hω : ZFSet.omega.{u} ∈ M) + {t : ZFSet.{u}} (ht : t ∈ M) (xs : List ZFSet.{u}) (hxs : ∀ x ∈ xs, x ∈ M) : + ∃ L ∈ M, Functional L ∧ ∀ x ∈ t ∪ FiniteTuple.elements xs, + ∃ a ∈ FiniteTuple.indexSpace t, ZFSet.pair a x ∈ L := by + have h0 : (∅ : ZFSet.{u}) ∈ M := hM _ hω _ ZFSet.omega_zero + have hs := binary_union_mem M hM hP hU ht (FiniteTuple.elements_mem M hM hP hU h0 xs hxs) + have hA := FiniteTuple.indexSpace_mem M hM hP hU hPow hS hω ht + obtain ⟨f,hf,hfg⟩ := FiniteTuple.internal_finite_extension_injection M hM hP hU hPow hS hR hω ht xs hxs + let L := inverseCover (FiniteTuple.indexSpace t) (t ∪ FiniteTuple.elements xs) f + have hL := inverseCover_mem M hM hP hU hPow hS hA hs hf + refine ⟨L,hL,?_,?_⟩ + · intro a x y hx hy + have hx' := (inverseCover_pair _ _ _ _ _).mp hx + have hy' := (inverseCover_pair _ _ _ _ _).mp hy + have hfx := (hfg.pair_iff x a).mp hx'.2.2 + have hfy := (hfg.pair_iff y a).mp hy'.2.2 + exact FiniteTuple.finiteIndex_injective t xs x hfx.1 y hfy.1 (hfx.2.symm.trans hfy.2) + · intro x hx + refine ⟨_,FiniteTuple.finiteIndex_mem t xs x,(inverseCover_pair _ _ _ _ _).mpr ?_⟩ + exact ⟨FiniteTuple.finiteIndex_mem t xs x,hx,(hfg.pair_iff x _).mpr ⟨hx,rfl⟩⟩ + +theorem eval_tuple {A B L O D : ZFSet.{u}} (hD : Transitive D) + (hzero : ∃ c, Eval A B L O D c ∅) (xs : List ZFSet.{u}) + (hxs : ∀ x ∈ xs, ∃ c, Eval A B L O D c x) (hcode : FiniteTuple.code xs ∈ D) : + ∃ c, Eval A B L O D c (FiniteTuple.code xs) := by + induction xs with + | nil => exact hzero + | cons x xs ih => + obtain ⟨a,ha⟩ := hxs x List.mem_cons_self + have htail : FiniteTuple.code xs ∈ D := (FiniteTuple.pair_components hD hcode).2 + obtain ⟨b,hb⟩ := ih (fun y hy => hxs y (List.mem_cons_of_mem _ hy)) htail + exact ⟨_,Eval.pair ha hb hcode⟩ + +noncomputable def generatedRange (d K E : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun x => ∃ c ∈ K, ZFSet.pair c x ∈ E) d + +theorem generatedRange_mem (M : ZFSet.{u}) (hM : Transitive M) (hS : Separation M) + {d K E : ZFSet.{u}} (hd : d ∈ M) (hK : K ∈ M) (hE : E ∈ M) : generatedRange d K E ∈ M := by + simpa only [generatedRange,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ] using + sep_mem M hM hS (.existsMem 1 (.pairMem 0 1 3)) (cons K (fun _ => E)) + (by intro i; cases i <;> assumption) hd + +theorem mem_generatedRange {A B L O D d K E : ZFSet.{u}} + (hE : ∀ c x, ZFSet.pair c x ∈ E ↔ Eval A B L O D c x) + (hsub : E ⊆ ZFSet.prod K D) (x : ZFSet.{u}) : + x ∈ generatedRange d K E ↔ x ∈ d ∧ ∃ c, Eval A B L O D c x := by + rw [generatedRange,ZFSet.mem_sep] + apply and_congr_right; intro _ + constructor + · rintro ⟨c,_,hc⟩; exact ⟨c,(hE c x).mp hc⟩ + · rintro ⟨c,hc⟩ + have hcx := (hE c x).mpr hc + obtain ⟨a,ha,b,_,he⟩ := ZFSet.mem_prod.mp (hsub hcx) + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨c,ha,hcx⟩ + +theorem generatedRange_closed {A L O V d K E : ZFSet.{u}} (n : ℕ) + (hV : Transitive V) (hdV : d ⊆ V) (hspace : FiniteTuple.space d n ⊆ V) + (hE : ∀ c x, ZFSet.pair c x ∈ E ↔ Eval A ZFSet.omega L O V c x) + (hsub : E ⊆ ZFSet.prod K V) (hzero : ∃ c, Eval A ZFSet.omega L O V c ∅) + {g : ZFSet.{u}} (hg : g ⊆ ZFSet.prod (FiniteTuple.space d n) d) (i : ℕ) + (hop : ∀ c x, ZFSet.pair c x ∈ g → ZFSet.pair (ZFSet.pair (natSet i) c) x ∈ O) : + FiniteTuple.Closed n g (generatedRange d K E) := by + intro xs hlen hxs y hy + have hxsd : ∀ x ∈ xs, x ∈ d := fun x hx => ((mem_generatedRange hE hsub x).mp (hxs x hx)).1 + have hcode : FiniteTuple.code xs ∈ V := hspace (hlen ▸ FiniteTuple.code_mem_space d xs hxsd) + obtain ⟨c,hc⟩ := eval_tuple hV hzero xs + (fun x hx => ((mem_generatedRange hE hsub x).mp (hxs x hx)).2) hcode + have hyd : y ∈ d := by + obtain ⟨a,_,b,hb,he⟩ := ZFSet.mem_prod.mp (hg hy) + obtain ⟨_,rfl⟩ := ZFSet.pair_inj.mp he + exact hb + apply (mem_generatedRange hE hsub y).mpr + exact ⟨hyd,_,Eval.app ((mem_omega _).mpr ⟨i,rfl⟩) hc (hdV hyd) (hop _ _ hy)⟩ +end FiniteTerm +namespace FiniteTuple + +theorem witnesses_of_closed_graphs (d h : ZFSet.{u}) (n : ℕ) (φ : Formula) + (hn : φ.width ≤ n) (hhd : h ⊆ d) + (hgs : ∀ ψ ∈ fragment n φ, ∃ g, SkolemGraph d n ψ (fun _ => d) g ∧ Closed n g h) : + Witnesses d h φ := by + intro i ψ hm e he hw + have hbounds := occurrence_width φ i ψ hm + have hin : i < n := lt_of_lt_of_le hbounds.1 hn + have hψn : ψ.scope ≤ n+1 := by omega + obtain ⟨g,hg,hcl⟩ := hgs _ (List.mem_map.mpr ⟨(i,ψ),hm,rfl⟩) + let xs := takeEnv n e + have hxs : ∀ x ∈ xs, x ∈ h := takeEnv_mem n e h he + have hlen : xs.length = n := length_takeEnv n e + obtain ⟨y,hy,hyi,hψ⟩ := hw + have hsuccess := (eval_witnessBody n i ψ hin hψn d y e).mpr ⟨hyi,hψ⟩ + obtain ⟨z,_,hz,_⟩ := hg.2 xs hlen (fun x hx => hhd (hxs x hx)) ⟨y,hy,hsuccess⟩ + exact ⟨z,hcl xs hlen hxs z hz, + (eval_witnessBody n i ψ hin hψn d z e).mp (hg.correct xs hlen hz).2.2⟩ + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/IdealCopy.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealCopy.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d6097d742399e0b5a472d8c79cb30af959a009b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealCopy.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.SetModels.IdealLift + +namespace OAI + +namespace TuringRigidity.IdealInterpretation +open SetCoding RelationCoding BoundedDecoding ArithmeticModelDecoding +noncomputable section + +theorem transport_copy {U : ℕ → Prop} {I J : DegreeIdeal} (ρ : I ≃o J) + (c : Copy U) (b : I) (hS : RelationBelow c.successor b.val) (hP : RelationBelow c.predicate b.val) : + ∃ d : Copy U, RelationBelow d.successor (ρ b).val ∧ RelationBelow d.predicate (ρ b).val := by + let S := RCode.ofBelow c.successor b hS + let P := RCode.ofBelow c.predicate b hP + have hn (n : ℕ) : c.node n ∈ I.carrier := by + have hh : S.external.Holds (two (c.node n) (c.node (n+1))) := by + simpa only [S,RCode.external_ofBelow] using (c.successor_spec _ _).mpr ⟨n,rfl,rfl⟩ + exact S.coordinates_mem hh 0 + let node : ℕ → I := fun n => ⟨c.node n,hn n⟩ + have hi : Function.Injective (fun n => (ρ (node n)).val) := by + intro i j he + have hh : ρ (node i) = ρ (node j) := Element.ext _ _ he + exact c.injective (congrArg Element.val (ρ.injective hh)) + have hsuccessor (a d : J) : (S.map ρ).external.Holds (two a.val d.val) ↔ + ∃ k, a = ρ (node k) ∧ d = ρ (node (k+1)) := by + have hh := S.transport_two ρ (ρ.symm a) (ρ.symm d) + simp only [ρ.apply_symm_apply,S,RCode.external_ofBelow] at hh + rw [hh,c.successor_spec] + constructor + · rintro ⟨k,hk,hl⟩ + have he : ρ.symm a = node k := Element.ext _ _ hk + have hf : ρ.symm d = node (k+1) := Element.ext _ _ hl + exact ⟨k,by rw [← he,ρ.apply_symm_apply],by rw [← hf,ρ.apply_symm_apply]⟩ + · rintro ⟨k,rfl,rfl⟩ + exact ⟨k,by simp only [ρ.symm_apply_apply,node],by simp only [ρ.symm_apply_apply,node]⟩ + have hpredicate (a : J) : (P.map ρ).external.Holds (one a.val) ↔ + ∃ k, U k ∧ a = ρ (node k) := by + have hh := P.transport_one ρ (ρ.symm a) + simp only [ρ.apply_symm_apply,P,RCode.external_ofBelow] at hh + rw [hh,c.predicate_spec] + constructor + · rintro ⟨k,hk,he⟩ + have hf : ρ.symm a = node k := Element.ext _ _ he + exact ⟨k,hk,by rw [← hf,ρ.apply_symm_apply]⟩ + · rintro ⟨k,hk,rfl⟩ + exact ⟨k,hk,by simp only [ρ.symm_apply_apply,node]⟩ + have hsglobal (a d : Degree) : (S.map ρ).external.Holds (two a d) ↔ + ∃ k, a = (ρ (node k)).val ∧ d = (ρ (node (k+1))).val := by + constructor + · intro h + have ha : a ∈ J.carrier := (S.map ρ).coordinates_mem h 0 + have hd : d ∈ J.carrier := (S.map ρ).coordinates_mem h 1 + obtain ⟨k,hk,hl⟩ := (hsuccessor ⟨a,ha⟩ ⟨d,hd⟩).mp h + exact ⟨k,congrArg Element.val hk,congrArg Element.val hl⟩ + · rintro ⟨k,rfl,rfl⟩ + exact (hsuccessor _ _).mpr ⟨k,rfl,rfl⟩ + have hpglobal (a : Degree) : (P.map ρ).external.Holds (one a) ↔ + ∃ k, U k ∧ a = (ρ (node k)).val := by + constructor + · intro h + have ha : a ∈ J.carrier := (P.map ρ).coordinates_mem h 0 + obtain ⟨k,hk,he⟩ := (hpredicate ⟨a,ha⟩).mp h + exact ⟨k,hk,congrArg Element.val he⟩ + · rintro ⟨k,hk,rfl⟩ + exact (hpredicate _).mpr ⟨k,hk,rfl⟩ + let d : Copy U := ⟨fun k => (ρ (node k)).val,hi,(S.map ρ).external,(P.map ρ).external,hsglobal,hpglobal⟩ + refine ⟨d,S.map_below ρ b ?_,P.map_below ρ b ?_⟩ + · simpa only [S,RCode.external_ofBelow] using hS + · simpa only [P,RCode.external_ofBelow] using hP + +end +end TuringRigidity.IdealInterpretation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/IdealEnumeration.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..55515f2a6a4b7a3559e7ad650689fe2aed5dff29 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealEnumeration.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DegreeRigidity.SetModels.IdealLift +import OAI.Computability.DegreeRigidity.SetModels.EnumerationDecoding + +namespace OAI + +namespace TuringRigidity.IdealInterpretation +open SetCoding RelationCoding BoundedDecoding ArithmeticModelDecoding EnumerationDecoding +noncomputable section + +theorem transport_enumeration {I J : DegreeIdeal} (ρ : I ≃o J) + (c : Enumeration) (b : I) (hS : RelationBelow c.successor b.val) (hP : RelationBelow c.payload b.val) + (v : ℕ → I) (hv : ∀ n, (v n).val = c.output n) : + ∃ d : Enumeration, (∀ n, d.output n = (ρ (v n)).val) ∧ + RelationBelow d.successor (ρ b).val ∧ RelationBelow d.payload (ρ b).val := by + let S := RCode.ofBelow c.successor b hS + let P := RCode.ofBelow c.payload b hP + have hn (n : ℕ) : c.node n ∈ I.carrier := by + have hh : S.external.Holds (two (c.node n) (c.node (n+1))) := by + simpa only [S,RCode.external_ofBelow] using (c.successor_spec _ _).mpr ⟨n,rfl,rfl⟩ + exact S.coordinates_mem hh 0 + let node : ℕ → I := fun n => ⟨c.node n,hn n⟩ + have hi : Function.Injective (fun n => (ρ (node n)).val) := by + intro i j he + have hh : ρ (node i) = ρ (node j) := Element.ext _ _ he + exact c.injective (congrArg Element.val (ρ.injective hh)) + have hsuccessor (a d : J) : (S.map ρ).external.Holds (two a.val d.val) ↔ + ∃ k, a = ρ (node k) ∧ d = ρ (node (k+1)) := by + have hh := S.transport_two ρ (ρ.symm a) (ρ.symm d) + simp only [ρ.apply_symm_apply,S,RCode.external_ofBelow] at hh + rw [hh,c.successor_spec] + constructor + · rintro ⟨k,hk,hl⟩ + have he : ρ.symm a = node k := Element.ext _ _ hk + have hf : ρ.symm d = node (k+1) := Element.ext _ _ hl + exact ⟨k,by rw [← he,ρ.apply_symm_apply],by rw [← hf,ρ.apply_symm_apply]⟩ + · rintro ⟨k,rfl,rfl⟩ + exact ⟨k,by simp only [ρ.symm_apply_apply,node],by simp only [ρ.symm_apply_apply,node]⟩ + have hpayload (a d : J) : (P.map ρ).external.Holds (two a.val d.val) ↔ + ∃ k, a = ρ (node k) ∧ d = ρ (v k) := by + have hh := P.transport_two ρ (ρ.symm a) (ρ.symm d) + simp only [ρ.apply_symm_apply,P,RCode.external_ofBelow] at hh + rw [hh,c.payload_spec] + constructor + · rintro ⟨k,hk,hl⟩ + have he : ρ.symm a = node k := Element.ext _ _ hk + have hf : ρ.symm d = v k := Element.ext _ _ (hl.trans (hv k).symm) + exact ⟨k,by rw [← he,ρ.apply_symm_apply],by rw [← hf,ρ.apply_symm_apply]⟩ + · rintro ⟨k,rfl,rfl⟩ + exact ⟨k,by simp only [ρ.symm_apply_apply,node],by simpa only [ρ.symm_apply_apply] using hv k⟩ + have hsglobal (a d : Degree) : (S.map ρ).external.Holds (two a d) ↔ + ∃ k, a = (ρ (node k)).val ∧ d = (ρ (node (k+1))).val := by + constructor + · intro h + have ha : a ∈ J.carrier := (S.map ρ).coordinates_mem h 0 + have hd : d ∈ J.carrier := (S.map ρ).coordinates_mem h 1 + obtain ⟨k,hk,hl⟩ := (hsuccessor ⟨a,ha⟩ ⟨d,hd⟩).mp h + exact ⟨k,congrArg Element.val hk,congrArg Element.val hl⟩ + · rintro ⟨k,rfl,rfl⟩ + exact (hsuccessor _ _).mpr ⟨k,rfl,rfl⟩ + have hpglobal (a d : Degree) : (P.map ρ).external.Holds (two a d) ↔ + ∃ k, a = (ρ (node k)).val ∧ d = (ρ (v k)).val := by + constructor + · intro h + have ha : a ∈ J.carrier := (P.map ρ).coordinates_mem h 0 + have hd : d ∈ J.carrier := (P.map ρ).coordinates_mem h 1 + obtain ⟨k,hk,hl⟩ := (hpayload ⟨a,ha⟩ ⟨d,hd⟩).mp h + exact ⟨k,congrArg Element.val hk,congrArg Element.val hl⟩ + · rintro ⟨k,rfl,rfl⟩ + exact (hpayload _ _).mpr ⟨k,rfl,rfl⟩ + let d : Enumeration := ⟨fun k => (ρ (node k)).val,hi,fun k => (ρ (v k)).val, + (S.map ρ).external,(P.map ρ).external,hsglobal,hpglobal⟩ + refine ⟨d,fun _ => rfl,S.map_below ρ b ?_,P.map_below ρ b ?_⟩ + · simpa only [S,RCode.external_ofBelow] using hS + · simpa only [P,RCode.external_ofBelow] using hP + +end +end TuringRigidity.IdealInterpretation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/IdealInterpretation.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealInterpretation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b25107e89fc12df541d177eb69473714a3c67513 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealInterpretation.lean @@ -0,0 +1,196 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedDecoding + +namespace OAI + +namespace TuringRigidity.IdealInterpretation +open AntichainParameters SetCoding RelationCoding + +structure DegreeIdeal where + carrier : Set Degree + nonempty : carrier.Nonempty + lower : ∀ {x y}, x ≤ y → y ∈ carrier → x ∈ carrier + join_mem : ∀ {x y}, x ∈ carrier → y ∈ carrier → x ⊔ y ∈ carrier + +structure Element (I : DegreeIdeal) where + val : Degree + property : val ∈ I.carrier + +instance : CoeSort DegreeIdeal Type := ⟨Element⟩ + +@[ext] theorem Element.ext {I : DegreeIdeal} (x y : I) (h : x.val = y.val) : x = y := by + cases x; cases y; cases h; rfl + +instance (I : DegreeIdeal) : PartialOrder I := + PartialOrder.lift Element.val (fun x y h => Element.ext x y h) + +instance (I : DegreeIdeal) : SemilatticeSup (Element I) where + toPartialOrder := inferInstance + sup x y := ⟨x.val ⊔ y.val,I.join_mem x.property y.property⟩ + le_sup_left := by + intro x y + change x.val ≤ x.val ⊔ y.val + exact le_sup_left + le_sup_right := by + intro x y + change y.val ≤ x.val ⊔ y.val + exact le_sup_right + sup_le := by + intro x y z hx hy + change x.val ⊔ y.val ≤ z.val + exact sup_le hx hy + +instance (I : DegreeIdeal) : OrderBot (Element I) where + bot := ⟨⊥,by obtain ⟨x,hx⟩ := I.nonempty; exact I.lower bot_le hx⟩ + bot_le := by + intro x + change (⊥ : Degree) ≤ x.val + exact bot_le + +@[simp] theorem coe_sup {I : DegreeIdeal} (x y : I) : (x ⊔ y).val = x.val ⊔ y.val := rfl +@[simp] theorem coe_bot (I : DegreeIdeal) : (⊥ : I).val = (⊥ : Degree) := rfl + +theorem coe_finset_sup {I : DegreeIdeal} {α : Type*} (F : Finset α) (f : α → I) : + (F.sup f).val = F.sup (fun a => (f a).val) := by + classical + induction F using Finset.induction_on with + | empty => rfl + | @insert a F ha ih => simp only [Finset.sup_insert,coe_sup,ih] + +section Formula +variable {α β : Type*} [SemilatticeSup α] [SemilatticeSup β] + +def nontrivial (b g₀ g₁ x : α) : Prop := + x ≤ b ∧ ∃ z, z ≤ g₀ ⊔ x ∧ z ≤ g₁ ⊔ x ∧ ¬ z ≤ x + +def antichain (b g₀ g₁ x : α) : Prop := + nontrivial b g₀ g₁ x ∧ ∀ y, nontrivial b g₀ g₁ y → y ≤ x → x ≤ y + +theorem map_nontrivial (ρ : α ≃o β) (b g₀ g₁ x : α) : + nontrivial (ρ b) (ρ g₀) (ρ g₁) (ρ x) ↔ nontrivial b g₀ g₁ x := by + unfold nontrivial + simp only [← ρ.map_sup,ρ.le_iff_le] + constructor + · rintro ⟨hx,z,h₀,h₁,hn⟩ + obtain ⟨w,rfl⟩ := ρ.surjective z + exact ⟨hx,w,(ρ.le_iff_le).mp h₀,(ρ.le_iff_le).mp h₁,fun h => hn ((ρ.le_iff_le).mpr h)⟩ + · rintro ⟨hx,z,h₀,h₁,hn⟩ + exact ⟨hx,ρ z,(ρ.le_iff_le).mpr h₀,(ρ.le_iff_le).mpr h₁,fun h => hn ((ρ.le_iff_le).mp h)⟩ + +theorem map_antichain (ρ : α ≃o β) (b g₀ g₁ x : α) : + antichain (ρ b) (ρ g₀) (ρ g₁) (ρ x) ↔ antichain b g₀ g₁ x := by + unfold antichain + rw [map_nontrivial] + constructor + · rintro ⟨hx,hm⟩ + refine ⟨hx,fun y hy hyx => ?_⟩ + exact ρ.le_iff_le.mp (hm (ρ y) ((map_nontrivial ρ _ _ _ _).mpr hy) (ρ.le_iff_le.mpr hyx)) + · rintro ⟨hx,hm⟩ + refine ⟨hx,fun y hy hyx => ?_⟩ + obtain ⟨z,rfl⟩ := ρ.surjective y + exact ρ.le_iff_le.mpr (hm z ((map_nontrivial ρ _ _ _ _).mp hy) (ρ.le_iff_le.mp hyx)) +end Formula + +theorem ideal_nontrivial (I : DegreeIdeal) (b g₀ g₁ x : I) : + nontrivial b g₀ g₁ x ↔ NontrivialCommonLower b.val g₀.val g₁.val x.val := by + constructor + · rintro ⟨hx,z,h₀,h₁,hn⟩ + exact ⟨hx,z.val,h₀,h₁,hn⟩ + · rintro ⟨hx,z,h₀,h₁,hn⟩ + exact ⟨hx,⟨z,I.lower h₀ (I.join_mem g₀.property x.property)⟩,h₀,h₁,hn⟩ + +theorem ideal_antichain (I : DegreeIdeal) (b g₀ g₁ x : I) : + antichain b g₀ g₁ x ↔ CodedAntichain b.val g₀.val g₁.val x.val := by + constructor + · rintro ⟨hx,hm⟩ + refine ⟨(ideal_nontrivial I _ _ _ _).mp hx,fun y hy hyx => ?_⟩ + let y' : I := ⟨y,I.lower hy.1 b.property⟩ + exact hm y' ((ideal_nontrivial I _ _ _ _).mpr hy) hyx + · rintro ⟨hx,hm⟩ + exact ⟨(ideal_nontrivial I _ _ _ _).mpr hx,fun y hy hyx => + hm y.val ((ideal_nontrivial I _ _ _ _).mp hy) hyx⟩ + +theorem transport_antichain {I J : DegreeIdeal} (ρ : I ≃o J) (b g₀ g₁ x : I) : + CodedAntichain (ρ b).val (ρ g₀).val (ρ g₁).val (ρ x).val ↔ + CodedAntichain b.val g₀.val g₁.val x.val := by + rw [← ideal_antichain,← ideal_antichain,map_antichain] + +structure ACode (I : DegreeIdeal) where + bound : I + left : I + right : I + +def ACode.external {I : DegreeIdeal} (p : ACode I) : AntichainCode := ⟨p.bound.val,p.left.val,p.right.val⟩ +def ACode.map {I J : DegreeIdeal} (ρ : I ≃o J) (p : ACode I) : ACode J := ⟨ρ p.bound,ρ p.left,ρ p.right⟩ + +theorem ACode.transport {I J : DegreeIdeal} (ρ : I ≃o J) (p : ACode I) (x : I) : + (p.map ρ).external.Holds (ρ x).val ↔ p.external.Holds x.val := + transport_antichain ρ _ _ _ _ + +structure SCode (I : DegreeIdeal) where + bound : I + tags : ACode I + decorated : ACode I + +def SCode.external {I : DegreeIdeal} (p : SCode I) : SetCode := ⟨p.bound.val,p.tags.external,p.decorated.external⟩ +def SCode.map {I J : DegreeIdeal} (ρ : I ≃o J) (p : SCode I) : SCode J := + ⟨ρ p.bound,p.tags.map ρ,p.decorated.map ρ⟩ + +theorem SCode.transport {I J : DegreeIdeal} (ρ : I ≃o J) (p : SCode I) (x c : I) : + (p.map ρ).external.Graph (ρ x).val (ρ c).val ↔ p.external.Graph x.val c.val := by + change ((ρ x).val ≤ (ρ p.bound).val ∧ (p.tags.map ρ).external.Holds (ρ c).val ∧ + (p.decorated.map ρ).external.Holds ((ρ x).val ⊔ (ρ c).val)) ↔ _ + rw [← coe_sup,← ρ.map_sup,p.tags.transport ρ c,p.decorated.transport ρ (x ⊔ c)] + exact and_congr ρ.le_iff_le Iff.rfl + +structure RCode (I : DegreeIdeal) (n : ℕ) where + coordinates : Fin n → SCode I + tuples : ACode I + +def RCode.external {I : DegreeIdeal} {n : ℕ} (p : RCode I n) : RelationCode n := + ⟨fun i => (p.coordinates i).external,p.tuples.external⟩ +def RCode.map {I J : DegreeIdeal} {n : ℕ} (ρ : I ≃o J) (p : RCode I n) : RCode J n := + ⟨fun i => (p.coordinates i).map ρ,p.tuples.map ρ⟩ + +theorem RCode.internal {I : DegreeIdeal} {n : ℕ} (p : RCode I n) (v : Fin n → I) : + p.external.Holds (fun i => (v i).val) ↔ + ∃ c : Fin n → I, (∀ i, (p.coordinates i).external.Graph (v i).val (c i).val) ∧ + p.tuples.external.Holds (Finset.univ.sup c).val := by + constructor + · rintro ⟨c,hc,ht⟩ + have hm : ∀ i, c i ∈ I.carrier := fun i => + I.lower (hc i).2.1.1.1 (p.coordinates i).tags.bound.property + refine ⟨fun i => ⟨c i,hm i⟩,hc,?_⟩ + simpa only [coe_finset_sup,RCode.external] using ht + · rintro ⟨c,hc,ht⟩ + exact ⟨fun i => (c i).val,hc,by simpa only [coe_finset_sup,RCode.external] using ht⟩ + +private theorem map_sup_finset {I J : DegreeIdeal} (ρ : I ≃o J) {α : Type*} + (F : Finset α) (f : α → I) : ρ (F.sup f) = F.sup (fun a => ρ (f a)) := by + classical + induction F using Finset.induction_on with + | empty => exact ρ.map_bot + | @insert a F ha ih => simp only [Finset.sup_insert,ρ.map_sup,ih] + +theorem RCode.transport {I J : DegreeIdeal} {n : ℕ} (ρ : I ≃o J) (p : RCode I n) (v : Fin n → I) : + (p.map ρ).external.Holds (fun i => (ρ (v i)).val) ↔ p.external.Holds (fun i => (v i).val) := by + classical + rw [(p.map ρ).internal,p.internal] + constructor + · rintro ⟨c,hc,ht⟩ + let d := fun i => ρ.symm (c i) + have hd : ∀ i, ρ (d i) = c i := fun i => ρ.apply_symm_apply _ + refine ⟨d,fun i => ?_,?_⟩ + · exact ((p.coordinates i).transport ρ (v i) (d i)).mp (by simpa only [hd,RCode.map] using hc i) + · apply (p.tuples.transport ρ (Finset.univ.sup d)).mp + have he : ρ (Finset.univ.sup d) = Finset.univ.sup c := by + rw [map_sup_finset] + simp only [hd] + simpa only [he,RCode.map] using ht + · rintro ⟨c,hc,ht⟩ + refine ⟨fun i => ρ (c i),fun i => ((p.coordinates i).transport ρ (v i) (c i)).mpr (hc i),?_⟩ + have hh := (p.tuples.transport ρ (Finset.univ.sup c)).mpr ht + simpa only [map_sup_finset,RCode.map] using hh + +end TuringRigidity.IdealInterpretation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/IdealLift.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealLift.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b899e5ca66166875c6c9942a297c34df8631135 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealLift.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.SetModels.IdealInterpretation +import OAI.Computability.DegreeRigidity.Effective.CodingBounds + +namespace OAI + +namespace TuringRigidity.IdealInterpretation +open SetCoding RelationCoding BoundedDecoding ArithmeticModelDecoding + +def ACode.ofBelow {I : DegreeIdeal} (p : AntichainCode) (b : I) (hp : AntichainBelow p b.val) : ACode I := + ⟨⟨p.bound,I.lower hp.1 b.property⟩,⟨p.left,I.lower hp.2.1 b.property⟩, + ⟨p.right,I.lower hp.2.2 b.property⟩⟩ + +@[simp] theorem ACode.external_ofBelow {I : DegreeIdeal} (p : AntichainCode) (b : I) + (hp : AntichainBelow p b.val) : (ACode.ofBelow p b hp).external = p := by cases p; rfl + +def SCode.ofBelow {I : DegreeIdeal} (p : SetCode) (b : I) (hp : SetBelow p b.val) : SCode I := + ⟨⟨p.bound,I.lower hp.1 b.property⟩,ACode.ofBelow p.tags b hp.2.1,ACode.ofBelow p.decorated b hp.2.2⟩ + +@[simp] theorem SCode.external_ofBelow {I : DegreeIdeal} (p : SetCode) (b : I) + (hp : SetBelow p b.val) : (SCode.ofBelow p b hp).external = p := by cases p; rfl + +def RCode.ofBelow {I : DegreeIdeal} {n : ℕ} (p : RelationCode n) (b : I) + (hp : RelationBelow p b.val) : RCode I n := + ⟨fun i => SCode.ofBelow (p.coordinates i) b (hp.1 i),ACode.ofBelow p.tuples b hp.2⟩ + +@[simp] theorem RCode.external_ofBelow {I : DegreeIdeal} {n : ℕ} (p : RelationCode n) (b : I) + (hp : RelationBelow p b.val) : (RCode.ofBelow p b hp).external = p := by cases p; rfl + +theorem ACode.map_below {I J : DegreeIdeal} (ρ : I ≃o J) (p : ACode I) (b : I) + (hp : AntichainBelow p.external b.val) : AntichainBelow (p.map ρ).external (ρ b).val := + ⟨show ρ p.bound ≤ ρ b from ρ.monotone hp.1, + show ρ p.left ≤ ρ b from ρ.monotone hp.2.1, + show ρ p.right ≤ ρ b from ρ.monotone hp.2.2⟩ + +theorem SCode.map_below {I J : DegreeIdeal} (ρ : I ≃o J) (p : SCode I) (b : I) + (hp : SetBelow p.external b.val) : SetBelow (p.map ρ).external (ρ b).val := + ⟨show ρ p.bound ≤ ρ b from ρ.monotone hp.1,p.tags.map_below ρ b hp.2.1, + p.decorated.map_below ρ b hp.2.2⟩ + +theorem RCode.map_below {I J : DegreeIdeal} {n : ℕ} (ρ : I ≃o J) (p : RCode I n) (b : I) + (hp : RelationBelow p.external b.val) : RelationBelow (p.map ρ).external (ρ b).val := + ⟨fun i => (p.coordinates i).map_below ρ b (hp.1 i),p.tuples.map_below ρ b hp.2⟩ + +theorem RCode.coordinates_mem {I : DegreeIdeal} {n : ℕ} (p : RCode I n) {v : Fin n → Degree} + (h : p.external.Holds v) (i : Fin n) : v i ∈ I.carrier := by + obtain ⟨c,hc,_⟩ := h + exact I.lower (hc i).1 (p.coordinates i).bound.property + +theorem RCode.transport_one {I J : DegreeIdeal} (ρ : I ≃o J) (p : RCode I 1) (a : I) : + (p.map ρ).external.Holds (one (ρ a).val) ↔ p.external.Holds (one a.val) := by + have hv : (fun _ : Fin 1 => (ρ a).val) = one (ρ a).val := by + funext i; fin_cases i; rfl + have hw : (fun _ : Fin 1 => a.val) = one a.val := by + funext i; fin_cases i; rfl + simpa only [hv,hw] using p.transport ρ (fun _ => a) + +theorem RCode.transport_two {I J : DegreeIdeal} (ρ : I ≃o J) (p : RCode I 2) (a b : I) : + (p.map ρ).external.Holds (two (ρ a).val (ρ b).val) ↔ p.external.Holds (two a.val b.val) := by + have hv : (fun i : Fin 2 => (ρ (![a,b] i)).val) = two (ρ a).val (ρ b).val := by + funext i; fin_cases i <;> rfl + have hw : (fun i : Fin 2 => (![a,b] i).val) = two a.val b.val := by + funext i; fin_cases i <;> rfl + simpa only [hv,hw] using p.transport ρ ![a,b] + +end TuringRigidity.IdealInterpretation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/IdealLocality.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealLocality.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1709a052d249b908bb5d8ef0b5e39b27c9dd67e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealLocality.lean @@ -0,0 +1,82 @@ +import OAI.Computability.DegreeRigidity.Effective.LocalUnary +import OAI.Computability.DegreeRigidity.SetModels.IdealCopy + +namespace OAI + +namespace TuringRigidity.IdealLocality +open OracleJump ArithmeticHierarchy ArithmeticModelDecoding BoundedDecoding IdealInterpretation +noncomputable section + +def JumpClosed (J : DegreeIdeal) : Prop := ∀ x, x ∈ J.carrier → degreeJump x ∈ J.carrier + +theorem image_arithmetic {I : DegreeIdeal} (ρ : I ≃o I) (z : I) + (hz : z.val = degree (jump FixedArithmetic.zero)) (x : I) : + ∃ X Y : Oracle, degree X = (ρ x).val ∧ degree Y = x.val ⊔ (ρ.symm z).val ∧ + Reduces X (iterate Y 5) := by + obtain ⟨X,hX⟩ := degree_surjective (ρ x).val + obtain ⟨c,hS,hP⟩ := LocalUnary.localized_copy X + let b : I := ρ x ⊔ z + have hb : degree (join X (jump FixedArithmetic.zero)) = b.val := by + change degree X ⊔ degree (jump FixedArithmetic.zero) = (ρ x).val ⊔ z.val + rw [hX,hz] + obtain ⟨d,hdS,hdP⟩ := transport_copy ρ.symm c b (hb ▸ hS) (hb ▸ hP) + have he : (ρ.symm b).val = x.val ⊔ (ρ.symm z).val := by + simp only [b,ρ.symm.map_sup,ρ.symm_apply_apply,coe_sup] + obtain ⟨Y,hY⟩ := degree_surjective (ρ.symm b).val + have hY' : degree Y = x.val ⊔ (ρ.symm z).val := hY.trans he + have hrec := (unary_decoding Y d (hY.symm ▸ hdS) (hY.symm ▸ hdP)).2 + have hXY : Reduces X (iterate Y 5) := by + apply RecursiveIn.iff_nat.mpr + exact hrec.of_eq (fun n => by cases hx : X n <;> simp [oracleFunction,hx]) + exact ⟨X,Y,hX,hY',hXY⟩ + +theorem image_mem {I J : DegreeIdeal} (ρ : I ≃o I) (z : I) + (hz : z.val = degree (jump FixedArithmetic.zero)) (hjump : JumpClosed J) + (hpre : (ρ.symm z).val ∈ J.carrier) (x : I) (hx : x.val ∈ J.carrier) : + (ρ x).val ∈ J.carrier := by + obtain ⟨X,Y,hX,hY,hXY⟩ := image_arithmetic ρ z hz x + have hbase : degree Y ∈ J.carrier := hY.symm ▸ J.join_mem hx hpre + have hit (n : ℕ) : degree (iterate Y n) ∈ J.carrier := by + induction n with + | zero => exact hbase + | succ n ih => exact hjump _ ih + exact hX ▸ J.lower hXY (hit 5) + +theorem invariant {I J : DegreeIdeal} (ρ : I ≃o I) (z : I) + (hz : z.val = degree (jump FixedArithmetic.zero)) (hjump : JumpClosed J) + (himages : (ρ z).val ⊔ (ρ.symm z).val ∈ J.carrier) (x : I) : + (ρ x).val ∈ J.carrier ↔ x.val ∈ J.carrier := by + have hforward := image_mem ρ z hz hjump (J.lower le_sup_right himages) + have hback := image_mem ρ.symm z hz hjump (J.lower le_sup_left himages) + exact ⟨fun h => by simpa only [ρ.symm_apply_apply] using hback (ρ x) h,hforward x⟩ + +theorem source_4_1_4 {I J : DegreeIdeal} (ρ : I ≃o I) (z : I) + (hz : z.val = degree (jump FixedArithmetic.zero)) (hJI : J.carrier ⊆ I.carrier) + (hjump : JumpClosed J) (himages : (ρ z).val ⊔ (ρ.symm z).val ∈ J.carrier) : + ∃ σ : J ≃o J, ∀ x : J, (σ x).val = (ρ ⟨x.val,hJI x.property⟩).val := by + let incl : J → I := fun x => ⟨x.val,hJI x.property⟩ + let f : J → J := fun x => ⟨(ρ (incl x)).val, + (invariant ρ z hz hjump himages (incl x)).mpr x.property⟩ + let g : J → J := fun x => ⟨(ρ.symm (incl x)).val,by + apply (invariant ρ z hz hjump himages (ρ.symm (incl x))).mp + simpa only [ρ.apply_symm_apply,incl] using x.property⟩ + have hfg (x : J) : f (g x) = x := by + apply Element.ext + change (ρ (ρ.symm (incl x))).val = x.val + rw [ρ.apply_symm_apply] + have hgf (x : J) : g (f x) = x := by + apply Element.ext + change (ρ.symm (ρ (incl x))).val = x.val + rw [ρ.symm_apply_apply] + let σ : J ≃o J := + { toEquiv := ⟨f,g,hgf,hfg⟩ + map_rel_iff' := by + intro x y + change ρ (incl x) ≤ ρ (incl y) ↔ incl x ≤ incl y + exact ρ.le_iff_le } + exact ⟨σ,fun _ => rfl⟩ + +end +end TuringRigidity.IdealLocality + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/IdealPresentation.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..a9a0206e51fb0829f406029c4f1f8352a3507fcc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealPresentation.lean @@ -0,0 +1,53 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticPresentation +import OAI.Computability.DegreeRigidity.SetModels.IdealEnumeration + +namespace OAI + +namespace TuringRigidity.IdealPresentation +open OracleJump ArithmeticHierarchy EncodedForcing BoundedDecoding IdealInterpretation IdealLocality +open EnumerationDecoding EnumerationConstruction +noncomputable section + +def entry {J : DegreeIdeal} (H : Oracle) (hH : degree H ∈ J.carrier) (n : ℕ) : J := + ⟨degree (columns H n),J.lower (CodingExtraction.column_projection_reduces H n) hH⟩ + +def Graph {J : DegreeIdeal} (ρ : J ≃o J) (H : Oracle) (hH : degree H ∈ J.carrier) (v : ℕ) : Prop := + (ρ (entry H hH (Nat.unpair v).1)).val = degree (columns H (Nat.unpair v).2) + +theorem source_4_1_7 (I J : DegreeIdeal) (H : Oracle) (ρ : J ≃o J) + (hpres : ∀ x, x ∈ I.carrier ↔ ∃ k, degree (columns H k) = x) + (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (hH : degree H ∈ J.carrier) (hjump : JumpClosed J) + (hinv : ∀ x : J, (ρ x).val ∈ I.carrier ↔ x.val ∈ I.carrier) : + Sigma (iterate H 6) 5 (Graph ρ H hH) ∧ RecursivePred (iterate H 11) (Graph ρ H hH) := by + have hbound (x : Degree) (hx : x ∈ I.carrier) : x ≤ degree H := by + obtain ⟨k,rfl⟩ := (hpres x).mp hx + exact CodingExtraction.column_projection_reduces H k + have hzero : Reduces (jump FixedArithmetic.zero) H := hbound _ hz + let z : J := ⟨degree (jump FixedArithmetic.zero),J.lower hzero hH⟩ + have hpre : (ρ.symm z).val ≤ degree H := by + apply hbound + apply (hinv (ρ.symm z)).mp + simpa only [ρ.apply_symm_apply,z] using hz + let b : J := ⟨degree (jump H),hjump _ hH⟩ + obtain ⟨c,hout,hS,hP⟩ := enumeration_exists H hzero + obtain ⟨d,hdout,hdS,hdP⟩ := transport_enumeration ρ c b hS hP (entry H hH) + (fun n => by simp only [entry,hout]) + have hb : (ρ b).val ≤ degree (iterate H 6) := by + obtain ⟨X,Y,hX,hY,hXY⟩ := image_arithmetic ρ z rfl b + have hYH : Reduces Y (jump H) := by + change degree Y ≤ degree (jump H) + rw [hY] + exact sup_le le_rfl (hpre.trans (reduces_jump H)) + rw [← hX] + exact reduces_trans hXY (iterate_mono hYH 5) + have hg := graph_sigma (ArithmeticPresentation.reduces_iterate H 6) d (hdS.mono hb) (hdP.mono hb) + have h : Sigma (iterate H 6) 5 (Graph ρ H hH) := hg.congr (fun v => by + simp only [hdout,Graph]) + have hr := form_recursive h + exact ⟨h,hr⟩ + +end +end TuringRigidity.IdealPresentation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/IdealSelection.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..017a3aa5f942304c89d76bc92bd24b7dbfd39d5a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/IdealSelection.lean @@ -0,0 +1,135 @@ +import OAI.Computability.DegreeRigidity.Effective.ProgramSelection +import OAI.Computability.DegreeRigidity.Representation.Assembly + +namespace OAI + +open Set +namespace TuringRigidity + +noncomputable def programOutput (c : OracleCode) (A : Oracle) : Oracle := + fun n => by classical exact decide (1 ∈ OracleCode.eval (oracleFunction A) c n) + +theorem programOutput_measurable (c : OracleCode) : Measurable (programOutput c) := by + apply Measurable.of_eval + intro n + apply measurable_to_countable' + intro b + cases b with + | false => + convert (OracleCode.halting_set_open c n 1).measurableSet.compl using 1 + ext A + simp [programOutput] + | true => + convert (OracleCode.halting_set_open c n 1).measurableSet using 1 + ext A + simp [programOutput] + +theorem programOutput_eq (c : OracleCode) (A B : Oracle) + (h : OracleCode.eval (oracleFunction A) c = oracleFunction B) : + programOutput c A = B := by + funext n + simp only [programOutput, h, oracleFunction, Part.mem_some_iff] + cases B n <;> simp + +theorem reduces_measurable {X : Type*} [MeasurableSpace X] + (A B : X → Oracle) (hA : Measurable A) (hB : Measurable B) : + MeasurableSet {x | Reduces (A x) (B x)} := by + have he : {x | Reduces (A x) (B x)} = + ⋃ c : OracleCode, {x | OracleCode.eval (oracleFunction (B x)) c = oracleFunction (A x)} := by + ext x + simp only [mem_ofPred_eq, mem_iUnion] + exact OracleCode.turingReducible_iff_exists_code _ _ + rw [he] + exact MeasurableSet.iUnion (fun c => OracleCode.success_measurable c B A hB hA) + +theorem exists_programOutput (A B : Oracle) (h : Reduces B A) : + ∃ n, programOutput (codeEnumeration n) A = B := by + obtain ⟨c,hc⟩ := (OracleCode.turingReducible_iff_exists_code _ _).mp h + obtain ⟨n,hn⟩ := codeEnumeration_surjective c + exact ⟨n,by simpa [hn] using programOutput_eq c A B hc⟩ + +theorem borel_of_ideal_intersection {X : Type*} [MeasurableSpace X] + (L R : X → Oracle) (hL : Measurable L) (hR : Measurable R) + (d : X → Degree) + (hd : ∀ x b, b ≤ d x ↔ b ≤ degree (L x) ∧ b ≤ degree (R x)) : + ∃ F : X → Oracle, Measurable F ∧ ∀ x, degree (F x) = d x := by + let C : ℕ → X → Oracle := fun n x => programOutput (codeEnumeration n) (L x) + have hC (n : ℕ) : Measurable (C n) := (programOutput_measurable _).comp hL + let S : X → ℕ → Prop := fun x n => + Reduces (C n x) (L x) ∧ Reduces (C n x) (R x) ∧ + ∀ k, Reduces (C k x) (L x) ∧ Reduces (C k x) (R x) → Reduces (C k x) (C n x) + have hS (n : ℕ) : MeasurableSet {x | S x n} := by + have hb (k : ℕ) : MeasurableSet {x | Reduces (C k x) (L x) ∧ Reduces (C k x) (R x)} := + (reduces_measurable _ _ (hC k) hL).inter (reduces_measurable _ _ (hC k) hR) + have hm : MeasurableSet {x | ∀ k, Reduces (C k x) (L x) ∧ Reduces (C k x) (R x) → Reduces (C k x) (C n x)} := by + simp only [Set.ofPred_forall] + apply MeasurableSet.iInter + intro k + have he : {x | Reduces (C k x) (L x) ∧ Reduces (C k x) (R x) → Reduces (C k x) (C n x)} = + {x | Reduces (C k x) (L x) ∧ Reduces (C k x) (R x)}ᶜ ∪ + {x | Reduces (C k x) (C n x)} := by ext x; simp only [mem_ofPred_eq, mem_union, mem_compl_iff]; tauto + rw [he] + exact (hb k).compl.union (reduces_measurable _ _ (hC k) (hC n)) + exact (reduces_measurable _ _ (hC n) hL).inter + ((reduces_measurable _ _ (hC n) hR).inter hm) + have hex : ∀ x, ∃ n, S x n := by + intro x + obtain ⟨B,hB⟩ := degree_surjective (d x) + have hb : Reduces B (L x) ∧ Reduces B (R x) := (hd x (degree B)).mp (by rw [hB]) + obtain ⟨n,hn⟩ := exists_programOutput (L x) B hb.1 + have hc : C n x = B := hn + refine ⟨n,?_,?_,?_⟩ + · simpa [hc] using hb.1 + · simpa [hc] using hb.2 + · intro k hk + change degree (C k x) ≤ degree (C n x) + rw [hc,hB] + exact (hd x _).mpr hk + let e := leastSuccess S hex + have he : Measurable e := leastSuccess_measurable S hex hS + have hout : Measurable (fun x => C (e x) x) := by + apply Measurable.of_eval + intro i + apply measurable_to_countable' + intro b + have heq : {x | C (e x) x i = b} = ⋃ n : ℕ, {x | e x = n} ∩ {x | C n x i = b} := by + ext x + simp only [mem_ofPred_eq, mem_iUnion, mem_inter_iff] + exact ⟨fun h => ⟨e x,rfl,h⟩,fun ⟨n,hn,h⟩ => by simpa [hn] using h⟩ + change MeasurableSet {x | C (e x) x i = b} + rw [heq] + exact MeasurableSet.iUnion (fun n => (measurableSet_eq_fun he measurable_const).inter + (measurableSet_eq_fun ((measurable_pi_apply i).comp (hC n)) measurable_const)) + refine ⟨fun x => C (e x) x,hout,?_⟩ + intro x + have hs := leastSuccess_spec S hex x + change S x (e x) at hs + apply le_antisymm + · exact (hd x _).mpr ⟨hs.1,hs.2.1⟩ + · obtain ⟨B,hB⟩ := degree_surjective (d x) + have hb : Reduces B (L x) ∧ Reduces B (R x) := (hd x (degree B)).mp (by rw [hB]) + obtain ⟨n,hn⟩ := exists_programOutput (L x) B hb.1 + have hc : C n x = B := hn + have hh := hs.2.2 n (by simpa [hc] using hb) + change degree (C n x) ≤ degree (C (e x) x) at hh + simpa [hc,hB] using hh + +theorem common_lower_transport (π : Degree ≃o Degree) (a l r : Degree) + (h : ∀ b, b ≤ a ↔ b ≤ l ∧ b ≤ r) : + ∀ b, b ≤ π a ↔ b ≤ π l ∧ b ≤ π r := by + intro b + have hh := h (π.symm b) + simpa only [π.symm_apply_le] using hh + +theorem representation_of_ideal_generators + (h : ∀ π : Degree ≃o Degree, ∃ L R : Oracle → Oracle, + Measurable L ∧ Measurable R ∧ + ∀ A b, b ≤ π (degree A) ↔ b ≤ degree (L A) ∧ b ≤ degree (R A)) : + BorelRepresentation := by + intro π + obtain ⟨L,R,hL,hR,hd⟩ := h π + exact borel_of_ideal_intersection L R hL hR (fun A => π (degree A)) hd + +end TuringRigidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalAtomicTruth.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalAtomicTruth.lean new file mode 100644 index 0000000000000000000000000000000000000000..a1a2912043a7f19c962c1ae0ba5bddac76117614 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalAtomicTruth.lean @@ -0,0 +1,107 @@ +import OAI.Computability.DegreeRigidity.Syntax.AtomicDecisionFormula +import OAI.Computability.DegreeRigidity.Syntax.AtomicTruth +import OAI.Computability.DegreeRigidity.SetModels.InternalContainer + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +def GroundGeneric (M : ZFSet.{u}) (G : GenericFilter (Conditions c)) : Prop := + ∀ D ∈ M, Dense {q | label c q ∈ D} → ∃ q ∈ G.carrier, label c q ∈ D + +theorem internal_atomic_requirements (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (a b : Name (Conditions c)) (ha : a.encode (label c) ∈ M) (hb : b.encode (label c) ∈ M) : + ∃ D ∈ M, ∃ E ∈ M, + (∀ q, label c q ∈ D ↔ q ∈ MemTest a b) ∧ (∀ q, label c q ∈ E ↔ q ∈ EqTest a b) := by + obtain ⟨d,hd,hdT,hdab⟩ := internal_transitive_container M hM hP hU hS hR hI + (pair_mem M hM hP ha hb) + have had : a.encode (label c) ∈ d := hdT _ hdab _ (ZFSet.mem_pair.mpr (Or.inl rfl)) + have hbd : b.encode (label c) ∈ d := hdT _ hdab _ (ZFSet.mem_pair.mpr (Or.inr rfl)) + obtain ⟨f,hf,hfG⟩ := internal_atomic_graph M hM hP hU hPow hS hd hc hoM + let k := ZFSet.prod d d + have hk : k ∈ M := product_mem M hM hP hU hPow hS hd hd + let e := cons d (cons c (cons k (cons o (cons f + (cons (a.encode (label c)) (cons (b.encode (label c)) (fun _ => c))))))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hd + rcases i with _|i; exact hc + rcases i with _|i; exact hk + rcases i with _|i; exact hoM + rcases i with _|i; exact hf + rcases i with _|i; exact ha + rcases i with _|i; exact hb + exact hc + let φ := AtomicFormula.memTest 1 2 3 4 5 6 7 0 + let ψ := AtomicFormula.eqTest 1 2 3 4 5 6 7 0 + have hφ (q : Conditions c) : φ.Eval (cons (label c q) e) ↔ q ∈ MemTest a b := by + simp only [φ,AtomicFormula.memTest,Formula.eval_disj,AtomicFormula.eval_witness, + AtomicFormula.eval_negMem,cons_zero,cons_succ,e] + exact or_congr (codeWitness_iff hdT ho hfG a b had hbd q) + (codeNeg_iff hdT ho hfG a b had hbd q) + have hψ (q : Conditions c) : ψ.Eval (cons (label c q) e) ↔ q ∈ EqTest a b := by + simp only [ψ,AtomicFormula.eqTest,Formula.eval_disj,AtomicFormula.eval_triple, + AtomicFormula.eval_refute,cons_zero,cons_succ,e] + have hEq := (triple_pair had hbd).trans (hfG.correct hdT ho a b had hbd q) + have hA := codeRefute_iff hdT ho hfG a b had hbd q + have hB := codeRefute_iff hdT ho hfG b a hbd had q + cases a + cases b + exact or_congr hEq (or_congr hA hB) + refine ⟨ZFSet.sep (fun z => φ.Eval (cons z e)) c,sep_mem M hM hS φ e he hc, + ZFSet.sep (fun z => ψ.Eval (cons z e)) c,sep_mem M hM hS ψ e he hc,?_,?_⟩ + · intro q + simp only [ZFSet.mem_sep,label_mem c q,true_and,hφ] + · intro q + simp only [ZFSet.mem_sep,label_mem c q,true_and,hψ] + +theorem groundGeneric_atomic (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) : Generic (names M c) G := by + have requirements (a : Name (Conditions c)) (ha : a ∈ names M c) + (b : Name (Conditions c)) (hb : b ∈ names M c) := + internal_atomic_requirements M hM hP hU hPow hS hR hI hc hoM ho a b ha hb + constructor + · intro a ha b hb + obtain ⟨D,hD,E,hE,hDm,hEe⟩ := requirements a ha b hb + have hd : Dense {q | label c q ∈ D} := by + intro p + obtain ⟨q,hq,hm⟩ := memTest_dense a b p + exact ⟨q,hq,(hDm q).mpr hm⟩ + obtain ⟨q,hq,hqd⟩ := hG D hD hd + exact ⟨q,hq,(hDm q).mp hqd⟩ + · intro a ha b hb + obtain ⟨D,hD,E,hE,hDm,hEe⟩ := requirements a ha b hb + have hd : Dense {q | label c q ∈ E} := by + intro p + obtain ⟨q,hq,hm⟩ := eqTest_dense a b p + exact ⟨q,hq,(hEe q).mpr hm⟩ + obtain ⟨q,hq,hqe⟩ := hG E hE hd + exact ⟨q,hq,(hEe q).mp hqe⟩ + +theorem internal_atomic_truth (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) + (a b : Name (Conditions c)) (ha : a.encode (label c) ∈ M) (hb : b.encode (label c) ∈ M) : + (Name.val G.carrier a = Name.val G.carrier b ↔ ∃ p ∈ G.carrier, EqForces a b p) ∧ + (Name.val G.carrier a ∈ Name.val G.carrier b ↔ ∃ p ∈ G.carrier, MemForces a b p) := by + have hg := groundGeneric_atomic M hM hP hU hPow hS hR hI hc hoM ho G hG + exact ⟨eq_truth (names_childClosed M c hM) G hg a b ha hb, + mem_truth (names_childClosed M c hM) G hg a b ha hb⟩ + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanBits.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanBits.lean new file mode 100644 index 0000000000000000000000000000000000000000..dae3345a2df05ac50aaecd6d3c4362c937a88d59 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanBits.lean @@ -0,0 +1,116 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanProjection +import OAI.Computability.DegreeRigidity.SetModels.InternalRealQuotient + +namespace OAI + +namespace TuringRigidity.InternalBooleanBits +open TransitiveNameModel BoundedSetTheory InternalRegularOperations InternalRegularAlgebra +open InternalBooleanSyntax InternalGeneratedAlgebra +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +def bitFormula (c E V : ℕ) : Formula := + .conj (.subset V c) (.allMem c (.iff (.member 0 (V+1)) + (.allMem (c+1) (.imp (.subset 1 0) + (.existsMem (c+2) (.conj (.subset 1 0) + (.existsMem (E+3) (.subset 0 1)))))))) + +theorem bitFormula_spec (c E V : ℕ) (e : ℕ → ZFSet.{0}) : + (bitFormula c E V).Eval e ↔ e V = bitCode (e c) (e E) := by + simp only [bitFormula,Formula.Eval,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_iff,Formula.eval_imp,cons_zero,cons_succ] + have hb (q : ZFSet.{0}) : + (∃ r ∈ e c, q ⊆ r ∧ ∃ s ∈ e E, s ⊆ r) ↔ + ∃ r ∈ CohenInternalDecision.below (e c) (e E), q ⊆ r := by + simp only [CohenInternalDecision.below,ZFSet.mem_sep] + constructor + · rintro ⟨r,hr,hqr,hs⟩; exact ⟨r,⟨hr,hs⟩,hqr⟩ + · rintro ⟨r,⟨hr,hs⟩,hqr⟩; exact ⟨r,hr,hqr,hs⟩ + simp only [hb] + constructor + · rintro ⟨hVc,hV⟩ + apply ZFSet.ext + intro p + rw [bitCode,mem_regular] + exact ⟨fun h => ⟨hVc h,(hV p (hVc h)).mp h⟩,fun h => (hV p h.1).mpr h.2⟩ + · intro h + rw [h] + exact ⟨(regular_isCode _ _).1,fun p hp => (mem_regular _ _ p).trans (and_iff_right hp)⟩ + +noncomputable def seeds (c B : ZFSet.{0}) (E : ℕ → ZFSet.{0}) : ZFSet.{0} := + B.sep (fun U => ∃ n, U = bitCode c (E n)) + +theorem seeds_mem (M c B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : B ∈ M) (E : ℕ → ZFSet.{0}) + (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) : seeds c B E ∈ M := by + obtain ⟨Q,hQ,hQdef⟩ := internal_power M hM hT.powerSet hc + have hω := sourceT_omega_mem M hM hT + let e := cons c (cons ZFSet.omega (cons Q (fun _ => orbitGraph E))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|i + exact hc; exact hω; exact hQ; exact hgraph + let φ : Formula := .existsMem 2 (.existsMem 4 (.conj (.pairMem 1 0 6) (bitFormula 3 0 2))) + have hφ (U : ZFSet.{0}) : φ.Eval (cons U e) ↔ ∃ n, U = bitCode c (E n) := by + simp only [φ,Formula.Eval,Formula.eval_pairMem,bitFormula_spec,cons_zero,cons_succ,e] + constructor + · rintro ⟨n,hn,W,_,hp,hU⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + have hw := (orbitGraph_pair E n W).mp hp + exact ⟨n,hw ▸ hU⟩ + · rintro ⟨n,hU⟩ + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,E n,(hQdef _).mpr (hE n), + (orbitGraph_pair E n _).mpr rfl,hU⟩ + have hs := sep_mem M hM hT.separation.finitePrefix.bounded φ e he hB + simpa only [hφ,seeds] using hs + +theorem bit_mem_seeds (M c B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M) (n : ℕ) : bitCode c (E n) ∈ seeds c B E := + ZFSet.mem_sep.mpr ⟨(hB _).mpr ⟨bitCode_mem M c _ hM hT hc (hE n),regular_isCode c _⟩,n,rfl⟩ + +theorem interpret_bit (c : ZFSet.{0}) (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ⊆ c) (n : ℕ) : + interpret c (bitCode c (E n)) (regular_isCode c _) = + RealGeneratedPart.bit (InternalRealQuotient.tags c E) n := by + have hl : Lower c (CohenInternalDecision.below c (E n)) := by + intro p hp q hq hpq + obtain ⟨_,r,hr,hrp⟩ := ZFSet.mem_sep.mp hp + exact ZFSet.mem_sep.mpr ⟨hq,r,hr,fun z hz => hpq (hrp hz)⟩ + have he : decode c (CohenInternalDecision.below c (E n)) hl = + RealGeneratedPart.tagLower (InternalRealQuotient.tags c E n) := by + apply SetLike.ext + intro p + exact InternalRealQuotient.label_below c (E n) (hE n) p + apply Heyting.Regular.coe_injective + change decode c (regular c (CohenInternalDecision.below c (E n))) (neg_lower c _) = _ + have hd := decode_regular c (CohenInternalDecision.below c (E n)) + (fun _ h => (ZFSet.mem_sep.mp h).1) hl + apply hd.trans + rw [he] + rfl + +theorem internal_bit_generated_part (M c : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) + (hgraph : orbitGraph E ∈ M) : + ∃ B ∈ M, ∃ Q ∈ M, ∃ A ∈ M, + (∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) ∧ + (∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) ∧ + A = generated c B Q (seeds c B E) ∧ Closed c B Q A ∧ + (∀ n, bitCode c (E n) ∈ A) ∧ + ∀ A' ∈ Q, (∀ n, bitCode c (E n) ∈ A') → Closed c B Q A' → A ⊆ A' := by + obtain ⟨B,hBM,hB⟩ := internal_algebra M c hM hT hc + obtain ⟨Q,hQM,hQ⟩ := internal_power M hM hT.powerSet hBM + have hS := seeds_mem M c B hM hT hc hBM E hE hgraph + have hSB : seeds c B E ⊆ B := fun _ h => (ZFSet.mem_sep.mp h).1 + have hA := generated_mem M c B Q _ hM hT hc hBM hQM hS + refine ⟨B,hBM,Q,hQM,generated c B Q (seeds c B E),hA,hB,hQ,rfl, + generated_closed c B Q _ (algebra_closed M c B Q hM hT hc hB hQ),?_,?_⟩ + · intro n + exact seeds_subset c B Q _ hSB (bit_mem_seeds M c B hM hT hc hB E (fun n => (hE n).1) n) + · intro A' hA' hb hclosed + apply generated_le c B Q _ A' hA' _ hclosed + intro U hU + obtain ⟨_,n,rfl⟩ := ZFSet.mem_sep.mp hU + exact hb n + +end TuringRigidity.InternalBooleanBits + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanDense.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanDense.lean new file mode 100644 index 0000000000000000000000000000000000000000..badca06c4af242a8e172d4d9970142e7c0de1739 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanDense.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanGraph + +namespace OAI + +namespace TuringRigidity.InternalBooleanDense +open Set TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalRegularOrder InternalBooleanSyntax +open InternalGeneratedAlgebra InternalBooleanProjection InternalBooleanGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +noncomputable def basicCode (c p : ZFSet.{0}) : ZFSet.{0} := bitCode c {p} + +theorem below_lower (c U : ZFSet.{0}) : Lower c (CohenInternalDecision.below c U) := by + intro p hp q hq hpq + obtain ⟨_,r,hr,hrp⟩ := ZFSet.mem_sep.mp hp + exact ZFSet.mem_sep.mpr ⟨hq,r,hr,fun z hz => hpq (hrp hz)⟩ + +theorem mem_basicCode (c p : ZFSet.{0}) (hp : p ∈ c) : p ∈ basicCode c p := by + apply subset_regular c _ (fun _ h => (ZFSet.mem_sep.mp h).1) (below_lower c {p}) + exact ZFSet.mem_sep.mpr ⟨hp,p,ZFSet.mem_singleton.mpr rfl,fun _ h => h⟩ + +theorem basicCode_le_iff (c p U : ZFSet.{0}) (hp : p ∈ c) (hU : IsCode c U) : + basicCode c p ⊆ U ↔ p ∈ U := by + constructor + · intro h; exact h (mem_basicCode c p hp) + · intro hpU + apply (regular_le_iff c _ U (fun _ h => (ZFSet.mem_sep.mp h).1) (below_lower c {p}) hU).mpr + intro q hq + obtain ⟨hqc,r,hr,hrq⟩ := ZFSet.mem_sep.mp hq + have hrp := ZFSet.mem_singleton.mp hr + subst r + exact code_lower c U hU p hpU q hqc hrq + +theorem basicCode_mem (M c p : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hp : p ∈ c) : basicCode c p ∈ M := + bitCode_mem M c _ hM hT hc (singleton_mem M hM hT.pairing (hM c hc p hp)) + +def DenseCodes (A D : ZFSet.{0}) : Prop := + ∀ U ∈ A, U ≠ ∅ → ∃ V ∈ D, V ∈ A ∧ V ≠ ∅ ∧ V ⊆ U + +theorem dense_preimage (M c B Q A D : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (hD : DenseCodes A D) : Dense {p : Conditions c | label c p ∈ ZFSet.sUnion D} := by + classical + intro p + let b := basicCode c (label c p) + have hbM : b ∈ M := basicCode_mem M c _ hM hT hc (label_mem c p) + have hbc : IsCode c b := regular_isCode c _ + have hpb : label c p ∈ b := mem_basicCode c _ (label_mem c p) + have hb0 : b ≠ ∅ := fun h => ZFSet.notMem_empty _ (h ▸ hpb) + have hPA := project_mem_part M c B Q A b hM hT hc hBM hAM hbM hB hQ hA + obtain ⟨V,hVD,hVA,hV0,hVP⟩ := hD _ hPA (project_nonempty c A b hbc.1 hb0) + have hVc := ((hB V).mp (hA.1 hVA)).2 + have hex : ∃ q ∈ V, label c p ⊆ q := by + by_contra hn + have hpN : label c p ∈ neg c V := ZFSet.mem_sep.mpr + ⟨label_mem c p,fun q hq hpq => hn ⟨q,hq,hpq⟩⟩ + have hbN : b ⊆ neg c V := (basicCode_le_iff c _ _ (label_mem c p) (neg_isCode c V hVc)).mpr hpN + have hPN := (project_le_iff c A b _ hbc.1 (hA.2.1 V hVA)).mpr hbN + apply hV0 + apply ZFSet.ext + intro q + constructor + · intro hq + have hqN := hPN (hVP hq) + exact False.elim ((ZFSet.mem_sep.mp hqN).2 q hq (fun _ h => h)) + · exact fun h => False.elim (ZFSet.notMem_empty q h) + obtain ⟨q,hq,hpq⟩ := hex + obtain ⟨q,rfl⟩ := label_surjective c (hVc.1 hq) + exact ⟨q,hpq,ZFSet.mem_sUnion.mpr ⟨V,hVD,hq⟩⟩ + +theorem ground_meets_dense_codes (M c B Q A D : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) (hDM : D ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (hD : DenseCodes A D) (G : GenericFilter (Conditions c)) + (hG : AtomicForcing.GroundGeneric M G) : ∃ U ∈ D, Hit G U := by + obtain ⟨p,hp,hpD⟩ := hG (ZFSet.sUnion D) (union_mem M hM hT.union hDM) + (dense_preimage M c B Q A D hM hT hc hBM hAM hB hQ hA hD) + obtain ⟨U,hU,hpU⟩ := ZFSet.mem_sUnion.mp hpD + exact ⟨U,hU,p,hp,hpU⟩ + +end TuringRigidity.InternalBooleanDense + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanExtension.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..49821ebb210ee60dbe56f8c40a6e9b465852c1b2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanExtension.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanName +import OAI.Computability.DegreeRigidity.SetModels.InternalNameEvaluation + +namespace OAI + +namespace TuringRigidity.InternalBooleanExtension +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames +open InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax +open InternalProjectedGeneric InternalBooleanTop InternalBooleanName InternalBooleanGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder +attribute [local instance] codeOrder codePreorder + +noncomputable def hitSet (A g : ZFSet.{0}) : ZFSet.{0} := + (positive A).sep (fun U => ∃ p ∈ g, p ∈ U) + +theorem hitSet_mem (N A g : ZFSet.{0}) (hN : Transitive N) (hT : SourceT N) + (hA : A ∈ N) (hg : g ∈ N) : hitSet A g ∈ N := by + have hs := sep_mem N hN hT.separation.finitePrefix.bounded + (.existsMem 1 (.member 0 1)) (fun _ => g) (fun _ => hg) + (positive_mem N A hN hT hA) + simpa only [hitSet,Formula.Eval,cons_zero,cons_succ] using hs + +theorem projected_filterSet (M c B Q A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) : + genericFilterSet (positive A) (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier = + hitSet A (genericFilterSet c G.carrier) := by + apply ZFSet.ext; intro U + rw [mem_genericFilterSet,hitSet,ZFSet.mem_sep] + constructor + · rintro ⟨q,hq,rfl⟩ + obtain ⟨p,hp,hpq⟩ := hq + exact ⟨label_mem _ q,label c p,(mem_genericFilterSet c G.carrier _).mpr ⟨p,hp,rfl⟩,hpq⟩ + · rintro ⟨hU,p,hp,hpU⟩ + obtain ⟨q,rfl⟩ := label_surjective (positive A) hU + obtain ⟨r,hr,rfl⟩ := (mem_genericFilterSet c G.carrier p).mp hp + exact ⟨q,⟨r,hr,hpU⟩,rfl⟩ + +theorem projected_extension_subset_model (M N c B Q A : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hN : Transitive N) (hTN : SourceT N) (hMN : M ⊆ N) + (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) (hgN : genericFilterSet c G.carrier ∈ N) : + genericExtensionSet M (positive A) + (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier ⊆ N := by + apply InternalNameEvaluation.extension_subset M N hN hTN hMN + rw [projected_filterSet M c B Q A hM hT hc hBM hAM hB hQ hA G] + exact hitSet_mem N A _ hN hTN (hMN hAM) hgN + +theorem projected_extension_subset_original (M c B Q A : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (hTop : ⊤ ∈ G.carrier) : + genericExtensionSet M (positive A) + (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier ⊆ + genericExtensionSet M c G.carrier := by + have hN := genericExtensionSet_transitive M c hM G.carrier + have hTN := extension_sourceT M hM hT hc (InternalCollapse.orderSet_mem M hM hT hc) + (InternalCollapse.orderSet_pair c) G hG hTop + have hMN := ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier hTop + apply projected_extension_subset_model M _ c B Q A hM hT hN hTN hMN hc hBM hAM hB hQ hA G + exact genericFilterSet_mem_extension M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier hTop + +theorem projected_extension_sandwich (M c B Q A : ZFSet.{0}) + [Top (Conditions c)] [Top (Conditions (positive A))] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (ht : label (positive A) ⊤ = c) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) + (hbits : ∀ n, bitCode c (E n) ∈ A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (hTop : ⊤ ∈ G.carrier) : + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + let N := genericExtensionSet M (positive A) H.carrier + Transitive N ∧ SourceT N ∧ M ⊆ N ∧ + (InternalNiceName.nice E : Name (Conditions c)).val G.carrier ∈ N ∧ + genericFilterSet (positive A) H.carrier ∈ N ∧ N ⊆ genericExtensionSet M c G.carrier := by + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + have hHt := top_in_filter c A (fun U hU => ((hB U).mp (hA.1 hU)).2.1) ht H + have hpM := positive_mem M A hM hT hAM + have hHG := projected_ground_generic M c B Q A hM hT hc hBM hAM hB hQ hA G hG + obtain ⟨hoM,ho⟩ := projected_order_code M A hM hT hAM + refine ⟨genericExtensionSet_transitive M _ hM H.carrier, + extension_sourceT M hM hT hpM hoM ho H hHG hHt,?_,?_,?_, + projected_extension_subset_original M c B Q A hM hT hc hBM hAM hB hQ hA G hG hTop⟩ + · exact ground_inclusion_set M _ hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hpM H.carrier hHt + · exact same_value_mem_projected_extension M c B Q A hM hT hc hBM hAM hB hQ hA ht E hE hgraph hbits G hG hTop + · exact genericFilterSet_mem_extension M _ hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hpM H.carrier hHt + +end TuringRigidity.InternalBooleanExtension + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanGeneric.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanGeneric.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c206dfeeeea1ed048ae7cf929f3ac4c800d8fb7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanGeneric.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanBits + +namespace OAI + +namespace TuringRigidity.InternalBooleanGeneric +open Set TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalRegularOrder +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +def Hit {c : ZFSet.{0}} (G : GenericFilter (Conditions c)) (U : ZFSet.{0}) : Prop := + ∃ p ∈ G.carrier, label c p ∈ U + +noncomputable def decision (c U : ZFSet.{0}) : ZFSet.{0} := U ∪ neg c U + +theorem decision_mem (M c U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hU : U ∈ M) : decision c U ∈ M := + binary_union_mem M hM hT.pairing hT.union hU (neg_mem M c U hM hT hc hU) + +theorem decision_dense (c U : ZFSet.{0}) (hUc : U ⊆ c) : + Dense {p : Conditions c | label c p ∈ decision c U} := by + classical + intro p + by_cases h : ∃ q ∈ U, label c p ⊆ q + · obtain ⟨q,hq,hpq⟩ := h + obtain ⟨q,rfl⟩ := label_surjective c (hUc hq) + exact ⟨q,hpq,ZFSet.mem_union.mpr (Or.inl hq)⟩ + · refine ⟨p,le_rfl,ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_sep.mpr ⟨label_mem c p,?_⟩))⟩ + intro q hq hpq + exact h ⟨q,hq,hpq⟩ + +theorem generic_decision (M c U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hU : U ∈ M) (hUc : U ⊆ c) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + Hit G U ∨ Hit G (neg c U) := by + obtain ⟨p,hp,hpd⟩ := hG (decision c U) (decision_mem M c U hM hT hc hU) (decision_dense c U hUc) + rcases ZFSet.mem_union.mp hpd with h | h + · exact Or.inl ⟨p,hp,h⟩ + · exact Or.inr ⟨p,hp,h⟩ + +theorem hit_neg_excludes (c U : ZFSet.{0}) (hU : Lower c U) + (G : GenericFilter (Conditions c)) (hn : Hit G (neg c U)) : ¬ Hit G U := by + rintro ⟨q,hq,hqU⟩ + obtain ⟨p,hp,hpN⟩ := hn + obtain ⟨r,_,hrp,hrq⟩ := G.directed hp hq + have hrU := hU _ hqU _ (label_mem c r) hrq + exact (ZFSet.mem_sep.mp hpN).2 (label c r) hrU hrp + +theorem hit_complement_iff (M c U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hUM : U ∈ M) (hU : IsCode c U) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + Hit G (neg c U) ↔ ¬ Hit G U := by + constructor + · exact hit_neg_excludes c U (code_lower c U hU) G + · intro hn + exact (generic_decision M c U hM hT hc hUM hU.1 G hG).resolve_left hn + +theorem hit_regular_iff (M c U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hUM : U ∈ M) (hUc : U ⊆ c) (hU : Lower c U) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + Hit G (regular c U) ↔ Hit G U := by + constructor + · intro hr + rcases generic_decision M c U hM hT hc hUM hUc G hG with hp | hn + · exact hp + · exact False.elim (hit_neg_excludes c (neg c U) (neg_lower c U) G hr hn) + · rintro ⟨p,hp,hpU⟩ + exact ⟨p,hp,subset_regular c U hUc hU hpU⟩ + +theorem hit_supCode_iff (M c F : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hFM : F ∈ M) (hF : ∀ U ∈ F, IsCode c U) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + Hit G (supCode c F) ↔ ∃ U ∈ F, Hit G U := by + rw [supCode,hit_regular_iff M c _ hM hT hc (union_mem M hM hT.union hFM) + (union_subset c F hF) (union_lower c F (fun U hU => code_lower c U (hF U hU))) G hG] + constructor + · rintro ⟨p,hp,hpF⟩ + obtain ⟨U,hU,hpU⟩ := ZFSet.mem_sUnion.mp hpF + exact ⟨U,hU,p,hp,hpU⟩ + · rintro ⟨U,hU,p,hp,hpU⟩ + exact ⟨p,hp,ZFSet.mem_sUnion.mpr ⟨U,hU,hpU⟩⟩ + +theorem hit_bit_iff (M c : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) + (hTop : ⊤ ∈ G.carrier) (n : ℕ) : + Hit G (bitCode c (E n)) ↔ + natSet n ∈ (InternalNiceName.nice E : RecursiveNames.Name (Conditions c)).val G.carrier := by + have he := InternalBooleanBits.interpret_bit c E (fun n => (hE n).2) n + have hv : Hit G (bitCode c (E n)) ↔ + ∃ p ∈ G.carrier, p ∈ (RealGeneratedPart.bit (InternalRealQuotient.tags c E) n : LowerSet (Conditions c)) := by + change (∃ p ∈ G.carrier, p ∈ (interpret c (bitCode c (E n)) (regular_isCode c _) : LowerSet (Conditions c))) ↔ _ + rw [he] + rw [hv,RealGeneratedPart.bit_hit_iff _ G + (InternalRealQuotient.ground_generic_decisions M c hM hT hc E hE G hG)] + exact (InternalRealQuotient.nice_value_iff E G hTop n).symm + +end TuringRigidity.InternalBooleanGeneric + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanGraph.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8da79cb7d6b163a772346a581511ac5881be122 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanGraph.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanGeneric + +namespace OAI + +namespace TuringRigidity.InternalBooleanGraph +open TransitiveNameModel BoundedSetTheory InternalRegularOperations InternalRegularAlgebra +open InternalRegularOrder InternalBooleanSyntax InternalBooleanProjection + +def projectFormula (c A U V : ℕ) : Formula := + .conj (.subset V c) (.allMem c (.iff (.member 0 (V+1)) + (.allMem (A+1) (.imp (.subset (U+2) 0) (.member 1 0))))) + +theorem projectFormula_spec (c A U V : ℕ) (e : ℕ → ZFSet.{0}) : + (projectFormula c A U V).Eval e ↔ e V = project (e c) (e A) (e U) := by + simp only [projectFormula,Formula.Eval,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_iff,Formula.eval_imp,cons_zero,cons_succ] + have hs (p : ZFSet.{0}) : p ∈ project (e c) (e A) (e U) ↔ + p ∈ e c ∧ ∀ W ∈ e A, e U ⊆ W → p ∈ W := by + simp only [project,infCode,uppers,ZFSet.mem_sep] + exact and_congr_right (fun _ => ⟨fun h W hW hUW => h W ⟨hW,hUW⟩, + fun h W hW => h W hW.1 hW.2⟩) + constructor + · rintro ⟨hVc,hV⟩ + exact ZFSet.ext (fun p => (Iff.intro + (fun h => ⟨hVc h,(hV p (hVc h)).mp h⟩) + (fun h => (hV p h.1).mpr h.2)).trans (hs p).symm) + · intro h + rw [h] + exact ⟨fun _ hp => ((hs _).mp hp).1,fun p hp => (hs p).trans (and_iff_right hp)⟩ + +noncomputable def graph (c B A : ZFSet.{0}) : ZFSet.{0} := + (ZFSet.prod B A).sep (fun z => ∃ U ∈ B, ∃ V ∈ A, z = ZFSet.pair U V ∧ V = project c A U) + +theorem pair_graph (c B A U V : ZFSet.{0}) : + ZFSet.pair U V ∈ graph c B A ↔ U ∈ B ∧ V ∈ A ∧ V = project c A U := by + rw [graph,ZFSet.mem_sep] + constructor + · rintro ⟨_,U',hU,V',hV,he,hp⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hU,hV,hp⟩ + · rintro ⟨hU,hV,hp⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨U,hU,V,hV,rfl⟩,U,hU,V,hV,rfl,hp⟩ + +theorem graph_mem (M c B A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : B ∈ M) (hA : A ∈ M) : graph c B A ∈ M := by + let e := cons c (cons B (fun _ => A)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i; exact hc; exact hB; exact hA + have hp := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hB hA + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 2 (.existsMem 4 (.conj (.orderedPair 2 1 0) (projectFormula 3 5 1 0)))) e he hp + simpa only [graph,Formula.Eval,Formula.eval_orderedPair,projectFormula_spec, + cons_zero,cons_succ,e] using hs + +noncomputable def inclusionOrder (A : ZFSet.{0}) : ZFSet.{0} := + (ZFSet.prod A A).sep (fun z => ∃ U ∈ A, ∃ V ∈ A, z = ZFSet.pair U V ∧ U ⊆ V) + +theorem inclusionOrder_mem (M A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) : inclusionOrder A ∈ M := by + have hp := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hA hA + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.existsMem 2 (.conj (.orderedPair 2 1 0) (.subset 1 0)))) + (fun _ => A) (fun _ => hA) hp + simpa only [inclusionOrder,Formula.Eval,Formula.eval_orderedPair,Formula.eval_subset, + cons_zero,cons_succ] using hs + +theorem pair_inclusionOrder (A U V : ZFSet.{0}) : ZFSet.pair U V ∈ inclusionOrder A ↔ + U ∈ A ∧ V ∈ A ∧ U ⊆ V := by + rw [inclusionOrder,ZFSet.mem_sep] + constructor + · rintro ⟨_,U',hU,V',hV,he,hp⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hU,hV,hp⟩ + · rintro ⟨hU,hV,hp⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨U,hU,V,hV,rfl⟩,U,hU,V,hV,rfl,hp⟩ + +end TuringRigidity.InternalBooleanGraph + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanIntermediate.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanIntermediate.lean new file mode 100644 index 0000000000000000000000000000000000000000..0cddac3d5a4643b61ef74bc701cdca09bfdbec86 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanIntermediate.lean @@ -0,0 +1,59 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanExtension + +namespace OAI + +namespace TuringRigidity.InternalBooleanIntermediate +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames +open InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax InternalBooleanBits +open InternalProjectedGeneric InternalBooleanTop InternalBooleanName InternalBooleanExtension +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder +attribute [local instance] codeOrder codePreorder + +theorem internal_boolean_intermediate (M c : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) : + ∃ B ∈ M, ∃ Q ∈ M, ∃ A ∈ M, + (∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) ∧ + (∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) ∧ + A = InternalGeneratedAlgebra.generated c B Q (seeds c B E) ∧ Closed c B Q A ∧ + ∃ σ : Name (Conditions (positive A)), σ.encode (label (positive A)) ∈ M ∧ + ∀ G : GenericFilter (Conditions c), AtomicForcing.GroundGeneric M G → ⊤ ∈ G.carrier → + ∃ H : GenericFilter (Conditions (positive A)), AtomicForcing.GroundGeneric M H ∧ + (∀ q, q ∈ H.carrier ↔ InternalBooleanGeneric.Hit G (label (positive A) q)) ∧ + σ.val H.carrier = (InternalNiceName.nice E : Name (Conditions c)).val G.carrier ∧ + Transitive (genericExtensionSet M (positive A) H.carrier) ∧ + SourceT (genericExtensionSet M (positive A) H.carrier) ∧ + M ⊆ genericExtensionSet M (positive A) H.carrier ∧ + σ.val H.carrier ∈ genericExtensionSet M (positive A) H.carrier ∧ + genericFilterSet (positive A) H.carrier ∈ genericExtensionSet M (positive A) H.carrier ∧ + genericExtensionSet M (positive A) H.carrier ⊆ genericExtensionSet M c G.carrier := by + obtain ⟨B,hBM,Q,hQM,A,hAM,hB,hQ,heq,hA,hbits,_⟩ := + internal_bit_generated_part M c hM hT hc E hE hgraph + have hcA := top_mem_part M c B Q A hM hT hc hBM hB hQ hA + have hc0 : c ≠ ∅ := by + intro h + exact ZFSet.notMem_empty (label c ⊤) + (Eq.mp (congrArg (fun d => label c ⊤ ∈ d) h) (label_mem c ⊤)) + let _ := booleanTop c A hcA hc0 + have ht : label (positive A) ⊤ = c := label_booleanTop c A hcA hc0 + let σ := booleanName c A E + have hσ := booleanName_internal M c A hM hT hc hAM E hE hgraph + refine ⟨B,hBM,Q,hQM,A,hAM,hB,hQ,heq,hA,σ,hσ,?_⟩ + intro G hG hTop + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + have hv := val_booleanName M c B Q A hM hT hc hBM hAM hB hQ hA ht E hE hbits G hG hTop + obtain ⟨hN,hTN,hMN,_,hHN,hNG⟩ := + projected_extension_sandwich M c B Q A hM hT hc hBM hAM hB hQ hA ht E hE hgraph hbits G hG hTop + exact ⟨H,projected_ground_generic M c B Q A hM hT hc hBM hAM hB hQ hA G hG, + fun _ => Iff.rfl,hv,hN,hTN,hMN,(mem_extensionSet _ _ _ _).mpr ⟨σ,hσ,rfl⟩,hHN,hNG⟩ + +theorem extension_least_for_filter (M A : ZFSet.{0}) + (H : Set (Conditions (positive A))) (N : ZFSet.{0}) + (hN : Transitive N) (hTN : SourceT N) (hMN : M ⊆ N) + (hH : genericFilterSet (positive A) H ∈ N) : + genericExtensionSet M (positive A) H ⊆ N := + InternalNameEvaluation.extension_subset M N hN hTN hMN H hH + +end TuringRigidity.InternalBooleanIntermediate + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanName.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanName.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9f1a53da06c91ec597252b4a41ebc185018cc90 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanName.lean @@ -0,0 +1,114 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanTop +import OAI.Computability.DegreeRigidity.SetModels.InternalSubsetSequence + +namespace OAI + +namespace TuringRigidity.InternalBooleanName +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames +open InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax +open InternalBooleanBits InternalProjectedGeneric InternalBooleanTop +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder +attribute [local instance] codeOrder codePreorder + +noncomputable def tags (c A : ZFSet.{0}) (E : ℕ → ZFSet.{0}) (n : ℕ) : ZFSet.{0} := + (positive A).sep (fun U => U = bitCode c (E n)) + +theorem tags_info (M c A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hA : A ∈ M) (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M) : + ∀ n, tags c A E n ∈ M ∧ tags c A E n ⊆ positive A := by + intro n + refine ⟨?_,fun _ h => (ZFSet.mem_sep.mp h).1⟩ + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (bitFormula 1 2 0) (cons c (fun _ => E n)) + (by intro i; cases i; exact hc; exact hE n) (positive_mem M A hM hT hA) + simpa only [bitFormula_spec,cons_zero,cons_succ,tags] using hs + +theorem tags_graph_mem (M c A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hA : A ∈ M) (E : ℕ → ZFSet.{0}) + (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) : + orbitGraph (tags c A E) ∈ M := by + obtain ⟨R,hRM,hR⟩ := internal_power M hM hT.powerSet hc + let e := cons c (cons R (fun _ => orbitGraph E)) + let φ : BoundedSetTheory.Formula := .existsMem 3 (.conj (.pairMem 2 0 5) (bitFormula 3 0 1)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i; exact hc; exact hRM; exact hgraph + apply InternalSubsetSequence.subset_sequence M (positive A) hM hT + (positive_mem M A hM hT hA) φ e he (tags c A E) + (fun n _ h => (ZFSet.mem_sep.mp h).1) + intro n U hU + simp only [φ,Formula.Eval,Formula.eval_pairMem,bitFormula_spec,cons_zero,cons_succ,e, + tags,ZFSet.mem_sep,and_iff_right hU] + constructor + · rintro ⟨W,_,hnW,hUW⟩ + have hw := (orbitGraph_pair E n W).mp hnW + exact hw ▸ hUW + · intro h + exact ⟨E n,(hR _).mpr (hE n),(orbitGraph_pair E n _).mpr rfl,h⟩ + +noncomputable def booleanName (c A : ZFSet.{0}) [Top (Conditions (positive A))] + (E : ℕ → ZFSet.{0}) : Name (Conditions (positive A)) := + InternalNiceName.nice (tags c A E) + +theorem booleanName_internal (M c A : ZFSet.{0}) [Top (Conditions (positive A))] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hA : A ∈ M) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) + (hgraph : orbitGraph E ∈ M) : (booleanName c A E).encode (label (positive A)) ∈ M := + InternalNiceName.nice_internal M hM hT (positive_mem M A hM hT hA) + (tags c A E) (tags_info M c A hM hT hc hA E (fun n => (hE n).1)) + (tags_graph_mem M c A hM hT hc hA E hE hgraph) + +theorem mem_val_booleanName (c A : ZFSet.{0}) [Top (Conditions (positive A))] + (E : ℕ → ZFSet.{0}) (H : Set (Conditions (positive A))) (hH : ⊤ ∈ H) + (x : ZFSet.{0}) : x ∈ (booleanName c A E).val H ↔ + ∃ n, (∃ q ∈ H, label (positive A) q = bitCode c (E n)) ∧ natSet n = x := by + rw [booleanName,InternalNiceName.mem_val_nice _ H hH] + constructor + · rintro ⟨n,q,hq,ht,hx⟩ + exact ⟨n,⟨q,hq,(ZFSet.mem_sep.mp ht).2⟩,hx⟩ + · rintro ⟨n,⟨q,hq,he⟩,hx⟩ + exact ⟨n,q,hq,ZFSet.mem_sep.mpr ⟨label_mem _ q,he⟩,hx⟩ + +theorem val_booleanName (M c B Q A : ZFSet.{0}) + [Top (Conditions c)] [Top (Conditions (positive A))] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (ht : label (positive A) ⊤ = c) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) + (hbits : ∀ n, bitCode c (E n) ∈ A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) + (hTop : ⊤ ∈ G.carrier) : + (booleanName c A E).val (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier = + (InternalNiceName.nice E : Name (Conditions c)).val G.carrier := by + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + have hHt := top_in_filter c A (fun U hU => ((hB U).mp (hA.1 hU)).2.1) ht H + apply ZFSet.ext + intro x + rw [mem_val_booleanName c A E H.carrier hHt] + dsimp only [H] + simp only [InternalSameNameGeneric.projected_bit_iff M c B Q A hM hT hc hBM hAM + hB hQ hA E hE hbits G hG hTop] + constructor + · rintro ⟨n,hn,rfl⟩; exact hn + · intro hx + obtain ⟨n,p,hp,hpE,hnx⟩ := (InternalNiceName.mem_val_nice E G.carrier hTop x).mp hx + exact ⟨n,hnx.symm ▸ hx,hnx⟩ + +theorem same_value_mem_projected_extension (M c B Q A : ZFSet.{0}) + [Top (Conditions c)] [Top (Conditions (positive A))] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (ht : label (positive A) ⊤ = c) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) + (hbits : ∀ n, bitCode c (E n) ∈ A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (hTop : ⊤ ∈ G.carrier) : + (InternalNiceName.nice E : Name (Conditions c)).val G.carrier ∈ + genericExtensionSet M (positive A) (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier := + (mem_extensionSet _ _ _ _).mpr ⟨booleanName c A E, + booleanName_internal M c A hM hT hc hAM E hE hgraph, + val_booleanName M c B Q A hM hT hc hBM hAM hB hQ hA ht E hE hbits G hG hTop⟩ + +end TuringRigidity.InternalBooleanName + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanProjection.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..63abfdf81d20b6b1c2b4fa55ebfb1dabfdec8909 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanProjection.lean @@ -0,0 +1,112 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalRegularOrder + +namespace OAI + +namespace TuringRigidity.InternalBooleanProjection +open TransitiveNameModel BoundedSetTheory InternalRegularOperations InternalRegularAlgebra +open InternalRegularOrder InternalBooleanSyntax InternalGeneratedAlgebra + +noncomputable def complements (c B F : ZFSet.{0}) : ZFSet.{0} := + B.sep (fun V => ∃ U ∈ F, V = neg c U) + +theorem complements_mem (M c B F : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : B ∈ M) (hF : F ∈ M) : complements c B F ∈ M := by + let e := cons c (fun _ => F) + have he : ∀ i, e i ∈ M := by intro i; cases i; exact hc; exact hF + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 2 (negFormula 2 0 1)) e he hB + simpa only [complements,Formula.Eval,negFormula_spec,cons_zero,cons_succ,e] using hs + +theorem inf_eq_neg_sup (c B F : ZFSet.{0}) + (hB : ∀ U ∈ B, IsCode c U) (hF : F ⊆ B) + (hN : ∀ U ∈ F, neg c U ∈ B) : + infCode c F = neg c (supCode c (complements c B F)) := by + have hFc := fun U hU => hB U (hF hU) + have hNc : ∀ V ∈ complements c B F, IsCode c V := + fun V hV => hB V (ZFSet.mem_sep.mp hV).1 + have hI := inf_isCode c F hFc + have hni : supCode c (complements c B F) ⊆ neg c (infCode c F) := by + apply (supCode_le_iff c _ _ hNc (neg_isCode c _ hI)).mpr + intro V hV + obtain ⟨_,U,hU,rfl⟩ := ZFSet.mem_sep.mp hV + exact neg_antitone c _ U (inf_subset c F hU) + apply ZFSet.ext + intro p + constructor + · intro hp + apply neg_antitone c _ _ hni + change p ∈ regular c (infCode c F) + rwa [hI.2] + · intro hp + refine ZFSet.mem_sep.mpr ⟨neg_subset c _ hp,fun U hU => ?_⟩ + have hnU : neg c U ∈ complements c B F := + ZFSet.mem_sep.mpr ⟨hN U hU,U,hU,rfl⟩ + have hx := neg_antitone c _ _ (subset_supCode c _ hNc hnU) hp + change p ∈ regular c U at hx + rwa [(hFc U hU).2] at hx + +theorem closed_inf (M c B Q A F : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) + (hA : Closed c B Q A) (hFM : F ∈ M) (hFA : F ⊆ A) : infCode c F ∈ A := by + have hFB : F ⊆ B := fun _ h => hA.1 (hFA h) + have hNF : complements c B F ⊆ A := by + intro V hV + obtain ⟨_,U,hU,rfl⟩ := ZFSet.mem_sep.mp hV + exact hA.2.1 U (hFA hU) + have hNQ : complements c B F ∈ Q := (hQ _).mpr + ⟨complements_mem M c B F hM hT hc hBM hFM,fun _ h => (ZFSet.mem_sep.mp h).1⟩ + rw [inf_eq_neg_sup c B F (fun U hU => ((hB U).mp hU).2) hFB + (fun U hU => hA.1 (hA.2.1 U (hFA hU)))] + exact hA.2.1 _ (hA.2.2 _ hNQ hNF) + +noncomputable def uppers (A U : ZFSet.{0}) : ZFSet.{0} := A.sep (fun V => U ⊆ V) + +noncomputable def project (c A U : ZFSet.{0}) : ZFSet.{0} := infCode c (uppers A U) + +theorem uppers_mem (M A U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hU : U ∈ M) : uppers A U ∈ M := by + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (.subset 1 0) (fun _ => U) (fun _ => hU) hA + simpa only [uppers,Formula.eval_subset,cons_zero,cons_succ] using hs + +theorem project_internal (M c A U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hA : A ∈ M) (hU : U ∈ M) : project c A U ∈ M := + inf_mem M c _ hM hT hc (uppers_mem M A U hM hT hA hU) + +theorem project_mem_part (M c B Q A U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) (hUM : U ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) : project c A U ∈ A := + closed_inf M c B Q A _ hM hT hc hBM hB hQ hA + (uppers_mem M A U hM hT hAM hUM) (fun _ h => (ZFSet.mem_sep.mp h).1) + +theorem subset_project (c A U : ZFSet.{0}) (hUc : U ⊆ c) : U ⊆ project c A U := + subset_inf c _ U hUc (fun _ h => (ZFSet.mem_sep.mp h).2) + +theorem project_le_iff (c A U V : ZFSet.{0}) (hUc : U ⊆ c) (hV : V ∈ A) : + project c A U ⊆ V ↔ U ⊆ V := by + constructor + · intro h p hp; exact h (subset_project c A U hUc hp) + · intro h; exact inf_subset c _ (ZFSet.mem_sep.mpr ⟨hV,h⟩) + +theorem project_fixed (c A U : ZFSet.{0}) (hUc : U ⊆ c) (hU : U ∈ A) : project c A U = U := by + have h := (project_le_iff c A U U hUc hU).mpr (fun _ h => h) + exact ZFSet.ext (fun p => ⟨fun hp => h hp,fun hp => subset_project c A U hUc hp⟩) + +theorem project_nonempty (c A U : ZFSet.{0}) (hUc : U ⊆ c) (hU : U ≠ ∅) : project c A U ≠ ∅ := by + intro hp + apply hU + apply ZFSet.ext + intro p + constructor + · intro h + have hx := subset_project c A U hUc h + rw [hp] at hx + exact hx + · exact fun h => False.elim (ZFSet.notMem_empty p h) + +end TuringRigidity.InternalBooleanProjection + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanSyntax.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..402db7c33df54b486e8d34c38232fee09fe3fa63 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanSyntax.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalRegularAlgebra + +namespace OAI + +namespace TuringRigidity.InternalBooleanSyntax +open TransitiveNameModel BoundedSetTheory InternalRegularOperations InternalRegularAlgebra + +def negFormula (c U V : ℕ) : Formula := + .conj (.subset V c) (.allMem c (.iff (.member 0 (V+1)) + (.allMem (U+1) (.neg (.subset 1 0))))) + +theorem negFormula_spec (c U V : ℕ) (e : ℕ → ZFSet.{0}) : + (negFormula c U V).Eval e ↔ e V = neg (e c) (e U) := by + simp only [negFormula,Formula.Eval,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_iff,cons_zero,cons_succ] + constructor + · rintro ⟨hVc,hV⟩ + apply ZFSet.ext + intro p + rw [neg,ZFSet.mem_sep] + exact ⟨fun h => ⟨hVc h,(hV p (hVc h)).mp h⟩,fun h => (hV p h.1).mpr h.2⟩ + · intro h + rw [h] + refine ⟨neg_subset _ _,fun p hp => ?_⟩ + exact (ZFSet.mem_sep).trans (and_iff_right hp) + +def supFormula (c F V : ℕ) : Formula := + .conj (.subset V c) (.allMem c (.iff (.member 0 (V+1)) + (.allMem (c+1) (.imp (.subset 1 0) + (.existsMem (F+2) (.existsMem 0 (.subset 2 0))))))) + +theorem supFormula_spec (c F V : ℕ) (e : ℕ → ZFSet.{0}) : + (supFormula c F V).Eval e ↔ e V = supCode (e c) (e F) := by + simp only [supFormula,Formula.Eval,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_iff,Formula.eval_imp,cons_zero,cons_succ] + have hu (q : ZFSet.{0}) : (∃ U ∈ e F, ∃ r ∈ U, q ⊆ r) ↔ + ∃ r ∈ ZFSet.sUnion (e F), q ⊆ r := by + constructor + · rintro ⟨U,hU,r,hr,hqr⟩; exact ⟨r,ZFSet.mem_sUnion.mpr ⟨U,hU,hr⟩,hqr⟩ + · rintro ⟨r,hr,hqr⟩; obtain ⟨U,hU,hr⟩ := ZFSet.mem_sUnion.mp hr + exact ⟨U,hU,r,hr,hqr⟩ + simp only [hu] + constructor + · rintro ⟨hVc,hV⟩ + apply ZFSet.ext + intro p + rw [supCode,mem_regular] + exact ⟨fun h => ⟨hVc h,(hV p (hVc h)).mp h⟩,fun h => (hV p h.1).mpr h.2⟩ + · intro h + rw [h] + refine ⟨(join_isCode _ _).1,fun p hp => ?_⟩ + exact (mem_regular _ _ p).trans (and_iff_right hp) + +def Closed (c B Q A : ZFSet.{0}) : Prop := + A ⊆ B ∧ (∀ U ∈ A, neg c U ∈ A) ∧ + ∀ F ∈ Q, F ⊆ A → supCode c F ∈ A + +def closedFormula (c B Q A : ℕ) : Formula := + .conj (.subset A B) (.conj + (.allMem A (.existsMem (A+1) (negFormula (c+2) 1 0))) + (.allMem Q (.imp (.subset 0 (A+1)) + (.existsMem (A+1) (supFormula (c+2) 1 0))))) + +theorem closedFormula_spec (c B Q A : ℕ) (e : ℕ → ZFSet.{0}) : + (closedFormula c B Q A).Eval e ↔ Closed (e c) (e B) (e Q) (e A) := by + simp only [closedFormula,Formula.Eval,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_imp,negFormula_spec,supFormula_spec,cons_zero,cons_succ,Closed] + simp only [exists_eq_right] + +noncomputable def candidates (c B Q S : ZFSet.{0}) : ZFSet.{0} := + Q.sep (fun A => S ⊆ A ∧ Closed c B Q A) + +theorem candidates_mem (M c B Q S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : B ∈ M) (hQ : Q ∈ M) (hS : S ∈ M) : + candidates c B Q S ∈ M := by + let e := cons c (cons B (cons Q (fun _ => S))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|i + exact hc; exact hB; exact hQ; exact hS + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (.conj (.subset 4 0) (closedFormula 1 2 3 0)) e he hQ + simpa only [candidates,Formula.Eval,Formula.eval_subset,closedFormula_spec, + cons_zero,cons_succ,e] using hs + +end TuringRigidity.InternalBooleanSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanTop.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanTop.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d5107f001074839031b0f150a0b697df9338c1c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBooleanTop.lean @@ -0,0 +1,44 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalSameNameGeneric + +namespace OAI + +namespace TuringRigidity.InternalBooleanTop +open TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalRegularOrder +open InternalBooleanSyntax InternalBooleanProjection InternalProjectedGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder +attribute [local instance] codeOrder codePreorder + +theorem top_mem_part (M c B Q A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) : c ∈ A := by + have h0 : (∅ : ZFSet.{0}) ∈ M := hM _ (sourceT_omega_mem M hM hT) _ ZFSet.omega_zero + have h := closed_inf M c B Q A ∅ hM hT hc hBM hB hQ hA h0 + (fun x hx => False.elim (ZFSet.notMem_empty x hx)) + have he : infCode c ∅ = c := by + apply ZFSet.ext; intro p + simp only [infCode,ZFSet.mem_sep,ZFSet.notMem_empty,false_implies,implies_true,and_true] + rwa [he] at h + +@[instance_reducible] +noncomputable def booleanTop (c A : ZFSet.{0}) (hcA : c ∈ A) (hc0 : c ≠ ∅) : + Top (Conditions (positive A)) := + ⟨Classical.choose (label_surjective (positive A) (ZFSet.mem_sep.mpr ⟨hcA,hc0⟩))⟩ + +theorem label_booleanTop (c A : ZFSet.{0}) (hcA : c ∈ A) (hc0 : c ≠ ∅) : + @label (positive A) (booleanTop c A hcA hc0).top = c := + Classical.choose_spec (label_surjective (positive A) (ZFSet.mem_sep.mpr ⟨hcA,hc0⟩)) + +theorem top_in_filter (c A : ZFSet.{0}) [Top (Conditions (positive A))] + (hAc : ∀ U ∈ A, U ⊆ c) (ht : label (positive A) ⊤ = c) + (H : GenericFilter (Conditions (positive A))) : ⊤ ∈ H.carrier := by + obtain ⟨p,hp⟩ := H.nonempty + apply H.upper (q := ⊤) _ hp + change label (positive A) p ⊆ label (positive A) ⊤ + rw [ht] + exact hAc _ (label_info A p).1 + +end TuringRigidity.InternalBooleanTop + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBoundedTruth.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBoundedTruth.lean new file mode 100644 index 0000000000000000000000000000000000000000..68c17bd5bd883a3c81c49174b9ca399f6c504e26 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalBoundedTruth.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedSupport + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem internal_decision (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (φ : BoundedSetTheory.Formula) (e : ℕ → Name (Conditions c)) + (he : ∀ i, (e i).encode (label c) ∈ M) : + ∃ D ∈ M, ∀ q, label c q ∈ D ↔ q ∈ Decision e φ := by + obtain ⟨d,hd,hdT,he0,hen⟩ := finite_container M hM hP hU hS hR hI + (fun i => (e i).encode (label c)) he (bound φ) + let e' := truncate (bound φ) e + have he' (i) : (e' i).encode (label c) ∈ d := by + dsimp only [e',truncate] + split + · exact hen i ‹_› + · exact he0 + obtain ⟨f,hf,hfG⟩ := internal_atomic_graph M hM hP hU hPow hS hd hc hoM + let k := ZFSet.prod d d + have hk : k ∈ M := product_mem M hM hP hU hPow hS hd hd + let env := cons d (cons c (cons k (cons o (cons f (fun i => (e' i).encode (label c)))))) + have henv : ∀ i, env i ∈ M := by + intro i + rcases i with _|i; exact hd + rcases i with _|i; exact hc + rcases i with _|i; exact hk + rcases i with _|i; exact hoM + rcases i with _|i; exact hf + exact hM d hd _ (he' i) + let ψ := Formula.disj (code φ 1 2 3 4 5 (fun i => i+6) 0) + (code (.neg φ) 1 2 3 4 5 (fun i => i+6) 0) + have hψ (q : Conditions c) : ψ.Eval (cons (label c q) env) ↔ q ∈ Decision e φ := by + have hcφ (χ : BoundedSetTheory.Formula) := eval_code χ hdT ho hfG e' he' q + (cons (label c q) env) 1 2 3 4 5 (fun i => i+6) 0 + ⟨rfl,rfl,rfl,rfl,rfl,rfl⟩ (fun _ => rfl) + rw [Formula.eval_disj,hcφ φ,hcφ (.neg φ)] + exact or_congr (truncate_forces φ e q) (truncate_forces (.neg φ) e q) + refine ⟨ZFSet.sep (fun q => ψ.Eval (cons q env)) c,sep_mem M hM hS ψ env henv hc,?_⟩ + intro q + simp only [ZFSet.mem_sep,label_mem c q,true_and,hψ] + +theorem groundGeneric_bounded (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) : Generic (names M c) G := by + intro φ e he + obtain ⟨D,hD,hDdef⟩ := internal_decision M hM hP hU hPow hS hR hI hc hoM ho φ e he + have hd : Dense {q | label c q ∈ D} := by + intro p + obtain ⟨q,hq,hf⟩ := decision_dense e φ p + exact ⟨q,hq,(hDdef q).mpr hf⟩ + obtain ⟨q,hq,hqd⟩ := hG D hD hd + exact ⟨q,hq,(hDdef q).mp hqd⟩ + +theorem internal_bounded_truth (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) + (φ : BoundedSetTheory.Formula) (e : ℕ → Name (Conditions c)) + (he : ∀ i, (e i).encode (label c) ∈ M) : + φ.Eval (fun i => (e i).val G.carrier) ↔ ∃ p ∈ G.carrier, Forces e φ p := + truth (names_childClosed M c hM) G + (groundGeneric_atomic M hM hP hU hPow hS hR hI hc hoM ho G hG) + (groundGeneric_bounded M hM hP hU hPow hS hR hI hc hoM ho G hG) φ e he + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCheckRecursion.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCheckRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b37d2abb91e0334ad97b492d6e9068bf98da41c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCheckRecursion.lean @@ -0,0 +1,154 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalHull +import OAI.Computability.DegreeRigidity.Syntax.CheckGraphConstruction + +namespace OAI + +namespace TuringRigidity.TransitiveNameModel +open RecursiveNames BoundedSetTheory +universe u + +def checkCertificate : SigmaFormula := .existsSet (.existsSet (.bounded + (.conj (.isHull 1 3 4 5) (CheckFormula.graph 1 0 2 6)))) + +theorem realize_checkCertificate (M d q t : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hdM : d ∈ M) (hqM : q ∈ M) (htM : t ∈ M) + (hd : Transitive d) (hq : ∀ c, c ∈ q ↔ c ∈ M ∧ c ⊆ d) + {x f : ZFSet.{u}} (hx : x ∈ d) (hf : f ∈ M) : + checkCertificate.Realize M (cons f (cons x (cons d (cons q (cons t (fun _ => d)))))) ↔ + ∃ r ∈ M, CheckGraph (hull d q x) r f t := by + have hxM := hM d hdM x hx + have matrix (c r : ZFSet.{u}) (hc : c ∈ M) (hr : r ∈ M) : + (Formula.conj (.isHull 1 3 4 5) (CheckFormula.graph 1 0 2 6)).Realize M + (cons r (cons c (cons f (cons x (cons d (cons q (cons t (fun _ => d)))))))) ↔ + c = hull d q x ∧ CheckGraph c r f t := by + have he : ∀ i, (cons r (cons c (cons f (cons x + (cons d (cons q (cons t (fun _ => d)))))))) i ∈ M := by + intro i + rcases i with _|i; exact hr + rcases i with _|i; exact hc + rcases i with _|i; exact hf + rcases i with _|i; exact hxM + rcases i with _|i; exact hdM + rcases i with _|i; exact hqM + rcases i with _|i; exact htM + exact hdM + rw [Formula.absolute _ M hM _ he] + simp only [Formula.Eval,Formula.eval_isHull,CheckFormula.eval_graph,cons_zero,cons_succ] + exact and_congr (isHull_iff M d q hM hS hdM hqM hd hq hx hc) Iff.rfl + change (∃ c ∈ M, ∃ r ∈ M, _) ↔ _ + constructor + · rintro ⟨c,hc,r,hr,h⟩ + obtain ⟨rfl,hg⟩ := (matrix c r hc hr).mp h + exact ⟨r,hr,hg⟩ + · rintro ⟨r,hr,hg⟩ + have hc := hull_mem M d q hM hS hdM hqM hxM + exact ⟨_,hc,r,hr,(matrix _ r hc hr).mpr ⟨rfl,hg⟩⟩ + +theorem internal_checkGraph (M d q t : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) + (hdM : d ∈ M) (hqM : q ∈ M) (htM : t ∈ M) (hd : Transitive d) + (hq : ∀ c, c ∈ q ↔ c ∈ M ∧ c ⊆ d) (x : ZFSet.{u}) (hx : x ∈ d) : + ∃ f ∈ M, CheckGraph (hull d q x) (iterUnion 2 f) f t := by + induction x using ZFSet.inductionOn with + | h x ih => + have hxM := hM d hdM x hx + let e := cons d (cons q (cons t (fun _ => d))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hdM + rcases i with _|i; exact hqM + rcases i with _|i; exact htM + exact hdM + have cert (y f : ZFSet.{u}) (hy : y ∈ x) (hf : f ∈ M) : + checkCertificate.Realize M (cons f (cons y e)) ↔ + ∃ r ∈ M, CheckGraph (hull d q y) r f t := + realize_checkCertificate M d q t hM hS hdM hqM htM hd hq (hd x hx y hy) hf + obtain ⟨b,hb,hbdef⟩ := hR checkCertificate e he x hxM (by + intro y hy + obtain ⟨f,hf,hfg⟩ := ih y hy (hd x hx y hy) + refine ⟨f,hf,(cert y f hy hf).mpr + ⟨_,iterUnion_mem M hM hU hf 2,hfg⟩,?_⟩ + intro g hg hcg + obtain ⟨r,_,hgg⟩ := (cert y g hy hg).mp hcg + exact hgg.unique hfg) + have hbg (f : ZFSet.{u}) : f ∈ b ↔ + ∃ y ∈ x, ∃ r ∈ M, CheckGraph (hull d q y) r f t := by + constructor + · intro hf + have hfM := hM b hb f hf + obtain ⟨y,hy,hc⟩ := (hbdef f hfM).mp hf + exact ⟨y,hy,(cert y f hy hfM).mp hc⟩ + · rintro ⟨y,hy,r,hr,hg⟩ + obtain ⟨f',hf',hg'⟩ := ih y hy (hd x hx y hy) + have heq := hg.unique hg' + have hfM : f ∈ M := heq ▸ hf' + exact (hbdef f hfM).mpr ⟨y,hy,(cert y f hy hfM).mpr ⟨r,hr,hg⟩⟩ + let g := ZFSet.sUnion b + have hgM : g ∈ M := union_mem M hM hU hb + have hg (z : ZFSet.{u}) : z ∈ g ↔ + ∃ y ∈ x, ∃ w ∈ hull d q y, z = ZFSet.pair w (checkedCode t w) := by + constructor + · intro hz + obtain ⟨f,hf,hzf⟩ := ZFSet.mem_sUnion.mp hz + obtain ⟨y,hy,r,_,hfg⟩ := (hbg f).mp hf + exact ⟨y,hy,(hfg.mem_iff z).mp hzf⟩ + · rintro ⟨y,hy,w,hw,hz⟩ + obtain ⟨f,hf,hfg⟩ := ih y hy (hd x hx y hy) + exact ZFSet.mem_sUnion.mpr ⟨f,(hbg f).mpr + ⟨y,hy,_,iterUnion_mem M hM hU hf 2,hfg⟩,(hfg.mem_iff z).mpr ⟨w,hw,hz⟩⟩ + have hvalue : taggedImage x g t = checkedCode t x := by + apply ZFSet.ext + intro z + rw [mem_taggedImage,mem_checkedCode] + constructor + · rintro ⟨y,hy,w,hw,hz⟩ + obtain ⟨a,_,v,_,hp⟩ := (hg _).mp hw + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact ⟨y,hy,hz⟩ + · rintro ⟨y,hy,hz⟩ + exact ⟨y,hy,_,(hg _).mpr + ⟨y,hy,y,self_mem_hull d q (hd x hx y hy),rfl⟩,hz⟩ + have hvM : checkedCode t x ∈ M := hvalue ▸ + taggedImage_mem M hM hP hU hPow hS hxM hgM htM + let f := g ∪ ({ZFSet.pair x (checkedCode t x)} : ZFSet.{u}) + have hfM : f ∈ M := binary_union_mem M hM hP hU hgM + (singleton_mem M hM hP (orderedPair_mem M hM hP hxM hvM)) + refine ⟨f,hfM,checkGraph_of_mem_iff _ f t (hull_transitive d q x hd) ?_⟩ + intro z + change z ∈ g ∪ ({ZFSet.pair x (checkedCode t x)} : ZFSet.{u}) ↔ _ + rw [ZFSet.mem_union,ZFSet.mem_singleton,hg] + constructor + · rintro (⟨y,hy,w,hw,hz⟩|hz) + · exact ⟨w,(hull_unfold M d q hM hP hU hS hR hdM hqM hd hq hx w).mpr + (Or.inr ⟨y,hy,hw⟩),hz⟩ + · exact ⟨x,self_mem_hull d q hx,hz⟩ + · rintro ⟨w,hw,hz⟩ + rcases (hull_unfold M d q hM hP hU hS hR hdM hqM hd hq hx w).mp hw with rfl|⟨y,hy,hw⟩ + · exact Or.inr hz + · exact Or.inl ⟨y,hy,w,hw,hz⟩ + +theorem checkedCode_mem_of_container (M d t : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) + (hdM : d ∈ M) (htM : t ∈ M) (hd : Transitive d) + {x : ZFSet.{u}} (hx : x ∈ d) : checkedCode t x ∈ M := by + obtain ⟨q,hqM,hq⟩ := internal_power M hM hPow hdM + obtain ⟨f,hf,hfg⟩ := internal_checkGraph M d q t hM hP hU hPow hS hR + hdM hqM htM hd hq x hx + obtain ⟨v,hv,hfv,_⟩ := hfg.2.2.1 x (self_mem_hull d q hx) + rw [←hfg.correct x (self_mem_hull d q hx) v hv hfv] + exact hM _ (iterUnion_mem M hM hU hf 2) v hv + +theorem encoded_check_mem_of_container (M p d : ZFSet.{u}) [Top (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) (hR : SigmaReplacement M) + (hpM : p ∈ M) (hdM : d ∈ M) (hd : Transitive d) + {x : ZFSet.{u}} (hx : x ∈ d) : (Name.check x).encode (label p) ∈ M := by + rw [encode_check] + exact checkedCode_mem_of_container M d _ hM hP hU hPow hS hR hdM + (hM p hpM _ (label_mem p ⊤)) hd hx + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCheckedValue.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCheckedValue.lean new file mode 100644 index 0000000000000000000000000000000000000000..60c4d95de62f1260071005d4298b879b2897bafc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCheckedValue.lean @@ -0,0 +1,45 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementaryCheckedCode +import OAI.Computability.DegreeRigidity.Representation.GroundInclusion + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel SentenceForm +universe u + +theorem checkedValue_complete (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hv : e 0 = checkedCode (e 2) (e 1)) : + checkedValueFormula.Sat (M : Set ZFSet) e := by + have hS := hT.separation.finitePrefix.bounded + have hR := hT.replacement.finitePrefix + obtain ⟨d,hd,hdT,hxd⟩ := internal_transitive_container M hM hT.pairing hT.union hS hR + hT.infinity (he 1) + obtain ⟨q,hq,hqdef⟩ := internal_power M hM hT.powerSet hd + obtain ⟨f,hf,hg⟩ := internal_checkGraph M d q (e 2) hM hT.pairing hT.union hT.powerSet + hS hR hd hq (he 2) hdT hqdef (e 1) hxd + have hh := hull_mem M d q hM hS hd hq (he 1) + have hr := iterUnion_mem M hM hT.union hf 2 + have hx := self_mem_hull d q hxd + obtain ⟨w,hw,hfw,_⟩ := hg.2.2.1 (e 1) hx + have hwv : w = e 0 := (hg.correct (e 1) hx w hw hfw).trans hv.symm + refine ⟨BoundedSetTheory.hull d q (e 1),hh,iterUnion 2 f,hr,f,hf,?_⟩ + have hi : ∀ i, cons f (cons (iterUnion 2 f) (cons (BoundedSetTheory.hull d q (e 1)) e)) i ∈ M := by + intro i; rcases i with _|_|_|i + exact hf + exact hr + exact hh + exact he i + rw [bounded_sat,Formula.absolute _ M hM _ hi] + simp only [Formula.Eval,CheckFormula.eval_graph,Formula.eval_pairMem,cons_zero,cons_succ] + exact ⟨hg,hx,hwv ▸ hw,hwv ▸ hfw⟩ + +theorem checkedValue_spec (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + checkedValueFormula.Sat (M : Set ZFSet) e ↔ e 0 = checkedCode (e 2) (e 1) := + ⟨checkedValue_sound M hM e he,checkedValue_complete M hM hT e he⟩ + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalChoice.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalChoice.lean new file mode 100644 index 0000000000000000000000000000000000000000..051b2a9e0c9ae6a41f3c7dfa598bd3d82914239e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalChoice.lean @@ -0,0 +1,59 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaSeparationName + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +def ChoiceGraph (a f : ZFSet.{u}) : Prop := + (∀ z ∈ f, ∃ x ∈ a, ∃ y ∈ x, z = ZFSet.pair x y) ∧ + (∀ x ∈ a, ∃ y ∈ x, ZFSet.pair x y ∈ f ∧ + ∀ z ∈ x, ZFSet.pair x z ∈ f → z = y) + +def Choice (M : ZFSet.{u}) : Prop := + ∀ a ∈ M, (∀ x ∈ a, ∃ y, y ∈ x) → ∃ f ∈ M, ChoiceGraph a f + +namespace ChoiceCode +open Formula + +def graph (a f : ℕ) : Formula := + .conj (allMem f (.existsMem (a+1) (.existsMem 0 (orderedPair 2 1 0)))) + (allMem a (.existsMem 0 (.conj (pairMem 1 0 (f+2)) + (allMem 1 (imp (pairMem 2 0 (f+3)) (.equal 0 1)))))) + +theorem eval_graph (a f : ℕ) (e : ℕ → ZFSet.{u}) : + (graph a f).Eval e ↔ ChoiceGraph (e a) (e f) := by + simp only [graph,ChoiceGraph,Formula.Eval,eval_allMem,eval_orderedPair, + eval_pairMem,eval_imp,cons_zero,cons_succ] +end ChoiceCode + +theorem internal_selector (M : ZFSet.{u}) (hM : Transitive M) + (hPow : PowerSet M) (hS : Separation M) (hAC : Choice M) + {t : ZFSet.{u}} (ht : t ∈ M) : + ∃ a ∈ M, ∃ f ∈ M, ChoiceGraph a f ∧ + ∀ x, x ∈ a ↔ x ∈ M ∧ x ⊆ t ∧ ∃ y, y ∈ x := by + obtain ⟨q,hq,hqdef⟩ := internal_power M hM hPow ht + let a := ZFSet.sep (fun x => ∃ y, y ∈ x) q + have ha : a ∈ M := by + simpa only [Formula.Eval,cons_zero,iff_true,exists_prop,and_true,a] using + sep_mem M hM hS (.existsMem 0 (.equal 0 0)) (fun _ => t) (fun _ => ht) hq + have hadef (x : ZFSet.{u}) : x ∈ a ↔ x ∈ M ∧ x ⊆ t ∧ ∃ y, y ∈ x := by + rw [ZFSet.mem_sep,hqdef] + exact and_assoc + obtain ⟨f,hf,hfg⟩ := hAC a ha (fun x hx => ((hadef x).mp hx).2.2) + exact ⟨a,ha,f,hf,hfg,hadef⟩ + +theorem ChoiceGraph.functional {a f : ZFSet.{u}} (hf : ChoiceGraph a f) + {x y z : ZFSet.{u}} (hxy : ZFSet.pair x y ∈ f) (hxz : ZFSet.pair x z ∈ f) : y = z := by + obtain ⟨a',ha,b,hb,he⟩ := hf.1 _ hxy + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + obtain ⟨a',_,b,hb',he⟩ := hf.1 _ hxz + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + obtain ⟨v,_,hxv,hunique⟩ := hf.2 x ha + exact (hunique y hb hxy).trans (hunique z hb' hxz).symm + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCollapseConditions.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCollapseConditions.lean new file mode 100644 index 0000000000000000000000000000000000000000..fcc966ebcfacd168e82927db49d37a03f9741e8b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCollapseConditions.lean @@ -0,0 +1,137 @@ +import OAI.Computability.DegreeRigidity.Syntax.FiniteModelGraph +import OAI.Computability.DegreeRigidity.Representation.GenericFilterName + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalCollapse +open TransitiveNameModel +universe u + +def Prefix (A p : ZFSet.{u}) : Prop := + ∃ n : ℕ, TransitiveNameModel.FunctionGraph (natSet n) A p + +theorem prefix_subset {A p : ZFSet.{u}} (hp : Prefix A p) : p ⊆ ZFSet.prod ZFSet.omega A := by + obtain ⟨n,hp⟩ := hp + intro z hz + obtain ⟨i,hi,x,hx,rfl⟩ := hp.1 z hz + obtain ⟨k,_,rfl⟩ := (mem_natSet n i).mp hi + exact ZFSet.mem_prod.mpr ⟨natSet k,(mem_omega _).mpr ⟨k,rfl⟩,x,hx,rfl⟩ + +theorem prefix_empty (A : ZFSet.{u}) : Prefix A ∅ := + ⟨0,fun _ h => False.elim (ZFSet.notMem_empty _ h),fun _ h => False.elim (ZFSet.notMem_empty _ h)⟩ + +noncomputable def append (p : ZFSet.{u}) (n : ℕ) (x : ZFSet.{u}) : ZFSet.{u} := + p ∪ ({ZFSet.pair (natSet n) x} : ZFSet.{u}) + +theorem mem_append (p : ZFSet.{u}) (n : ℕ) (x z : ZFSet.{u}) : + z ∈ append p n x ↔ z ∈ p ∨ z = ZFSet.pair (natSet n) x := by + simp only [append,ZFSet.mem_union,ZFSet.mem_singleton] + +theorem append_function {A p x : ZFSet.{u}} {n : ℕ} + (hp : TransitiveNameModel.FunctionGraph (natSet n) A p) (hx : x ∈ A) : + TransitiveNameModel.FunctionGraph (natSet (n+1)) A (append p n x) := by + have hold {i y : ZFSet.{u}} (h : ZFSet.pair i y ∈ p) : i ∈ natSet n := by + obtain ⟨j,hj,z,_,he⟩ := hp.1 _ h + obtain ⟨rfl,_⟩ := ZFSet.pair_inj.mp he + exact hj + constructor + · intro z hz + rcases (mem_append p n x z).mp hz with hz|rfl + · obtain ⟨i,hi,y,hy,rfl⟩ := hp.1 z hz + exact ⟨i,ZFSet.mem_insert_iff.mpr (Or.inr hi),y,hy,rfl⟩ + · exact ⟨natSet n,ZFSet.mem_insert_iff.mpr (Or.inl rfl),x,hx,rfl⟩ + · intro i hi + change i ∈ insert (natSet n) (natSet n) at hi + rcases ZFSet.mem_insert_iff.mp hi with rfl|hi + · refine ⟨x,hx,(mem_append _ _ _ _).mpr (Or.inr rfl),?_⟩ + intro y _ hy + rcases (mem_append _ _ _ _).mp hy with hy|hy + · exact False.elim ((Nat.lt_irrefl n) ((natSet_mem_natSet n n).mp (hold hy))) + · exact (ZFSet.pair_inj.mp hy).2 + · obtain ⟨y,hy,hiy,hunique⟩ := hp.2 i hi + refine ⟨y,hy,(mem_append _ _ _ _).mpr (Or.inl hiy),?_⟩ + intro z hz hiz + rcases (mem_append _ _ _ _).mp hiz with hiz|hiz + · exact hunique z hz hiz + · have he := (ZFSet.pair_inj.mp hiz).1 + rw [he] at hi + exact False.elim ((Nat.lt_irrefl n) ((natSet_mem_natSet n n).mp hi)) + +theorem append_mem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {p x : ZFSet.{u}} (hp : p ∈ M) (hx : x ∈ M) (n : ℕ) : append p n x ∈ M := + binary_union_mem M hM hT.pairing hT.union hp + (singleton_mem M hM hT.pairing (orderedPair_mem M hM hT.pairing + (hM _ (sourceT_omega_mem M hM hT) _ ((mem_omega _).mpr ⟨n,rfl⟩)) hx)) + +def prefixFormula (o A p : ℕ) : Formula := .existsMem o (.functionGraph (p+1) 0 (A+1)) + +theorem eval_prefixFormula (o A p : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) : + (prefixFormula o A p).Eval e ↔ Prefix (e A) (e p) := by + simp only [prefixFormula,Formula.Eval,Formula.eval_functionGraph,cons_zero,cons_succ] + rw [ho] + exact ⟨fun ⟨n,hn,h⟩ => by obtain ⟨k,rfl⟩ := (mem_omega n).mp hn; exact ⟨k,h⟩, + fun ⟨n,h⟩ => ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,h⟩⟩ + +theorem conditions_exist (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A : ZFSet.{u}} (hA : A ∈ M) : + ∃ c ∈ M, ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + obtain ⟨Q,hQM,hQ⟩ := internal_power M hM hT.powerSet + (product_mem M hM hT.pairing hT.union hT.powerSet hS hω hA) + let e := cons ZFSet.omega (fun _ => A) + have he : ∀ i, e i ∈ M := by intro i; cases i <;> assumption + let c := ZFSet.sep (fun p => (prefixFormula 1 2 0).Eval (cons p e)) Q + refine ⟨c,sep_mem M hM hS _ e he hQM,fun p => ?_⟩ + rw [ZFSet.mem_sep,eval_prefixFormula 1 2 0 (cons p e) rfl,hQ] + exact ⟨fun h => ⟨h.1.1,h.2⟩,fun h => ⟨⟨h.1,prefix_subset h.2⟩,h.2⟩⟩ + +@[instance_reducible] noncomputable def order (c : ZFSet.{u}) : PartialOrder (Conditions c) where + le p q := label c q ⊆ label c p + lt left right := label c right ⊆ label c left ∧ ¬ label c left ⊆ label c right + le_refl _ := fun _ h => h + le_trans _ _ _ hpq hqr := fun _ h => hpq (hqr h) + le_antisymm p q hpq hqp := label_injective c (ZFSet.ext (fun z => ⟨fun h => hqp h,fun h => hpq h⟩)) + +attribute [local instance] order + +@[instance_reducible] noncomputable def collapsePreorder + (conditionSet : ZFSet.{u}) : Preorder (Conditions conditionSet) := + (order conditionSet).toPreorder + +attribute [local instance] collapsePreorder + +@[instance_reducible] noncomputable def top (c : ZFSet.{u}) (h0 : (∅ : ZFSet.{u}) ∈ c) : OrderTop (Conditions c) where + top := equivShrink c ⟨∅,h0⟩ + le_top p := by + have he : label c (equivShrink c ⟨∅,h0⟩) = ∅ := by simp [label] + change label c (equivShrink c ⟨∅,h0⟩) ⊆ label c p + rw [he] + exact fun z hz => False.elim (ZFSet.notMem_empty z hz) + +noncomputable def orderSet (c : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ p ∈ c, ∃ q ∈ c, z = ZFSet.pair p q ∧ q ⊆ p) (ZFSet.prod c c) + +theorem orderSet_mem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c : ZFSet.{u}} (hc : c ∈ M) : orderSet c ∈ M := by + let e : ℕ → ZFSet.{u} := fun _ => c + simpa only [orderSet,Formula.Eval,Formula.eval_orderedPair,Formula.eval_subset,cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.existsMem 2 (.conj (.orderedPair 2 1 0) (.subset 0 1)))) e (fun _ => hc) + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hc hc) + +theorem orderSet_pair (c : ZFSet.{u}) (p q : Conditions c) : + ZFSet.pair (label c p) (label c q) ∈ orderSet c ↔ p ≤ q := by + rw [orderSet,ZFSet.mem_sep] + constructor + · rintro ⟨_,x,_,y,_,he,h⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact h + · intro h + exact ⟨ZFSet.mem_prod.mpr ⟨_,label_mem c p,_,label_mem c q,rfl⟩, + _,label_mem c p,_,label_mem c q,rfl,h⟩ + +end TuringRigidity.BoundedSetTheory.InternalCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCollapseCounting.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCollapseCounting.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc9f0c8ba1a90c9ecd8082b57ce09d32823f6d3b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCollapseCounting.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCollapseDense +import OAI.Computability.DegreeRigidity.SetModels.CountableSetReal + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalCollapse +open TransitiveNameModel CountableForcing +universe u +attribute [local instance] order collapsePreorder + +noncomputable def unionGraph {c : ZFSet.{u}} (G : GenericFilter (Conditions c)) : ZFSet.{u} := + ZFSet.sUnion (genericFilterSet c G.carrier) + +theorem mem_unionGraph {c : ZFSet.{u}} (G : GenericFilter (Conditions c)) (z : ZFSet.{u}) : + z ∈ unionGraph G ↔ ∃ p ∈ G.carrier, z ∈ label c p := by + rw [unionGraph,ZFSet.mem_sUnion] + constructor + · rintro ⟨p,hp,hz⟩ + obtain ⟨q,hq,rfl⟩ := (mem_genericFilterSet c G.carrier p).mp hp + exact ⟨q,hq,hz⟩ + · rintro ⟨p,hp,hz⟩ + exact ⟨label c p,(mem_genericFilterSet c G.carrier _).mpr ⟨p,hp,rfl⟩,hz⟩ + +theorem unionGraph_functional {A c : ZFSet.{u}} + (hc : ∀ p ∈ c, Prefix A p) (G : GenericFilter (Conditions c)) + {i x y : ZFSet.{u}} (hx : ZFSet.pair i x ∈ unionGraph G) + (hy : ZFSet.pair i y ∈ unionGraph G) : x = y := by + obtain ⟨p,hp,hpx⟩ := (mem_unionGraph G _).mp hx + obtain ⟨q,hq,hqy⟩ := (mem_unionGraph G _).mp hy + obtain ⟨r,_,hrp,hrq⟩ := G.directed hp hq + obtain ⟨k,hr⟩ := hc _ (label_mem c r) + have hid : i ∈ natSet k := by + obtain ⟨j,hj,z,_,he⟩ := hr.1 _ (hrp hpx) + obtain ⟨rfl,_⟩ := ZFSet.pair_inj.mp he + exact hj + exact hr.functional hid (hrp hpx) (hrq hqy) + +theorem unionGraph_total (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A c : ZFSet.{u}} (hA : A ∈ M) (hcM : c ∈ M) + (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) (hne : ∃ x, x ∈ A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (n : ℕ) : + ∃ x ∈ A, ZFSet.pair (natSet n) x ∈ unionGraph G := by + obtain ⟨p,hp,hpn⟩ := hG (definedAt c A n) (definedAt_mem M hM hT hcM hA n) + (definedAt_dense M hM hT hA hc hne n) + obtain ⟨_,x,hx,hnx⟩ := ZFSet.mem_sep.mp hpn + exact ⟨x,hx,(mem_unionGraph G _).mpr ⟨p,hp,hnx⟩⟩ + +theorem unionGraph_onto (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A c : ZFSet.{u}} (hA : A ∈ M) (hcM : c ∈ M) + (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + ∀ x ∈ A, ∃ n ∈ ZFSet.omega, ZFSet.pair n x ∈ unionGraph G := by + intro x hx + obtain ⟨p,hp,hpx⟩ := hG (covers c x) (covers_mem M hM hT hcM (hM _ hA _ hx)) + (covers_dense M hM hT hA hc hx) + obtain ⟨_,n,hn,hnx⟩ := ZFSet.mem_sep.mp hpx + exact ⟨n,hn,(mem_unionGraph G _).mpr ⟨p,hp,hnx⟩⟩ + +theorem unionGraph_function (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A c : ZFSet.{u}} (hA : A ∈ M) (hcM : c ∈ M) + (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) (hne : ∃ x, x ∈ A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + TransitiveNameModel.FunctionGraph ZFSet.omega A (unionGraph G) := by + have hcP : ∀ p ∈ c, Prefix A p := fun p hp => ((hc p).mp hp).2 + constructor + · intro z hz + obtain ⟨p,_,hzp⟩ := (mem_unionGraph G z).mp hz + exact ZFSet.mem_prod.mp (prefix_subset (hcP _ (label_mem c p)) hzp) + · intro i hi + obtain ⟨n,rfl⟩ := (mem_omega i).mp hi + obtain ⟨x,hx,hnx⟩ := unionGraph_total M hM hT hA hcM hc hne G hG n + exact ⟨x,hx,hnx,fun y _ hny => unionGraph_functional hcP G hny hnx⟩ + +theorem unionGraph_mem_extension (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c : ZFSet.{u}} (hcM : c ∈ M) (h0 : (∅ : ZFSet.{u}) ∈ c) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + unionGraph G ∈ genericExtensionSet M c G.carrier := by + let _ := top c h0 + have htop : ⊤ ∈ G.carrier := by + obtain ⟨p,hp⟩ := G.nonempty + exact G.upper le_top hp + have hE := extension_sourceT M hM hT hcM (orderSet_mem M hM hT hcM) (orderSet_pair c) G hG htop + apply union_mem _ (genericExtensionSet_transitive M c hM G.carrier) hE.union + exact genericFilterSet_mem_extension M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hcM G.carrier htop + +theorem internal_counting (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A c : ZFSet.{u}} (hA : A ∈ M) (hcM : c ∈ M) + (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) (hne : ∃ x, x ∈ A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + InternallyCountable (genericExtensionSet M c G.carrier) A := by + have h0 : (∅ : ZFSet.{u}) ∈ c := + (hc ∅).mpr ⟨hM _ (sourceT_omega_mem M hM hT) _ ZFSet.omega_zero,prefix_empty A⟩ + exact ⟨unionGraph G,unionGraph_mem_extension M hM hT hcM h0 G hG, + unionGraph_function M hM hT hA hcM hc hne G hG,unionGraph_onto M hM hT hA hcM hc G hG⟩ + +end TuringRigidity.BoundedSetTheory.InternalCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCollapseDense.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCollapseDense.lean new file mode 100644 index 0000000000000000000000000000000000000000..867e56cfd136a82037bb33bfcc02e926bf8b9c79 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCollapseDense.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCollapseConditions + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalCollapse +open TransitiveNameModel CountableForcing +universe u +attribute [local instance] order collapsePreorder + +theorem extend_length (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A p : ZFSet.{u}} (hA : A ∈ M) (hpM : p ∈ M) (hp : Prefix A p) + (hne : ∃ x, x ∈ A) (m : ℕ) : + ∃ q ∈ M, ∃ k : ℕ, m ≤ k ∧ TransitiveNameModel.FunctionGraph (natSet k) A q ∧ p ⊆ q := by + obtain ⟨x,hx⟩ := hne + induction m with + | zero => + obtain ⟨k,hk⟩ := hp + exact ⟨p,hpM,k,Nat.zero_le _,hk,fun _ h => h⟩ + | succ m ih => + obtain ⟨q,hqM,k,hk,hq,hpq⟩ := ih + by_cases hmk : m+1 ≤ k + · exact ⟨q,hqM,k,hmk,hq,hpq⟩ + · refine ⟨append q k x,append_mem M hM hT hqM (hM _ hA _ hx) k,k+1,by omega, + append_function hq hx,fun z hz => ?_⟩ + exact (mem_append _ _ _ _).mpr (Or.inl (hpq hz)) + +noncomputable def covers (c x : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun p => ∃ n ∈ ZFSet.omega, ZFSet.pair n x ∈ p) c + +noncomputable def definedAt (c A : ZFSet.{u}) (n : ℕ) : ZFSet.{u} := + ZFSet.sep (fun p => ∃ x ∈ A, ZFSet.pair (natSet n) x ∈ p) c + +theorem covers_mem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c x : ZFSet.{u}} (hc : c ∈ M) (hx : x ∈ M) : covers c x ∈ M := by + let e := cons ZFSet.omega (fun _ => x) + have he : ∀ i, e i ∈ M := by intro i; cases i <;> first | exact sourceT_omega_mem M hM hT | exact hx + simpa only [covers,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded (.existsMem 1 (.pairMem 0 3 1)) e he hc + +theorem definedAt_mem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c A : ZFSet.{u}} (hc : c ∈ M) (hA : A ∈ M) (n : ℕ) : definedAt c A n ∈ M := by + let e := cons A (fun _ => natSet.{u} n) + have he : ∀ i, e i ∈ M := by + intro i; cases i + · exact hA + · exact hM _ (sourceT_omega_mem M hM hT) _ ((mem_omega _).mpr ⟨n,rfl⟩) + simpa only [definedAt,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded (.existsMem 1 (.pairMem 3 0 1)) e he hc + +theorem covers_dense (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A c : ZFSet.{u}} (hA : A ∈ M) (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) + {x : ZFSet.{u}} (hx : x ∈ A) : Dense {p : Conditions c | label c p ∈ covers c x} := by + intro p + obtain ⟨hpM,n,hp⟩ := (hc _).mp (label_mem c p) + let q := append (label c p) n x + have hq : q ∈ c := (hc q).mpr ⟨append_mem M hM hT hpM (hM _ hA _ hx) n,n+1,append_function hp hx⟩ + obtain ⟨r,hr⟩ := label_surjective c hq + refine ⟨r,?_,?_⟩ + · change label c p ⊆ label c r + rw [hr] + exact fun z hz => (mem_append _ _ _ _).mpr (Or.inl hz) + · change label c r ∈ covers c x + rw [hr,covers,ZFSet.mem_sep] + exact ⟨hq,natSet n,(mem_omega _).mpr ⟨n,rfl⟩,(mem_append _ _ _ _).mpr (Or.inr rfl)⟩ + +theorem definedAt_dense (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A c : ZFSet.{u}} (hA : A ∈ M) (hc : ∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) + (hne : ∃ x, x ∈ A) (n : ℕ) : Dense {p : Conditions c | label c p ∈ definedAt c A n} := by + intro p + obtain ⟨hpM,hp⟩ := (hc _).mp (label_mem c p) + obtain ⟨q,hqM,k,hnk,hq,hpq⟩ := extend_length M hM hT hA hpM hp hne (n+1) + have hqc : q ∈ c := (hc q).mpr ⟨hqM,k,hq⟩ + obtain ⟨r,hr⟩ := label_surjective c hqc + obtain ⟨x,hx,hnx,_⟩ := hq.2 (natSet n) ((natSet_mem_natSet n k).mpr (by omega)) + refine ⟨r,?_,?_⟩ + · change label c p ⊆ label c r + rw [hr]; exact hpq + · change label c r ∈ definedAt c A n + rw [hr,definedAt,ZFSet.mem_sep] + exact ⟨hqc,x,hx,hnx⟩ + +end TuringRigidity.BoundedSetTheory.InternalCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCollapseExistence.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCollapseExistence.lean new file mode 100644 index 0000000000000000000000000000000000000000..1faad51fe945937ca6fcaf485481ce29c606c6bf --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCollapseExistence.lean @@ -0,0 +1,37 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCollapseCounting +import OAI.Computability.DegreeRigidity.Representation.CountableGroundGeneric + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalCollapse +open TransitiveNameModel CountableForcing +universe u +attribute [local instance] order collapsePreorder + +theorem exists_internal_counting_extension (M : ZFSet.{u}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) {A : ZFSet.{u}} (hA : A ∈ M) + (hne : ∃ x, x ∈ A) : + ∃ c ∈ M, orderSet c ∈ M ∧ + (∀ p, p ∈ c ↔ p ∈ M ∧ Prefix A p) ∧ + ∃ G : GenericFilter (Conditions c), AtomicForcing.GroundGeneric M G ∧ + M ⊆ genericExtensionSet M c G.carrier ∧ + Transitive (genericExtensionSet M c G.carrier) ∧ + SourceT (genericExtensionSet M c G.carrier) ∧ + InternallyCountable (genericExtensionSet M c G.carrier) A := by + classical + obtain ⟨c,hcM,hc⟩ := conditions_exist M hM hT hA + have h0M : (∅ : ZFSet.{u}) ∈ M := hM _ (sourceT_omega_mem M hM hT) _ ZFSet.omega_zero + have h0 : (∅ : ZFSet.{u}) ∈ c := (hc ∅).mpr ⟨h0M,prefix_empty A⟩ + let _ := top c h0 + obtain ⟨G,htop,hG⟩ := AtomicForcing.countable_ground_generic M ⟨∅,h0M⟩ (⊤ : Conditions c) + refine ⟨c,hcM,orderSet_mem M hM hT hcM,hc,G,hG,?_,?_,?_,?_⟩ + · exact ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + hT.replacement.finitePrefix hT.infinity hcM G.carrier htop + · exact genericExtensionSet_transitive M c hM G.carrier + · exact extension_sourceT M hM hT hcM (orderSet_mem M hM hT hcM) (orderSet_pair c) G hG htop + · exact internal_counting M hM hT hA hcM hc hne G hG + +end TuringRigidity.BoundedSetTheory.InternalCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalColumnExtension.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalColumnExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2dc58bf4c0e46296bc53e0492d762c50e253092 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalColumnExtension.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenSupportedValue +import OAI.Computability.DegreeRigidity.SetModels.InternalNameEvaluation + +namespace OAI + +namespace TuringRigidity.InternalColumnExtension +open TransitiveNameModel BoundedSetTheory CountableForcing +open CohenGroundPoset InternalCohenRestriction InternalCohenFactor InternalCohenProjectedGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder +attribute [local instance] CohenNiceNameConstruction.cohenTop + +noncomputable def filterImage (A B g : ZFSet.{0}) : ZFSet.{0} := + (conditions B).sep (fun q => ∃ p ∈ g, ZFSet.pair p q ∈ restrictionGraph A B) + +theorem filterImage_mem (N A B g : ZFSet.{0}) (hN : Transitive N) (hT : SourceT N) + (hA : A ∈ N) (hB : B ∈ N) (hg : g ∈ N) : filterImage A B g ∈ N := by + have hR := restrictionGraph_mem N A B hN hT hA hB + have hs := sep_mem N hN hT.separation.finitePrefix.bounded + (.existsMem 1 (.pairMem 0 1 3)) (cons g (fun _ => restrictionGraph A B)) + (by intro i; cases i; exact hg; exact hR) (conditions_mem N B hN hT hB) + simpa only [filterImage,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ] using hs + +theorem projected_filter_image (A B : ZFSet.{0}) (hBA : B ⊆ A) + (G : GenericFilter (Conditions (conditions A))) : + genericFilterSet (conditions B) (projected A B hBA G).carrier = + filterImage A B (genericFilterSet (conditions A) G.carrier) := by + apply ZFSet.ext; intro q + rw [mem_genericFilterSet,filterImage,ZFSet.mem_sep] + constructor + · rintro ⟨s,hs,rfl⟩ + obtain ⟨p,hp,hps⟩ := (mem_projected A B hBA G s).mp hs + refine ⟨label_mem _ s,label _ p,(mem_genericFilterSet _ _ _).mpr ⟨p,hp,rfl⟩,?_⟩ + rw [←hps] + exact (pair_restrictionGraph A B _ _).mpr ⟨label_mem _ p,label_mem _ _,label_project A B hBA p⟩ + · rintro ⟨hq,p,hp,hpq⟩ + obtain ⟨r,hr,hrp⟩ := (mem_genericFilterSet (conditions A) G.carrier p).mp hp + rw [←hrp] at hpq + have he := ((pair_restrictionGraph A B _ q).mp hpq).2.2 + refine ⟨project A B hBA r,projected_contains A B hBA G hr,?_⟩ + exact (label_project A B hBA r).trans he.symm + +theorem column_extension_subset (M A B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hB : B ∈ M) (hBA : B ⊆ A) + (G : GenericFilter (Conditions (conditions A))) (hG : AtomicForcing.GroundGeneric M G) : + genericExtensionSet M (conditions B) (projected A B hBA G).carrier ⊆ + genericExtensionSet M (conditions A) G.carrier := by + let N := genericExtensionSet M (conditions A) G.carrier + have hN := genericExtensionSet_transitive M (conditions A) hM G.carrier + obtain ⟨p,hp⟩ := G.nonempty + have ht : (⊤ : Conditions (conditions A)) ∈ G.carrier := G.upper le_top hp + have hc := conditions_mem M A hM hT hA + have hTN : SourceT N := extension_sourceT M hM hT hc (InternalCollapse.orderSet_mem M hM hT hc) + (InternalCollapse.orderSet_pair _) G hG ht + have hMN : M ⊆ N := ground_inclusion_set M _ hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht + apply InternalNameEvaluation.extension_subset M N hN hTN hMN + rw [projected_filter_image A B hBA G] + apply filterImage_mem N A B _ hN hTN (hMN hA) (hMN hB) + exact genericFilterSet_mem_extension M _ hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht + +end TuringRigidity.InternalColumnExtension + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalColumnProjection.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalColumnProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..51c62dbdc8edde41f859e706812c8ee01f094e3d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalColumnProjection.lean @@ -0,0 +1,93 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableMap + +namespace OAI + +namespace TuringRigidity.InternalColumnProjection +open TransitiveNameModel BoundedSetTheory InternalCountableMap + +noncomputable def columns (K S : ZFSet.{0}) : ZFSet.{0} := + K.sep (fun x => ∃ n ∈ ZFSet.omega, ZFSet.pair x n ∈ S) + +theorem mem_columns (K S x : ZFSet.{0}) : + x ∈ columns K S ↔ x ∈ K ∧ ∃ n ∈ ZFSet.omega, ZFSet.pair x n ∈ S := ZFSet.mem_sep + +theorem columns_mem (M K S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : K ∈ M) (hS : S ∈ M) : columns K S ∈ M := by + let e := cons ZFSet.omega (fun _ => S) + have he : ∀ i, e i ∈ M := by + intro i; cases i; exact sourceT_omega_mem M hM hT; exact hS + simpa only [columns,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded (.existsMem 1 (.pairMem 1 0 3)) e he hK + +theorem support_subset_columns (K S : ZFSet.{0}) (hS : S ⊆ ZFSet.prod K ZFSet.omega) : + S ⊆ ZFSet.prod (columns K S) ZFSet.omega := by + intro z hz + obtain ⟨x,hx,n,hn,rfl⟩ := ZFSet.mem_prod.mp (hS hz) + exact ZFSet.pair_mem_prod.mpr ⟨(mem_columns K S x).mpr ⟨hx,n,hn,hz⟩,hn⟩ + +noncomputable def projection (K S : ZFSet.{0}) : ZFSet.{0} := + (ZFSet.prod S (columns K S)).sep (fun z => ∃ s ∈ S, ∃ x ∈ columns K S, + z = ZFSet.pair s x ∧ ∃ n ∈ ZFSet.omega, s = ZFSet.pair x n) + +theorem pair_projection (K S s x : ZFSet.{0}) : + ZFSet.pair s x ∈ projection K S ↔ + s ∈ S ∧ x ∈ columns K S ∧ ∃ n ∈ ZFSet.omega, s = ZFSet.pair x n := by + simp only [projection,ZFSet.mem_sep] + constructor + · rintro ⟨_,s',hs,x',hx,he,hn⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hs,hx,hn⟩ + · rintro ⟨hs,hx,hn⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨hs,hx⟩,s,hs,x,hx,rfl,hn⟩ + +theorem projection_mem (M K S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : K ∈ M) (hS : S ∈ M) : projection K S ∈ M := by + have hC := columns_mem M K S hM hT hK hS + let e := cons S (cons (columns K S) (fun _ => ZFSet.omega)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i + exact hS; exact hC; exact sourceT_omega_mem M hM hT + simpa only [projection,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) + (.existsMem 5 (.orderedPair 2 1 0))))) e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hS hC) + +theorem projection_function (K S : ZFSet.{0}) (hS : S ⊆ ZFSet.prod K ZFSet.omega) : + FunctionGraph S (columns K S) (projection K S) := by + constructor + · intro z hz; exact ZFSet.mem_prod.mp (ZFSet.mem_sep.mp hz).1 + · intro s hs + obtain ⟨x,hx,n,hn,he⟩ := ZFSet.mem_prod.mp (hS hs) + have hxC : x ∈ columns K S := (mem_columns K S x).mpr ⟨hx,n,hn,he ▸ hs⟩ + refine ⟨x,hxC,(pair_projection K S s x).mpr ⟨hs,hxC,n,hn,he⟩,?_⟩ + intro y _ hsy + obtain ⟨_,_,m,_,hm⟩ := (pair_projection K S s y).mp hsy + exact (ZFSet.pair_inj.mp (hm.symm.trans he)).1 + +theorem projection_onto (K S : ZFSet.{0}) : + ∀ x ∈ columns K S, ∃ s ∈ S, ZFSet.pair s x ∈ projection K S := by + intro x hx + obtain ⟨_,n,hn,hs⟩ := (mem_columns K S x).mp hx + exact ⟨ZFSet.pair x n,hs,(pair_projection K S _ x).mpr ⟨hs,hx,n,hn,rfl⟩⟩ + +theorem columns_counted (M K S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : K ∈ M) (hS : S ∈ M) (hsub : S ⊆ ZFSet.prod K ZFSet.omega) + (hct : S = ∅ ∨ InternallyCountable M S) : + columns K S ∈ M ∧ columns K S ⊆ K ∧ + S ⊆ ZFSet.prod (columns K S) ZFSet.omega ∧ + (columns K S = ∅ ∨ InternallyCountable M (columns K S)) := by + refine ⟨columns_mem M K S hM hT hK hS,fun _ h => (mem_columns K S _).mp h |>.1, + support_subset_columns K S hsub,?_⟩ + rcases hct with he|hc + · left + apply ZFSet.ext; intro x + simp only [columns,he,ZFSet.mem_sep,ZFSet.notMem_empty,and_false,exists_false] + · right + exact countable_of_surjection M S (columns K S) (projection K S) hM hT hS + (columns_mem M K S hM hT hK hS) (projection_mem M K S hM hT hK hS) + (projection_function K S hsub) (projection_onto K S) hc + +end TuringRigidity.InternalColumnProjection + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCommonRequirements.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCommonRequirements.lean new file mode 100644 index 0000000000000000000000000000000000000000..f6a3fde22bd84620564662e2740be3d2819d1f1e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCommonRequirements.lean @@ -0,0 +1,91 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticCommonRequirement +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericalCohenProductSets +import OAI.Computability.DegreeRigidity.CohenForcing.CohenProductSplitting + +namespace OAI + + +namespace TuringRigidity.InternalCommonRequirements +open TransitiveNameModel BoundedSetTheory InternalCohen Encodable UniformArithmetic +open EncodedForcing (word) +open TaggedProductConditions (code) +open CountableForcing CohenProductSplitting +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +noncomputable def requirementCodes (A : Oracle) (p q : OracleCode) : Oracle := + arithmeticReal (fun O n => CommonIdeal.Requirement (O 0) p q + (word (left n)) (word (right n))) (fun _ => A) + +theorem requirementCodes_true (A : Oracle) (p q : OracleCode) (n : ℕ) : + requirementCodes A p q n = true ↔ + CommonIdeal.Requirement A p q (word (left n)) (word (right n)) := + arithmeticReal_true _ _ _ + +theorem requirementCodes_mem (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (A : Oracle) (hA : A ∈ modelReals M) (p q : OracleCode) : + realCode (requirementCodes A p q) ∈ M := + sourceT_arithmetic_comprehension M hM hT + (ArithmeticCommonRequirement.requirement_arith p q left_primrec right_primrec) + (fun _ => A) (fun _ => hA) + +noncomputable def denseSet (c : ZFSet.{0}) (A : Oracle) (p q : OracleCode) : ZFSet.{0} := + c.sep (fun z => ∃ s t : List Bool, + z = code (wordCode s) (wordCode t) ∧ CommonIdeal.Requirement A p q s t) + +theorem denseSet_eq_image (c : ZFSet.{0}) (A : Oracle) (p q : OracleCode) : + denseSet c A p q = NumericalCohenProductSets.image c (requirementCodes A p q) := by + apply ZFSet.ext + intro z + simp only [denseSet,NumericalCohenProductSets.image,ZFSet.mem_sep,requirementCodes_true] + apply and_congr_right + intro _ + constructor + · rintro ⟨s,t,hz,h⟩ + refine ⟨Nat.pair (encode s) (encode t),?_,?_⟩ + · simpa [left,right,word] using h + · simpa [left,right,word] using hz + · rintro ⟨n,h,hz⟩ + exact ⟨word (left n),word (right n),hz,h⟩ + +theorem denseSet_mem (M c : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (A : Oracle) (hA : A ∈ modelReals M) (p q : OracleCode) : + denseSet c A p q ∈ M := by + rw [denseSet_eq_image] + exact NumericalCohenProductSets.image_mem M c hM hT hc _ + (requirementCodes_mem M hM hT A hA p q) + +theorem denseSet_spec (c : ZFSet.{0}) + (hcs : ∀ z, z ∈ c ↔ ∃ p ∈ conditions, ∃ s ∈ conditions, z = code p s) + (A : Oracle) (p q : OracleCode) (s t : List Bool) : + code (wordCode s) (wordCode t) ∈ denseSet c A p q ↔ CommonIdeal.Requirement A p q s t := by + rw [denseSet_eq_image] + exact NumericalCohenProductSets.image_spec c hcs _ _ (requirementCodes_true A p q) s t + +theorem denseSet_dense (c : ZFSet.{0}) + (hcs : ∀ z, z ∈ c ↔ ∃ p ∈ conditions, ∃ s ∈ conditions, z = code p s) + (A : Oracle) (p q : OracleCode) : + Dense {x : Conditions c | label c x ∈ denseSet c A p q} := by + intro x + let I := productIso conditions conditions c hcs + let y := I.symm x + let s := conditionEquiv.symm y.1 + let t := conditionEquiv.symm y.2 + obtain ⟨u,v,hu,hv,hreq⟩ := CommonIdeal.requirement_dense A p q s.word t.word + let u' := conditionEquiv ⟨u⟩ + let v' := conditionEquiv ⟨v⟩ + have hu' : u' ≤ y.1 := by + simpa only [s,OrderIso.apply_symm_apply] using conditionEquiv.monotone hu + have hv' : v' ≤ y.2 := by + simpa only [t,OrderIso.apply_symm_apply] using conditionEquiv.monotone hv + refine ⟨I (u',v'),?_,?_⟩ + · simpa only [y,OrderIso.apply_symm_apply] using I.monotone (show (u',v') ≤ y from ⟨hu',hv'⟩) + · change label c (productMap conditions conditions c hcs (u',v')) ∈ denseSet c A p q + rw [label_productMap] + change code (label conditions (encodeCondition ⟨u⟩)) + (label conditions (encodeCondition ⟨v⟩)) ∈ denseSet c A p q + rw [label_encodeCondition,label_encodeCondition,denseSet_spec c hcs] + exact hreq + +end TuringRigidity.InternalCommonRequirements + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalContainer.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalContainer.lean new file mode 100644 index 0000000000000000000000000000000000000000..59f1a6e9525dcc9d608c6a3c3546d952137f0f89 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalContainer.lean @@ -0,0 +1,106 @@ +import OAI.Computability.DegreeRigidity.SetModels.UnionIteration + +namespace OAI + +namespace TuringRigidity.TransitiveNameModel +open BoundedSetTheory +universe u + +def unionCertificate : SigmaFormula := .existsSet (.existsSet (.existsSet (.bounded + (.conj (.successor 2 4) (.conj (IterationFormula.iteration 2 1 0 5 6) (.pairMem 4 3 0)))))) + +theorem realize_unionCertificate (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hω : ZFSet.omega.{u} ∈ M) + {a v : ZFSet.{u}} (ha : a ∈ M) (hv : v ∈ M) (n : ℕ) : + unionCertificate.Realize M (cons v (cons (natSet n) + (cons a (cons ∅ (fun _ => a))))) ↔ v = iterUnion n a := by + have hn (i : ℕ) : natSet.{u} i ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨i,rfl⟩) + have h0 : (∅ : ZFSet.{u}) ∈ M := hn 0 + have matrix (k r f : ZFSet.{u}) (hk : k ∈ M) (hr : r ∈ M) (hf : f ∈ M) : + (Formula.conj (.successor 2 4) + (.conj (IterationFormula.iteration 2 1 0 5 6) (.pairMem 4 3 0))).Realize M + (cons f (cons r (cons k (cons v (cons (natSet n) + (cons a (cons ∅ (fun _ => a)))))))) ↔ + k = natSet (n+1) ∧ UnionIteration k r f a ∧ ZFSet.pair (natSet n) v ∈ f := by + have he : ∀ i, (cons f (cons r (cons k (cons v (cons (natSet n) + (cons a (cons ∅ (fun _ => a)))))))) i ∈ M := by + intro i + rcases i with _|i; exact hf + rcases i with _|i; exact hr + rcases i with _|i; exact hk + rcases i with _|i; exact hv + rcases i with _|i; exact hn n + rcases i with _|i; exact ha + rcases i with _|i; exact h0 + exact ha + rw [Formula.absolute _ M hM _ he] + simp only [Formula.Eval,Formula.eval_successor, + Formula.eval_pairMem,cons_zero,cons_succ] + rw [IterationFormula.eval_iteration 2 1 0 5 6 + (cons f (cons r (cons k (cons v (cons (natSet n) (cons a (cons ∅ (fun _ => a)))))))) rfl] + rfl + change (∃ k ∈ M, ∃ r ∈ M, ∃ f ∈ M, _) ↔ _ + constructor + · rintro ⟨k,hk,r,hr,f,hf,hc⟩ + obtain ⟨rfl,hg,hv⟩ := (matrix k r f hk hr hf).mp hc + exact hg.correct n (le_refl n) v hv + · intro hvEq + have hf := unionGraph_mem M hM hP hU hω ha n + refine ⟨natSet (n+1),hn (n+1),_,iterUnion_mem M hM hU hf 2,_,hf,?_⟩ + apply (matrix _ _ _ (hn (n+1)) (iterUnion_mem M hM hU hf 2) hf).mpr + exact ⟨rfl,unionGraph_valid a n,(unionGraph_pair a _ v n).mpr ⟨n,le_refl n,rfl,hvEq⟩⟩ + +theorem collect_unionIterates (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + (hU : BoundedSetTheory.Union M) (hR : SigmaReplacement M) + (hω : ZFSet.omega.{u} ∈ M) {a : ZFSet.{u}} (ha : a ∈ M) : + ∃ b ∈ M, ∀ y, y ∈ b ↔ ∃ n : ℕ, y = iterUnion n a := by + have h0 : (∅ : ZFSet.{u}) ∈ M := hM _ hω _ ZFSet.omega_zero + let e := cons a (cons ∅ (fun _ => a)) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact ha + rcases i with _|i; exact h0 + exact ha + obtain ⟨b,hb,hbdef⟩ := hR unionCertificate e he _ hω (by + intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + have hv := iterUnion_mem M hM hU ha n + refine ⟨_,hv,(realize_unionCertificate M hM hP hU hω ha hv n).mpr rfl,?_⟩ + intro z hz hφ + exact (realize_unionCertificate M hM hP hU hω ha hz n).mp hφ) + refine ⟨b,hb,fun y => ?_⟩ + constructor + · intro hy + have hyM := hM b hb y hy + obtain ⟨x,hx,hφ⟩ := (hbdef y hyM).mp hy + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + exact ⟨n,(realize_unionCertificate M hM hP hU hω ha hyM n).mp hφ⟩ + · rintro ⟨n,rfl⟩ + have hv := iterUnion_mem M hM hU ha n + exact (hbdef _ hv).mpr ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩, + (realize_unionCertificate M hM hP hU hω ha hv n).mpr rfl⟩ + +theorem internal_transitive_container (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) {a : ZFSet.{u}} (ha : a ∈ M) : + ∃ d ∈ M, Transitive d ∧ a ∈ d := by + have hω := omega_mem M hM hS hI + obtain ⟨b,hb,hbdef⟩ := collect_unionIterates M hM hP hU hR hω ha + let d := ({a} : ZFSet.{u}) ∪ ZFSet.sUnion b + have hd : d ∈ M := binary_union_mem M hM hP hU + (singleton_mem M hM hP ha) (union_mem M hM hU hb) + refine ⟨d,hd,?_,ZFSet.mem_union.mpr (Or.inl (ZFSet.mem_singleton.mpr rfl))⟩ + intro x hx y hy + apply ZFSet.mem_union.mpr + apply Or.inr + rcases ZFSet.mem_union.mp hx with hx|hx + · obtain rfl := ZFSet.mem_singleton.mp hx + exact ZFSet.mem_sUnion.mpr ⟨x,(hbdef x).mpr ⟨0,rfl⟩,hy⟩ + · obtain ⟨c,hc,hxc⟩ := ZFSet.mem_sUnion.mp hx + obtain ⟨n,rfl⟩ := (hbdef c).mp hc + exact ZFSet.mem_sUnion.mpr ⟨iterUnion (n+1) a,(hbdef _).mpr ⟨n+1,rfl⟩, + ZFSet.mem_sUnion.mpr ⟨x,hxc,hy⟩⟩ + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableClosure.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ff97043e32c6c7a201b67698881339497b35bb4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableClosure.lean @@ -0,0 +1,121 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableFamily +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableMap + +namespace OAI + +namespace TuringRigidity.InternalCountableClosure +open TransitiveNameModel BoundedSetTheory + +theorem constant_graph (A : ZFSet.{0}) : + orbitGraph (fun _ => A) = ZFSet.prod ZFSet.omega {A} := by + apply ZFSet.ext; intro z + rw [mem_orbitGraph,ZFSet.mem_prod] + constructor + · rintro ⟨n,rfl⟩ + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,A,ZFSet.mem_singleton.mpr rfl,rfl⟩ + · rintro ⟨n,hn,x,hx,rfl⟩ + obtain rfl := ZFSet.mem_singleton.mp hx + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + exact ⟨n,rfl⟩ + +theorem finite_countable (M A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hfin : (A : Set ZFSet.{0}).Finite) (hne : ∃ x, x ∈ A) : + InternallyCountable M A := by + apply InternalCountableFiniteUnion.internally_countable_union M A hM hT hA (fun _ => A) + (fun _ => (InternalFiniteSubsets.mem_finiteSubsets_iff A A).mpr ⟨fun _ h => h,hfin⟩) + _ (fun x hx => ⟨0,hx⟩) hne + rw [constant_graph] + exact product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + (sourceT_omega_mem M hM hT) (singleton_mem M hM hT.pairing hA) + +theorem singleton_countable (M a : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) : InternallyCountable M ({a} : ZFSet.{0}) := by + apply finite_countable M {a} hM hT (singleton_mem M hM hT.pairing ha) + · simpa only [ZFSet.coe_singleton] using Set.finite_singleton a + · exact ⟨a,ZFSet.mem_singleton.mpr rfl⟩ + +theorem pair_countable (M a b : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) (hb : b ∈ M) : InternallyCountable M ({a,b} : ZFSet.{0}) := by + apply finite_countable M {a,b} hM hT (pair_mem M hM hT.pairing ha hb) + · simpa only [ZFSet.coe_insert,ZFSet.coe_singleton] using (Set.finite_singleton b).insert a + · exact ⟨a,ZFSet.mem_pair.mpr (Or.inl rfl)⟩ + +theorem countable_union (M A B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hB : B ∈ M) + (hcA : A = ∅ ∨ InternallyCountable M A) (hcB : B = ∅ ∨ InternallyCountable M B) : + A ∪ B = ∅ ∨ InternallyCountable M (A ∪ B) := by + have h := InternalCountableFamily.countable_sUnion M {A,B} hM hT + (pair_mem M hM hT.pairing hA hB) (Or.inr (pair_countable M A B hM hT hA hB)) + (fun E hE => (ZFSet.mem_pair.mp hE).elim (fun h => h ▸ hcA) (fun h => h ▸ hcB)) + simpa only [ZFSet.sUnion_pair] using h + +theorem countable_insert (M A a : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (ha : a ∈ M) (hcA : A = ∅ ∨ InternallyCountable M A) : + InternallyCountable M (insert a A) := by + have he : ({a} : ZFSet.{0}) ∪ A = insert a A := by + apply ZFSet.ext; intro z + simp only [ZFSet.mem_union,ZFSet.mem_singleton,ZFSet.mem_insert_iff] + have h := countable_union M {a} A hM hT (singleton_mem M hM hT.pairing ha) hA + (Or.inr (singleton_countable M a hM hT ha)) hcA + rw [he] at h + rcases h with h|h + · exact False.elim (ZFSet.notMem_empty a (h ▸ ZFSet.mem_insert a A)) + · exact h + +noncomputable def retractGraph (A B d : ZFSet.{0}) : ZFSet.{0} := + (ZFSet.prod A B).sep (fun z => ∃ x ∈ A, ∃ y ∈ B, + z = ZFSet.pair x y ∧ ((x ∈ B ∧ y = x) ∨ (x ∉ B ∧ y = d))) + +theorem pair_retractGraph (A B d x y : ZFSet.{0}) : + ZFSet.pair x y ∈ retractGraph A B d ↔ + x ∈ A ∧ y ∈ B ∧ ((x ∈ B ∧ y = x) ∨ (x ∉ B ∧ y = d)) := by + simp only [retractGraph,ZFSet.mem_sep] + constructor + · rintro ⟨_,x',hx,y',hy,he,h⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hx,hy,h⟩ + · rintro ⟨hx,hy,h⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨hx,hy⟩,x,hx,y,hy,rfl,h⟩ + +theorem retractGraph_mem (M A B d : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hB : B ∈ M) (hd : d ∈ M) : retractGraph A B d ∈ M := by + let e := cons A (cons B (fun _ => d)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i + exact hA; exact hB; exact hd + simpa only [retractGraph,Formula.Eval,Formula.eval_orderedPair,Formula.eval_disj, + cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) + (.disj (.conj (.member 1 4) (.equal 0 1)) + (.conj (.neg (.member 1 4)) (.equal 0 5)))))) e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hA hB) + +theorem retractGraph_function (A B d : ZFSet.{0}) (hd : d ∈ B) : + FunctionGraph A B (retractGraph A B d) := by + classical + constructor + · intro z hz; exact ZFSet.mem_prod.mp (ZFSet.mem_sep.mp hz).1 + · intro x hx + by_cases hxB : x ∈ B + · refine ⟨x,hxB,(pair_retractGraph A B d x x).mpr ⟨hx,hxB,Or.inl ⟨hxB,rfl⟩⟩,?_⟩ + intro y _ hy + exact ((pair_retractGraph A B d x y).mp hy).2.2.elim And.right + (fun h => False.elim (h.1 hxB)) + · refine ⟨d,hd,(pair_retractGraph A B d x d).mpr ⟨hx,hd,Or.inr ⟨hxB,rfl⟩⟩,?_⟩ + intro y _ hy + exact ((pair_retractGraph A B d x y).mp hy).2.2.elim + (fun h => False.elim (hxB h.1)) And.right + +theorem countable_subset (M A B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hB : B ∈ M) (hsub : B ⊆ A) + (hct : InternallyCountable M A) (hne : ∃ d, d ∈ B) : InternallyCountable M B := by + obtain ⟨d,hd⟩ := hne + apply InternalCountableMap.countable_of_surjection M A B (retractGraph A B d) hM hT hA hB + (retractGraph_mem M A B d hM hT hA hB (hM B hB d hd)) (retractGraph_function A B d hd) _ hct + intro y hy + exact ⟨y,hsub hy,(pair_retractGraph A B d y y).mpr ⟨hsub hy,hy,Or.inl ⟨hy,rfl⟩⟩⟩ + +end TuringRigidity.InternalCountableClosure + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableEnumeration.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5d66fe26110d43ada58bda0a08bdebb46193199 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableEnumeration.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalRelationSelection + +namespace OAI + +namespace TuringRigidity.InternalCountableEnumeration +open TransitiveNameModel BoundedSetTheory InternalRelationSelection +open InternalCountableFiniteUnion InternalFiniteEnumeration + +def Enumerates (E g : ZFSet.{0}) : Prop := + (E = ∅ ∧ g = ∅) ∨ (FunctionGraph ZFSet.omega E g ∧ + ∀ x ∈ E, ∃ n ∈ ZFSet.omega, ZFSet.pair n x ∈ g) + +def enumeratesFormula (ω E g : ℕ) : Formula := + .disj (.conj (.empty E) (.empty g)) + (.conj (.functionGraph g ω E) (.allMem E (.existsMem (ω+1) (.pairMem 0 1 (g+2))))) + +theorem enumeratesFormula_spec (ω E g : ℕ) (e : ℕ → ZFSet.{0}) + (hω : e ω = ZFSet.omega) : + (enumeratesFormula ω E g).Eval e ↔ Enumerates (e E) (e g) := by + simp only [enumeratesFormula,Enumerates,FunctionGraph,Formula.eval_disj,Formula.Eval, + Formula.eval_empty,Formula.eval_functionGraph,Formula.eval_allMem, + Formula.eval_pairMem,cons_zero,cons_succ,hω] + +theorem enumerates_ranges (U E g : ZFSet.{0}) (hE : E ⊆ U) (hg : Enumerates E g) : + Ranges U E g := by + refine ⟨hE,fun x _ => ?_⟩ + rcases hg with ⟨rfl,rfl⟩|⟨hg,honto⟩ + · simp + · refine ⟨fun hx => honto x hx,?_⟩ + rintro ⟨n,_,hn⟩ + obtain ⟨n',_,x',hx,hp⟩ := hg.1 _ hn + exact (ZFSet.pair_inj.mp hp).2 ▸ hx + +theorem enumerates_entry (U E g d k : ZFSet.{0}) (hE : E ⊆ U) (hg : Enumerates E g) + (hd : d ∈ U) (hk : k ∈ ZFSet.omega) : + ∃ x ∈ U, Entry U g d k x ∧ ∀ y ∈ U, Entry U g d k y → y = x := by + rcases hg with ⟨_,rfl⟩|⟨hg,_⟩ + · exact ⟨d,hd,Or.inr ⟨rfl,fun y _ => ZFSet.notMem_empty _⟩, + fun y _ hy => hy.elim (fun h => False.elim (ZFSet.notMem_empty _ h)) And.left⟩ + · obtain ⟨x,hx,hkx,_⟩ := hg.2 k hk + refine ⟨x,hE hx,Or.inl hkx,?_⟩ + intro y _ hy + rcases hy with hy|⟨_,hy⟩ + · exact hg.functional hk hy hkx + · exact False.elim (hy x (hE hx) hkx) + +theorem internal_countable_selector (M U S : ZFSet.{0}) (hM : Transitive M) + (hT : SourceT M) (hU : U ∈ M) (hS : S ∈ M) + (hsub : ∀ E ∈ S, E ⊆ U) + (hct : ∀ E ∈ S, E = ∅ ∨ InternallyCountable M E) : + ∃ C ∈ M, ∃ T ∈ M, FunctionGraph S C T ∧ + ∀ E ∈ S, ∀ g, ZFSet.pair E g ∈ T → Enumerates E g := by + have hω := sourceT_omega_mem M hM hT + have hp := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hω hU + obtain ⟨C,hCM,hC⟩ := internal_power M hM hT.powerSet hp + let e := cons S (cons C (fun _ => ZFSet.omega)) + let φ : Formula := .existsMem 1 (.existsMem 3 + (.conj (.orderedPair 2 1 0) (enumeratesFormula 5 1 0))) + let R := (ZFSet.prod S C).sep (fun z => φ.Eval (cons z e)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i + exact hS; exact hCM; exact hω + have hRM : R ∈ M := sep_mem M hM hT.separation.finitePrefix.bounded φ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hS hCM) + have hr (E g : ZFSet.{0}) : ZFSet.pair E g ∈ R ↔ E ∈ S ∧ g ∈ C ∧ Enumerates E g := by + have henum (domain graph pair : ZFSet.{0}) : + (enumeratesFormula 5 1 0).Eval (cons graph (cons domain (cons pair e))) ↔ + Enumerates domain graph := enumeratesFormula_spec 5 1 0 _ rfl + simp only [R,ZFSet.mem_sep,φ,Formula.Eval,Formula.eval_orderedPair, + henum,cons_zero,cons_succ,e] + constructor + · rintro ⟨_,E',hE,g',hg,hp,hEnum⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact ⟨hE,hg,hEnum⟩ + · rintro ⟨hE,hg,hEnum⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨E,hE,g,hg,rfl⟩,E,hE,g,hg,rfl,hEnum⟩ + have htotal : ∀ E ∈ S, ∃ g ∈ C, ZFSet.pair E g ∈ R := by + intro E hE + rcases hct E hE with hempty|⟨g,hgM,hg,honto⟩ + · have hzero : (∅ : ZFSet.{0}) ∈ M := hempty ▸ hM S hS E hE + have hgC := (hC ∅).mpr ⟨hzero,fun _ h => False.elim (ZFSet.notMem_empty _ h)⟩ + exact ⟨∅,hgC,(hr E ∅).mpr ⟨hE,hgC,Or.inl ⟨hempty,rfl⟩⟩⟩ + · have hgC := (hC g).mpr ⟨hgM,by + intro z hz + obtain ⟨n,hn,x,hx,hz⟩ := hg.1 z hz + exact ZFSet.mem_prod.mpr ⟨n,hn,x,hsub E hE hx,hz⟩⟩ + exact ⟨g,hgC,(hr E g).mpr ⟨hE,hgC,Or.inr ⟨hg,honto⟩⟩⟩ + obtain ⟨T,hTM,hfun,hTR⟩ := select_relation M S C R hM hT hS hCM hRM htotal + exact ⟨C,hCM,T,hTM,hfun,fun E _ g hEg => ((hr E g).mp (hTR hEg)).2.2⟩ + +end TuringRigidity.InternalCountableEnumeration + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableFamily.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..6dced5138e8a682dd279966abc3a73ba3ba7b452 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableFamily.lean @@ -0,0 +1,49 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableUnion + +namespace OAI + +namespace TuringRigidity.InternalCountableFamily +open TransitiveNameModel BoundedSetTheory + +theorem sequence_of_graph (S B : ZFSet.{0}) (hB : FunctionGraph ZFSet.omega S B) : + ∃ E : ℕ → ZFSet.{0}, (∀ n, E n ∈ S) ∧ orbitGraph E = B := by + classical + have h (n : ℕ) := hB.2 (natSet n) ((mem_omega _).mpr ⟨n,rfl⟩) + choose E hE hpair huniq using h + refine ⟨E,hE,?_⟩ + apply ZFSet.ext; intro z + constructor + · intro hz + obtain ⟨n,rfl⟩ := (mem_orbitGraph E z).mp hz + exact hpair n + · intro hz + obtain ⟨n,hn,x,hx,rfl⟩ := hB.1 z hz + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + exact (orbitGraph_pair E n x).mpr (huniq n x hx hz) + +theorem countable_sUnion (M S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hS : S ∈ M) (hcount : S = ∅ ∨ InternallyCountable M S) + (hsets : ∀ A ∈ S, A = ∅ ∨ InternallyCountable M A) : + ZFSet.sUnion S = ∅ ∨ InternallyCountable M (ZFSet.sUnion S) := by + classical + by_cases hne : ∃ x, x ∈ ZFSet.sUnion S + · right + rcases hcount with rfl|⟨B,hBM,hB,honto⟩ + · simp at hne + obtain ⟨E,hE,hEB⟩ := sequence_of_graph S B hB + apply InternalCountableUnion.internally_countable_union M (ZFSet.sUnion S) S hM hT + (union_mem M hM hT.union hS) hS + (fun A hA x hx => ZFSet.mem_sUnion.mpr ⟨A,hA,hx⟩) hsets E hE (hEB.symm ▸ hBM) _ hne + intro x hx + obtain ⟨A,hA,hxA⟩ := ZFSet.mem_sUnion.mp hx + obtain ⟨n,hn,hnA⟩ := honto A hA + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + have he : A = E n := (orbitGraph_pair E n A).mp (hEB.symm ▸ hnA) + exact ⟨n,he ▸ hxA⟩ + · left + apply ZFSet.ext; intro x + exact ⟨fun hx => False.elim (hne ⟨x,hx⟩),fun hx => False.elim (ZFSet.notMem_empty x hx)⟩ + +end TuringRigidity.InternalCountableFamily + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableFiniteUnion.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableFiniteUnion.lean new file mode 100644 index 0000000000000000000000000000000000000000..eedba21a61915e4dc7fccced502e34b3c276108e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableFiniteUnion.lean @@ -0,0 +1,147 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalFiniteEnumeration +import OAI.Computability.DegreeRigidity.SetModels.CountableSetReal +import OAI.Computability.DegreeRigidity.SetModels.InternalFunctionOrbit + +namespace OAI + +namespace TuringRigidity.InternalCountableFiniteUnion +open Set TransitiveNameModel BoundedSetTheory InternalFiniteSubsets InternalFiniteEnumeration + +def Entry (U g d k x : ZFSet.{0}) : Prop := ZFSet.pair k x ∈ g ∨ + (x = d ∧ ∀ y ∈ U, ¬ ZFSet.pair k y ∈ g) + +def entryFormula (U g d k x : ℕ) : Formula := .disj (.pairMem k x g) + (.conj (.equal x d) (.allMem U (.neg (.pairMem (k+1) 0 (g+1))))) + +theorem entryFormula_spec (U g d k x : ℕ) (e : ℕ → ZFSet.{0}) : + (entryFormula U g d k x).Eval e ↔ Entry (e U) (e g) (e d) (e k) (e x) := by + simp only [entryFormula,Entry,Formula.eval_disj,Formula.eval_allMem, + Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ] + +theorem entry_exists_unique (U g d k : ZFSet.{0}) (hg : InternalCollapse.Prefix U g) + (hd : d ∈ U) : ∃ x ∈ U, Entry U g d k x ∧ ∀ y ∈ U, Entry U g d k y → y = x := by + classical + by_cases h : ∃ x ∈ U, ZFSet.pair k x ∈ g + · obtain ⟨x,hx,hkx⟩ := h + obtain ⟨n,hg⟩ := hg + have hk : k ∈ natSet n := by + obtain ⟨k',hk,x',_,he⟩ := hg.1 _ hkx + exact (ZFSet.pair_inj.mp he).1 ▸ hk + refine ⟨x,hx,Or.inl hkx,?_⟩ + intro y _ hy + rcases hy with hy|⟨_,hy⟩ + · exact hg.functional hk hy hkx + · exact False.elim (hy x hx hkx) + · exact ⟨d,hd,Or.inr ⟨rfl,fun y hy hky => h ⟨y,hy,hky⟩⟩, + fun y hy he => he.elim (fun hky => False.elim (h ⟨y,hy,hky⟩)) And.left⟩ + +def flattenFormula (ω Q S C B T U d k x : ℕ) : Formula := + .existsMem ω (.existsMem (ω+1) (.conj (Formula.naturalPair (ω+2) (Q+2) 1 0 (k+2)) + (.existsMem (S+2) (.conj (.pairMem 2 0 (B+3)) + (.existsMem (C+3) (.conj (.pairMem 1 0 (T+4)) + (entryFormula (U+4) 0 (d+4) 2 (x+4)))))))) + +theorem flattenFormula_spec (ω Q S C B T U d k x : ℕ) (e : ℕ → ZFSet.{0}) + (hω : e ω = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ l, finiteNaturalGraph f l ∈ e Q) (N K : ℕ) + (hk : e k = natSet (Nat.pair N K)) : + (flattenFormula ω Q S C B T U d k x).Eval e ↔ + ∃ E ∈ e S, ZFSet.pair (natSet N) E ∈ e B ∧ + ∃ g ∈ e C, ZFSet.pair E g ∈ e T ∧ Entry (e U) g (e d) (natSet K) (e x) := by + simp only [flattenFormula,Formula.Eval,Formula.eval_pairMem,entryFormula_spec,cons_zero,cons_succ] + rw [hω] + constructor + · rintro ⟨n,hn,j,hj,hpair,hrest⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + obtain ⟨j,rfl⟩ := (mem_omega j).mp hj + have he := (Formula.naturalPair_spec (ω+2) (Q+2) 1 0 (k+2) + (cons (natSet j) (cons (natSet n) e)) hω hQ n j rfl rfl).mp hpair + have hh := congrArg Nat.unpair (natSet_injective (hk.symm.trans he)) + simp only [Nat.unpair_pair,Prod.mk.injEq] at hh + obtain ⟨rfl,rfl⟩ := hh + exact hrest + · intro h + exact ⟨natSet N,(mem_omega _).mpr ⟨N,rfl⟩,natSet K,(mem_omega _).mpr ⟨K,rfl⟩, + (Formula.naturalPair_spec (ω+2) (Q+2) 1 0 (k+2) + (cons (natSet K) (cons (natSet N) e)) hω hQ N K rfl rfl).mpr hk,h⟩ + +theorem internally_countable_union (M U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hU : U ∈ M) (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ finiteSubsets U) + (hB : orbitGraph E ∈ M) (hcover : ∀ p ∈ U, ∃ n, p ∈ E n) + (hne : ∃ p, p ∈ U) : InternallyCountable M U := by + classical + obtain ⟨d,hd⟩ := hne + obtain ⟨C,hCM,hC,T,hTM,hTfun,hTrange⟩ := internal_enumeration_selector M U hM hT hU + have hω := sourceT_omega_mem M hM hT + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union + hT.powerSet hT.separation.finitePrefix.bounded hω + let S := finiteSubsets U + let B := orbitGraph E + have hchoice (n k : ℕ) : ∃ x ∈ U, ∃ g ∈ C, + ZFSet.pair (E n) g ∈ T ∧ Entry U g d (natSet k) x ∧ + ∀ y ∈ U, Entry U g d (natSet k) y → y = x := by + obtain ⟨g,hg,hEg,_⟩ := hTfun.2 _ (hE n) + obtain ⟨x,hx,he,hu⟩ := entry_exists_unique U g d (natSet k) ((hC g).mp hg) hd + exact ⟨x,hx,g,hg,hEg,he,hu⟩ + choose v hv g hg hEg hentry huniq using hchoice + let f : ℕ → ZFSet.{0} := fun i => v (Nat.unpair i).1 (Nat.unpair i).2 + let e := cons ZFSet.omega (cons Q (cons S (cons C (cons B (cons T (cons U (fun _ => d))))))) + let φ : Formula := .existsMem 1 (.existsMem 8 (.conj (.orderedPair 2 1 0) + (flattenFormula 3 4 5 6 7 8 9 10 1 0))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|_|_|_|i + exact hω; exact hQM; exact finiteSubsets_mem M U hM hT hU + exact hCM; exact hB; exact hTM; exact hU; exact hM U hU d hd + have flat (N K : ℕ) (x : ZFSet.{0}) (hx : x ∈ U) (z : ZFSet.{0}) : + (flattenFormula 3 4 5 6 7 8 9 10 1 0).Eval + (cons x (cons (natSet (Nat.pair N K)) (cons z e))) ↔ x = v N K := by + rw [flattenFormula_spec 3 4 5 6 7 8 9 10 1 0 _ rfl hQ N K rfl] + change (∃ H ∈ S, ZFSet.pair (natSet N) H ∈ B ∧ + ∃ t ∈ C, ZFSet.pair H t ∈ T ∧ Entry U t d (natSet K) x) ↔ _ + constructor + · rintro ⟨H,_,hNH,t,_,hHt,ht⟩ + have hH := (orbitGraph_pair E N H).mp hNH + rw [hH] at hHt + have ht' := hTfun.functional (hE N) hHt (hEg N K) + exact huniq N K x hx (ht' ▸ ht) + · rintro rfl + exact ⟨E N,hE N,(orbitGraph_pair E N _).mpr rfl,g N K,hg N K,hEg N K,hentry N K⟩ + have hφ (z : ZFSet.{0}) : φ.Eval (cons z e) ↔ z ∈ orbitGraph f := by + simp only [φ,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,e] + constructor + · rintro ⟨i,hi,x,hx,hz,hflat⟩ + obtain ⟨i,rfl⟩ := (mem_omega i).mp hi + have hn : natSet i = natSet (Nat.pair (Nat.unpair i).1 (Nat.unpair i).2) := by rw [Nat.pair_unpair] + have hflat' := hflat + rw [hn] at hflat' + have hx' := (flat (Nat.unpair i).1 (Nat.unpair i).2 x hx z).mp hflat' + exact (mem_orbitGraph f z).mpr ⟨i,by rw [hz,hx']⟩ + · intro hz + obtain ⟨i,rfl⟩ := (mem_orbitGraph f z).mp hz + refine ⟨natSet i,(mem_omega _).mpr ⟨i,rfl⟩,f i,hv _ _,rfl,?_⟩ + have hh := (flat (Nat.unpair i).1 (Nat.unpair i).2 (f i) (hv _ _) + (ZFSet.pair (natSet i) (f i))).mpr rfl + simpa only [Nat.pair_unpair] using hh + have hG : orbitGraph f ∈ M := by + have hh := sep_mem M hM hT.separation.finitePrefix.bounded φ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hω hU) + have heq : (ZFSet.prod ZFSet.omega U).sep (fun z => φ.Eval (cons z e)) = orbitGraph f := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,hφ] + exact ⟨And.right,fun hz => ⟨ZFSet.mem_prod.mpr ((orbitGraph_function U f (fun _ => hv _ _)).1 z hz),hz⟩⟩ + exact heq ▸ hh + refine ⟨orbitGraph f,hG,orbitGraph_function U f (fun _ => hv _ _),?_⟩ + intro p hp + obtain ⟨n,hpE⟩ := hcover p hp + have hr := hTrange (E n) (hE n) (g n 0) (hEg n 0) + obtain ⟨k,hk,hkp⟩ := (hr.2 p hp).mp hpE + obtain ⟨k,rfl⟩ := (mem_omega k).mp hk + have heq := hTfun.functional (hE n) (hEg n 0) (hEg n k) + have hpv := huniq n k p hp (Or.inl (heq ▸ hkp)) + refine ⟨natSet (Nat.pair n k),(mem_omega _).mpr ⟨Nat.pair n k,rfl⟩,?_⟩ + apply (orbitGraph_pair f _ p).mpr + simpa only [f,Nat.unpair_pair] using hpv + +end TuringRigidity.InternalCountableFiniteUnion + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableMap.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableMap.lean new file mode 100644 index 0000000000000000000000000000000000000000..f556bdb578e39bc5b79faae893bc616c367fbd34 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableMap.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalRelationSelection + +namespace OAI + +namespace TuringRigidity.InternalCountableMap +open TransitiveNameModel BoundedSetTheory + +noncomputable def composite (A B C f g : ZFSet.{0}) : ZFSet.{0} := + (ZFSet.prod A C).sep (fun z => ∃ x ∈ A, ∃ y ∈ C, + z = ZFSet.pair x y ∧ ∃ t ∈ B, ZFSet.pair x t ∈ f ∧ ZFSet.pair t y ∈ g) + +theorem pair_composite (A B C f g x y : ZFSet.{0}) : + ZFSet.pair x y ∈ composite A B C f g ↔ + x ∈ A ∧ y ∈ C ∧ ∃ t ∈ B, ZFSet.pair x t ∈ f ∧ ZFSet.pair t y ∈ g := by + simp only [composite,ZFSet.mem_sep] + constructor + · rintro ⟨_,x',hx,y',hy,he,ht⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hx,hy,ht⟩ + · rintro ⟨hx,hy,ht⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨hx,hy⟩,x,hx,y,hy,rfl,ht⟩ + +theorem composite_mem (M A B C f g : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hB : B ∈ M) (hC : C ∈ M) (hf : f ∈ M) (hg : g ∈ M) : + composite A B C f g ∈ M := by + let e := cons A (cons C (cons B (cons f (fun _ => g)))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|i + exact hA; exact hC; exact hB; exact hf; exact hg + simpa only [composite,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) + (.existsMem 5 (.conj (.pairMem 2 0 7) (.pairMem 0 1 8)))))) e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hA hC) + +theorem composite_function (A B C f g : ZFSet.{0}) + (hf : FunctionGraph A B f) (hg : FunctionGraph B C g) : + FunctionGraph A C (composite A B C f g) := by + constructor + · intro z hz + exact ZFSet.mem_prod.mp (ZFSet.mem_sep.mp hz).1 + · intro x hx + obtain ⟨t,ht,hxt,_⟩ := hf.2 x hx + obtain ⟨y,hy,hty,_⟩ := hg.2 t ht + refine ⟨y,hy,(pair_composite A B C f g x y).mpr ⟨hx,hy,t,ht,hxt,hty⟩,?_⟩ + intro y' _ hxy' + obtain ⟨_,_,t',_,hxt',hty'⟩ := (pair_composite A B C f g x y').mp hxy' + have he := hf.functional hx hxt' hxt + exact hg.functional ht (he ▸ hty') hty + +theorem countable_of_surjection (M A B g : ZFSet.{0}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) (hB : B ∈ M) (hgM : g ∈ M) + (hg : FunctionGraph A B g) (honto : ∀ y ∈ B, ∃ x ∈ A, ZFSet.pair x y ∈ g) + (hct : InternallyCountable M A) : InternallyCountable M B := by + obtain ⟨f,hfM,hf,hfOnto⟩ := hct + refine ⟨composite ZFSet.omega A B f g, + composite_mem M _ A B f g hM hT (sourceT_omega_mem M hM hT) hA hB hfM hgM, + composite_function _ A B f g hf hg,?_⟩ + intro y hy + obtain ⟨x,hx,hxy⟩ := honto y hy + obtain ⟨n,hn,hnx⟩ := hfOnto x hx + exact ⟨n,hn,(pair_composite _ A B f g n y).mpr ⟨hn,hy,x,hx,hnx,hxy⟩⟩ + +end TuringRigidity.InternalCountableMap + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableOrdinals.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableOrdinals.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b5baa1c7e3d26e2b4584b2ef658309ab1b629cb --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableOrdinals.lean @@ -0,0 +1,108 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableClosure +import Mathlib.SetTheory.ZFC.Ordinal + +namespace OAI + +namespace TuringRigidity.InternalCountableOrdinals +open TransitiveNameModel BoundedSetTheory InternalCountableClosure + +def FirstUncountable (M K : ZFSet.{0}) : Prop := + K.IsOrdinal ∧ K ∈ M ∧ ¬ (K = ∅ ∨ InternallyCountable M K) ∧ + ∀ a ∈ K, a = ∅ ∨ InternallyCountable M a + +theorem successor_mem (M a : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) : insert a a ∈ M := by + have he : insert a a = ({a} : ZFSet.{0}) ∪ a := by + apply ZFSet.ext; intro z + simp only [ZFSet.mem_insert_iff,ZFSet.mem_union,ZFSet.mem_singleton] + rw [he] + exact binary_union_mem M hM hT.pairing hT.union (singleton_mem M hM hT.pairing ha) ha + +theorem nonempty (M K : ZFSet.{0}) (hK : FirstUncountable M K) : ∃ x, x ∈ K := by + classical + by_contra h + apply hK.2.2.1; left + apply ZFSet.ext; intro x + exact ⟨fun hx => False.elim (h ⟨x,hx⟩),fun hx => False.elim (ZFSet.notMem_empty x hx)⟩ + +theorem countable_ordinal_lt (M K a : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : FirstUncountable M K) (haM : a ∈ M) (ha : a.IsOrdinal) + (hct : a = ∅ ∨ InternallyCountable M a) : a ∈ K := by + rcases ha.mem_or_subset hK.1 with h|h + · exact h + · exfalso + rcases hct with rfl|hct + · obtain ⟨x,hx⟩ := nonempty M K hK + exact ZFSet.notMem_empty x (h hx) + · exact hK.2.2.1 (Or.inr (countable_subset M a K hM hT haM hK.2.1 h hct (nonempty M K hK))) + +theorem unique (M K L : ZFSet.{0}) + (hK : FirstUncountable M K) (hL : FirstUncountable M L) : K = L := by + rcases hK.1.mem_trichotomous hL.1 with h|h|h + · exact False.elim (hK.2.2.1 (hL.2.2.2 K h)) + · exact h + · exact False.elim (hL.2.2.1 (hK.2.2.2 L h)) + +theorem sUnion_isOrdinal (S : ZFSet.{0}) (hS : ∀ a ∈ S, a.IsOrdinal) : + (ZFSet.sUnion S).IsOrdinal := by + apply ZFSet.isOrdinal_iff_forall_mem_isOrdinal.mpr + refine ⟨ZFSet.IsTransitive.sUnion' (fun a ha => (hS a ha).isTransitive),?_⟩ + intro x hx + obtain ⟨a,ha,hx⟩ := ZFSet.mem_sUnion.mp hx + exact (hS a ha).mem hx + +theorem countable_ordinal_union (M S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hSM : S ∈ M) (hct : S = ∅ ∨ InternallyCountable M S) + (hord : ∀ a ∈ S, a.IsOrdinal) + (hsets : ∀ a ∈ S, a = ∅ ∨ InternallyCountable M a) : + ZFSet.sUnion S ∈ M ∧ (ZFSet.sUnion S).IsOrdinal ∧ + (ZFSet.sUnion S = ∅ ∨ InternallyCountable M (ZFSet.sUnion S)) := + ⟨union_mem M hM hT.union hSM,sUnion_isOrdinal S hord, + InternalCountableFamily.countable_sUnion M S hM hT hSM hct hsets⟩ + +theorem countable_subset_bounded (M K S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : FirstUncountable M K) (hSM : S ∈ M) (hSK : S ⊆ K) + (hct : S = ∅ ∨ InternallyCountable M S) : + ∃ b ∈ K, b ∈ M ∧ b.IsOrdinal ∧ InternallyCountable M b ∧ ∀ a ∈ S, a ∈ b := by + obtain ⟨hUM,hU,hctU⟩ := countable_ordinal_union M S hM hT hSM hct + (fun a ha => hK.1.mem (hSK ha)) (fun a ha => hK.2.2.2 a (hSK ha)) + let b := insert (ZFSet.sUnion S) (ZFSet.sUnion S) + have hbM : b ∈ M := successor_mem M _ hM hT hUM + have hb : b.IsOrdinal := ZFSet.isOrdinal_succ hU + have hcb : InternallyCountable M b := countable_insert M _ _ hM hT hUM hUM hctU + refine ⟨b,countable_ordinal_lt M K b hM hT hK hbM hb (Or.inr hcb),hbM,hb,hcb,?_⟩ + intro a ha + have hsub : a ⊆ ZFSet.sUnion S := fun x hx => ZFSet.mem_sUnion.mpr ⟨a,ha,hx⟩ + exact ZFSet.mem_insert_iff.mpr (((hK.1.mem (hSK ha)).subset_iff_eq_or_mem hU).mp hsub) + +theorem no_countable_cofinal_subset (M K S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : FirstUncountable M K) (hSM : S ∈ M) (hSK : S ⊆ K) + (hct : S = ∅ ∨ InternallyCountable M S) : + ¬ (∀ b ∈ K, ∃ a ∈ S, b ⊆ a) := by + obtain ⟨b,hb,_,_,_,hbound⟩ := countable_subset_bounded M K S hM hT hK hSM hSK hct + intro h + obtain ⟨a,ha,hba⟩ := h b hb + exact ZFSet.mem_irrefl a (hba (hbound a ha)) + +theorem firstUncountable_below (M L : ZFSet.{0}) (hM : Transitive M) + (hL : L ∈ M) (hord : L.IsOrdinal) + (hunc : ¬ (L = ∅ ∨ InternallyCountable M L)) : + ∃ K, FirstUncountable M K ∧ K ⊆ L := by + classical + have h : ∀ L : ZFSet.{0}, L ∈ M → L.IsOrdinal → + ¬ (L = ∅ ∨ InternallyCountable M L) → ∃ K, FirstUncountable M K ∧ K ⊆ L := by + intro L + induction L using ZFSet.mem_wf.induction with + | h L ih => + intro hLM ho hu + by_cases hs : ∀ a ∈ L, a = ∅ ∨ InternallyCountable M a + · exact ⟨L,⟨ho,hLM,hu,hs⟩,fun _ h => h⟩ + · push Not at hs + obtain ⟨a,ha,hac⟩ := hs + obtain ⟨K,hK,hKa⟩ := ih a ha (hM L hLM a ha) (ho.mem ha) (not_or.mpr hac) + exact ⟨K,hK,fun x hx => ho.subset_of_mem ha (hKa hx)⟩ + exact h L hL hord hunc + +end TuringRigidity.InternalCountableOrdinals + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableProduct.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbe2e39097671f503debfd1f62924387033b3100 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableProduct.lean @@ -0,0 +1,116 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalFiniteExhaustion + +namespace OAI + +namespace TuringRigidity.InternalCountableProduct +open TransitiveNameModel BoundedSetTheory InternalFiniteSubsets InternalFiniteExhaustion + +theorem finite_product (A B : ZFSet.{0}) + (hA : (A : Set ZFSet.{0}).Finite) (hB : (B : Set ZFSet.{0}).Finite) : + (ZFSet.prod A B : Set ZFSet.{0}).Finite := by + apply ((hA.prod hB).image (fun t => ZFSet.pair t.1 t.2)).subset + intro z hz + obtain ⟨x,hx,y,hy,hz⟩ := ZFSet.mem_prod.mp hz + exact ⟨(x,y),⟨hx,hy⟩,hz.symm⟩ + +def rectangleFormula (A B f g n p : ℕ) : Formula := + .existsMem A (.existsMem (B+1) (.conj (.orderedPair (p+2) 1 0) + (.conj (initialFormula (f+2) (n+2) 1) (initialFormula (g+2) (n+2) 0)))) + +theorem rectangleFormula_spec (A B f g n p : ℕ) (e : ℕ → ZFSet.{0}) + (F G : ℕ → ZFSet.{0}) (N : ℕ) + (hF : ∀ k, F k ∈ e A) (hG : ∀ k, G k ∈ e B) + (hf : e f = orbitGraph F) (hg : e g = orbitGraph G) (hn : e n = natSet N) : + (rectangleFormula A B f g n p).Eval e ↔ e p ∈ ZFSet.prod (initial F N) (initial G N) := by + simp only [rectangleFormula,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ] + constructor + · rintro ⟨x,_,y,_,hp,hx,hy⟩ + exact ZFSet.mem_prod.mpr ⟨x, + (initialFormula_spec (f+2) (n+2) 1 _ F N hf hn).mp hx,y, + (initialFormula_spec (g+2) (n+2) 0 _ G N hg hn).mp hy,hp⟩ + · intro hp + obtain ⟨x,hx,y,hy,hp⟩ := ZFSet.mem_prod.mp hp + exact ⟨x,initial_subset (e A) F hF N hx,y,initial_subset (e B) G hG N hy,hp, + (initialFormula_spec (f+2) (n+2) 1 _ F N hf hn).mpr hx, + (initialFormula_spec (g+2) (n+2) 0 _ G N hg hn).mpr hy⟩ + +theorem product_countable (M A B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hB : B ∈ M) + (hcA : InternallyCountable M A) (hcB : InternallyCountable M B) : + InternallyCountable M (ZFSet.prod A B) := by + obtain ⟨f,hf,hff,hfo⟩ := hcA + obtain ⟨g,hg,hgf,hgo⟩ := hcB + obtain ⟨F,hF,hFf⟩ := InternalCountableFamily.sequence_of_graph A f hff + obtain ⟨G,hG,hGg⟩ := InternalCountableFamily.sequence_of_graph B g hgf + have hprod := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hA hB + let E := fun n => ZFSet.prod (initial F n) (initial G n) + have hsub (n : ℕ) : E n ⊆ ZFSet.prod A B := by + intro z hz + obtain ⟨x,hx,y,hy,hz⟩ := ZFSet.mem_prod.mp hz + exact ZFSet.mem_prod.mpr ⟨x,initial_subset A F hF n hx,y,initial_subset B G hG n hy,hz⟩ + have hgraph : orbitGraph E ∈ M := by + let e := cons A (cons B (cons f (fun _ => g))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|i + exact hA; exact hB; exact hf; exact hg + exact InternalSubsetSequence.subset_sequence M _ hM hT hprod + (rectangleFormula 2 3 4 5 1 0) e he E hsub + (fun n _ _ => rectangleFormula_spec 2 3 4 5 1 0 _ F G n hF hG hFf.symm hGg.symm rfl) + apply InternalCountableFiniteUnion.internally_countable_union M _ hM hT hprod E + (fun n => (mem_finiteSubsets_iff _ (E n)).mpr + ⟨hsub n,finite_product _ _ (initial_finite F n) (initial_finite G n)⟩) hgraph + · intro z hz + obtain ⟨x,hx,y,hy,hz⟩ := ZFSet.mem_prod.mp hz + obtain ⟨i,hi,hix⟩ := hfo x hx + obtain ⟨j,hj,hjy⟩ := hgo y hy + obtain ⟨i,rfl⟩ := (mem_omega i).mp hi + obtain ⟨j,rfl⟩ := (mem_omega j).mp hj + refine ⟨max i j + 1,ZFSet.mem_prod.mpr ⟨x,?_,y,?_,hz⟩⟩ + · exact (mem_initial F _ x).mpr + ⟨i,Nat.lt_succ_of_le (Nat.le_max_left i j),(orbitGraph_pair F i x).mp (hFf.symm ▸ hix)⟩ + · exact (mem_initial G _ y).mpr + ⟨j,Nat.lt_succ_of_le (Nat.le_max_right i j),(orbitGraph_pair G j y).mp (hGg.symm ▸ hjy)⟩ + · exact ⟨ZFSet.pair (F 0) (G 0),ZFSet.pair_mem_prod.mpr ⟨hF 0,hG 0⟩⟩ + +theorem product_empty_left (B : ZFSet.{0}) : ZFSet.prod ∅ B = ∅ := by + apply ZFSet.ext; intro z; simp [ZFSet.mem_prod] + +theorem product_empty_right (A : ZFSet.{0}) : ZFSet.prod A ∅ = ∅ := by + apply ZFSet.ext; intro z; simp [ZFSet.mem_prod] + +theorem product_countable_or_empty (M A B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hB : B ∈ M) + (hcA : A = ∅ ∨ InternallyCountable M A) (hcB : B = ∅ ∨ InternallyCountable M B) : + ZFSet.prod A B = ∅ ∨ InternallyCountable M (ZFSet.prod A B) := by + rcases hcA with rfl|hcA + · exact Or.inl (product_empty_left B) + rcases hcB with rfl|hcB + · exact Or.inl (product_empty_right A) + exact Or.inr (product_countable M A B hM hT hA hB hcA hcB) + +theorem omega_countable (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) : + InternallyCountable M ZFSet.omega := by + have hω := sourceT_omega_mem M hM hT + have hn (n : ℕ) : natSet.{0} n ∈ ZFSet.omega := (mem_omega _).mpr ⟨n,rfl⟩ + let e : ℕ → ZFSet.{0} := fun _ => ZFSet.omega + let φ : Formula := .existsMem 1 (.orderedPair 1 0 0) + have hφ (z : ZFSet.{0}) : φ.Eval (cons z e) ↔ z ∈ orbitGraph natSet := by + simp only [φ,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,e,mem_orbitGraph] + exact ⟨fun ⟨x,hx,hz⟩ => by obtain ⟨n,rfl⟩ := (mem_omega x).mp hx; exact ⟨n,hz⟩, + fun ⟨n,hz⟩ => ⟨natSet n,hn n,hz⟩⟩ + have hs := sep_mem M hM hT.separation.finitePrefix.bounded φ e (fun _ => hω) + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hω hω) + have heq : (ZFSet.prod ZFSet.omega ZFSet.omega).sep (fun z => φ.Eval (cons z e)) = + orbitGraph natSet := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,hφ] + exact ⟨And.right,fun hz => ⟨ZFSet.mem_prod.mpr ((orbitGraph_function _ natSet hn).1 z hz),hz⟩⟩ + refine ⟨orbitGraph natSet,heq ▸ hs,orbitGraph_function _ natSet hn,?_⟩ + intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + exact ⟨natSet n,hn n,(orbitGraph_pair natSet n _).mpr rfl⟩ + +end TuringRigidity.InternalCountableProduct + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableUnion.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableUnion.lean new file mode 100644 index 0000000000000000000000000000000000000000..349ca02230a5fde120a72315fc358da69aa0125e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCountableUnion.lean @@ -0,0 +1,90 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableEnumeration + +namespace OAI + +namespace TuringRigidity.InternalCountableUnion +open TransitiveNameModel BoundedSetTheory InternalCountableFiniteUnion InternalCountableEnumeration + +theorem internally_countable_union (M U S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hU : U ∈ M) (hS : S ∈ M) + (hsub : ∀ H ∈ S, H ⊆ U) (hct : ∀ H ∈ S, H = ∅ ∨ InternallyCountable M H) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ S) + (hB : orbitGraph E ∈ M) (hcover : ∀ p ∈ U, ∃ n, p ∈ E n) + (hne : ∃ p, p ∈ U) : InternallyCountable M U := by + classical + obtain ⟨d,hd⟩ := hne + obtain ⟨C,hCM,T,hTM,hTfun,hEnum⟩ := internal_countable_selector M U S hM hT hU hS hsub hct + have hω := sourceT_omega_mem M hM hT + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union + hT.powerSet hT.separation.finitePrefix.bounded hω + let B := orbitGraph E + have hchoice (n k : ℕ) : ∃ x ∈ U, ∃ g ∈ C, + ZFSet.pair (E n) g ∈ T ∧ Entry U g d (natSet k) x ∧ + ∀ y ∈ U, Entry U g d (natSet k) y → y = x := by + obtain ⟨g,hg,hEg,_⟩ := hTfun.2 _ (hE n) + obtain ⟨x,hx,he,hu⟩ := enumerates_entry U (E n) g d (natSet k) (hsub _ (hE n)) + (hEnum _ (hE n) g hEg) hd ((mem_omega _).mpr ⟨k,rfl⟩) + exact ⟨x,hx,g,hg,hEg,he,hu⟩ + choose v hv g hg hEg hentry huniq using hchoice + let f : ℕ → ZFSet.{0} := fun i => v (Nat.unpair i).1 (Nat.unpair i).2 + let e := cons ZFSet.omega (cons Q (cons S (cons C (cons B (cons T (cons U (fun _ => d))))))) + let φ : Formula := .existsMem 1 (.existsMem 8 (.conj (.orderedPair 2 1 0) + (flattenFormula 3 4 5 6 7 8 9 10 1 0))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|_|_|_|i + exact hω; exact hQM; exact hS + exact hCM; exact hB; exact hTM; exact hU; exact hM U hU d hd + have flat (N K : ℕ) (x : ZFSet.{0}) (hx : x ∈ U) (z : ZFSet.{0}) : + (flattenFormula 3 4 5 6 7 8 9 10 1 0).Eval + (cons x (cons (natSet (Nat.pair N K)) (cons z e))) ↔ x = v N K := by + rw [flattenFormula_spec 3 4 5 6 7 8 9 10 1 0 _ rfl hQ N K rfl] + change (∃ H ∈ S, ZFSet.pair (natSet N) H ∈ B ∧ + ∃ t ∈ C, ZFSet.pair H t ∈ T ∧ Entry U t d (natSet K) x) ↔ _ + constructor + · rintro ⟨H,_,hNH,t,_,hHt,ht⟩ + have hH := (orbitGraph_pair E N H).mp hNH + rw [hH] at hHt + have ht' := hTfun.functional (hE N) hHt (hEg N K) + exact huniq N K x hx (ht' ▸ ht) + · rintro rfl + exact ⟨E N,hE N,(orbitGraph_pair E N _).mpr rfl,g N K,hg N K,hEg N K,hentry N K⟩ + have hφ (z : ZFSet.{0}) : φ.Eval (cons z e) ↔ z ∈ orbitGraph f := by + simp only [φ,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,e] + constructor + · rintro ⟨i,hi,x,hx,hz,hflat⟩ + obtain ⟨i,rfl⟩ := (mem_omega i).mp hi + have hn : natSet i = natSet (Nat.pair (Nat.unpair i).1 (Nat.unpair i).2) := by rw [Nat.pair_unpair] + have hflat' := hflat + rw [hn] at hflat' + have hx' := (flat (Nat.unpair i).1 (Nat.unpair i).2 x hx z).mp hflat' + exact (mem_orbitGraph f z).mpr ⟨i,by rw [hz,hx']⟩ + · intro hz + obtain ⟨i,rfl⟩ := (mem_orbitGraph f z).mp hz + refine ⟨natSet i,(mem_omega _).mpr ⟨i,rfl⟩,f i,hv _ _,rfl,?_⟩ + have hh := (flat (Nat.unpair i).1 (Nat.unpair i).2 (f i) (hv _ _) + (ZFSet.pair (natSet i) (f i))).mpr rfl + simpa only [Nat.pair_unpair] using hh + have hG : orbitGraph f ∈ M := by + have hh := sep_mem M hM hT.separation.finitePrefix.bounded φ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hω hU) + have heq : (ZFSet.prod ZFSet.omega U).sep (fun z => φ.Eval (cons z e)) = orbitGraph f := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,hφ] + exact ⟨And.right,fun hz => ⟨ZFSet.mem_prod.mpr ((orbitGraph_function U f (fun _ => hv _ _)).1 z hz),hz⟩⟩ + exact heq ▸ hh + refine ⟨orbitGraph f,hG,orbitGraph_function U f (fun _ => hv _ _),?_⟩ + intro p hp + obtain ⟨n,hpE⟩ := hcover p hp + have hr := enumerates_ranges U (E n) (g n 0) (hsub _ (hE n)) + (hEnum (E n) (hE n) (g n 0) (hEg n 0)) + obtain ⟨k,hk,hkp⟩ := (hr.2 p hp).mp hpE + obtain ⟨k,rfl⟩ := (mem_omega k).mp hk + have heq := hTfun.functional (hE n) (hEg n 0) (hEg n k) + have hpv := huniq n k p hp (Or.inl (heq ▸ hkp)) + refine ⟨natSet (Nat.pair n k),(mem_omega _).mpr ⟨Nat.pair n k,rfl⟩,?_⟩ + apply (orbitGraph_pair f _ p).mpr + simpa only [f,Nat.unpair_pair] using hpv + +end TuringRigidity.InternalCountableUnion + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCoverInjection.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCoverInjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c28e98d356bd11b5f47435059d7fb8adf01b84c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalCoverInjection.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.Syntax.TermFunctionality +import OAI.Computability.DegreeRigidity.SetModels.InternalUniformization + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse +universe u +namespace FiniteTerm + +noncomputable def inverseCover (h K E : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ x ∈ h, ∃ c ∈ K, z = ZFSet.pair x c ∧ ZFSet.pair c x ∈ E) (ZFSet.prod h K) + +theorem inverseCover_pair (h K E x c : ZFSet.{u}) : + ZFSet.pair x c ∈ inverseCover h K E ↔ x ∈ h ∧ c ∈ K ∧ ZFSet.pair c x ∈ E := by + rw [inverseCover,ZFSet.mem_sep] + constructor + · rintro ⟨_,y,hy,d,hd,he,hdy⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hy,hd,hdy⟩ + · rintro ⟨hx,hc,hcx⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨x,hx,c,hc,rfl⟩,x,hx,c,hc,rfl,hcx⟩ + +theorem inverseCover_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + {h K E : ZFSet.{u}} (hh : h ∈ M) (hK : K ∈ M) (hE : E ∈ M) : inverseCover h K E ∈ M := by + simpa only [inverseCover,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + cons_zero,cons_succ] using + sep_mem M hM hS (.existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) (.pairMem 0 1 5)))) + (cons h (cons K (fun _ => E))) (by + intro i; rcases i with _|i; exact hh + rcases i with _|i; exact hK + exact hE) (product_mem M hM hP hU hPow hS hh hK) + +theorem internal_injection_of_cover (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hAC : Choice M) {h K E : ZFSet.{u}} + (hh : h ∈ M) (hK : K ∈ M) (hE : E ∈ M) (hfun : Functional E) + (hcover : ∀ x ∈ h, ∃ c ∈ K, ZFSet.pair c x ∈ E) : + ∃ f ∈ M, ∃ j : ZFSet.{u} → ZFSet.{u}, Presents h f j ∧ + (∀ x ∈ h, j x ∈ K) ∧ (∀ x ∈ h, ZFSet.pair (j x) x ∈ E) ∧ + (∀ x ∈ h, ∀ y ∈ h, j x = j y → x = y) := by + classical + have hr := inverseCover_mem M hM hP hU hPow hS hh hK hE + obtain ⟨f,hf,hfr,hshape,hsel⟩ := internal_relation_choice M hM hP hU hPow hS hAC hh hK hr (by + intro x hx + obtain ⟨c,hc,hcx⟩ := hcover x hx + exact ⟨c,hc,(inverseCover_pair h K E x c).mpr ⟨hx,hc,hcx⟩⟩) + let j := fun x => if hx : x ∈ h then (hsel x hx).choose else ∅ + have hj (x : ZFSet.{u}) (hx : x ∈ h) : j x ∈ K ∧ ZFSet.pair x (j x) ∈ f ∧ + ∀ c ∈ K, ZFSet.pair x c ∈ f → c = j x := by + simp only [j,dite_eq_left hx] + exact (hsel x hx).choose_spec + have hEpair (x : ZFSet.{u}) (hx : x ∈ h) : ZFSet.pair (j x) x ∈ E := + ((inverseCover_pair h K E x (j x)).mp (hfr (hj x hx).2.1)).2.2 + refine ⟨f,hf,j,?_,fun x hx => (hj x hx).1,hEpair,?_⟩ + · intro z + constructor + · intro hz + obtain ⟨x,hx,c,hc,rfl⟩ := hshape z hz + have hcj := (hj x hx).2.2 c hc hz + exact ⟨x,hx,congrArg (ZFSet.pair x) hcj⟩ + · rintro ⟨x,hx,rfl⟩ + exact (hj x hx).2.1 + · intro x hx y hy he + have hyE := hEpair y hy + rw [← he] at hyE + exact hfun (j x) x y (hEpair x hx) hyE + +theorem internal_evaluated_injection (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hAC : Choice M) {A B L O D E K h : ZFSet.{u}} + (hh : h ∈ M) (hK : K ∈ M) (hE : E ∈ M) + (hL : Functional L) (hO : Functional O) (hsub : E ⊆ ZFSet.prod K D) + (hgraph : ∀ c v, ZFSet.pair c v ∈ E ↔ Eval A B L O D c v) + (hcover : ∀ x ∈ h, ∃ c, Eval A B L O D c x) : + ∃ f ∈ M, ∃ j : ZFSet.{u} → ZFSet.{u}, Presents h f j ∧ + (∀ x ∈ h, j x ∈ K) ∧ (∀ x ∈ h, ∀ y ∈ h, j x = j y → x = y) := by + have hc : ∀ x ∈ h, ∃ c ∈ K, ZFSet.pair c x ∈ E := by + intro x hx + obtain ⟨c,hcx⟩ := hcover x hx + have hp := (hgraph c x).mpr hcx + obtain ⟨c',hc',v,_,he⟩ := ZFSet.mem_prod.mp (hsub hp) + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨c,hc',hp⟩ + obtain ⟨f,hf,j,hfj,hj,_,hi⟩ := internal_injection_of_cover M hM hP hU hPow hS hAC hh hK hE + (evaluation_graph_functional hL hO hgraph) hc + exact ⟨f,hf,j,hfj,hj,hi⟩ + +end FiniteTerm +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalDefinablePower.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalDefinablePower.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b5393fa1f5aa70f639722ac6821b3002a16f6c4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalDefinablePower.lean @@ -0,0 +1,46 @@ +import OAI.Computability.DegreeRigidity.Syntax.DefinableSubsetCertificates + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +theorem definablePower_mem (M A : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) : definablePower A ∈ M := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + obtain ⟨Q,hQ,_,hf⟩ := internal_family_bound M hM C.pairing C.union C.power C.omega_mem + obtain ⟨B,hB,hb⟩ := internal_support_bound C + obtain ⟨G,hG,hg⟩ := internal_tuple_graph_bound C hA + have ht := tupleSpace_mem M A hM hT hA + have hz := satisfactionSet_mem M A hM hT hA + obtain ⟨P,hP,_,hsub⟩ := definablePower_internal_bound M A hM C.separation C.power hA + let e := cons A (cons (tupleSpace A) (cons (satisfactionSet A) (fun _ => ZFSet.omega))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|i + · exact hA + · exact ht + · exact hz + · exact C.omega_mem + have hd := definitionWitness_definable C hQ hB hG 1 2 3 0 + have hs := hd.sep_mem C e he hP + have heq : P.sep (fun S => DefinitionWitness Q B G A (tupleSpace A) (satisfactionSet A) S) = + definablePower A := by + apply ZFSet.ext; intro S + rw [ZFSet.mem_sep,definitionWitness_spec Q B G A S hf hb hg,← mem_definablePower] + exact ⟨And.right,fun h => ⟨hsub h,h⟩⟩ + exact heq ▸ hs + +theorem internal_definable_successor (M A : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) : + ∃ D ∈ M, (∀ S, S ∈ D ↔ DefinableOver A S) ∧ + ∀ E, (∀ S, S ∈ E ↔ DefinableOver A S) → E = D := by + refine ⟨definablePower A,definablePower_mem M A hM hT hA,mem_definablePower A,?_⟩ + intro E hE + exact ZFSet.ext (fun S => (hE S).trans (mem_definablePower A S).symm) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalDenseFamily.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalDenseFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..6453002670edf87f202ecbba66c9a3a4e3f01dbd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalDenseFamily.lean @@ -0,0 +1,78 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalGenericFilter + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalGeneric +open TransitiveNameModel CountableForcing +universe u + +namespace Code +open Formula + +def dense (c o t : ℕ) : Formula := allMem c (.existsMem (c+1) + (.conj (.member 0 (t+2)) (.pairMem 0 1 (o+2)))) + +theorem eval_dense (c o t : ℕ) (e : ℕ → ZFSet.{u}) : + (dense c o t).Eval e ↔ ∀ p ∈ e c, ∃ q ∈ e c, q ∈ e t ∧ ZFSet.pair q p ∈ e o := by + simp only [dense,Formula.eval_allMem,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ] +end Code + +theorem dense_labels {c o t : ZFSet.{u}} [Preorder (Conditions c)] + (ho : ∀ p q : Conditions c, ZFSet.pair (label c p) (label c q) ∈ o ↔ p ≤ q) : + (∀ p ∈ c, ∃ q ∈ c, q ∈ t ∧ ZFSet.pair q p ∈ o) ↔ Dense {p : Conditions c | label c p ∈ t} := by + constructor + · intro h p + obtain ⟨q,hq,hqt,hqp⟩ := h (label c p) (label_mem c p) + obtain ⟨j,rfl⟩ := label_surjective c hq + exact ⟨j,(ho j p).mp hqp,hqt⟩ + · intro h p hp + obtain ⟨i,rfl⟩ := label_surjective c hp + obtain ⟨j,hji,hjt⟩ := h i + exact ⟨_,label_mem c j,hjt,(ho j i).mpr hji⟩ + +theorem dense_family (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} [Preorder (Conditions c)] (hc : c ∈ M) (hoM : o ∈ M) + (ho : ∀ p q : Conditions c, ZFSet.pair (label c p) (label c q) ∈ o ↔ p ≤ q) : + ∃ D ∈ M, (∀ t, t ∈ D ↔ t ∈ M ∧ t ⊆ c ∧ Dense {p : Conditions c | label c p ∈ t}) ∧ + c ∈ D := by + obtain ⟨Q,hQM,hQ⟩ := internal_power M hM hT.powerSet hc + let D := ZFSet.sep (fun t => (Code.dense 1 2 0).Eval (cons t (cons c (fun _ => o)))) Q + have hDM : D ∈ M := sep_mem M hM hT.separation.finitePrefix.bounded _ + (cons c (fun _ => o)) (by intro i; cases i <;> assumption) hQM + have hD (t : ZFSet.{u}) : t ∈ D ↔ t ∈ M ∧ t ⊆ c ∧ Dense {p : Conditions c | label c p ∈ t} := by + dsimp only [D] + rw [ZFSet.mem_sep,hQ,Code.eval_dense] + simp only [cons_zero,cons_succ] + rw [dense_labels ho] + exact and_assoc + exact ⟨D,hDM,hD,(hD c).mpr ⟨hc,fun _ h => h,fun p => ⟨p,le_rfl,label_mem c p⟩⟩⟩ + +theorem internal_ground_generic (M N : ZFSet.{u}) + (hM : Transitive M) (hN : Transitive N) (hTM : SourceT M) (hTN : SourceT N) + (hMN : M ⊆ N) {c o D : ZFSet.{u}} [Preorder (Conditions c)] + (hc : c ∈ M) (hoM : o ∈ M) (hDM : D ∈ M) + (ho : ∀ p q : Conditions c, ZFSet.pair (label c p) (label c q) ∈ o ↔ p ≤ q) + (hD : ∀ t, t ∈ D ↔ t ∈ M ∧ t ⊆ c ∧ Dense {p : Conditions c | label c p ∈ t}) + (hcount : InternallyCountable N D) (p₀ : Conditions c) : + ∃ G : GenericFilter (Conditions c), p₀ ∈ G.carrier ∧ genericFilterSet c G.carrier ∈ N ∧ + AtomicForcing.GroundGeneric M G := by + obtain ⟨G,hp,hGN,hmeet⟩ := internal_generic_filter N hN hTN (hMN hc) (hMN hoM) (hMN hDM) ho + hcount (fun t ht => ((hD t).mp ht).2.2) p₀ + refine ⟨G,hp,hGN,?_⟩ + intro E hEM hE + let t := ZFSet.sep (fun x => x ∈ E) c + have htM : t ∈ M := sep_mem M hM hTM.separation.finitePrefix.bounded (.member 0 1) + (fun _ => E) (fun _ => hEM) hc + have htD : t ∈ D := by + apply (hD t).mpr + refine ⟨htM,fun _ h => (ZFSet.mem_sep.mp h).1,?_⟩ + intro p + obtain ⟨q,hqp,hqE⟩ := hE p + exact ⟨q,hqp,ZFSet.mem_sep.mpr ⟨label_mem c q,hqE⟩⟩ + obtain ⟨q,hq,hqt⟩ := hmeet t htD + exact ⟨q,hq,(ZFSet.mem_sep.mp hqt).2⟩ + +end TuringRigidity.BoundedSetTheory.InternalGeneric + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalDenseInclusion.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalDenseInclusion.lean new file mode 100644 index 0000000000000000000000000000000000000000..a396b7f23f7377b4fe0232b545bdc78428d348df --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalDenseInclusion.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularTreeExtension + +namespace OAI + +namespace TuringRigidity.InternalDenseInclusion +open TransitiveNameModel BoundedSetTheory CountableForcing +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +noncomputable def embed (a b : ZFSet.{0}) (hab : a ⊆ b) (p : Conditions a) : Conditions b := + equivShrink b ⟨label a p,hab (label_mem a p)⟩ + +theorem label_embed (a b : ZFSet.{0}) (hab : a ⊆ b) (p : Conditions a) : + label b (embed a b hab p) = label a p := by simp [embed,label] + +theorem embed_le_iff (a b : ZFSet.{0}) (hab : a ⊆ b) (p q : Conditions a) : + embed a b hab p ≤ embed a b hab q ↔ p ≤ q := by + change label b (embed a b hab q) ⊆ label b (embed a b hab p) ↔ _ + rw [label_embed,label_embed]; rfl + +noncomputable def inclusionGraph (a b : ZFSet.{0}) : ZFSet.{0} := + (ZFSet.prod a b).sep (fun z => ∃ p ∈ a, z = ZFSet.pair p p) + +theorem pair_inclusionGraph (a b x y : ZFSet.{0}) (hab : a ⊆ b) : + ZFSet.pair x y ∈ inclusionGraph a b ↔ x ∈ a ∧ y = x := by + constructor + · intro h + obtain ⟨_,p,hp,he⟩ := ZFSet.mem_sep.mp h + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hp,rfl⟩ + · rintro ⟨hx,hy⟩ + rw [hy] + exact ZFSet.mem_sep.mpr ⟨ZFSet.pair_mem_prod.mpr ⟨hx,hab hx⟩,x,hx,rfl⟩ + +theorem inclusionGraph_mem (M a b : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) (hb : b ∈ M) : inclusionGraph a b ∈ M := by + let e := fun _ : ℕ => a + simpa only [inclusionGraph,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded (.existsMem 1 (.orderedPair 1 0 0)) e + (fun _ => ha) (product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded ha hb) + +theorem inclusionGraph_function (a b : ZFSet.{0}) (hab : a ⊆ b) : + FunctionGraph a b (inclusionGraph a b) := by + refine ⟨fun z hz => ZFSet.mem_prod.mp (ZFSet.mem_sep.mp hz).1,?_⟩ + intro x hx + exact ⟨x,hab hx,(pair_inclusionGraph a b x x hab).mpr ⟨hx,rfl⟩, + fun y _ hy => (pair_inclusionGraph a b x y hab).mp hy |>.2⟩ + +noncomputable def push (a b : ZFSet.{0}) (hab : a ⊆ b) (G : GenericFilter (Conditions a)) : + GenericFilter (Conditions b) where + carrier := {q | ∃ p ∈ G.carrier, embed a b hab p ≤ q} + nonempty := by obtain ⟨p,hp⟩ := G.nonempty; exact ⟨embed a b hab p,p,hp,le_rfl⟩ + upper := by rintro p q hpq ⟨r,hr,hrp⟩; exact ⟨r,hr,hrp.trans hpq⟩ + directed := by + rintro p q ⟨s,hs,hsp⟩ ⟨t,ht,htq⟩ + obtain ⟨r,hr,hrs,hrt⟩ := G.directed hs ht + exact ⟨embed a b hab r,⟨r,hr,le_rfl⟩, + ((embed_le_iff a b hab r s).mpr hrs).trans hsp, + ((embed_le_iff a b hab r t).mpr hrt).trans htq⟩ + +theorem embed_mem_push (a b : ZFSet.{0}) (hab : a ⊆ b) + (G : GenericFilter (Conditions a)) (p : Conditions a) : + embed a b hab p ∈ (push a b hab G).carrier ↔ p ∈ G.carrier := by + constructor + · rintro ⟨q,hq,hqp⟩; exact G.upper ((embed_le_iff a b hab q p).mp hqp) hq + · intro hp; exact ⟨p,hp,le_rfl⟩ + +noncomputable def densePull (a b D : ZFSet.{0}) : ZFSet.{0} := + a.sep (fun p => ∃ q ∈ b, q ∈ D ∧ q ⊆ p) + +theorem densePull_mem (M a b D : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) (hb : b ∈ M) (hD : D ∈ M) : densePull a b D ∈ M := by + let e := cons b (fun _ => D) + have he : ∀ i, e i ∈ M := by intro i; cases i; exact hb; exact hD + simpa only [densePull,Formula.Eval,Formula.eval_subset,cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.conj (.member 0 3) (.subset 0 1))) e he ha + +theorem push_ground_generic (M a b : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) (hb : b ∈ M) (hab : a ⊆ b) + (hd : ∀ q ∈ b, ∃ p ∈ a, q ⊆ p) + (G : GenericFilter (Conditions a)) (hG : AtomicForcing.GroundGeneric M G) : + AtomicForcing.GroundGeneric M (push a b hab G) := by + intro D hD hden + have hpull : Dense {p : Conditions a | label a p ∈ densePull a b D} := by + intro p + obtain ⟨q,hqp,hqD⟩ := hden (embed a b hab p) + obtain ⟨r,hr,hqr⟩ := hd (label b q) (label_mem b q) + obtain ⟨r,rfl⟩ := label_surjective a hr + have hpr : label a p ⊆ label a r := + fun z hz => hqr (hqp ((label_embed a b hab p).symm ▸ hz)) + exact ⟨r,hpr,ZFSet.mem_sep.mpr ⟨label_mem a r,label b q,label_mem b q,hqD,hqr⟩⟩ + obtain ⟨p,hp,hpD⟩ := hG (densePull a b D) (densePull_mem M a b D hM hT ha hb hD) hpull + obtain ⟨_,q,hqb,hqD,hqp⟩ := ZFSet.mem_sep.mp hpD + obtain ⟨q,rfl⟩ := label_surjective b hqb + exact ⟨q,⟨p,hp,by change label b q ⊆ label b (embed a b hab p); rwa [label_embed]⟩,hqD⟩ + +end TuringRigidity.InternalDenseInclusion + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFiniteEnumeration.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFiniteEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..2921daff5b6d40af7052d4793ee0ab121a2f8ee5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFiniteEnumeration.lean @@ -0,0 +1,113 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalFiniteSubsets + +namespace OAI + +namespace TuringRigidity.InternalFiniteEnumeration +open Set TransitiveNameModel BoundedSetTheory InternalFiniteSubsets RelativeConstructible + +def Ranges (U E g : ZFSet.{0}) : Prop := E ⊆ U ∧ + ∀ p ∈ U, p ∈ E ↔ ∃ i ∈ ZFSet.omega, ZFSet.pair i p ∈ g + +theorem rangeFormula_ranges (ω U E g : ℕ) (e : ℕ → ZFSet.{0}) + (hω : e ω = ZFSet.omega) : + (rangeFormula ω U E g).Eval e ↔ Ranges (e U) (e E) (e g) := by + simp only [rangeFormula,Ranges,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_iff,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,hω] + +noncomputable def candidates (U C E : ZFSet.{0}) : ZFSet.{0} := C.sep (Ranges U E) + +def candidateFormula (ω U C E a : ℕ) : Formula := .conj (.subset a C) + (.allMem C (.iff (.member 0 (a+1)) (rangeFormula (ω+1) (U+1) (E+1) 0))) + +theorem candidateFormula_spec (ω U C E a : ℕ) (e : ℕ → ZFSet.{0}) + (hω : e ω = ZFSet.omega) : + (candidateFormula ω U C E a).Eval e ↔ e a = candidates (e U) (e C) (e E) := by + simp only [candidateFormula,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_iff,Formula.Eval,cons_zero,cons_succ] + have hr (g : ZFSet.{0}) := rangeFormula_ranges (ω+1) (U+1) (E+1) 0 (cons g e) hω + simp only [cons_zero,cons_succ] at hr + simp only [hr] + constructor + · rintro ⟨hsub,h⟩ + apply ZFSet.ext; intro g + exact ⟨fun hg => ZFSet.mem_sep.mpr ⟨hsub hg,(h g (hsub hg)).mp hg⟩, + fun hg => (h g (ZFSet.mem_sep.mp hg).1).mpr (ZFSet.mem_sep.mp hg).2⟩ + · rintro h + rw [h] + exact ⟨fun _ hg => (ZFSet.mem_sep.mp hg).1, + fun g hg => ZFSet.mem_sep.trans (and_iff_right hg)⟩ + +theorem candidates_mem (M U C E : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hU : U ∈ M) (hC : C ∈ M) (hE : E ∈ M) : candidates U C E ∈ M := by + let e := cons ZFSet.omega (cons U (fun _ => E)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i + exact sourceT_omega_mem M hM hT + exact hU; exact hE + have hr (g : ZFSet.{0}) := rangeFormula_ranges 1 2 3 0 (cons g e) rfl + have hs := sep_mem M hM hT.separation.finitePrefix.bounded (rangeFormula 1 2 3 0) e he hC + simpa only [hr,candidates,cons_zero,cons_succ,e] using hs + +theorem internal_enumeration_selector (M U : ZFSet.{0}) (hM : Transitive M) + (hT : SourceT M) (hU : U ∈ M) : + ∃ C ∈ M, (∀ g, g ∈ C ↔ InternalCollapse.Prefix U g) ∧ + ∃ T ∈ M, FunctionGraph (finiteSubsets U) C T ∧ + ∀ E ∈ finiteSubsets U, ∀ g, ZFSet.pair E g ∈ T → Ranges U E g := by + have hω := sourceT_omega_mem M hM hT + obtain ⟨C,hC,hCdef⟩ := InternalCollapse.conditions_exist_absolute_without_choice M hM + hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hω hU + obtain ⟨q,hq,s,hsM,hs,hqdef⟩ := internal_selector M hM hT.powerSet + hT.separation.finitePrefix.bounded hT.choice hC + have hcan (E : ZFSet.{0}) (hE : E ∈ finiteSubsets U) : candidates U C E ∈ q := by + apply (hqdef _).mpr + refine ⟨candidates_mem M U C E hM hT hU hC (finite_subset_mem M U E hM hT hU hE), + fun _ hg => (ZFSet.mem_sep.mp hg).1,?_⟩ + obtain ⟨n,v,hv,rfl⟩ := (mem_finiteSubsets U E).mp hE + refine ⟨tupleGraph v,ZFSet.mem_sep.mpr ⟨(hCdef _).mpr ⟨n,tupleGraph_function U v hv⟩,?_⟩⟩ + exact (rangeFormula_ranges 0 1 2 3 + (cons ZFSet.omega (cons U (cons (ZFSet.range v) (fun _ => tupleGraph v)))) rfl).mp + ((rangeFormula_spec 0 1 2 3 _ rfl hv rfl).mpr rfl) + let S := finiteSubsets U + let e := cons ZFSet.omega (cons U (cons C (cons S (cons q (fun _ => s))))) + let φ : Formula := .existsMem 4 (.existsMem 4 (.conj (.orderedPair 2 1 0) + (.existsMem 7 (.conj (candidateFormula 4 5 6 2 0) (.pairMem 0 1 9))))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|_|i + exact hω; exact hU; exact hC; exact finiteSubsets_mem M U hM hT hU + exact hq; exact hsM + let T := (ZFSet.prod S C).sep (fun z => φ.Eval (cons z e)) + have hTM : T ∈ M := sep_mem M hM hT.separation.finitePrefix.bounded φ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + (finiteSubsets_mem M U hM hT hU) hC) + have hmem (z : ZFSet.{0}) : z ∈ T ↔ ∃ E ∈ S, ∃ g ∈ C, + z = ZFSet.pair E g ∧ ZFSet.pair (candidates U C E) g ∈ s := by + simp only [T,ZFSet.mem_sep,φ,Formula.Eval,Formula.eval_orderedPair, + Formula.eval_pairMem,cons_zero,cons_succ,e] + constructor + · rintro ⟨_,E,hE,g,hg,hz,a,_,ha,hag⟩ + have ha' := (candidateFormula_spec 4 5 6 2 0 _ rfl).mp ha + change a = candidates U C E at ha' + exact ⟨E,hE,g,hg,hz,ha' ▸ hag⟩ + · rintro ⟨E,hE,g,hg,rfl,hag⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨E,hE,g,hg,rfl⟩,E,hE,g,hg,rfl, + candidates U C E,hcan E hE,(candidateFormula_spec 4 5 6 2 0 _ rfl).mpr rfl,hag⟩ + refine ⟨C,hC,hCdef,T,hTM,⟨?_,?_⟩,?_⟩ + · intro z hz + obtain ⟨E,hE,g,hg,hz,_⟩ := (hmem z).mp hz + exact ⟨E,hE,g,hg,hz⟩ + · intro E hE + obtain ⟨g,hg,hag,_⟩ := hs.2 _ (hcan E hE) + have hgC := (ZFSet.mem_sep.mp hg).1 + refine ⟨g,hgC,(hmem _).mpr ⟨E,hE,g,hgC,rfl,hag⟩,?_⟩ + intro g' _ hEg' + obtain ⟨E',_,g'',_,hp,hag'⟩ := (hmem _).mp hEg' + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact hs.functional hag' hag + · intro E _ g hEg + obtain ⟨E',_,g',_,hp,hag⟩ := (hmem _).mp hEg + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact (ZFSet.mem_sep.mp (InternalWellOrder.choice_value_mem hs hag)).2 + +end TuringRigidity.InternalFiniteEnumeration + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFiniteExhaustion.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFiniteExhaustion.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fd08612a698653eba390fec9b610be9319a1e7a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFiniteExhaustion.lean @@ -0,0 +1,116 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalSubsetSequence +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableClosure +import Mathlib.Data.Set.Finite.Powerset + +namespace OAI + +namespace TuringRigidity.InternalFiniteExhaustion +open TransitiveNameModel BoundedSetTheory InternalFiniteSubsets + +noncomputable def initial (f : ℕ → ZFSet.{0}) (n : ℕ) : ZFSet.{0} := + ZFSet.range (fun i : Fin n => f i.val) + +theorem mem_initial (f : ℕ → ZFSet.{0}) (n : ℕ) (x : ZFSet.{0}) : + x ∈ initial f n ↔ ∃ k < n, x = f k := by + rw [initial,ZFSet.mem_range] + exact ⟨fun ⟨i,hi⟩ => ⟨i.val,i.isLt,hi.symm⟩,fun ⟨k,hk,hx⟩ => ⟨⟨k,hk⟩,hx.symm⟩⟩ + +theorem initial_finite (f : ℕ → ZFSet.{0}) (n : ℕ) : + (initial f n : Set ZFSet.{0}).Finite := by + rw [initial,ZFSet.coe_range] + exact Set.finite_range _ + +theorem initial_subset (A : ZFSet.{0}) (f : ℕ → ZFSet.{0}) + (hf : ∀ n, f n ∈ A) (n : ℕ) : initial f n ⊆ A := by + intro x hx + obtain ⟨k,_,rfl⟩ := (mem_initial f n x).mp hx + exact hf k + +def initialFormula (g n x : ℕ) : Formula := .existsMem n (.pairMem 0 (x+1) (g+1)) + +theorem initialFormula_spec (g n x : ℕ) (e : ℕ → ZFSet.{0}) + (f : ℕ → ZFSet.{0}) (N : ℕ) (hg : e g = orbitGraph f) (hn : e n = natSet N) : + (initialFormula g n x).Eval e ↔ e x ∈ initial f N := by + simp only [initialFormula,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,hg,hn] + rw [mem_initial] + constructor + · rintro ⟨k,hk,hkx⟩ + obtain ⟨k,hklt,rfl⟩ := (mem_natSet N k).mp hk + exact ⟨k,hklt,(orbitGraph_pair f k _).mp hkx⟩ + · rintro ⟨k,hk,hkx⟩ + exact ⟨natSet k,(natSet_mem_natSet k N).mpr hk,(orbitGraph_pair f k _).mpr hkx⟩ + +theorem initial_sequence_mem (M A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (f : ℕ → ZFSet.{0}) (hf : ∀ n, f n ∈ A) (hg : orbitGraph f ∈ M) : + orbitGraph (initial f) ∈ M := by + exact InternalSubsetSequence.subset_sequence M A hM hT hA (initialFormula 2 1 0) + (fun _ => orbitGraph f) (fun _ => hg) (initial f) (initial_subset A f hf) + (fun n _ _ => initialFormula_spec 2 1 0 _ f n rfl rfl) + +theorem finite_subsets_finite (A : ZFSet.{0}) (hA : (A : Set ZFSet.{0}).Finite) : + (finiteSubsets A : Set ZFSet.{0}).Finite := by + apply Set.Finite.of_injOn (f := fun x : ZFSet.{0} => (x : Set ZFSet.{0})) + (t := Set.powerset (A : Set ZFSet.{0})) + · intro x hx + exact (mem_finiteSubsets_iff A x).mp hx |>.1 + · intro x _ y _ hxy + exact ZFSet.ext (fun z => Set.ext_iff.mp hxy z) + · exact hA.powerset + +theorem finite_subset_initial (A : ZFSet.{0}) (f : ℕ → ZFSet.{0}) + (honto : ∀ x ∈ A, ∃ n, x = f n) (a : ZFSet.{0}) (ha : a ∈ finiteSubsets A) : + ∃ n, a ⊆ initial f n := by + classical + obtain ⟨k,v,hv,rfl⟩ := (mem_finiteSubsets A a).mp ha + choose idx hidx using fun i => honto (v i) (hv i) + refine ⟨Finset.univ.sup idx + 1,?_⟩ + intro x hx + obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hx + apply (mem_initial f _ _).mpr + exact ⟨idx i,Nat.lt_succ_of_le (Finset.le_sup (f := idx) (Finset.mem_univ i)),hidx i⟩ + +theorem finite_subsets_countable (M A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hct : InternallyCountable M A) : + InternallyCountable M (finiteSubsets A) := by + obtain ⟨g,hg,hfun,honto⟩ := hct + obtain ⟨f,hf,hfg⟩ := InternalCountableFamily.sequence_of_graph A g hfun + have hgf : orbitGraph f ∈ M := hfg.symm ▸ hg + have onto : ∀ x ∈ A, ∃ n, x = f n := by + intro x hx + obtain ⟨n,hn,hnx⟩ := honto x hx + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + exact ⟨n,(orbitGraph_pair f n x).mp (hfg.symm ▸ hnx)⟩ + let U := finiteSubsets A + let E := fun n => finiteSubsets (initial f n) + have hsub (n : ℕ) : E n ⊆ U := by + intro a ha + obtain ⟨hs,hfin⟩ := (mem_finiteSubsets_iff _ a).mp ha + exact (mem_finiteSubsets_iff A a).mpr ⟨fun x hx => initial_subset A f hf n (hs hx),hfin⟩ + have hEM : orbitGraph E ∈ M := by + apply InternalSubsetSequence.subset_sequence M U hM hT (finiteSubsets_mem M A hM hT hA) + (.allMem 0 (initialFormula 3 2 0)) (fun _ => orbitGraph f) (fun _ => hgf) E hsub + intro n a ha + rw [Formula.eval_allMem] + change (∀ x ∈ a, (initialFormula 3 2 0).Eval + (cons x (cons a (cons (natSet n) (fun _ => orbitGraph f)))) ) ↔ _ + have heval (x : ZFSet.{0}) := initialFormula_spec 3 2 0 + (cons x (cons a (cons (natSet n) (fun _ => orbitGraph f)))) f n rfl rfl + constructor + · intro hs + exact (mem_finiteSubsets_iff _ a).mpr + ⟨fun x hx => (heval x).mp (hs x hx),((mem_finiteSubsets_iff A a).mp ha).2⟩ + · intro h x hx + exact (heval x).mpr (((mem_finiteSubsets_iff _ a).mp h).1 hx) + apply InternalCountableFiniteUnion.internally_countable_union M U hM hT + (finiteSubsets_mem M A hM hT hA) E + (fun n => (mem_finiteSubsets_iff U (E n)).mpr + ⟨hsub n,finite_subsets_finite _ (initial_finite f n)⟩) hEM + · intro a ha + obtain ⟨n,hn⟩ := finite_subset_initial A f onto a ha + exact ⟨n,(mem_finiteSubsets_iff _ a).mpr ⟨hn,((mem_finiteSubsets_iff A a).mp ha).2⟩⟩ + · exact ⟨∅,(mem_finiteSubsets_iff A ∅).mpr + ⟨ZFSet.empty_subset A,by simpa only [ZFSet.coe_empty] using Set.finite_empty⟩⟩ + +end TuringRigidity.InternalFiniteExhaustion + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFiniteSubsets.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFiniteSubsets.lean new file mode 100644 index 0000000000000000000000000000000000000000..b35fa0b55a79a7e84099b996d921bd12e9cf588a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFiniteSubsets.lean @@ -0,0 +1,115 @@ +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleTupleSpace +import OAI.Computability.DegreeRigidity.SetModels.CollapsePrefixAbsolute + +namespace OAI + +namespace TuringRigidity.InternalFiniteSubsets +open Set TransitiveNameModel BoundedSetTheory InternalCollapse RelativeConstructible +universe u + +noncomputable def finiteSubsets (A : ZFSet.{u}) : ZFSet.{u} := + ZFSet.range (fun t : Σ n : ℕ, Fin n → Conditions A => + ZFSet.range (fun i => label A (t.2 i))) + +theorem mem_finiteSubsets (A x : ZFSet.{u}) : + x ∈ finiteSubsets A ↔ ∃ (n : ℕ) (v : Fin n → ZFSet.{u}), + (∀ i, v i ∈ A) ∧ x = ZFSet.range v := by + rw [finiteSubsets,ZFSet.mem_range] + constructor + · rintro ⟨⟨n,v⟩,hx⟩ + exact ⟨n,fun i => label A (v i),fun i => label_mem A (v i),hx.symm⟩ + · rintro ⟨n,v,hv,rfl⟩ + refine ⟨⟨n,fun i => equivShrink A ⟨v i,hv i⟩⟩,?_⟩ + congr 1; funext i; simp [label] + +theorem mem_finiteSubsets_iff (A x : ZFSet.{u}) : + x ∈ finiteSubsets A ↔ x ⊆ A ∧ (x : Set ZFSet.{u}).Finite := by + rw [mem_finiteSubsets] + constructor + · rintro ⟨n,v,hv,rfl⟩ + exact ⟨fun z hz => by obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hz; exact hv i, + by rw [ZFSet.coe_range]; exact Set.finite_range v⟩ + · rintro ⟨hx,hfin⟩ + let : Fintype x := hfin.fintype + let v : Fin (Fintype.card x) → ZFSet.{u} := fun i => ((Fintype.equivFin x).symm i).val + refine ⟨_,v,fun i => hx ((Fintype.equivFin x).symm i).property,?_⟩ + apply ZFSet.ext; intro z + rw [ZFSet.mem_range] + exact ⟨fun hz => ⟨(Fintype.equivFin x) ⟨z,hz⟩,by simp [v]⟩, + fun ⟨i,hi⟩ => hi ▸ ((Fintype.equivFin x).symm i).property⟩ + +theorem finite_subset_mem (M A x : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) (hx : x ∈ finiteSubsets A) : x ∈ M := by + obtain ⟨n,v,hv,rfl⟩ := (mem_finiteSubsets A x).mp hx + exact finite_range_mem M hM hT.pairing hT.union + (hM _ (sourceT_omega_mem M hM hT) _ ZFSet.omega_zero) n v + (fun i => hM A hA _ (hv i)) + +def rangeFormula (o A x g : ℕ) : Formula := + .conj (.subset x A) (.allMem A + (.iff (.member 0 (x+1)) (.existsMem (o+1) (.pairMem 0 1 (g+2))))) + +theorem rangeFormula_spec (o A x g : ℕ) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) {n : ℕ} {v : Fin n → ZFSet.{u}} + (hv : ∀ i, v i ∈ e A) (hg : e g = tupleGraph v) : + (rangeFormula o A x g).Eval e ↔ e x = ZFSet.range v := by + simp only [rangeFormula,Formula.Eval,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_iff,Formula.eval_pairMem,cons_zero,cons_succ] + rw [ho,hg] + have hr (z : ZFSet.{u}) : (∃ i ∈ ZFSet.omega, ZFSet.pair i z ∈ tupleGraph v) ↔ + z ∈ ZFSet.range v := by + constructor + · rintro ⟨i,_,hi⟩ + obtain ⟨j,hj⟩ := ZFSet.mem_range.mp hi + exact ZFSet.mem_range.mpr ⟨j,(ZFSet.pair_inj.mp hj).2⟩ + · rintro hz + obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hz + exact ⟨natSet i.val,(mem_omega _).mpr ⟨i.val,rfl⟩,(tupleGraph_pair v i _).mpr rfl⟩ + constructor + · rintro ⟨hsub,h⟩ + apply ZFSet.ext; intro z + constructor + · intro hz; exact (hr z).mp ((h z (hsub hz)).mp hz) + · intro hz + have hzA : z ∈ e A := by obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hz; exact hv i + exact (h z hzA).mpr ((hr z).mpr hz) + · intro he + refine ⟨fun z hz => ?_,fun z _ => ?_⟩ + · rw [he] at hz; obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hz; exact hv i + · rw [he]; exact (hr z).symm + +theorem finiteSubsets_mem (M A : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) : finiteSubsets A ∈ M := by + obtain ⟨C,hC,hCdef⟩ := conditions_exist_absolute_without_choice M hM hT.pairing + hT.union hT.powerSet hT.separation.finitePrefix.bounded (sourceT_omega_mem M hM hT) hA + obtain ⟨Q,hQ,hQdef⟩ := internal_power M hM hT.powerSet hA + let e := cons ZFSet.omega (cons A (fun _ => C)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i + exact sourceT_omega_mem M hM hT + exact hA + exact hC + let φ : Formula := .existsMem 3 (rangeFormula 2 3 1 0) + have hφ (x : ZFSet.{u}) : φ.Eval (cons x e) ↔ x ∈ finiteSubsets A := by + change (∃ g ∈ C, (rangeFormula 2 3 1 0).Eval (cons g (cons x e))) ↔ _ + constructor + · rintro ⟨g,hg,h⟩ + obtain ⟨n,hn⟩ := (hCdef g).mp hg + obtain ⟨v,hv,rfl⟩ := functionGraph_tuple A g n hn + exact (mem_finiteSubsets A x).mpr ⟨n,v,hv, + (rangeFormula_spec 2 3 1 0 _ rfl hv rfl).mp h⟩ + · intro hx + obtain ⟨n,v,hv,rfl⟩ := (mem_finiteSubsets A x).mp hx + exact ⟨tupleGraph v,(hCdef _).mpr ⟨n,tupleGraph_function A v hv⟩, + (rangeFormula_spec 2 3 1 0 _ rfl hv rfl).mpr rfl⟩ + have hs := sep_mem M hM hT.separation.finitePrefix.bounded φ e he hQ + have heq : Q.sep (fun x => φ.Eval (cons x e)) = finiteSubsets A := by + apply ZFSet.ext; intro x + rw [ZFSet.mem_sep,hφ,hQdef] + exact ⟨fun h => h.2,fun hx => ⟨⟨finite_subset_mem M A x hM hT hA hx, + ((mem_finiteSubsets_iff A x).mp hx).1⟩,hx⟩⟩ + exact heq ▸ hs + +end TuringRigidity.InternalFiniteSubsets + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFixedPoint.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFixedPoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbbf84b9d579d4e75436f614b1ca09e388f44ce4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFixedPoint.lean @@ -0,0 +1,51 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedRelations + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +theorem internal_fixed_point (M : ZFSet.{u}) (hM : Transitive M) + (hU : Union M) (hPow : PowerSet M) (hS : Separation M) + (φ : Formula) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (a : ZFSet.{u}) (ha : a ∈ M) + (mono : ∀ f g : ZFSet.{u}, f ⊆ a → g ⊆ a → f ⊆ g → + ∀ z ∈ a, φ.Eval (cons z (cons f e)) → φ.Eval (cons z (cons g e))) : + ∃ g ∈ M, g ⊆ a ∧ ∀ z ∈ a, + z ∈ g ↔ φ.Eval (cons z (cons g e)) := by + obtain ⟨b,hb,hbdef⟩ := internal_power M hM hPow ha + let post := Formula.allMem 0 φ + let s := ZFSet.sep (fun f => post.Eval (cons f e)) b + have hs : s ∈ M := sep_mem M hM hS post e he hb + have hsdef (f : ZFSet.{u}) : f ∈ s ↔ + f ∈ M ∧ f ⊆ a ∧ ∀ z ∈ f, φ.Eval (cons z (cons f e)) := by + simp only [s,ZFSet.mem_sep,hbdef,post,Formula.eval_allMem,cons_zero] + exact and_assoc + let g := ZFSet.sUnion s + have hg : g ∈ M := union_mem M hM hU hs + have hga : g ⊆ a := by + intro z hz + obtain ⟨f,hf,hzf⟩ := ZFSet.mem_sUnion.mp hz + exact ((hsdef f).mp hf).2.1 hzf + have hgpost : ∀ z ∈ g, φ.Eval (cons z (cons g e)) := by + intro z hz + obtain ⟨f,hf,hzf⟩ := ZFSet.mem_sUnion.mp hz + have hf' := (hsdef f).mp hf + apply mono f g hf'.2.1 hga (fun w hw => ZFSet.mem_sUnion.mpr ⟨f,hf,hw⟩) z (hga hz) + exact hf'.2.2 z hzf + let v := ZFSet.sep (fun z => φ.Eval (cons z (cons g e))) a + have hv : v ∈ M := sep_mem M hM hS φ (cons g e) + (fun i => by cases i <;> simp [hg,he]) ha + have hva : v ⊆ a := fun z hz => (ZFSet.mem_sep.mp hz).1 + have hgv : g ⊆ v := fun z hz => ZFSet.mem_sep.mpr ⟨hga hz,hgpost z hz⟩ + have hvpost : ∀ z ∈ v, φ.Eval (cons z (cons v e)) := by + intro z hz + exact mono g v hga hva hgv z (hva hz) (ZFSet.mem_sep.mp hz).2 + have hvs : v ∈ s := (hsdef v).mpr ⟨hv,hva,hvpost⟩ + refine ⟨g,hg,hga,fun z hz => ⟨hgpost z,fun h => ?_⟩⟩ + exact ZFSet.mem_sUnion.mpr ⟨v,hvs,ZFSet.mem_sep.mpr ⟨hz,h⟩⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFunctionOrbit.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFunctionOrbit.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5c6c726f38a912c4084092497a38a18b1c97451 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalFunctionOrbit.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelIterationFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +noncomputable def orbitGraph (a : ℕ → ZFSet.{u}) : ZFSet.{u} := + ZFSet.range (fun n => ZFSet.pair (natSet n) (a n)) + +theorem mem_orbitGraph (a : ℕ → ZFSet.{u}) (z : ZFSet.{u}) : + z ∈ orbitGraph a ↔ ∃ n, z = ZFSet.pair (natSet n) (a n) := by + rw [orbitGraph,ZFSet.mem_range] + exact ⟨fun ⟨n,hn⟩ => ⟨n,hn.symm⟩,fun ⟨n,hn⟩ => ⟨n,hn.symm⟩⟩ + +theorem orbitGraph_pair (a : ℕ → ZFSet.{u}) (n : ℕ) (x : ZFSet.{u}) : + ZFSet.pair (natSet n) x ∈ orbitGraph a ↔ x = a n := by + rw [mem_orbitGraph] + constructor + · rintro ⟨m,he⟩ + obtain ⟨hn,hx⟩ := ZFSet.pair_inj.mp he + have hnm := natSet_injective hn + exact hnm.symm ▸ hx + · intro h; exact ⟨n,congrArg (ZFSet.pair (natSet n)) h⟩ + +theorem orbitGraph_function (d : ZFSet.{u}) (a : ℕ → ZFSet.{u}) (ha : ∀ n, a n ∈ d) : + TransitiveNameModel.FunctionGraph ZFSet.omega d (orbitGraph a) := by + constructor + · intro z hz + obtain ⟨n,rfl⟩ := (mem_orbitGraph a z).mp hz + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,a n,ha n,rfl⟩ + · intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + exact ⟨a n,ha n,(orbitGraph_pair a n _).mpr rfl,fun y _ hy => (orbitGraph_pair a n y).mp hy⟩ + +namespace Formula + +def orbitMember (o d Q b F z : ℕ) : Formula := .existsMem o (.existsMem (d+1) + (.conj (.orderedPair (z+2) 1 0) + (modelIteration (o+2) (d+2) (Q+2) 1 (b+2) 0 (.pairMem 1 0 (F+5))))) + +theorem orbitMember_spec (o d Q b F z : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ a : ℕ → ZFSet.{u}, (∀ i, a i ∈ e d) → ∀ k, finiteModelGraph a k ∈ e Q) + (hF : TransitiveNameModel.FunctionGraph (e d) (e d) (e F)) + (a : ℕ → ZFSet.{u}) (ha : ∀ i, a i ∈ e d) (hb : e b = a 0) + (hstep : ∀ i, ZFSet.pair (a i) (a (i+1)) ∈ e F) : + (orbitMember o d Q b F z).Eval e ↔ e z ∈ orbitGraph a := by + simp only [orbitMember,Formula.Eval,eval_orderedPair,cons_zero,cons_succ] + rw [ho,mem_orbitGraph] + have hs (n : ℕ) (w : ZFSet.{u}) : + (modelIteration (o+2) (d+2) (Q+2) 1 (b+2) 0 (.pairMem 1 0 (F+5))).Eval + (cons w (cons (natSet n) e)) ↔ w = a n := by + apply modelIteration_spec (o+2) (d+2) (Q+2) 1 (b+2) 0 (.pairMem 1 0 (F+5)) + (cons w (cons (natSet n) e)) ho hQ n rfl a ha hb + intro i v _ + simp only [eval_pairMem,cons_zero,cons_succ] + exact ⟨fun hv => hF.functional (ha i) hv (hstep i),fun hv => hv.symm ▸ hstep i⟩ + constructor + · rintro ⟨n,hn,w,_,hz,hw⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + rw [(hs n w).mp hw] at hz + exact ⟨n,hz⟩ + · rintro ⟨n,hz⟩ + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,a n,ha n,hz,(hs n _).mpr rfl⟩ +end Formula + +theorem internal_orbitGraph (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {d F : ZFSet.{u}} (hd : d ∈ M) (hFM : F ∈ M) + (hF : TransitiveNameModel.FunctionGraph d d F) (a : ℕ → ZFSet.{u}) + (ha : ∀ i, a i ∈ d) (hstep : ∀ i, ZFSet.pair (a i) (a (i+1)) ∈ F) : orbitGraph a ∈ M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_model_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω d hd + let e := cons ZFSet.omega (cons d (cons Q (cons (a 0) (fun _ => F)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hd + rcases i with _|i; exact hQM + rcases i with _|i; exact hM _ hd _ (ha 0) + exact hFM + have hs := sep_mem M hM hS (Formula.orbitMember 1 2 3 4 5 0) e he + (product_mem M hM hT.pairing hT.union hT.powerSet hS hω hd) + have hEq : ZFSet.sep (fun z => (Formula.orbitMember 1 2 3 4 5 0).Eval (cons z e)) + (ZFSet.prod ZFSet.omega d) = orbitGraph a := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,Formula.orbitMember_spec 1 2 3 4 5 0 (cons z e) rfl hQ hF a ha rfl hstep] + exact ⟨And.right,fun h => ⟨ZFSet.mem_prod.mpr ((orbitGraph_function d a ha).1 z h),h⟩⟩ + exact hEq ▸ hs + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalGeneratedAlgebra.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalGeneratedAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..bda1eda05e036533bd520a781d3c966a0dae9a99 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalGeneratedAlgebra.lean @@ -0,0 +1,72 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanSyntax + +namespace OAI + +namespace TuringRigidity.InternalGeneratedAlgebra +open TransitiveNameModel BoundedSetTheory InternalRegularOperations InternalRegularAlgebra +open InternalBooleanSyntax + +noncomputable def generated (c B Q S : ZFSet.{0}) : ZFSet.{0} := + B.sep (fun U => ∀ A ∈ candidates c B Q S, U ∈ A) + +theorem generated_mem (M c B Q S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : B ∈ M) (hQ : Q ∈ M) (hS : S ∈ M) : + generated c B Q S ∈ M := by + have hk := candidates_mem M c B Q S hM hT hc hB hQ hS + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (.allMem 1 (.member 1 0)) (fun _ => candidates c B Q S) (fun _ => hk) hB + simpa only [generated,Formula.eval_allMem,Formula.Eval,cons_zero,cons_succ] using hs + +theorem generated_subset (c B Q S : ZFSet.{0}) : generated c B Q S ⊆ B := + fun _ h => (ZFSet.mem_sep.mp h).1 + +theorem seeds_subset (c B Q S : ZFSet.{0}) (hS : S ⊆ B) : S ⊆ generated c B Q S := by + intro U hU + refine ZFSet.mem_sep.mpr ⟨hS hU,fun A hA => ?_⟩ + exact (ZFSet.mem_sep.mp hA).2.1 hU + +theorem generated_le (c B Q S A : ZFSet.{0}) (hA : A ∈ Q) + (hS : S ⊆ A) (hc : Closed c B Q A) : generated c B Q S ⊆ A := by + intro U hU + exact (ZFSet.mem_sep.mp hU).2 A (ZFSet.mem_sep.mpr ⟨hA,hS,hc⟩) + +theorem algebra_closed (M c B Q : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) : Closed c B Q B := by + refine ⟨fun _ h => h,fun U hU => internal_complement M c B hM hT hc hB hU,?_⟩ + intro F hF _ + exact internal_join M c B F hM hT hc hB ((hQ F).mp hF).1 + +theorem generated_closed (c B Q S : ZFSet.{0}) (hB : Closed c B Q B) : + Closed c B Q (generated c B Q S) := by + refine ⟨generated_subset c B Q S,?_,?_⟩ + · intro U hU + obtain ⟨hUB,hU⟩ := ZFSet.mem_sep.mp hU + refine ZFSet.mem_sep.mpr ⟨hB.2.1 U hUB,fun A hA => ?_⟩ + exact (ZFSet.mem_sep.mp hA).2.2.2.1 U (hU A hA) + · intro F hF hFS + refine ZFSet.mem_sep.mpr ⟨hB.2.2 F hF (fun U hU => generated_subset c B Q S (hFS hU)),?_⟩ + intro A hA + apply (ZFSet.mem_sep.mp hA).2.2.2.2 F hF + intro U hU + exact (ZFSet.mem_sep.mp (hFS hU)).2 A hA + +theorem internal_generated_part (M c S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hS : S ∈ M) (hSc : ∀ U ∈ S, IsCode c U) : + ∃ B ∈ M, ∃ Q ∈ M, ∃ A ∈ M, + (∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) ∧ + (∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) ∧ + A = generated c B Q S ∧ S ⊆ A ∧ A ∈ Q ∧ Closed c B Q A ∧ + ∀ A' ∈ Q, S ⊆ A' → Closed c B Q A' → A ⊆ A' := by + obtain ⟨B,hBM,hB⟩ := internal_algebra M c hM hT hc + obtain ⟨Q,hQM,hQ⟩ := internal_power M hM hT.powerSet hBM + have hSB : S ⊆ B := fun U hU => (hB U).mpr ⟨hM S hS U hU,hSc U hU⟩ + have hA := generated_mem M c B Q S hM hT hc hBM hQM hS + refine ⟨B,hBM,Q,hQM,generated c B Q S,hA,hB,hQ,rfl,seeds_subset c B Q S hSB, + (hQ _).mpr ⟨hA,generated_subset c B Q S⟩, + generated_closed c B Q S (algebra_closed M c B Q hM hT hc hB hQ),?_⟩ + exact fun A' hA' hSA' hclosed => generated_le c B Q S A' hA' hSA' hclosed + +end TuringRigidity.InternalGeneratedAlgebra + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalGenericFilter.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalGenericFilter.lean new file mode 100644 index 0000000000000000000000000000000000000000..932bb0cebe21b0151786d2fdae3d8b15527101d7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalGenericFilter.lean @@ -0,0 +1,107 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalGenericSequence +import OAI.Computability.DegreeRigidity.SetModels.InternalAtomicTruth + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalGeneric +open TransitiveNameModel CountableForcing +universe u + +namespace Code +open Formula + +def reaches (ω c s g o p : ℕ) : Formula := + .existsMem ω (.existsMem (s+1) (.conj (.pairMem 1 0 (g+2)) + (.existsMem (ω+2) (.existsMem (c+3) (.conj (.orderedPair 2 1 0) (.pairMem 0 (p+4) (o+4))))))) +end Code + +theorem sequence_filter_set (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o : ZFSet.{u}} (hc : c ∈ M) (ho : o ∈ M) + (a : ℕ → ZFSet.{u}) (ha : ∀ n, a n ∈ c) + (hg : orbitGraph (fun n => ZFSet.pair (natSet n) (a n)) ∈ M) : + ZFSet.sep (fun p => ∃ n, ZFSet.pair (a n) p ∈ o) c ∈ M := by + have hω := sourceT_omega_mem M hM hT + let s := ZFSet.prod ZFSet.omega c + have hs := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hω hc + let g := orbitGraph (fun n => ZFSet.pair (natSet n) (a n)) + let e := cons ZFSet.omega (cons c (cons s (cons g (fun _ => o)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hc + rcases i with _|i; exact hs + rcases i with _|i; exact hg + exact ho + have eq (p : ZFSet.{u}) : (Code.reaches 1 2 3 4 5 0).Eval (cons p e) ↔ + ∃ n, ZFSet.pair (a n) p ∈ o := by + simp only [Code.reaches,Formula.Eval,Formula.eval_pairMem,Formula.eval_orderedPair, + cons_zero,cons_succ,e] + constructor + · rintro ⟨n,hn,st,_,hst,k,_,q,_,hpair,hqp⟩ + obtain ⟨i,rfl⟩ := (mem_omega n).mp hn + have heq := (orbitGraph_pair _ i st).mp hst + obtain ⟨_,hqa⟩ := ZFSet.pair_inj.mp (hpair.symm.trans heq) + exact ⟨i,hqa ▸ hqp⟩ + · rintro ⟨n,hn⟩ + have hnω : natSet.{u} n ∈ ZFSet.omega := (mem_omega _).mpr ⟨n,rfl⟩ + exact ⟨natSet n,hnω,ZFSet.pair (natSet n) (a n),ZFSet.mem_prod.mpr ⟨_,hnω,_,ha n,rfl⟩, + (orbitGraph_pair _ n _).mpr rfl,natSet n,hnω,a n,ha n,rfl,hn⟩ + have hset := sep_mem M hM hT.separation.finitePrefix.bounded (Code.reaches 1 2 3 4 5 0) e he hc + have heq : ZFSet.sep (fun p => (Code.reaches 1 2 3 4 5 0).Eval (cons p e)) c = + ZFSet.sep (fun p => ∃ n, ZFSet.pair (a n) p ∈ o) c := by + apply ZFSet.ext; intro p + simp only [ZFSet.mem_sep,eq] + exact heq ▸ hset + +theorem internal_generic_filter (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c o D : ZFSet.{u}} [Preorder (Conditions c)] (hc : c ∈ M) (hoM : o ∈ M) (hD : D ∈ M) + (ho : ∀ p q : Conditions c, ZFSet.pair (label c p) (label c q) ∈ o ↔ p ≤ q) + (hcount : InternallyCountable M D) + (hdense : ∀ t ∈ D, Dense {p : Conditions c | label c p ∈ t}) (p₀ : Conditions c) : + ∃ G : GenericFilter (Conditions c), p₀ ∈ G.carrier ∧ genericFilterSet c G.carrier ∈ M ∧ + ∀ t ∈ D, ∃ p ∈ G.carrier, label c p ∈ t := by + classical + obtain ⟨E,hEM,hEF,honto⟩ := hcount + have hdense' : ∀ t ∈ D, ∀ p ∈ c, ∃ q ∈ c, q ∈ t ∧ ZFSet.pair q p ∈ o := by + intro t ht p hp + obtain ⟨i,rfl⟩ := label_surjective c hp + obtain ⟨j,hji,hjt⟩ := hdense t ht i + exact ⟨_,label_mem c j,hjt,(ho j i).mpr hji⟩ + obtain ⟨a,ha,ha0,hgraph,hstep⟩ := internal_dense_sequence M hM hT hc hEM hD hoM hEF hdense' (label_mem c p₀) + choose q hq using fun n => label_surjective c (ha n) + have hq0 : q 0 = p₀ := label_injective c ((hq 0).trans ha0) + have hanti : Antitone q := by + apply antitone_nat_of_succ_le + intro n + obtain ⟨t,_,_,_,hs⟩ := hstep n + exact (ho _ _).mp (by simpa only [hq] using hs) + let G : GenericFilter (Conditions c) := { + carrier := {p | ∃ n, q n ≤ p} + nonempty := ⟨q 0,0,le_rfl⟩ + upper := fun hpq ⟨n,hn⟩ => ⟨n,hn.trans hpq⟩ + directed := by + rintro p r ⟨n,hn⟩ ⟨m,hm⟩ + exact ⟨q (max n m),⟨max n m,le_rfl⟩, + (hanti (Nat.le_max_left n m)).trans hn,(hanti (Nat.le_max_right n m)).trans hm⟩ } + have hset := sequence_filter_set M hM hT hc hoM a ha hgraph + have heq : genericFilterSet c G.carrier = ZFSet.sep (fun p => ∃ n, ZFSet.pair (a n) p ∈ o) c := by + apply ZFSet.ext; intro x + rw [mem_genericFilterSet,ZFSet.mem_sep] + constructor + · rintro ⟨p,⟨n,hn⟩,rfl⟩ + exact ⟨label_mem c p,n,by simpa only [hq] using (ho (q n) p).mpr hn⟩ + · rintro ⟨hx,n,hn⟩ + obtain ⟨p,rfl⟩ := label_surjective c hx + exact ⟨p,⟨n,(ho (q n) p).mp (by simpa only [hq] using hn)⟩,rfl⟩ + refine ⟨G,⟨0,by rw [hq0]⟩,heq.symm ▸ hset,?_⟩ + intro t ht + obtain ⟨n,hn,hnt⟩ := honto t ht + obtain ⟨i,rfl⟩ := (mem_omega n).mp hn + obtain ⟨s,hs,hns,has,_⟩ := hstep i + have he : t = s := hEF.functional ((mem_omega _).mpr ⟨i,rfl⟩) hnt hns + exact ⟨q (i+1),⟨i+1,le_rfl⟩,by simpa only [hq,he] using has⟩ + +end TuringRigidity.BoundedSetTheory.InternalGeneric + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalGenericSequence.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalGenericSequence.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8533a8da0d4d6d0e5eb0821221a7456ea29e274 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalGenericSequence.lean @@ -0,0 +1,121 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTDependentChoice +import OAI.Computability.DegreeRigidity.SetModels.CountableSetReal + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalGeneric +open TransitiveNameModel +universe u + +namespace Code +open Formula + +def step (ω c E D o s z : ℕ) : Formula := + .existsMem ω (.existsMem (c+1) (.existsMem (ω+2) (.existsMem (c+3) + (.existsMem (D+4) (.existsMem (s+5) (.existsMem (s+6) + (.conj (.orderedPair (z+7) 0 1) + (.conj (.orderedPair 1 6 5) (.conj (.orderedPair 0 4 3) + (.conj (.successor 4 6) (.conj (.pairMem 6 2 (E+7)) + (.conj (.member 3 2) (.pairMem 3 5 (o+7)))))))))))))) + +theorem eval_step (ω c E D o s z : ℕ) (e : ℕ → ZFSet.{u}) + (hs : e s = ZFSet.prod (e ω) (e c)) : + (step ω c E D o s z).Eval e ↔ + ∃ n ∈ e ω, ∃ p ∈ e c, ∃ m ∈ e ω, ∃ q ∈ e c, ∃ t ∈ e D, + e z = ZFSet.pair (ZFSet.pair m q) (ZFSet.pair n p) ∧ + m = insert n n ∧ ZFSet.pair n t ∈ e E ∧ q ∈ t ∧ ZFSet.pair q p ∈ e o := by + simp only [step,Formula.Eval,eval_orderedPair,eval_successor,eval_pairMem,cons_zero,cons_succ] + constructor + · rintro ⟨n,hn,p,hp,m,hm,q,hq,t,ht,v,_,w,_,hz,rfl,rfl,hrest⟩ + exact ⟨n,hn,p,hp,m,hm,q,hq,t,ht,hz,hrest⟩ + · rintro ⟨n,hn,p,hp,m,hm,q,hq,t,ht,hz,hrest⟩ + refine ⟨n,hn,p,hp,m,hm,q,hq,t,ht,ZFSet.pair n p,?_,ZFSet.pair m q,?_,hz,rfl,rfl,hrest⟩ + · rw [hs]; exact ZFSet.mem_prod.mpr ⟨n,hn,p,hp,rfl⟩ + · rw [hs]; exact ZFSet.mem_prod.mpr ⟨m,hm,q,hq,rfl⟩ +end Code + +noncomputable def stepRelation (c E D o : ZFSet.{u}) : ZFSet.{u} := + let s := ZFSet.prod ZFSet.omega c + ZFSet.sep (fun z => (Code.step 1 2 3 4 5 6 0).Eval + (cons z (cons ZFSet.omega (cons c (cons E (cons D (cons o (fun _ => s)))))))) + (ZFSet.prod s s) + +theorem step_pair (c E D o x y : ZFSet.{u}) : + ZFSet.pair y x ∈ stepRelation c E D o ↔ + ∃ n ∈ ZFSet.omega, ∃ p ∈ c, ∃ m ∈ ZFSet.omega, ∃ q ∈ c, ∃ t ∈ D, + x = ZFSet.pair n p ∧ y = ZFSet.pair m q ∧ + m = insert n n ∧ ZFSet.pair n t ∈ E ∧ q ∈ t ∧ ZFSet.pair q p ∈ o := by + rw [stepRelation,ZFSet.mem_sep] + rw [Code.eval_step _ _ _ _ _ _ _ _ rfl] + simp only [cons_zero,cons_succ] + constructor + · rintro ⟨_,n,hn,p,hp,m,hm,q,hq,t,ht,hpair,hrest⟩ + obtain ⟨hy,hx⟩ := ZFSet.pair_inj.mp hpair + exact ⟨n,hn,p,hp,m,hm,q,hq,t,ht,hx,hy,hrest⟩ + · rintro ⟨n,hn,p,hp,m,hm,q,hq,t,ht,rfl,rfl,hrest⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨_,ZFSet.mem_prod.mpr ⟨m,hm,q,hq,rfl⟩, + _,ZFSet.mem_prod.mpr ⟨n,hn,p,hp,rfl⟩,rfl⟩,n,hn,p,hp,m,hm,q,hq,t,ht,rfl,hrest⟩ + +theorem stepRelation_mem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c E D o : ZFSet.{u}} (hc : c ∈ M) (hE : E ∈ M) (hD : D ∈ M) (ho : o ∈ M) : + stepRelation c E D o ∈ M := by + have hω := sourceT_omega_mem M hM hT + have hs := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hω hc + apply sep_mem M hM hT.separation.finitePrefix.bounded + · intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hc + rcases i with _|i; exact hE + rcases i with _|i; exact hD + rcases i with _|i; exact ho + exact hs + · exact product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hs hs + +theorem internal_dense_sequence (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c E D o : ZFSet.{u}} (hc : c ∈ M) (hE : E ∈ M) (hD : D ∈ M) (ho : o ∈ M) + (hEF : TransitiveNameModel.FunctionGraph ZFSet.omega D E) + (hdense : ∀ t ∈ D, ∀ p ∈ c, ∃ q ∈ c, q ∈ t ∧ ZFSet.pair q p ∈ o) + {p₀ : ZFSet.{u}} (hp₀ : p₀ ∈ c) : + ∃ a : ℕ → ZFSet.{u}, (∀ n, a n ∈ c) ∧ a 0 = p₀ ∧ + orbitGraph (fun n => ZFSet.pair (natSet n) (a n)) ∈ M ∧ + ∀ n, ∃ t ∈ D, ZFSet.pair (natSet n) t ∈ E ∧ + a (n+1) ∈ t ∧ ZFSet.pair (a (n+1)) (a n) ∈ o := by + classical + let s := ZFSet.prod ZFSet.omega c + have hs := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + (sourceT_omega_mem M hM hT) hc + have serial : ∀ x ∈ s, ∃ y ∈ s, ZFSet.pair y x ∈ stepRelation c E D o := by + intro x hx + obtain ⟨n,hn,p,hp,rfl⟩ := ZFSet.mem_prod.mp hx + obtain ⟨t,ht,hnt,_⟩ := hEF.2 n hn + obtain ⟨q,hq,hqt,hqp⟩ := hdense t ht p hp + refine ⟨ZFSet.pair (insert n n) q,ZFSet.mem_prod.mpr ⟨_,ZFSet.omega_succ hn,q,hq,rfl⟩,?_⟩ + exact (step_pair c E D o _ _).mpr ⟨n,hn,p,hp,_,ZFSet.omega_succ hn,q,hq,t,ht,rfl,rfl,rfl,hnt,hqt,hqp⟩ + obtain ⟨b,hb0,hb,hbM,hstep⟩ := sourceT_dependent_choice M hM hT hs + (stepRelation_mem M hM hT hc hE hD ho) + (ZFSet.mem_prod.mpr ⟨natSet 0,(mem_omega _).mpr ⟨0,rfl⟩,p₀,hp₀,rfl⟩) serial + have shape : ∀ n, ∃ p ∈ c, b n = ZFSet.pair (natSet n) p := by + intro n + induction n with + | zero => exact ⟨p₀,hp₀,hb0⟩ + | succ n ih => + obtain ⟨p,hp,hbp⟩ := ih + obtain ⟨k,_,q,_,m,_,r,hr,t,_,hbq,hbr,hm,_⟩ := (step_pair c E D o _ _).mp (hstep n) + have heq := ZFSet.pair_inj.mp (hbp.symm.trans hbq) + refine ⟨r,hr,?_⟩ + rw [hbr,hm,←heq.1] + rfl + choose a ha hab using shape + have ha0 : a 0 = p₀ := (ZFSet.pair_inj.mp ((hab 0).symm.trans hb0)).2 + have heq : b = fun n => ZFSet.pair (natSet n) (a n) := funext hab + refine ⟨a,ha,ha0,heq ▸ hbM,?_⟩ + intro n + obtain ⟨k,hk,p,hp,m,hm,q,hq,t,ht,hbp,hbq,hsucc,hkt,hqt,hqp⟩ := (step_pair c E D o _ _).mp (hstep n) + obtain ⟨hk',hp'⟩ := ZFSet.pair_inj.mp ((hab n).symm.trans hbp) + obtain ⟨_,hq'⟩ := ZFSet.pair_inj.mp ((hab (n+1)).symm.trans hbq) + exact ⟨t,ht,hk'.symm ▸ hkt,hq'.symm ▸ hqt,hq'.symm ▸ hp'.symm ▸ hqp⟩ + +end TuringRigidity.BoundedSetTheory.InternalGeneric + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalGraphEquiv.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalGraphEquiv.lean new file mode 100644 index 0000000000000000000000000000000000000000..31547ba8ba546a084257b5330310c4a0a84bcf51 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalGraphEquiv.lean @@ -0,0 +1,45 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalInverseGraph + +namespace OAI + +namespace TuringRigidity.InternalGraphEquiv +open TransitiveNameModel BoundedSetTheory + +noncomputable def graphMap (A B f : ZFSet.{0}) (hf : FunctionGraph A B f) + (x : Conditions A) : Conditions B := + equivShrink B ⟨(hf.2 (label A x) (label_mem A x)).choose, + (hf.2 (label A x) (label_mem A x)).choose_spec.1⟩ + +theorem graphMap_spec (A B f : ZFSet.{0}) (hf : FunctionGraph A B f) (x : Conditions A) : + ZFSet.pair (label A x) (label B (graphMap A B f hf x)) ∈ f := by + simpa only [graphMap,label,Equiv.symm_apply_apply] using + (hf.2 (label A x) (label_mem A x)).choose_spec.2.1 + +theorem graphMap_bijective (A B f : ZFSet.{0}) (hf : FunctionGraph A B f) + (hi : ∀ x ∈ A, ∀ x' ∈ A, ∀ y ∈ B, ZFSet.pair x y ∈ f → ZFSet.pair x' y ∈ f → x = x') + (hs : ∀ y ∈ B, ∃ x ∈ A, ZFSet.pair x y ∈ f) : Function.Bijective (graphMap A B f hf) := by + constructor + · intro x x' he + apply label_injective A + exact hi _ (label_mem A x) _ (label_mem A x') _ (label_mem B (graphMap A B f hf x)) + (graphMap_spec A B f hf x) (he.symm ▸ graphMap_spec A B f hf x') + · intro y + obtain ⟨x,hx,hxy⟩ := hs (label B y) (label_mem B y) + obtain ⟨x,rfl⟩ := label_surjective A hx + exact ⟨x,label_injective B (hf.functional (label_mem A x) (graphMap_spec A B f hf x) hxy)⟩ + +noncomputable def graphEquiv (A B f : ZFSet.{0}) (hf : FunctionGraph A B f) + (hi : ∀ x ∈ A, ∀ x' ∈ A, ∀ y ∈ B, ZFSet.pair x y ∈ f → ZFSet.pair x' y ∈ f → x = x') + (hs : ∀ y ∈ B, ∃ x ∈ A, ZFSet.pair x y ∈ f) : Conditions A ≃ Conditions B := + Equiv.ofBijective (graphMap A B f hf) (graphMap_bijective A B f hf hi hs) + +theorem graphEquiv_spec (A B f : ZFSet.{0}) (hf : FunctionGraph A B f) + (hi : ∀ x ∈ A, ∀ x' ∈ A, ∀ y ∈ B, ZFSet.pair x y ∈ f → ZFSet.pair x' y ∈ f → x = x') + (hs : ∀ y ∈ B, ∃ x ∈ A, ZFSet.pair x y ∈ f) (x : Conditions A) (y : Conditions B) : + ZFSet.pair (label A x) (label B y) ∈ f ↔ y = graphEquiv A B f hf hi hs x := by + exact ⟨fun h => label_injective B (hf.functional (label_mem A x) h (graphMap_spec A B f hf x)), + fun h => h.symm ▸ graphMap_spec A B f hf x⟩ + +end TuringRigidity.InternalGraphEquiv + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalHartogs.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalHartogs.lean new file mode 100644 index 0000000000000000000000000000000000000000..95ab3d345dae401b6eff2b71959b8d4046675793 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalHartogs.lean @@ -0,0 +1,42 @@ +import OAI.Computability.DegreeRigidity.SetModels.CollapseCoding +import OAI.Computability.DegreeRigidity.OrdinalCodes.RankOrdinal + +namespace OAI + + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory InternalRank +universe u + +theorem internal_hartogs (M d : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hd : d ∈ M) : + ∃ α ∈ M, α.IsOrdinal ∧ ∀ f ∈ M, ∀ j : ZFSet.{u} → ZFSet.{u}, + Presents α f j → (∀ x ∈ α, j x ∈ d) → + ¬ (∀ x ∈ α, ∀ y ∈ α, j x = j y → x = y) := by + obtain ⟨W,hW,hbound⟩ := internal_small_transitive_bound M d hM hP hU hPow hS hR hd + let k := rankSet W + have hk : k ∈ M := rankSet_mem_ground M hM hP hU hPow hS.bounded hR hI hW + have hko : k.IsOrdinal := rankSet_isOrdinal W + let α := insert k k + have hα : α ∈ M := by + have eq : α = ({k} : ZFSet.{u}) ∪ k := by + apply ZFSet.ext + intro z + simp only [α,ZFSet.mem_insert_iff,ZFSet.mem_union,ZFSet.mem_singleton] + rw [eq] + exact binary_union_mem M hM hP hU (singleton_mem M hM hP hk) hk + have hαo : α.IsOrdinal := ZFSet.isOrdinal_succ hko + refine ⟨α,hα,hαo,?_⟩ + intro f hf j hfj hj hi + have hαt : Transitive α := fun x hx y hy => hαo.subset_of_mem hx hy + have hsub := hbound α hα hαt f hf j hfj hj hi + have hkw : k ∈ W := hsub (ZFSet.mem_insert_iff.mpr (Or.inl rfl)) + have hlt := ZFSet.rank_lt_of_mem hkw + have heq : k.rank = W.rank := by + rw [show k = W.rank.toZFSet from rankSet_eq_ordinal W,Ordinal.rank_toZFSet] + exact (lt_irrefl W.rank) (heq ▸ hlt) + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalHomogeneousTruth.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalHomogeneousTruth.lean new file mode 100644 index 0000000000000000000000000000000000000000..45173f390e6fb01c70223561594218fe44a21f4f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalHomogeneousTruth.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenHomogeneity +import OAI.Computability.DegreeRigidity.SetModels.InternalOrderIsoTransport +import OAI.Computability.DegreeRigidity.SetModels.InternalBoundedTruth +import OAI.Computability.DegreeRigidity.Representation.SourceTGenericExistence + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem top_weak_of_internal_symmetry (M c : ZFSet.{0}) + [OrderTop (Conditions c)] (hM : Transitive M) (hT : SourceT M) + (hct : (M : Set ZFSet.{0}).Countable) (hc : c ∈ M) + (hom : ∀ p q : Conditions c, ∃ w ∈ M, ∃ a : Conditions c ≃o Conditions c, + (∀ s t, ZFSet.pair (label c s) (label c t) ∈ w ↔ t = a s) ∧ + ∃ r, r ≤ a p ∧ r ≤ q) + (φ : BoundedSetTheory.Formula) (e : ℕ → Name (Conditions c)) + (he : ∀ i, (e i).encode (label c) ∈ M) + (hinv : ∀ w ∈ M, ∀ a : Conditions c ≃o Conditions c, + (∀ s t, ZFSet.pair (label c s) (label c t) ∈ w ↔ t = a s) → + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → + (φ.Eval (fun i => (e i).val (AutomorphismName.mapFilter a G).carrier) ↔ + φ.Eval (fun i => (e i).val G.carrier))) + (p : Conditions c) (hp : Forces e φ p) : Forces e (.neg (.neg φ)) ⊤ := by + have truthAt (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) + (ψ : BoundedSetTheory.Formula) := internal_bounded_truth M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc + (InternalCollapse.orderSet_mem M hM hT hc) (InternalCollapse.orderSet_pair c) + G hG ψ e he + intro q _ hn + obtain ⟨w,hw,a,ha,r,hrp,hrq⟩ := hom p q + obtain ⟨G,hr,hG⟩ := ArithmeticTree.countable_ground_generic M hct ⟨c,hc⟩ (a.symm r) + have hpG : p ∈ G.carrier := + G.upper (by simpa using a.symm.monotone hrp) hr + have hval := (truthAt G hG φ).mpr ⟨p,hpG,hp⟩ + let H := AutomorphismName.mapFilter a G + have hH : GroundGeneric M H := + InternalOrderIsoTransport.map_ground_generic M c c w hM hT hc hc hw a ha G hG + have hrH : r ∈ H.carrier := hr + have hqH : q ∈ H.carrier := H.upper hrq hrH + have hnot := (truthAt H hH (.neg φ)).mpr ⟨q,hqH,hn⟩ + exact hnot ((hinv w hw a ha G hG).mpr hval) + +theorem all_generics_of_internal_symmetry (M c : ZFSet.{0}) + [OrderTop (Conditions c)] (hM : Transitive M) (hT : SourceT M) + (hct : (M : Set ZFSet.{0}).Countable) (hc : c ∈ M) + (hom : ∀ p q : Conditions c, ∃ w ∈ M, ∃ a : Conditions c ≃o Conditions c, + (∀ s t, ZFSet.pair (label c s) (label c t) ∈ w ↔ t = a s) ∧ + ∃ r, r ≤ a p ∧ r ≤ q) + (φ : BoundedSetTheory.Formula) (e : ℕ → Name (Conditions c)) + (he : ∀ i, (e i).encode (label c) ∈ M) + (hinv : ∀ w ∈ M, ∀ a : Conditions c ≃o Conditions c, + (∀ s t, ZFSet.pair (label c s) (label c t) ∈ w ↔ t = a s) → + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → + (φ.Eval (fun i => (e i).val (AutomorphismName.mapFilter a G).carrier) ↔ + φ.Eval (fun i => (e i).val G.carrier))) + (G₀ : GenericFilter (Conditions c)) (hG₀ : GroundGeneric M G₀) + (hφ : φ.Eval (fun i => (e i).val G₀.carrier)) : + Forces e (.neg (.neg φ)) ⊤ ∧ + ∀ G : GenericFilter (Conditions c), GroundGeneric M G → + φ.Eval (fun i => (e i).val G.carrier) := by + classical + have truthAt (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) + (ψ : BoundedSetTheory.Formula) := internal_bounded_truth M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc + (InternalCollapse.orderSet_mem M hM hT hc) (InternalCollapse.orderSet_pair c) + G hG ψ e he + obtain ⟨p,_,hp⟩ := (truthAt G₀ hG₀ φ).mp hφ + have ht := top_weak_of_internal_symmetry M c hM hT hct hc hom φ e he hinv p hp + refine ⟨ht,?_⟩ + intro G hG + obtain ⟨q,hq⟩ := G.nonempty + have hv := (truthAt G hG (.neg (.neg φ))).mpr ⟨⊤,G.upper le_top hq,ht⟩ + exact not_not.mp hv + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalHull.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..87ff5d467415b416643f1a72b16159fdd39cb5c4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalHull.lean @@ -0,0 +1,158 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedRelations + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +noncomputable def hull (d q x : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∀ c ∈ q, Transitive c → x ∈ c → z ∈ c) d + +theorem mem_hull (d q x z : ZFSet.{u}) : + z ∈ hull d q x ↔ z ∈ d ∧ ∀ c ∈ q, Transitive c → x ∈ c → z ∈ c := + ZFSet.mem_sep + +def hullMemberFormula : Formula := + .allMem 2 (.imp (.conj (.transitive 0) (.member 2 0)) (.member 1 0)) + +theorem eval_hullMemberFormula (z x q : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + hullMemberFormula.Eval (cons z (cons x (cons q e))) ↔ + ∀ c ∈ q, Transitive c → x ∈ c → z ∈ c := by + simp only [hullMemberFormula, Formula.eval_allMem, Formula.eval_imp, + Formula.Eval, Formula.eval_transitive, cons_zero, cons_succ] + exact forall_congr' (fun c => forall_congr' (fun _ => and_imp)) + +theorem hull_mem (M d q : ZFSet.{u}) (hM : Transitive M) (hS : Separation M) + (hdM : d ∈ M) (hqM : q ∈ M) {x : ZFSet.{u}} (hxM : x ∈ M) : + hull d q x ∈ M := by + have he : ∀ i, cons x (cons q (fun _ => d)) i ∈ M := by + intro i; cases i with + | zero => exact hxM + | succ i => cases i <;> assumption + have hs := sep_mem M hM hS hullMemberFormula _ he hdM + have heq : ZFSet.sep (fun z => hullMemberFormula.Eval + (cons z (cons x (cons q (fun _ => d))))) d = hull d q x := by + apply ZFSet.ext + intro z + simp only [ZFSet.mem_sep, eval_hullMemberFormula, mem_hull] + exact heq ▸ hs + +theorem hull_subset (d q x : ZFSet.{u}) : hull d q x ⊆ d := + fun _ hz => (mem_hull _ _ _ _).mp hz |>.1 + +theorem self_mem_hull (d q : ZFSet.{u}) {x : ZFSet.{u}} (hx : x ∈ d) : + x ∈ hull d q x := (mem_hull _ _ _ _).mpr ⟨hx,fun _ _ _ h => h⟩ + +theorem hull_transitive (d q x : ZFSet.{u}) (hd : Transitive d) : + Transitive (hull d q x) := by + intro y hy z hz + obtain ⟨hyd,hyc⟩ := (mem_hull _ _ _ _).mp hy + exact (mem_hull _ _ _ _).mpr + ⟨hd y hyd z hz,fun c hc ht hx => ht y (hyc c hc ht hx) z hz⟩ + +theorem hull_least (d q x c : ZFSet.{u}) (hcq : c ∈ q) + (hc : Transitive c) (hx : x ∈ c) : hull d q x ⊆ c := + fun _ hz => (mem_hull _ _ _ _).mp hz |>.2 c hcq hc hx + +namespace Formula +def isHull (c x _d q : ℕ) : Formula := + .conj (.member c q) (.conj (transitive c) (.conj (.member x c) + (allMem q (imp (.conj (transitive 0) (.member (x+1) 0)) (subset (c+1) 0))))) + +theorem eval_isHull (c x d q : ℕ) (e : ℕ → ZFSet.{u}) : + (isHull c x d q).Eval e ↔ e c ∈ e q ∧ Transitive (e c) ∧ e x ∈ e c ∧ + ∀ b ∈ e q, Transitive b → e x ∈ b → e c ⊆ b := by + simp only [isHull, Eval, eval_transitive, eval_allMem, eval_imp, + eval_subset, cons_zero, cons_succ] + simp only [and_imp] +end Formula + +theorem isHull_iff (M d q : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hdM : d ∈ M) (hqM : q ∈ M) (hd : Transitive d) + (hq : ∀ c, c ∈ q ↔ c ∈ M ∧ c ⊆ d) {x c : ZFSet.{u}} + (hx : x ∈ d) (hc : c ∈ M) : + (c ∈ q ∧ Transitive c ∧ x ∈ c ∧ + ∀ b ∈ q, Transitive b → x ∈ b → c ⊆ b) ↔ c = hull d q x := by + have hhM := hull_mem M d q hM hS hdM hqM (hM d hdM x hx) + have hhq := (hq _).mpr ⟨hhM,hull_subset d q x⟩ + have hht := hull_transitive d q x hd + have hhx := self_mem_hull d q hx + constructor + · rintro ⟨hcq,hct,hxc,hmin⟩ + apply ZFSet.ext + intro z + exact ⟨fun hz => hmin _ hhq hht hhx hz,fun hz => hull_least d q x c hcq hct hxc hz⟩ + · rintro rfl + exact ⟨hhq,hht,hhx,fun b hb ht hx => hull_least d q x b hb ht hx⟩ + +theorem collect_hulls (M d q : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hR : SigmaReplacement M) + (hdM : d ∈ M) (hqM : q ∈ M) (hd : Transitive d) + (hq : ∀ c, c ∈ q ↔ c ∈ M ∧ c ⊆ d) {x : ZFSet.{u}} (hx : x ∈ d) : + ∃ b ∈ M, ∀ c, c ∈ b ↔ ∃ y ∈ x, hull d q y = c := by + let e := cons d (cons q (fun _ => d)) + have he : ∀ i, e i ∈ M := by + intro i; cases i with + | zero => exact hdM + | succ i => cases i <;> assumption + apply replacement_image M hM hR (.bounded (.isHull 0 1 2 3)) e he + (hM d hdM x hx) (hull d q) + · intro y hy + exact hull_mem M d q hM hS hdM hqM (hM _ (hM d hdM x hx) y hy) + · intro y hy c hc + change (Formula.isHull 0 1 2 3).Realize M (cons c (cons y e)) ↔ _ + have he' : ∀ i, cons c (cons y e) i ∈ M := by + intro i; cases i with + | zero => exact hc + | succ i => cases i with + | zero => exact hM _ (hM d hdM x hx) y hy + | succ i => exact he i + rw [Formula.absolute _ M hM _ he', Formula.eval_isHull] + exact isHull_iff M d q hM hS hdM hqM hd hq (hd x hx y hy) hc + +theorem hull_unfold (M d q : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : Union M) (hS : Separation M) (hR : SigmaReplacement M) + (hdM : d ∈ M) (hqM : q ∈ M) (hd : Transitive d) + (hq : ∀ c, c ∈ q ↔ c ∈ M ∧ c ⊆ d) {x : ZFSet.{u}} (hx : x ∈ d) : + ∀ z, z ∈ hull d q x ↔ z = x ∨ ∃ y ∈ x, z ∈ hull d q y := by + obtain ⟨b,hb,hbdef⟩ := collect_hulls M d q hM hS hR hdM hqM hd hq hx + let a := ({x} : ZFSet.{u}) ∪ ZFSet.sUnion b + have haM : a ∈ M := binary_union_mem M hM hP hU + (singleton_mem M hM hP (hM d hdM x hx)) (union_mem M hM hU hb) + have ha (z : ZFSet.{u}) : z ∈ a ↔ z = x ∨ ∃ y ∈ x, z ∈ hull d q y := by + simp only [a,ZFSet.mem_union,ZFSet.mem_singleton,ZFSet.mem_sUnion] + constructor + · rintro (h|⟨c,hc,hzc⟩) + · exact Or.inl h + · obtain ⟨y,hy,rfl⟩ := (hbdef c).mp hc + exact Or.inr ⟨y,hy,hzc⟩ + · rintro (h|⟨y,hy,hzy⟩) + · exact Or.inl h + · exact Or.inr ⟨_,(hbdef _).mpr ⟨y,hy,rfl⟩,hzy⟩ + have had : a ⊆ d := by + intro z hz + rcases (ha z).mp hz with rfl|⟨y,_,hzy⟩ + · exact hx + · exact hull_subset d q y hzy + have hat : Transitive a := by + intro z hz w hw + apply (ha w).mpr + rcases (ha z).mp hz with rfl|⟨y,hy,hzy⟩ + · exact Or.inr ⟨w,hw,self_mem_hull d q (hd _ hx w hw)⟩ + · exact Or.inr ⟨y,hy,hull_transitive d q y hd z hzy w hw⟩ + have hhM := hull_mem M d q hM hS hdM hqM (hM d hdM x hx) + have hhq := (hq _).mpr ⟨hhM,hull_subset d q x⟩ + intro z + constructor + · intro hz + exact (ha z).mp (hull_least d q x a ((hq _).mpr ⟨haM,had⟩) hat + ((ha x).mpr (Or.inl rfl)) hz) + · rintro (rfl|⟨y,hy,hzy⟩) + · exact self_mem_hull d q hx + · exact hull_least d q y _ hhq (hull_transitive d q x hd) + (hull_transitive d q x hd x (self_mem_hull d q hx) y hy) hzy + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalInfinity.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalInfinity.lean new file mode 100644 index 0000000000000000000000000000000000000000..926936d2023a4073943f008f91ef2fecc712f97f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalInfinity.lean @@ -0,0 +1,179 @@ +import OAI.Computability.DegreeRigidity.SetModels.ExtensionBasicAxioms +import OAI.Computability.DegreeRigidity.Syntax.BoundedRelations + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +def natSet : ℕ → ZFSet.{u} + | 0 => ∅ + | n+1 => insert (natSet n) (natSet n) + +theorem natSet_eq_mk (n : ℕ) : natSet.{u} n = ZFSet.mk (PSet.ofNat n) := by + induction n with + | zero => rfl + | succ n ih => change insert (natSet n) (natSet n) = _; rw [ih]; rfl + +theorem mem_natSet (n : ℕ) (x : ZFSet.{u}) : + x ∈ natSet n ↔ ∃ i < n, x = natSet i := by + induction n with + | zero => simp [natSet] + | succ n ih => + rw [natSet,ZFSet.mem_insert_iff,ih] + constructor + · rintro (rfl|⟨i,hi,hx⟩) + · exact ⟨n,Nat.lt_succ_self n,rfl⟩ + · exact ⟨i,Nat.lt_succ_of_lt hi,hx⟩ + · rintro ⟨i,hi,hx⟩ + rcases Nat.lt_or_eq_of_le (Nat.le_of_lt_succ hi) with hi|rfl + · exact Or.inr ⟨i,hi,hx⟩ + · exact Or.inl hx + +theorem natSet_injective : Function.Injective natSet.{u} := by + intro n m h + rcases Nat.lt_trichotomy n m with hn|he|hm + · exact False.elim (ZFSet.mem_irrefl (natSet m) + (h ▸ (mem_natSet m _).mpr ⟨n,hn,rfl⟩)) + · exact he + · exact False.elim (ZFSet.mem_irrefl (natSet n) + (h.symm ▸ (mem_natSet n _).mpr ⟨m,hm,rfl⟩)) + +theorem natSet_mem_natSet (n m : ℕ) : natSet.{u} n ∈ natSet m ↔ n < m := by + rw [mem_natSet] + exact ⟨fun ⟨i,hi,he⟩ => natSet_injective he ▸ hi,fun h => ⟨n,h,rfl⟩⟩ + +theorem natSet_transitive (n : ℕ) : Transitive (natSet.{u} n) := by + intro x hx y hy + obtain ⟨i,hi,rfl⟩ := (mem_natSet n x).mp hx + obtain ⟨j,hj,rfl⟩ := (mem_natSet i y).mp hy + exact (natSet_mem_natSet j n).mpr (Nat.lt_trans hj hi) + +theorem mem_omega (x : ZFSet.{u}) : x ∈ ZFSet.omega ↔ ∃ n, x = natSet n := by + induction x using Quotient.inductionOn with + | h x => + change (∃ n : ULift ℕ, PSet.Equiv x (PSet.ofNat n.down)) ↔ _ + constructor + · rintro ⟨⟨n⟩,hn⟩ + exact ⟨n,(Quotient.sound hn).trans (natSet_eq_mk n).symm⟩ + · rintro ⟨n,hn⟩ + exact ⟨⟨n⟩,Quotient.exact (hn.trans (natSet_eq_mk n))⟩ + +theorem omega_transitive : Transitive ZFSet.omega.{u} := by + intro x hx y hy + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + obtain ⟨i,_,rfl⟩ := (mem_natSet n y).mp hy + exact (mem_omega _).mpr ⟨i,rfl⟩ + +namespace Formula +def empty (x : ℕ) : Formula := allMem x (.neg (.equal 0 0)) +def successor (s n : ℕ) : Formula := + .conj (.member n s) (.conj (subset n s) + (allMem s (disj (.equal 0 (n+1)) (.member 0 (n+1))))) + +@[simp] theorem eval_empty (x : ℕ) (e : ℕ → ZFSet.{u}) : + (empty x).Eval e ↔ e x = ∅ := by + simp only [empty,eval_allMem,Eval,cons_zero,not_true_eq_false] + constructor + · intro h; apply ZFSet.ext; intro z; simp only [ZFSet.notMem_empty,iff_false]; exact h z + · intro h; simp [h] + +@[simp] theorem eval_successor (s n : ℕ) (e : ℕ → ZFSet.{u}) : + (successor s n).Eval e ↔ e s = insert (e n) (e n) := by + simp only [successor,Eval,eval_subset,eval_allMem,eval_disj,cons_zero,cons_succ] + constructor + · rintro ⟨hn,hsub,hall⟩ + apply ZFSet.ext + intro z + rw [ZFSet.mem_insert_iff] + exact ⟨hall z,fun h => h.elim (fun h => h ▸ hn) (fun h => hsub h)⟩ + · intro h; rw [h] + exact ⟨ZFSet.mem_insert _ _,fun _ hz => ZFSet.mem_insert_of_mem _ hz, + fun _ hz => ZFSet.mem_insert_iff.mp hz⟩ + +def zeroOrSuccessor (x : ℕ) : Formula := + disj (empty x) (.existsMem x (successor (x+1) 0)) + +def finiteOrdinal (x : ℕ) : Formula := .conj (transitive x) + (.conj (allMem x (transitive 0)) + (.conj (zeroOrSuccessor x) (allMem x (zeroOrSuccessor 0)))) + +theorem eval_zeroOrSuccessor (x : ℕ) (e : ℕ → ZFSet.{u}) : + (zeroOrSuccessor x).Eval e ↔ e x = ∅ ∨ ∃ y ∈ e x, e x = insert y y := by + simp only [zeroOrSuccessor,eval_disj,eval_empty,Eval,eval_successor,cons_zero,cons_succ] +end Formula + +def FiniteOrdinal (x : ZFSet.{u}) : Prop := Transitive x ∧ (∀ y ∈ x, Transitive y) ∧ + (x = ∅ ∨ ∃ y ∈ x, x = insert y y) ∧ + ∀ y ∈ x, y = ∅ ∨ ∃ z ∈ y, y = insert z z + +theorem eval_finiteOrdinal (x : ℕ) (e : ℕ → ZFSet.{u}) : + (Formula.finiteOrdinal x).Eval e ↔ FiniteOrdinal (e x) := by + simp only [Formula.finiteOrdinal,Formula.Eval,Formula.eval_transitive, + Formula.eval_allMem,Formula.eval_zeroOrSuccessor,cons_zero,FiniteOrdinal] + +theorem finiteOrdinal_natSet (n : ℕ) : FiniteOrdinal (natSet.{u} n) := by + have hshape (n : ℕ) : natSet.{u} n = ∅ ∨ ∃ y ∈ natSet n, natSet n = insert y y := by + cases n with + | zero => exact Or.inl rfl + | succ n => exact Or.inr ⟨_,ZFSet.mem_insert _ _,rfl⟩ + refine ⟨natSet_transitive n,?_,hshape n,?_⟩ + · intro y hy + obtain ⟨i,_,rfl⟩ := (mem_natSet n y).mp hy + exact natSet_transitive i + · intro y hy + obtain ⟨i,_,rfl⟩ := (mem_natSet n y).mp hy + exact hshape i + +theorem finiteOrdinal_iff (x : ZFSet.{u}) : FiniteOrdinal x ↔ ∃ n, x = natSet n := by + constructor + · induction x using ZFSet.inductionOn with + | h x ih => + intro h + rcases h.2.2.1 with he|⟨y,hy,he⟩ + · exact ⟨0,he⟩ + · have hyf : FiniteOrdinal y := ⟨h.2.1 y hy, + fun z hz => h.2.1 z (h.1 y hy z hz),h.2.2.2 y hy, + fun z hz => h.2.2.2 z (h.1 y hy z hz)⟩ + obtain ⟨n,rfl⟩ := ih y hy hyf + exact ⟨n+1,he⟩ + · rintro ⟨n,rfl⟩; exact finiteOrdinal_natSet n + +def Infinity (M : ZFSet.{u}) : Prop := + ∃ a ∈ M, (∃ e ∈ M, e ∈ a ∧ ∀ z ∈ M, z ∉ e) ∧ + ∀ x ∈ M, x ∈ a → ∃ s ∈ M, s ∈ a ∧ + ∀ z ∈ M, z ∈ s ↔ z = x ∨ z ∈ x + +theorem omega_mem (M : ZFSet.{u}) (hM : Transitive M) (hS : Separation M) + (hI : Infinity M) : ZFSet.omega.{u} ∈ M := by + obtain ⟨a,ha,⟨e,he,hea,hee⟩,hs⟩ := hI + have he0 : e = ∅ := by + apply ZFSet.ext; intro z + simp only [ZFSet.notMem_empty,iff_false] + exact fun hz => hee z (hM e he z hz) hz + have hn (n : ℕ) : natSet.{u} n ∈ a := by + induction n with + | zero => simpa only [natSet,he0] using hea + | succ n ih => + obtain ⟨s,hsM,hsa,hsdef⟩ := hs _ (hM a ha _ ih) ih + have heq : s = insert (natSet n) (natSet n) := by + apply ZFSet.ext; intro z; rw [ZFSet.mem_insert_iff] + constructor + · intro hz; exact (hsdef z (hM s hsM z hz)).mp hz + · intro hz + have hzM : z ∈ M := hz.elim (fun h => h ▸ hM a ha _ ih) + (fun h => hM _ (hM a ha _ ih) z h) + exact (hsdef z hzM).mpr hz + simpa only [natSet,←heq] using hsa + have hsep := sep_mem M hM hS (.finiteOrdinal 0) (fun _ => a) (fun _ => ha) ha + have heq : ZFSet.sep (fun x => (Formula.finiteOrdinal 0).Eval (cons x (fun _ => a))) a = + ZFSet.omega := by + apply ZFSet.ext; intro x + simp only [ZFSet.mem_sep,eval_finiteOrdinal,cons_zero,finiteOrdinal_iff,mem_omega] + exact ⟨And.right,fun h => ⟨by obtain ⟨n,rfl⟩ := h; exact hn n,h⟩⟩ + exact heq ▸ hsep + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalInverseGraph.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalInverseGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..d49f40501c4ca8a238295d2493f00c5ef96b7cb7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalInverseGraph.lean @@ -0,0 +1,63 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableMap + +namespace OAI + +namespace TuringRigidity.InternalInverseGraph +open TransitiveNameModel BoundedSetTheory + +noncomputable def inverse (A B f : ZFSet.{0}) : ZFSet.{0} := + (ZFSet.prod B A).sep (fun z => ∃ y ∈ B, ∃ x ∈ A, + z = ZFSet.pair y x ∧ ZFSet.pair x y ∈ f) + +theorem pair_inverse (A B f y x : ZFSet.{0}) : + ZFSet.pair y x ∈ inverse A B f ↔ y ∈ B ∧ x ∈ A ∧ ZFSet.pair x y ∈ f := by + simp only [inverse,ZFSet.mem_sep] + constructor + · rintro ⟨_,y',hy,x',hx,he,h⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hy,hx,h⟩ + · rintro ⟨hy,hx,h⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨hy,hx⟩,y,hy,x,hx,rfl,h⟩ + +theorem inverse_mem (M A B f : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hB : B ∈ M) (hf : f ∈ M) : inverse A B f ∈ M := by + let e := cons B (cons A (fun _ => f)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i + exact hB; exact hA; exact hf + simpa only [inverse,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) (.pairMem 0 1 5)))) e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hB hA) + +theorem inverse_function (A B f : ZFSet.{0}) + (hi : ∀ x ∈ A, ∀ x' ∈ A, ∀ y ∈ B, ZFSet.pair x y ∈ f → ZFSet.pair x' y ∈ f → x = x') + (hs : ∀ y ∈ B, ∃ x ∈ A, ZFSet.pair x y ∈ f) : + FunctionGraph B A (inverse A B f) := by + constructor + · intro z hz; exact ZFSet.mem_prod.mp (ZFSet.mem_sep.mp hz).1 + · intro y hy + obtain ⟨x,hx,hxy⟩ := hs y hy + refine ⟨x,hx,(pair_inverse A B f y x).mpr ⟨hy,hx,hxy⟩,?_⟩ + intro x' hx' hyx' + exact hi x' hx' x hx y hy ((pair_inverse A B f y x').mp hyx').2.2 hxy + +theorem inverse_onto (A B f : ZFSet.{0}) (hf : FunctionGraph A B f) : + ∀ x ∈ A, ∃ y ∈ B, ZFSet.pair y x ∈ inverse A B f := by + intro x hx + obtain ⟨y,hy,hxy,_⟩ := hf.2 x hx + exact ⟨y,hy,(pair_inverse A B f y x).mpr ⟨hy,hx,hxy⟩⟩ + +theorem countable_of_bijection (M A B f : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hB : B ∈ M) (hfM : f ∈ M) (hf : FunctionGraph A B f) + (hi : ∀ x ∈ A, ∀ x' ∈ A, ∀ y ∈ B, ZFSet.pair x y ∈ f → ZFSet.pair x' y ∈ f → x = x') + (hs : ∀ y ∈ B, ∃ x ∈ A, ZFSet.pair x y ∈ f) + (hct : InternallyCountable M B) : InternallyCountable M A := + InternalCountableMap.countable_of_surjection M B A (inverse A B f) hM hT hB hA + (inverse_mem M A B f hM hT hA hB hfM) (inverse_function A B f hi hs) + (inverse_onto A B f hf) hct + +end TuringRigidity.InternalInverseGraph + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalInverseIso.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalInverseIso.lean new file mode 100644 index 0000000000000000000000000000000000000000..2cf0cc8957782dc14d73fa9403128936024edbf9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalInverseIso.lean @@ -0,0 +1,29 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalOrderIsoTransport +import OAI.Computability.DegreeRigidity.SetModels.InternalInverseGraph + +namespace OAI + +namespace TuringRigidity.InternalInverseIso +open TransitiveNameModel BoundedSetTheory CountableForcing InternalInverseGraph +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem inverse_graph (M a b f : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) (hb : b ∈ M) (hf : f ∈ M) (e : Conditions a ≃o Conditions b) + (he : ∀ p q, ZFSet.pair (label a p) (label b q) ∈ f ↔ q = e p) : + inverse a b f ∈ M ∧ ∀ p q, + ZFSet.pair (label b p) (label a q) ∈ inverse a b f ↔ q = e.symm p := by + refine ⟨inverse_mem M a b f hM hT ha hb hf,?_⟩ + intro p q + rw [pair_inverse] + simp only [label_mem,true_and,he] + constructor + · intro h + apply e.injective + rw [OrderIso.apply_symm_apply] + exact h.symm + · intro h + rw [h,OrderIso.apply_symm_apply] + +end TuringRigidity.InternalInverseIso + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalMinimalSelector.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalMinimalSelector.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b4699bbc0cbce79c9548f1d5d47cffbaae25b27 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalMinimalSelector.lean @@ -0,0 +1,119 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTheory + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace InternalWellOrder + +def MinimalIn (r a x : ZFSet.{u}) : Prop := x ∈ a ∧ ∀ y ∈ a, ¬ ZFSet.pair y x ∈ r + +def InternallyWellFounded (M d r : ZFSet.{u}) : Prop := + ∀ a ∈ M, a ⊆ d → (∃ x, x ∈ a) → ∃ x, MinimalIn r a x + +def LeastMinimal (δ F r a x : ZFSet.{u}) : Prop := MinimalIn r a x ∧ + ∃ i ∈ δ, ZFSet.pair i x ∈ F ∧ + ∀ j ∈ i, ∀ y ∈ a, ZFSet.pair j y ∈ F → ¬ MinimalIn r a y + +theorem leastMinimal_exists {δ d F r a : ZFSet.{u}} (hδ : δ.IsOrdinal) + (honto : ∀ x ∈ d, ∃ i ∈ δ, ZFSet.pair i x ∈ F) (ha : a ⊆ d) + (hm : ∃ x, MinimalIn r a x) : ∃ x, LeastMinimal δ F r a x := by + classical + have find (i : ZFSet.{u}) : i ∈ δ → (∃ x, MinimalIn r a x ∧ ZFSet.pair i x ∈ F) → + ∃ x, LeastMinimal δ F r a x := by + induction i using ZFSet.inductionOn with + | h i ih => + intro hi hx + by_cases he : ∃ j ∈ i, ∃ y, MinimalIn r a y ∧ ZFSet.pair j y ∈ F + · obtain ⟨j,hji,hy⟩ := he + exact ih j hji (hδ.subset_of_mem hi hji) hy + · obtain ⟨x,hx,hix⟩ := hx + exact ⟨x,hx,i,hi,hix,fun j hj y _ hjy hmy => he ⟨j,hj,y,hmy,hjy⟩⟩ + obtain ⟨x,hx⟩ := hm + obtain ⟨i,hi,hix⟩ := honto x (ha hx.1) + exact find i hi ⟨x,hx,hix⟩ + +theorem LeastMinimal.unique {δ d F r a x y : ZFSet.{u}} (hδ : δ.IsOrdinal) + (hF : TransitiveNameModel.FunctionGraph δ d F) + (hx : LeastMinimal δ F r a x) (hy : LeastMinimal δ F r a y) : x = y := by + obtain ⟨hx,i,hi,hix,hleast⟩ := hx + obtain ⟨hy,j,hj,hjy,hleast'⟩ := hy + rcases (hδ.mem hi).mem_trichotomous (hδ.mem hj) with hij|he|hji + · exact False.elim (hleast' i hij x hx.1 hix hx) + · subst j; exact hF.functional hi hix hjy + · exact False.elim (hleast j hji y hy.1 hjy hy) + +open Formula + +def minimalInFormula (r a x : ℕ) : Formula := + .conj (.member x a) (allMem a (.neg (pairMem 0 (x+1) (r+1)))) + +theorem eval_minimalInFormula (r a x : ℕ) (e : ℕ → ZFSet.{u}) : + (minimalInFormula r a x).Eval e ↔ MinimalIn (e r) (e a) (e x) := by + simp only [minimalInFormula,MinimalIn,Formula.Eval,eval_allMem,eval_pairMem,cons_zero,cons_succ] + +def leastMinimalFormula (δ F r a x : ℕ) : Formula := .conj (minimalInFormula r a x) + (.existsMem δ (.conj (pairMem 0 (x+1) (F+1)) + (allMem 0 (allMem (a+2) (imp (pairMem 1 0 (F+3)) + (.neg (minimalInFormula (r+3) (a+3) 0))))))) + +theorem eval_leastMinimalFormula (δ F r a x : ℕ) (e : ℕ → ZFSet.{u}) : + (leastMinimalFormula δ F r a x).Eval e ↔ LeastMinimal (e δ) (e F) (e r) (e a) (e x) := by + simp only [leastMinimalFormula,LeastMinimal,Formula.Eval,eval_minimalInFormula, + eval_pairMem,eval_allMem,eval_imp,cons_zero,cons_succ] + +def minimalSelectorFormula : Formula := .existsMem 1 (.existsMem 3 + (.conj (.orderedPair 2 1 0) (leastMinimalFormula 5 6 7 1 0))) + +theorem internal_minimal_selector (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {d r : ZFSet.{u}} (hd : d ∈ M) (hr : r ∈ M) (hw : InternallyWellFounded M d r) : + ∃ q ∈ M, ∃ s ∈ M, ChoiceGraph q s ∧ + (∀ a, a ∈ q ↔ a ∈ M ∧ a ⊆ d ∧ ∃ x, x ∈ a) ∧ + ∀ a x, ZFSet.pair a x ∈ s → MinimalIn r a x := by + have hS := hT.separation.finitePrefix + obtain ⟨q,hq,_,_,_,hqdef⟩ := internal_selector M hM hT.powerSet hS.bounded hT.choice hd + obtain ⟨δ,hδM,hδ,F,hFM,hF,honto,_⟩ := internal_ordinal_enumeration M hM + hT.pairing hT.union hT.powerSet hS hT.replacement.finitePrefix hT.infinity hT.choice hd + let e := cons q (cons d (cons δ (cons F (fun _ => r)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hq + rcases i with _|i; exact hd + rcases i with _|i; exact hδM + rcases i with _|i; exact hFM + exact hr + let s := ZFSet.sep (fun z => minimalSelectorFormula.Eval (cons z e)) (ZFSet.prod q d) + have hs : s ∈ M := sep_mem M hM hS.bounded _ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hS.bounded hq hd) + have hmem (z : ZFSet.{u}) : z ∈ s ↔ + ∃ a ∈ q, ∃ x ∈ a, z = ZFSet.pair a x ∧ LeastMinimal δ F r a x := by + simp only [s,ZFSet.mem_sep,minimalSelectorFormula,Formula.Eval,eval_orderedPair, + eval_leastMinimalFormula,cons_zero,cons_succ,e] + constructor + · rintro ⟨_,a,ha,x,_,hz,hm⟩; exact ⟨a,ha,x,hm.1.1,hz,hm⟩ + · rintro ⟨a,ha,x,hx,rfl,hm⟩ + have hxd := ((hqdef a).mp ha).2.1 hx + exact ⟨ZFSet.mem_prod.mpr ⟨a,ha,x,hxd,rfl⟩,a,ha,x,hxd,rfl,hm⟩ + refine ⟨q,hq,s,hs,⟨?_,?_⟩,hqdef,?_⟩ + · intro z hz + obtain ⟨a,ha,x,hx,hz,_⟩ := (hmem z).mp hz + exact ⟨a,ha,x,hx,hz⟩ + · intro a ha + obtain ⟨haM,had,hane⟩ := (hqdef a).mp ha + obtain ⟨x,hx⟩ := leastMinimal_exists hδ honto had (hw a haM had hane) + refine ⟨x,hx.1.1,(hmem _).mpr ⟨a,ha,x,hx.1.1,rfl,hx⟩,?_⟩ + intro y _ hy + obtain ⟨a',_,y',_,heq,hy'⟩ := (hmem _).mp hy + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + exact hy'.unique hδ hF hx + · intro a x hax + obtain ⟨a',_,x',_,heq,hx⟩ := (hmem _).mp hax + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + exact hx.1 + +end InternalWellOrder +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNameEvaluation.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNameEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..007bdb30e524265b527c60747b7f56bfd2bac49c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNameEvaluation.lean @@ -0,0 +1,93 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTheory +import OAI.Computability.DegreeRigidity.SetModels.MostowskiCollapse + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory.InternalNameEvaluation +open TransitiveNameModel RecursiveNames RelationCollapse +universe u + +noncomputable def activeRelation (d g : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ x ∈ d, ∃ y ∈ d, z = ZFSet.pair x y ∧ + ∃ p ∈ g, ZFSet.pair x p ∈ y) (ZFSet.prod d d) + +theorem active_pair (d g x y : ZFSet.{u}) : + ZFSet.pair x y ∈ activeRelation d g ↔ x ∈ d ∧ y ∈ d ∧ ∃ p ∈ g, ZFSet.pair x p ∈ y := by + rw [activeRelation,ZFSet.mem_sep] + constructor + · rintro ⟨_,a,ha,b,hb,he,hrest⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨ha,hb,hrest⟩ + · rintro ⟨hx,hy,hrest⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨x,hx,y,hy,rfl⟩,x,hx,y,hy,rfl,hrest⟩ + +def activeFormula : Formula := .existsMem 1 (.existsMem 2 + (.conj (.orderedPair 2 1 0) (.existsMem 4 (.pairMem 2 0 1)))) + +theorem activeRelation_mem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {d g : ZFSet.{u}} (hd : d ∈ M) (hg : g ∈ M) : activeRelation d g ∈ M := by + simpa only [activeRelation,activeFormula,Formula.Eval,Formula.eval_orderedPair, + Formula.eval_pairMem,cons_zero,cons_succ] using + sep_mem M hM hT.separation.finitePrefix.bounded activeFormula (cons d (fun _ => g)) + (by intro i; cases i <;> assumption) + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hd hd) + +theorem active_wellFounded (d g : ZFSet.{u}) : WellFounded (Rel d (activeRelation d g)) := by + apply (InvImage.wf ZFSet.rank Ordinal.lt_wf).mono + intro x y hxy + obtain ⟨_,_,p,_,hpair⟩ := (active_pair d g x y).mp hxy.2 + exact (FiniteTerm.pair_rank_left x p).trans (ZFSet.rank_lt_of_mem hpair) + +theorem value_eq (d : ZFSet.{u}) (hd : Transitive d) {c : ZFSet.{u}} + (G : Set (Conditions c)) (a : Name (Conditions c)) (ha : a.encode (label c) ∈ d) : + value d (activeRelation d (genericFilterSet c G)) (active_wellFounded _ _) (a.encode (label c)) = a.val G := by + induction a with + | mk ι child tag ih => + have hc (i : ι) : (child i).encode (label c) ∈ d := by + have hp := hd _ ha _ (ZFSet.mem_range_self i) + have hs := hd _ hp _ (ZFSet.mem_pair.mpr (Or.inl rfl)) + exact hd _ hs _ (ZFSet.mem_singleton.mpr rfl) + apply ZFSet.ext; intro z + rw [mem_value,Name.mem_val] + constructor + · rintro ⟨x,_,hxy,hzx⟩ + obtain ⟨_,_,p,hp,hpa⟩ := (active_pair _ _ _ _).mp hxy + obtain ⟨i,hi⟩ := ZFSet.mem_range.mp hpa + obtain ⟨hiX,hiP⟩ := ZFSet.pair_inj.mp hi + obtain ⟨q,hq,hqp⟩ := (mem_genericFilterSet c G p).mp hp + have htag : tag i = q := label_injective c (hiP.trans hqp.symm) + refine ⟨i,htag.symm ▸ hq,?_⟩ + rw [←ih i (hc i),hiX] + exact hzx.symm + · rintro ⟨i,hig,hiz⟩ + refine ⟨(child i).encode (label c),hc i,?_,?_⟩ + · exact (active_pair _ _ _ _).mpr ⟨hc i,ha,label c (tag i), + (mem_genericFilterSet c G _).mpr ⟨tag i,hig,rfl⟩,ZFSet.mem_range_self i⟩ + · exact hiz.symm.trans (ih i (hc i)).symm + +theorem name_value_mem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {c : ZFSet.{u}} (G : Set (Conditions c)) (hg : genericFilterSet c G ∈ M) + (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) : a.val G ∈ M := by + obtain ⟨d,hdM,hd,had⟩ := internal_transitive_container M hM hT.pairing hT.union + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity ha + obtain ⟨f,hf,hfg⟩ := internal_graph M d (activeRelation d (genericFilterSet c G)) hM + hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hT.replacement.finitePrefix + hdM (activeRelation_mem M hM hT hdM hg) (active_wellFounded _ _) + have hp : ZFSet.pair (a.encode (label c)) + (value d (activeRelation d (genericFilterSet c G)) (active_wellFounded _ _) (a.encode (label c))) ∈ f := + (hfg.mem_iff (active_wellFounded _ _) _).mpr ⟨_,had,rfl⟩ + have hv := second_mem_doubleUnion hp + have hi := hM _ (iterUnion_mem M hM hT.union hf 2) _ hv + rwa [value_eq d hd G a had] at hi + +theorem extension_subset (M N : ZFSet.{u}) (hN : Transitive N) (hT : SourceT N) (hMN : M ⊆ N) + {c : ZFSet.{u}} (G : Set (Conditions c)) (hG : genericFilterSet c G ∈ N) : + genericExtensionSet M c G ⊆ N := by + intro x hx + obtain ⟨a,ha,rfl⟩ := (mem_extensionSet M c G x).mp hx + exact name_value_mem N hN hT G hG a (hMN ha) + +end TuringRigidity.BoundedSetTheory.InternalNameEvaluation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNameValidity.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNameValidity.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1f6795c567f3335f9b55810c0d6da03dc4ad7d6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNameValidity.lean @@ -0,0 +1,47 @@ +import OAI.Computability.DegreeRigidity.SetModels.NameValidity +import OAI.Computability.DegreeRigidity.SetModels.InternalContainer + +namespace OAI + + +namespace TuringRigidity.NameValidity +open RecursiveNames TransitiveNameModel BoundedSetTheory +universe u + +namespace Code + +def valid (c x : ℕ) : SigmaFormula := .existsSet (.existsSet (.bounded + (.conj (.transitive 1) (.conj (.member (x+2) 1) + (.conj (certificate 1 (c+2) 0) (.member (x+2) 0)))))) +end Code + +theorem realize_valid (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (c x : ℕ) : + (Code.valid c x).Realize M e ↔ + ∃ a : Name (Conditions (e c)), a.encode (label (e c)) = e x := by + have matrix (d h : ZFSet.{u}) (hd : d ∈ M) (hh : h ∈ M) : + (Formula.conj (.transitive 1) (.conj (.member (x+2) 1) + (.conj (Code.certificate 1 (c+2) 0) (.member (x+2) 0)))).Realize M + (cons h (cons d e)) ↔ + Transitive d ∧ e x ∈ d ∧ Certificate d (e c) h ∧ e x ∈ h := by + rw [Formula.absolute _ M hM _ (by + intro i; rcases i with _|i; exact hh + rcases i with _|i; exact hd + exact he i)] + simp only [Formula.Eval,Formula.eval_transitive,Code.eval_certificate,cons_zero,cons_succ] + change (∃ d ∈ M, ∃ h ∈ M, _) ↔ _ + constructor + · rintro ⟨d,hd,h,hh,hφ⟩ + obtain ⟨_,_,hcert,hx⟩ := (matrix d h hd hh).mp hφ + exact hcert.decode _ hx + · rintro ⟨a,ha⟩ + obtain ⟨d,hd,hdT,hxd⟩ := internal_transitive_container M hM hP hU hS hR hI (he x) + obtain ⟨h,hh,hcert⟩ := internal_certificate M hM hU hPow hS hd (he c) + exact ⟨d,hd,h,hh,(matrix d h hd hh).mpr + ⟨hdT,hxd,hcert,(hcert.correct hdT hxd).mpr ⟨a,ha⟩⟩⟩ + +end TuringRigidity.NameValidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNaturalCheckSequence.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNaturalCheckSequence.lean new file mode 100644 index 0000000000000000000000000000000000000000..999a8cab6369ec897c77acb1c2a07d9a13ff4da1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNaturalCheckSequence.lean @@ -0,0 +1,59 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCheckRecursion +import OAI.Computability.DegreeRigidity.SetModels.InternalContainer +import OAI.Computability.DegreeRigidity.SetModels.InternalSequenceRange + +namespace OAI + +namespace TuringRigidity.InternalNaturalCheckSequence +open TransitiveNameModel BoundedSetTheory + +theorem natural_check_sequence (M t : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ht : t ∈ M) : orbitGraph (fun n => checkedCode t (natSet n)) ∈ M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + obtain ⟨d,hdM,hd,hωd⟩ := internal_transitive_container M hM hT.pairing hT.union hS + hT.replacement.finitePrefix hT.infinity hω + obtain ⟨q,hqM,hq⟩ := internal_power M hM hT.powerSet hdM + obtain ⟨g,hgM,hg⟩ := internal_checkGraph M d q t hM hT.pairing hT.union hT.powerSet hS + hT.replacement.finitePrefix hdM hqM ht hd hq ZFSet.omega hωd + let r := iterUnion 2 g + have hrM : r ∈ M := iterUnion_mem M hM hT.union hgM 2 + have hn (n : ℕ) : natSet n ∈ hull d q ZFSet.omega := + hull_transitive d q ZFSet.omega hd _ (self_mem_hull d q hωd) _ ((mem_omega _).mpr ⟨n,rfl⟩) + have hpair (n : ℕ) (v : ZFSet.{0}) : + ZFSet.pair (natSet n) v ∈ g ↔ v = checkedCode t (natSet n) := by + rw [hg.mem_iff] + constructor + · rintro ⟨w,_,hp⟩ + obtain ⟨he,hv⟩ := ZFSet.pair_inj.mp hp + exact he.symm ▸ hv + · intro hv + exact ⟨natSet n,hn n,congrArg (ZFSet.pair (natSet n)) hv⟩ + have hv (n : ℕ) : checkedCode t (natSet n) ∈ r := + second_mem_doubleUnion ((hpair n _).mpr rfl) + let e := cons ZFSet.omega (cons r (fun _ => g)) + let φ : Formula := .existsMem 1 (.existsMem 3 + (.conj (.orderedPair 2 1 0) (.pairMem 1 0 5))) + have he : ∀ i, e i ∈ M := by intro i; rcases i with _|_|i; exact hω; exact hrM; exact hgM + have hφ (z : ZFSet.{0}) : φ.Eval (cons z e) ↔ + z ∈ orbitGraph (fun n => checkedCode t (natSet n)) := by + simp only [φ,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem,cons_zero,cons_succ,e] + constructor + · rintro ⟨n,hn,v,_,hz,hnv⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + exact (mem_orbitGraph _ z).mpr ⟨n,by rw [hz,(hpair n v).mp hnv]⟩ + · intro hz + obtain ⟨n,rfl⟩ := (mem_orbitGraph _ z).mp hz + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,_,hv n,rfl,(hpair n _).mpr rfl⟩ + have hh := sep_mem M hM hS φ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hS hω hrM) + have heq : (ZFSet.prod ZFSet.omega r).sep (fun z => φ.Eval (cons z e)) = + orbitGraph (fun n => checkedCode t (natSet n)) := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,hφ] + exact ⟨And.right,fun hz => ⟨ZFSet.mem_prod.mpr ((orbitGraph_function r _ hv).1 z hz),hz⟩⟩ + exact heq ▸ hh + +end TuringRigidity.InternalNaturalCheckSequence + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNaturalRelationReal.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNaturalRelationReal.lean new file mode 100644 index 0000000000000000000000000000000000000000..033cec75563db43bf19c454b174488c6bef166cf --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNaturalRelationReal.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DegreeRigidity.SetModels.ColumnSetFormula +import OAI.Computability.DegreeRigidity.Representation.SourceTDependentChoice + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse +universe u + +noncomputable def naturalRelationReal (G : ZFSet.{u}) : Oracle := fun v => by + classical + exact decide (ZFSet.pair (natSet (Nat.unpair v).1) (natSet (Nat.unpair v).2) ∈ G) + +theorem naturalRelationReal_pair (G : ZFSet.{u}) (n k : ℕ) : + naturalRelationReal G (Nat.pair n k) = true ↔ ZFSet.pair (natSet n) (natSet k) ∈ G := by + classical + simp [naturalRelationReal] + +namespace Formula +def naturalRelationBit (o Q G v : ℕ) : Formula := .existsMem o (.existsMem (o+1) + (.conj (naturalPair (o+2) (Q+2) 1 0 (v+2)) (.pairMem 1 0 (G+2)))) + +theorem naturalRelationBit_spec (o Q G v : ℕ) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) + (N K : ℕ) (hv : e v = natSet (Nat.pair N K)) : + (naturalRelationBit o Q G v).Eval e ↔ ZFSet.pair (natSet N) (natSet K) ∈ e G := by + simp only [naturalRelationBit,Formula.Eval,eval_pairMem,cons_succ,cons_zero] + rw [ho] + constructor + · rintro ⟨n,hn,k,hk,hp,hg⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + obtain ⟨k,rfl⟩ := (mem_omega k).mp hk + have hp' := (naturalPair_spec (o+2) (Q+2) 1 0 (v+2) + (cons (natSet k) (cons (natSet n) e)) ho hQ n k rfl rfl).mp hp + have hnk : Nat.pair N K = Nat.pair n k := natSet_injective (hv.symm.trans hp') + have he := congrArg Nat.unpair hnk + simp only [Nat.unpair_pair,Prod.mk.injEq] at he + obtain ⟨rfl,rfl⟩ := he + exact hg + · intro h + exact ⟨natSet N,(mem_omega _).mpr ⟨N,rfl⟩,natSet K,(mem_omega _).mpr ⟨K,rfl⟩, + (naturalPair_spec (o+2) (Q+2) 1 0 (v+2) + (cons (natSet K) (cons (natSet N) e)) ho hQ N K rfl rfl).mpr hv,h⟩ +end Formula + +theorem sourceT_naturalRelationReal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {G : ZFSet.{u}} (hG : G ∈ M) : naturalRelationReal G ∈ modelReals M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω + let e := cons ZFSet.omega (cons Q (fun _ => G)) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hQM + exact hG + let B := ZFSet.sep (fun v => (Formula.naturalRelationBit 1 2 3 0).Eval (cons v e)) ZFSet.omega + have hBM : B ∈ M := sep_mem M hM hS _ e he hω + have hb (v : ℕ) : natSet.{u} v ∈ B ↔ naturalRelationReal G v = true := by + obtain ⟨⟨n,k⟩,rfl⟩ := Nat.pairEquiv.surjective v + change natSet (Nat.pair n k) ∈ B ↔ naturalRelationReal G (Nat.pair n k) = true + rw [naturalRelationReal_pair] + change natSet (Nat.pair n k) ∈ ZFSet.sep _ ZFSet.omega ↔ _ + rw [ZFSet.mem_sep,Formula.naturalRelationBit_spec 1 2 3 0 + (cons (natSet (Nat.pair n k)) e) rfl hQ n k rfl] + exact and_iff_right ((mem_omega _).mpr ⟨Nat.pair n k,rfl⟩) + have hEq : realCode (naturalRelationReal G) = B := by + apply ZFSet.ext; intro x + by_cases hx : x ∈ ZFSet.omega.{u} + · obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + rw [natSet_mem_realCode,hb] + · exact ⟨fun h => False.elim (hx (realCode_subset _ h)),fun h => False.elim (hx (ZFSet.mem_sep.mp h).1)⟩ + change realCode _ ∈ M + rw [hEq]; exact hBM + +theorem sourceT_natural_descent_real (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {r : ZFSet.{u}} (hr : r ∈ M) (hon : On ZFSet.omega r) + (hw : ¬ WellFounded (Rel ZFSet.omega r)) : + ∃ f : ℕ → ℕ, ∃ A ∈ modelReals M, + (∀ n k, A (Nat.pair n k) = true ↔ k = f n) ∧ + ∀ n, ZFSet.pair (natSet (f (n+1))) (natSet (f n)) ∈ r := by + classical + obtain ⟨a,ha,hAM,hstep⟩ := sourceT_internal_descent M hM hT (sourceT_omega_mem M hM hT) hr hon hw + have hn (n : ℕ) : ∃ k, a n = natSet k := (mem_omega _).mp (ha n) + let f (n : ℕ) := (hn n).choose + have hf (n : ℕ) : a n = natSet (f n) := (hn n).choose_spec + refine ⟨f,naturalRelationReal (orbitGraph a),sourceT_naturalRelationReal M hM hT hAM,?_,?_⟩ + · intro n k + rw [naturalRelationReal_pair,orbitGraph_pair,hf n] + exact ⟨fun h => natSet_injective h,fun h => congrArg natSet h⟩ + · intro n + rw [←hf (n+1),←hf n] + exact hstep n + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNiceName.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNiceName.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ff0c1352bc079391cf3104038e1772eff2248d5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalNiceName.lean @@ -0,0 +1,78 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalNaturalCheckSequence + +namespace OAI + +namespace TuringRigidity.InternalNiceName +open TransitiveNameModel BoundedSetTheory RecursiveNames CountableForcing +variable {c : ZFSet.{0}} [Top (Conditions c)] + +noncomputable def nice (E : ℕ → ZFSet.{0}) : Name (Conditions c) := + .mk (Σ n : ℕ, {p : Conditions c // label c p ∈ E n}) + (fun i => Name.check (natSet i.1)) (fun i => i.2.val) + +theorem mem_encode_nice (E : ℕ → ZFSet.{0}) (z : ZFSet.{0}) : + z ∈ (nice E : Name (Conditions c)).encode (label c) ↔ + ∃ n, ∃ p : Conditions c, label c p ∈ E n ∧ + z = ZFSet.pair (checkedCode (label c ⊤) (natSet n)) (label c p) := by + simp only [nice,Name.encode,ZFSet.mem_range,encode_check] + exact ⟨fun ⟨⟨n,p,hp⟩,hz⟩ => ⟨n,p,hp,hz.symm⟩, + fun ⟨n,p,hp,hz⟩ => ⟨⟨n,p,hp⟩,hz.symm⟩⟩ + +theorem nice_internal (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (E : ℕ → ZFSet.{0}) + (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hEgraph : orbitGraph E ∈ M) : + (nice E : Name (Conditions c)).encode (label c) ∈ M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + obtain ⟨Q,hQM,hQ⟩ := internal_power M hM hT.powerSet hc + have hEQ : ∀ n, E n ∈ Q := fun n => (hQ _).mpr (hE n) + let B := orbitGraph (fun n => checkedCode (label c ⊤) (natSet n)) + have hBM : B ∈ M := InternalNaturalCheckSequence.natural_check_sequence M _ hM hT + (hM c hc _ (label_mem c ⊤)) + let r := iterUnion 2 B + have hrM := iterUnion_mem M hM hT.union hBM 2 + have hr (n : ℕ) : checkedCode (label c ⊤) (natSet n) ∈ r := + second_mem_doubleUnion ((orbitGraph_pair _ n _).mpr rfl) + let e := cons ZFSet.omega (cons Q (cons r (cons c (cons B (fun _ => orbitGraph E))))) + let φ : BoundedSetTheory.Formula := .existsMem 1 (.existsMem 3 (.existsMem 5 (.existsMem 7 + (.conj (.orderedPair 4 1 0) (.conj (.pairMem 3 1 9) + (.conj (.pairMem 3 2 10) (.member 0 2))))))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|_|i + exact hω; exact hQM; exact hrM; exact hc; exact hBM; exact hEgraph + have hφ (z : ZFSet.{0}) : φ.Eval (cons z e) ↔ + z ∈ (nice E : Name (Conditions c)).encode (label c) := by + simp only [φ,BoundedSetTheory.Formula.Eval,BoundedSetTheory.Formula.eval_orderedPair,BoundedSetTheory.Formula.eval_pairMem,cons_zero,cons_succ,e] + rw [mem_encode_nice] + constructor + · rintro ⟨n,hn,H,_,v,_,p,hp,hz,hnv,hnH,hpH⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + obtain ⟨p,rfl⟩ := label_surjective c hp + have hv := (orbitGraph_pair _ n v).mp hnv + have hH := (orbitGraph_pair E n H).mp hnH + exact ⟨n,p,hH ▸ hpH,by rw [hz,hv]⟩ + · rintro ⟨n,p,hp,rfl⟩ + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,E n,hEQ n,_,hr n,_,label_mem c p,rfl, + (orbitGraph_pair _ n _).mpr rfl,(orbitGraph_pair E n _).mpr rfl,hp⟩ + have hs := sep_mem M hM hS φ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hS hrM hc) + have heq : (ZFSet.prod r c).sep (fun z => φ.Eval (cons z e)) = + (nice E : Name (Conditions c)).encode (label c) := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,hφ] + refine ⟨And.right,fun hz => ⟨?_,hz⟩⟩ + obtain ⟨n,p,_,rfl⟩ := (mem_encode_nice E z).mp hz + exact ZFSet.mem_prod.mpr ⟨_,hr n,_,label_mem c p,rfl⟩ + exact heq ▸ hs + +theorem mem_val_nice (E : ℕ → ZFSet.{0}) (G : Set (Conditions c)) (hG : ⊤ ∈ G) + (x : ZFSet.{0}) : x ∈ (nice E : Name (Conditions c)).val G ↔ + ∃ n, ∃ p ∈ G, label c p ∈ E n ∧ natSet n = x := by + rw [nice,Name.mem_val] + simp only [Name.val_check _ hG] + exact ⟨fun ⟨⟨n,p,hp⟩,hpG,hx⟩ => ⟨n,p,hpG,hp,hx⟩, + fun ⟨n,p,hpG,hp,hx⟩ => ⟨⟨n,p,hp⟩,hpG,hx⟩⟩ + +end TuringRigidity.InternalNiceName + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalOrderIsoTransport.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalOrderIsoTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..cba0b65ddbccfd6d923ff57e0dc3a626e3beed63 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalOrderIsoTransport.lean @@ -0,0 +1,108 @@ +import OAI.Computability.DegreeRigidity.SetModels.DenseInclusionExtension +import OAI.Computability.DegreeRigidity.Representation.AutomorphismName + +namespace OAI + +namespace TuringRigidity.InternalOrderIsoTransport +open TransitiveNameModel BoundedSetTheory CountableForcing +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +noncomputable def imageSet (b f g : ZFSet.{0}) : ZFSet.{0} := + b.sep (fun y => ∃ x ∈ g, ZFSet.pair x y ∈ f) + +noncomputable def preimageSet (a f k : ZFSet.{0}) : ZFSet.{0} := + a.sep (fun x => ∃ y ∈ k, ZFSet.pair x y ∈ f) + +theorem imageSet_mem (M b f g : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hb : b ∈ M) (hf : f ∈ M) (hg : g ∈ M) : imageSet b f g ∈ M := by + let e := cons g (fun _ => f) + have he : ∀ i, e i ∈ M := by intro i; cases i; exact hg; exact hf + simpa only [imageSet,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded (.existsMem 1 (.pairMem 0 1 3)) e he hb + +theorem preimageSet_mem (M a f k : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) (hf : f ∈ M) (hk : k ∈ M) : preimageSet a f k ∈ M := by + let e := cons k (fun _ => f) + have he : ∀ i, e i ∈ M := by intro i; cases i; exact hk; exact hf + simpa only [preimageSet,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded (.existsMem 1 (.pairMem 1 0 3)) e he ha + +theorem map_ground_generic (M a b f : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) (hb : b ∈ M) (hf : f ∈ M) (e : Conditions a ≃o Conditions b) + (he : ∀ p q, ZFSet.pair (label a p) (label b q) ∈ f ↔ q = e p) + (G : GenericFilter (Conditions a)) (hG : AtomicForcing.GroundGeneric M G) : + AtomicForcing.GroundGeneric M (AutomorphismName.mapFilter e G) := by + intro D hD hd + let E := DenseInclusionExtension.restrictSet b D + have hE := DenseInclusionExtension.restrictSet_mem M b D hM hT hb hD + have hden : Dense {p : Conditions a | label a p ∈ preimageSet a f E} := by + intro p + obtain ⟨q,hqp,hqD⟩ := hd (e p) + refine ⟨e.symm q,by simpa using e.symm.monotone hqp,?_⟩ + exact ZFSet.mem_sep.mpr ⟨label_mem a _,label b q,ZFSet.mem_sep.mpr ⟨label_mem b q,hqD⟩,(he _ _).mpr (e.apply_symm_apply q).symm⟩ + obtain ⟨p,hp,hpD⟩ := hG (preimageSet a f E) (preimageSet_mem M a f E hM hT ha hf hE) hden + obtain ⟨_,y,hyD,hpy⟩ := ZFSet.mem_sep.mp hpD + obtain ⟨hyb,hyD⟩ := ZFSet.mem_sep.mp hyD + obtain ⟨q,rfl⟩ := label_surjective b hyb + obtain rfl := (he p q).mp hpy + exact ⟨e p,by simpa [AutomorphismName.mapFilter] using hp,hyD⟩ + +theorem mapFilterSet_eq (a b f : ZFSet.{0}) (e : Conditions a ≃o Conditions b) + (he : ∀ p q, ZFSet.pair (label a p) (label b q) ∈ f ↔ q = e p) + (G : GenericFilter (Conditions a)) : + genericFilterSet b (AutomorphismName.mapFilter e G).carrier = + imageSet b f (genericFilterSet a G.carrier) := by + apply ZFSet.ext; intro y + constructor + · intro hy + obtain ⟨q,hq,rfl⟩ := (mem_genericFilterSet _ _ y).mp hy + exact ZFSet.mem_sep.mpr ⟨label_mem b q,label a (e.symm q), + (mem_genericFilterSet _ _ _).mpr ⟨e.symm q,hq,rfl⟩,(he _ _).mpr (e.apply_symm_apply q).symm⟩ + · intro hy + obtain ⟨hyb,x,hx,hxy⟩ := ZFSet.mem_sep.mp hy + obtain ⟨q,rfl⟩ := label_surjective b hyb + obtain ⟨p,hp,rfl⟩ := (mem_genericFilterSet _ _ x).mp hx + obtain rfl := (he p q).mp hxy + exact (mem_genericFilterSet _ _ _).mpr ⟨e p,by simpa [AutomorphismName.mapFilter] using hp,rfl⟩ + +theorem originalFilterSet_eq (a b f : ZFSet.{0}) (e : Conditions a ≃o Conditions b) + (he : ∀ p q, ZFSet.pair (label a p) (label b q) ∈ f ↔ q = e p) + (G : GenericFilter (Conditions a)) : + genericFilterSet a G.carrier = + preimageSet a f (genericFilterSet b (AutomorphismName.mapFilter e G).carrier) := by + apply ZFSet.ext; intro x + constructor + · intro hx + obtain ⟨p,hp,rfl⟩ := (mem_genericFilterSet _ _ x).mp hx + exact ZFSet.mem_sep.mpr ⟨label_mem a p,label b (e p), + (mem_genericFilterSet _ _ _).mpr ⟨e p,by simpa [AutomorphismName.mapFilter] using hp,rfl⟩, + (he p (e p)).mpr rfl⟩ + · intro hx + obtain ⟨hxa,y,hy,hxy⟩ := ZFSet.mem_sep.mp hx + obtain ⟨p,rfl⟩ := label_surjective a hxa + obtain ⟨q,hq,rfl⟩ := (mem_genericFilterSet _ _ y).mp hy + obtain rfl := (he p q).mp hxy + exact (mem_genericFilterSet _ _ _).mpr ⟨p,by simpa [AutomorphismName.mapFilter] using hq,rfl⟩ + +theorem extension_eq (M a b f : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) (hb : b ∈ M) (hf : f ∈ M) (e : Conditions a ≃o Conditions b) + (he : ∀ p q, ZFSet.pair (label a p) (label b q) ∈ f ↔ q = e p) + (G : GenericFilter (Conditions a)) (hG : AtomicForcing.GroundGeneric M G) : + genericExtensionSet M b (AutomorphismName.mapFilter e G).carrier = genericExtensionSet M a G.carrier := by + let K := AutomorphismName.mapFilter e G + have hK := map_ground_generic M a b f hM hT ha hb hf e he G hG + obtain ⟨hN,hTN,hMN,hgN⟩ := RegularTreeExtension.extension_properties M a hM hT ha G hG + obtain ⟨hV,hTV,hMV,hkV⟩ := RegularTreeExtension.extension_properties M b hM hT hb K hK + have hkN : genericFilterSet b K.carrier ∈ genericExtensionSet M a G.carrier := by + rw [mapFilterSet_eq a b f e he G] + exact imageSet_mem _ b f _ hN hTN (hMN hb) (hMN hf) hgN + have hgV : genericFilterSet a G.carrier ∈ genericExtensionSet M b K.carrier := by + rw [originalFilterSet_eq a b f e he G] + exact preimageSet_mem _ a f _ hV hTV (hMV ha) (hMV hf) hkV + apply ZFSet.ext; intro x + exact ⟨fun hx => InternalNameEvaluation.extension_subset M _ hN hTN hMN K.carrier hkN hx, + fun hx => InternalNameEvaluation.extension_subset M _ hV hTV hMV G.carrier hgV hx⟩ + +end TuringRigidity.InternalOrderIsoTransport + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalOrdinalCodes.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalOrdinalCodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..45376032e07661ebc0b9cb3cfd179d5075079fe5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalOrdinalCodes.lean @@ -0,0 +1,56 @@ +import OAI.Computability.DegreeRigidity.Constructibility.InternalOmegaPower +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalSumClosure +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalCodeDomains + +namespace OAI + +namespace TuringRigidity.OrdinalCoding +open TransitiveNameModel BoundedSetTheory OrdinalArithmetic RelativeConstructible +universe u + +theorem pairCode_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (x y : Ordinal.{u}) (hx : x.toZFSet ∈ M) (hy : y.toZFSet ∈ M) : + (pairCode x y).toZFSet ∈ M := by + unfold pairCode + split + · exact (ordinal_add_internal M hM hT _ _ + (ordinal_omega_opow_internal M hM hT _ (internal_ordinal_succ M hM hT x hx)) + (ordinal_omega_opow_internal M hM hT y hy)).1 + · exact (ordinal_add_internal M hM hT _ _ + (ordinal_mul_two_internal M hM hT _ + (ordinal_omega_opow_internal M hM hT _ (internal_ordinal_succ M hM hT y hy))) + (ordinal_omega_opow_internal M hM hT x hx)).1 + +theorem vectorCode_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {n : ℕ} (v : Fin n → Ordinal.{u}) (hv : ∀ i, (v i).toZFSet ∈ M) : + (vectorCode v).toZFSet ∈ M := by + induction n with + | zero => + simpa only [vectorCode,zero_add] using internal_ordinal_succ M hM hT 0 (internal_ordinal_zero M hM hT) + | succ n ih => + exact pairCode_internal M hM hT _ _ (hv 0) (ih _ (fun i => hv i.succ)) + +theorem paddedCode_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hv : ∀ i, (v i).toZFSet ∈ M) (hβ : β.toZFSet ∈ M) : + (paddedCode v β).toZFSet ∈ M := + pairCode_internal M hM hT _ _ hβ (vectorCode_internal M hM hT v hv) + +theorem padded_height_index_from_inputs (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {n : ℕ} (v : Fin n → Ordinal.{u}) (β : Ordinal.{u}) + (hv : ∀ i, (v i).toZFSet ∈ M) (hβ : β.toZFSet ∈ M) : + (heightDomainIndex (paddedCode v β)).toZFSet ∈ M := + padded_height_index_internal M hM hT v β (paddedCode_internal M hM hT v β hv hβ) + +theorem internal_padded_codes_cofinal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {n : ℕ} (v : Fin n → Ordinal.{u}) (hv : ∀ i, (v i).toZFSet ∈ M) + (β : Ordinal.{u}) (hβ : β.toZFSet ∈ M) : + ∃ a : Ordinal.{u}, a.toZFSet ∈ M ∧ β < a ∧ paddedDecode n a = v ∧ + (∀ i, v i < a) ∧ (heightDomainIndex a).toZFSet ∈ M := + ⟨paddedCode v β,paddedCode_internal M hM hT v β hv hβ, + padding_lt_paddedCode v β,paddedDecode_paddedCode v β,entry_lt_paddedCode v β, + padded_height_index_from_inputs M hM hT v β hv hβ⟩ + +end TuringRigidity.OrdinalCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalOrdinalEnumeration.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalOrdinalEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..80767f99e4cc3b8036ae802c38d7bc161c13b535 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalOrdinalEnumeration.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DegreeRigidity.SetModels.ChoiceTraceExtension + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationCollapse +universe u +namespace InternalWellOrder + +theorem internal_ordinal_enumeration (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) + {a : ZFSet.{u}} (ha : a ∈ M) : + ∃ δ ∈ M, δ.IsOrdinal ∧ ∃ F ∈ M, TransitiveNameModel.FunctionGraph δ a F ∧ + (∀ x ∈ a, ∃ i ∈ δ, ZFSet.pair i x ∈ F) ∧ + (∀ i ∈ δ, ∀ j ∈ δ, ∀ x, ZFSet.pair i x ∈ F → ZFSet.pair j x ∈ F → i = j) := by + classical + obtain ⟨q,hq,s,hsM,hs,hqdef⟩ := internal_selector M hM hPow hS.bounded hAC ha + obtain ⟨α,hαM,hα,hHartogs⟩ := internal_hartogs M a hM hP hU hPow hS hR hI ha + have hαT : Transitive α := fun i hi j hj => hα.subset_of_mem hi hj + obtain ⟨F,hF,htrace,hmax⟩ := internal_maximal_trace M hM hP hU hPow hS.bounded hαM ha hq hsM hαT hs + have hfun := htrace.functional hαT hs + have hmissing : ∃ i ∈ α, ¬ ∃ x ∈ a, ZFSet.pair i x ∈ F := by + by_contra hn + have htotal : ∀ i ∈ α, ∃ x ∈ a, ZFSet.pair i x ∈ F := by + intro i hi; exact Classical.byContradiction (fun h => hn ⟨i,hi,h⟩) + have hfg : TransitiveNameModel.FunctionGraph α a F := by + refine ⟨htrace.shape,?_⟩ + intro i hi + obtain ⟨x,hx,hix⟩ := htotal i hi + exact ⟨x,hx,hix,fun y _ hiy => hfun i y x hiy hix⟩ + obtain ⟨v,hv,hva⟩ := FunctionGraph.exists_presentation hfg + apply hHartogs F hF v hv hva + intro i hi j hj he + have hip := (hv.pair_iff i (v i)).mpr ⟨hi,rfl⟩ + have hjp := (hv.pair_iff j (v j)).mpr ⟨hj,rfl⟩ + rw [← he] at hjp + exact htrace.injective hα hs i j (v i) hip hjp + have minimal (i : ZFSet.{u}) : i ∈ α → (¬ ∃ x ∈ a, ZFSet.pair i x ∈ F) → + ∃ j ∈ α, (¬ ∃ x ∈ a, ZFSet.pair j x ∈ F) ∧ + ∀ k ∈ j, ∃ x ∈ a, ZFSet.pair k x ∈ F := by + induction i using ZFSet.inductionOn with + | h i ih => + intro hi hmiss + by_cases hex : ∃ j ∈ i, ¬ ∃ x ∈ a, ZFSet.pair j x ∈ F + · obtain ⟨j,hji,hjmiss⟩ := hex + exact ih j hji (hα.subset_of_mem hi hji) hjmiss + · refine ⟨i,hi,hmiss,?_⟩ + intro j hji + exact Classical.byContradiction (fun h => hex ⟨j,hji,h⟩) + obtain ⟨i,hi,hmiss⟩ := hmissing + obtain ⟨i,hi,hmiss,hprev⟩ := minimal i hi hmiss + have hiM := hM α hαM i hi + have hiT : Transitive i := fun j hj k hk => (hα.mem hi).subset_of_mem hj hk + have hdom : ∀ j y, ZFSet.pair j y ∈ F → j ∈ i := htrace.domain_before hα hi hmiss + have hres := residual_mem M hM hS.bounded ha hF hiM + have hrem := residual_remaining a F i + have hempty : ¬ ∃ x, x ∈ residual a F i := by + intro hex + have hrq : residual a F i ∈ q := (hqdef _).mpr ⟨hres,hrem.1,hex⟩ + obtain ⟨x,hxr,hrx,_⟩ := hs.2 _ hrq + have hxa := hrem.1 hxr + have hpair := orderedPair_mem M hM hP hiM (hM a ha x hxa) + have hnew := binary_union_mem M hM hP hU hF (singleton_mem M hM hP hpair) + have hnewtrace := htrace.adjoin hi hiT hxa hrq hrem hrx hprev hdom + have hnewsub := hmax _ hnew hnewtrace + exact hmiss ⟨x,hxa,hnewsub (ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_singleton.mpr rfl)))⟩ + refine ⟨i,hiM,hα.mem hi,F,hF,?_,?_,?_⟩ + · refine ⟨?_,?_⟩ + · intro z hz + obtain ⟨j,_,x,hx,rfl⟩ := htrace.shape z hz + exact ⟨j,hdom j x hz,x,hx,rfl⟩ + · intro j hj + obtain ⟨x,hx,hjx⟩ := hprev j hj + exact ⟨x,hx,hjx,fun y _ hjy => hfun j y x hjy hjx⟩ + · intro x hx + exact Classical.byContradiction (fun hn => hempty ⟨x,(hrem.2 x hx).mpr hn⟩) + · intro j _ k _ x hjx hkx + exact htrace.injective hα hs j k x hjx hkx + +end InternalWellOrder +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalOrdinalSubset.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalOrdinalSubset.lean new file mode 100644 index 0000000000000000000000000000000000000000..e44d5d4fef32f8f08fc3445c030c12a28df97f88 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalOrdinalSubset.lean @@ -0,0 +1,86 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalOrderType +import OAI.Computability.DegreeRigidity.Representation.SourceTheory + +namespace OAI + +namespace TuringRigidity.InternalOrdinalSubset +open TransitiveNameModel BoundedSetTheory RelationCollapse + +noncomputable def memberOrder (D : ZFSet.{0}) : ZFSet.{0} := + (ZFSet.prod D D).sep (fun z => ∃ x ∈ D, ∃ y ∈ D, z = ZFSet.pair x y ∧ x ∈ y) + +theorem pair_memberOrder (D x y : ZFSet.{0}) : + ZFSet.pair x y ∈ memberOrder D ↔ x ∈ D ∧ y ∈ D ∧ x ∈ y := by + simp only [memberOrder,ZFSet.mem_sep] + constructor + · rintro ⟨_,x',hx,y',hy,he,h⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hx,hy,h⟩ + · rintro ⟨hx,hy,h⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨hx,hy⟩,x,hx,y,hy,rfl,h⟩ + +theorem memberOrder_mem (M D : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hD : D ∈ M) : memberOrder D ∈ M := by + simpa only [memberOrder,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ] using + sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.existsMem 2 (.conj (.orderedPair 2 1 0) (.member 1 0)))) + (fun _ => D) (fun _ => hD) + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hD hD) + +theorem memberOrder_wf (D : ZFSet.{0}) : WellFounded (Rel D (memberOrder D)) := + ZFSet.mem_wf.mono (fun _ _ h => ((pair_memberOrder D _ _).mp h.2).2.2) + +theorem memberOrder_transitive (K D : ZFSet.{0}) (hK : K.IsOrdinal) (hD : D ⊆ K) : + TransitiveOn D (memberOrder D) := by + intro x hx y _ z hz hxy hyz + exact (pair_memberOrder D x z).mpr ⟨hx,hz,(hK.mem (hD hz)).mem_trans + ((pair_memberOrder D x y).mp hxy).2.2 ((pair_memberOrder D y z).mp hyz).2.2⟩ + +theorem memberOrder_total (K D : ZFSet.{0}) (hK : K.IsOrdinal) (hD : D ⊆ K) : + TotalOn D (memberOrder D) := by + intro x hx y hy + rcases (hK.mem (hD hx)).mem_trichotomous (hK.mem (hD hy)) with h|h|h + · exact Or.inr (Or.inl ((pair_memberOrder D x y).mpr ⟨hx,hy,h⟩)) + · exact Or.inl h + · exact Or.inr (Or.inr ((pair_memberOrder D y x).mpr ⟨hy,hx,h⟩)) + +theorem value_subset (K D x : ZFSet.{0}) (hK : K.IsOrdinal) (hD : D ⊆ K) (hx : x ∈ D) : + value D (memberOrder D) (memberOrder_wf D) x ⊆ x := by + induction x using (memberOrder_wf D).induction with + | h x ih => + intro z hz + obtain ⟨y,hy,hyx,rfl⟩ := (mem_value D _ _ x z).mp hz + have hv := value_isOrdinal (memberOrder_wf D) (memberOrder_transitive K D hK hD) y hy + have hs := (hv.subset_iff_eq_or_mem (hK.mem (hD hy))).mp (ih y ⟨hy,hyx⟩ hy) + have hyx' := ((pair_memberOrder D y x).mp hyx).2.2 + exact hs.elim (fun h => h.symm ▸ hyx') + (fun h => (hK.mem (hD hx)).mem_trans h hyx') + +theorem range_subset (K D : ZFSet.{0}) (hK : K.IsOrdinal) (hD : D ⊆ K) : + ordinalRange D (memberOrder D) (memberOrder_wf D) ⊆ K := by + intro z hz + obtain ⟨x,hx,rfl⟩ := (mem_ordinalRange D _ _ z).mp hz + exact (value_isOrdinal (memberOrder_wf D) (memberOrder_transitive K D hK hD) x hx).mem_of_subset_of_mem + hK (value_subset K D x hK hD hx) (hD hx) + +theorem internal_subset_orderType (M K D : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : K.IsOrdinal) (hD : D ∈ M) (hDK : D ⊆ K) : + ∃ J ∈ M, J.IsOrdinal ∧ J ⊆ K ∧ ∃ f ∈ M, FunctionGraph D J f ∧ + (∀ x ∈ D, ∀ x' ∈ D, ∀ y ∈ J, ZFSet.pair x y ∈ f → ZFSet.pair x' y ∈ f → x = x') ∧ + (∀ y ∈ J, ∃ x ∈ D, ZFSet.pair x y ∈ f) := by + let wf := memberOrder_wf D + have ht := memberOrder_transitive K D hK hDK + obtain ⟨hJ,f,hf,hg,honto⟩ := orderType_internal M D (memberOrder D) hM hT.pairing hT.union + hT.powerSet hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hD + (memberOrder_mem M D hM hT hD) wf ht + refine ⟨(orderType D (memberOrder D) wf).toZFSet,hJ,ZFSet.isOrdinal_toZFSet _,?_,f,hf,?_,?_,honto⟩ + · rw [orderType_toZFSet wf ht] + exact range_subset K D hK hDK + · exact ⟨hg.2.2.1,hg.2.2.2.1⟩ + · intro x hx x' hx' y hy hxy hx'y + apply value_injective wf (total_extensional wf (memberOrder_total K D hK hDK)) x hx x' hx' + exact (hg.correct wf x hx y hy hxy).symm.trans (hg.correct wf x' hx' y hy hx'y) + +end TuringRigidity.InternalOrdinalSubset + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalPositiveNameFamily.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalPositiveNameFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b77414534d0b989c9c2193d51d542a0d387f5a0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalPositiveNameFamily.lean @@ -0,0 +1,72 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalNaturalCheckSequence +import OAI.Computability.DegreeRigidity.SetModels.InternalSubsetSequence +import OAI.Computability.DegreeRigidity.Syntax.AtomicDefinability + +namespace OAI + +namespace TuringRigidity.InternalPositiveNameFamily +open TransitiveNameModel BoundedSetTheory RecursiveNames AtomicForcing +variable {c : ZFSet.{0}} [Preorder (Conditions c)] [Top (Conditions c)] + +noncomputable def positive (τ : Name (Conditions c)) (n : ℕ) : ZFSet.{0} := + c.sep (fun p => ∃ q : Conditions c, label c q = p ∧ MemForces (Name.check (natSet n)) τ q) + +theorem label_positive (τ : Name (Conditions c)) (n : ℕ) (p : Conditions c) : + label c p ∈ positive τ n ↔ MemForces (Name.check (natSet n)) τ p := by + rw [positive,ZFSet.mem_sep] + exact ⟨fun ⟨_,q,hq,h⟩ => label_injective c hq ▸ h, + fun h => ⟨label_mem c p,p,rfl,h⟩⟩ + +theorem internal_positive_family (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) {o : ZFSet.{0}} (hoM : o ∈ M) + (ho : ∀ p q : Conditions c, ZFSet.pair (label c p) (label c q) ∈ o ↔ p ≤ q) + (τ : Name (Conditions c)) (hτ : τ.encode (label c) ∈ M) : + orbitGraph (positive τ) ∈ M := by + have hS := hT.separation.finitePrefix.bounded + let B := orbitGraph (fun n => checkedCode (label c ⊤) (natSet n)) + have hBM : B ∈ M := InternalNaturalCheckSequence.natural_check_sequence M _ hM hT + (hM c hc _ (label_mem c ⊤)) + have hrM := iterUnion_mem M hM hT.union hBM 2 + obtain ⟨d,hdM,hd,hboth⟩ := internal_transitive_container M hM hT.pairing hT.union hS + hT.replacement.finitePrefix hT.infinity (pair_mem M hM hT.pairing hrM hτ) + have hrd : iterUnion 2 B ∈ d := hd _ hboth _ (ZFSet.mem_pair.mpr (Or.inl rfl)) + have hτd : τ.encode (label c) ∈ d := hd _ hboth _ (ZFSet.mem_pair.mpr (Or.inr rfl)) + have hn (n : ℕ) : (Name.check (natSet n) : Name (Conditions c)).encode (label c) ∈ d := by + rw [encode_check] + exact hd _ hrd _ (second_mem_doubleUnion ((orbitGraph_pair _ n _).mpr rfl)) + obtain ⟨f,hfM,hf⟩ := internal_atomic_graph M hM hT.pairing hT.union hT.powerSet hS hdM hc hoM + let k := ZFSet.prod d d + have hkM := product_mem M hM hT.pairing hT.union hT.powerSet hS hdM hdM + let e := cons d (cons c (cons k (cons o (cons f (cons B (fun _ => τ.encode (label c))))))) + let φ : BoundedSetTheory.Formula := .existsMem 2 (.conj (.pairMem 2 0 8) + (AtomicFormula.membership 3 4 5 6 7 0 9 1)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|_|_|i + exact hdM; exact hc; exact hkM; exact hoM; exact hfM; exact hBM; exact hτ + have hφ (n : ℕ) (p : Conditions c) : + φ.Eval (cons (label c p) (cons (natSet n) e)) ↔ MemForces (Name.check (natSet n)) τ p := by + simp only [φ,BoundedSetTheory.Formula.Eval,BoundedSetTheory.Formula.eval_pairMem,cons_zero,cons_succ,e] + constructor + · rintro ⟨v,_,hnv,hquery⟩ + have hv := (orbitGraph_pair _ n v).mp hnv + have hv' : v = (Name.check (natSet n) : Name (Conditions c)).encode (label c) := by + rw [encode_check]; exact hv + clear hv + subst v + exact (eval_membership hd ho hf (Name.check (natSet n)) τ (hn n) hτd p + _ 3 4 5 6 7 0 9 1 ⟨rfl,rfl,rfl,rfl,rfl,rfl,rfl,rfl⟩).mp hquery + · intro h + refine ⟨(Name.check (natSet n) : Name (Conditions c)).encode (label c),hn n,?_,?_⟩ + · apply (orbitGraph_pair _ n _).mpr + exact encode_check _ _ + · exact (eval_membership hd ho hf (Name.check (natSet n)) τ (hn n) hτd p + _ 3 4 5 6 7 0 9 1 ⟨rfl,rfl,rfl,rfl,rfl,rfl,rfl,rfl⟩).mpr h + apply InternalSubsetSequence.subset_sequence M c hM hT hc φ e he (positive τ) + (fun n p hp => (ZFSet.mem_sep.mp hp).1) + intro n p hp + obtain ⟨p,rfl⟩ := label_surjective c hp + exact (hφ n p).trans (label_positive τ n p).symm + +end TuringRigidity.InternalPositiveNameFamily + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalPresentationEnumeration.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalPresentationEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..abf5ca9bc907280b6850740dda6c50275cb28a9b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalPresentationEnumeration.lean @@ -0,0 +1,62 @@ +import OAI.Computability.DegreeRigidity.SetModels.PresentationEnumeration + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel EncodedForcing +universe u + +theorem internal_presentationEnumeration (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ A : Oracle, realCode A ∈ R ↔ A ∈ modelReals M) + (hRd : ∀ w ∈ R, ∃ B : Oracle, realCode B = w) + {H : Oracle} (hH : H ∈ modelReals M) : presentationEnumeration R H ∈ M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + have hz : natSet.{u} 0 ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨0,rfl⟩) + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω + obtain ⟨φ,hφ⟩ := degree_equality_bounded.{u} + have hφ' : DegreeEqualityFormula.{u} φ := hφ + have hc : ∀ n, realCode (columns H n) ∈ R := + fun n => (hR _).mpr (sourceT_real_column M hM hT hH n) + let I := presentationSet R H + have hIM : I ∈ M := internal_presentationSet M hM hT R hRM hR hRd hH + have hsub : presentationEnumeration R H ⊆ ZFSet.prod ZFSet.omega I := by + intro z hz + exact ZFSet.mem_prod.mpr ((presentationEnumeration_function R H).1 z hz) + let e := cons ZFSet.omega (cons Q (cons (natSet 0) (cons R (cons (realCode H) (fun _ => I))))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hQM + rcases i with _|i; exact hz + rcases i with _|i; exact hRM + rcases i with _|i; exact hH + exact hIM + let E := ZFSet.sep (fun z => (Formula.enumerationMember φ 1 2 3 4 5 6 0).Eval (cons z e)) + (ZFSet.prod ZFSet.omega I) + have hEM : E ∈ M := sep_mem M hM hS _ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hS hω hIM) + have hE : E = presentationEnumeration R H := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,Formula.enumerationMember_spec hφ' 1 2 3 4 5 6 0 (cons z e) rfl hQ rfl hRd H rfl hc rfl] + exact ⟨And.right,fun h => ⟨hsub h,h⟩⟩ + rw [←hE] + exact hEM + +theorem internal_presentation_countable (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ A : Oracle, realCode A ∈ R ↔ A ∈ modelReals M) + (hRd : ∀ w ∈ R, ∃ B : Oracle, realCode B = w) + {H : Oracle} (hH : H ∈ modelReals M) : + presentationSet R H ∈ M ∧ ∃ E ∈ M, + TransitiveNameModel.FunctionGraph ZFSet.omega (presentationSet R H) E ∧ + ∀ D ∈ presentationSet R H, ∃ x ∈ ZFSet.omega, ZFSet.pair x D ∈ E := + ⟨internal_presentationSet M hM hT R hRM hR hRd hH, + presentationEnumeration R H,internal_presentationEnumeration M hM hT R hRM hR hRd hH, + presentationEnumeration_function R H,presentationEnumeration_onto R H⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalPrimitiveGraph.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalPrimitiveGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..57e5d09990919a4bb4a98f05bbed79f2cf620d2e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalPrimitiveGraph.lean @@ -0,0 +1,46 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.NaturalPrimitiveRecursion + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace Formula + +def numericalGraph (φ : Formula) : Formula := .existsMem 1 (.existsMem 2 + (.conj (.orderedPair 2 1 0) (unary φ 3 4 1 0))) +end Formula + +theorem internal_primitive_graph (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {f : ℕ → ℕ} (hf : Nat.Primrec f) : + ∃ F ∈ M, ∀ z, z ∈ F ↔ ∃ n, z = ZFSet.pair (natSet n) (natSet (f n)) := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + obtain ⟨Q,hQ,_,hbound⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω + obtain ⟨φ,hφ⟩ := primitive_bounded_definition.{u} hf + let e := cons ZFSet.omega (fun _ => Q) + have he : ∀ i, e i ∈ M := by intro i; cases i <;> assumption + let F := ZFSet.sep (fun z => (Formula.numericalGraph φ).Eval (cons z e)) + (ZFSet.prod ZFSet.omega ZFSet.omega) + have hF : F ∈ M := sep_mem M hM hS (Formula.numericalGraph φ) e he + (product_mem M hM hT.pairing hT.union hT.powerSet hS hω hω) + have hn (n : ℕ) : natSet.{u} n ∈ ZFSet.omega := (mem_omega _).mpr ⟨n,rfl⟩ + have hdef (z y : ZFSet.{u}) (n : ℕ) := Formula.unary_spec hφ 3 4 1 0 + (cons y (cons (natSet n) (cons z e))) rfl hbound n rfl + refine ⟨F,hF,?_⟩ + intro z + simp only [F,ZFSet.mem_sep,Formula.numericalGraph,Formula.Eval,Formula.eval_orderedPair, + cons_zero,cons_succ,e] + constructor + · rintro ⟨_,x,hx,y,_,hz,h⟩ + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + obtain rfl := (hdef z y n).mp h + exact ⟨n,hz⟩ + · rintro ⟨n,rfl⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨natSet n,hn n,natSet (f n),hn (f n),rfl⟩, + natSet n,hn n,natSet (f n),hn (f n),rfl,(hdef _ _ n).mpr rfl⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalProductBijection.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalProductBijection.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2ac9f22c6f9961b3e6661beb26fbd814ebfe923 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalProductBijection.lean @@ -0,0 +1,78 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalGraphEquiv + +namespace OAI + +namespace TuringRigidity.InternalProductBijection +open TransitiveNameModel BoundedSetTheory + +noncomputable def productGraph (A B W f : ZFSet.{0}) : ZFSet.{0} := + (ZFSet.prod (ZFSet.prod A W) (ZFSet.prod B W)).sep (fun z => + ∃ u ∈ ZFSet.prod A W, ∃ v ∈ ZFSet.prod B W, z = ZFSet.pair u v ∧ + ∃ x ∈ A, ∃ y ∈ B, ∃ n ∈ W, u = ZFSet.pair x n ∧ v = ZFSet.pair y n ∧ ZFSet.pair x y ∈ f) + +theorem pair_productGraph (A B W f u v : ZFSet.{0}) : + ZFSet.pair u v ∈ productGraph A B W f ↔ + ∃ x ∈ A, ∃ y ∈ B, ∃ n ∈ W, u = ZFSet.pair x n ∧ v = ZFSet.pair y n ∧ ZFSet.pair x y ∈ f := by + simp only [productGraph,ZFSet.mem_sep] + constructor + · rintro ⟨_,u',_,v',_,he,h⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact h + · intro h + obtain ⟨x,hx,y,hy,n,hn,rfl,rfl,hxy⟩ := h + have hu := ZFSet.pair_mem_prod.mpr ⟨hx,hn⟩ + have hv := ZFSet.pair_mem_prod.mpr ⟨hy,hn⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨hu,hv⟩,_,hu,_,hv,rfl,x,hx,y,hy,n,hn,rfl,rfl,hxy⟩ + +theorem productGraph_mem (M A B W f : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) (hB : B ∈ M) (hW : W ∈ M) (hf : f ∈ M) : productGraph A B W f ∈ M := by + have hAW := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hA hW + have hBW := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hB hW + let e := cons (ZFSet.prod A W) (cons (ZFSet.prod B W) (cons A (cons B (cons W (fun _ => f))))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|_|i + exact hAW; exact hBW; exact hA; exact hB; exact hW; exact hf + simpa only [productGraph,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) + (.existsMem 5 (.existsMem 7 (.existsMem 9 (.conj (.orderedPair 4 2 0) + (.conj (.orderedPair 3 1 0) (.pairMem 2 1 11))))))))) e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hAW hBW) + +theorem productGraph_function (A B W f : ZFSet.{0}) (hf : FunctionGraph A B f) : + FunctionGraph (ZFSet.prod A W) (ZFSet.prod B W) (productGraph A B W f) := by + constructor + · intro z hz; exact ZFSet.mem_prod.mp (ZFSet.mem_sep.mp hz).1 + · intro u hu + obtain ⟨x,hx,n,hn,rfl⟩ := ZFSet.mem_prod.mp hu + obtain ⟨y,hy,hxy,_⟩ := hf.2 x hx + refine ⟨ZFSet.pair y n,ZFSet.pair_mem_prod.mpr ⟨hy,hn⟩, + (pair_productGraph A B W f _ _).mpr ⟨x,hx,y,hy,n,hn,rfl,rfl,hxy⟩,?_⟩ + intro v _ hv + obtain ⟨x',_,y',_,n',_,he,rfl,hxy'⟩ := (pair_productGraph A B W f _ v).mp hv + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + rw [hf.functional hx hxy' hxy] + +theorem productGraph_injective (A B W f : ZFSet.{0}) + (hi : ∀ x ∈ A, ∀ x' ∈ A, ∀ y ∈ B, ZFSet.pair x y ∈ f → ZFSet.pair x' y ∈ f → x = x') : + ∀ u ∈ ZFSet.prod A W, ∀ u' ∈ ZFSet.prod A W, ∀ v ∈ ZFSet.prod B W, + ZFSet.pair u v ∈ productGraph A B W f → ZFSet.pair u' v ∈ productGraph A B W f → u = u' := by + intro u _ u' _ v _ huv hu'v + obtain ⟨x,hx,y,hy,n,_,rfl,rfl,hxy⟩ := (pair_productGraph A B W f u v).mp huv + obtain ⟨x',hx',y',_,n',_,rfl,he,hx'y⟩ := (pair_productGraph A B W f u' _).mp hu'v + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + rw [hi x hx x' hx' y hy hxy hx'y] + +theorem productGraph_onto (A B W f : ZFSet.{0}) + (hs : ∀ y ∈ B, ∃ x ∈ A, ZFSet.pair x y ∈ f) : + ∀ v ∈ ZFSet.prod B W, ∃ u ∈ ZFSet.prod A W, ZFSet.pair u v ∈ productGraph A B W f := by + intro v hv + obtain ⟨y,hy,n,hn,rfl⟩ := ZFSet.mem_prod.mp hv + obtain ⟨x,hx,hxy⟩ := hs y hy + exact ⟨ZFSet.pair x n,ZFSet.pair_mem_prod.mpr ⟨hx,hn⟩, + (pair_productGraph A B W f _ _).mpr ⟨x,hx,y,hy,n,hn,rfl,rfl,hxy⟩⟩ + +end TuringRigidity.InternalProductBijection + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalProjectedGeneric.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalProjectedGeneric.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8607b40e9c9db8a868f1c179d09f711a7196537 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalProjectedGeneric.lean @@ -0,0 +1,143 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanDense + +namespace OAI + +namespace TuringRigidity.InternalProjectedGeneric +open Set TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalRegularOrder InternalBooleanSyntax +open InternalGeneratedAlgebra InternalBooleanProjection InternalBooleanGeneric InternalBooleanDense +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +noncomputable def positive (A : ZFSet.{0}) : ZFSet.{0} := A.sep (fun U => U ≠ ∅) + +theorem positive_mem (M A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) : positive A ∈ M := by + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 0 (.equal 0 0)) (fun _ => A) (fun _ => hA) hA + have he : A.sep (fun U => (Formula.existsMem 0 (.equal 0 0)).Eval (cons U (fun _ => A))) = positive A := by + apply ZFSet.ext + intro U + simp only [positive,ZFSet.mem_sep,Formula.Eval,cons_zero] + apply and_congr_right + intro _ + constructor + · rintro ⟨p,hp,_⟩ h0 + exact ZFSet.notMem_empty p (h0 ▸ hp) + · intro hn + obtain h0 | ⟨p,hp⟩ := ZFSet.eq_empty_or_nonempty U + · exact False.elim (hn h0) + · exact ⟨p,hp,True.intro⟩ + exact he ▸ hs + +@[instance_reducible] +noncomputable def codeOrder (A : ZFSet.{0}) : PartialOrder (Conditions (positive A)) where + le p q := label (positive A) p ⊆ label (positive A) q + lt p q := label (positive A) p ⊆ label (positive A) q ∧ ¬ label (positive A) q ⊆ label (positive A) p + lt_iff_le_not_ge _ _ := Iff.rfl + le_refl _ := fun _ h => h + le_trans _ _ _ hpq hqr := fun _ h => hqr (hpq h) + le_antisymm _ _ hpq hqp := label_injective _ (ZFSet.ext (fun _ => ⟨fun h => hpq h,fun h => hqp h⟩)) + +@[instance_reducible] +noncomputable def codePreorder (algebraSet : ZFSet.{0}) : + Preorder (Conditions (positive algebraSet)) := + (codeOrder algebraSet).toPreorder + +attribute [local instance] codeOrder codePreorder + +theorem label_info (A : ZFSet.{0}) (p : Conditions (positive A)) : + label (positive A) p ∈ A ∧ label (positive A) p ≠ ∅ := + ZFSet.mem_sep.mp (label_mem (positive A) p) + +noncomputable def projected (M c B Q A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) : GenericFilter (Conditions (positive A)) where + carrier := {p | Hit G (label (positive A) p)} + nonempty := by + obtain ⟨p,hp⟩ := G.nonempty + let b := basicCode c (label c p) + have hbM : b ∈ M := basicCode_mem M c _ hM hT hc (label_mem c p) + have hbc : IsCode c b := regular_isCode c _ + have hb : label c p ∈ b := mem_basicCode c _ (label_mem c p) + have hpb := subset_project c A b hbc.1 hb + have hPA := project_mem_part M c B Q A b hM hT hc hBM hAM hbM hB hQ hA + have hn : project c A b ≠ ∅ := fun h => ZFSet.notMem_empty _ (h ▸ hpb) + obtain ⟨q,hq⟩ := label_surjective (positive A) (ZFSet.mem_sep.mpr ⟨hPA,hn⟩) + exact ⟨q,p,hp,hq.symm ▸ hpb⟩ + upper := by + intro p q hpq hp + obtain ⟨r,hr,hrp⟩ := hp + exact ⟨r,hr,hpq hrp⟩ + directed := by + intro p q hp hq + let U := label (positive A) p + let V := label (positive A) q + have hU := (label_info A p).1 + have hV := (label_info A q).1 + have hUc := ((hB U).mp (hA.1 hU)).2 + have hVc := ((hB V).mp (hA.1 hV)).2 + let F : ZFSet.{0} := {U,V} + have hFM : F ∈ M := pair_mem M hM hT.pairing (hM A hAM U hU) (hM A hAM V hV) + have hFA : F ⊆ A := by + intro W hW + exact (ZFSet.mem_pair.mp hW).elim (fun h => h ▸ hU) (fun h => h ▸ hV) + have hWA := closed_inf M c B Q A F hM hT hc hBM hB hQ hA hFM hFA + obtain ⟨r,hr,hrU⟩ := hp + obtain ⟨s,hs,hsV⟩ := hq + obtain ⟨t,ht,htr,hts⟩ := G.directed hr hs + have htU := code_lower c U hUc _ hrU _ (label_mem c t) htr + have htV := code_lower c V hVc _ hsV _ (label_mem c t) hts + have htW : label c t ∈ infCode c F := by + refine ZFSet.mem_sep.mpr ⟨label_mem c t,fun W hW => ?_⟩ + exact (ZFSet.mem_pair.mp hW).elim (fun h => h ▸ htU) (fun h => h ▸ htV) + have hn : infCode c F ≠ ∅ := fun h => ZFSet.notMem_empty _ (h ▸ htW) + obtain ⟨w,hw⟩ := label_surjective (positive A) (ZFSet.mem_sep.mpr ⟨hWA,hn⟩) + refine ⟨w,⟨t,ht,hw.symm ▸ htW⟩,?_,?_⟩ + · change label (positive A) w ⊆ U + rw [hw] + exact inf_subset c F (ZFSet.mem_pair.mpr (Or.inl rfl)) + · change label (positive A) w ⊆ V + rw [hw] + exact inf_subset c F (ZFSet.mem_pair.mpr (Or.inr rfl)) + +theorem projected_ground_generic (M c B Q A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + AtomicForcing.GroundGeneric M (projected M c B Q A hM hT hc hBM hAM hB hQ hA G) := by + intro D hDM hD + let D' := (positive A).sep (fun U => U ∈ D) + have hD'M : D' ∈ M := by + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (.member 0 1) (fun _ => D) (fun _ => hDM) (positive_mem M A hM hT hAM) + simpa only [D',Formula.Eval,cons_zero,cons_succ] using hs + have hd : DenseCodes A D' := by + intro U hUA hU0 + obtain ⟨p,hp⟩ := label_surjective (positive A) (ZFSet.mem_sep.mpr ⟨hUA,hU0⟩) + obtain ⟨q,hqp,hqD⟩ := hD p + refine ⟨label (positive A) q,ZFSet.mem_sep.mpr ⟨label_mem _ q,hqD⟩, + (label_info A q).1,(label_info A q).2,?_⟩ + change label (positive A) q ⊆ label (positive A) p at hqp + rwa [hp] at hqp + obtain ⟨U,hUD,hUG⟩ := ground_meets_dense_codes M c B Q A D' hM hT hc hBM hAM hD'M hB hQ hA hd G hG + obtain ⟨hUp,hUD⟩ := ZFSet.mem_sep.mp hUD + obtain ⟨p,hp⟩ := label_surjective (positive A) hUp + exact ⟨p,(show Hit G (label (positive A) p) from hp.symm ▸ hUG),hp.symm ▸ hUD⟩ + +theorem projected_order_code (M A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hA : A ∈ M) : + InternalBooleanGraph.inclusionOrder (positive A) ∈ M ∧ + ∀ p q : Conditions (positive A), + ZFSet.pair (label (positive A) p) (label (positive A) q) ∈ + InternalBooleanGraph.inclusionOrder (positive A) ↔ p ≤ q := by + refine ⟨InternalBooleanGraph.inclusionOrder_mem M _ hM hT (positive_mem M A hM hT hA),?_⟩ + intro p q + rw [InternalBooleanGraph.pair_inclusionOrder] + exact ⟨fun h => h.2.2,fun h => ⟨label_mem _ p,label_mem _ q,h⟩⟩ + +end TuringRigidity.InternalProjectedGeneric + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientConditions.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientConditions.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0f63a2eed034dcdb12bf090672277bdcd3aa31b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientConditions.lean @@ -0,0 +1,86 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanTop + +namespace OAI + +namespace TuringRigidity.InternalQuotientConditions +open TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalRegularOrder InternalBooleanSyntax +open InternalBooleanProjection InternalBooleanDense InternalProjectedGeneric InternalBooleanGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder +attribute [local instance] codeOrder codePreorder + +noncomputable def cover (c A p : ZFSet.{0}) : ZFSet.{0} := + c.sep (fun r => ∀ U ∈ A, p ∈ U → r ∈ U) + +theorem cover_eq_project (c A p : ZFSet.{0}) (hp : p ∈ c) + (hA : ∀ U ∈ A, IsCode c U) : cover c A p = project c A (basicCode c p) := by + apply ZFSet.ext; intro r + simp only [cover,project,infCode,uppers,ZFSet.mem_sep] + apply and_congr_right; intro _ + constructor + · intro h U hU + exact h U hU.1 ((basicCode_le_iff c p U hp (hA U hU.1)).mp hU.2) + · intro h U hU hpU + exact h U ⟨hU,(basicCode_le_iff c p U hp (hA U hU)).mpr hpU⟩ + +def coverFormula (c A p V : ℕ) : Formula := + .conj (.subset V c) (.allMem c (.iff (.member 0 (V+1)) + (.allMem (A+1) (.imp (.member (p+2) 0) (.member 1 0))))) + +theorem coverFormula_spec (c A p V : ℕ) (e : ℕ → ZFSet.{0}) : + (coverFormula c A p V).Eval e ↔ e V = cover (e c) (e A) (e p) := by + simp only [coverFormula,Formula.Eval,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_iff,Formula.eval_imp,cons_zero,cons_succ] + constructor + · rintro ⟨hVc,hV⟩ + exact ZFSet.ext (fun r => (Iff.intro + (fun hr => ⟨hVc hr,(hV r (hVc hr)).mp hr⟩) + (fun hr => (hV r hr.1).mpr hr.2)).trans ZFSet.mem_sep.symm) + · intro h; rw [h] + exact ⟨fun _ hr => (ZFSet.mem_sep.mp hr).1,fun r hr => + ZFSet.mem_sep.trans (and_iff_right hr)⟩ + +noncomputable def conditions (c A h : ZFSet.{0}) : ZFSet.{0} := + c.sep (fun p => project c A (basicCode c p) ∈ h) + +theorem conditions_subset (c A h : ZFSet.{0}) : conditions c A h ⊆ c := + fun _ hp => (ZFSet.mem_sep.mp hp).1 + +theorem conditions_mem (N c A h : ZFSet.{0}) (hN : Transitive N) (hT : SourceT N) + (hc : c ∈ N) (hA : A ∈ N) (hh : h ∈ N) + (hAc : ∀ U ∈ A, IsCode c U) : conditions c A h ∈ N := by + let e := cons c (cons A (fun _ => h)) + have he : ∀ i, e i ∈ N := by + intro i; rcases i with _|_|i; exact hc; exact hA; exact hh + have hs := sep_mem N hN hT.separation.finitePrefix.bounded + (.existsMem 3 (coverFormula 2 3 1 0)) e he hc + have heq : c.sep (fun p => (Formula.existsMem 3 (coverFormula 2 3 1 0)).Eval (cons p e)) = + conditions c A h := by + apply ZFSet.ext; intro p + simp only [conditions,ZFSet.mem_sep,Formula.Eval,coverFormula_spec,cons_zero,cons_succ,e] + apply and_congr_right; intro hp + rw [cover_eq_project c A p hp hAc] + exact ⟨fun ⟨V,hV,he⟩ => he ▸ hV,fun hv => ⟨_,hv,rfl⟩⟩ + exact heq ▸ hs + +theorem order_mem (N c A h : ZFSet.{0}) (hN : Transitive N) (hT : SourceT N) + (hc : c ∈ N) (hA : A ∈ N) (hh : h ∈ N) + (hAc : ∀ U ∈ A, IsCode c U) : + InternalCollapse.orderSet (conditions c A h) ∈ N := + InternalCollapse.orderSet_mem N hN hT (conditions_mem N c A h hN hT hc hA hh hAc) + +theorem original_condition_mem (M c B Q A : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) (p : Conditions c) (hp : p ∈ G.carrier) : + label c p ∈ conditions c A (genericFilterSet (positive A) + (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier) := by + obtain ⟨q,hq,he⟩ := InternalSameNameGeneric.projected_condition M c B Q A + hM hT hc hBM hAM hB hQ hA G p hp + exact ZFSet.mem_sep.mpr ⟨label_mem c p, + (mem_genericFilterSet _ _ _).mpr ⟨q,hq,he⟩⟩ + +end TuringRigidity.InternalQuotientConditions + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientCountability.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientCountability.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc0a50fb3a4e15d05146887473d2787d86e96187 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientCountability.lean @@ -0,0 +1,38 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalQuotientExtension +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableClosure + +namespace OAI + +namespace TuringRigidity.InternalQuotientCountability +open TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax +open InternalProjectedGeneric InternalQuotientGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + codeOrder codePreorder + +theorem countability_upward (M N c : ZFSet.{0}) (hMN : M ⊆ N) + (hct : InternallyCountable M c) : InternallyCountable N c := by + obtain ⟨E,hE,hfun,honto⟩ := hct + exact ⟨E,hMN hE,hfun,honto⟩ + +theorem quotient_countable (M c B Q A : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (hct : InternallyCountable M c) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + let N := genericExtensionSet M (positive A) H.carrier + let q := InternalQuotientConditions.conditions c A (genericFilterSet (positive A) H.carrier) + InternallyCountable N q := by + obtain ⟨hN,hTN,hMN,_,hqN,_⟩ := InternalQuotientExtension.intermediate_properties M c B Q A + hM hT hc hBM hAM hB hQ hA G hG + apply InternalCountableClosure.countable_subset _ c _ hN hTN (hMN hc) hqN + (InternalQuotientConditions.conditions_subset c A _) (countability_upward M _ c hMN hct) + obtain ⟨p,hp⟩ := G.nonempty + exact ⟨label c p,InternalQuotientConditions.original_condition_mem M c B Q A + hM hT hc hBM hAM hB hQ hA G p hp⟩ + +end TuringRigidity.InternalQuotientCountability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientExtension.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad35f0f0a02271e128ac2f1b948fa440684a562f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientExtension.lean @@ -0,0 +1,114 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalQuotientGeneric +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanExtension + +namespace OAI + +namespace TuringRigidity.InternalQuotientExtension +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames +open InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax +open InternalProjectedGeneric InternalBooleanTop InternalQuotientGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder +attribute [local instance] codeOrder codePreorder + +theorem intermediate_properties (M c B Q A : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + let N := genericExtensionSet M (positive A) H.carrier + let h := genericFilterSet (positive A) H.carrier + let q := InternalQuotientConditions.conditions c A h + Transitive N ∧ SourceT N ∧ M ⊆ N ∧ h ∈ N ∧ q ∈ N ∧ + InternalCollapse.orderSet q ∈ N := by + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + have hcA := top_mem_part M c B Q A hM hT hc hBM hB hQ hA + have hc0 : c ≠ ∅ := by + obtain ⟨p,_⟩ := G.nonempty + exact fun he => ZFSet.notMem_empty _ + (Eq.mp (congrArg (fun d => label c p ∈ d) he) (label_mem c p)) + let _ := booleanTop c A hcA hc0 + have ht := label_booleanTop c A hcA hc0 + have hHt := top_in_filter c A (fun U hU => ((hB U).mp (hA.1 hU)).2.1) ht H + have hpM := positive_mem M A hM hT hAM + have hHG := projected_ground_generic M c B Q A hM hT hc hBM hAM hB hQ hA G hG + obtain ⟨hoM,ho⟩ := projected_order_code M A hM hT hAM + have hN := genericExtensionSet_transitive M _ hM H.carrier + have hTN := extension_sourceT M hM hT hpM hoM ho H hHG hHt + have hMN := ground_inclusion_set M _ hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hpM H.carrier hHt + have hhN := genericFilterSet_mem_extension M _ hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hpM H.carrier hHt + have hqN := InternalQuotientConditions.conditions_mem _ c A _ hN hTN (hMN hc) (hMN hAM) hhN + (fun U hU => ((hB U).mp (hA.1 hU)).2) + exact ⟨hN,hTN,hMN,hhN,hqN,InternalCollapse.orderSet_mem _ hN hTN hqN⟩ + +theorem extension_eq (M c B Q A : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (hGt : ⊤ ∈ G.carrier) : + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + let N := genericExtensionSet M (positive A) H.carrier + let q := InternalQuotientConditions.conditions c A (genericFilterSet (positive A) H.carrier) + let K := quotient M c B Q A hM hT hc hBM hAM hB hQ hA G + genericExtensionSet N q K.carrier = genericExtensionSet M c G.carrier := by + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + let N := genericExtensionSet M (positive A) H.carrier + let q := InternalQuotientConditions.conditions c A (genericFilterSet (positive A) H.carrier) + let K := quotient M c B Q A hM hT hc hBM hAM hB hQ hA G + obtain ⟨hN,hTN,hMN,_,hqN,hoN⟩ := intermediate_properties M c B Q A hM hT hc hBM hAM hB hQ hA G hG + have hKG : AtomicForcing.GroundGeneric N K := + quotient_ground_generic M c B Q A hM hT hc hBM hAM hB hQ hA G hG + have hcode : genericFilterSet q K.carrier = genericFilterSet c G.carrier := + RestrictedForcingFilter.filterSet_eq c q (InternalQuotientConditions.conditions_subset c A _) G + (InternalQuotientConditions.original_condition_mem M c B Q A hM hT hc hBM hAM hB hQ hA G) + let _ : Top (Conditions q) := ⟨Classical.choose K.nonempty⟩ + have hKt : ⊤ ∈ K.carrier := Classical.choose_spec K.nonempty + have hV := genericExtensionSet_transitive N q hN K.carrier + have hTV := extension_sourceT N hN hTN hqN hoN (InternalCollapse.orderSet_pair q) K hKG hKt + have hNV := ground_inclusion_set N q hN hTN.pairing hTN.union hTN.powerSet + hTN.separation.finitePrefix.bounded hTN.replacement.finitePrefix hTN.infinity hqN K.carrier hKt + have hkV := genericFilterSet_mem_extension N q hN hTN.pairing hTN.union hTN.powerSet + hTN.separation.finitePrefix.bounded hTN.replacement.finitePrefix hTN.infinity hqN K.carrier hKt + have hgV : genericFilterSet c G.carrier ∈ genericExtensionSet N q K.carrier := hcode ▸ hkV + have hO := genericExtensionSet_transitive M c hM G.carrier + have hTO := extension_sourceT M hM hT hc (InternalCollapse.orderSet_mem M hM hT hc) + (InternalCollapse.orderSet_pair c) G hG hGt + have hgO := genericFilterSet_mem_extension M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier hGt + have hNO := InternalBooleanExtension.projected_extension_subset_original M c B Q A + hM hT hc hBM hAM hB hQ hA G hG hGt + have hVO := InternalNameEvaluation.extension_subset N _ hO hTO hNO K.carrier (hcode.symm ▸ hgO) + have hOV := InternalNameEvaluation.extension_subset M _ hV hTV + (fun _ hx => hNV (hMN hx)) G.carrier hgV + exact ZFSet.ext (fun x => ⟨fun hx => hVO hx,fun hx => hOV hx⟩) + +theorem name_ranges (M c B Q A : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (hGt : ⊤ ∈ G.carrier) : + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + let N := genericExtensionSet M (positive A) H.carrier + let q := InternalQuotientConditions.conditions c A (genericFilterSet (positive A) H.carrier) + let K := quotient M c B Q A hM hT hc hBM hAM hB hQ hA G + (∀ τ : Name (Conditions c), τ.encode (label c) ∈ M → + ∃ σ : Name (Conditions q), σ.encode (label q) ∈ N ∧ σ.val K.carrier = τ.val G.carrier) ∧ + (∀ σ : Name (Conditions q), σ.encode (label q) ∈ N → + ∃ τ : Name (Conditions c), τ.encode (label c) ∈ M ∧ τ.val G.carrier = σ.val K.carrier) := by + have he := extension_eq M c B Q A hM hT hc hBM hAM hB hQ hA G hG hGt + dsimp only + constructor + · intro τ hτ + apply (mem_extensionSet _ _ _ _).mp + rw [he] + exact (mem_extensionSet _ _ _ _).mpr ⟨τ,hτ,rfl⟩ + · intro σ hσ + apply (mem_extensionSet _ _ _ _).mp + rw [←he] + exact (mem_extensionSet _ _ _ _).mpr ⟨σ,hσ,rfl⟩ + +end TuringRigidity.InternalQuotientExtension + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientGeneric.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientGeneric.lean new file mode 100644 index 0000000000000000000000000000000000000000..0eabd8ec4548a3fd8fa542cc41f43367655cb683 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientGeneric.lean @@ -0,0 +1,109 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalQuotientRequirement +import OAI.Computability.DegreeRigidity.CohenForcing.RestrictedForcingFilter + +namespace OAI + +namespace TuringRigidity.InternalQuotientGeneric +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames AtomicForcing +open InternalRegularOperations InternalRegularAlgebra InternalRegularOrder InternalBooleanSyntax +open InternalBooleanProjection InternalBooleanDense InternalProjectedGeneric InternalBooleanGeneric +open InternalBooleanTop InternalQuotientRequirement +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder +attribute [local instance] codeOrder codePreorder + +theorem meets_named_dense (M c B Q A : ZFSet.{0}) [Top (Conditions (positive A))] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (ht : label (positive A) ⊤ = c) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) + (τ : Name (Conditions (positive A))) (hτ : τ.encode (label (positive A)) ∈ M) + (hD : Dense {p : Conditions (InternalQuotientConditions.conditions c A + (genericFilterSet (positive A) (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier)) | + label _ p ∈ τ.val (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier}) : + ∃ p ∈ G.carrier, label c p ∈ τ.val (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier := by + let H := projected M c B Q A hM hT hc hBM hAM hB hQ hA G + let q := InternalQuotientConditions.conditions c A (genericFilterSet (positive A) H.carrier) + have hAc : ∀ U ∈ A, IsCode c U := fun U hU => ((hB U).mp (hA.1 hU)).2 + have hpos := positive_mem M A hM hT hAM + have hH := projected_ground_generic M c B Q A hM hT hc hBM hAM hB hQ hA G hG + have hHt : ⊤ ∈ H.carrier := top_in_filter c A (fun U hU => (hAc U hU).1) ht H + obtain ⟨hoM,ho⟩ := projected_order_code M A hM hT hAM + let R := CheckedForcingRelation.relation c τ + have hR : R ∈ M := CheckedForcingRelation.relation_mem M c hM hT hpos hc hoM ho τ hτ + have htruth (r : Conditions c) : label c r ∈ τ.val H.carrier ↔ + ∃ a ∈ H.carrier, MemForces (Name.check (label c r)) τ a := by + have hcheck := encoded_check_mem M (positive A) hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hpos + (hM c hc _ (label_mem c r)) + have h := (internal_atomic_truth M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hpos + hoM ho H hH (Name.check (label c r)) τ hcheck hτ).2 + simpa only [Name.val_check _ hHt] using h + have hGq : ∀ p ∈ G.carrier, label c p ∈ q := + InternalQuotientConditions.original_condition_mem M c B Q A hM hT hc hBM hAM hB hQ hA G + let U := requirement c (positive A) R + have hUM : U ∈ M := requirement_mem M c (positive A) R hM hT hc hpos hR + rcases generic_decision M c U hM hT hc hUM (requirement_subset c (positive A) R) G hG with hU | hn + · obtain ⟨p,hp,hpU⟩ := hU + obtain ⟨_,r,hr,hrp,V,hV,hpV,hrV⟩ := ZFSet.mem_sep.mp hpU + obtain ⟨r,rfl⟩ := label_surjective c hr + obtain ⟨a,rfl⟩ := label_surjective (positive A) hV + have ha : a ∈ H.carrier := ⟨p,hp,hpV⟩ + have hf := (CheckedForcingRelation.pair_relation c (label c r) τ a).mp hrV + exact ⟨r,G.upper hrp hp,(htruth r).mpr ⟨a,ha,hf.2⟩⟩ + · obtain ⟨p,hp,hpn⟩ := hn + obtain ⟨pq,hpq⟩ := label_surjective q (hGq p hp) + obtain ⟨rq,hrq,hrD⟩ := hD pq + let r := RestrictedForcingFilter.inclusion c q (InternalQuotientConditions.conditions_subset c A _) rq + have hre : label c r = label q rq := RestrictedForcingFilter.label_inclusion c q _ rq + have hpr : r ≤ p := by + change label c p ⊆ label c r + rw [hre,←hpq] + exact hrq + obtain ⟨a,ha,hforce⟩ := (htruth r).mp (hre.symm ▸ hrD) + have hrqcode : label c r ∈ q := hre.symm ▸ label_mem q rq + obtain ⟨s,hsr,hsa⟩ := InternalQuotientLifting.quotient_compatible c A hAc hA.2.1 H r hrqcode a ha + have hsU : label c s ∈ U := ZFSet.mem_sep.mpr ⟨label_mem c s,label c r,label_mem c r,hsr, + label (positive A) a,label_mem (positive A) a,hsa, + (CheckedForcingRelation.pair_relation c (label c r) τ a).mpr ⟨label_mem c r,hforce⟩⟩ + exact False.elim ((ZFSet.mem_sep.mp hpn).2 (label c s) hsU (hsr.trans hpr)) + +noncomputable def quotient (M c B Q A : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) : + GenericFilter (Conditions (InternalQuotientConditions.conditions c A + (genericFilterSet (positive A) (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier))) := + RestrictedForcingFilter.restrict c _ (InternalQuotientConditions.conditions_subset c A _) G + (InternalQuotientConditions.original_condition_mem M c B Q A hM hT hc hBM hAM hB hQ hA G) + +theorem quotient_ground_generic (M c B Q A : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) : + GroundGeneric (genericExtensionSet M (positive A) + (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier) + (quotient M c B Q A hM hT hc hBM hAM hB hQ hA G) := by + have hcA := top_mem_part M c B Q A hM hT hc hBM hB hQ hA + have hc0 : c ≠ ∅ := by + obtain ⟨p,_⟩ := G.nonempty + exact fun he => ZFSet.notMem_empty _ + (Eq.mp (congrArg (fun d => label c p ∈ d) he) (label_mem c p)) + let _ := booleanTop c A hcA hc0 + have ht := label_booleanTop c A hcA hc0 + intro D hDN hD + obtain ⟨τ,hτ,hval⟩ := (mem_extensionSet _ _ _ D).mp hDN + have hD' := hD + rw [←hval] at hD' + obtain ⟨p,hp,hpD⟩ := meets_named_dense M c B Q A hM hT hc hBM hAM hB hQ hA ht G hG τ hτ hD' + obtain ⟨r,hr,he⟩ := RestrictedForcingFilter.original_condition c _ + (InternalQuotientConditions.conditions_subset c A _) G + (InternalQuotientConditions.original_condition_mem M c B Q A hM hT hc hBM hAM hB hQ hA G) p hp + exact ⟨r,hr,he.symm ▸ hval ▸ hpD⟩ + +end TuringRigidity.InternalQuotientGeneric + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientLifting.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientLifting.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0b365ec50170697931e787ddf0f4120b2c048f0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientLifting.lean @@ -0,0 +1,54 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalQuotientConditions + +namespace OAI + +namespace TuringRigidity.InternalQuotientLifting +open TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalRegularOrder InternalBooleanSyntax +open InternalBooleanProjection InternalBooleanDense InternalProjectedGeneric InternalBooleanGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder +attribute [local instance] codeOrder codePreorder + +theorem extension_in_code (c A : ZFSet.{0}) (hAc : ∀ U ∈ A, IsCode c U) + (hneg : ∀ U ∈ A, neg c U ∈ A) (p : Conditions c) + (V : ZFSet.{0}) (hVA : V ∈ A) (hV0 : V ≠ ∅) + (hVP : V ⊆ project c A (basicCode c (label c p))) : + ∃ r : Conditions c, r ≤ p ∧ label c r ∈ V := by + classical + have hVc := hAc V hVA + have hex : ∃ r ∈ V, label c p ⊆ r := by + by_contra hn + have hpN : label c p ∈ neg c V := ZFSet.mem_sep.mpr + ⟨label_mem c p,fun r hr hpr => hn ⟨r,hr,hpr⟩⟩ + have hbN := (basicCode_le_iff c _ _ (label_mem c p) (neg_isCode c V hVc)).mpr hpN + have hPN := (project_le_iff c A _ _ (regular_isCode c _).1 (hneg V hVA)).mpr hbN + apply hV0 + apply ZFSet.ext; intro r + constructor + · intro hr + exact False.elim ((ZFSet.mem_sep.mp (hPN (hVP hr))).2 r hr (fun _ h => h)) + · exact fun hr => False.elim (ZFSet.notMem_empty r hr) + obtain ⟨r,hr,hpr⟩ := hex + obtain ⟨r,rfl⟩ := label_surjective c (hVc.1 hr) + exact ⟨r,hpr,hr⟩ + +theorem quotient_compatible (c A : ZFSet.{0}) + (hAc : ∀ U ∈ A, IsCode c U) (hneg : ∀ U ∈ A, neg c U ∈ A) + (H : GenericFilter (Conditions (positive A))) + (p : Conditions c) + (hp : label c p ∈ InternalQuotientConditions.conditions c A + (genericFilterSet (positive A) H.carrier)) + (a : Conditions (positive A)) (ha : a ∈ H.carrier) : + ∃ r : Conditions c, r ≤ p ∧ label c r ∈ label (positive A) a := by + obtain ⟨b,hb,hbe⟩ := (mem_genericFilterSet _ _ _).mp (ZFSet.mem_sep.mp hp).2 + obtain ⟨v,_,hvb,hva⟩ := H.directed hb ha + have hvp : label (positive A) v ⊆ project c A (basicCode c (label c p)) := by + change label (positive A) v ⊆ label (positive A) b at hvb + rwa [hbe] at hvb + obtain ⟨r,hr,hrv⟩ := extension_in_code c A hAc hneg p _ + (label_info A v).1 (label_info A v).2 hvp + exact ⟨r,hr,hva hrv⟩ + +end TuringRigidity.InternalQuotientLifting + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientRequirement.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientRequirement.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8e2f958ee2c905803fb7d3ffc263dd9a43308a0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalQuotientRequirement.lean @@ -0,0 +1,37 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalQuotientLifting +import OAI.Computability.DegreeRigidity.CohenForcing.CheckedForcingRelation + +namespace OAI + +namespace TuringRigidity.InternalQuotientRequirement +open TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalRegularOrder InternalBooleanSyntax +attribute [local instance] InternalCollapse.order + +noncomputable def requirement (c a R : ZFSet.{0}) : ZFSet.{0} := + c.sep (fun p => ∃ r ∈ c, r ⊆ p ∧ ∃ V ∈ a, p ∈ V ∧ ZFSet.pair r V ∈ R) + +theorem requirement_mem (M c a R : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (ha : a ∈ M) (hR : R ∈ M) : requirement c a R ∈ M := by + let e := cons c (cons a (fun _ => R)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i; exact hc; exact ha; exact hR + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.conj (.subset 0 1) (.existsMem 3 + (.conj (.member 2 0) (.pairMem 1 0 5))))) e he hc + simpa only [requirement,Formula.Eval,Formula.eval_subset,Formula.eval_pairMem, + cons_zero,cons_succ,e] using hs + +theorem requirement_subset (c a R : ZFSet.{0}) : requirement c a R ⊆ c := + fun _ h => (ZFSet.mem_sep.mp h).1 + +theorem requirement_lower (c a R : ZFSet.{0}) (ha : ∀ V ∈ a, IsCode c V) : + Lower c (requirement c a R) := by + intro p hp s hs hps + obtain ⟨_,r,hr,hrp,V,hV,hpV,hrV⟩ := ZFSet.mem_sep.mp hp + exact ZFSet.mem_sep.mpr ⟨hs,r,hr,fun _ h => hps (hrp h),V,hV, + code_lower c V (ha V hV) p hpV s hs hps,hrV⟩ + +end TuringRigidity.InternalQuotientRequirement + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRealQuotient.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRealQuotient.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c3e83d1ea1554729a8ddf28953707e73948885e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRealQuotient.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.Representation.RealGeneratedPart +import OAI.Computability.DegreeRigidity.CohenForcing.QuotientNames +import OAI.Computability.DegreeRigidity.CohenForcing.CohenInternalDecision +import OAI.Computability.DegreeRigidity.SetModels.InternalNiceName + +namespace OAI + +namespace TuringRigidity.InternalRealQuotient +open Set CountableForcing TransitiveNameModel BoundedSetTheory RecursiveNames +open ForcingProjection RegularCompletion BooleanProjection +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +def tags (c : ZFSet.{0}) (E : ℕ → ZFSet.{0}) : ℕ → Set (Conditions c) := + fun n => {p | label c p ∈ E n} + +theorem label_below (c U : ZFSet.{0}) (hUc : U ⊆ c) (p : Conditions c) : + label c p ∈ CohenInternalDecision.below c U ↔ + p ∈ RealGeneratedPart.tagLower {q | label c q ∈ U} := by + rw [CohenInternalDecision.below,ZFSet.mem_sep] + constructor + · rintro ⟨_,q,hq,hqp⟩ + obtain ⟨q,rfl⟩ := label_surjective c (hUc hq) + exact ⟨q,hq,hqp⟩ + · rintro ⟨q,hq,hpq⟩ + exact ⟨label_mem c p,label c q,hq,hpq⟩ + +theorem label_decision (c : ZFSet.{0}) (E : ℕ → ZFSet.{0}) + (hEc : ∀ n, E n ⊆ c) (n : ℕ) (p : Conditions c) : + label c p ∈ CohenInternalDecision.decision c (CohenInternalDecision.below c (E n)) (E n) ↔ + p ∈ RealGeneratedPart.decision (tags c E) n := by + rw [CohenInternalDecision.decision,ZFSet.mem_sep] + constructor + · rintro ⟨_,hp | hp⟩ + · obtain ⟨q,hq,hqp⟩ := hp + obtain ⟨q,rfl⟩ := label_surjective c (hEc n hq) + exact Or.inl ⟨q,hq,hqp⟩ + · apply Or.inr + apply (mem_compl _ p).mpr + intro q hqp hq + exact hp (label c q) ((label_below c (E n) (hEc n) q).mpr hq) hqp + · intro hp + refine ⟨label_mem c p,?_⟩ + rcases hp with ⟨q,hq,hpq⟩ | hp + · exact Or.inl ⟨label c q,hq,hpq⟩ + · apply Or.inr + intro q hq hpq + obtain ⟨q,rfl⟩ := label_surjective c (ZFSet.mem_sep.mp hq).1 + exact (mem_compl _ p).mp hp q hpq ((label_below c (E n) (hEc n) q).mp hq) + +theorem ground_generic_decisions (M c : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + GenericFor (RealGeneratedPart.decision (tags c E)) G := by + intro n + let D := CohenInternalDecision.decision c (CohenInternalDecision.below c (E n)) (E n) + have hDM : D ∈ M := CohenInternalDecision.decision_mem M c _ _ hM hT hc + (CohenInternalDecision.below_mem M c _ hM hT hc (hE n).1) (hE n).1 + have hd : Dense {p : Conditions c | label c p ∈ D} := by + intro p + obtain ⟨q,hqp,hq⟩ := RealGeneratedPart.decision_dense (tags c E) n p + exact ⟨q,hqp,(label_decision c E (fun n => (hE n).2) n q).mpr hq⟩ + obtain ⟨p,hp,hpD⟩ := hG D hDM hd + exact ⟨p,hp,(label_decision c E (fun n => (hE n).2) n p).mp hpD⟩ + +theorem nice_value_iff {c : ZFSet.{0}} [Top (Conditions c)] + (E : ℕ → ZFSet.{0}) (G : GenericFilter (Conditions c)) (hTop : ⊤ ∈ G.carrier) (n : ℕ) : + natSet n ∈ (InternalNiceName.nice E : Name (Conditions c)).val G.carrier ↔ + n ∈ RealGeneratedPart.value (tags c E) G := by + rw [InternalNiceName.mem_val_nice E G.carrier hTop] + constructor + · rintro ⟨m,p,hp,hpE,hmn⟩ + have he := natSet_injective hmn + subst m + exact ⟨p,hp,hpE⟩ + · rintro ⟨p,hp,hpE⟩ + exact ⟨n,p,hp,hpE,rfl⟩ + +theorem projected_nice_bit (M c : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) + (hTop : ⊤ ∈ G.carrier) (n : ℕ) : + (∃ hn : RealGeneratedPart.bit (tags c E) n ≠ ⊥, + (⟨RealGeneratedPart.bit (tags c E) n,RealGeneratedPart.bit_mem_part (tags c E) n,hn⟩ : + PartPositive (RealGeneratedPart.part (tags c E))) ∈ + (imageFilter (RealGeneratedPart.projection (tags c E)) G).carrier) ↔ + natSet n ∈ (InternalNiceName.nice E : Name (Conditions c)).val G.carrier := by + rw [RealGeneratedPart.projected_bit_iff _ G + (ground_generic_decisions M c hM hT hc E hE G hG),nice_value_iff E G hTop] + +theorem original_name_value (c : ZFSet.{0}) (E : ℕ → ZFSet.{0}) + (G : GenericFilter (Conditions c)) (τ : Name (Conditions c)) : + (QuotientNames.restrict (RealGeneratedPart.projection (tags c E)) + (imageFilter (RealGeneratedPart.projection (tags c E)) G) τ).val + (quotientFilter (RealGeneratedPart.projection (tags c E)) G).carrier = τ.val G.carrier := + QuotientNames.original_val_restrict _ G τ + +end TuringRigidity.InternalRealQuotient + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularAlgebra.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a34ffdf81a20ea60e24a0d211ac7f3f340e11e7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularAlgebra.lean @@ -0,0 +1,116 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalRegularOperations + +namespace OAI + +namespace TuringRigidity.InternalRegularAlgebra +open Set TransitiveNameModel BoundedSetTheory RegularCompletion InternalRegularOperations +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +def IsCode (c U : ZFSet.{0}) : Prop := U ⊆ c ∧ regular c U = U + +theorem mem_regular (c U p : ZFSet.{0}) : + p ∈ regular c U ↔ p ∈ c ∧ ∀ q ∈ c, p ⊆ q → ∃ r ∈ U, q ⊆ r := by + classical + simp only [regular,neg,ZFSet.mem_sep] + constructor + · rintro ⟨hp,h⟩ + refine ⟨hp,fun q hq hpq => ?_⟩ + by_contra hn + exact h q ⟨hq,fun r hr hqr => hn ⟨r,hr,hqr⟩⟩ hpq + · rintro ⟨hp,h⟩ + refine ⟨hp,fun q hq hpq => ?_⟩ + obtain ⟨r,hr,hqr⟩ := h q hq.1 hpq + exact hq.2 r hr hqr + +theorem isCode_iff (c U : ZFSet.{0}) : IsCode c U ↔ + U ⊆ c ∧ ∀ p ∈ c, p ∈ U ↔ ∀ q ∈ c, p ⊆ q → ∃ r ∈ U, q ⊆ r := by + constructor + · rintro ⟨hUc,hU⟩ + refine ⟨hUc,fun p hp => ?_⟩ + have h := mem_regular c U p + rw [hU] at h + exact h.trans (and_iff_right hp) + · rintro ⟨hUc,hU⟩ + refine ⟨hUc,ZFSet.ext (fun p => ?_)⟩ + rw [mem_regular] + exact ⟨fun h => (hU p h.1).mpr h.2,fun h => ⟨hUc h,(hU p (hUc h)).mp h⟩⟩ + +def codeFormula (c U : ℕ) : Formula := + .conj (.subset U c) (.allMem c (.iff (.member 0 (U+1)) + (.allMem (c+1) (.imp (.subset 1 0) (.existsMem (U+2) (.subset 1 0)))))) + +theorem codeFormula_spec (c U : ℕ) (e : ℕ → ZFSet.{0}) : + (codeFormula c U).Eval e ↔ IsCode (e c) (e U) := by + rw [isCode_iff] + simp only [codeFormula,Formula.Eval,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_iff,Formula.eval_imp,cons_zero,cons_succ] + +theorem internal_algebra (M c : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) : ∃ B ∈ M, ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U := by + obtain ⟨Q,hQ,hQdef⟩ := internal_power M hM hT.powerSet hc + let B := Q.sep (IsCode c) + have hB : B ∈ M := by + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (codeFormula 1 0) (fun _ => c) (fun _ => hc) hQ + simpa only [codeFormula_spec,cons_zero,cons_succ] using hs + refine ⟨B,hB,fun U => ?_⟩ + change (U ∈ Q.sep (IsCode c)) ↔ _ + rw [ZFSet.mem_sep,hQdef] + exact ⟨fun h => ⟨h.1.1,h.2⟩,fun h => ⟨⟨h.1,h.2.1⟩,h.2⟩⟩ + +theorem code_lower (c U : ZFSet.{0}) (hU : IsCode c U) : Lower c U := by + rw [← hU.2] + exact neg_lower c _ + +def interpret (c U : ZFSet.{0}) (hU : IsCode c U) : Algebra (Conditions c) := + ⟨decode c U (code_lower c U hU),by + change (decode c U _)ᶜᶜ = decode c U _ + have h := decode_regular c U hU.1 (code_lower c U hU) + change decode c (regular c U) _ = (decode c U _)ᶜᶜ at h + apply h.symm.trans + apply SetLike.ext + intro p + change label c p ∈ regular c U ↔ label c p ∈ U + rw [hU.2]⟩ + +theorem interpret_le_iff (c U V : ZFSet.{0}) (hU : IsCode c U) (hV : IsCode c V) : + interpret c U hU ≤ interpret c V hV ↔ U ⊆ V := by + constructor + · intro h p hp + obtain ⟨p,rfl⟩ := label_surjective c (hU.1 hp) + exact h hp + · intro h p hp + exact h hp + +theorem interpret_injective (c U V : ZFSet.{0}) (hU : IsCode c U) (hV : IsCode c V) : + interpret c U hU = interpret c V hV → U = V := by + intro h + exact ZFSet.ext (fun p => ⟨fun hp => (interpret_le_iff c U V hU hV).mp (le_of_eq h) hp, + fun hp => (interpret_le_iff c V U hV hU).mp (le_of_eq h.symm) hp⟩) + +theorem neg_isCode (c U : ZFSet.{0}) (hU : IsCode c U) : IsCode c (neg c U) := + ⟨neg_subset c U,neg_regular c U hU.1 (code_lower c U hU)⟩ + +theorem regular_isCode (c U : ZFSet.{0}) : IsCode c (regular c U) := + ⟨neg_subset c _,regular_idempotent c U⟩ + +theorem join_isCode (c F : ZFSet.{0}) : IsCode c (supCode c F) := regular_isCode c _ + +theorem interpret_neg (c U : ZFSet.{0}) (hU : IsCode c U) : + interpret c (neg c U) (neg_isCode c U hU) = (interpret c U hU)ᶜ := by + apply Heyting.Regular.coe_injective + exact decode_neg c U hU.1 (code_lower c U hU) + +theorem internal_complement (M c B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + {U : ZFSet.{0}} (hU : U ∈ B) : neg c U ∈ B := + (hB _).mpr ⟨neg_mem M c U hM hT hc ((hB U).mp hU).1,neg_isCode c U ((hB U).mp hU).2⟩ + +theorem internal_join (M c B F : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) (hF : F ∈ M) : + supCode c F ∈ B := + (hB _).mpr ⟨join_mem M c F hM hT hc hF,join_isCode c F⟩ + +end TuringRigidity.InternalRegularAlgebra + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularOperations.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularOperations.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a894c96ba9b1e05406d8adb70ffa7608d72925b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularOperations.lean @@ -0,0 +1,116 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularCompletion +import OAI.Computability.DegreeRigidity.CohenForcing.CohenInternalDecision + +namespace OAI + +namespace TuringRigidity.InternalRegularOperations +open Set TransitiveNameModel BoundedSetTheory RegularCompletion +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +noncomputable def neg (c U : ZFSet.{0}) : ZFSet.{0} := + c.sep (fun p => ∀ q ∈ U, ¬ p ⊆ q) + +noncomputable def regular (c U : ZFSet.{0}) : ZFSet.{0} := neg c (neg c U) + +def Lower (c U : ZFSet.{0}) : Prop := + ∀ p ∈ U, ∀ q ∈ c, p ⊆ q → q ∈ U + +theorem neg_subset (c U : ZFSet.{0}) : neg c U ⊆ c := + fun _ h => (ZFSet.mem_sep.mp h).1 + +theorem neg_lower (c U : ZFSet.{0}) : Lower c (neg c U) := by + intro p hp q hq hpq + refine ZFSet.mem_sep.mpr ⟨hq,?_⟩ + intro r hr hqr + exact (ZFSet.mem_sep.mp hp).2 r hr (fun z hz => hqr (hpq hz)) + +theorem neg_mem (M c U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hU : U ∈ M) : neg c U ∈ M := by + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (.allMem 1 (.neg (.subset 1 0))) (fun _ => U) (fun _ => hU) hc + simpa only [neg,Formula.Eval,Formula.eval_allMem,Formula.eval_subset, + cons_zero,cons_succ] using hs + +theorem regular_mem (M c U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hU : U ∈ M) : regular c U ∈ M := + neg_mem M c _ hM hT hc (neg_mem M c U hM hT hc hU) + +def decode (c U : ZFSet.{0}) (hU : Lower c U) : LowerSet (Conditions c) where + carrier := {p | label c p ∈ U} + lower' := by + intro p q hpq hq + exact hU _ hq _ (label_mem c q) hpq + +theorem decode_injective (c U V : ZFSet.{0}) (hUc : U ⊆ c) (hVc : V ⊆ c) + (hU : Lower c U) (hV : Lower c V) : + decode c U hU = decode c V hV → U = V := by + intro h + apply ZFSet.ext + intro z + constructor + · intro hz + obtain ⟨p,rfl⟩ := label_surjective c (hUc hz) + exact (show label c p ∈ U ↔ label c p ∈ V from + SetLike.ext_iff.mp h p).mp hz + · intro hz + obtain ⟨p,rfl⟩ := label_surjective c (hVc hz) + exact (show label c p ∈ U ↔ label c p ∈ V from + SetLike.ext_iff.mp h p).mpr hz + +theorem decode_neg (c U : ZFSet.{0}) (hUc : U ⊆ c) (hU : Lower c U) : + decode c (neg c U) (neg_lower c U) = (decode c U hU)ᶜ := by + apply SetLike.ext + intro p + rw [RegularCompletion.mem_compl] + change (label c p ∈ neg c U) ↔ _ + rw [neg,ZFSet.mem_sep] + constructor + · rintro ⟨_,hp⟩ q hqp hq + exact hp (label c q) hq hqp + · intro hp + refine ⟨label_mem c p,?_⟩ + intro q hq hpq + obtain ⟨q,rfl⟩ := label_surjective c (hUc hq) + exact hp q hpq hq + +theorem decode_regular (c U : ZFSet.{0}) (hUc : U ⊆ c) (hU : Lower c U) : + decode c (regular c U) (neg_lower c (neg c U)) = + (Heyting.Regular.toRegular (decode c U hU) : LowerSet (Conditions c)) := by + change decode c (neg c (neg c U)) _ = _ + rw [decode_neg c _ (neg_subset c U) (neg_lower c U),decode_neg c U hUc hU] + rfl + +theorem regular_idempotent (c U : ZFSet.{0}) : regular c (regular c U) = regular c U := by + apply decode_injective c _ _ (neg_subset c _) (neg_subset c _) + (neg_lower c _) (neg_lower c _) + simp only [regular,decode_neg c _ (neg_subset c _) (neg_lower c _),compl_compl_compl] + +theorem neg_regular (c U : ZFSet.{0}) (hUc : U ⊆ c) (hU : Lower c U) : regular c (neg c U) = neg c U := by + apply decode_injective c _ _ (neg_subset c _) (neg_subset c _) (neg_lower c _) (neg_lower c _) + rw [decode_neg c _ (neg_subset c _) (neg_lower c _), + decode_neg c _ (neg_subset c _) (neg_lower c _)] + rw [decode_neg c U hUc hU] + exact compl_compl_compl _ + +theorem union_lower (c F : ZFSet.{0}) (hF : ∀ U ∈ F, Lower c U) : + Lower c (ZFSet.sUnion F) := by + intro p hp q hq hpq + obtain ⟨U,hU,hp⟩ := ZFSet.mem_sUnion.mp hp + exact ZFSet.mem_sUnion.mpr ⟨U,hU,hF U hU p hp q hq hpq⟩ + +noncomputable def supCode (c F : ZFSet.{0}) : ZFSet.{0} := regular c (ZFSet.sUnion F) + +theorem join_mem (M c F : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hF : F ∈ M) : supCode c F ∈ M := + regular_mem M c _ hM hT hc (union_mem M hM hT.union hF) + +noncomputable def bitCode (c E : ZFSet.{0}) : ZFSet.{0} := + regular c (CohenInternalDecision.below c E) + +theorem bitCode_mem (M c E : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hE : E ∈ M) : bitCode c E ∈ M := + regular_mem M c _ hM hT hc (CohenInternalDecision.below_mem M c E hM hT hc hE) + +end TuringRigidity.InternalRegularOperations + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularOrder.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularOrder.lean new file mode 100644 index 0000000000000000000000000000000000000000..efa9bdf823850625fe59c5601a6da59c7c3f6f9c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularOrder.lean @@ -0,0 +1,76 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalGeneratedAlgebra + +namespace OAI + +namespace TuringRigidity.InternalRegularOrder +open TransitiveNameModel BoundedSetTheory InternalRegularOperations InternalRegularAlgebra + +theorem neg_antitone (c U V : ZFSet.{0}) (h : U ⊆ V) : neg c V ⊆ neg c U := by + intro p hp + obtain ⟨hpc,hp⟩ := ZFSet.mem_sep.mp hp + exact ZFSet.mem_sep.mpr ⟨hpc,fun q hq => hp q (h hq)⟩ + +theorem regular_mono (c U V : ZFSet.{0}) (h : U ⊆ V) : regular c U ⊆ regular c V := + neg_antitone c _ _ (neg_antitone c U V h) + +theorem subset_regular (c U : ZFSet.{0}) (hUc : U ⊆ c) (hU : Lower c U) : U ⊆ regular c U := by + intro p hp + exact (mem_regular c U p).mpr ⟨hUc hp,fun q hq hpq => ⟨q,hU p hp q hq hpq,fun _ h => h⟩⟩ + +theorem regular_le_iff (c U V : ZFSet.{0}) (hUc : U ⊆ c) (hU : Lower c U) + (hV : IsCode c V) : regular c U ⊆ V ↔ U ⊆ V := by + constructor + · intro h p hp; exact h (subset_regular c U hUc hU hp) + · intro h p hp + have hx := regular_mono c U V h hp + rwa [hV.2] at hx + +theorem union_subset (c F : ZFSet.{0}) (hF : ∀ U ∈ F, IsCode c U) : ZFSet.sUnion F ⊆ c := by + intro p hp + obtain ⟨U,hU,hp⟩ := ZFSet.mem_sUnion.mp hp + exact (hF U hU).1 hp + +theorem supCode_le_iff (c F V : ZFSet.{0}) (hF : ∀ U ∈ F, IsCode c U) + (hV : IsCode c V) : supCode c F ⊆ V ↔ ∀ U ∈ F, U ⊆ V := by + rw [supCode,regular_le_iff c _ V (union_subset c F hF) + (union_lower c F (fun U hU => code_lower c U (hF U hU))) hV] + constructor + · intro h U hU p hp; exact h (ZFSet.mem_sUnion.mpr ⟨U,hU,hp⟩) + · intro h p hp + obtain ⟨U,hU,hp⟩ := ZFSet.mem_sUnion.mp hp + exact h U hU hp + +theorem subset_supCode (c F : ZFSet.{0}) (hF : ∀ U ∈ F, IsCode c U) + {U : ZFSet.{0}} (hU : U ∈ F) : U ⊆ supCode c F := + (supCode_le_iff c F _ hF (join_isCode c F)).mp (fun _ h => h) U hU + +noncomputable def infCode (c F : ZFSet.{0}) : ZFSet.{0} := + c.sep (fun p => ∀ U ∈ F, p ∈ U) + +theorem inf_subset (c F : ZFSet.{0}) {U : ZFSet.{0}} (hU : U ∈ F) : infCode c F ⊆ U := + fun _ hp => (ZFSet.mem_sep.mp hp).2 U hU + +theorem subset_inf (c F U : ZFSet.{0}) (hUc : U ⊆ c) (h : ∀ V ∈ F, U ⊆ V) : + U ⊆ infCode c F := fun _ hp => ZFSet.mem_sep.mpr ⟨hUc hp,fun V hV => h V hV hp⟩ + +theorem inf_isCode (c F : ZFSet.{0}) (hF : ∀ U ∈ F, IsCode c U) : IsCode c (infCode c F) := by + have hc : infCode c F ⊆ c := fun _ h => (ZFSet.mem_sep.mp h).1 + have hl : Lower c (infCode c F) := by + intro p hp q hq hpq + exact ZFSet.mem_sep.mpr ⟨hq,fun U hU => code_lower c U (hF U hU) + p ((ZFSet.mem_sep.mp hp).2 U hU) q hq hpq⟩ + refine ⟨hc,ZFSet.ext (fun p => ⟨?_,fun hp => subset_regular c _ hc hl hp⟩)⟩ + intro hp + refine ZFSet.mem_sep.mpr ⟨neg_subset c _ hp,fun U hU => ?_⟩ + have hx := regular_mono c (infCode c F) U (inf_subset c F hU) hp + rwa [(hF U hU).2] at hx + +theorem inf_mem (M c F : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hF : F ∈ M) : infCode c F ∈ M := by + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (.allMem 1 (.member 1 0)) (fun _ => F) (fun _ => hF) hc + simpa only [infCode,Formula.eval_allMem,Formula.Eval,cons_zero,cons_succ] using hs + +end TuringRigidity.InternalRegularOrder + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularSplitter.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularSplitter.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a784b6bb539df90fc9c4a6d1e430ca34a39a13f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularSplitter.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularDecisionPartition +import OAI.Computability.DegreeRigidity.SetModels.InternalProjectedGeneric +import OAI.Computability.DegreeRigidity.CohenForcing.CohenProductSplitting + +namespace OAI + +namespace TuringRigidity.InternalRegularSplitter +open TransitiveNameModel BoundedSetTheory InternalRegularOperations InternalRegularAlgebra +open InternalProjectedGeneric RegularDecisionPartition RegularCodeSplitting + +theorem splitter_graph (M c B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hsplit : ∀ p ∈ c, ∃ p0 ∈ c, ∃ p1 ∈ c, p ⊆ p0 ∧ p ⊆ p1 ∧ + ¬ ∃ r ∈ c, p0 ⊆ r ∧ p1 ⊆ r) : + ∃ T ∈ M, FunctionGraph (ZFSet.prod (positive B) B) + (ZFSet.prod (positive B) (positive B)) T ∧ + ∀ U ∈ positive B, ∀ D ∈ B, ∀ V W, + ZFSet.pair (ZFSet.pair U D) (ZFSet.pair V W) ∈ T → + V ∈ positive B ∧ W ∈ positive B ∧ Refines c U D V W := by + let P := positive B + let X := ZFSet.prod P B + let Y := ZFSet.prod P P + have hP := positive_mem M B hM hT hBM + have hX := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hP hBM + have hY := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hP hP + let e := cons X (cons Y (cons P (cons B (fun _ => c)))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|i + exact hX; exact hY; exact hP; exact hBM; exact hc + let φ : Formula := .existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) + (.existsMem 5 (.existsMem 7 (.conj (.orderedPair 3 1 0) + (.existsMem 7 (.existsMem 8 (.conj (.orderedPair 4 1 0) + (refiningFormula 11 3 2 1 0))))))))) + let R := (ZFSet.prod X Y).sep (fun z => φ.Eval (cons z e)) + have hRM : R ∈ M := sep_mem M hM hT.separation.finitePrefix.bounded φ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hX hY) + have hR (U D V W : ZFSet.{0}) : + ZFSet.pair (ZFSet.pair U D) (ZFSet.pair V W) ∈ R ↔ + U ∈ P ∧ D ∈ B ∧ V ∈ P ∧ W ∈ P ∧ Refines c U D V W := by + simp only [R,ZFSet.mem_sep,φ,Formula.Eval,Formula.eval_orderedPair, + refiningFormula_spec,cons_zero,cons_succ,e] + constructor + · rintro ⟨_,x,_,y,_,hxy,U',hU,D',hD,hUD,V',hV,W',hW,hVW,h⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hxy + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hUD + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hVW + exact ⟨hU,hD,hV,hW,h⟩ + · rintro ⟨hU,hD,hV,hW,h⟩ + have hx : ZFSet.pair U D ∈ X := ZFSet.pair_mem_prod.mpr ⟨hU,hD⟩ + have hy : ZFSet.pair V W ∈ Y := ZFSet.pair_mem_prod.mpr ⟨hV,hW⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨hx,hy⟩,_,hx,_,hy,rfl,U,hU,D,hD,rfl,V,hV,W,hW,rfl,h⟩ + have htotal : ∀ x ∈ X, ∃ y ∈ Y, ZFSet.pair x y ∈ R := by + intro x hx + obtain ⟨U,hU,D,hD,rfl⟩ := ZFSet.mem_prod.mp hx + obtain ⟨hUB,hU0⟩ := ZFSet.mem_sep.mp hU + obtain ⟨V,hV,W,hW,h⟩ := refining_partition M c B hM hT hc hB hsplit U D hUB hD hU0 + have hVP : V ∈ P := ZFSet.mem_sep.mpr ⟨hV,h.1.2.2.1⟩ + have hWP : W ∈ P := ZFSet.mem_sep.mpr ⟨hW,h.1.2.2.2.1⟩ + exact ⟨ZFSet.pair V W,ZFSet.pair_mem_prod.mpr ⟨hVP,hWP⟩, + (hR U D V W).mpr ⟨hU,hD,hVP,hWP,h⟩⟩ + obtain ⟨T,hTmem,hfun,hTR⟩ := InternalRelationSelection.select_relation M X Y R + hM hT hX hY hRM htotal + exact ⟨T,hTmem,hfun,fun U _ D _ V W hp => ((hR U D V W).mp (hTR hp)).2.2⟩ + +theorem counted_cohen_presentation (M q : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hq : q ∈ M) (hct : InternallyCountable M q) : + ∃ c ∈ M, + (∀ z, z ∈ c ↔ ∃ p ∈ q, ∃ s ∈ CohenGroundPoset.conditions ZFSet.omega, + z = TaggedProductConditions.code p s) ∧ + InternalCollapse.orderSet c ∈ M ∧ InternallyCountable M c ∧ + ∃ B ∈ M, (∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) ∧ + ∃ S ∈ M, InternallyCountable M S ∧ S ⊆ positive B ∧ + (∀ U, U ∈ S ↔ ∃ p ∈ c, U = InternalBooleanDense.basicCode c p) ∧ + (∀ U, IsCode c U → U ≠ ∅ → ∃ V ∈ S, V ⊆ U) ∧ + ∃ T ∈ M, FunctionGraph (ZFSet.prod (positive B) B) + (ZFSet.prod (positive B) (positive B)) T ∧ + ∀ U ∈ positive B, ∀ D ∈ B, ∀ V W, + ZFSet.pair (ZFSet.pair U D) (ZFSet.pair V W) ∈ T → + V ∈ positive B ∧ W ∈ positive B ∧ Refines c U D V W := by + have hω := sourceT_omega_mem M hM hT + obtain ⟨c,hc,hcs,hco,hcc⟩ := TaggedProductConditions.product_countable M q + (CohenGroundPoset.conditions ZFSet.omega) hM hT hq + (CohenGroundPoset.conditions_mem M _ hM hT hω) hct + (CountedCohenConditions.conditions_countable M _ hM hT hω + (Or.inr (InternalCountableProduct.omega_countable M hM hT))) + obtain ⟨B,hBM,hB⟩ := internal_algebra M c hM hT hc + obtain ⟨S,hSM,hSc,hSs,hSp,hSd⟩ := CountedRegularBasis.counted_basis M c hM hT hc hcc + refine ⟨c,hc,hcs,hco,hcc,B,hBM,hB,S,hSM,hSc,?_,hSs,hSd,?_⟩ + · intro U hU + exact ZFSet.mem_sep.mpr ⟨(hB U).mpr ⟨hM S hSM U hU,(hSp U hU).1⟩,(hSp U hU).2⟩ + · exact splitter_graph M c B hM hT hc hBM hB (CohenProductSplitting.product_splits q c hcs) + +end TuringRigidity.InternalRegularSplitter + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularTree.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..164fb5ed89eac7c7cae46c694d0edf2e64ec1eb5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRegularTree.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularTreeRun + +namespace OAI + +namespace TuringRigidity.InternalRegularTree +open TransitiveNameModel BoundedSetTheory InternalProjectedGeneric RegularBinaryTree RegularTreeRun + +theorem graph_domain_unique (a b C f : ZFSet.{0}) + (ha : FunctionGraph a C f) (hb : FunctionGraph b C f) : a = b := by + apply ZFSet.ext; intro x + constructor + · intro hx + obtain ⟨y,_,hxy,_⟩ := ha.2 x hx + obtain ⟨x',hx',y',_,he⟩ := hb.1 _ hxy + exact (ZFSet.pair_inj.mp he).1 ▸ hx' + · intro hx + obtain ⟨y,_,hxy,_⟩ := hb.2 x hx + obtain ⟨x',hx',y',_,he⟩ := ha.1 _ hxy + exact (ZFSet.pair_inj.mp he).1 ▸ hx' + +theorem tree_graph_internal (M c B T : ZFSet.{0}) (E : ℕ → ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hBM : B ∈ M) (hTM : T ∈ M) + (hc : c ∈ positive B) + (hf : FunctionGraph (ZFSet.prod (positive B) B) (ZFSet.prod (positive B) (positive B)) T) + (hE : ∀ n, E n ∈ B) (hEM : orbitGraph E ∈ M) : + ∃ A ∈ M, FunctionGraph InternalCohen.conditions (positive B) A ∧ + ∀ (s : List Bool) U, + ZFSet.pair (InternalCohen.wordCode s) U ∈ A ↔ U = tree c B T E s := by + let P := positive B + let X := ZFSet.prod P B + let Y := ZFSet.prod P P + have hP := positive_mem M B hM hT hBM + have hω := sourceT_omega_mem M hM hT + have hcM := hM _ hP _ hc + have hX := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hP hBM + have hY := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hP hP + have hW := InternalCohen.conditions_mem M hM hT + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_model_graph_bound M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hω P hP + let e := cons ZFSet.omega (cons P (cons Q (cons c (cons B (cons X (cons Y + (cons T (cons (orbitGraph E) (cons (InternalCohen.bitSet true) + (cons InternalCohen.alphabet (fun _ => InternalCohen.conditions))))))))))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|_|_|_|_|_|_|_|i + exact hω; exact hP; exact hQM; exact hcM; exact hBM; exact hX; exact hY + exact hTM; exact hEM + exact hM _ (InternalCohen.alphabet_mem M hM hT) _ ((InternalCohen.mem_alphabet _).mpr ⟨true,rfl⟩) + exact InternalCohen.alphabet_mem M hM hT + exact hW + let θ := stepFormula 11 8 12 13 14 15 5 16 2 1 0 + let ψ := Formula.modelIteration 4 5 6 0 7 1 θ + have hψ (s : List Bool) (n : ℕ) (U z : ZFSet.{0}) : + ψ.Eval (cons (natSet n) (cons U (cons (InternalCohen.wordCode s) (cons z e)))) ↔ + U = run c B T E (InternalCohen.wordCode s) n := by + apply Formula.modelIteration_spec 4 5 6 0 7 1 θ _ rfl hQ n rfl + (run c B T E (InternalCohen.wordCode s)) (run_positive c B T E _ hc hf hE) rfl + intro i V _ + exact stepFormula_spec B T E (InternalCohen.wordCode s) _ V i hf + (run_positive c B T E _ hc hf hE i) hE + 11 8 12 13 14 15 5 16 2 1 0 _ rfl rfl rfl rfl rfl rfl rfl rfl rfl rfl rfl + let φ : Formula := .existsMem 12 (.existsMem 3 (.conj (.orderedPair 2 1 0) + (.existsMem 3 (.conj (.functionGraph 2 0 14) ψ)))) + let A := (ZFSet.prod InternalCohen.conditions P).sep (fun z => φ.Eval (cons z e)) + have hAM : A ∈ M := sep_mem M hM hT.separation.finitePrefix.bounded φ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hW hP) + have hgs (s : List Bool) (U : ZFSet.{0}) : + ZFSet.pair (InternalCohen.wordCode s) U ∈ A ↔ U = tree c B T E s := by + simp only [A,ZFSet.mem_sep,φ,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,e] + constructor + · rintro ⟨_,w,_,V,_,he,n,hn,hfun,hiter⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + have hfg : FunctionGraph n InternalCohen.alphabet (InternalCohen.wordCode s) := + (Formula.eval_functionGraph 2 0 14 _).mp hfun + have hlen := graph_domain_unique n (natSet s.length) _ _ hfg (InternalCohen.wordCode_function s) + subst n + exact ((hψ s s.length U _).mp hiter).trans (run_word c B T E s) + · intro heq + have hUP : U ∈ P := heq ▸ tree_positive c B T E hc hf hE s + have hsW : InternalCohen.wordCode s ∈ InternalCohen.conditions := + (InternalCohen.mem_conditions _).mpr ((InternalCohen.prefix_iff_wordCode _).mpr ⟨s,rfl⟩) + refine ⟨ZFSet.pair_mem_prod.mpr ⟨hsW,hUP⟩,_,hsW,U,hUP,rfl,natSet s.length, + (mem_omega _).mpr ⟨s.length,rfl⟩,?_,?_⟩ + · exact (Formula.eval_functionGraph 2 0 14 _).mpr (InternalCohen.wordCode_function s) + · exact (hψ s s.length U _).mpr (heq.trans (run_word c B T E s).symm) + refine ⟨A,hAM,⟨?_,?_⟩,hgs⟩ + · intro z hz; exact ZFSet.mem_prod.mp (ZFSet.mem_sep.mp hz).1 + · intro w hw + obtain ⟨s,rfl⟩ := (InternalCohen.prefix_iff_wordCode w).mp ((InternalCohen.mem_conditions w).mp hw) + exact ⟨tree c B T E s,tree_positive c B T E hc hf hE s,(hgs s _).mpr rfl, + fun U _ hU => (hgs s U).mp hU⟩ + +end TuringRigidity.InternalRegularTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRelationCollapse.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRelationCollapse.lean new file mode 100644 index 0000000000000000000000000000000000000000..b87afffab8d1d8807c49ef78f60ba41f2e166425 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRelationCollapse.lean @@ -0,0 +1,164 @@ +import OAI.Computability.DegreeRigidity.SetModels.RelationCollapse + +namespace OAI + + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory +universe u + +noncomputable def nextValue (d r x f : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ y ∈ d, ZFSet.pair y x ∈ r ∧ ZFSet.pair y z ∈ f) (iterUnion 2 f) + +theorem mem_nextValue (d r x f z : ZFSet.{u}) : + z ∈ nextValue d r x f ↔ ∃ y ∈ d, ZFSet.pair y x ∈ r ∧ ZFSet.pair y z ∈ f := by + rw [nextValue,ZFSet.mem_sep] + constructor + · exact And.right + · intro h + obtain ⟨y,hy,hyx,hyz⟩ := h + exact ⟨second_mem_doubleUnion hyz,y,hy,hyx,hyz⟩ + +def nextFormula : Formula := .existsMem 1 (.conj (.pairMem 0 3 4) (.pairMem 0 1 5)) + +theorem nextValue_mem (M : ZFSet.{u}) (hM : Transitive M) + (hU : BoundedSetTheory.Union M) (hS : Separation M) + {d r x f : ZFSet.{u}} (hd : d ∈ M) (hr : r ∈ M) (hx : x ∈ M) (hf : f ∈ M) : + nextValue d r x f ∈ M := by + let e := cons d (cons x (cons r (cons f (fun _ => d)))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hd + rcases i with _|i; exact hx + rcases i with _|i; exact hr + rcases i with _|i; exact hf + exact hd + simpa only [nextFormula,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e,nextValue] using + sep_mem M hM hS nextFormula e he (iterUnion_mem M hM hU hf 2) + +def certificate : SigmaFormula := .existsSet (.existsSet (.bounded + (.conj (RelationHull.Code.isHull 1 3 4 5 6) (Code.graph 5 6 1 0 2)))) + +theorem realize_certificate (M d r q : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hd : d ∈ M) (hr : r ∈ M) (hqM : q ∈ M) + (hq : ∀ a, a ∈ q ↔ a ∈ M ∧ a ⊆ d) + {x f : ZFSet.{u}} (hx : x ∈ d) (hf : f ∈ M) : + certificate.Realize M (cons f (cons x (cons q (cons d (cons r (fun _ => d)))))) ↔ + ∃ b ∈ M, Graph d r (RelationHull.hull d r q x) b f := by + have hxM := hM d hd x hx + have matrix (a b : ZFSet.{u}) (ha : a ∈ M) (hb : b ∈ M) : + (Formula.conj (RelationHull.Code.isHull 1 3 4 5 6) (Code.graph 5 6 1 0 2)).Realize M + (cons b (cons a (cons f (cons x (cons q (cons d (cons r (fun _ => d)))))))) ↔ + a = RelationHull.hull d r q x ∧ Graph d r a b f := by + rw [Formula.absolute _ M hM _ (by + intro i; rcases i with _|i; exact hb + rcases i with _|i; exact ha + rcases i with _|i; exact hf + rcases i with _|i; exact hxM + rcases i with _|i; exact hqM + rcases i with _|i; exact hd + rcases i with _|i; exact hr + exact hd)] + simp only [Formula.Eval,RelationHull.Code.eval_isHull,Code.eval_graph,cons_zero,cons_succ] + exact and_congr (RelationHull.isHull_iff M d r q hM hS hd hr hqM hq hx) Iff.rfl + change (∃ a ∈ M, ∃ b ∈ M, _) ↔ _ + constructor + · rintro ⟨a,ha,b,hb,h⟩ + obtain ⟨rfl,hg⟩ := (matrix a b ha hb).mp h + exact ⟨b,hb,hg⟩ + · rintro ⟨b,hb,hg⟩ + have ha := RelationHull.hull_mem M d r q hM hS hd hr hqM hxM + exact ⟨_,ha,b,hb,(matrix _ b ha hb).mpr ⟨rfl,hg⟩⟩ + +theorem internal_hull_graph (M d r q : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hS : Separation M) (hR : SigmaReplacement M) + (hd : d ∈ M) (hr : r ∈ M) (hqM : q ∈ M) + (hq : ∀ a, a ∈ q ↔ a ∈ M ∧ a ⊆ d) + (wf : WellFounded (Rel d r)) (x : ZFSet.{u}) (hx : x ∈ d) : + ∃ f ∈ M, Graph d r (RelationHull.hull d r q x) (iterUnion 2 f) f := by + induction x using wf.induction with + | h x ih => + have hxM := hM d hd x hx + let e := cons q (cons d (cons r (fun _ => d))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hqM + rcases i with _|i; exact hd + rcases i with _|i; exact hr + exact hd + have cert (y f : ZFSet.{u}) (hy : y ∈ RelationHull.predecessors d r x) (hf : f ∈ M) : + certificate.Realize M (cons f (cons y e)) ↔ + ∃ b ∈ M, Graph d r (RelationHull.hull d r q y) b f := + realize_certificate M d r q hM hS hd hr hqM hq + ((RelationHull.mem_predecessors _ _ _ _).mp hy).1 hf + have predM := RelationHull.predecessors_mem M hM hS hd hr hxM + obtain ⟨B,hB,hBdef⟩ := hR certificate e he _ predM (by + intro y hy + have hyr := (RelationHull.mem_predecessors _ _ _ _).mp hy + obtain ⟨f,hf,hfg⟩ := ih y hyr hyr.1 + refine ⟨f,hf,(cert y f hy hf).mpr ⟨_,iterUnion_mem M hM hU hf 2,hfg⟩,?_⟩ + intro g hg hcg + obtain ⟨b,_,hgg⟩ := (cert y g hy hg).mp hcg + exact hgg.unique wf hfg) + have hBg (f : ZFSet.{u}) : f ∈ B ↔ + ∃ y ∈ RelationHull.predecessors d r x, ∃ b ∈ M, + Graph d r (RelationHull.hull d r q y) b f := by + constructor + · intro hf + have hfM := hM B hB f hf + obtain ⟨y,hy,hc⟩ := (hBdef f hfM).mp hf + exact ⟨y,hy,(cert y f hy hfM).mp hc⟩ + · rintro ⟨y,hy,b,hb,hg⟩ + have hyr := (RelationHull.mem_predecessors _ _ _ _).mp hy + obtain ⟨f',hf',hg'⟩ := ih y hyr hyr.1 + have hfM : f ∈ M := hg.unique wf hg' ▸ hf' + exact (hBdef f hfM).mpr ⟨y,hy,(cert y f hy hfM).mpr ⟨b,hb,hg⟩⟩ + let g := ZFSet.sUnion B + have hgM : g ∈ M := union_mem M hM hU hB + have hg (z : ZFSet.{u}) : z ∈ g ↔ + ∃ y ∈ RelationHull.predecessors d r x, ∃ w ∈ RelationHull.hull d r q y, + z = ZFSet.pair w (value d r wf w) := by + constructor + · intro hz + obtain ⟨f,hf,hzf⟩ := ZFSet.mem_sUnion.mp hz + obtain ⟨y,hy,b,_,hfg⟩ := (hBg f).mp hf + exact ⟨y,hy,(hfg.mem_iff wf z).mp hzf⟩ + · rintro ⟨y,hy,w,hw,hz⟩ + have hyr := (RelationHull.mem_predecessors _ _ _ _).mp hy + obtain ⟨f,hf,hfg⟩ := ih y hyr hyr.1 + exact ZFSet.mem_sUnion.mpr ⟨f,(hBg f).mpr + ⟨y,hy,_,iterUnion_mem M hM hU hf 2,hfg⟩,(hfg.mem_iff wf z).mpr ⟨w,hw,hz⟩⟩ + have hvalue : nextValue d r x g = value d r wf x := by + apply ZFSet.ext + intro z + rw [mem_nextValue,mem_value] + constructor + · rintro ⟨y,hyd,hyx,hyz⟩ + obtain ⟨a,_,w,_,heq⟩ := (hg _).mp hyz + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + exact ⟨y,hyd,hyx,rfl⟩ + · rintro ⟨y,hyd,hyx,rfl⟩ + exact ⟨y,hyd,hyx,(hg _).mpr + ⟨y,(RelationHull.mem_predecessors _ _ _ _).mpr ⟨hyd,hyx⟩, + y,RelationHull.self_mem d r q hyd,rfl⟩⟩ + have hvM : value d r wf x ∈ M := hvalue ▸ nextValue_mem M hM hU hS hd hr hxM hgM + let f := g ∪ ({ZFSet.pair x (value d r wf x)} : ZFSet.{u}) + have hfM : f ∈ M := binary_union_mem M hM hP hU hgM + (singleton_mem M hM hP (orderedPair_mem M hM hP hxM hvM)) + refine ⟨f,hfM,graph_of_mem_iff d r _ f wf (RelationHull.hull_subset d r q x) + (RelationHull.hull_closed d r q x) ?_⟩ + intro z + change z ∈ g ∪ ({ZFSet.pair x (value d r wf x)} : ZFSet.{u}) ↔ _ + rw [ZFSet.mem_union,ZFSet.mem_singleton,hg] + constructor + · rintro (⟨y,hy,w,hw,hz⟩|hz) + · exact ⟨w,(RelationHull.hull_unfold M d r q hM hP hU hS hR hd hr hqM hq hx w).mpr + (Or.inr ⟨y,hy,hw⟩),hz⟩ + · exact ⟨x,RelationHull.self_mem d r q hx,hz⟩ + · rintro ⟨w,hw,hz⟩ + rcases (RelationHull.hull_unfold M d r q hM hP hU hS hR hd hr hqM hq hx w).mp hw with rfl|⟨y,hy,hw⟩ + · exact Or.inr hz + · exact Or.inl ⟨y,hy,w,hw,hz⟩ + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRelationSelection.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRelationSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..871cb6b11dc1a273e9b3642133ca86917635dd2c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalRelationSelection.lean @@ -0,0 +1,116 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableFiniteUnion + +namespace OAI + +namespace TuringRigidity.InternalRelationSelection +open TransitiveNameModel BoundedSetTheory + +noncomputable def fiber (Y R x : ZFSet.{0}) : ZFSet.{0} := + Y.sep (fun y => ZFSet.pair x y ∈ R) + +def fiberFormula (Y R x a : ℕ) : Formula := .conj (.subset a Y) + (.allMem Y (.iff (.member 0 (a+1)) (.pairMem (x+1) 0 (R+1)))) + +theorem fiberFormula_spec (Y R x a : ℕ) (e : ℕ → ZFSet.{0}) : + (fiberFormula Y R x a).Eval e ↔ e a = fiber (e Y) (e R) (e x) := by + simp only [fiberFormula,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_iff,Formula.eval_pairMem,Formula.Eval,cons_zero,cons_succ] + constructor + · rintro ⟨hs,h⟩ + apply ZFSet.ext; intro y + exact ⟨fun hy => ZFSet.mem_sep.mpr ⟨hs hy,(h y (hs hy)).mp hy⟩, + fun hy => (h y (ZFSet.mem_sep.mp hy).1).mpr (ZFSet.mem_sep.mp hy).2⟩ + · rintro h + rw [h] + exact ⟨fun _ hy => (ZFSet.mem_sep.mp hy).1, + fun y hy => ZFSet.mem_sep.trans (and_iff_right hy)⟩ + +theorem fiber_mem (M Y R x : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hY : Y ∈ M) (hR : R ∈ M) (hx : x ∈ M) : fiber Y R x ∈ M := by + let e := cons x (fun _ => R) + have he : ∀ i, e i ∈ M := by intro i; cases i; exact hx; exact hR + simpa only [fiber,Formula.eval_pairMem,cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded (.pairMem 1 0 2) e he hY + +theorem select_relation (M X Y R : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hX : X ∈ M) (hY : Y ∈ M) (hR : R ∈ M) + (htotal : ∀ x ∈ X, ∃ y ∈ Y, ZFSet.pair x y ∈ R) : + ∃ T ∈ M, FunctionGraph X Y T ∧ T ⊆ R := by + obtain ⟨q,hq,s,hsM,hs,hqdef⟩ := internal_selector M hM hT.powerSet + hT.separation.finitePrefix.bounded hT.choice hY + have hf (x : ZFSet.{0}) (hx : x ∈ X) : fiber Y R x ∈ q := by + apply (hqdef _).mpr + obtain ⟨y,hy,hxy⟩ := htotal x hx + exact ⟨fiber_mem M Y R x hM hT hY hR (hM X hX x hx), + fun _ h => (ZFSet.mem_sep.mp h).1,y,ZFSet.mem_sep.mpr ⟨hy,hxy⟩⟩ + let e := cons X (cons Y (cons R (cons q (fun _ => s)))) + let φ : Formula := .existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) + (.existsMem 6 (.conj (fiberFormula 5 6 2 0) (.pairMem 0 1 8))))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|i + exact hX; exact hY; exact hR; exact hq; exact hsM + let T := (ZFSet.prod X Y).sep (fun z => φ.Eval (cons z e)) + have hTM : T ∈ M := sep_mem M hM hT.separation.finitePrefix.bounded φ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hX hY) + have hmem (z : ZFSet.{0}) : z ∈ T ↔ ∃ x ∈ X, ∃ y ∈ Y, + z = ZFSet.pair x y ∧ ZFSet.pair (fiber Y R x) y ∈ s := by + simp only [T,ZFSet.mem_sep,φ,Formula.Eval,Formula.eval_orderedPair, + Formula.eval_pairMem,fiberFormula_spec,cons_zero,cons_succ,e] + constructor + · rintro ⟨_,x,hx,y,hy,hz,a,_,ha,hay⟩ + exact ⟨x,hx,y,hy,hz,ha ▸ hay⟩ + · rintro ⟨x,hx,y,hy,rfl,hay⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨x,hx,y,hy,rfl⟩,x,hx,y,hy,rfl,fiber Y R x,hf x hx,rfl,hay⟩ + refine ⟨T,hTM,⟨?_,?_⟩,?_⟩ + · intro z hz + obtain ⟨x,hx,y,hy,hz,_⟩ := (hmem z).mp hz + exact ⟨x,hx,y,hy,hz⟩ + · intro x hx + obtain ⟨y,hy,hxy,_⟩ := hs.2 _ (hf x hx) + have hyY := (ZFSet.mem_sep.mp hy).1 + refine ⟨y,hyY,(hmem _).mpr ⟨x,hx,y,hyY,rfl,hxy⟩,?_⟩ + intro y' _ hxy' + obtain ⟨x',_,y'',_,hp,hfy⟩ := (hmem _).mp hxy' + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact hs.functional hfy hxy + · intro z hz + obtain ⟨x,_,y,_,rfl,hfy⟩ := (hmem z).mp hz + exact (ZFSet.mem_sep.mp (InternalWellOrder.choice_value_mem hs hfy)).2 + +theorem map_sequence (M X Y T : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hX : X ∈ M) (hY : Y ∈ M) (hTM : T ∈ M) (hf : FunctionGraph X Y T) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ X) (hB : orbitGraph E ∈ M) : + ∃ F : ℕ → ZFSet.{0}, orbitGraph F ∈ M ∧ + ∀ n, F n ∈ Y ∧ ZFSet.pair (E n) (F n) ∈ T := by + choose F hF hp hu using fun n => hf.2 (E n) (hE n) + let B := orbitGraph E + let e := cons ZFSet.omega (cons X (cons Y (cons B (fun _ => T)))) + let φ : Formula := .existsMem 1 (.existsMem 4 (.conj (.orderedPair 2 1 0) + (.existsMem 4 (.conj (.pairMem 2 0 7) (.pairMem 0 1 8))))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|i + exact sourceT_omega_mem M hM hT; exact hX; exact hY; exact hB; exact hTM + have hφ (z : ZFSet.{0}) : φ.Eval (cons z e) ↔ z ∈ orbitGraph F := by + simp only [φ,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem,cons_zero,cons_succ,e] + constructor + · rintro ⟨n,hn,y,hy,hz,x,_,hnx,hxy⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + have hx := (orbitGraph_pair E n x).mp hnx + have hy' := hf.functional (hE n) (hx ▸ hxy) (hp n) + exact (mem_orbitGraph F z).mpr ⟨n,by rw [hz,hy']⟩ + · intro hz + obtain ⟨n,rfl⟩ := (mem_orbitGraph F z).mp hz + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,F n,hF n,rfl,E n,hE n, + (orbitGraph_pair E n _).mpr rfl,hp n⟩ + have hh := sep_mem M hM hT.separation.finitePrefix.bounded φ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + (sourceT_omega_mem M hM hT) hY) + have heq : (ZFSet.prod ZFSet.omega Y).sep (fun z => φ.Eval (cons z e)) = orbitGraph F := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,hφ] + exact ⟨And.right,fun hz => ⟨ZFSet.mem_prod.mpr ((orbitGraph_function Y F hF).1 z hz),hz⟩⟩ + exact ⟨F,heq ▸ hh,fun n => ⟨hF n,hp n⟩⟩ + +end TuringRigidity.InternalRelationSelection + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSameNameGeneric.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSameNameGeneric.lean new file mode 100644 index 0000000000000000000000000000000000000000..7eba9be3f69915196837e1aa7ed3eca0ecfb30b3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSameNameGeneric.lean @@ -0,0 +1,84 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalProjectedGeneric + +namespace OAI + +namespace TuringRigidity.InternalSameNameGeneric +open Set TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalRegularOrder InternalBooleanSyntax +open InternalGeneratedAlgebra InternalBooleanProjection InternalBooleanGeneric InternalBooleanDense +open InternalBooleanBits InternalProjectedGeneric +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder +attribute [local instance] codeOrder codePreorder + +theorem projected_bit_iff (M c B Q A : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) + (hbits : ∀ n, bitCode c (E n) ∈ A) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) + (hTop : ⊤ ∈ G.carrier) (n : ℕ) : + (∃ q ∈ (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier, + label (positive A) q = bitCode c (E n)) ↔ + natSet n ∈ (InternalNiceName.nice E : RecursiveNames.Name (Conditions c)).val G.carrier := by + rw [← hit_bit_iff M c hM hT hc E hE G hG hTop n] + constructor + · rintro ⟨q,hq,he⟩ + change Hit G (label (positive A) q) at hq + rwa [he] at hq + · intro h + obtain ⟨p,hp,hpb⟩ := h + have hn : bitCode c (E n) ≠ ∅ := fun h0 => ZFSet.notMem_empty _ (h0 ▸ hpb) + obtain ⟨q,hq⟩ := label_surjective (positive A) (ZFSet.mem_sep.mpr ⟨hbits n,hn⟩) + refine ⟨q,?_,hq⟩ + change Hit G (label (positive A) q) + rw [hq] + exact ⟨p,hp,hpb⟩ + +theorem projected_condition (M c B Q A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) (p : Conditions c) (hp : p ∈ G.carrier) : + ∃ q ∈ (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier, + label (positive A) q = project c A (basicCode c (label c p)) := by + let b := basicCode c (label c p) + have hbM := basicCode_mem M c _ hM hT hc (label_mem c p) + have hbc : IsCode c b := regular_isCode c _ + have hpb := subset_project c A b hbc.1 (mem_basicCode c _ (label_mem c p)) + have hPA := project_mem_part M c B Q A b hM hT hc hBM hAM hbM hB hQ hA + have hn : project c A b ≠ ∅ := fun h => ZFSet.notMem_empty _ (h ▸ hpb) + obtain ⟨q,hq⟩ := label_surjective (positive A) (ZFSet.mem_sep.mpr ⟨hPA,hn⟩) + refine ⟨q,?_,hq⟩ + change Hit G (label (positive A) q) + rw [hq] + exact ⟨p,hp,hpb⟩ + +theorem internal_same_name_generic (M c : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) : + ∃ B ∈ M, ∃ Q ∈ M, ∃ A ∈ M, + (∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) ∧ + (∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) ∧ + A = generated c B Q (seeds c B E) ∧ Closed c B Q A ∧ + positive A ∈ M ∧ InternalBooleanGraph.inclusionOrder (positive A) ∈ M ∧ + InternalBooleanGraph.graph c B A ∈ M ∧ + ∀ G : GenericFilter (Conditions c), AtomicForcing.GroundGeneric M G → ⊤ ∈ G.carrier → + ∃ H : GenericFilter (Conditions (positive A)), AtomicForcing.GroundGeneric M H ∧ + (∀ n, (∃ q ∈ H.carrier, label (positive A) q = bitCode c (E n)) ↔ + natSet n ∈ (InternalNiceName.nice E : RecursiveNames.Name (Conditions c)).val G.carrier) ∧ + ∀ p ∈ G.carrier, ∃ q ∈ H.carrier, + label (positive A) q = project c A (basicCode c (label c p)) := by + obtain ⟨B,hBM,Q,hQM,A,hAM,hB,hQ,heq,hA,hbits,_⟩ := + internal_bit_generated_part M c hM hT hc E hE hgraph + refine ⟨B,hBM,Q,hQM,A,hAM,hB,hQ,heq,hA,positive_mem M A hM hT hAM, + (projected_order_code M A hM hT hAM).1,InternalBooleanGraph.graph_mem M c B A hM hT hc hBM hAM,?_⟩ + intro G hG hTop + refine ⟨projected M c B Q A hM hT hc hBM hAM hB hQ hA G, + projected_ground_generic M c B Q A hM hT hc hBM hAM hB hQ hA G hG,?_,?_⟩ + · exact fun n => projected_bit_iff M c B Q A hM hT hc hBM hAM hB hQ hA E hE hbits G hG hTop n + · exact fun p hp => projected_condition M c B Q A hM hT hc hBM hAM hB hQ hA G p hp + +end TuringRigidity.InternalSameNameGeneric + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSatisfactionSlice.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSatisfactionSlice.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6e2a5764bcdb1f6ca5320d8cb92f195d9f9c6fe --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSatisfactionSlice.lean @@ -0,0 +1,104 @@ +import OAI.Computability.DegreeRigidity.Syntax.FiniteGraphSatisfaction + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +theorem natSet_subset_iff (k n : ℕ) : natSet.{u} k ⊆ natSet n ↔ k ≤ n := by + constructor + · intro h + by_contra hn + have hk : n < k := by omega + have hn' := (natSet_mem_natSet n n).mp (h ((natSet_mem_natSet n k).mpr hk)) + omega + · intro h x hx + obtain ⟨i,hi,rfl⟩ := (mem_natSet k x).mp hx + exact (natSet_mem_natSet i n).mpr (by omega) + +theorem satisfactionSet_record (A : ZFSet.{u}) (p : SentenceForm) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) : + ZFSet.pair (natSet (Encodable.encode p)) (tupleCode v) ∈ satisfactionSet A ↔ + p.bound ≤ n ∧ p.Sat (A : Set ZFSet) (tupleEnv v) := by + constructor + · intro h + obtain ⟨⟨⟨m,q,w⟩,hqm,hq⟩,he⟩ := ZFSet.mem_range.mp h + obtain ⟨hp,ht⟩ := ZFSet.pair_inj.mp he + have hqp : q = p := Encodable.encode_injective (natSet_injective hp) + subst q + have hmn : m = n := tupleCode_length _ _ ht + subst m + have hwv := tupleCode_injective n ht + rw [hwv] at hq + exact ⟨hqm,hq⟩ + · rintro ⟨hb,hs⟩ + exact (satisfactionSet_spec A p v hv hb).mpr hs + +noncomputable def truthSlice (A : ZFSet.{u}) (p : SentenceForm) : ZFSet.{u} := + (tupleSpace A).sep (fun t => ZFSet.pair (natSet (Encodable.encode p)) t ∈ satisfactionSet A) + +theorem truthSlice_record (A : ZFSet.{u}) (p : SentenceForm) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) : + tupleCode v ∈ truthSlice A p ↔ p.bound ≤ n ∧ p.Sat (A : Set ZFSet) (tupleEnv v) := by + rw [truthSlice,ZFSet.mem_sep,satisfactionSet_record A p v hv] + exact and_iff_right ((mem_tupleSpace A _).mpr ⟨n,v,hv,rfl⟩) + +def tupleTruth (p : SentenceForm) (o A Q b t : ℕ) (idx : ℕ → ℕ) : Formula := + .existsMem o (.existsMem (Q+1) + (.conj (.orderedPair (t+2) 1 0) + (.conj (.subset (b+2) 1) (graphTruth p (A+2) 0 (fun i => idx i+2))))) + +theorem tupleTruth_spec (p : SentenceForm) (o A Q b t : ℕ) (idx : ℕ → ℕ) + (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) (hb : e b = natSet p.bound) + (hi : ∀ i, i < p.bound → e (idx i) = natSet i) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ e A) + (ht : e t = tupleCode v) (hQ : tupleGraph v ∈ e Q) : + (tupleTruth p o A Q b t idx).Eval e ↔ + p.bound ≤ n ∧ p.Sat (e A : Set ZFSet) (tupleEnv v) := by + simp only [tupleTruth,Formula.Eval,Formula.eval_orderedPair,Formula.eval_subset, + cons_zero,cons_succ] + constructor + · rintro ⟨m,_,g,_,hp,hsub,htruth⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp (ht.symm.trans hp) + have hbn : p.bound ≤ n := natSet_subset_iff p.bound n |>.mp (hb ▸ hsub) + exact ⟨hbn,(graphTruth_spec p (A+2) 0 (fun i => idx i+2) + (cons (tupleGraph v) (cons (natSet n) e)) v hv hbn rfl hi).mp htruth⟩ + · rintro ⟨hbn,htruth⟩ + refine ⟨natSet n,ho ▸ (mem_omega _).mpr ⟨n,rfl⟩,tupleGraph v,hQ,ht,?_,?_⟩ + · rw [hb]; exact (natSet_subset_iff p.bound n).mpr hbn + · exact (graphTruth_spec p (A+2) 0 (fun i => idx i+2) + (cons (tupleGraph v) (cons (natSet n) e)) v hv hbn rfl hi).mpr htruth + +theorem truthSlice_mem (M A : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) (p : SentenceForm) : truthSlice A p ∈ M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + have hn (n : ℕ) : natSet.{u} n ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩) + obtain ⟨Q,hQM,hQdef⟩ := internal_power M hM hT.powerSet + (product_mem M hM hT.pairing hT.union hT.powerSet hS hω hA) + have hQ {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) : tupleGraph v ∈ Q := by + apply (hQdef _).mpr + refine ⟨tupleGraph_mem M hM hT.pairing hT.union hω v (fun i => hM A hA _ (hv i)),?_⟩ + intro z hz + obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hz + exact ZFSet.mem_prod.mpr ⟨_,(mem_omega _).mpr ⟨i.val,rfl⟩,_,hv i,rfl⟩ + let e := cons ZFSet.omega (cons A (cons Q (cons (natSet p.bound) natSet))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|i + exact hω; exact hA; exact hQM; exact hn _; exact hn _ + let φ := tupleTruth p 1 2 3 4 0 (fun i => i+5) + have hs := sep_mem M hM hS φ e he (tupleSpace_mem M A hM hT hA) + have heq : (tupleSpace A).sep (fun t => φ.Eval (cons t e)) = truthSlice A p := by + apply ZFSet.ext; intro t + rw [truthSlice,ZFSet.mem_sep,ZFSet.mem_sep] + apply and_congr_right; intro ht + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp ht + exact (tupleTruth_spec p 1 2 3 4 0 (fun i => i+5) (cons (tupleCode v) e) + rfl rfl (fun _ _ => rfl) v hv rfl (hQ v hv)).trans (satisfactionSet_record A p v hv).symm + exact heq ▸ hs + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSequenceRange.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSequenceRange.lean new file mode 100644 index 0000000000000000000000000000000000000000..ecd3db592f8b1cb59d4fa1605fd2cec53d05b22e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSequenceRange.lean @@ -0,0 +1,45 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalRelationSelection + +namespace OAI + +namespace TuringRigidity.InternalSequenceRange +open TransitiveNameModel BoundedSetTheory + +noncomputable def rangeSet (X B : ZFSet.{0}) : ZFSet.{0} := + X.sep (fun x => ∃ n ∈ ZFSet.omega, ZFSet.pair n x ∈ B) + +theorem rangeSet_mem (M X B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hX : X ∈ M) (hB : B ∈ M) : rangeSet X B ∈ M := by + let e := cons ZFSet.omega (fun _ => B) + have he : ∀ i, e i ∈ M := by + intro i; cases i; exact sourceT_omega_mem M hM hT; exact hB + simpa only [rangeSet,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded (.existsMem 1 (.pairMem 0 1 3)) e he hX + +theorem mem_rangeSet (X : ZFSet.{0}) (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ X) + (x : ZFSet.{0}) : x ∈ rangeSet X (orbitGraph E) ↔ ∃ n, x = E n := by + rw [rangeSet,ZFSet.mem_sep] + constructor + · rintro ⟨_,n,hn,hpair⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + exact ⟨n,(orbitGraph_pair E n x).mp hpair⟩ + · rintro ⟨n,rfl⟩ + exact ⟨hE n,natSet n,(mem_omega _).mpr ⟨n,rfl⟩,(orbitGraph_pair E n _).mpr rfl⟩ + +noncomputable def unionSet (U S : ZFSet.{0}) : ZFSet.{0} := + U.sep (fun x => ∃ E ∈ S, x ∈ E) + +theorem unionSet_mem (M U S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hU : U ∈ M) (hS : S ∈ M) : unionSet U S ∈ M := by + simpa only [unionSet,Formula.Eval,cons_zero,cons_succ] using + sep_mem M hM hT.separation.finitePrefix.bounded (.existsMem 1 (.member 1 0)) + (fun _ => S) (fun _ => hS) hU + +theorem mem_unionSet (U S x : ZFSet.{0}) (hS : ∀ E ∈ S, E ⊆ U) : + x ∈ unionSet U S ↔ ∃ E ∈ S, x ∈ E := by + rw [unionSet,ZFSet.mem_sep] + exact ⟨And.right,fun ⟨E,hE,hx⟩ => ⟨hS E hE hx,E,hE,hx⟩⟩ + +end TuringRigidity.InternalSequenceRange + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSerialSelection.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSerialSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0d27b22df102ca7bafacaf4eaac2c4e5d64f098 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSerialSelection.lean @@ -0,0 +1,82 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTheory + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel RelationHull +universe u +namespace Formula + +def predecessorSet (d r x a : ℕ) : Formula := .conj (.subset a d) + (allMem d (iff (.member 0 (a+1)) (.pairMem 0 (x+1) (r+1)))) + +theorem eval_predecessorSet (d r x a : ℕ) (e : ℕ → ZFSet.{u}) : + (predecessorSet d r x a).Eval e ↔ e a = predecessors (e d) (e r) (e x) := by + simp only [predecessorSet,Formula.Eval,eval_subset,eval_allMem,eval_iff,eval_pairMem,cons_zero,cons_succ] + constructor + · rintro ⟨hsub,h⟩ + apply ZFSet.ext; intro y + rw [mem_predecessors] + exact ⟨fun hy => ⟨hsub hy,(h y (hsub hy)).mp hy⟩,fun hy => (h y hy.1).mpr hy.2⟩ + · intro he + rw [he] + exact ⟨fun _ h => (mem_predecessors _ _ _ _).mp h |>.1, + fun y hy => (mem_predecessors _ _ _ _).trans (and_iff_right hy)⟩ + +def serialSelector (d r q s z : ℕ) : Formula := .existsMem d (.existsMem (d+1) + (.conj (.orderedPair (z+2) 1 0) (.existsMem (q+2) + (.conj (predecessorSet (d+3) (r+3) 2 0) (.pairMem 0 1 (s+3)))))) +end Formula + +theorem internal_serial_function (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {d r : ZFSet.{u}} (hd : d ∈ M) (hr : r ∈ M) + (hser : ∀ x ∈ d, ∃ y ∈ d, ZFSet.pair y x ∈ r) : + ∃ F ∈ M, TransitiveNameModel.FunctionGraph d d F ∧ + ∀ x y, ZFSet.pair x y ∈ F → ZFSet.pair y x ∈ r := by + have hS := hT.separation.finitePrefix.bounded + obtain ⟨q,hq,s,hsM,hs,hqdef⟩ := internal_selector M hM hT.powerSet hS hT.choice hd + have hp (x : ZFSet.{u}) (hx : x ∈ d) : predecessors d r x ∈ q := by + apply (hqdef _).mpr + refine ⟨predecessors_mem M hM hS hd hr (hM _ hd _ hx), + fun _ h => (mem_predecessors _ _ _ _).mp h |>.1,?_⟩ + obtain ⟨y,hy,hyx⟩ := hser x hx + exact ⟨y,(mem_predecessors _ _ _ _).mpr ⟨hy,hyx⟩⟩ + let e := cons d (cons r (cons q (fun _ => s))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hd + rcases i with _|i; exact hr + rcases i with _|i; exact hq + exact hsM + let F := ZFSet.sep (fun z => (Formula.serialSelector 1 2 3 4 0).Eval (cons z e)) (ZFSet.prod d d) + have hFM : F ∈ M := sep_mem M hM hS _ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hS hd hd) + have hmem (z : ZFSet.{u}) : z ∈ F ↔ + ∃ x ∈ d, ∃ y ∈ d, z = ZFSet.pair x y ∧ ZFSet.pair (predecessors d r x) y ∈ s := by + simp only [F,ZFSet.mem_sep,Formula.serialSelector,Formula.Eval,Formula.eval_orderedPair, + Formula.eval_predecessorSet,Formula.eval_pairMem,cons_zero,cons_succ,e] + constructor + · rintro ⟨_,x,hx,y,hy,hz,a,_,rfl,hay⟩; exact ⟨x,hx,y,hy,hz,hay⟩ + · rintro ⟨x,hx,y,hy,rfl,hxy⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨x,hx,y,hy,rfl⟩,x,hx,y,hy,rfl,predecessors d r x,hp x hx,rfl,hxy⟩ + refine ⟨F,hFM,⟨?_,?_⟩,?_⟩ + · intro z hz + obtain ⟨x,hx,y,hy,hz,_⟩ := (hmem z).mp hz + exact ⟨x,hx,y,hy,hz⟩ + · intro x hx + obtain ⟨y,hy,hxy,_⟩ := hs.2 _ (hp x hx) + have hyd := ((mem_predecessors _ _ _ _).mp hy).1 + refine ⟨y,hyd,(hmem _).mpr ⟨x,hx,y,hyd,rfl,hxy⟩,?_⟩ + intro z _ hxz + obtain ⟨x',_,z',_,heq,hxz'⟩ := (hmem _).mp hxz + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + exact hs.functional hxz' hxy + · intro x y hxy + obtain ⟨x',_,y',_,heq,hsy⟩ := (hmem _).mp hxy + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + exact ((mem_predecessors _ _ _ _).mp (InternalWellOrder.choice_value_mem hs hsy)).2 + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalShuffleGeneric.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalShuffleGeneric.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3f452f4749b05f3a339df2e166886e494f89cda --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalShuffleGeneric.lean @@ -0,0 +1,38 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalShuffleSets + +namespace OAI + + +namespace TuringRigidity.InternalCohen +open TransitiveNameModel BoundedSetTheory CohenBorelForcing CountableForcing +open ShuffleRequirements FiniteShuffleCertificate +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem groundGeneric_shuffle (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (G : Oracle) (hG : AtomicForcing.GroundGeneric M (pushFilter (realFilter G))) + (Y : Oracle) : + AtomicForcing.GroundGeneric M (pushFilter (realFilter (GenericCoding.code Y G))) := by + apply (groundGeneric_iff M _).mpr + intro D hD hd + obtain ⟨p,hp,hstar⟩ := (groundGeneric_iff M _).mp hG (shuffleStar D) + (shuffleStar_mem M hM hT D hD) (shuffleStar_dense D hd) + rw [pull_push] at hp + have hc := (wordCode_mem_shuffleStar D p.word).mp hstar + obtain ⟨t,⟨r,hr,hrt⟩,htransfer⟩ := certificate_transfer (shuffleOpen D) p.word hc Y + refine ⟨⟨r⟩,?_,hr⟩ + rw [pull_push] + exact realizes_mono hrt (htransfer G hp) + +theorem shuffleStar_internal_dense (D : ZFSet.{0}) + (hD : Dense {p : Conditions conditions | label conditions p ∈ D}) : + Dense {p : Conditions conditions | label conditions p ∈ shuffleStar D} := by + apply (dense_pull_iff _).mp + have hd := (dense_pull_iff _).mpr hD + have hl (p : Condition) : label conditions (conditionEquiv p) = wordCode p.word := + label_encodeCondition p + simp only [Set.mem_ofPred_eq,hl] at hd ⊢ + exact shuffleStar_dense D hd + +end TuringRigidity.InternalCohen + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalShuffleSets.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalShuffleSets.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7137599e910421460d4955de95ca02534ef4577 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalShuffleSets.lean @@ -0,0 +1,97 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticShuffleCertificate +import OAI.Computability.DegreeRigidity.OrdinalCodes.NumericalCohenSets +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenFilters + +namespace OAI + + +namespace TuringRigidity.InternalCohen +open TransitiveNameModel BoundedSetTheory Encodable UniformArithmetic +open FiniteShuffleCertificate FiniteShuffle CohenBorelForcing CountableForcing + +def shuffleOpen (D : ZFSet.{0}) (t : List Bool) : Prop := + ∃ r : List Bool, wordCode r ∈ D ∧ r <+: t + +noncomputable def shuffleOpenCodes (D : ZFSet.{0}) : Oracle := + arithmeticReal (fun O n => ∃ r : List Bool, O 0 (encode r) = true ∧ r <+: EncodedForcing.word n) + (fun _ => wordPullback D) + +theorem shuffleOpenCodes_true (D : ZFSet.{0}) (n : ℕ) : + shuffleOpenCodes D n = true ↔ shuffleOpen D (EncodedForcing.word n) := by + rw [shuffleOpenCodes,arithmeticReal_true] + simp only [wordPullback_true,EncodedForcing.word,encodek,Option.getD_some,shuffleOpen] + +theorem shuffleOpenCodes_mem (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (D : ZFSet.{0}) (hD : D ∈ M) : realCode (shuffleOpenCodes D) ∈ M := + sourceT_arithmetic_comprehension M hM hT ArithmeticShuffleCertificate.open_arith + (fun _ => wordPullback D) (fun _ => wordPullback_mem M hM hT D hD) + +noncomputable def shuffleCertificateCodes (D : ZFSet.{0}) : Oracle := + arithmeticReal (fun O n => Certificate (fun t => O 0 (encode t) = true) (EncodedForcing.word n)) + (fun _ => shuffleOpenCodes D) + +theorem shuffleCertificateCodes_true (D : ZFSet.{0}) (n : ℕ) : + shuffleCertificateCodes D n = true ↔ Certificate (shuffleOpen D) (EncodedForcing.word n) := by + rw [shuffleCertificateCodes,arithmeticReal_true] + simp only [Certificate,shuffleOpenCodes_true,EncodedForcing.word,encodek,Option.getD_some] + +theorem shuffleCertificateCodes_mem (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (D : ZFSet.{0}) (hD : D ∈ M) : realCode (shuffleCertificateCodes D) ∈ M := + sourceT_arithmetic_comprehension M hM hT ArithmeticShuffleCertificate.certificate_arith + (fun _ => shuffleOpenCodes D) (fun _ => shuffleOpenCodes_mem M hM hT D hD) + +noncomputable def shuffleStar (D : ZFSet.{0}) : ZFSet.{0} := + conditions.sep (fun q => ∃ w : List Bool, q = wordCode w ∧ Certificate (shuffleOpen D) w) + +theorem wordCode_mem_shuffleStar (D : ZFSet.{0}) (p : List Bool) : + wordCode p ∈ shuffleStar D ↔ Certificate (shuffleOpen D) p := by + rw [shuffleStar,ZFSet.mem_sep] + constructor + · rintro ⟨_,w,hw,hc⟩ + exact wordCode_injective hw ▸ hc + · intro hc + exact ⟨(mem_conditions _).mpr ⟨_,wordCode_function _⟩,p,rfl,hc⟩ + +theorem shuffleStar_eq_image (D : ZFSet.{0}) : + shuffleStar D = wordImage (shuffleCertificateCodes D) := by + apply ZFSet.ext + intro q + by_cases hq : q ∈ conditions + · obtain ⟨p,rfl⟩ := (prefix_iff_wordCode q).mp ((mem_conditions q).mp hq) + exact (wordCode_mem_shuffleStar D p).trans + (wordImage_spec (Certificate (shuffleOpen D)) (shuffleCertificateCodes D) + (shuffleCertificateCodes_true D) p).symm + · exact ⟨fun h => False.elim (hq (ZFSet.mem_sep.mp h).1), + fun h => False.elim (hq (ZFSet.mem_sep.mp h).1)⟩ + +theorem shuffleStar_mem (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (D : ZFSet.{0}) (hD : D ∈ M) : shuffleStar D ∈ M := by + rw [shuffleStar_eq_image] + exact wordImage_mem M hM hT _ (shuffleCertificateCodes_mem M hM hT D hD) + +theorem shuffleOpen_denseOpen (D : ZFSet.{0}) + (hD : Dense {p : Condition | wordCode p.word ∈ D}) : DenseOpen (shuffleOpen D) := by + refine ⟨?_,?_⟩ + · intro p + obtain ⟨q,hq,hd⟩ := hD ⟨p⟩ + exact ⟨q.word,hq,q.word,hd,List.prefix_rfl⟩ + · intro p q hpq h + obtain ⟨r,hr,hrp⟩ := h + exact ⟨r,hr,hrp.trans hpq⟩ + +theorem shuffleStar_denseOpen (D : ZFSet.{0}) + (hD : Dense {p : Condition | wordCode p.word ∈ D}) : + DenseOpen (fun p => wordCode p ∈ shuffleStar D) := by + simpa only [wordCode_mem_shuffleStar] using + certificate_denseOpen (shuffleOpen D) (shuffleOpen_denseOpen D hD) + +theorem shuffleStar_dense (D : ZFSet.{0}) + (hD : Dense {p : Condition | wordCode p.word ∈ D}) : + Dense {p : Condition | wordCode p.word ∈ shuffleStar D} := by + intro p + obtain ⟨q,hpq,hq⟩ := (shuffleStar_denseOpen D hD).1 p.word + exact ⟨⟨q⟩,hpq,hq⟩ + +end TuringRigidity.InternalCohen + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSigmaSequence.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSigmaSequence.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fd8d676f6c57c7777fcc3f3b4dc8d651562f16a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSigmaSequence.lean @@ -0,0 +1,65 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaSequenceTrace + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel BoundedDefinability SetModelFunctions SetModelIteration RelativeConstructible +universe u + +theorem sequenceValue_sigma (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (S : ZFSet.{u} → ZFSet.{u} → Prop) + (hS : SigmaDefinable M (fun e => S (e 1) (e 0))) + (x : ZFSet.{u}) (hx : x ∈ M) : + SigmaDefinable M (fun e => ∃ z ∈ M, ∃ f ∈ M, ∃ r ∈ M, ∃ d ∈ M, + SequenceTrace M S (e 1) x (e 0) d r f z) := by + have ht := (sequenceTrace_sigma M hM hT S hS).subst + (fun i => match i with | 0 => 5 | 1 => 6 | 2 => 4 | 3 => 0 | 4 => 1 | 5 => 2 | _ => 3) + have hv := ht.existsSet.existsSet.existsSet.existsSet + have hs := hv.subst (fun i => if i=0 then 1 else if i=1 then 2 else 0) + have h := (((equal_param hx 0).toSigma hM).and hs).existsSet + apply h.congr + intro e _ + change (∃ x' ∈ M, x'=x ∧ ∃ z ∈ M, ∃ f ∈ M, ∃ r ∈ M, ∃ d ∈ M, + SequenceTrace M S (e 1) x' (e 0) d r f z) ↔ _ + exact ⟨fun ⟨_,_,he,hv⟩ => he ▸ hv,fun hv => ⟨x,hx,rfl,hv⟩⟩ + +theorem sigma_sequence_range_internal (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (S : ZFSet.{u} → ZFSet.{u} → Prop) + (hS : SigmaDefinable M (fun e => S (e 1) (e 0))) + (s : ℕ → ZFSet.{u}) (hs : ∀ n, s n ∈ M) + (hstep : ∀ n, S (s n) (s (n+1))) + (hunique : ∀ n y, S (s n) y → y = s (n+1)) : + ∃ B ∈ M, ∀ y, y ∈ B ↔ ∃ n, y = s n := by + obtain ⟨p,e,he,hp⟩ := sigma_binary_relation + (fun n y => ∃ z ∈ M, ∃ f ∈ M, ∃ r ∈ M, ∃ d ∈ M, + SequenceTrace M S n (s 0) y d r f z) + (sequenceValue_sigma M hM hT S hS (s 0) (hs 0)) + have hω := sourceT_omega_mem M hM hT + have hv (n : ℕ) (y : ZFSet.{u}) (hy : y ∈ M) : + p.Realize M (cons y (cons (natSet n) e)) ↔ y = s n := by + rw [hp _ (hM _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩)) y hy] + constructor + · rintro ⟨z,_,f,_,r,_,d,_,h⟩ + exact SequenceTrace.correct M S s hunique n h + · rintro rfl + exact sequenceTrace_exists M hM hT S s hs hstep n + obtain ⟨B,hB,hdef⟩ := hT.replacement.finitePrefix p e he ZFSet.omega hω (by + intro n hn + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + exact ⟨s n,hs n,(hv n (s n) (hs n)).mpr rfl, + fun y hy h => (hv n y hy).mp h⟩) + refine ⟨B,hB,?_⟩ + intro y + constructor + · intro hy + have hyM := hM B hB y hy + obtain ⟨n,hn,h⟩ := (hdef y hyM).mp hy + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + exact ⟨n,(hv n y hyM).mp h⟩ + · rintro ⟨n,rfl⟩ + exact (hdef (s n) (hs n)).mpr ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩, + (hv n (s n) (hs n)).mpr rfl⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSingletonColumn.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSingletonColumn.lean new file mode 100644 index 0000000000000000000000000000000000000000..59778103d0e89f96dc020976fb47ba969374c093 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSingletonColumn.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenReindex + +namespace OAI + +namespace TuringRigidity.InternalSingletonColumn +open TransitiveNameModel BoundedSetTheory CohenGroundPoset +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +noncomputable def graph (a W : ZFSet.{0}) : ZFSet.{0} := + (ZFSet.prod (ZFSet.prod {a} W) W).sep (fun z => + ∃ u ∈ ZFSet.prod {a} W, ∃ n ∈ W, z = ZFSet.pair u n ∧ u = ZFSet.pair a n) + +theorem pair_graph (a W u n : ZFSet.{0}) : + ZFSet.pair u n ∈ graph a W ↔ n ∈ W ∧ u = ZFSet.pair a n := by + constructor + · intro h + obtain ⟨_,v,_,m,hm,he,hv⟩ := ZFSet.mem_sep.mp h + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hm,hv⟩ + · rintro ⟨hn,hu⟩ + have huA : u ∈ ZFSet.prod {a} W := hu ▸ ZFSet.pair_mem_prod.mpr ⟨ZFSet.mem_singleton.mpr rfl,hn⟩ + exact ZFSet.mem_sep.mpr ⟨ZFSet.pair_mem_prod.mpr ⟨huA,hn⟩,u,huA,n,hn,rfl,hu⟩ + +theorem graph_mem (M a W : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) (hW : W ∈ M) : graph a W ∈ M := by + have hA := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + (singleton_mem M hM hT.pairing ha) hW + let e := cons (ZFSet.prod {a} W) (cons W (fun _ => a)) + have he : ∀ i, e i ∈ M := by intro i; rcases i with _|_|i; exact hA; exact hW; exact ha + simpa only [graph,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) (.orderedPair 1 5 0)))) e he + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hA hW) + +theorem graph_function (a W : ZFSet.{0}) : FunctionGraph (ZFSet.prod {a} W) W (graph a W) := by + refine ⟨fun z hz => ZFSet.mem_prod.mp (ZFSet.mem_sep.mp hz).1,?_⟩ + intro u hu + obtain ⟨x,hx,n,hn,rfl⟩ := ZFSet.mem_prod.mp hu + have hx_eq : x = a := ZFSet.mem_singleton.mp hx + subst x + exact ⟨n,hn,(pair_graph a W _ n).mpr ⟨hn,rfl⟩,fun m _ hm => + (ZFSet.pair_inj.mp ((pair_graph a W _ m).mp hm).2).2.symm⟩ + +theorem graph_injective (a W : ZFSet.{0}) : + ∀ x ∈ ZFSet.prod {a} W, ∀ x' ∈ ZFSet.prod {a} W, ∀ y ∈ W, + ZFSet.pair x y ∈ graph a W → ZFSet.pair x' y ∈ graph a W → x = x' := by + intro x _ x' _ y _ hx hx' + exact ((pair_graph a W x y).mp hx).2.trans ((pair_graph a W x' y).mp hx').2.symm + +theorem graph_onto (a W : ZFSet.{0}) : + ∀ y ∈ W, ∃ x ∈ ZFSet.prod {a} W, ZFSet.pair x y ∈ graph a W := by + intro y hy + exact ⟨ZFSet.pair a y,ZFSet.pair_mem_prod.mpr ⟨ZFSet.mem_singleton.mpr rfl,hy⟩, + (pair_graph a W _ y).mpr ⟨hy,rfl⟩⟩ + +theorem internal_column_iso (M a : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) (ha : a ∈ M) : + ∃ e : Conditions (conditions (ZFSet.prod {a} ZFSet.omega)) ≃o + Conditions (conditions ZFSet.omega), + ∃ f ∈ M, ∀ p q, ZFSet.pair (label _ p) (label _ q) ∈ f ↔ q = e p := by + have hW := sourceT_omega_mem M hM hT + have hA := product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + (singleton_mem M hM hT.pairing ha) hW + obtain ⟨e,hf,hfe,_⟩ := InternalCohenReindex.internal_reindex M _ _ (graph a ZFSet.omega) + hM hT hA hW (graph_mem M a _ hM hT ha hW) (graph_function a _) + (graph_injective a _) (graph_onto a _) + exact ⟨e,_,hf,hfe⟩ + +end TuringRigidity.InternalSingletonColumn + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalStructureCollapse.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalStructureCollapse.lean new file mode 100644 index 0000000000000000000000000000000000000000..c569b328b9188c143e9f346ba52731ec704b8fb9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalStructureCollapse.lean @@ -0,0 +1,97 @@ +import OAI.Computability.DegreeRigidity.SetModels.MostowskiCollapse +import OAI.Computability.DegreeRigidity.Syntax.FormulaIsomorphism + +namespace OAI + + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory +universe u + +noncomputable def membershipRelation (d : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ x ∈ d, ∃ y ∈ d, z = ZFSet.pair x y ∧ x ∈ y) (ZFSet.prod d d) + +theorem membershipRelation_pair (d x y : ZFSet.{u}) : + ZFSet.pair x y ∈ membershipRelation d ↔ x ∈ d ∧ y ∈ d ∧ x ∈ y := by + rw [membershipRelation,ZFSet.mem_sep] + constructor + · rintro ⟨_,a,ha,b,hb,he,hab⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨ha,hb,hab⟩ + · rintro ⟨hx,hy,hxy⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨x,hx,y,hy,rfl⟩,x,hx,y,hy,rfl,hxy⟩ + +theorem membershipRelation_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + {d : ZFSet.{u}} (hd : d ∈ M) : membershipRelation d ∈ M := by + simpa only [membershipRelation,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ] using + sep_mem M hM hS (.existsMem 1 (.existsMem 2 (.conj (.orderedPair 2 1 0) (.member 1 0)))) + (fun _ => d) (fun _ => hd) (product_mem M hM hP hU hPow hS hd hd) + +theorem membershipRelation_wellFounded (d : ZFSet.{u}) : + WellFounded (Rel d (membershipRelation d)) := by + apply ZFSet.mem_wf.mono + intro x y h + exact ((membershipRelation_pair d x y).mp h.2).2.2 + +def StructureExtensional (d : ZFSet.{u}) : Prop := + ∀ x ∈ d, ∀ y ∈ d, (∀ z ∈ d, z ∈ x ↔ z ∈ y) → x = y + +theorem membershipRelation_extensional {d : ZFSet.{u}} (he : StructureExtensional d) : + Extensional d (membershipRelation d) := by + intro x hx y hy hxy + apply he x hx y hy + intro z hz + simpa only [membershipRelation_pair,and_iff_right hz,and_iff_right hx,and_iff_right hy] using hxy z hz + +noncomputable def structureMap (d : ZFSet.{u}) : ZFSet.{u} → ZFSet.{u} := + value d (membershipRelation d) (membershipRelation_wellFounded d) + +theorem structureMap_fixed {d t : ZFSet.{u}} (ht : Transitive t) (htd : t ⊆ d) + (x : ZFSet.{u}) (hx : x ∈ t) : structureMap d x = x := by + induction x using ZFSet.inductionOn with + | h x ih => + apply ZFSet.ext + intro z + rw [structureMap,mem_value] + constructor + · rintro ⟨y,_,hyx,hz⟩ + have hyx' := ((membershipRelation_pair d y x).mp hyx).2.2 + have hyv := ih y hyx' (ht x hx y hyx') + change structureMap d y = y at hyv + change z = structureMap d y at hz + rw [hyv] at hz + exact hz ▸ hyx' + · intro hz + have hzt := ht x hx z hz + refine ⟨z,htd hzt,(membershipRelation_pair d z x).mpr ⟨htd hzt,htd hx,hz⟩,?_⟩ + exact (ih z hz hzt).symm + +theorem internal_structure_collapse (M d : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) + (hd : d ∈ M) (he : StructureExtensional d) : + ∃ b ∈ M, ∃ f ∈ M, Presents d f (structureMap d) ∧ Transitive b ∧ + (∀ y, y ∈ b ↔ ∃ x ∈ d, y = structureMap d x) ∧ + (∀ φ : SigmaFormula, ∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ d) → + (φ.Realize d e ↔ φ.Realize b (fun i => structureMap d (e i)))) := by + obtain ⟨b,hb,f,hf,hfg,hbt,hbdef,hi,hm⟩ := internal_mostowski M d (membershipRelation d) + hM hP hU hPow hS hR hd (membershipRelation_mem M hM hP hU hPow hS hd) + (membershipRelation_wellFounded d) (membershipRelation_extensional he) + refine ⟨b,hb,f,hf,hfg,hbt,hbdef,?_⟩ + intro φ e henv + apply φ.realize_isomorphism d b (structureMap d) + · intro x hx + exact (hbdef _).mpr ⟨x,hx,rfl⟩ + · intro y hy + obtain ⟨x,hx,hyx⟩ := (hbdef y).mp hy + exact ⟨x,hx,hyx.symm⟩ + · exact hi + · intro x hx y hy + exact (hm x hx y hy).trans + ((membershipRelation_pair d x y).trans (and_iff_right hx |>.trans (and_iff_right hy))) + · exact henv + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSubsetSequence.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSubsetSequence.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e1675c1c5f20f42b7a35f79517a24abf59bad30 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalSubsetSequence.lean @@ -0,0 +1,69 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalSequenceRange +import OAI.Computability.DegreeRigidity.Syntax.BoundedFormulaRename + +namespace OAI + +namespace TuringRigidity.InternalSubsetSequence +open TransitiveNameModel BoundedSetTheory + +theorem subset_sequence (M c : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (φ : Formula) (e : ℕ → ZFSet.{0}) (he : ∀ i, e i ∈ M) + (U : ℕ → ZFSet.{0}) (hU : ∀ n, U n ⊆ c) + (hφ : ∀ n p, p ∈ c → (φ.Eval (cons p (cons (natSet n) e)) ↔ p ∈ U n)) : + orbitGraph U ∈ M := by + have hω := sourceT_omega_mem M hM hT + have hUM (n : ℕ) : U n ∈ M := by + have hnM := hM _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩) + have he' : ∀ i, cons (natSet n) e i ∈ M := by + intro i; cases i; exact hnM; exact he _ + have hs := sep_mem M hM hT.separation.finitePrefix.bounded φ _ he' hc + have heq : c.sep (fun p => φ.Eval (cons p (cons (natSet n) e))) = U n := by + apply ZFSet.ext; intro p + rw [ZFSet.mem_sep] + exact ⟨fun ⟨hp,h⟩ => (hφ n p hp).mp h,fun hp => ⟨hU n hp,(hφ n p (hU n hp)).mpr hp⟩⟩ + exact heq ▸ hs + obtain ⟨Q,hQM,hQ⟩ := internal_power M hM hT.powerSet hc + have hUQ : ∀ n, U n ∈ Q := fun n => (hQ _).mpr ⟨hUM n,hU n⟩ + let v := cons ZFSet.omega (cons Q (cons c e)) + let ren : ℕ → ℕ := fun | 0 => 0 | 1 => 2 | n+2 => n+7 + let ψ : Formula := .existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) + (.conj (.subset 0 5) (.allMem 5 (.iff (.member 0 1) (φ.rename ren)))))) + have hv : ∀ i, v i ∈ M := by + intro i; rcases i with _|_|_|i; exact hω; exact hQM; exact hc; exact he i + have renamed (p H n z : ZFSet.{0}) : + (φ.rename ren).Eval (cons p (cons H (cons n (cons z v)))) ↔ + φ.Eval (cons p (cons n e)) := by + rw [Formula.eval_rename_comp] + have hh : (cons p (cons H (cons n (cons z v)))) ∘ ren = cons p (cons n e) := by + funext i; rcases i with _|_|i <;> rfl + rw [hh] + have hψ (z : ZFSet.{0}) : ψ.Eval (cons z v) ↔ z ∈ orbitGraph U := by + simp only [ψ,Formula.Eval,Formula.eval_orderedPair,Formula.eval_subset, + Formula.eval_allMem,Formula.eval_iff,cons_zero,cons_succ,v] + constructor + · rintro ⟨n,hn,H,_,hz,hH,hdef⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + have hHU : H = U n := by + apply ZFSet.ext; intro p + constructor + · intro hp + exact (hφ n p (hH hp)).mp ((renamed p H _ z).mp ((hdef p (hH hp)).mp hp)) + · intro hp + exact (hdef p (hU n hp)).mpr ((renamed p H _ z).mpr ((hφ n p (hU n hp)).mpr hp)) + exact (mem_orbitGraph U z).mpr ⟨n,by rw [hz,hHU]⟩ + · intro hz + obtain ⟨n,rfl⟩ := (mem_orbitGraph U z).mp hz + refine ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,U n,hUQ n,rfl,hU n,?_⟩ + intro p hp + exact (hφ n p hp).symm.trans (renamed p (U n) _ _).symm + have hs := sep_mem M hM hT.separation.finitePrefix.bounded ψ v hv + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded hω hQM) + have heq : (ZFSet.prod ZFSet.omega Q).sep (fun z => ψ.Eval (cons z v)) = orbitGraph U := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,hψ] + exact ⟨And.right,fun hz => ⟨ZFSet.mem_prod.mpr ((orbitGraph_function Q U hUQ).1 z hz),hz⟩⟩ + exact heq ▸ hs + +end TuringRigidity.InternalSubsetSequence + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalUncountableComplement.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalUncountableComplement.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4893420784dffc3d24bd3194076e4ea6050ee79 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalUncountableComplement.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableOrdinals +import OAI.Computability.DegreeRigidity.SetModels.InternalInverseGraph +import OAI.Computability.DegreeRigidity.SetModels.InternalOrdinalSubset + +namespace OAI + +namespace TuringRigidity.InternalUncountableComplement +open TransitiveNameModel BoundedSetTheory InternalCountableOrdinals InternalCountableClosure + +theorem difference_mem (M K C : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : K ∈ M) (hC : C ∈ M) : K \ C ∈ M := by + simpa only [ZFSet.sep_notMem,Formula.Eval,cons_zero,cons_succ] using + sep_mem M hM hT.separation.finitePrefix.bounded (.neg (.member 0 1)) + (fun _ => C) (fun _ => hC) hK + +theorem difference_uncountable (M K C : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : K ∈ M) (hunc : ¬ (K = ∅ ∨ InternallyCountable M K)) (hC : C ∈ M) + (hCK : C ⊆ K) (hct : C = ∅ ∨ InternallyCountable M C) : + ¬ (K \ C = ∅ ∨ InternallyCountable M (K \ C)) := by + classical + intro h + have hc := countable_union M C (K \ C) hM hT hC (difference_mem M K C hM hT hK hC) hct h + have he : C ∪ (K \ C) = K := by + apply ZFSet.ext; intro x + rw [ZFSet.mem_union,ZFSet.mem_sdiff] + exact ⟨fun h => h.elim (fun h => hCK h) And.left, + fun h => (Classical.em (x ∈ C)).elim Or.inl (fun hn => Or.inr ⟨h,hn⟩)⟩ + exact hunc (he ▸ hc) + +theorem uncountable_subset_bijection (M K D : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : FirstUncountable M K) (hD : D ∈ M) (hDK : D ⊆ K) + (hunc : ¬ (D = ∅ ∨ InternallyCountable M D)) : + ∃ f ∈ M, FunctionGraph D K f ∧ + (∀ x ∈ D, ∀ x' ∈ D, ∀ y ∈ K, ZFSet.pair x y ∈ f → ZFSet.pair x' y ∈ f → x = x') ∧ + (∀ y ∈ K, ∃ x ∈ D, ZFSet.pair x y ∈ f) := by + obtain ⟨J,hJM,hJ,hJK,f,hfM,hf,hi,hs⟩ := + InternalOrdinalSubset.internal_subset_orderType M K D hM hT hK.1 hD hDK + have huncJ : ¬ (J = ∅ ∨ InternallyCountable M J) := by + rintro (rfl|hct) + · apply hunc; left + apply ZFSet.ext; intro x + constructor + · intro hx + obtain ⟨y,hy,_,_⟩ := hf.2 x hx + exact False.elim (ZFSet.notMem_empty y hy) + · intro hx; exact False.elim (ZFSet.notMem_empty x hx) + · exact hunc (Or.inr (InternalInverseGraph.countable_of_bijection M D J f hM hT hD hJM hfM hf hi hs hct)) + have he : J = K := by + rcases (hJ.subset_iff_eq_or_mem hK.1).mp hJK with h|h + · exact h + · exact False.elim (huncJ (hK.2.2.2 J h)) + exact he ▸ ⟨f,hfM,hf,hi,hs⟩ + +theorem complement_bijection (M K C : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : FirstUncountable M K) (hC : C ∈ M) (hCK : C ⊆ K) + (hct : C = ∅ ∨ InternallyCountable M C) : + ∃ f ∈ M, FunctionGraph (K \ C) K f ∧ + (∀ x ∈ K \ C, ∀ x' ∈ K \ C, ∀ y ∈ K, + ZFSet.pair x y ∈ f → ZFSet.pair x' y ∈ f → x = x') ∧ + (∀ y ∈ K, ∃ x ∈ K \ C, ZFSet.pair x y ∈ f) := + uncountable_subset_bijection M K (K \ C) hM hT hK + (difference_mem M K C hM hT hK.2.1 hC) + (fun _ h => (ZFSet.mem_sdiff.mp h).1) + (difference_uncountable M K C hM hT hK.2.1 hK.2.2.1 hC hCK hct) + +end TuringRigidity.InternalUncountableComplement + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalUncountableSentence.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalUncountableSentence.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad89ea766787c4352855deb43fb37acb68d3e177 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalUncountableSentence.lean @@ -0,0 +1,88 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCountableOrdinals +import OAI.Computability.DegreeRigidity.SetModels.ElementarySatisfaction + +namespace OAI + +namespace TuringRigidity.InternalUncountableSentence +open TransitiveNameModel BoundedSetTheory ElementaryModel + +def ontoMatrix (f ω A : ℕ) : Formula := + .conj (.functionGraph f ω A) (.allMem A (.existsMem (ω+1) (.pairMem 0 1 (f+2)))) + +theorem ontoMatrix_spec (f ω A : ℕ) (e : ℕ → ZFSet.{0}) : + (ontoMatrix f ω A).Eval e ↔ FunctionGraph (e ω) (e A) (e f) ∧ + ∀ x ∈ e A, ∃ n ∈ e ω, ZFSet.pair n x ∈ e f := by + simp only [ontoMatrix,Formula.Eval,Formula.eval_functionGraph,Formula.eval_allMem, + Formula.eval_pairMem,FunctionGraph,cons_zero,cons_succ] + +noncomputable def countableSentence (A ω : ℕ) : SentenceForm := + .ex (fromBounded (ontoMatrix 0 (ω+1) (A+1))) + +theorem countableSentence_spec (M : ZFSet.{0}) (hM : Transitive M) (A ω : ℕ) + (e : ℕ → ZFSet.{0}) (he : ∀ i, e i ∈ M) (hω : e ω = ZFSet.omega) : + (countableSentence A ω).Sat (M : Set ZFSet) e ↔ InternallyCountable M (e A) := by + change (∃ f ∈ M, (fromBounded _).Sat _ (cons f e)) ↔ _ + unfold InternallyCountable + apply exists_congr; intro f + apply and_congr_right; intro hf + rw [bounded_sat,Formula.absolute _ M hM _ (by intro i; cases i; exact hf; exact he _),ontoMatrix_spec] + simp only [cons_zero,cons_succ,hω] + +noncomputable def uncountableOrdinalSentence : SentenceForm := + .conj (fromBounded (.conj (.transitive 0) (.allMem 0 (.transitive 0)))) + (.conj (.neg (fromBounded (.empty 0))) (.neg (countableSentence 0 1))) + +theorem uncountableOrdinalSentence_spec (M : ZFSet.{0}) (hM : Transitive M) + (e : ℕ → ZFSet.{0}) (he : ∀ i, e i ∈ M) (hω : e 1 = ZFSet.omega) : + uncountableOrdinalSentence.Sat (M : Set ZFSet) e ↔ + (e 0).IsOrdinal ∧ ¬ (e 0 = ∅ ∨ InternallyCountable M (e 0)) := by + change (fromBounded _).Sat _ e ∧ (¬ (fromBounded _).Sat _ e) ∧ + ¬ (countableSentence 0 1).Sat _ e ↔ _ + rw [bounded_sat,Formula.absolute _ M hM e he,bounded_sat,Formula.absolute _ M hM e he, + countableSentence_spec M hM 0 1 e he hω] + simp only [Formula.Eval,Formula.eval_transitive,Formula.eval_allMem,Formula.eval_empty, + cons_zero,ZFSet.isOrdinal_iff_forall_mem_isTransitive,not_or] + rfl + +theorem no_surjection [Uncountable (Conditions (Ordinal.omega 1 : Ordinal.{0}).toZFSet)] + (f : ZFSet.{0}) (hf : FunctionGraph ZFSet.omega (Ordinal.omega 1 : Ordinal.{0}).toZFSet f) + (hs : ∀ x ∈ (Ordinal.omega 1 : Ordinal.{0}).toZFSet, ∃ n ∈ ZFSet.omega, ZFSet.pair n x ∈ f) : False := by + classical + obtain ⟨E,hE,hEf⟩ := InternalCountableFamily.sequence_of_graph _ f hf + let t : ℕ → Conditions (Ordinal.omega 1 : Ordinal.{0}).toZFSet := fun n => equivShrink _ ⟨E n,hE n⟩ + have ht : Function.Surjective t := by + intro x + obtain ⟨n,hn,hnx⟩ := hs (label _ x) (label_mem _ x) + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + have heq := (orbitGraph_pair E n (label _ x)).mp (hEf.symm ▸ hnx) + exact ⟨n,label_injective _ (by simpa only [t,label,Equiv.symm_apply_apply] using heq.symm)⟩ + exact not_countable ht.countable + +theorem ambient_uncountable_ordinal : + uncountableOrdinalSentence.Sat Set.univ + (cons (Ordinal.omega 1 : Ordinal.{0}).toZFSet (fun _ => ZFSet.omega)) := by + classical + have hc : Cardinal.aleph0 < Cardinal.mk (Conditions (Ordinal.omega 1 : Ordinal.{0}).toZFSet) := by + change Cardinal.aleph0 < ((Ordinal.omega 1 : Ordinal.{0}).toZFSet).card + rw [Ordinal.card_toZFSet,Ordinal.card_omega] + exact Cardinal.aleph0_lt_aleph_one + have : Uncountable (Conditions (Ordinal.omega 1 : Ordinal.{0}).toZFSet) := Cardinal.aleph0_lt_mk_iff.mp hc + change (fromBounded _).Sat _ _ ∧ (¬ (fromBounded _).Sat _ _) ∧ ¬ (countableSentence 0 1).Sat _ _ + rw [bounded_univ,bounded_univ] + constructor + · simp only [Formula.Eval,Formula.eval_transitive,Formula.eval_allMem,cons_zero] + exact (ZFSet.isOrdinal_iff_forall_mem_isTransitive.mp (ZFSet.isOrdinal_toZFSet (Ordinal.omega 1 : Ordinal.{0}))) + constructor + · simp only [Formula.eval_empty,cons_zero] + intro he + have hpos := Ordinal.omega_pos (1 : Ordinal.{0}) + have hr := congrArg ZFSet.rank he + rw [Ordinal.rank_toZFSet,ZFSet.rank_empty] at hr + exact hpos.ne' hr + · rintro ⟨f,_,hf⟩ + have h := (ontoMatrix_spec 0 2 1 _).mp ((bounded_univ _ _).mp hf) + exact no_surjection f h.1 h.2 + +end TuringRigidity.InternalUncountableSentence + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/InternalUniformization.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalUniformization.lean new file mode 100644 index 0000000000000000000000000000000000000000..745794dcd429bd2be4f0d908c26d9e67b0cc3751 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/InternalUniformization.lean @@ -0,0 +1,104 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalChoice + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +noncomputable def relationFiber (b r x : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun y => ZFSet.pair x y ∈ r) b + +theorem relationFiber_mem (M : ZFSet.{u}) (hM : Transitive M) (hS : Separation M) + {b r x : ZFSet.{u}} (hb : b ∈ M) (hr : r ∈ M) (hx : x ∈ M) : relationFiber b r x ∈ M := by + simpa only [relationFiber,Formula.eval_pairMem,cons_zero,cons_succ] using + sep_mem M hM hS (.pairMem 1 0 2) (cons x (fun _ => r)) + (by intro i; cases i <;> assumption) hb + +def selectionFormula : Formula := + .existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) + (.existsMem 5 (.conj + (.allMem 5 (.iff (.member 0 1) (.pairMem 3 0 9))) (.pairMem 0 1 7))))) + +theorem eval_selectionFormula (z a b q f r : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + selectionFormula.Eval (cons z (cons a (cons b (cons q (cons f (cons r e)))))) ↔ + ∃ x ∈ a, ∃ y ∈ b, z = ZFSet.pair x y ∧ ∃ s ∈ q, + (∀ w ∈ b, w ∈ s ↔ ZFSet.pair x w ∈ r) ∧ ZFSet.pair s y ∈ f := by + simp only [selectionFormula,Formula.Eval,Formula.eval_orderedPair,Formula.eval_allMem, + Formula.eval_iff,Formula.eval_pairMem,cons_zero,cons_succ] + +theorem internal_relation_choice (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hAC : Choice M) + {a b r : ZFSet.{u}} (ha : a ∈ M) (hb : b ∈ M) (hr : r ∈ M) + (htotal : ∀ x ∈ a, ∃ y ∈ b, ZFSet.pair x y ∈ r) : + ∃ g ∈ M, g ⊆ r ∧ + (∀ z ∈ g, ∃ x ∈ a, ∃ y ∈ b, z = ZFSet.pair x y) ∧ + (∀ x ∈ a, ∃ y ∈ b, ZFSet.pair x y ∈ g ∧ + ∀ z ∈ b, ZFSet.pair x z ∈ g → z = y) := by + obtain ⟨q,hq,f,hf,hfg,hqdef⟩ := internal_selector M hM hPow hS hAC hb + let e := cons a (cons b (cons q (cons f (cons r (fun _ => a))))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact ha + rcases i with _|i; exact hb + rcases i with _|i; exact hq + rcases i with _|i; exact hf + rcases i with _|i; exact hr + exact ha + let g := ZFSet.sep (fun z => selectionFormula.Eval (cons z e)) (ZFSet.prod a b) + have hg : g ∈ M := sep_mem M hM hS selectionFormula e he + (product_mem M hM hP hU hPow hS ha hb) + have hfiber (x : ZFSet.{u}) (hx : x ∈ a) : relationFiber b r x ∈ q := by + apply (hqdef _).mpr + obtain ⟨y,hy,hxy⟩ := htotal x hx + exact ⟨relationFiber_mem M hM hS hb hr (hM a ha x hx), + (fun _ hz => (ZFSet.mem_sep.mp hz).1),y,ZFSet.mem_sep.mpr ⟨hy,hxy⟩⟩ + have hfibereq (x s : ZFSet.{u}) (hs : s ∈ q) + (hdef : ∀ w ∈ b, w ∈ s ↔ ZFSet.pair x w ∈ r) : s = relationFiber b r x := by + apply ZFSet.ext + intro w + rw [relationFiber,ZFSet.mem_sep] + constructor + · intro hw + have hwb := ((hqdef s).mp hs).2.1 hw + exact ⟨hwb,(hdef w hwb).mp hw⟩ + · rintro ⟨hwb,hw⟩ + exact (hdef w hwb).mpr hw + have hgpair (x y : ZFSet.{u}) : ZFSet.pair x y ∈ g ↔ + x ∈ a ∧ y ∈ b ∧ ZFSet.pair (relationFiber b r x) y ∈ f := by + change _ ∈ ZFSet.sep _ _ ↔ _ + rw [ZFSet.mem_sep] + have eval := eval_selectionFormula (ZFSet.pair x y) a b q f r (fun _ => a) + change selectionFormula.Eval (cons (ZFSet.pair x y) e) ↔ _ at eval + rw [eval] + constructor + · rintro ⟨_,x',hx,y',hy,hp,s,hs,hdef,hsy⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + rw [hfibereq x s hs hdef] at hsy + exact ⟨hx,hy,hsy⟩ + · rintro ⟨hx,hy,hsy⟩ + refine ⟨ZFSet.mem_prod.mpr ⟨x,hx,y,hy,rfl⟩,x,hx,y,hy,rfl, + relationFiber b r x,hfiber x hx,?_,hsy⟩ + intro w hw + exact (ZFSet.mem_sep).trans (and_iff_right hw) + have hgshape (z : ZFSet.{u}) (hz : z ∈ g) : + ∃ x ∈ a, ∃ y ∈ b, z = ZFSet.pair x y := + ZFSet.mem_prod.mp (ZFSet.mem_sep.mp hz).1 + refine ⟨g,hg,?_,hgshape,?_⟩ + · intro z hz + obtain ⟨x,_,y,_,rfl⟩ := hgshape z hz + have hsy := ((hgpair x y).mp hz).2.2 + obtain ⟨s,_,v,hv,heq⟩ := hfg.1 _ hsy + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + exact (ZFSet.mem_sep.mp hv).2 + · intro x hx + obtain ⟨y,hy,hsy,_⟩ := hfg.2 _ (hfiber x hx) + have hyb := (ZFSet.mem_sep.mp hy).1 + refine ⟨y,hyb,(hgpair x y).mpr ⟨hx,hyb,hsy⟩,?_⟩ + intro z _ hxz + exact hfg.functional ((hgpair x z).mp hxz).2.2 hsy + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/IntersectionName.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/IntersectionName.lean new file mode 100644 index 0000000000000000000000000000000000000000..baf5f8f6e1564ae4ed1babf54915308d2a84e79e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/IntersectionName.lean @@ -0,0 +1,104 @@ +import OAI.Computability.DegreeRigidity.SetModels.NameSupport + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing +universe u + +namespace AtomicFormula +open Formula + +def select (d c k o f y z : ℕ) : Formula := + .existsMem d (.existsMem (c+1) (.conj (orderedPair (z+2) 1 0) + (witness (d+2) (c+2) (k+2) (o+2) (f+2) 1 (y+2) 0))) + +theorem eval_select (d c k o f y z : ℕ) (e : ℕ → ZFSet.{u}) : + (select d c k o f y z).Eval e ↔ + ∃ x ∈ e d, ∃ q ∈ e c, e z = ZFSet.pair x q ∧ + CodeWitness (e d) (e c) (e k) (e o) (e f) x (e y) q := by + simp only [select,Formula.Eval,eval_orderedPair,eval_witness,cons_zero,cons_succ] +end AtomicFormula + +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem internal_intersection_name (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) + (a b : Name (Conditions c)) (ha : a.encode (label c) ∈ M) (hb : b.encode (label c) ∈ M) : + ∃ B ∈ M, B ⊆ a.support (label c) ∧ + (a.restrict (label c) B).val G.carrier = a.val G.carrier ∩ b.val G.carrier := by + obtain ⟨d,hd,hdT,hdab⟩ := internal_transitive_container M hM hP hU hS hR hI + (pair_mem M hM hP ha hb) + have had : a.encode (label c) ∈ d := hdT _ hdab _ (ZFSet.mem_pair.mpr (Or.inl rfl)) + have hbd : b.encode (label c) ∈ d := hdT _ hdab _ (ZFSet.mem_pair.mpr (Or.inr rfl)) + have hai (i) : (a.child i).encode (label c) ∈ d := by + apply names_childClosed d c hdT a had + cases a + exact ⟨i,rfl⟩ + obtain ⟨f,hf,hfG⟩ := internal_atomic_graph M hM hP hU hPow hS hd hc hoM + let k := ZFSet.prod d d + have hk : k ∈ M := product_mem M hM hP hU hPow hS hd hd + let e := cons d (cons c (cons k (cons o (cons f (cons (b.encode (label c)) (fun _ => c)))))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hd + rcases i with _|i; exact hc + rcases i with _|i; exact hk + rcases i with _|i; exact hoM + rcases i with _|i; exact hf + rcases i with _|i; exact hb + exact hc + let φ := AtomicFormula.select 1 2 3 4 5 6 0 + let B := ZFSet.sep (fun z => φ.Eval (cons z e)) (a.support (label c)) + have hBM : B ∈ M := sep_mem M hM hS φ e he (support_mem M hM hP hU hPow hS hc hoM ho a ha) + have hBsub : B ⊆ a.support (label c) := fun z hz => (ZFSet.mem_sep.mp hz).1 + have hB (i : a.arity) (q : Conditions c) (hq : q ≤ a.tag i) : + ZFSet.pair ((a.child i).encode (label c)) (label c q) ∈ B ↔ Witness (a.child i) b q := by + have hs : ZFSet.pair ((a.child i).encode (label c)) (label c q) ∈ a.support (label c) := + ZFSet.mem_range.mpr ⟨⟨i,⟨q,hq⟩⟩,rfl⟩ + change _ ∈ ZFSet.sep _ _ ↔ _ + rw [ZFSet.mem_sep,and_iff_right hs] + change (AtomicFormula.select 1 2 3 4 5 6 0).Eval (cons _ e) ↔ _ + rw [AtomicFormula.eval_select] + change (∃ x ∈ d, ∃ r ∈ c, + ZFSet.pair ((a.child i).encode (label c)) (label c q) = ZFSet.pair x r ∧ + CodeWitness d c k o f x (b.encode (label c)) r) ↔ _ + constructor + · rintro ⟨x,hx,r,hr,hxr,hw⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hxr + exact (codeWitness_iff hdT ho hfG _ b (hai i) hbd q).mp hw + · intro hw + exact ⟨_,hai i,_,label_mem c q,rfl,(codeWitness_iff hdT ho hfG _ b (hai i) hbd q).mpr hw⟩ + have hg := groundGeneric_atomic M hM hP hU hPow hS hR hI hc hoM ho G hG + have hiM (i) : a.child i ∈ names M c := by + apply names_childClosed M c hM a ha + cases a + exact ⟨i,rfl⟩ + refine ⟨B,hBM,hBsub,?_⟩ + apply ZFSet.ext + intro x + rw [ZFSet.mem_inter] + constructor + · intro hx + have hxa := a.val_restrict_subset (label c) B G hx + obtain ⟨i,q,hqi,hqb,hqG,hix⟩ := (a.mem_val_restrict (label c) B G.carrier x).mp hx + have hw := (hB i q hqi).mp hqb + have hxb := (mem_truth (names_childClosed M c hM) G hg _ b (hiM i) hb).mpr + ⟨q,hqG,witness_mem _ _ q hw⟩ + exact ⟨hxa,hix ▸ hxb⟩ + · rintro ⟨hxa,hxb⟩ + obtain ⟨i,hi,hix⟩ := (a.mem_val_children G.carrier x).mp hxa + have hmem : (a.child i).val G.carrier ∈ b.val G.carrier := hix ▸ hxb + obtain ⟨p,hp,hm⟩ := (mem_truth (names_childClosed M c hM) G hg _ b (hiM i) hb).mp hmem + obtain ⟨q,hq,hw⟩ := generic_witness hg (hiM i) hb hp hm + obtain ⟨r,hr,hrq,hri⟩ := G.directed hq hi + exact (a.mem_val_restrict (label c) B G.carrier x).mpr + ⟨i,r,hri,(hB i r hri).mpr (witness_mono _ _ hrq hw),hr,hix⟩ + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelArithmeticComprehension.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelArithmeticComprehension.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b4ff25d10e42655921c6296a6f485ef70b946a0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelArithmeticComprehension.lean @@ -0,0 +1,61 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticSetSyntax + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel UniformArithmetic +universe u + +noncomputable def arithmeticReal (P : Predicate) (O : Oracles) : Oracle := fun n => by + classical + exact decide (P O n) + +theorem arithmeticReal_true (P : Predicate) (O : Oracles) (n : ℕ) : + arithmeticReal P O n = true ↔ P O n := by + classical + simp only [arithmeticReal,decide_eq_true_eq] + +theorem sourceT_arithmetic_comprehension (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {P : Predicate} (hP : Arith P) (O : Oracles) (hO : ∀ i, O i ∈ modelReals M) : + arithmeticReal P O ∈ modelReals M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + obtain ⟨Q,hQ,_,hbound⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω + obtain ⟨φ,hφ⟩ := arithmetic_bounded_definition.{u} hP + let e := cons ZFSet.omega (cons Q (fun i => realCode (O i))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hω + rcases i with _|i; exact hQ + exact hO i + let B := ZFSet.sep (fun x => φ.Eval (cons x e)) ZFSet.omega + have hB : B ∈ M := sep_mem M hM hS φ e he hω + have hBdef (n : ℕ) : natSet.{u} n ∈ B ↔ P O n := by + rw [ZFSet.mem_sep] + change (natSet n ∈ ZFSet.omega ∧ φ.Eval (arithmeticEnv Q O n)) ↔ P O n + rw [hφ Q hbound O n] + exact and_iff_right ((mem_omega _).mpr ⟨n,rfl⟩) + have hcode : realCode (arithmeticReal P O) = B := by + apply ZFSet.ext; intro x + by_cases hx : x ∈ ZFSet.omega.{u} + · obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + rw [natSet_mem_realCode,arithmeticReal_true,hBdef] + · exact ⟨fun h => False.elim (hx (realCode_subset _ h)), + fun h => False.elim (hx (ZFSet.mem_sep.mp h).1)⟩ + change realCode (arithmeticReal P O) ∈ M + rw [hcode] + exact hB + +theorem sourceT_arithmetic_real (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {P : Predicate} (hP : Arith P) (O : Oracles) (hO : ∀ i, O i ∈ modelReals M) + (A : Oracle) (hA : ∀ n, A n = true ↔ P O n) : A ∈ modelReals M := by + have he : A = arithmeticReal P O := by + funext n + have h := (hA n).trans (arithmeticReal_true P O n).symm + cases ha : A n <;> cases hb : arithmeticReal P O n <;> simp_all + rw [he] + exact sourceT_arithmetic_comprehension M hM hT hP O hO + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelArithmeticTreeDescent.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelArithmeticTreeDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc93cad7b2cd6b789cb4d8057fee83cf59b92729 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelArithmeticTreeDescent.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticTreeSequence +import OAI.Computability.DegreeRigidity.Constructibility.PersistenceWitnessTree +import OAI.Computability.DegreeRigidity.OrdinalCodes.NaturalRealRelation + +namespace OAI + + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic BoundedSetTheory TransitiveNameModel ArithmeticPersistence +universe u +noncomputable section + +theorem Test.sourceT_chain (t : Test) (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (O : Oracles) (hO : ∀ i, O i ∈ modelReals M) (v : ℕ) + (hw : ∃ f : ℕ → ℕ, ∀ n, t.eval O f (Nat.pair v n)) : + ∃ s : ℕ → ℕ, ∃ G ∈ modelReals M, + (∀ n k, G (Nat.pair n k) = true ↔ k = s n) ∧ + ∀ n, t.eval O (chainValue s) (Nat.pair v n) := by + let P : Predicate := fun O k => t.codeChild O v (left k) (right k) + let B := arithmeticReal P O + have hB : B ∈ modelReals M := sourceT_arithmetic_comprehension M hM hT (t.codeChild_arith v) O hO + have hb (x y : ℕ) : B (Nat.pair x y) = true ↔ t.codeChild O v x y := by + simpa only [P,left,right,Nat.unpair_pair] using arithmeticReal_true P O (Nat.pair x y) + obtain ⟨s,hs⟩ := t.code_chain_exists O v hw + obtain ⟨s,G,hGM,hG,hs⟩ := sourceT_realRelation_descent M hM hT hB + ⟨s,fun n => (hb _ _).mpr (hs n)⟩ + exact ⟨s,G,hGM,hG,t.code_chain_eval O v s (fun n => (hb _ _).mp (hs n))⟩ + +def nodeValue (k i : ℕ) : ℕ := ((decodeNode k)[i]?).getD 0 + +theorem nodeValue_primrec : Primrec (fun p : ℕ × ℕ => nodeValue p.1 p.2) := + Primrec.option_getD.comp + (Primrec.list_getElem?.comp (decodeNode_primrec.comp Primrec.fst) Primrec.snd) + (Primrec.const 0) + +def chainGraphPredicate (O : Oracles) (v : ℕ) : Prop := + ∃ k, O 0 (Nat.pair (left v + 1) k) = true ∧ nodeValue k (left v) = right v + +theorem chainGraph_arith : Arith chainGraphPredicate := by + have hq := (Arith.query 0).comp (fun v => Nat.pair (left (left v)+1) (right v)) + (Primrec₂.natPair.comp (Primrec.succ.comp (left_primrec.comp left_primrec)) right_primrec) + have he := equal + (nodeValue_primrec.comp (right_primrec.pair (left_primrec.comp left_primrec))) + (right_primrec.comp left_primrec) + exact (hq.and he).ex.congr (fun _ _ => by + simp only [chainGraphPredicate,left,right,Nat.unpair_pair]) + +theorem sourceT_chainGraph (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (s : ℕ → ℕ) {G : Oracle} (hGM : G ∈ modelReals M) + (hG : ∀ n k, G (Nat.pair n k) = true ↔ k = s n) : + ∃ F ∈ modelReals M, ∀ i j, F (Nat.pair i j) = true ↔ j = chainValue s i := by + let O : Oracles := fun _ => G + refine ⟨arithmeticReal chainGraphPredicate O, + sourceT_arithmetic_comprehension M hM hT chainGraph_arith O (fun _ => hGM),?_⟩ + intro i j + rw [arithmeticReal_true] + simp only [chainGraphPredicate,O,left,right,Nat.unpair_pair,hG,exists_eq_left] + exact eq_comm + +theorem sourceT_realPart (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (f : ℕ → ℕ) {F : Oracle} (hFM : F ∈ modelReals M) + (hF : ∀ i j, F (Nat.pair i j) = true ↔ j = f i) : Test.realPart f ∈ modelReals M := by + have hq := (Arith.query 0).comp (fun n => Nat.pair (Nat.pair 0 n) 1) + (Primrec₂.natPair.comp (Primrec₂.natPair.comp (Primrec.const 0) Primrec.id) (Primrec.const 1)) + apply sourceT_arithmetic_real M hM hT hq (fun _ => F) (fun _ => hFM) (Test.realPart f) + intro n + simp only [Test.realPart,decide_eq_true_eq,hF] + exact eq_comm + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelAutomorphismInterpretation.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelAutomorphismInterpretation.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a5b64470abe53b9721b47239545c4af7784c7ae --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelAutomorphismInterpretation.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelOrderSatisfaction +import OAI.Computability.DegreeRigidity.SetModels.ModelPersistentGraph + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel EncodedForcing PersistentRestrictions PersistentPresentation +open NumericalIdeal NumericalAutomorphism NumericalExtension +universe u + +theorem presentationGraph_automorphism (R : ZFSet.{u}) {J : CountableIdeal} {H S : Oracle} + (hH : Presented J H) (hc : ∀ n, realCode (columns H n) ∈ R) + (ρ : J ≃o J) (hS : ∀ v, S v = true ↔ Graph ρ hH v) : + SetAutomorphism (presentationSet R H) (degreeOrder R) (presentationGraph R H S) := by + refine ⟨presentationGraph_function R hH hc ρ hS,presentationGraph_onto R hH hc ρ hS,?_⟩ + intro D hD E hE D' hD' E' hE' hDD hEE + obtain ⟨x,rfl⟩ := presentedDegreeCode_onto R hH hc D hD + obtain ⟨y,rfl⟩ := presentedDegreeCode_onto R hH hc E hE + obtain ⟨x',rfl⟩ := presentedDegreeCode_onto R hH hc D' hD' + obtain ⟨y',rfl⟩ := presentedDegreeCode_onto R hH hc E' hE' + have hx := (presentationGraph_actual R hH hc ρ hS x x').mp hDD + have hy := (presentationGraph_actual R hH hc ρ hS y y').mp hEE + rw [presentedDegreeCode_order R hH hc,presentedDegreeCode_order R hH hc,←hx,←hy] + exact ρ.le_iff_le.symm + +theorem presentationGraph_action (R : ZFSet.{u}) {J : CountableIdeal} {H S : Oracle} + (hH : Presented J H) (hc : ∀ n, realCode (columns H n) ∈ R) + (hS : Action H (fun v => S v = true)) : + SetAutomorphism (presentationSet R H) (degreeOrder R) (presentationGraph R H S) := by + obtain ⟨ρ,hρ⟩ := reconstruct hH hS + exact presentationGraph_automorphism R hH hc ρ hρ + +theorem presentationSet_subset_of_includes (R : ZFSet.{u}) {A H : Oracle} + (hA : ∀ n, realCode (columns A n) ∈ R) (hin : Includes A H) : + presentationSet R A ⊆ presentationSet R H := by + intro D hD + obtain ⟨n,rfl⟩ := (mem_presentationSet R A D).mp hD + obtain ⟨m,hm⟩ := hin n + exact (mem_presentationSet R H _).mpr ⟨m,(degreeCode_equal R (hA n)).mpr hm⟩ + +theorem presentationGraph_subset_of_compatible (R : ZFSet.{u}) {A H S T : Oracle} + (hA : ∀ n, realCode (columns A n) ∈ R) + (hin : Includes A H) (ha : Action H (fun v => T v = true)) + (hc : Compatible A H (fun v => S v = true) (fun v => T v = true)) : + presentationGraph R A S ⊆ presentationGraph R H T := by + intro z hz + obtain ⟨i,j,rfl,hij⟩ := (mem_presentationGraph R A S z).mp hz + obtain ⟨n,hin⟩ := hin i + obtain ⟨m,hm⟩ := ha.total n + have hjm := hc i j n m hij hm hin + exact (mem_presentationGraph R H T _).mpr ⟨n,m,by + rw [(degreeCode_equal R (hA i)).mpr hin,(degreeCode_equal R (hA j)).mpr hjm],hm⟩ + +theorem presentationGraph_unique (R : ZFSet.{u}) {J : CountableIdeal} {H S : Oracle} + (hH : Presented J H) (hc : ∀ n, realCode (columns H n) ∈ R) + (ρ : J ≃o J) (hS : ∀ v, S v = true ↔ Graph ρ hH v) + (F : ZFSet.{u}) (hf : F ⊆ ZFSet.prod (presentationSet R H) (presentationSet R H)) + (hF : ∀ x y : J, ZFSet.pair (presentedDegreeCode R hH x) (presentedDegreeCode R hH y) ∈ F ↔ ρ x = y) : + F = presentationGraph R H S := by + apply ZFSet.ext; intro z + by_cases hz : z ∈ ZFSet.prod (presentationSet R H) (presentationSet R H) + · obtain ⟨D,hD,E,hE,rfl⟩ := ZFSet.mem_prod.mp hz + obtain ⟨x,rfl⟩ := presentedDegreeCode_onto R hH hc D hD + obtain ⟨y,rfl⟩ := presentedDegreeCode_onto R hH hc E hE + exact (hF x y).trans (presentationGraph_actual R hH hc ρ hS x y).symm + · exact ⟨fun h => False.elim (hz (hf h)),fun h => False.elim (hz (ZFSet.mem_sep.mp h).1)⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelDegreeCodes.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelDegreeCodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..615ea0bb38baf44fd20d174b31d20c919c463954 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelDegreeCodes.lean @@ -0,0 +1,72 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticParameterFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +noncomputable def degreeCode (R : ZFSet.{u}) (A : Oracle) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ B : Oracle, z = realCode B ∧ degree B = degree A) R + +theorem degreeCode_subset (R : ZFSet.{u}) (A : Oracle) : degreeCode R A ⊆ R := + fun _ h => (ZFSet.mem_sep.mp h).1 + +theorem realCode_mem_degreeCode (R : ZFSet.{u}) (A B : Oracle) : + realCode B ∈ degreeCode R A ↔ realCode B ∈ R ∧ degree B = degree A := by + rw [degreeCode,ZFSet.mem_sep] + constructor + · rintro ⟨hB,C,he,hC⟩ + have hBC := realCode_injective he + exact ⟨hB,hBC.symm ▸ hC⟩ + · rintro ⟨hB,hBA⟩; exact ⟨hB,B,rfl,hBA⟩ + +theorem degreeCode_equal (R : ZFSet.{u}) {A B : Oracle} (hA : realCode A ∈ R) + : degreeCode R A = degreeCode R B ↔ degree A = degree B := by + constructor + · intro h + have ha := (realCode_mem_degreeCode R A A).mpr ⟨hA,rfl⟩ + rw [h] at ha + exact ((realCode_mem_degreeCode R B A).mp ha).2 + · intro h; unfold degreeCode; simp only [h] + +theorem internal_degreeCode (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ x ∈ R, ∃ B : Oracle, realCode B = x) + {A : Oracle} (hA : A ∈ modelReals M) : degreeCode R A ∈ M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + have hz : natSet.{u} 0 ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨0,rfl⟩) + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω + obtain ⟨φ,hφ⟩ := degree_equality_bounded.{u} + let e := cons ZFSet.omega (cons Q (cons (natSet 0) (fun _ => realCode A))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hQM + rcases i with _|i; exact hz + exact hA + let D := ZFSet.sep (fun x => (Formula.twoOracles φ 1 2 3 0 4).Eval (cons x e)) R + have hD : D ∈ M := sep_mem M hM hS _ e he hRM + have hcode : degreeCode R A = D := by + apply ZFSet.ext; intro x + by_cases hx : x ∈ R + · obtain ⟨B,rfl⟩ := hR x hx + rw [realCode_mem_degreeCode,ZFSet.mem_sep] + rw [hφ 1 2 3 0 4 (cons (realCode B) e) rfl hQ rfl B A rfl rfl] + · simp only [degreeCode,D,ZFSet.mem_sep,hx,false_and] + rw [hcode] + exact hD + +theorem actual_degreeCode_membership (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hR : ∀ C : Oracle, realCode C ∈ R ↔ C ∈ modelReals M) + {A : Oracle} (hA : A ∈ modelReals M) (B : Oracle) : + realCode B ∈ degreeCode R A ↔ degree B = degree A := by + rw [realCode_mem_degreeCode] + refine ⟨And.right,fun h => ⟨?_,h⟩⟩ + exact (hR B).mpr (sourceT_real_lower M hM hT hA ((degree_eq_iff B A).mp h).1) + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelDegreeOrder.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelDegreeOrder.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9a05895e182c1cafdc1c9880fb30c0e01ce96e4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelDegreeOrder.lean @@ -0,0 +1,134 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelDegreeUniverse + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel UniformArithmetic +universe u + +def degreeCodeLE (D E : ZFSet.{u}) : Prop := + ∃ A B : Oracle, realCode A ∈ D ∧ realCode B ∈ E ∧ Reduces A B + +theorem degreeCodeLE_actual (R : ZFSet.{u}) {A B : Oracle} + (hA : realCode A ∈ R) (hB : realCode B ∈ R) : + degreeCodeLE (degreeCode R A) (degreeCode R B) ↔ degree A ≤ degree B := by + constructor + · rintro ⟨C,D,hC,hD,hCD⟩ + have heC := ((realCode_mem_degreeCode R A C).mp hC).2 + have heD := ((realCode_mem_degreeCode R B D).mp hD).2 + rw [←heC,←heD] + exact hCD + · intro h + exact ⟨A,B,(realCode_mem_degreeCode R A A).mpr ⟨hA,rfl⟩, + (realCode_mem_degreeCode R B B).mpr ⟨hB,rfl⟩,h⟩ + +noncomputable def degreeOrder (R : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun p => ∃ D ∈ degreeUniverse R, ∃ E ∈ degreeUniverse R, + p = ZFSet.pair D E ∧ degreeCodeLE D E) (ZFSet.prod (degreeUniverse R) (degreeUniverse R)) + +theorem mem_degreeOrder (R D E : ZFSet.{u}) : + ZFSet.pair D E ∈ degreeOrder R ↔ + D ∈ degreeUniverse R ∧ E ∈ degreeUniverse R ∧ degreeCodeLE D E := by + rw [degreeOrder,ZFSet.mem_sep] + constructor + · rintro ⟨_,D',hD,E',hE,he,hle⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hD,hE,hle⟩ + · rintro ⟨hD,hE,hle⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨D,hD,E,hE,rfl⟩,D,hD,E,hE,rfl,hle⟩ + +theorem degreeOrder_actual (R : ZFSet.{u}) {A B : Oracle} + (hA : realCode A ∈ R) (hB : realCode B ∈ R) : + ZFSet.pair (degreeCode R A) (degreeCode R B) ∈ degreeOrder R ↔ degree A ≤ degree B := by + rw [mem_degreeOrder,degreeCodeLE_actual R hA hB] + exact ⟨fun h => h.2.2,fun h => ⟨(mem_degreeUniverse _ _).mpr ⟨A,hA,rfl⟩, + (mem_degreeUniverse _ _).mpr ⟨B,hB,rfl⟩,h⟩⟩ + +def DegreeOrderFormula (φ : Formula) : Prop := ∀ o Q z x y : ℕ, ∀ e : ℕ → ZFSet.{u}, + e o = ZFSet.omega → (∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) → + e z = natSet 0 → ∀ A B : Oracle, e x = realCode A → e y = realCode B → + ((Formula.twoOracles φ o Q z x y).Eval e ↔ Reduces A B) + +theorem degree_order_bounded : ∃ φ : Formula, DegreeOrderFormula.{u} φ := by + obtain ⟨φ,hφ⟩ := arithmetic_bounded_definition.{u} + (reduces_arith (parameter_arith 0) (parameter_arith 1)) + refine ⟨φ,?_⟩ + intro o Q z x y e ho hQ hz A B hx hy + simpa using Formula.twoOracles_spec hφ o Q z x y e ho hQ A B hx hy 0 hz + +namespace Formula +def degreeLE (φ : Formula) (o Q z D E : ℕ) : Formula := + .existsMem D (.existsMem (E+1) (twoOracles φ (o+2) (Q+2) (z+2) 1 0)) + +theorem degreeLE_spec {φ : Formula} (hφ : DegreeOrderFormula.{u} φ) + (o Q z D E : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) (hz : e z = natSet 0) + (hD : ∀ w ∈ e D, ∃ A : Oracle, realCode A = w) + (hE : ∀ w ∈ e E, ∃ A : Oracle, realCode A = w) : + (degreeLE φ o Q z D E).Eval e ↔ degreeCodeLE (e D) (e E) := by + simp only [degreeLE,Formula.Eval,cons_succ] + constructor + · rintro ⟨a,ha,b,hb,hle⟩ + obtain ⟨A,rfl⟩ := hD a ha + obtain ⟨B,rfl⟩ := hE b hb + exact ⟨A,B,ha,hb,(hφ (o+2) (Q+2) (z+2) 1 0 + (cons (realCode B) (cons (realCode A) e)) ho hQ hz A B rfl rfl).mp hle⟩ + · rintro ⟨A,B,hA,hB,hle⟩ + exact ⟨realCode A,hA,realCode B,hB,(hφ (o+2) (Q+2) (z+2) 1 0 + (cons (realCode B) (cons (realCode A) e)) ho hQ hz A B rfl rfl).mpr hle⟩ + +def degreeOrderMember (φ : Formula) (o Q z U p : ℕ) : Formula := + .existsMem U (.existsMem (U+1) (.conj (.orderedPair (p+2) 1 0) + (degreeLE φ (o+2) (Q+2) (z+2) 1 0))) + +theorem degreeOrderMember_spec {φ : Formula} (hφ : DegreeOrderFormula.{u} φ) + (o Q z U p : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) (hz : e z = natSet 0) + (R : ZFSet.{u}) (hU : e U = degreeUniverse R) + (hR : ∀ w ∈ R, ∃ A : Oracle, realCode A = w) : + (degreeOrderMember φ o Q z U p).Eval e ↔ e p ∈ degreeOrder R := by + simp only [degreeOrderMember,Formula.Eval,eval_orderedPair,cons_succ,cons_zero] + rw [hU] + have hd (D : ZFSet.{u}) (hD : D ∈ degreeUniverse R) : ∀ w ∈ D, ∃ A : Oracle, realCode A = w := by + obtain ⟨A,_,rfl⟩ := (mem_degreeUniverse R D).mp hD + exact fun w hw => hR w (degreeCode_subset R A hw) + constructor + · rintro ⟨D,hD,E,hE,hp,hle⟩ + rw [hp,mem_degreeOrder] + exact ⟨hD,hE,(degreeLE_spec hφ (o+2) (Q+2) (z+2) 1 0 (cons E (cons D e)) + ho hQ hz (hd D hD) (hd E hE)).mp hle⟩ + · intro hp + obtain ⟨_,D,hD,E,hE,he,hle⟩ := ZFSet.mem_sep.mp hp + exact ⟨D,hD,E,hE,he,(degreeLE_spec hφ (o+2) (Q+2) (z+2) 1 0 (cons E (cons D e)) + ho hQ hz (hd D hD) (hd E hE)).mpr hle⟩ +end Formula + +theorem internal_degreeOrder (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ w ∈ R, ∃ B : Oracle, realCode B = w) : degreeOrder R ∈ M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + have hz : natSet.{u} 0 ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨0,rfl⟩) + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω + obtain ⟨φ,hφ⟩ := degree_order_bounded.{u} + have hU := internal_degreeUniverse M hM hT R hRM hR + let e := cons ZFSet.omega (cons Q (cons (natSet 0) (fun _ => degreeUniverse R))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hQM + rcases i with _|i; exact hz + exact hU + have hs := sep_mem M hM hS (Formula.degreeOrderMember φ 1 2 3 4 0) e he + (product_mem M hM hT.pairing hT.union hT.powerSet hS hU hU) + have heq : ZFSet.sep (fun p => (Formula.degreeOrderMember φ 1 2 3 4 0).Eval (cons p e)) + (ZFSet.prod (degreeUniverse R) (degreeUniverse R)) = degreeOrder R := by + apply ZFSet.ext; intro p + rw [ZFSet.mem_sep,Formula.degreeOrderMember_spec hφ 1 2 3 4 0 (cons p e) rfl hQ rfl R rfl hR] + exact ⟨And.right,fun h => ⟨(ZFSet.mem_sep.mp h).1,h⟩⟩ + exact heq ▸ hs + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelDegreeUniverse.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelDegreeUniverse.lean new file mode 100644 index 0000000000000000000000000000000000000000..7286fb88062ca01a994595646f31252fb4c69617 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelDegreeUniverse.lean @@ -0,0 +1,77 @@ +import OAI.Computability.DegreeRigidity.SetModels.DegreeSetFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +noncomputable def degreeUniverse (R : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun D => ∃ A : Oracle, realCode A ∈ R ∧ D = degreeCode R A) (ZFSet.powerset R) + +theorem mem_degreeUniverse (R D : ZFSet.{u}) : + D ∈ degreeUniverse R ↔ ∃ A : Oracle, realCode A ∈ R ∧ D = degreeCode R A := by + rw [degreeUniverse,ZFSet.mem_sep] + refine ⟨And.right,fun h => ⟨?_,h⟩⟩ + obtain ⟨A,_,rfl⟩ := h + exact ZFSet.mem_powerset.mpr (degreeCode_subset R A) + +theorem degreeUniverse_nonempty_member (R D : ZFSet.{u}) (hD : D ∈ degreeUniverse R) : + ∃ A : Oracle, realCode A ∈ D ∧ D = degreeCode R A := by + obtain ⟨A,hA,rfl⟩ := (mem_degreeUniverse R D).mp hD + exact ⟨A,(realCode_mem_degreeCode R A A).mpr ⟨hA,rfl⟩,rfl⟩ + +namespace Formula +def degreeUniverseMember (φ : Formula) (o Q z R D : ℕ) : Formula := + .existsMem R (degreeSet φ (o+1) (Q+1) (z+1) (R+1) 0 (D+1)) + +theorem degreeUniverseMember_spec {φ : Formula} (hφ : DegreeEqualityFormula.{u} φ) + (o Q z R D : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) (hz : e z = natSet 0) + (hR : ∀ w ∈ e R, ∃ B : Oracle, realCode B = w) : + (degreeUniverseMember φ o Q z R D).Eval e ↔ e D ∈ degreeUniverse (e R) := by + simp only [degreeUniverseMember,Formula.Eval] + rw [mem_degreeUniverse] + constructor + · rintro ⟨w,hw,hd⟩ + obtain ⟨A,rfl⟩ := hR w hw + exact ⟨A,hw,(degreeSet_spec hφ (o+1) (Q+1) (z+1) (R+1) 0 (D+1) + (cons (realCode A) e) ho hQ hz hR A rfl).mp hd⟩ + · rintro ⟨A,hA,hd⟩ + exact ⟨realCode A,hA,(degreeSet_spec hφ (o+1) (Q+1) (z+1) (R+1) 0 (D+1) + (cons (realCode A) e) ho hQ hz hR A rfl).mpr hd⟩ +end Formula + +theorem internal_degreeUniverse (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ w ∈ R, ∃ B : Oracle, realCode B = w) : degreeUniverse R ∈ M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + have hz : natSet.{u} 0 ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨0,rfl⟩) + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω + obtain ⟨P,hPM,hP⟩ := internal_power M hM hT.powerSet hRM + obtain ⟨φ,hφ⟩ := degree_equality_bounded.{u} + have hsub : degreeUniverse R ⊆ P := by + intro D hD + obtain ⟨A,hA,rfl⟩ := (mem_degreeUniverse R D).mp hD + exact (hP _).mpr ⟨internal_degreeCode M hM hT R hRM hR (hM _ hRM _ hA), + degreeCode_subset R A⟩ + let e := cons ZFSet.omega (cons Q (cons (natSet 0) (fun _ => R))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hQM + rcases i with _|i; exact hz + exact hRM + have hs := sep_mem M hM hS (Formula.degreeUniverseMember φ 1 2 3 4 0) e he hPM + have heq : ZFSet.sep (fun D => (Formula.degreeUniverseMember φ 1 2 3 4 0).Eval (cons D e)) P = + degreeUniverse R := by + apply ZFSet.ext; intro D + rw [ZFSet.mem_sep,Formula.degreeUniverseMember_spec hφ 1 2 3 4 0 (cons D e) rfl hQ rfl hR] + exact ⟨And.right,fun h => ⟨hsub h,h⟩⟩ + exact heq ▸ hs + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelIdealInterpretation.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelIdealInterpretation.lean new file mode 100644 index 0000000000000000000000000000000000000000..1bc954fd0f49f354e699a7aad0d80f2e96cf1b94 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelIdealInterpretation.lean @@ -0,0 +1,93 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelDegreeOrder +import OAI.Computability.DegreeRigidity.SetModels.CountableSetReal +import OAI.Computability.DegreeRigidity.SetModels.PresentedDegreeEmbedding + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel EncodedForcing PersistentRestrictions PersistentPresentation +universe u + +def SetIdeal (U L I : ZFSet.{u}) : Prop := I ⊆ U ∧ (∃ D, D ∈ I) ∧ + (∀ D ∈ U, ∀ E ∈ I, ZFSet.pair D E ∈ L → D ∈ I) ∧ + (∀ D ∈ I, ∀ E ∈ I, ∃ F ∈ I, ZFSet.pair D F ∈ L ∧ ZFSet.pair E F ∈ L) + +theorem degreeCode_mem_presentationSet (R : ZFSet.{u}) (H : Oracle) + (hc : ∀ n, realCode (columns H n) ∈ R) (A : Oracle) : + degreeCode R A ∈ presentationSet R H ↔ ∃ n, degree (columns H n) = degree A := by + rw [mem_presentationSet] + constructor + · rintro ⟨n,hn⟩ + exact ⟨n,(degreeCode_equal R (hc n)).mp hn.symm⟩ + · rintro ⟨n,hn⟩ + exact ⟨n,((degreeCode_equal R (hc n)).mpr hn).symm⟩ + +theorem presentationSet_ideal (R : ZFSet.{u}) {J : CountableIdeal} {H : Oracle} + (hH : Presented J H) (hc : ∀ n, realCode (columns H n) ∈ R) : + SetIdeal (degreeUniverse R) (degreeOrder R) (presentationSet R H) := by + have hmem (A : Oracle) : degreeCode R A ∈ presentationSet R H ↔ degree A ∈ J.carrier := + (degreeCode_mem_presentationSet R H hc A).trans (hH (degree A)).symm + refine ⟨?_,⟨degreeCode R (columns H 0),(mem_presentationSet _ _ _).mpr ⟨0,rfl⟩⟩,?_,?_⟩ + · intro D hD + obtain ⟨n,rfl⟩ := (mem_presentationSet R H D).mp hD + exact (mem_degreeUniverse _ _).mpr ⟨columns H n,hc n,rfl⟩ + · intro D hD E hE hle + obtain ⟨A,hA,rfl⟩ := (mem_degreeUniverse R D).mp hD + obtain ⟨n,rfl⟩ := (mem_presentationSet R H E).mp hE + exact (hmem A).mpr (J.lower ((degreeOrder_actual R hA (hc n)).mp hle) (entry hH n).property) + · intro D hD E hE + obtain ⟨n,rfl⟩ := (mem_presentationSet R H D).mp hD + obtain ⟨m,rfl⟩ := (mem_presentationSet R H E).mp hE + obtain ⟨k,hk⟩ := (hH _).mp (J.join_mem (entry hH n).property (entry hH m).property) + refine ⟨degreeCode R (columns H k),(mem_presentationSet _ _ _).mpr ⟨k,rfl⟩,?_,?_⟩ + · apply (degreeOrder_actual R (hc n) (hc k)).mpr + rw [hk]; exact le_sup_left + · apply (degreeOrder_actual R (hc m) (hc k)).mpr + rw [hk]; exact le_sup_right + +theorem sourceT_countable_ideal_presentation (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hR : ∀ A : Oracle, realCode A ∈ R ↔ A ∈ modelReals M) + (hRd : ∀ w ∈ R, ∃ A : Oracle, realCode A = w) + {I : ZFSet.{u}} (hIM : I ∈ M) + (hI : SetIdeal (degreeUniverse R) (degreeOrder R) I) (hcount : InternallyCountable M I) : + ∃ J : CountableIdeal, ∃ H ∈ modelReals M, Presented J H ∧ presentationSet R H = I := by + obtain ⟨H,hHM,hHI⟩ := internal_countable_degree_presentation M hM hT R hRd hIM hI.1 hcount + have hc : ∀ n, realCode (columns H n) ∈ R := + fun n => (hR _).mpr (sourceT_real_column M hM hT hHM n) + let C : Set Degree := Set.range (fun n => degree (columns H n)) + have hmem (A : Oracle) : degreeCode R A ∈ I ↔ degree A ∈ C := by + rw [←hHI,degreeCode_mem_presentationSet R H hc] + rfl + have hlower : ∀ {a b : Degree}, a ≤ b → b ∈ C → a ∈ C := by + intro a b hab hb + obtain ⟨n,rfl⟩ := hb + obtain ⟨A,rfl⟩ := degree_surjective a + have hA : realCode A ∈ R := (hR A).mpr + (sourceT_real_lower M hM hT (sourceT_real_column M hM hT hHM n) hab) + exact (hmem A).mp (hI.2.2.1 (degreeCode R A) ((mem_degreeUniverse _ _).mpr ⟨A,hA,rfl⟩) + (degreeCode R (columns H n)) ((hmem _).mpr ⟨n,rfl⟩) + ((degreeOrder_actual R hA (hc n)).mpr hab)) + have hjoin : ∀ {a b : Degree}, a ∈ C → b ∈ C → a ⊔ b ∈ C := by + intro a b ha hb + obtain ⟨n,rfl⟩ := ha + obtain ⟨m,rfl⟩ := hb + obtain ⟨D,hD,hn,hm⟩ := hI.2.2.2 _ ((hmem _).mpr ⟨n,rfl⟩) _ ((hmem _).mpr ⟨m,rfl⟩) + obtain ⟨k,hk⟩ := (mem_presentationSet R H D).mp (hHI.symm ▸ hD) + rw [hk] at hn hm + exact hlower (sup_le ((degreeOrder_actual R (hc n) (hc k)).mp hn) + ((degreeOrder_actual R (hc m) (hc k)).mp hm)) ⟨k,rfl⟩ + let J : CountableIdeal := ⟨C,⟨degree (columns H 0),0,rfl⟩,Set.countable_range _,@hlower,@hjoin⟩ + exact ⟨J,H,hHM,fun _ => Iff.rfl,hHI⟩ + +theorem presentedDegreeCode_order (R : ZFSet.{u}) {J : CountableIdeal} {H : Oracle} + (hH : Presented J H) (hc : ∀ n, realCode (columns H n) ∈ R) (x y : J) : + ZFSet.pair (presentedDegreeCode R hH x) (presentedDegreeCode R hH y) ∈ degreeOrder R ↔ x ≤ y := by + unfold presentedDegreeCode + rw [degreeOrder_actual R (hc _) (hc _)] + rw [Classical.choose_spec ((hH x.val).mp x.property),Classical.choose_spec ((hH y.val).mp y.property)] + rfl + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelIterationFormula.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelIterationFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..20c73e88920a78c21d981a539242d9fbe538d539 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelIterationFormula.lean @@ -0,0 +1,57 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelIterationTrace + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace Formula + +def modelIterationOuterVars : ℕ → ℕ + | 0 => 0 + | 1 => 1 + | 2 => 2 + | i+3 => i+6 + +def modelIteration (o R Q n b y : ℕ) (θ : Formula) : Formula := + .existsMem o (.existsMem (o+1) (.existsMem (Q+2) + (.conj (modelIterationTrace (o+3) (R+3) 1 2 (n+3) (b+3) 0 (θ.rename modelIterationOuterVars)) + (.pairMem (n+3) (y+3) 0)))) + +theorem eval_modelIteration (o R Q n b y : ℕ) (θ : Formula) (e : ℕ → ZFSet.{u}) : + (modelIteration o R Q n b y θ).Eval e ↔ ∃ k ∈ e o, ∃ z ∈ e o, ∃ f ∈ e Q, + ModelIterationTrace (e o) (e R) z k (e n) (e b) f + (fun i v w => θ.Eval (cons w (cons v (cons i e)))) ∧ ZFSet.pair (e n) (e y) ∈ f := by + simp only [modelIteration,Formula.Eval,eval_modelIterationTrace,eval_pairMem,eval_rename,cons_zero,cons_succ] + have eq (k z f i v w : ZFSet.{u}) : + (fun n => cons w (cons v (cons i (cons f (cons z (cons k e))))) (modelIterationOuterVars n)) = + cons w (cons v (cons i e)) := by + funext n + rcases n with _|n; rfl + rcases n with _|n; rfl + rcases n with _|n <;> rfl + simp only [eq] + +theorem modelIteration_spec (o R Q n b y : ℕ) (θ : Formula) (e : ℕ → ZFSet.{u}) + (ho : e o = ZFSet.omega) + (hQ : ∀ a : ℕ → ZFSet.{u}, (∀ i, a i ∈ e R) → ∀ k, finiteModelGraph a k ∈ e Q) + (N : ℕ) (hn : e n = natSet N) (a : ℕ → ZFSet.{u}) (ha : ∀ i, a i ∈ e R) + (hb : e b = a 0) + (hθ : ∀ i w, w ∈ e R → + (θ.Eval (cons w (cons (a i) (cons (natSet i) e))) ↔ w = a (i+1))) : + (modelIteration o R Q n b y θ).Eval e ↔ e y = a N := by + rw [eval_modelIteration,ho,hn,hb] + constructor + · rintro ⟨k,_,z,_,f,_,hf,hy⟩ + exact hf.correct a ha N _ (fun i w hw h => (hθ i w hw).mp h) hy + · intro hy + refine ⟨natSet (N+1),(mem_omega _).mpr ⟨N+1,rfl⟩,natSet 0,(mem_omega _).mpr ⟨0,rfl⟩, + finiteModelGraph a N,hQ a ha N,?_,?_⟩ + · exact modelIterationTrace_exists (e R) a ha _ (fun i => (hθ i _ (ha (i+1))).mpr rfl) N + · exact (finiteModelGraph_pair a N N _).mpr ⟨le_rfl,hy⟩ + +end Formula +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelIterationTrace.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelIterationTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a72d8339cfd7b47fe175b1c4cd00d226fc26e39 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelIterationTrace.lean @@ -0,0 +1,83 @@ +import OAI.Computability.DegreeRigidity.Syntax.FiniteModelGraph +import OAI.Computability.DegreeRigidity.Effective.TupleFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +def ModelIterationTrace (o R z k n b f : ZFSet.{u}) (S : ZFSet.{u} → ZFSet.{u} → ZFSet.{u} → Prop) : Prop := + TransitiveNameModel.FunctionGraph k R f ∧ k = insert n n ∧ z = ∅ ∧ ZFSet.pair z b ∈ f ∧ + ∀ i ∈ n, ∀ j ∈ o, j = insert i i → ∀ v ∈ R, ∀ w ∈ R, + ZFSet.pair i v ∈ f → ZFSet.pair j w ∈ f → S i v w + +theorem modelIterationTrace_exists (R : ZFSet.{u}) (a : ℕ → ZFSet.{u}) + (ha : ∀ i, a i ∈ R) (S : ZFSet.{u} → ZFSet.{u} → ZFSet.{u} → Prop) + (hS : ∀ i, S (natSet i) (a i) (a (i+1))) (n : ℕ) : + ModelIterationTrace ZFSet.omega R (natSet 0) (natSet (n+1)) (natSet n) (a 0) + (finiteModelGraph a n) S := by + refine ⟨finiteModelGraph_function R a ha n,rfl,rfl,?_,?_⟩ + · exact (finiteModelGraph_pair a n 0 _).mpr ⟨Nat.zero_le _,rfl⟩ + · intro i hi j _ hj v _ w _ hiv hjw + obtain ⟨i,_,rfl⟩ := (mem_natSet n i).mp hi + have hj' : j = natSet (i+1) := hj + subst j + rw [((finiteModelGraph_pair a n i v).mp hiv).2, + ((finiteModelGraph_pair a n (i+1) w).mp hjw).2] + exact hS i + +theorem ModelIterationTrace.correct {R z k f : ZFSet.{u}} (a : ℕ → ZFSet.{u}) + (ha : ∀ i, a i ∈ R) (n : ℕ) + (S : ZFSet.{u} → ZFSet.{u} → ZFSet.{u} → Prop) + (hS : ∀ i w, w ∈ R → S (natSet i) (a i) w → w = a (i+1)) + (hf : ModelIterationTrace ZFSet.omega R z k (natSet n) (a 0) f S) + {y : ZFSet.{u}} (hy : ZFSet.pair (natSet n) y ∈ f) : y = a n := by + obtain ⟨hfun,hk,rfl,hzero,hstep⟩ := hf + have hk' : k = natSet (n+1) := hk + subst k + have computes (i : ℕ) (hi : i ≤ n) : ZFSet.pair (natSet i) (a i) ∈ f := by + induction i with + | zero => exact hzero + | succ i ih => + have hin : i ≤ n := by omega + have hj : natSet.{u} (i+1) ∈ natSet (n+1) := (natSet_mem_natSet _ _).mpr (by omega) + obtain ⟨w,hw,hjw,_⟩ := hfun.2 _ hj + have hs := hstep (natSet i) ((natSet_mem_natSet _ _).mpr (by omega)) (natSet (i+1)) + ((mem_omega _).mpr ⟨i+1,rfl⟩) rfl (a i) (ha i) w hw (ih hin) hjw + have he : w = a (i+1) := hS i w hw hs + exact he ▸ hjw + exact hfun.functional ((natSet_mem_natSet n (n+1)).mpr (Nat.lt_succ_self n)) hy (computes n le_rfl) + +namespace Formula +def modelIterationVars : ℕ → ℕ + | 0 => 0 + | 1 => 1 + | 2 => 3 + | i+3 => i+4 + +def modelIterationTrace (o R z k n b f : ℕ) (θ : Formula) : Formula := + .conj (.functionGraph f k R) (.conj (.successor k n) (.conj (.empty z) + (.conj (.pairMem z b f) + (allMem n (allMem (o+1) (imp (.successor 0 1) + (allMem (R+2) (allMem (R+3) (imp (.pairMem 3 1 (f+4)) + (imp (.pairMem 2 0 (f+4)) (θ.rename modelIterationVars))))))))))) + +theorem eval_modelIterationTrace (o R z k n b f : ℕ) (θ : Formula) (e : ℕ → ZFSet.{u}) : + (modelIterationTrace o R z k n b f θ).Eval e ↔ ModelIterationTrace (e o) (e R) (e z) (e k) (e n) (e b) (e f) + (fun i v w => θ.Eval (cons w (cons v (cons i e)))) := by + simp only [modelIterationTrace,ModelIterationTrace,TransitiveNameModel.FunctionGraph,Formula.Eval, + eval_functionGraph,eval_successor,eval_empty,eval_pairMem,eval_allMem,eval_imp,eval_rename,cons_zero,cons_succ] + have eq (i j v w : ZFSet.{u}) : + (fun n => cons w (cons v (cons j (cons i e))) (modelIterationVars n)) = cons w (cons v (cons i e)) := by + funext n + rcases n with _|n; rfl + rcases n with _|n; rfl + rcases n with _|n <;> rfl + simp only [eq] +end Formula + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelNaturalNumbers.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelNaturalNumbers.lean new file mode 100644 index 0000000000000000000000000000000000000000..defca0130a00a4d619ebaa10c15f8f7a5bd45b69 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelNaturalNumbers.lean @@ -0,0 +1,48 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTheory + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +def InternalNatural (M : ZFSet.{u}) := + {x : ZFSet.{u} // x ∈ M ∧ (Formula.finiteOrdinal 0).Realize M (fun _ => x)} + +theorem internal_natural_iff (M : ZFSet.{u}) (hM : Transitive M) + {x : ZFSet.{u}} (hx : x ∈ M) : + (Formula.finiteOrdinal 0).Realize M (fun _ => x) ↔ ∃ n, x = natSet n := by + rw [Formula.absolute _ M hM _ (fun _ => hx),eval_finiteOrdinal,finiteOrdinal_iff] + +theorem sourceT_omega_mem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ZFSet.omega.{u} ∈ M := omega_mem M hM hT.separation.finitePrefix.bounded hT.infinity + +noncomputable def naturalNumberEquiv (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ℕ ≃ InternalNatural M := by + have hω := sourceT_omega_mem M hM hT + have hn (n : ℕ) : natSet.{u} n ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩) + let f : ℕ → InternalNatural M := fun n => + ⟨natSet n,hn n,(internal_natural_iff M hM (hn n)).mpr ⟨n,rfl⟩⟩ + apply Equiv.ofBijective f + constructor + · intro m n h + exact natSet_injective (congrArg Subtype.val h) + · intro x + obtain ⟨n,hn⟩ := (internal_natural_iff M hM x.property.1).mp x.property.2 + exact ⟨n,Subtype.ext hn.symm⟩ + +theorem naturalNumberEquiv_value (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) (n : ℕ) : + (naturalNumberEquiv M hM hT n).val = natSet n := rfl + +theorem naturalNumberEquiv_mem (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) (m n : ℕ) : + (naturalNumberEquiv M hM hT m).val ∈ (naturalNumberEquiv M hM hT n).val ↔ m < n := + natSet_mem_natSet m n + +theorem naturalNumberEquiv_successor (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) (n : ℕ) : + (naturalNumberEquiv M hM hT (n+1)).val = + insert (naturalNumberEquiv M hM hT n).val (naturalNumberEquiv M hM hT n).val := rfl + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelOmegaJump.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelOmegaJump.lean new file mode 100644 index 0000000000000000000000000000000000000000..83d408d26cd8ed43149227d5e553947770eb2c5a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelOmegaJump.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.Computability.JumpIterationFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel OracleJump +universe u + +namespace Formula +def omegaJumpBits (φ : Formula) : Formula := + .existsMem 1 (.existsMem 2 (.existsMem 4 + (.conj (naturalPair 4 7 2 1 3) + (.conj (jumpIteration φ 4 5 6 7 2 8 0) (.member 1 0))))) +end Formula + +noncomputable def omegaJumpEnv (R Qf Qn : ZFSet.{u}) (A : Oracle) (n : ℕ) : ℕ → ZFSet.{u} := + cons (natSet n) (cons ZFSet.omega (cons R (cons Qf (cons Qn (fun _ => realCode A))))) + +theorem omegaJumpBits_spec {φ : Formula} (hφ : JumpFormula.{u} φ) + (R Qf Qn : ZFSet.{u}) + (hQn : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ Qn) + (hQf : ∀ a : ℕ → ZFSet.{u}, (∀ i, a i ∈ R) → ∀ k, finiteModelGraph a k ∈ Qf) + (hR : ∀ w ∈ R, ∃ B : Oracle, realCode B = w) + (A : Oracle) (hA : ∀ i, realCode (iterate A i) ∈ R) (N : ℕ) : + (Formula.omegaJumpBits φ).Eval (omegaJumpEnv R Qf Qn A N) ↔ + iterate A (Nat.unpair N).1 (Nat.unpair N).2 = true := by + let e := omegaJumpEnv R Qf Qn A N + have hpair (i j : ℕ) (w : ZFSet.{u}) := Formula.naturalPair_spec 4 7 2 1 3 + (cons w (cons (natSet j) (cons (natSet i) e))) rfl hQn i j rfl rfl + have hiter (i j : ℕ) (w : ZFSet.{u}) := Formula.jumpIteration_spec hφ 4 5 6 7 2 8 0 + (cons w (cons (natSet j) (cons (natSet i) e))) rfl hQn hQf hR A hA rfl i rfl + simp only [Formula.omegaJumpBits,Formula.Eval,omegaJumpEnv,cons_zero,cons_succ] + constructor + · rintro ⟨i,hi,j,hj,w,_,hp,ht,hm⟩ + obtain ⟨i,rfl⟩ := (mem_omega i).mp hi + obtain ⟨j,rfl⟩ := (mem_omega j).mp hj + have hN : N = Nat.pair i j := natSet_injective ((hpair i j w).mp hp) + have hw : w = realCode (iterate A i) := (hiter i j w).mp ht + rw [hw,natSet_mem_realCode] at hm + simpa only [hN,Nat.unpair_pair] using hm + · intro h + let i := (Nat.unpair N).1 + let j := (Nat.unpair N).2 + refine ⟨natSet i,(mem_omega _).mpr ⟨i,rfl⟩,natSet j,(mem_omega _).mpr ⟨j,rfl⟩, + realCode (iterate A i),hA i,(hpair i j _).mpr ?_,(hiter i j _).mpr rfl,?_⟩ + · change natSet N = natSet (Nat.pair (Nat.unpair N).1 (Nat.unpair N).2) + rw [Nat.pair_unpair] + · exact (natSet_mem_realCode _ _).mpr h + +theorem sourceT_real_omega_jump (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A : Oracle} (hA : A ∈ modelReals M) : + (fun v => iterate A (Nat.unpair v).1 (Nat.unpair v).2) ∈ modelReals M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + obtain ⟨R,hRM,hR,hRdecode⟩ := internal_real_power M hM hT + have hi : ∀ i, realCode (iterate A i) ∈ R := + fun i => (hR _).mpr (sourceT_real_iterate M hM hT hA i) + obtain ⟨Qf,hQfM,_,hQf⟩ := internal_finite_model_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω R hRM + obtain ⟨Qn,hQnM,_,hQn⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω + obtain ⟨φ,hφ⟩ := jump_bounded_relation.{u} + have hφ' : JumpFormula.{u} φ := hφ + let e := cons ZFSet.omega (cons R (cons Qf (cons Qn (fun _ => realCode A)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hRM + rcases i with _|i; exact hQfM + rcases i with _|i; exact hQnM + exact hA + let B := ZFSet.sep (fun x => (Formula.omegaJumpBits φ).Eval (cons x e)) ZFSet.omega + have hBM : B ∈ M := sep_mem M hM hS _ e he hω + have hbits (n : ℕ) : natSet.{u} n ∈ B ↔ iterate A (Nat.unpair n).1 (Nat.unpair n).2 = true := by + rw [ZFSet.mem_sep] + change (natSet n ∈ ZFSet.omega ∧ (Formula.omegaJumpBits φ).Eval (omegaJumpEnv R Qf Qn A n)) ↔ _ + rw [omegaJumpBits_spec hφ' R Qf Qn hQn hQf + (fun w hw => by obtain ⟨B,_,hB⟩ := hRdecode w hw; exact ⟨B,hB⟩) A hi n] + exact and_iff_right ((mem_omega _).mpr ⟨n,rfl⟩) + have hcode : realCode (fun v => iterate A (Nat.unpair v).1 (Nat.unpair v).2) = B := by + apply ZFSet.ext; intro x + by_cases hx : x ∈ ZFSet.omega.{u} + · obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + rw [natSet_mem_realCode,hbits] + · exact ⟨fun h => False.elim (hx (realCode_subset _ h)), + fun h => False.elim (hx (ZFSet.mem_sep.mp h).1)⟩ + change realCode _ ∈ M + rw [hcode] + exact hBM + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelOrderSatisfaction.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelOrderSatisfaction.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa565ab63edeee7441a9749d3f9e3768a8def62d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelOrderSatisfaction.lean @@ -0,0 +1,82 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelIdealInterpretation + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +def SetAutomorphism (I L F : ZFSet.{u}) : Prop := + TransitiveNameModel.FunctionGraph I I F ∧ + (∀ E ∈ I, ∃ D ∈ I, ZFSet.pair D E ∈ F) ∧ + (∀ D ∈ I, ∀ E ∈ I, ∀ D' ∈ I, ∀ E' ∈ I, + ZFSet.pair D D' ∈ F → ZFSet.pair E E' ∈ F → + (ZFSet.pair D E ∈ L ↔ ZFSet.pair D' E' ∈ L)) + +namespace Formula + +def setIdeal (U L I : ℕ) : Formula := .conj (.subset I U) + (.conj (.existsMem I (.equal 0 0)) + (.conj (allMem U (allMem (I+1) (imp (pairMem 1 0 (L+2)) (.member 1 (I+2))))) + (allMem I (allMem (I+1) (.existsMem (I+2) + (.conj (pairMem 2 0 (L+3)) (pairMem 1 0 (L+3)))))))) + +theorem eval_setIdeal (U L I : ℕ) (e : ℕ → ZFSet.{u}) : + (setIdeal U L I).Eval e ↔ SetIdeal (e U) (e L) (e I) := by + simp only [setIdeal,SetIdeal,Formula.Eval,eval_subset,eval_allMem,eval_imp,eval_pairMem, + cons_zero,cons_succ,and_true] + +def onto (d r f : ℕ) : Formula := allMem r (.existsMem (d+1) (pairMem 0 1 (f+2))) + +theorem eval_onto (d r f : ℕ) (e : ℕ → ZFSet.{u}) : + (onto d r f).Eval e ↔ ∀ y ∈ e r, ∃ x ∈ e d, ZFSet.pair x y ∈ e f := by + simp only [onto,Formula.Eval,eval_allMem,eval_pairMem,cons_zero,cons_succ] + +def surjection (d r f : ℕ) : Formula := .conj (functionGraph f d r) (onto d r f) + +theorem eval_surjection (d r f : ℕ) (e : ℕ → ZFSet.{u}) : + (surjection d r f).Eval e ↔ TransitiveNameModel.FunctionGraph (e d) (e r) (e f) ∧ + ∀ y ∈ e r, ∃ x ∈ e d, ZFSet.pair x y ∈ e f := by + simp only [surjection,Formula.Eval,eval_functionGraph,eval_onto,TransitiveNameModel.FunctionGraph] + +def setAutomorphism (I L F : ℕ) : Formula := .conj (functionGraph F I I) + (.conj (onto I I F) + (allMem I (allMem (I+1) (allMem (I+2) (allMem (I+3) + (imp (pairMem 3 1 (F+4)) (imp (pairMem 2 0 (F+4)) + (iff (pairMem 3 2 (L+4)) (pairMem 1 0 (L+4)))))))))) + +theorem eval_setAutomorphism (I L F : ℕ) (e : ℕ → ZFSet.{u}) : + (setAutomorphism I L F).Eval e ↔ SetAutomorphism (e I) (e L) (e F) := by + simp only [setAutomorphism,SetAutomorphism,TransitiveNameModel.FunctionGraph,Formula.Eval, + eval_functionGraph,eval_onto,eval_allMem,eval_imp,eval_iff,eval_pairMem,cons_zero,cons_succ] + +theorem realize_setIdeal (M : ZFSet.{u}) (hM : Transitive M) + (U L I : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (setIdeal U L I).Realize M e ↔ SetIdeal (e U) (e L) (e I) := + ((setIdeal U L I).absolute M hM e he).trans (eval_setIdeal U L I e) + +theorem realize_setAutomorphism (M : ZFSet.{u}) (hM : Transitive M) + (I L F : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (setAutomorphism I L F).Realize M e ↔ SetAutomorphism (e I) (e L) (e F) := + ((setAutomorphism I L F).absolute M hM e he).trans (eval_setAutomorphism I L F e) +end Formula + +namespace LevySigma + +def countable (o I : ℕ) : LevySigma := .existsSet (.bounded (.surjection (o+1) (I+1) 0)) + +theorem realize_countable (M : ZFSet.{u}) (hM : Transitive M) + (o I : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (ho : e o = ZFSet.omega) : + (countable o I).Realize M e ↔ InternallyCountable M (e I) := by + simp only [countable,Realize,InternallyCountable] + apply exists_congr; intro E + apply and_congr_right; intro hE + rw [(Formula.surjection (o+1) (I+1) 0).absolute M hM (cons E e) + (by intro i; cases i <;> simp [cons,he,hE]),Formula.eval_surjection] + simp only [cons_zero,cons_succ,ho] +end LevySigma + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelPersistenceReals.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelPersistenceReals.lean new file mode 100644 index 0000000000000000000000000000000000000000..fad5f3816df3908fd9b1024541500988ce540170 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelPersistenceReals.lean @@ -0,0 +1,37 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelOmegaJump +import OAI.Computability.DegreeRigidity.Constructibility.PersistenceRealClosure + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open PersistentCountability +open TransitiveNameModel OracleJump PersistenceRealClosure PersistentRestrictions +open PersistentPresentation NumericalAutomorphism NumericalIdeal NumericalExtension +universe u + +theorem sourceT_real_closed (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + PersistenceRealClosure.Closed (modelReals M) where + lower := sourceT_real_lower M hM hT + join := sourceT_real_join M hM hT + omega := sourceT_real_omega_jump M hM hT + +theorem sourceT_persistent_graph_real (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {I : CountableIdeal} {A : Oracle} (hA : Presented I A) (hAM : A ∈ modelReals M) + (ρ : I ≃o I) (hp : Persistent I ρ) (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) : + graphOracle hA ρ ∈ modelReals M := + graph_mem (sourceT_real_closed M hM hT) hA hAM ρ hp hz + +theorem sourceT_persistent_extension_reals (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {I : CountableIdeal} {A R : Oracle} (hA : Presented I A) (hAM : A ∈ modelReals M) + (ρ : I ≃o I) (hp : Persistent I ρ) (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (hR : ∀ v, R v = true ↔ Graph ρ hA v) {X : Oracle} (hX : X ∈ modelReals M) : + ∃ H ∈ modelReals M, ∃ S ∈ modelReals M, JumpCode H ∧ Includes A H ∧ + (∃ n, degree X = degree (EncodedForcing.columns H n)) ∧ + Action H (fun v => S v = true) ∧ + Compatible A H (fun v => R v = true) (fun v => S v = true) := + extension_witnesses (sourceT_real_closed M hM hT) hA hAM ρ hp hz hR hX + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelPersistenceSatisfaction.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelPersistenceSatisfaction.lean new file mode 100644 index 0000000000000000000000000000000000000000..5da0a6e663d070ea06b47b20da361b2158cd4ced --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelPersistenceSatisfaction.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelAutomorphismInterpretation + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +def SetExtensionWitness (o U L I F x J S E : ZFSet.{u}) : Prop := + SetIdeal U L J ∧ + (TransitiveNameModel.FunctionGraph o J E ∧ ∀ y ∈ J, ∃ n ∈ o, ZFSet.pair n y ∈ E) ∧ + SetAutomorphism J L S ∧ I ⊆ J ∧ x ∈ J ∧ F ⊆ S + +def ModelPersistent (M U L I F : ZFSet.{u}) : Prop := SetAutomorphism I L F ∧ + ∀ x ∈ U, ∃ J ∈ M, ∃ S ∈ M, ∃ E ∈ M, SetExtensionWitness ZFSet.omega U L I F x J S E + +namespace Formula + +def setExtensionWitness (o U L I F x J S E : ℕ) : Formula := + .conj (setIdeal U L J) (.conj (surjection o J E) (.conj (setAutomorphism J L S) + (.conj (.subset I J) (.conj (.member x J) (.subset F S))))) + +theorem eval_setExtensionWitness (o U L I F x J S E : ℕ) (e : ℕ → ZFSet.{u}) : + (setExtensionWitness o U L I F x J S E).Eval e ↔ + SetExtensionWitness (e o) (e U) (e L) (e I) (e F) (e x) (e J) (e S) (e E) := by + simp only [setExtensionWitness,SetExtensionWitness,Formula.Eval,eval_setIdeal,eval_surjection, + eval_setAutomorphism,eval_subset] +end Formula + +namespace LevySigma + +def persistent (o U L I F : ℕ) : LevySigma := .conj (.bounded (.setAutomorphism I L F)) + (.allMem U (.existsSet (.existsSet (.existsSet + (.bounded (.setExtensionWitness (o+4) (U+4) (L+4) (I+4) (F+4) 3 2 1 0)))))) + +theorem realize_persistent (M : ZFSet.{u}) (hM : Transitive M) + (o U L I F : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (ho : e o = ZFSet.omega) : + (persistent o U L I F).Realize M e ↔ ModelPersistent M (e U) (e L) (e I) (e F) := by + simp only [persistent,Realize,ModelPersistent] + rw [Formula.realize_setAutomorphism M hM I L F e he] + apply and_congr_right; intro _ + have hbody (x J S E : ZFSet.{u}) (hx : x ∈ M) (hJ : J ∈ M) (hS : S ∈ M) (hE : E ∈ M) : + (Formula.setExtensionWitness (o+4) (U+4) (L+4) (I+4) (F+4) 3 2 1 0).Realize M + (cons E (cons S (cons J (cons x e)))) ↔ + SetExtensionWitness ZFSet.omega (e U) (e L) (e I) (e F) x J S E := by + rw [Formula.absolute _ M hM _ (by + intro i + rcases i with _|i; exact hE + rcases i with _|i; exact hS + rcases i with _|i; exact hJ + rcases i with _|i; exact hx + exact he i),Formula.eval_setExtensionWitness] + simp only [cons_zero,cons_succ,ho] + constructor + · intro h x hx + have hxM := hM _ (he U) _ hx + obtain ⟨J,hJ,S,hS,E,hE,hb⟩ := h x hxM hx + exact ⟨J,hJ,S,hS,E,hE,(hbody x J S E hxM hJ hS hE).mp hb⟩ + · intro h x hxM hx + obtain ⟨J,hJ,S,hS,E,hE,hb⟩ := h x hx + exact ⟨J,hJ,S,hS,E,hE,(hbody x J S E hxM hJ hS hE).mpr hb⟩ +end LevySigma + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelPersistentGraph.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelPersistentGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d54b6c01f1c0912a4541eb96b69f95ff81845d7 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelPersistentGraph.lean @@ -0,0 +1,56 @@ +import OAI.Computability.DegreeRigidity.SetModels.PresentedDegreeEmbedding +import OAI.Computability.DegreeRigidity.SetModels.ModelPersistenceReals + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open PersistentCountability +open TransitiveNameModel EncodedForcing PersistentRestrictions PersistentPresentation OracleJump +universe u + +theorem presentationGraph_function (R : ZFSet.{u}) {I : CountableIdeal} {H S : Oracle} + (hH : Presented I H) (hc : ∀ n, realCode (columns H n) ∈ R) + (ρ : I ≃o I) (hS : ∀ v, S v = true ↔ Graph ρ hH v) : + TransitiveNameModel.FunctionGraph (presentationSet R H) (presentationSet R H) (presentationGraph R H S) := by + constructor + · intro z hz; exact ZFSet.mem_prod.mp (ZFSet.mem_sep.mp hz).1 + · intro D hD + obtain ⟨x,rfl⟩ := presentedDegreeCode_onto R hH hc D hD + refine ⟨presentedDegreeCode R hH (ρ x),presentedDegreeCode_mem R hH (ρ x), + (presentationGraph_actual R hH hc ρ hS x (ρ x)).mpr rfl,?_⟩ + intro F hF hDF + obtain ⟨y,rfl⟩ := presentedDegreeCode_onto R hH hc F hF + exact congrArg (presentedDegreeCode R hH) ((presentationGraph_actual R hH hc ρ hS x y).mp hDF).symm + +theorem presentationGraph_onto (R : ZFSet.{u}) {I : CountableIdeal} {H S : Oracle} + (hH : Presented I H) (hc : ∀ n, realCode (columns H n) ∈ R) + (ρ : I ≃o I) (hS : ∀ v, S v = true ↔ Graph ρ hH v) : + ∀ F ∈ presentationSet R H, ∃ D ∈ presentationSet R H, ZFSet.pair D F ∈ presentationGraph R H S := by + intro F hF + obtain ⟨y,rfl⟩ := presentedDegreeCode_onto R hH hc F hF + refine ⟨presentedDegreeCode R hH (ρ.symm y),presentedDegreeCode_mem R hH (ρ.symm y),?_⟩ + exact (presentationGraph_actual R hH hc ρ hS (ρ.symm y) y).mpr (ρ.apply_symm_apply y) + +theorem sourceT_persistent_graph_set (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ A : Oracle, realCode A ∈ R ↔ A ∈ modelReals M) + (hRd : ∀ w ∈ R, ∃ B : Oracle, realCode B = w) + {I : CountableIdeal} {H : Oracle} (hH : Presented I H) (hHM : H ∈ modelReals M) + (ρ : I ≃o I) (hp : Persistent I ρ) (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) : + presentationGraph R H (graphOracle hH ρ) ∈ M ∧ + TransitiveNameModel.FunctionGraph (presentationSet R H) (presentationSet R H) + (presentationGraph R H (graphOracle hH ρ)) ∧ + ∀ x y : I, ZFSet.pair (presentedDegreeCode R hH x) (presentedDegreeCode R hH y) ∈ + presentationGraph R H (graphOracle hH ρ) ↔ ρ x = y := by + have hc : ∀ n, realCode (columns H n) ∈ R := + fun n => (hR _).mpr (sourceT_real_column M hM hT hHM n) + have hS : ∀ v, graphOracle hH ρ v = true ↔ Graph ρ hH v := by + intro v; simp [graphOracle] + exact ⟨internal_presentationGraph M hM hT R hRM hR hRd hHM + (sourceT_persistent_graph_real M hM hT hH hHM ρ hp hz), + presentationGraph_function R hH hc ρ hS,presentationGraph_actual R hH hc ρ hS⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelPresentationSets.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelPresentationSets.lean new file mode 100644 index 0000000000000000000000000000000000000000..b268e7ac2a50d669b4ac799d4db2e1116509b4f0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelPresentationSets.lean @@ -0,0 +1,90 @@ +import OAI.Computability.DegreeRigidity.SetModels.ColumnSetFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel EncodedForcing UniformArithmetic +universe u + +theorem sourceT_real_column (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A : Oracle} (hA : A ∈ modelReals M) (n : ℕ) : columns A n ∈ modelReals M := + sourceT_arithmetic_oracle M hM hT (column_arith (parameter_arith 0) (Primrec.const n)) + (fun _ => A) (fun _ => hA) 0 + +noncomputable def presentationSet (R : ZFSet.{u}) (H : Oracle) : ZFSet.{u} := + ZFSet.range (fun n : ℕ => degreeCode R (columns H n)) + +theorem mem_presentationSet (R : ZFSet.{u}) (H : Oracle) (D : ZFSet.{u}) : + D ∈ presentationSet R H ↔ ∃ n, D = degreeCode R (columns H n) := by + rw [presentationSet,ZFSet.mem_range] + exact ⟨fun ⟨n,hn⟩ => ⟨n,hn.symm⟩,fun ⟨n,hn⟩ => ⟨n,hn.symm⟩⟩ + +namespace Formula +def presentationMember (φ : Formula) (o Q z R H D : ℕ) : Formula := + .existsMem o (.existsMem (R+1) (.conj (columnSet (o+2) (Q+2) 1 (H+2) 0) + (degreeSet φ (o+2) (Q+2) (z+2) (R+2) 0 (D+2)))) + +theorem presentationMember_spec {φ : Formula} (hφ : DegreeEqualityFormula.{u} φ) + (o Q z R H D : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) (hz : e z = natSet 0) + (hR : ∀ w ∈ e R, ∃ B : Oracle, realCode B = w) + (A : Oracle) (hA : e H = realCode A) (hc : ∀ n, realCode (columns A n) ∈ e R) : + (presentationMember φ o Q z R H D).Eval e ↔ e D ∈ presentationSet (e R) A := by + simp only [presentationMember,Formula.Eval,cons_succ] + rw [ho,mem_presentationSet] + constructor + · rintro ⟨n,hn,B,_,hb,hd⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + have heB : B = realCode (columns A n) := + (columnSet_spec (o+2) (Q+2) 1 (H+2) 0 (cons B (cons (natSet n) e)) ho hQ A hA n rfl).mp hb + refine ⟨n,?_⟩ + exact (degreeSet_spec hφ (o+2) (Q+2) (z+2) (R+2) 0 (D+2) + (cons B (cons (natSet n) e)) ho hQ hz hR (columns A n) heB).mp hd + · rintro ⟨n,hd⟩ + refine ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,realCode (columns A n),hc n,?_,?_⟩ + · exact (columnSet_spec (o+2) (Q+2) 1 (H+2) 0 + (cons (realCode (columns A n)) (cons (natSet n) e)) ho hQ A hA n rfl).mpr rfl + · exact (degreeSet_spec hφ (o+2) (Q+2) (z+2) (R+2) 0 (D+2) + (cons (realCode (columns A n)) (cons (natSet n) e)) ho hQ hz hR (columns A n) rfl).mpr hd +end Formula + +theorem internal_presentationSet (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ A : Oracle, realCode A ∈ R ↔ A ∈ modelReals M) + (hRd : ∀ w ∈ R, ∃ B : Oracle, realCode B = w) + {H : Oracle} (hH : H ∈ modelReals M) : presentationSet R H ∈ M := by + have hS := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + have hz : natSet.{u} 0 ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨0,rfl⟩) + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hS hω + obtain ⟨P,hPM,hP⟩ := internal_power M hM hT.powerSet hRM + obtain ⟨φ,hφ⟩ := degree_equality_bounded.{u} + have hφ' : DegreeEqualityFormula.{u} φ := hφ + have hc : ∀ n, realCode (columns H n) ∈ R := + fun n => (hR _).mpr (sourceT_real_column M hM hT hH n) + have hsub : presentationSet R H ⊆ P := by + intro D hD + obtain ⟨n,rfl⟩ := (mem_presentationSet R H D).mp hD + exact (hP _).mpr ⟨internal_degreeCode M hM hT R hRM hRd (sourceT_real_column M hM hT hH n), + degreeCode_subset R (columns H n)⟩ + let e := cons ZFSet.omega (cons Q (cons (natSet 0) (cons R (fun _ => realCode H)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hω + rcases i with _|i; exact hQM + rcases i with _|i; exact hz + rcases i with _|i; exact hRM + exact hH + let B := ZFSet.sep (fun D => (Formula.presentationMember φ 1 2 3 4 5 0).Eval (cons D e)) P + have hBM : B ∈ M := sep_mem M hM hS _ e he hPM + have hb : B = presentationSet R H := by + apply ZFSet.ext; intro D + rw [ZFSet.mem_sep,Formula.presentationMember_spec hφ' 1 2 3 4 5 0 (cons D e) rfl hQ rfl hRd H rfl hc] + exact ⟨And.right,fun h => ⟨hsub h,h⟩⟩ + rw [←hb] + exact hBM + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelProducts.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..88760f420e8dd1ca269ad32c4636acbeebbd30c4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelProducts.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedSetTheory + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory +open Set TransitiveNameModel +universe u + +theorem binary_union_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : Union M) {a b : ZFSet.{u}} (ha : a ∈ M) (hb : b ∈ M) : + a ∪ b ∈ M := by + simpa only [ZFSet.sUnion_pair] using union_mem M hM hU (pair_mem M hM hP ha hb) + +theorem pair_bound (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : Union M) (hPow : PowerSet M) + {a b : ZFSet.{u}} (ha : a ∈ M) (hb : b ∈ M) : + ∃ c ∈ M, ∀ x ∈ a, ∀ y ∈ b, ZFSet.pair x y ∈ c := by + obtain ⟨q,hq,hqdef⟩ := internal_power M hM hPow (binary_union_mem M hM hP hU ha hb) + obtain ⟨r,hr,hrdef⟩ := internal_power M hM hPow hq + refine ⟨r,hr,fun x hx y hy => ?_⟩ + have hxM := hM a ha x hx + have hyM := hM b hb y hy + apply (hrdef _).mpr + refine ⟨orderedPair_mem M hM hP hxM hyM,?_⟩ + intro z hz + change z ∈ ({({x} : ZFSet.{u}),({x,y} : ZFSet.{u})} : ZFSet.{u}) at hz + rcases ZFSet.mem_pair.mp hz with rfl|rfl + · apply (hqdef _).mpr + refine ⟨singleton_mem M hM hP hxM,?_⟩ + intro t ht + rw [ZFSet.mem_singleton] at ht + exact ht ▸ ZFSet.mem_union.mpr (Or.inl hx) + · apply (hqdef _).mpr + refine ⟨pair_mem M hM hP hxM hyM,?_⟩ + intro t ht + rcases ZFSet.mem_pair.mp ht with rfl|rfl + · exact ZFSet.mem_union.mpr (Or.inl hx) + · exact ZFSet.mem_union.mpr (Or.inr hy) + +def productFormula : Formula := .existsMem 1 (.existsMem 3 (.orderedPair 2 1 0)) + +theorem eval_productFormula (z a b : ZFSet.{u}) (env : ℕ → ZFSet.{u}) : + productFormula.Eval (cons z (cons a (cons b env))) ↔ z ∈ ZFSet.prod a b := by + simp only [productFormula,Formula.Eval,cons_succ,cons_zero,Formula.eval_orderedPair] + exact ZFSet.mem_prod.symm + +theorem product_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : Union M) (hPow : PowerSet M) (hS : Separation M) + {a b : ZFSet.{u}} (ha : a ∈ M) (hb : b ∈ M) : ZFSet.prod a b ∈ M := by + obtain ⟨c,hc,hbound⟩ := pair_bound M hM hP hU hPow ha hb + let env := cons a (cons b (fun _ => a)) + have he : ∀ i, env i ∈ M := by + intro i + cases i with + | zero => exact ha + | succ i => cases i <;> assumption + have hs := sep_mem M hM hS productFormula env he hc + have hprod : ZFSet.sep (fun z => productFormula.Eval (cons z env)) c = ZFSet.prod a b := by + apply ZFSet.ext + intro z + rw [ZFSet.mem_sep] + change (z ∈ c ∧ productFormula.Eval (cons z (cons a (cons b (fun _ => a))))) ↔ _ + rw [eval_productFormula] + constructor + · exact And.right + · intro hz + obtain ⟨x,hx,y,hy,rfl⟩ := ZFSet.mem_prod.mp hz + exact ⟨hbound x hx y hy,ZFSet.mem_prod.mpr ⟨x,hx,y,hy,rfl⟩⟩ + exact hprod ▸ hs + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelRealOperations.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelRealOperations.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5e5155fb6c67087eec9f40c8fb255db56a9e352 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelRealOperations.lean @@ -0,0 +1,51 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelArithmeticComprehension +import OAI.Computability.DegreeRigidity.Computability.ArithmeticRelations + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel UniformArithmetic Encodable TableIndices OracleJump IndexMatrix +universe u + +theorem sourceT_arithmetic_oracle (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {B : OracleFamily} (hB : ArithmeticOracle B) (O : Oracles) + (hO : ∀ i, O i ∈ modelReals M) (v : ℕ) : B O v ∈ modelReals M := by + have hp := Arith.comp (fun n => Nat.pair v n) hB (Primrec₂.natPair.comp (Primrec.const v) Primrec.id) + exact sourceT_arithmetic_real M hM hT hp O hO (B O v) + (fun n => by simp only [left,right,Nat.unpair_pair]) + +theorem sourceT_real_lower (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A B : Oracle} (hB : B ∈ modelReals M) (hAB : Reduces A B) : A ∈ modelReals M := by + obtain ⟨d,hd⟩ := reduces_represents hAB + have hd' : Represents B (machine (encode d)) A := by simpa using hd + have h := sourceT_arithmetic_oracle M hM hT + (tableOracle_arith (parameter_arith 0) (Primrec.const (encode d))) (fun _ => B) (fun _ => hB) 0 + change tableOracle B (encode d) ∈ modelReals M at h + rw [tableOracle_eq hd'] at h + exact h + +theorem sourceT_real_join (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A B : Oracle} (hA : A ∈ modelReals M) (hB : B ∈ modelReals M) : + TuringRigidity.join A B ∈ modelReals M := by + let O : Oracles := fun i => if i = 0 then A else B + have hO : ∀ i, O i ∈ modelReals M := by + intro i; dsimp [O]; split <;> assumption + have h := sourceT_arithmetic_oracle M hM hT + (join_arith (parameter_arith 0) (parameter_arith 1)) O hO 0 + simpa [O] using h + +theorem sourceT_real_jump (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A : Oracle} (hA : A ∈ modelReals M) : jump A ∈ modelReals M := + sourceT_arithmetic_oracle M hM hT (jump_arith (parameter_arith 0)) + (fun _ => A) (fun _ => hA) 0 + +theorem sourceT_real_iterate (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {A : Oracle} (hA : A ∈ modelReals M) (n : ℕ) : iterate A n ∈ modelReals M := by + induction n with + | zero => exact hA + | succ n ih => exact sourceT_real_jump M hM hT ih + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ModelReals.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelReals.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5246068605ed1c632b228ca8a4debbd2811d372 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ModelReals.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelNaturalNumbers +import OAI.Computability.DegreeRigidity.SetModels.Degrees + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +noncomputable def realCode (A : Oracle) : ZFSet.{u} := + ZFSet.sep (fun x => ∃ n, x = natSet n ∧ A n = true) ZFSet.omega + +theorem realCode_subset (A : Oracle) : realCode.{u} A ⊆ ZFSet.omega := + fun _ hx => (ZFSet.mem_sep.mp hx).1 + +theorem natSet_mem_realCode (A : Oracle) (n : ℕ) : natSet.{u} n ∈ realCode A ↔ A n = true := by + rw [realCode,ZFSet.mem_sep] + constructor + · rintro ⟨_,m,he,hm⟩ + have hnm := natSet_injective he + exact hnm.symm ▸ hm + · intro hn + exact ⟨(mem_omega _).mpr ⟨n,rfl⟩,n,rfl,hn⟩ + +noncomputable def decodeReal (x : ZFSet.{u}) : Oracle := fun n => by + classical + exact decide (natSet n ∈ x) + +theorem decodeReal_true (x : ZFSet.{u}) (n : ℕ) : decodeReal x n = true ↔ natSet n ∈ x := by + classical + simp only [decodeReal,decide_eq_true_eq] + +theorem realCode_decodeReal {x : ZFSet.{u}} (hx : x ⊆ ZFSet.omega) : realCode (decodeReal x) = x := by + apply ZFSet.ext; intro z + by_cases hz : z ∈ ZFSet.omega.{u} + · obtain ⟨n,rfl⟩ := (mem_omega z).mp hz + rw [natSet_mem_realCode,decodeReal_true] + · exact ⟨fun h => False.elim (hz (realCode_subset _ h)),fun h => False.elim (hz (hx h))⟩ + +theorem realCode_injective : Function.Injective (realCode.{u}) := by + intro A B he + funext n + have h : A n = true ↔ B n = true := by + rw [←natSet_mem_realCode.{u} A n,←natSet_mem_realCode.{u} B n,he] + cases ha : A n <;> cases hb : B n <;> simp_all + +theorem decodeReal_realCode (A : Oracle) : decodeReal (realCode.{u} A) = A := + realCode_injective (realCode_decodeReal (realCode_subset A)) + +def modelReals (M : ZFSet.{u}) : Set Oracle := {A | realCode A ∈ M} + +theorem internal_real_power (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) : + ∃ R ∈ M, (∀ A : Oracle, realCode A ∈ R ↔ A ∈ modelReals M) ∧ + ∀ x ∈ R, ∃ A ∈ modelReals M, realCode A = x := by + obtain ⟨R,hR,hRdef⟩ := internal_power M hM hT.powerSet (sourceT_omega_mem M hM hT) + refine ⟨R,hR,?_,?_⟩ + · intro A + rw [hRdef] + exact and_iff_left (realCode_subset A) + · intro x hx + have hxm := ((hRdef x).mp hx).1 + have he := realCode_decodeReal ((hRdef x).mp hx).2 + refine ⟨decodeReal x,?_,he⟩ + change realCode (decodeReal x) ∈ M + rw [he] + exact hxm + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/MostowskiCollapse.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/MostowskiCollapse.lean new file mode 100644 index 0000000000000000000000000000000000000000..527a8c2e5f609f5aba7200ebf27cfee2036b95e3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/MostowskiCollapse.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DegreeRigidity.SetModels.CollapseCoding + +namespace OAI + + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory +universe u + +def Extensional (d r : ZFSet.{u}) : Prop := + ∀ x ∈ d, ∀ y ∈ d, (∀ z ∈ d, ZFSet.pair z x ∈ r ↔ ZFSet.pair z y ∈ r) → x = y + +theorem value_injective {d r : ZFSet.{u}} (wf : WellFounded (Rel d r)) + (he : Extensional d r) (x : ZFSet.{u}) (hx : x ∈ d) (y : ZFSet.{u}) (hy : y ∈ d) + (hxy : value d r wf x = value d r wf y) : x = y := by + induction x using wf.induction generalizing y with + | h x ih => + apply he x hx y hy + intro z hz + constructor + · intro hzx + have hm : value d r wf z ∈ value d r wf y := hxy ▸ + (mem_value d r wf x _).mpr ⟨z,hz,hzx,rfl⟩ + obtain ⟨w,hw,hwy,hzw⟩ := (mem_value d r wf y _).mp hm + have hzw' := ih z ⟨hz,hzx⟩ hz w hw hzw + exact hzw' ▸ hwy + · intro hzy + have hm : value d r wf z ∈ value d r wf x := hxy.symm ▸ + (mem_value d r wf y _).mpr ⟨z,hz,hzy,rfl⟩ + obtain ⟨w,hw,hwx,hzw⟩ := (mem_value d r wf x _).mp hm + have hwz := ih w ⟨hw,hwx⟩ hw z hz hzw.symm + exact hwz ▸ hwx + +theorem value_mem_iff {d r : ZFSet.{u}} (wf : WellFounded (Rel d r)) + (he : Extensional d r) {x y : ZFSet.{u}} (hx : x ∈ d) : + value d r wf x ∈ value d r wf y ↔ ZFSet.pair x y ∈ r := by + rw [mem_value] + constructor + · rintro ⟨z,hz,hzy,hxz⟩ + have hxz := value_injective wf he x hx z hz hxz + exact hxz ▸ hzy + · intro hxy + exact ⟨x,hx,hxy,rfl⟩ + +noncomputable def graphRange (d f : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun v => ∃ x ∈ d, ZFSet.pair x v ∈ f) (iterUnion 2 f) + +theorem mem_graphRange (d f v : ZFSet.{u}) : + v ∈ graphRange d f ↔ ∃ x ∈ d, ZFSet.pair x v ∈ f := by + rw [graphRange,ZFSet.mem_sep] + constructor + · exact And.right + · rintro ⟨x,hx,hxv⟩ + exact ⟨second_mem_doubleUnion hxv,x,hx,hxv⟩ + +theorem graphRange_mem (M : ZFSet.{u}) (hM : Transitive M) + (hU : BoundedSetTheory.Union M) (hS : Separation M) + {d f : ZFSet.{u}} (hd : d ∈ M) (hf : f ∈ M) : graphRange d f ∈ M := by + simpa only [graphRange,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ] using + sep_mem M hM hS (.existsMem 1 (.pairMem 0 1 3)) (cons d (fun _ => f)) + (by intro i; cases i <;> assumption) (iterUnion_mem M hM hU hf 2) + +theorem Graph.range_iff {d r b f : ZFSet.{u}} (wf : WellFounded (Rel d r)) + (hf : Graph d r d b f) (v : ZFSet.{u}) : + v ∈ graphRange d f ↔ ∃ x ∈ d, v = value d r wf x := by + rw [mem_graphRange] + constructor + · rintro ⟨x,hx,hxv⟩ + obtain ⟨y,hy,heq⟩ := (hf.mem_iff wf _).mp hxv + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + exact ⟨x,hx,rfl⟩ + · rintro ⟨x,hx,rfl⟩ + exact ⟨x,hx,(hf.mem_iff wf _).mpr ⟨x,hx,rfl⟩⟩ + +theorem Graph.range_transitive {d r b f : ZFSet.{u}} (wf : WellFounded (Rel d r)) + (hf : Graph d r d b f) : Transitive (graphRange d f) := by + intro v hv w hw + obtain ⟨x,_,rfl⟩ := (hf.range_iff wf v).mp hv + obtain ⟨y,hy,_,rfl⟩ := (mem_value d r wf x w).mp hw + exact (hf.range_iff wf _).mpr ⟨y,hy,rfl⟩ + +theorem internal_mostowski (M d r : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) + (hd : d ∈ M) (hr : r ∈ M) (wf : WellFounded (Rel d r)) (he : Extensional d r) : + ∃ b ∈ M, ∃ f ∈ M, + Presents d f (value d r wf) ∧ Transitive b ∧ + (∀ v, v ∈ b ↔ ∃ x ∈ d, v = value d r wf x) ∧ + (∀ x ∈ d, ∀ y ∈ d, value d r wf x = value d r wf y → x = y) ∧ + (∀ x ∈ d, ∀ y ∈ d, value d r wf x ∈ value d r wf y ↔ ZFSet.pair x y ∈ r) := by + obtain ⟨f,hf,hfg⟩ := internal_graph M d r hM hP hU hPow hS hR hd hr wf + exact ⟨graphRange d f,graphRange_mem M hM hU hS hd hf,f,hf, + hfg.mem_iff wf,hfg.range_transitive wf,hfg.range_iff wf, + value_injective wf he,fun _ hx _ _ => value_mem_iff wf he hx⟩ + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/NameDifferenceDense.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/NameDifferenceDense.lean new file mode 100644 index 0000000000000000000000000000000000000000..24fdd4ba0c8515aca0ed2482a78a49f8fb3d85c8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/NameDifferenceDense.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformNameDescent + +namespace OAI + + +namespace TuringRigidity.FullSetForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] [OrderTop (Conditions c)] + +def NameDifference (a S : ZFSet.{u}) (t : Name (Conditions c)) : Set (Conditions c) := + {p | ∃ x ∈ a, (x ∈ S ∧ ∀ q, q ≤ p → ¬ MemForces (Name.check x) t q) ∨ + (x ∉ S ∧ MemForces (Name.check x) t p)} + +theorem nameDifference_dense (M : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) {o a S : ZFSet.{u}} (hoM : o ∈ M) (ha : a ∈ M) + (hSa : S ⊆ a) (hSM : S ∉ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (t : Name (Conditions c)) (ht : t.encode (label c) ∈ M) : + Dense (NameDifference a S t) := by + classical + intro p + by_contra h + have avoid : ∀ q, q ≤ p → ¬ (q ∈ NameDifference a S t) := by + simpa only [not_exists,not_and] using h + obtain ⟨b,hb,hdef⟩ := internal_forced_members M hM hT hc hoM ha ho t ht p + have hbS : b = S := by + apply ZFSet.ext + intro x + rw [hdef x] + constructor + · rintro ⟨hxa,hf⟩ + by_contra hx + exact avoid p le_rfl ⟨x,hxa,Or.inr ⟨hx,hf⟩⟩ + · intro hx + refine ⟨hSa hx,mem_of_dense _ _ p ?_⟩ + intro q hqp + by_contra hn + have hneg : ∀ r, r ≤ q → ¬ MemForces (Name.check x) t r := by + simpa only [not_exists,not_and] using hn + exact avoid q hqp ⟨x,hSa hx,Or.inl ⟨hx,hneg⟩⟩ + exact hSM (hbS ▸ hb) + +theorem nameDifference_ne_value (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) {o a S : ZFSet.{u}} (hoM : o ∈ M) (ha : a ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (t : Name (Conditions c)) (ht : t.encode (label c) ∈ M) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) + {p : Conditions c} (hp : p ∈ G.carrier) (hd : p ∈ NameDifference a S t) : + t.val G.carrier ≠ S := by + obtain ⟨x,hxa,hd⟩ := hd + have hS := hT.separation.finitePrefix.bounded + have hR := hT.replacement.finitePrefix + have hxM := hM a ha x hxa + have hcheck := encoded_check_mem M c hM hT.pairing hT.union hT.powerSet hS hR hT.infinity hc hxM + have htop : ⊤ ∈ G.carrier := G.upper le_top hp + have truth := (internal_atomic_truth M hM hT.pairing hT.union hT.powerSet hS hR hT.infinity + hc hoM ho G hG (Name.check x) t hcheck ht).2 + rw [Name.val_check G.carrier htop] at truth + intro hval + rw [hval] at truth + rcases hd with ⟨hx,hneg⟩|⟨hx,hpos⟩ + · obtain ⟨q,hq,hf⟩ := truth.mp hx + obtain ⟨r,_,hrp,hrq⟩ := G.directed hp hq + exact hneg r hrp (mem_mono _ _ hrq hf) + · exact hx (truth.mpr ⟨p,hp,hpos⟩) + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/NameEncoding.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/NameEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..c57f94aa62caa2f12ea2dae1515a933fee753844 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/NameEncoding.lean @@ -0,0 +1,61 @@ +import OAI.Computability.DegreeRigidity.SetModels.RecursiveNames + +namespace OAI + +namespace TuringRigidity.RecursiveNames +open Set +universe u +variable {P : Type u} + +noncomputable def Name.encode (label : P → ZFSet.{u}) : Name P → ZFSet.{u} + | .mk _ child tag => ZFSet.range (fun i => ZFSet.pair (encode label (child i)) (label (tag i))) + +theorem Name.val_eq_of_encode_eq (label : P → ZFSet.{u}) + (hl : Function.Injective label) (G : Set P) (τ σ : Name P) + (he : encode label τ = encode label σ) : val G τ = val G σ := by + induction τ generalizing σ with + | mk ι child tag ih => + cases σ with + | mk κ other otag => + apply ZFSet.ext + intro x + rw [mem_val,mem_val] + constructor + · rintro ⟨i,hi,hx⟩ + have hm : ZFSet.pair (encode label (child i)) (label (tag i)) ∈ + encode label (.mk ι child tag) := ZFSet.mem_range_self i + rw [he] at hm + obtain ⟨j,hj⟩ := ZFSet.mem_range.mp hm + obtain ⟨hc,ht⟩ := ZFSet.pair_inj.mp hj + refine ⟨j,by simpa only [hl ht] using hi,?_⟩ + exact (ih i (other j) hc.symm).symm.trans hx + · rintro ⟨j,hj,hx⟩ + have hm : ZFSet.pair (encode label (other j)) (label (otag j)) ∈ + encode label (.mk κ other otag) := ZFSet.mem_range_self j + rw [←he] at hm + obtain ⟨i,hi⟩ := ZFSet.mem_range.mp hm + obtain ⟨hc,ht⟩ := ZFSet.pair_inj.mp hi + refine ⟨i,by simpa only [hl ht] using hj,?_⟩ + exact (ih i (other j) hc).trans hx + +def EncodedName (label : P → ZFSet.{u}) := {x : ZFSet.{u} // ∃ τ, Name.encode label τ = x} + +noncomputable def Name.toEncoded (label : P → ZFSet.{u}) (τ : Name P) : EncodedName label := + ⟨Name.encode label τ,τ,rfl⟩ + +noncomputable def EncodedName.val {label : P → ZFSet.{u}} + (G : Set P) (τ : EncodedName label) : ZFSet.{u} := Name.val G τ.property.choose + +theorem Name.val_toEncoded (label : P → ZFSet.{u}) (hl : Function.Injective label) + (G : Set P) (τ : Name P) : (τ.toEncoded label).val G = τ.val G := by + apply Name.val_eq_of_encode_eq label hl G + exact (τ.toEncoded label).property.choose_spec + +theorem encoded_check [Top P] (label : P → ZFSet.{u}) (hl : Function.Injective label) + (G : Set P) (hG : ⊤ ∈ G) (x : ZFSet.{u}) : + ((Name.check x : Name P).toEncoded label).val G = x := by + rw [Name.val_toEncoded label hl,Name.val_check G hG] + +end TuringRigidity.RecursiveNames + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/NameEvaluationGraph.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/NameEvaluationGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..be344c59f2b6d4f187369dd5b9e340a48147c8c2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/NameEvaluationGraph.lean @@ -0,0 +1,71 @@ +import OAI.Computability.DegreeRigidity.SetModels.EvaluationNameCode +import OAI.Computability.DegreeRigidity.SetModels.NameValueCover + +namespace OAI + + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory +universe u +variable {c : ZFSet.{u}} + +theorem mem_val_coverName (W : ZFSet.{u}) + (hW : ∀ x ∈ W, ∃ a : Name (Conditions c), a.encode (label c) = x) + (G : Set (Conditions c)) (p : Conditions c) (hp : p ∈ G) (z : ZFSet.{u}) : + z ∈ (coverName W hW p).val G ↔ + ∃ b : Name (Conditions c), b.encode (label c) ∈ W ∧ b.val G = z := by + constructor + · intro hz + rw [coverName,Name.mem_val] at hz + obtain ⟨i,_,he⟩ := hz + exact ⟨coverChild W hW i,by rw [coverChild_code]; exact label_mem W i,he⟩ + · rintro ⟨b,hb,rfl⟩ + exact val_mem_coverName W hW G p hp b hb + +variable [Top (Conditions c)] + +theorem internal_name_evaluation_graph (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {V : ZFSet.{u}} (hV : V ∈ M) + (hvalid : ∀ x ∈ V, ∃ a : Name (Conditions c), a.encode (label c) = x) + (G : Set (Conditions c)) (htop : ⊤ ∈ G) : + ∃ H : Name (Conditions c), H.encode (label c) ∈ M ∧ ∀ z, + z ∈ H.val G ↔ ∃ x ∈ V, ∃ a : Name (Conditions c), + a.encode (label c) = x ∧ z = ZFSet.pair x (a.val G) := by + have ht := hM c hc _ (label_mem c ⊤) + obtain ⟨B,hB,hBdef⟩ := internal_evaluation_name_codes M hM hP hU hPow hS hR hI hV ht + have hvalidB (z : ZFSet.{u}) (hz : z ∈ B) : + ∃ a : Name (Conditions c), a.encode (label c) = z := by + obtain ⟨x,hx,he⟩ := (hBdef z).mp hz + obtain ⟨a,ha⟩ := hvalid x hx + refine ⟨orderedPairName (Name.check x) a,?_⟩ + rw [encode_orderedPairName,encode_check,ha] + exact he + let H := coverName B hvalidB ⊤ + have hH : H.encode (label c) ∈ M := by + rw [encode_coverName] + exact product_mem M hM hP hU hPow hS hB (singleton_mem M hM hP ht) + refine ⟨H,hH,?_⟩ + intro z + rw [mem_val_coverName B hvalidB G ⊤ htop] + constructor + · rintro ⟨b,hb,rfl⟩ + obtain ⟨x,hx,he⟩ := (hBdef _).mp hb + obtain ⟨a,ha⟩ := hvalid x hx + have hcode : b.encode (label c) = (orderedPairName (Name.check x) a).encode (label c) := by + rw [encode_orderedPairName,encode_check,ha] + exact he.symm + have hv := Name.val_eq_of_encode_eq (label c) (label_injective c) G _ _ hcode + rw [val_orderedPairName G htop,Name.val_check G htop] at hv + exact ⟨x,hx,a,ha,hv⟩ + · rintro ⟨x,hx,a,ha,rfl⟩ + refine ⟨orderedPairName (Name.check x) a,?_,?_⟩ + · apply (hBdef _).mpr + refine ⟨x,hx,?_⟩ + rw [encode_orderedPairName,encode_check,ha] + · rw [val_orderedPairName G htop,Name.val_check G htop] + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/NameExtension.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/NameExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb6ff8b06fe9bb3b14072e90f69a6340f74a0285 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/NameExtension.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DegreeRigidity.SetModels.RecursiveNames +import Mathlib.Data.Set.Countable + +namespace OAI + +namespace TuringRigidity.RecursiveNames +open Set CountableForcing +universe u +variable {P : Type u} + +def Name.Child : Name P → Name P → Prop + | σ, .mk _ child _ => ∃ i, child i = σ + +def extension (M : Set (Name P)) (G : Set P) : Set ZFSet.{u} := Name.val G '' M + +def ChildClosed (M : Set (Name P)) : Prop := + ∀ τ ∈ M, ∀ σ, Name.Child σ τ → σ ∈ M + +theorem extension_transitive (M : Set (Name P)) (hM : ChildClosed M) (G : Set P) : + ∀ x ∈ extension M G, ∀ y ∈ x, y ∈ extension M G := by + rintro x ⟨τ,hτ,rfl⟩ y hy + cases τ with + | mk ι child tag => + obtain ⟨i,_,hi⟩ := (Name.mem_val G ι child tag y).mp hy + exact ⟨child i,hM _ hτ _ ⟨i,rfl⟩,hi⟩ + +theorem extension_countable (M : Set (Name P)) (hM : M.Countable) (G : Set P) : + (extension M G).Countable := hM.image (Name.val G) + +theorem ground_subset_extension [Top P] (M : Set (Name P)) (V : Set ZFSet.{u}) + (hM : ∀ x ∈ V, Name.check x ∈ M) (G : Set P) (hG : ⊤ ∈ G) : + V ⊆ extension M G := fun x hx => ⟨Name.check x,hM x hx,Name.val_check G hG x⟩ + +namespace Name + +def pair [Top P] (σ τ : Name P) : Name P := + .mk (ULift Bool) (fun i => if i.down then σ else τ) (fun _ => ⊤) + +theorem val_pair [Top P] (G : Set P) (hG : ⊤ ∈ G) (σ τ : Name P) : + val G (pair σ τ) = ({val G σ,val G τ} : ZFSet.{u}) := by + apply ZFSet.ext + intro x + simp only [pair,mem_val,hG,true_and,ZFSet.mem_pair] + constructor + · rintro ⟨⟨b⟩,hb⟩ + cases b + · exact Or.inr hb.symm + · exact Or.inl hb.symm + · rintro (h|h) + · exact ⟨⟨true⟩,h.symm⟩ + · exact ⟨⟨false⟩,h.symm⟩ + +def arity : Name P → Type u + | .mk ι _ _ => ι + +def child : (τ : Name P) → arity τ → Name P + | .mk _ c _, i => c i + +def tag : (τ : Name P) → arity τ → P + | .mk _ _ t, i => t i + +def union [Preorder P] (τ : Name P) : Name P := + .mk (Σ i : arity τ, Σ j : arity (child τ i), + {p : P // p ≤ tag τ i ∧ p ≤ tag (child τ i) j}) + (fun t => child (child τ t.1) t.2.1) (fun t => t.2.2.val) + +theorem mem_val_children (G : Set P) (τ : Name P) (x : ZFSet.{u}) : + x ∈ val G τ ↔ ∃ i, tag τ i ∈ G ∧ val G (child τ i) = x := by + cases τ + exact mem_val _ _ _ _ _ + +theorem val_union [Preorder P] (G : GenericFilter P) (τ : Name P) : + val G.carrier (union τ) = ZFSet.sUnion (val G.carrier τ) := by + apply ZFSet.ext + intro x + rw [union,mem_val,ZFSet.mem_sUnion] + constructor + · rintro ⟨⟨i,j,p,hpi,hpj⟩,hp,hx⟩ + refine ⟨val G.carrier (child τ i),?_,?_⟩ + · exact (mem_val_children _ _ _).mpr ⟨i,G.upper hpi hp,rfl⟩ + · exact (mem_val_children _ _ _).mpr ⟨j,G.upper hpj hp,hx⟩ + · rintro ⟨y,hy,hx⟩ + obtain ⟨i,hi,rfl⟩ := (mem_val_children _ _ _).mp hy + obtain ⟨j,hj,hx⟩ := (mem_val_children _ _ _).mp hx + obtain ⟨p,hp,hpi,hpj⟩ := G.directed hi hj + exact ⟨⟨i,j,p,hpi,hpj⟩,hp,hx⟩ + +end Name + +theorem extension_pair_closed [Top P] (M : Set (Name P)) + (hM : ∀ σ ∈ M, ∀ τ ∈ M, Name.pair σ τ ∈ M) (G : Set P) (hG : ⊤ ∈ G) : + ∀ x ∈ extension M G, ∀ y ∈ extension M G, ({x,y} : ZFSet.{u}) ∈ extension M G := by + rintro x ⟨σ,hσ,rfl⟩ y ⟨τ,hτ,rfl⟩ + exact ⟨Name.pair σ τ,hM σ hσ τ hτ,Name.val_pair G hG σ τ⟩ + +end TuringRigidity.RecursiveNames + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/NameSupport.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/NameSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7c1847ccfa17cc21653ad8ca350600ed1eb6232 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/NameSupport.lean @@ -0,0 +1,77 @@ +import OAI.Computability.DegreeRigidity.SetModels.RestrictedName +import OAI.Computability.DegreeRigidity.Syntax.AtomicDefinability + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory +universe u + +def SupportPredicate (d c o x z : ZFSet.{u}) : Prop := + ∃ a ∈ d, ∃ q ∈ c, z = ZFSet.pair a q ∧ ∃ s ∈ c, + ZFSet.pair a s ∈ x ∧ ZFSet.pair q s ∈ o + +namespace AtomicFormula +open Formula + +def support (d c o x z : ℕ) : Formula := + .existsMem d (.existsMem (c+1) (.conj (orderedPair (z+2) 1 0) + (.existsMem (c+2) (.conj (pairMem 2 0 (x+3)) (pairMem 1 0 (o+3)))))) + +theorem eval_support (d c o x z : ℕ) (e : ℕ → ZFSet.{u}) : + (support d c o x z).Eval e ↔ SupportPredicate (e d) (e c) (e o) (e x) (e z) := by + simp only [support,Formula.Eval,eval_orderedPair,eval_pairMem,cons_zero,cons_succ,SupportPredicate] +end AtomicFormula + +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem support_iff {d o : ZFSet.{u}} (a : Name (Conditions c)) + (hd : ∀ i, (a.child i).encode (label c) ∈ d) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (z : ZFSet.{u}) : z ∈ a.support (label c) ↔ SupportPredicate d c o (a.encode (label c)) z := by + constructor + · intro hz + obtain ⟨⟨i,q,hq⟩,hz⟩ := ZFSet.mem_range.mp hz + exact ⟨_,hd i,_,label_mem c q,hz.symm,_,label_mem c (a.tag i), + (pair_mem_encode _ _ _ _).mpr ⟨i,rfl,rfl⟩,(ho q (a.tag i)).mpr hq⟩ + · rintro ⟨x,hx,q,hq,rfl,s,hs,hxs,hqs⟩ + obtain ⟨i,hi,his⟩ := (pair_mem_encode _ _ _ _).mp hxs + subst x + subst s + obtain ⟨r,rfl⟩ := label_surjective c hq + exact ZFSet.mem_range.mpr ⟨⟨i,⟨r,(ho r (a.tag i)).mp hqs⟩⟩,rfl⟩ + +theorem support_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hc : c ∈ M) {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) : a.support (label c) ∈ M := by + let d := iterUnion 2 (a.encode (label c)) + have hd : d ∈ M := iterUnion_mem M hM hU ha 2 + have hdi (i) : (a.child i).encode (label c) ∈ d := + first_mem_doubleUnion ((pair_mem_encode _ _ _ _).mpr ⟨i,rfl,rfl⟩) + let e := cons d (cons c (cons o (cons (a.encode (label c)) (fun _ => c)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hd + rcases i with _|i; exact hc + rcases i with _|i; exact hoM + rcases i with _|i; exact ha + exact hc + let φ := AtomicFormula.support 1 2 3 4 0 + have hφ (z : ZFSet.{u}) : φ.Eval (cons z e) ↔ z ∈ a.support (label c) := + (AtomicFormula.eval_support 1 2 3 4 0 _).trans (support_iff a hdi ho z).symm + have hcode : ZFSet.sep (fun z => φ.Eval (cons z e)) (ZFSet.prod d c) = a.support (label c) := by + apply ZFSet.ext + intro z + rw [ZFSet.mem_sep,hφ] + constructor + · exact And.right + · intro hz + obtain ⟨x,hx,q,hq,hz',_⟩ := (support_iff a hdi ho z).mp hz + exact ⟨ZFSet.mem_prod.mpr ⟨x,hx,q,hq,hz'⟩,hz⟩ + exact hcode ▸ sep_mem M hM hS φ e he (product_mem M hM hP hU hPow hS hd hc) + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/NameUnionCode.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/NameUnionCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef4de7e1c88781815df567c87c852ed7033dc0a0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/NameUnionCode.lean @@ -0,0 +1,142 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelProducts + +namespace OAI + +namespace TuringRigidity.TransitiveNameModel +open Set RecursiveNames BoundedSetTheory +universe u + +def iterUnion : ℕ → ZFSet.{u} → ZFSet.{u} + | 0, a => a + | n+1, a => ZFSet.sUnion (iterUnion n a) + +theorem iterUnion_mem (M : ZFSet.{u}) (hM : Transitive M) + (hU : BoundedSetTheory.Union M) {a : ZFSet.{u}} (ha : a ∈ M) (n : ℕ) : + iterUnion n a ∈ M := by + induction n with + | zero => exact ha + | succ n ih => exact union_mem M hM hU ih + +theorem first_mem_doubleUnion {a b c : ZFSet.{u}} (h : ZFSet.pair a b ∈ c) : + a ∈ iterUnion 2 c := by + apply ZFSet.mem_sUnion.mpr + refine ⟨({a} : ZFSet.{u}),?_,ZFSet.mem_singleton.mpr rfl⟩ + apply ZFSet.mem_sUnion.mpr + exact ⟨ZFSet.pair a b,h,ZFSet.mem_pair.mpr (Or.inl rfl)⟩ + +theorem iterUnion_lift {a b : ZFSet.{u}} (h : a ∈ b) (n : ℕ) : + iterUnion n a ⊆ iterUnion (n+1) b := by + induction n with + | zero => exact fun x hx => ZFSet.mem_sUnion.mpr ⟨a,h,hx⟩ + | succ n ih => + intro x hx + obtain ⟨y,hy,hxy⟩ := ZFSet.mem_sUnion.mp hx + exact ZFSet.mem_sUnion.mpr ⟨y,ih hy,hxy⟩ + +theorem iterUnion_add (m n : ℕ) (a : ZFSet.{u}) : + iterUnion m (iterUnion n a) = iterUnion (m+n) a := by + induction m with + | zero => simp only [iterUnion,Nat.zero_add] + | succ m ih => simp only [iterUnion,ih,Nat.succ_add] + +theorem second_child_bound {a b c d t : ZFSet.{u}} + (hab : ZFSet.pair a b ∈ t) (hcd : ZFSet.pair c d ∈ a) : c ∈ iterUnion 5 t := by + have ha := first_mem_doubleUnion hab + have hc := first_mem_doubleUnion hcd + have ht := iterUnion_lift ha 2 hc + simpa only [iterUnion_add] using ht + +theorem label_surjective (p : ZFSet.{u}) {x : ZFSet.{u}} (hx : x ∈ p) : + ∃ q : Conditions p, label p q = x := by + exact ⟨equivShrink p ⟨x,hx⟩,by simp [label]⟩ + +theorem pair_mem_encode {P : Type u} (l : P → ZFSet.{u}) (τ : Name P) + (x q : ZFSet.{u}) : + ZFSet.pair x q ∈ τ.encode l ↔ + ∃ i, (τ.child i).encode l = x ∧ l (τ.tag i) = q := by + cases τ with + | mk ι child tag => + change ZFSet.pair x q ∈ ZFSet.range _ ↔ _ + rw [ZFSet.mem_range] + simp only [ZFSet.pair_inj,Name.child,Name.tag] + rfl + +def unionPredicate (t p r z : ZFSet.{u}) : Prop := + ∃ d ∈ iterUnion 5 t, ∃ s ∈ p, z = ZFSet.pair d s ∧ + ∃ c ∈ iterUnion 2 t, ∃ q ∈ p, ∃ v ∈ p, + ZFSet.pair c q ∈ t ∧ ZFSet.pair d v ∈ c ∧ + ZFSet.pair s q ∈ r ∧ ZFSet.pair s v ∈ r + +def unionFormula : Formula := + .existsMem 3 (.existsMem 5 + (.conj (.orderedPair 2 1 0) + (.existsMem 4 (.existsMem 7 (.existsMem 8 + (.conj (.pairMem 2 1 6) (.conj (.pairMem 4 0 2) + (.conj (.pairMem 3 1 10) (.pairMem 3 0 10))))))))) + +theorem eval_unionFormula (t p r z : ZFSet.{u}) (env : ℕ → ZFSet.{u}) : + unionFormula.Eval (cons z (cons t (cons (iterUnion 2 t) + (cons (iterUnion 5 t) (cons p (cons r env)))))) ↔ unionPredicate t p r z := by + simp only [unionFormula,Formula.Eval,cons_succ,cons_zero, + Formula.eval_orderedPair,Formula.eval_pairMem,unionPredicate] + +noncomputable def unionCode (t p r : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (unionPredicate t p r) (ZFSet.prod (iterUnion 5 t) p) + +theorem mem_unionCode (t p r z : ZFSet.{u}) : + z ∈ unionCode t p r ↔ unionPredicate t p r z := by + rw [unionCode,ZFSet.mem_sep] + constructor + · exact And.right + · intro h + have hh := h + obtain ⟨d,hd,s,hs,hz,_⟩ := hh + exact ⟨ZFSet.mem_prod.mpr ⟨d,hd,s,hs,hz⟩,h⟩ + +theorem unionCode_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : Separation M) + {t p r : ZFSet.{u}} (ht : t ∈ M) (hp : p ∈ M) (hr : r ∈ M) : + unionCode t p r ∈ M := by + let env := cons t (cons (iterUnion 2 t) (cons (iterUnion 5 t) (cons p (cons r (fun _ => t))))) + have h2 := iterUnion_mem M hM hU ht 2 + have h5 := iterUnion_mem M hM hU ht 5 + have he : ∀ i, env i ∈ M := by + intro i + rcases i with _|_|_|_|_|i <;> assumption + have hs := sep_mem M hM hS unionFormula env he (product_mem M hM hP hU hPow hS h5 hp) + have heq : ZFSet.sep (fun z => unionFormula.Eval (cons z env)) (ZFSet.prod (iterUnion 5 t) p) = + unionCode t p r := by + apply ZFSet.ext + intro z + simp only [unionCode,ZFSet.mem_sep] + exact and_congr Iff.rfl (eval_unionFormula t p r z _) + exact heq ▸ hs + +theorem encode_union (p r : ZFSet.{u}) [Preorder (Conditions p)] + (hr : ∀ q s : Conditions p, ZFSet.pair (label p q) (label p s) ∈ r ↔ q ≤ s) + (τ : Name (Conditions p)) : + (Name.union τ).encode (label p) = unionCode (τ.encode (label p)) p r := by + apply ZFSet.ext + intro z + rw [mem_unionCode] + change z ∈ ZFSet.range _ ↔ _ + rw [ZFSet.mem_range] + constructor + · rintro ⟨⟨i,j,s,hsq,hsv⟩,hz⟩ + have hi : ZFSet.pair ((τ.child i).encode (label p)) (label p (τ.tag i)) ∈ τ.encode (label p) := + (pair_mem_encode _ _ _ _).mpr ⟨i,rfl,rfl⟩ + have hj : ZFSet.pair (((τ.child i).child j).encode (label p)) (label p ((τ.child i).tag j)) ∈ + (τ.child i).encode (label p) := (pair_mem_encode _ _ _ _).mpr ⟨j,rfl,rfl⟩ + exact ⟨_,second_child_bound hi hj,_,label_mem p s,hz.symm, + _,first_mem_doubleUnion hi,_,label_mem p _,_,label_mem p _,hi,hj, + (hr _ _).mpr hsq,(hr _ _).mpr hsv⟩ + · rintro ⟨d,_,s,hs,rfl,c,_,q,_,v,_,hc,hd,hq,hv⟩ + obtain ⟨i,rfl,rfl⟩ := (pair_mem_encode _ _ _ _).mp hc + obtain ⟨j,rfl,rfl⟩ := (pair_mem_encode _ _ _ _).mp hd + obtain ⟨s,rfl⟩ := label_surjective p hs + exact ⟨⟨i,j,s,(hr _ _).mp hq,(hr _ _).mp hv⟩,rfl⟩ + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/NameValidity.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/NameValidity.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7aee394eda45f8a3c6e2ad1615d1d53f155e831 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/NameValidity.lean @@ -0,0 +1,110 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalFixedPoint +import OAI.Computability.DegreeRigidity.SetModels.NameUnionCode + +namespace OAI + + +namespace TuringRigidity.NameValidity +open RecursiveNames TransitiveNameModel BoundedSetTheory +universe u + +def Step (c h x : ZFSet.{u}) : Prop := + ∀ z ∈ x, ∃ y ∈ h, ∃ q ∈ c, z = ZFSet.pair y q + +def Certificate (d c h : ZFSet.{u}) : Prop := + h ⊆ d ∧ ∀ x ∈ d, x ∈ h ↔ Step c h x + +def Child (y x : ZFSet.{u}) : Prop := ∃ q, ZFSet.pair y q ∈ x + +theorem child_wellFounded : WellFounded (Child : ZFSet.{u} → ZFSet.{u} → Prop) := by + apply ZFSet.mem_wf.transGen.mono + intro y x h + obtain ⟨q,hq⟩ := h + exact Relation.TransGen.tail + (Relation.TransGen.tail (Relation.TransGen.single (ZFSet.mem_singleton.mpr rfl)) + (show ({y} : ZFSet.{u}) ∈ ZFSet.pair y q from ZFSet.mem_pair.mpr (Or.inl rfl))) hq + +theorem Certificate.decode {d c h : ZFSet.{u}} (hh : Certificate d c h) + (x : ZFSet.{u}) (hx : x ∈ h) : + ∃ a : Name (Conditions c), a.encode (label c) = x := by + classical + induction x using child_wellFounded.induction with + | h x ih => + have step := (hh.2 x (hh.1 hx)).mp hx + have entry (i : Conditions x) : ∃ a : Name (Conditions c), ∃ q : Conditions c, + label x i = ZFSet.pair (a.encode (label c)) (label c q) := by + obtain ⟨y,hy,q,hq,heq⟩ := step _ (label_mem x i) + obtain ⟨a,rfl⟩ := ih y ⟨q,heq ▸ label_mem x i⟩ hy + obtain ⟨r,rfl⟩ := label_surjective c hq + exact ⟨a,r,heq⟩ + let a : Conditions x → Name (Conditions c) := fun i => (entry i).choose + let q : Conditions x → Conditions c := fun i => (entry i).choose_spec.choose + have heq (i : Conditions x) : label x i = ZFSet.pair ((a i).encode (label c)) (label c (q i)) := + (entry i).choose_spec.choose_spec + refine ⟨.mk (Conditions x) a q,?_⟩ + apply ZFSet.ext + intro z + change z ∈ ZFSet.range _ ↔ z ∈ x + rw [ZFSet.mem_range] + constructor + · rintro ⟨i,rfl⟩ + rw [←heq i] + exact label_mem x i + · intro hz + obtain ⟨i,rfl⟩ := label_surjective x hz + exact ⟨i,(heq i).symm⟩ + +theorem Certificate.encode_mem {d c h : ZFSet.{u}} (hd : Transitive d) + (hh : Certificate d c h) (a : Name (Conditions c)) + (ha : a.encode (label c) ∈ d) : a.encode (label c) ∈ h := by + induction a with + | mk ι a q ih => + apply (hh.2 _ ha).mpr + intro z hz + obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hz + have hai : (a i).encode (label c) ∈ d := + names_childClosed d c hd (.mk ι a q) ha (a i) ⟨i,rfl⟩ + exact ⟨_,ih i hai,_,label_mem c (q i),rfl⟩ + +theorem Certificate.correct {d c h : ZFSet.{u}} (hd : Transitive d) + (hh : Certificate d c h) {x : ZFSet.{u}} (hx : x ∈ d) : + x ∈ h ↔ ∃ a : Name (Conditions c), a.encode (label c) = x := by + constructor + · exact hh.decode x + · rintro ⟨a,rfl⟩ + exact hh.encode_mem hd a hx + +namespace Code +open Formula +def step (c h x : ℕ) : Formula := + allMem x (.existsMem (h+1) (.existsMem (c+2) (orderedPair 2 1 0))) + +theorem eval_step (c h x : ℕ) (e : ℕ → ZFSet.{u}) : + (step c h x).Eval e ↔ Step (e c) (e h) (e x) := by + simp only [step,Step,eval_allMem,Formula.Eval,eval_orderedPair,cons_zero,cons_succ] + +def certificate (d c h : ℕ) : Formula := + .conj (subset h d) (allMem d (iff (.member 0 (h+1)) (step (c+1) (h+1) 0))) + +theorem eval_certificate (d c h : ℕ) (e : ℕ → ZFSet.{u}) : + (certificate d c h).Eval e ↔ Certificate (e d) (e c) (e h) := by + simp only [certificate,Certificate,Formula.Eval,eval_subset,eval_allMem,eval_iff, + eval_step,cons_zero,cons_succ] +end Code + +theorem internal_certificate (M : ZFSet.{u}) (hM : Transitive M) + (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + {d c : ZFSet.{u}} (hd : d ∈ M) (hc : c ∈ M) : + ∃ h ∈ M, Certificate d c h := by + obtain ⟨h,hh,hs,hdef⟩ := internal_fixed_point M hM hU hPow hS + (Code.step 2 1 0) (fun _ => c) (fun _ => hc) d hd (by + intro f g _ _ hfg x _ hf + rw [Code.eval_step] at hf ⊢ + intro z hz + obtain ⟨y,hy,q,hq,heq⟩ := hf z hz + exact ⟨y,hfg hy,q,hq,heq⟩) + exact ⟨h,hh,hs,fun x hx => (hdef x hx).trans (Code.eval_step 2 1 0 _)⟩ + +end TuringRigidity.NameValidity + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/NameValueCover.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/NameValueCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..54a3dfd386f6dfc579697546312649fe4d9de3b0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/NameValueCover.lean @@ -0,0 +1,78 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaSeparationName + +namespace OAI + + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} + +noncomputable def coverChild (W : ZFSet.{u}) + (hW : ∀ x ∈ W, ∃ a : Name (Conditions c), a.encode (label c) = x) + (i : Conditions W) : Name (Conditions c) := (hW _ (label_mem W i)).choose + +theorem coverChild_code (W : ZFSet.{u}) + (hW : ∀ x ∈ W, ∃ a : Name (Conditions c), a.encode (label c) = x) (i : Conditions W) : + (coverChild W hW i).encode (label c) = label W i := (hW _ (label_mem W i)).choose_spec + +noncomputable def coverName (W : ZFSet.{u}) + (hW : ∀ x ∈ W, ∃ a : Name (Conditions c), a.encode (label c) = x) + (p : Conditions c) : Name (Conditions c) := .mk (Conditions W) (coverChild W hW) (fun _ => p) + +theorem encode_coverName (W : ZFSet.{u}) + (hW : ∀ x ∈ W, ∃ a : Name (Conditions c), a.encode (label c) = x) (p : Conditions c) : + (coverName W hW p).encode (label c) = ZFSet.prod W ({label c p} : ZFSet.{u}) := by + apply ZFSet.ext; intro z + change z ∈ ZFSet.range _ ↔ _ + rw [ZFSet.mem_range] + constructor + · rintro ⟨i,rfl⟩ + rw [coverChild_code] + exact ZFSet.mem_prod.mpr ⟨_,label_mem W i,_,ZFSet.mem_singleton.mpr rfl,rfl⟩ + · intro hz + obtain ⟨x,hx,y,hy,rfl⟩ := ZFSet.mem_prod.mp hz + obtain rfl := ZFSet.mem_singleton.mp hy + obtain ⟨i,rfl⟩ := label_surjective W hx + exact ⟨i,by rw [coverChild_code]⟩ + +theorem val_mem_coverName (W : ZFSet.{u}) + (hW : ∀ x ∈ W, ∃ a : Name (Conditions c), a.encode (label c) = x) + (G : Set (Conditions c)) (p : Conditions c) (hp : p ∈ G) + (b : Name (Conditions c)) (hb : b.encode (label c) ∈ W) : + b.val G ∈ (coverName W hW p).val G := by + obtain ⟨i,hi⟩ := label_surjective W hb + rw [coverName,Name.mem_val] + refine ⟨i,hp,?_⟩ + exact Name.val_eq_of_encode_eq (label c) (label_injective c) G _ b ((coverChild_code W hW i).trans hi) + +variable [Preorder (Conditions c)] + +theorem internal_name_value_cover (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {W : ZFSet.{u}} (hW : W ∈ M) (G : GenericFilter (Conditions c)) : + ∃ N : Name (Conditions c), N.encode (label c) ∈ M ∧ + ∀ b : Name (Conditions c), b.encode (label c) ∈ W → b.val G.carrier ∈ N.val G.carrier := by + let V := ZFSet.sep (fun x => (NameValidity.Code.valid 1 0).Realize M (cons x (fun _ => c))) W + have hV : V ∈ M := sigma_sep_mem M hM hS (NameValidity.Code.valid 1 0) (fun _ => c) (fun _ => hc) hW + have valid (x : ZFSet.{u}) (hx : x ∈ M) : + (NameValidity.Code.valid 1 0).Realize M (cons x (fun _ => c)) ↔ + ∃ a : Name (Conditions c), a.encode (label c) = x := + NameValidity.realize_valid M hM hP hU hPow hS.bounded hR hI _ + (by intro i; cases i <;> assumption) 1 0 + have hvalid (x : ZFSet.{u}) (hx : x ∈ V) : ∃ a : Name (Conditions c), a.encode (label c) = x := + (valid x (hM V hV x hx)).mp (ZFSet.mem_sep.mp hx).2 + obtain ⟨p,hp⟩ := G.nonempty + have hN : (coverName V hvalid p).encode (label c) ∈ M := by + rw [encode_coverName] + exact product_mem M hM hP hU hPow hS.bounded hV + (singleton_mem M hM hP (hM c hc _ (label_mem c p))) + refine ⟨coverName V hvalid p,hN,?_⟩ + intro b hb + apply val_mem_coverName V hvalid G.carrier p hp b + exact ZFSet.mem_sep.mpr ⟨hb,(valid _ (hM W hW _ hb)).mpr ⟨b,rfl⟩⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/NoNewOrdinals.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/NoNewOrdinals.lean new file mode 100644 index 0000000000000000000000000000000000000000..91a7e16bc1ebe68644ece9a280f3aab88b77a263 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/NoNewOrdinals.lean @@ -0,0 +1,45 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTheory +import OAI.Computability.DegreeRigidity.SetModels.NameEncoding +import OAI.Computability.DegreeRigidity.Syntax.FiniteTerm +import OAI.Computability.DegreeRigidity.OrdinalCodes.RankOrdinal +import OAI.Computability.DegreeRigidity.SetModels.NameExtension + +namespace OAI + +namespace TuringRigidity.TransitiveNameModel +open RecursiveNames BoundedSetTheory InternalRank +universe u + +theorem name_value_rank_le {P : Type u} (l : P → ZFSet.{u}) (G : Set P) (a : Name P) : + (a.val G).rank ≤ (a.encode l).rank := by + induction a with + | mk ι child tag ih => + apply ZFSet.rank_le_iff.mpr + intro x hx + obtain ⟨i,_,rfl⟩ := (Name.mem_val G ι child tag x).mp hx + have hp : ZFSet.pair ((child i).encode l) (l (tag i)) ∈ + (Name.mk ι child tag).encode l := ZFSet.mem_range_self i + exact (ih i).trans_lt ((FiniteTerm.pair_rank_left _ _).trans (ZFSet.rank_lt_of_mem hp)) + +theorem ordinal_name_value_ground (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {P : Type u} (l : P → ZFSet.{u}) (G : Set P) (a : Name P) + (ha : a.encode l ∈ M) (δ : Ordinal.{u}) (hv : a.val G = δ.toZFSet) : + δ.toZFSet ∈ M := by + have hr := rankSet_mem_ground M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity ha + rw [rankSet_eq_ordinal] at hr + have hle := name_value_rank_le l G a + rw [hv,Ordinal.rank_toZFSet] at hle + rcases lt_or_eq_of_le hle with hlt|heq + · exact hM _ hr _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hlt) + · exact heq ▸ hr + +theorem extension_ordinal_ground (M c : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (G : Set (Conditions c)) (δ : Ordinal.{u}) + (hδ : δ.toZFSet ∈ genericExtensionSet M c G) : δ.toZFSet ∈ M := by + obtain ⟨a,ha,hv⟩ := (mem_extensionSet M c G _).mp hδ + exact ordinal_name_value_ground M hM hT (label c) G a ha δ hv + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/OrderedNameCode.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/OrderedNameCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a6f8c14a75f98367f176c1cc6085a70b7cbd8e2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/OrderedNameCode.lean @@ -0,0 +1,93 @@ +import OAI.Computability.DegreeRigidity.Representation.GroundInclusion +import OAI.Computability.DegreeRigidity.Syntax.SigmaSyntax + +namespace OAI + + +namespace TuringRigidity.TransitiveNameModel +open RecursiveNames BoundedSetTheory +universe u + +noncomputable def pairNameCode (t x y : ZFSet.{u}) : ZFSet.{u} := + {ZFSet.pair x t, ZFSet.pair y t} + +noncomputable def orderedNameCode (t x y : ZFSet.{u}) : ZFSet.{u} := + pairNameCode t (pairNameCode t x x) (pairNameCode t x y) + +theorem pairNameCode_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + {t x y : ZFSet.{u}} (ht : t ∈ M) (hx : x ∈ M) (hy : y ∈ M) : pairNameCode t x y ∈ M := + pair_mem M hM hP (orderedPair_mem M hM hP hx ht) (orderedPair_mem M hM hP hy ht) + +theorem orderedNameCode_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + {t x y : ZFSet.{u}} (ht : t ∈ M) (hx : x ∈ M) (hy : y ∈ M) : orderedNameCode t x y ∈ M := + pairNameCode_mem M hM hP ht (pairNameCode_mem M hM hP ht hx hx) + (pairNameCode_mem M hM hP ht hx hy) + +namespace NameCodeFormula +open Formula + +def pairName (t x y z : ℕ) : Formula := + .conj (allMem z (disj (orderedPair 0 (x+1) (t+1)) (orderedPair 0 (y+1) (t+1)))) + (.conj (.existsMem z (orderedPair 0 (x+1) (t+1))) + (.existsMem z (orderedPair 0 (y+1) (t+1)))) + +theorem eval_pairName (t x y z : ℕ) (e : ℕ → ZFSet.{u}) : + (pairName t x y z).Eval e ↔ e z = pairNameCode (e t) (e x) (e y) := by + simp only [pairName,Formula.Eval,eval_allMem,eval_disj,eval_orderedPair,cons_zero,cons_succ] + constructor + · rintro ⟨h,hx,hy⟩ + apply ZFSet.ext; intro w + rw [pairNameCode,ZFSet.mem_pair] + constructor + · exact h w + · rintro (rfl|rfl) + · obtain ⟨v,hv,rfl⟩ := hx; exact hv + · obtain ⟨v,hv,rfl⟩ := hy; exact hv + · intro he + rw [he] + exact ⟨fun w hw => ZFSet.mem_pair.mp hw, + ⟨_,ZFSet.mem_pair.mpr (Or.inl rfl),rfl⟩, + ⟨_,ZFSet.mem_pair.mpr (Or.inr rfl),rfl⟩⟩ + +def orderedName (t x y z : ℕ) : SigmaFormula := .existsSet (.existsSet (.bounded + (.conj (pairName (t+2) (x+2) (x+2) 1) + (.conj (pairName (t+2) (x+2) (y+2) 0) (pairName (t+2) 1 0 (z+2)))))) + +theorem realize_orderedName (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + (t x y z : ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (orderedName t x y z).Realize M e ↔ e z = orderedNameCode (e t) (e x) (e y) := by + have matrix (a b : ZFSet.{u}) (ha : a ∈ M) (hb : b ∈ M) : + (Formula.conj (pairName (t+2) (x+2) (x+2) 1) + (.conj (pairName (t+2) (x+2) (y+2) 0) (pairName (t+2) 1 0 (z+2)))).Realize M + (cons b (cons a e)) ↔ a = pairNameCode (e t) (e x) (e x) ∧ + b = pairNameCode (e t) (e x) (e y) ∧ e z = pairNameCode (e t) a b := by + rw [Formula.absolute _ M hM _ (by + intro i; rcases i with _|i; exact hb + rcases i with _|i; exact ha + exact he i)] + simp only [Formula.Eval,eval_pairName,cons_zero,cons_succ] + change (∃ a ∈ M, ∃ b ∈ M, _) ↔ _ + constructor + · rintro ⟨a,ha,b,hb,h⟩ + obtain ⟨rfl,rfl,h⟩ := (matrix a b ha hb).mp h + exact h + · intro h + have ha := pairNameCode_mem M hM hP (he t) (he x) (he x) + have hb := pairNameCode_mem M hM hP (he t) (he x) (he y) + exact ⟨_,ha,_,hb,(matrix _ _ ha hb).mpr ⟨rfl,rfl,h⟩⟩ +end NameCodeFormula + +noncomputable def orderedPairName {P : Type u} [Top P] (a b : Name P) : Name P := + Name.pair (Name.pair a a) (Name.pair a b) + +theorem encode_orderedPairName {P : Type u} [Top P] (l : P → ZFSet.{u}) (a b : Name P) : + (orderedPairName a b).encode l = orderedNameCode (l ⊤) (a.encode l) (b.encode l) := by + simp only [orderedPairName,encode_pair,orderedNameCode,pairNameCode] + +theorem val_orderedPairName {P : Type u} [Top P] (G : Set P) (htop : ⊤ ∈ G) (a b : Name P) : + (orderedPairName a b).val G = ZFSet.pair (a.val G) (b.val G) := by + simp [orderedPairName,Name.val_pair G htop,ZFSet.pair] + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ParametricEval.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ParametricEval.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d56bb2e259b23d7369470ee4ca198b61f8726a6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ParametricEval.lean @@ -0,0 +1,38 @@ +import OAI.Computability.DegreeRigidity.Computability.OracleCode +import Mathlib.Computability.PartrecCode + +namespace OAI + +namespace TuringRigidity.OracleCode +open Computable + +theorem eval_partrec {α : Type*} [Primcodable α] {g : α → ℕ →. ℕ} + (hg : Partrec₂ g) (c : OracleCode) : Partrec₂ (fun a n => eval (g a) c n) := by + induction c with + | zero => exact Computable.const 0 + | succ => exact Computable.succ.comp snd + | left => exact (fst.comp Computable.unpair).comp snd + | right => exact (snd.comp Computable.unpair).comp snd + | query => exact hg + | pair c d hc hd => + change Partrec (fun z : α × ℕ => + (eval (g z.1) c z.2).bind (fun a => (eval (g z.1) d z.2).map (Nat.pair a))) + apply Partrec.bind hc + apply Partrec.map (hd.comp (fst.comp fst) (snd.comp fst)) + exact Primrec₂.natPair.to_comp.comp (snd.comp fst) snd + | comp c d hc hd => + exact hd.bind (hc.comp (fst.comp fst) snd) + | prec c d hc hd => + exact Partrec.nat_rec ((snd.comp Computable.unpair).comp snd) + (hc.comp fst ((fst.comp Computable.unpair).comp snd)) + (hd.comp (fst.comp fst) + (Primrec₂.natPair.to_comp.comp ((fst.comp Computable.unpair).comp (snd.comp fst)) + (Primrec₂.natPair.to_comp.comp (fst.comp snd) (snd.comp snd)))).to₂ + | find c hc => + exact Partrec.rfind ((hc.comp (fst.comp fst) + (Primrec₂.natPair.to_comp.comp (snd.comp fst) snd)).map + ((Primrec.beq.comp Primrec.snd (Primrec.const 0)).to_comp)) + +end TuringRigidity.OracleCode + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/PresentationEnumeration.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/PresentationEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8913cebd5df6002c1d4a7635da380d29dc7cd8b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/PresentationEnumeration.lean @@ -0,0 +1,99 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelPresentationSets + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel EncodedForcing +universe u + +noncomputable def presentationEnumeration (R : ZFSet.{u}) (H : Oracle) : ZFSet.{u} := + ZFSet.range (fun n : ℕ => ZFSet.pair (natSet n) (degreeCode R (columns H n))) + +theorem mem_presentationEnumeration (R : ZFSet.{u}) (H : Oracle) (z : ZFSet.{u}) : + z ∈ presentationEnumeration R H ↔ ∃ n, z = ZFSet.pair (natSet n) (degreeCode R (columns H n)) := by + rw [presentationEnumeration,ZFSet.mem_range] + exact ⟨fun ⟨n,hn⟩ => ⟨n,hn.symm⟩,fun ⟨n,hn⟩ => ⟨n,hn.symm⟩⟩ + +theorem presentationEnumeration_pair (R : ZFSet.{u}) (H : Oracle) (n : ℕ) (D : ZFSet.{u}) : + ZFSet.pair (natSet n) D ∈ presentationEnumeration R H ↔ D = degreeCode R (columns H n) := by + rw [mem_presentationEnumeration] + constructor + · rintro ⟨i,hi⟩ + obtain ⟨hn,hd⟩ := ZFSet.pair_inj.mp hi + have he := natSet_injective hn + subst i; exact hd + · intro h; exact ⟨n,congrArg (ZFSet.pair (natSet n)) h⟩ + +theorem presentationEnumeration_function (R : ZFSet.{u}) (H : Oracle) : + TransitiveNameModel.FunctionGraph ZFSet.omega (presentationSet R H) (presentationEnumeration R H) := by + constructor + · intro z hz + obtain ⟨n,rfl⟩ := (mem_presentationEnumeration R H z).mp hz + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,_,(mem_presentationSet R H _).mpr ⟨n,rfl⟩,rfl⟩ + · intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + exact ⟨_,(mem_presentationSet R H _).mpr ⟨n,rfl⟩, + (presentationEnumeration_pair R H n _).mpr rfl, + fun y _ hy => (presentationEnumeration_pair R H n y).mp hy⟩ + +theorem presentationEnumeration_onto (R : ZFSet.{u}) (H : Oracle) : + ∀ D ∈ presentationSet R H, ∃ x ∈ ZFSet.omega, ZFSet.pair x D ∈ presentationEnumeration R H := by + intro D hD + obtain ⟨n,rfl⟩ := (mem_presentationSet R H D).mp hD + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,(presentationEnumeration_pair R H n _).mpr rfl⟩ + +namespace Formula +def presentationValue (φ : Formula) (o Q z R H n D : ℕ) : Formula := + .existsMem R (.conj (columnSet (o+1) (Q+1) (n+1) (H+1) 0) + (degreeSet φ (o+1) (Q+1) (z+1) (R+1) 0 (D+1))) + +theorem presentationValue_spec {φ : Formula} (hφ : DegreeEqualityFormula.{u} φ) + (o Q z R H n D : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) (hz : e z = natSet 0) + (hR : ∀ w ∈ e R, ∃ B : Oracle, realCode B = w) + (A : Oracle) (hA : e H = realCode A) (N : ℕ) (hn : e n = natSet N) + (hc : realCode (columns A N) ∈ e R) : + (presentationValue φ o Q z R H n D).Eval e ↔ e D = degreeCode (e R) (columns A N) := by + simp only [presentationValue,Formula.Eval] + constructor + · rintro ⟨B,_,hb,hd⟩ + have heB := (columnSet_spec (o+1) (Q+1) (n+1) (H+1) 0 (cons B e) ho hQ A hA N hn).mp hb + exact (degreeSet_spec hφ (o+1) (Q+1) (z+1) (R+1) 0 (D+1) (cons B e) + ho hQ hz hR (columns A N) heB).mp hd + · intro hd + refine ⟨realCode (columns A N),hc,?_,?_⟩ + · exact (columnSet_spec (o+1) (Q+1) (n+1) (H+1) 0 (cons (realCode (columns A N)) e) + ho hQ A hA N hn).mpr rfl + · exact (degreeSet_spec hφ (o+1) (Q+1) (z+1) (R+1) 0 (D+1) + (cons (realCode (columns A N)) e) ho hQ hz hR (columns A N) rfl).mpr hd + +def enumerationMember (φ : Formula) (o Q z R H I Z : ℕ) : Formula := + .existsMem o (.existsMem (I+1) (.conj (.orderedPair (Z+2) 1 0) + (presentationValue φ (o+2) (Q+2) (z+2) (R+2) (H+2) 1 0))) + +theorem enumerationMember_spec {φ : Formula} (hφ : DegreeEqualityFormula.{u} φ) + (o Q z R H I Z : ℕ) (e : ℕ → ZFSet.{u}) (ho : e o = ZFSet.omega) + (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ e Q) (hz : e z = natSet 0) + (hR : ∀ w ∈ e R, ∃ B : Oracle, realCode B = w) + (A : Oracle) (hA : e H = realCode A) (hc : ∀ n, realCode (columns A n) ∈ e R) + (hI : e I = presentationSet (e R) A) : + (enumerationMember φ o Q z R H I Z).Eval e ↔ e Z ∈ presentationEnumeration (e R) A := by + simp only [enumerationMember,Formula.Eval,eval_orderedPair,cons_zero,cons_succ] + rw [ho,mem_presentationEnumeration] + constructor + · rintro ⟨n,hn,D,_,hp,hv⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + have hd := (presentationValue_spec hφ (o+2) (Q+2) (z+2) (R+2) (H+2) 1 0 + (cons D (cons (natSet n) e)) ho hQ hz hR A hA n rfl (hc n)).mp hv + exact ⟨n,hd ▸ hp⟩ + · rintro ⟨n,hp⟩ + refine ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,degreeCode (e R) (columns A n),?_,hp,?_⟩ + · rw [hI]; exact (mem_presentationSet _ _ _).mpr ⟨n,rfl⟩ + · exact (presentationValue_spec hφ (o+2) (Q+2) (z+2) (R+2) (H+2) 1 0 + (cons (degreeCode (e R) (columns A n)) (cons (natSet n) e)) ho hQ hz hR A hA n rfl (hc n)).mpr rfl +end Formula + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/PresentationGraphSet.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/PresentationGraphSet.lean new file mode 100644 index 0000000000000000000000000000000000000000..6571121760073da5793d58a628c3f39617d0f5b0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/PresentationGraphSet.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalPresentationEnumeration + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel EncodedForcing +universe u + +noncomputable def presentationGraph (R : ZFSet.{u}) (H S : Oracle) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ i j, z = ZFSet.pair (degreeCode R (columns H i)) (degreeCode R (columns H j)) ∧ + S (Nat.pair i j) = true) (ZFSet.prod (presentationSet R H) (presentationSet R H)) + +theorem mem_presentationGraph (R : ZFSet.{u}) (H S : Oracle) (z : ZFSet.{u}) : + z ∈ presentationGraph R H S ↔ ∃ i j, + z = ZFSet.pair (degreeCode R (columns H i)) (degreeCode R (columns H j)) ∧ S (Nat.pair i j) = true := by + rw [presentationGraph,ZFSet.mem_sep] + refine ⟨And.right,?_⟩ + rintro ⟨i,j,rfl,hs⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨_,(mem_presentationSet R H _).mpr ⟨i,rfl⟩, + _,(mem_presentationSet R H _).mpr ⟨j,rfl⟩,rfl⟩,i,j,rfl,hs⟩ + +namespace Formula +def presentationGraphMember : Formula := + .existsMem 1 (.existsMem 2 (.existsMem 6 (.existsMem 7 + (.conj (.orderedPair 4 3 2) (.conj (.pairMem 1 3 6) + (.conj (.pairMem 0 2 6) (columnBit 8 9 1 7 0))))))) + +theorem presentationGraphMember_spec (R Q : ZFSet.{u}) + (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ Q) + (H S : Oracle) (z : ZFSet.{u}) : + presentationGraphMember.Eval (cons z (cons (presentationSet R H) (cons (presentationEnumeration R H) + (cons (realCode S) (cons ZFSet.omega (fun _ => Q)))))) ↔ z ∈ presentationGraph R H S := by + let e := cons z (cons (presentationSet R H) (cons (presentationEnumeration R H) + (cons (realCode S) (cons ZFSet.omega (fun _ => Q))))) + have hb (D F : ZFSet.{u}) (i j : ℕ) := columnBit_spec 8 9 1 7 0 + (cons (natSet j) (cons (natSet i) (cons F (cons D e)))) rfl hQ S rfl i j rfl rfl + simp only [presentationGraphMember,Formula.Eval,eval_orderedPair,eval_pairMem,cons_zero,cons_succ] + rw [mem_presentationGraph] + constructor + · rintro ⟨D,_,F,_,i,hi,j,hj,hz,hiD,hjF,hs⟩ + obtain ⟨i,rfl⟩ := (mem_omega i).mp hi + obtain ⟨j,rfl⟩ := (mem_omega j).mp hj + have hd := (presentationEnumeration_pair R H i D).mp hiD + have hf := (presentationEnumeration_pair R H j F).mp hjF + exact ⟨i,j,by simpa only [hd,hf] using hz,(hb D F i j).mp hs⟩ + · rintro ⟨i,j,hz,hs⟩ + refine ⟨_,(mem_presentationSet R H _).mpr ⟨i,rfl⟩, + _,(mem_presentationSet R H _).mpr ⟨j,rfl⟩, + natSet i,(mem_omega _).mpr ⟨i,rfl⟩,natSet j,(mem_omega _).mpr ⟨j,rfl⟩,hz, + (presentationEnumeration_pair R H i _).mpr rfl,(presentationEnumeration_pair R H j _).mpr rfl,?_⟩ + exact (hb _ _ i j).mpr hs +end Formula + +theorem internal_presentationGraph (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (R : ZFSet.{u}) (hRM : R ∈ M) + (hR : ∀ A : Oracle, realCode A ∈ R ↔ A ∈ modelReals M) + (hRd : ∀ w ∈ R, ∃ B : Oracle, realCode B = w) + {H S : Oracle} (hH : H ∈ modelReals M) (hSM : S ∈ modelReals M) : presentationGraph R H S ∈ M := by + have hSep := hT.separation.finitePrefix.bounded + have hω := sourceT_omega_mem M hM hT + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hSep hω + have hIM := internal_presentationSet M hM hT R hRM hR hRd hH + have hEM := internal_presentationEnumeration M hM hT R hRM hR hRd hH + let e := cons (presentationSet R H) (cons (presentationEnumeration R H) + (cons (realCode S) (cons ZFSet.omega (fun _ => Q)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hIM + rcases i with _|i; exact hEM + rcases i with _|i; exact hSM + rcases i with _|i; exact hω + exact hQM + let B := ZFSet.sep (fun z => Formula.presentationGraphMember.Eval (cons z e)) + (ZFSet.prod (presentationSet R H) (presentationSet R H)) + have hBM : B ∈ M := sep_mem M hM hSep _ e he + (product_mem M hM hT.pairing hT.union hT.powerSet hSep hIM hIM) + have hB : B = presentationGraph R H S := by + apply ZFSet.ext; intro z + rw [ZFSet.mem_sep,Formula.presentationGraphMember_spec R Q hQ H S z] + exact ⟨And.right,fun h => ⟨(ZFSet.mem_sep.mp h).1,h⟩⟩ + rw [←hB] + exact hBM + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/PresentedDegreeEmbedding.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/PresentedDegreeEmbedding.lean new file mode 100644 index 0000000000000000000000000000000000000000..684bd773cec9ad3a3474c0fda50301cc68add5a5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/PresentedDegreeEmbedding.lean @@ -0,0 +1,69 @@ +import OAI.Computability.DegreeRigidity.SetModels.PresentationGraphSet +import OAI.Computability.DegreeRigidity.Constructibility.PersistentPresentation + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open EncodedForcing PersistentRestrictions PersistentPresentation +universe u + +noncomputable def presentedDegreeCode (R : ZFSet.{u}) {I : CountableIdeal} {H : Oracle} + (hH : Presented I H) (x : I) : ZFSet.{u} := + degreeCode R (columns H (Classical.choose ((hH x.val).mp x.property))) + +theorem presentedDegreeCode_entry (R : ZFSet.{u}) {I : CountableIdeal} {H : Oracle} + (hH : Presented I H) (hc : ∀ n, realCode (columns H n) ∈ R) (n : ℕ) : + presentedDegreeCode R hH (entry hH n) = degreeCode R (columns H n) := by + apply (degreeCode_equal R (hc _)).mpr + exact Classical.choose_spec ((hH (entry hH n).val).mp (entry hH n).property) + +theorem presentedDegreeCode_injective (R : ZFSet.{u}) {I : CountableIdeal} {H : Oracle} + (hH : Presented I H) (hc : ∀ n, realCode (columns H n) ∈ R) : + Function.Injective (presentedDegreeCode R hH) := by + intro x y hxy + apply Subtype.ext + have h := (degreeCode_equal R (hc (Classical.choose ((hH x.val).mp x.property)))).mp hxy + exact (Classical.choose_spec ((hH x.val).mp x.property)).symm.trans + (h.trans (Classical.choose_spec ((hH y.val).mp y.property))) + +theorem presentedDegreeCode_mem (R : ZFSet.{u}) {I : CountableIdeal} {H : Oracle} + (hH : Presented I H) (x : I) : presentedDegreeCode R hH x ∈ presentationSet R H := + (mem_presentationSet R H _).mpr ⟨_,rfl⟩ + +theorem presentedDegreeCode_onto (R : ZFSet.{u}) {I : CountableIdeal} {H : Oracle} + (hH : Presented I H) (hc : ∀ n, realCode (columns H n) ∈ R) : + ∀ D ∈ presentationSet R H, ∃ x : I, presentedDegreeCode R hH x = D := by + intro D hD + obtain ⟨n,rfl⟩ := (mem_presentationSet R H D).mp hD + exact ⟨entry hH n,presentedDegreeCode_entry R hH hc n⟩ + +theorem presentationGraph_actual (R : ZFSet.{u}) {I : CountableIdeal} {H S : Oracle} + (hH : Presented I H) (hc : ∀ n, realCode (columns H n) ∈ R) + (ρ : I ≃o I) (hS : ∀ v, S v = true ↔ Graph ρ hH v) (x y : I) : + ZFSet.pair (presentedDegreeCode R hH x) (presentedDegreeCode R hH y) ∈ presentationGraph R H S ↔ ρ x = y := by + rw [mem_presentationGraph] + constructor + · rintro ⟨i,j,hp,hs⟩ + obtain ⟨hx,hy⟩ := ZFSet.pair_inj.mp hp + have hxi : x = entry hH i := presentedDegreeCode_injective R hH hc + (hx.trans (presentedDegreeCode_entry R hH hc i).symm) + have hyj : y = entry hH j := presentedDegreeCode_injective R hH hc + (hy.trans (presentedDegreeCode_entry R hH hc j).symm) + rw [hxi,hyj] + apply Subtype.ext + simpa only [PersistentPresentation.Graph,entry,Nat.unpair_pair] using (hS (Nat.pair i j)).mp hs + · intro hxy + obtain ⟨i,hi⟩ := (hH x.val).mp x.property + obtain ⟨j,hj⟩ := (hH y.val).mp y.property + have hxi : entry hH i = x := Subtype.ext hi + have hyj : entry hH j = y := Subtype.ext hj + refine ⟨i,j,?_,(hS (Nat.pair i j)).mpr ?_⟩ + · rw [←hxi,←hyj,presentedDegreeCode_entry R hH hc i,presentedDegreeCode_entry R hH hc j] + · change (ρ (entry hH (Nat.unpair (Nat.pair i j)).1)).val = degree (columns H (Nat.unpair (Nat.pair i j)).2) + simp only [Nat.unpair_pair] + rw [hxi,hxy,hj] + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ProjectedArithmeticOutputCone.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ProjectedArithmeticOutputCone.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2ed9160c4f7f97a36c26c5902afe206fcdd67e9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ProjectedArithmeticOutputCone.lean @@ -0,0 +1,105 @@ +import OAI.Computability.DegreeRigidity.SetModels.ProjectedArithmeticOutputName +import OAI.Computability.DegreeRigidity.SetModels.FixedArithmeticTailCone +import OAI.Computability.DegreeRigidity.Representation.OwnDegreeExtensionMeaning +import OAI.Computability.DegreeRigidity.SetModels.InternalColumnExtension +import OAI.Computability.DegreeRigidity.Representation.CommonGenericModels + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open RelativeConstructible CohenGroundPoset InternalCohenRestriction InternalCohenProjectedGeneric +open InternalCohenProjectionSymmetry InternalCohenFactor OracleJump TableIndices IndexMatrix +open PersistentRestrictions SetDegreeDecoding ElementaryModel FullSetForcing +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem projected_arithmetic_output_cone (M C B : ZFSet.{0}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) (hC : C ∈ M) (hB : B ∈ M) (hBC : B ⊆ C) + (δ : Ordinal.{0}) (Z : ZFSet.{0}) (φ : ElementaryModel.SentenceForm) + (I : CountableIdeal) (ρ : I ≃o I) + (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (R : Oracle) (hRM : realCode R ∈ M) + (hR : degree R = (ρ.symm ⟨degree (jump FixedArithmetic.zero),hz⟩).val) + (f : Name (Conditions (conditions C))) (hf : f.encode (label (conditions C)) ∈ M) + (hfv : ∀ H : GenericFilter (Conditions (conditions C)), GroundGeneric M H → + f.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet M (conditions C) H.carrier)) δ) + φ (fun _ : Fin φ.bound => Z)) + (G : GenericFilter (Conditions (conditions C))) (hG : GroundGeneric M G) + (hOwn : OwnDegreeExtension (genericExtensionSet M (conditions C) G.carrier) + (idealSet I) (automorphismSet ρ) (f.val G.carrier)) + (τ : Name (Conditions (conditions B))) (hτ : τ.encode (label (conditions B)) ∈ M) + (A : Oracle) (hτv : τ.val (projected C B hBC G).carrier = realCode A) + (p₀ : Conditions (conditions C)) (hp₀ : p₀ ∈ G.carrier) : + ∃ x y : Name (Conditions (conditions C)), + x.encode (label (conditions C)) ∈ M ∧ y.encode (label (conditions C)) ∈ M ∧ + x.val G.carrier = realCode A ∧ + (∀ H : GenericFilter (Conditions (conditions C)), GroundGeneric M H → + τ.val (projected C B hBC H).carrier ⊆ ZFSet.omega → + x.val H.carrier = τ.val (projected C B hBC H).carrier) ∧ + ∃ d : ℕ, ∃ p ∈ G.carrier, p ≤ p₀ ∧ + ∀ H : GenericFilter (Conditions (conditions C)), GroundGeneric M H → + project C B hBC p ∈ (projected C B hBC H).carrier → + ∃ A' X' : Oracle, x.val H.carrier = realCode A' ∧ y.val H.carrier = realCode X' ∧ + Represents (iterate (join A' R) 5) (machine d) X' ∧ + ∃ a ∈ degreeUniverse (groundReals (genericExtensionSet M (conditions C) H.carrier)), + ∃ b ∈ degreeUniverse (groundReals (genericExtensionSet M (conditions C) H.carrier)), + realCode A' ∈ a ∧ realCode X' ∈ b ∧ ZFSet.pair a b ∈ f.val H.carrier := by + have hct : (M : Set ZFSet.{0}).Countable := by + apply (Set.countable_range (label M)).mono + intro z hz; exact label_surjective M hz + have hc := conditions_mem M C hM hT hC + have ht := G.upper le_top G.nonempty.choose_spec + let E := genericExtensionSet M (conditions C) G.carrier + have hE := genericExtensionSet_transitive M (conditions C) hM G.carrier + have hTE := extension_sourceT M hM hT hc (InternalCollapse.orderSet_mem M hM hT hc) + (InternalCollapse.orderSet_pair _) G hG ht + let J := modelIdeal E hE hTE + obtain ⟨hIJ,σ,hσ,hext⟩ := (own_degree_extension_iff E hE hTE I ρ _).mp hOwn + have hAN : A ∈ modelReals + (genericExtensionSet M (conditions B) (projected C B hBC G).carrier) := + (mem_extensionSet _ _ _ _).mpr ⟨τ,hτ,hτv⟩ + have hAE : A ∈ modelReals E := by + change realCode A ∈ E + exact InternalColumnExtension.column_extension_subset M C B hM hT hC hB hBC G hG hAN + have hAJ : degree A ∈ J.carrier := ⟨A,hAE,rfl⟩ + have hRN : R ∈ modelReals + (genericExtensionSet M (conditions B) (projected C B hBC G).carrier) := by + have hcB := conditions_mem M B hM hT hB + let H := projected C B hBC G + exact ground_inclusion_set M _ hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hcB H.carrier + (H.upper le_top H.nonempty.choose_spec) hRM + obtain ⟨x,hx,hxv,hxfix⟩ := CohenProjectedNameLift.lift_projected_real_name M C B hM hT hC hB hBC τ hτ + have hxG : x.val G.carrier = realCode A := + (hxv G hG (by rw [hτv]; exact realCode_subset A)).trans hτv + obtain ⟨X,hX,hred,_,y,hy,hyG,hyfix⟩ := + ProjectedArithmeticOutputName.projected_output_name M C B hM hT hC hB hBC G hG + I J hIJ ρ σ hext hz A R hAJ hR hAN hRN + obtain ⟨c,hprog⟩ := reduces_represents hred + let d := Encodable.encode c + have hd : Represents (iterate (join A R) 5) (machine d) X := by simpa only [d,machine_encode] using hprog + have houtput : ∃ a ∈ degreeUniverse (groundReals E), ∃ b ∈ degreeUniverse (groundReals E), + x.val G.carrier ∈ a ∧ y.val G.carrier ∈ b ∧ ZFSet.pair a b ∈ f.val G.carrier := by + rw [ownDegreeUniverse_eq_idealSet E hE hTE (groundReals E) (mem_groundReals E), + ←hσ,hxG,hyG] + exact boundedOutputFormula_raw _ _ _ _ |>.mp + ((boundedOutputFormula_spec J σ A hAJ (realCode X)).mpr ⟨X,rfl,hX⟩) + obtain ⟨q,hq,hqp₀,hqout⟩ := defined_output_tail_cone M C B hM hT hct hC hB hBC + δ Z φ f x y hf hx hy hfv hxfix hyfix G hG houtput p₀ hp₀ + obtain ⟨p,hp,hpq,hpcode⟩ := fixed_arithmetic_tail_cone M C B hM hT hct hC hB hBC + x y hx hy hxfix hyfix R hRM d 5 G hG A X hxG hyG hd q hq + refine ⟨x,y,hx,hy,hxG,hxv,d,p,hp,hpq.trans hqp₀,?_⟩ + intro H hH hpH + have hqH : project C B hBC q ∈ (projected C B hBC H).carrier := by + apply (projected C B hBC H).upper (p := project C B hBC p) _ hpH + change label _ (project C B hBC q) ⊆ label _ (project C B hBC p) + simpa only [label_project] using restrict_mono B _ _ hpq + obtain ⟨A',X',hxa,hya,hrep⟩ := hpcode H hH hpH + refine ⟨A',X',hxa,hya,hrep,?_⟩ + simpa only [hxa,hya] using hqout H hH hqH + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ProjectedArithmeticOutputName.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ProjectedArithmeticOutputName.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a8fe3ee92422f86ceba47c00c8904a538008f54 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ProjectedArithmeticOutputName.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.CohenProjectedNameLift +import OAI.Computability.DegreeRigidity.SetModels.ExtensionArithmeticRepresentative +import OAI.Computability.DegreeRigidity.Representation.SourceTTreeAbsoluteness +import OAI.Computability.DegreeRigidity.Representation.SourceTheory +import OAI.Computability.DegreeRigidity.SetModels.SetModelJoin + +namespace OAI + +namespace TuringRigidity.ProjectedArithmeticOutputName +open RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open CohenGroundPoset InternalCohenRestriction InternalCohenProjectedGeneric +open PersistentRestrictions ExtensionArithmeticRepresentative OracleJump +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem representative_in_model (N : ZFSet.{0}) (hN : Transitive N) (hTN : SourceT N) + (I J : CountableIdeal) (hIJ : I.carrier ⊆ J.carrier) (ρ : I ≃o I) (σ : J ≃o J) + (he : Extends hIJ ρ σ) (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (A R : Oracle) (hA : degree A ∈ J.carrier) + (hR : degree R = (ρ.symm ⟨degree (jump FixedArithmetic.zero),hz⟩).val) + (hAN : A ∈ modelReals N) (hRN : R ∈ modelReals N) : + ∃ X : Oracle, X ∈ modelReals N ∧ degree X = (σ ⟨degree A,hA⟩).val ∧ + Reduces X (iterate (join A R) 5) ∧ ∃ e : OracleCode, + OracleCode.eval (oracleFunction (iterate (join A R) 5)) e = oracleFunction X := by + obtain ⟨X,hX,hred,hcode⟩ := extension_literal_join_program I J hIJ ρ σ he hz A R hA hR + have hj : join A R ∈ SetModelReals.reals N := SetModelArithmetic.join_mem N hN + hTN.pairing hTN.union hTN.powerSet hTN.separation.finitePrefix.bounded hTN.infinity hAN hRN + have hi (n : ℕ) : iterate (join A R) n ∈ SetModelReals.reals N := by + induction n with + | zero => exact hj + | succ n ih => exact SetModelSyntax.jump_mem (ArithmeticTree.sourceContext N hN hTN) ih + exact ⟨X,SetModelSyntax.lower_mem (ArithmeticTree.sourceContext N hN hTN) (hi 5) hred, + hX,hred,hcode⟩ + +theorem projected_output_name (M C B : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hC : C ∈ M) (hB : B ∈ M) (hBC : B ⊆ C) + (G : GenericFilter (Conditions (conditions C))) (hG : GroundGeneric M G) + (I J : CountableIdeal) (hIJ : I.carrier ⊆ J.carrier) (ρ : I ≃o I) (σ : J ≃o J) + (he : Extends hIJ ρ σ) (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (A R : Oracle) (hA : degree A ∈ J.carrier) + (hR : degree R = (ρ.symm ⟨degree (jump FixedArithmetic.zero),hz⟩).val) + (hAN : A ∈ modelReals (genericExtensionSet M (conditions B) (projected C B hBC G).carrier)) + (hRN : R ∈ modelReals (genericExtensionSet M (conditions B) (projected C B hBC G).carrier)) : + ∃ X : Oracle, degree X = (σ ⟨degree A,hA⟩).val ∧ + Reduces X (iterate (join A R) 5) ∧ + (∃ e : OracleCode, OracleCode.eval (oracleFunction (iterate (join A R) 5)) e = oracleFunction X) ∧ + ∃ y : Name (Conditions (conditions C)), y.encode (label (conditions C)) ∈ M ∧ + y.val G.carrier = realCode X ∧ + ∀ a : Conditions (conditions C) ≃o Conditions (conditions C), + (∀ s, restrict B (label _ (a s)) = restrict B (label _ s)) → + ∀ H : GenericFilter (Conditions (conditions C)), + y.val (AutomorphismName.mapFilter a H).carrier = y.val H.carrier := by + let H := projected C B hBC G + let N := genericExtensionSet M (conditions B) H.carrier + have hH : GroundGeneric M H := projected_groundGeneric M C B hM hT hC hB hBC G hG + have hc := conditions_mem M B hM hT hB + have hN := genericExtensionSet_transitive M (conditions B) hM H.carrier + obtain ⟨p,hp⟩ := H.nonempty + have hTN := extension_sourceT M hM hT hc (InternalCollapse.orderSet_mem M hM hT hc) + (InternalCollapse.orderSet_pair _) H hH (H.upper le_top hp) + obtain ⟨X,hXN,hX,hred,hcode⟩ := + representative_in_model N hN hTN I J hIJ ρ σ he hz A R hA hR hAN hRN + have hxN : realCode X ∈ (N : Set ZFSet.{0}) := hXN + rw [genericExtensionSet_coe] at hxN + obtain ⟨τ,hτ,hτv⟩ := hxN + obtain ⟨y,hy,hyv,hinv⟩ := CohenProjectedNameLift.lift_projected_real_name M C B + hM hT hC hB hBC τ hτ + refine ⟨X,hX,hred,hcode,y,hy,?_,hinv⟩ + exact (hyv G hG (by rw [hτv]; exact realCode_subset X)).trans hτv + +end TuringRigidity.ProjectedArithmeticOutputName + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RecursiveNameSymmetry.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RecursiveNameSymmetry.lean new file mode 100644 index 0000000000000000000000000000000000000000..e74ebe3fda2494dfe90d34b796cbd7fd2fc1a8ec --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RecursiveNameSymmetry.lean @@ -0,0 +1,106 @@ +import OAI.Computability.DegreeRigidity.SetModels.NameExtension +import OAI.Computability.DegreeRigidity.Representation.AutomorphismName + +namespace OAI + +namespace TuringRigidity.RecursiveNames +open Set CountableForcing +universe u +variable {P : Type u} [Preorder P] + +theorem val_mapFilter (e : P ≃o P) (G : GenericFilter P) (τ : Name P) : + Name.val (AutomorphismName.mapFilter e G).carrier (Name.rename e τ) = + Name.val G.carrier τ := + Name.val_rename e G.carrier (AutomorphismName.mapFilter e G).carrier + (fun p => by simp [AutomorphismName.mapFilter]) τ + +theorem extension_mapFilter (M : Set (Name P)) (e : P ≃o P) + (hf : ∀ τ ∈ M, Name.rename e τ ∈ M) + (hb : ∀ τ ∈ M, Name.rename e.symm τ ∈ M) (G : GenericFilter P) : + extension M (AutomorphismName.mapFilter e G).carrier = extension M G.carrier := by + ext x + constructor + · rintro ⟨τ,hτ,rfl⟩ + refine ⟨Name.rename e.symm τ,hb τ hτ,?_⟩ + exact Name.val_rename e.symm (AutomorphismName.mapFilter e G).carrier G.carrier + (fun _ => Iff.rfl) τ + · rintro ⟨τ,hτ,rfl⟩ + exact ⟨Name.rename e τ,hf τ hτ,val_mapFilter e G τ⟩ + +def reals (U : Set ZFSet.{u}) : Set ZFSet.{u} := {x | x ∈ U ∧ x ⊆ ZFSet.omega} + +theorem reals_mapFilter (M : Set (Name P)) (e : P ≃o P) + (hf : ∀ τ ∈ M, Name.rename e τ ∈ M) + (hb : ∀ τ ∈ M, Name.rename e.symm τ ∈ M) (G : GenericFilter P) : + reals (extension M (AutomorphismName.mapFilter e G).carrier) = + reals (extension M G.carrier) := by rw [extension_mapFilter M e hf hb G] + +inductive Formula where + | equal (i j : ℕ) + | member (i j : ℕ) + | conj (φ ψ : Formula) + | neg (φ : Formula) + | existsSet (φ : Formula) + +def Formula.Realize (U : Set ZFSet.{u}) (env : ℕ → ZFSet.{u}) : Formula → Prop + | .equal i j => env i = env j + | .member i j => env i ∈ env j + | .conj φ ψ => Realize U env φ ∧ Realize U env ψ + | .neg φ => ¬ Realize U env φ + | .existsSet φ => ∃ x ∈ U, Realize U (fun n => if n = 0 then x else env (n-1)) φ + +theorem realize_mapFilter (M : Set (Name P)) (e : P ≃o P) + (hf : ∀ τ ∈ M, Name.rename e τ ∈ M) + (hb : ∀ τ ∈ M, Name.rename e.symm τ ∈ M) (G : GenericFilter P) + (env : ℕ → ZFSet.{u}) (φ : Formula) : + φ.Realize (extension M (AutomorphismName.mapFilter e G).carrier) env ↔ + φ.Realize (extension M G.carrier) env := by rw [extension_mapFilter M e hf hb G] + +theorem definable_subset_mapFilter (M : Set (Name P)) (e : P ≃o P) + (hf : ∀ τ ∈ M, Name.rename e τ ∈ M) + (hb : ∀ τ ∈ M, Name.rename e.symm τ ∈ M) (G : GenericFilter P) + (env : ℕ → ZFSet.{u}) (φ : Formula) : + {x | x ∈ extension M (AutomorphismName.mapFilter e G).carrier ∧ + φ.Realize (extension M (AutomorphismName.mapFilter e G).carrier) + (fun n => if n = 0 then x else env (n-1))} = + {x | x ∈ extension M G.carrier ∧ + φ.Realize (extension M G.carrier) (fun n => if n = 0 then x else env (n-1))} := by + rw [extension_mapFilter M e hf hb G] + +noncomputable def extensionSet (M : ℕ → Name P) (G : Set P) : ZFSet.{u} := + ZFSet.range (fun n => Name.val G (M n)) + +omit [Preorder P] in +theorem extensionSet_coe (M : ℕ → Name P) (G : Set P) : + (extensionSet M G : Set ZFSet.{u}) = extension (Set.range M) G := by + ext x + change x ∈ ZFSet.range (fun n => Name.val G (M n)) ↔ _ + rw [ZFSet.mem_range] + simp only [extension,Set.mem_image,Set.mem_range] + exact ⟨fun ⟨n,hn⟩ => ⟨M n,⟨n,rfl⟩,hn⟩, + fun ⟨τ,⟨n,hn⟩,hx⟩ => ⟨n,hn ▸ hx⟩⟩ + +noncomputable def definedSet (U : ZFSet.{u}) (env : ℕ → ZFSet.{u}) (φ : Formula) : + ZFSet.{u} := ZFSet.sep + (fun x => φ.Realize (U : Set ZFSet) (fun n => if n = 0 then x else env (n-1))) U + +theorem mem_definedSet (U : ZFSet.{u}) (env : ℕ → ZFSet.{u}) (φ : Formula) + (x : ZFSet.{u}) : x ∈ definedSet U env φ ↔ x ∈ U ∧ + φ.Realize (U : Set ZFSet) (fun n => if n = 0 then x else env (n-1)) := + ZFSet.mem_sep + +theorem definedSet_mapFilter (M : ℕ → Name P) (e : P ≃o P) + (hf : ∀ τ ∈ Set.range M, Name.rename e τ ∈ Set.range M) + (hb : ∀ τ ∈ Set.range M, Name.rename e.symm τ ∈ Set.range M) + (G : GenericFilter P) (env : ℕ → ZFSet.{u}) (φ : Formula) : + definedSet (extensionSet M (AutomorphismName.mapFilter e G).carrier) env φ = + definedSet (extensionSet M G.carrier) env φ := by + have hU : extensionSet M (AutomorphismName.mapFilter e G).carrier = + extensionSet M G.carrier := by + apply SetLike.coe_injective + rw [extensionSet_coe,extensionSet_coe,extension_mapFilter _ e hf hb G] + rw [hU] + +end TuringRigidity.RecursiveNames + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RecursiveNames.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RecursiveNames.lean new file mode 100644 index 0000000000000000000000000000000000000000..8835324da1d6bd8a21308e51487fa2f7065240da --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RecursiveNames.lean @@ -0,0 +1,76 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.CountableForcing +import Mathlib.SetTheory.ZFC.Basic + +namespace OAI + +namespace TuringRigidity.RecursiveNames +open Set CountableForcing +universe u +variable {P : Type u} + +inductive Name (P : Type u) : Type (u+1) where + | mk (ι : Type u) (child : ι → Name P) (tag : ι → P) : Name P + +namespace Name +noncomputable def val (G : Set P) : Name P → ZFSet.{u} + | .mk _ child tag => ZFSet.range (fun i : {i // tag i ∈ G} => val G (child i.val)) + +theorem mem_val (G : Set P) (ι : Type u) (child : ι → Name P) (tag : ι → P) + (x : ZFSet.{u}) : x ∈ val G (.mk ι child tag) ↔ + ∃ i, tag i ∈ G ∧ val G (child i) = x := by + simp only [val, ZFSet.mem_range] + exact ⟨fun ⟨i,h⟩ => ⟨i.val,i.property,h⟩, fun ⟨i,hi,h⟩ => ⟨⟨i,hi⟩,h⟩⟩ + +def rename {Q : Type u} (e : P → Q) : Name P → Name Q + | .mk ι child tag => .mk ι (fun i => rename e (child i)) (e ∘ tag) + +theorem val_rename {Q : Type u} (e : P → Q) (G : Set P) (H : Set Q) + (h : ∀ p, e p ∈ H ↔ p ∈ G) (τ : Name P) : + val H (rename e τ) = val G τ := by + induction τ with + | mk ι child tag ih => + apply ZFSet.ext + intro x + simp only [rename, mem_val, Function.comp_apply, h, ih] + +def checkPSet [Top P] : PSet.{u} → Name P + | .mk ι child => .mk ι (fun i => checkPSet (child i)) (fun _ => ⊤) + +noncomputable def check [Top P] (x : ZFSet.{u}) : Name P := checkPSet x.out + +theorem val_checkPSet [Top P] (G : Set P) (hG : ⊤ ∈ G) (x : PSet.{u}) : + val G (checkPSet x : Name P) = ZFSet.mk x := by + induction x with + | mk ι child ih => + apply ZFSet.ext + intro y + induction y using Quotient.inductionOn with + | h y => + change ZFSet.mk y ∈ val G (.mk ι (fun index => checkPSet (child index)) + (fun _ => ⊤)) ↔ ZFSet.mk y ∈ ZFSet.mk (.mk ι child) + rw [mem_val] + simp only [hG, true_and, ih] + change (∃ i, ZFSet.mk (child i) = ZFSet.mk y) ↔ + ∃ i, PSet.Equiv y (child i) + simp only [ZFSet.eq] + exact exists_congr (fun i => PSet.Equiv.comm) + +theorem val_check [Top P] (G : Set P) (hG : ⊤ ∈ G) (x : ZFSet.{u}) : + val G (check x : Name P) = x := by + rw [check, val_checkPSet G hG, ZFSet.mk_out] + +theorem rename_checkPSet {Q : Type u} [Top P] [Top Q] + (e : P → Q) (he : e ⊤ = ⊤) (x : PSet.{u}) : + rename e (checkPSet x) = checkPSet x := by + induction x with + | mk ι child ih => + simp only [checkPSet, rename, Function.comp_def, he, ih] + +theorem rename_check {Q : Type u} [Top P] [Top Q] + (e : P → Q) (he : e ⊤ = ⊤) (x : ZFSet.{u}) : + rename e (check x) = check x := rename_checkPSet e he x.out + +end Name +end TuringRigidity.RecursiveNames + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RecursiveOmegaBound.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RecursiveOmegaBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..aabf827c90efade9a5155cbe220938147c1781aa --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RecursiveOmegaBound.lean @@ -0,0 +1,102 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedOmegaGraph +import OAI.Computability.DegreeRigidity.Effective.FiniteBlockProducts +import OAI.Computability.DegreeRigidity.Constructibility.UniformOmegaLevels + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalCoding +universe u + +theorem omega_certificates_explicit_bound (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (θ : Ordinal.{u}) + (hbase : ∀ c ≤ (1 : Ordinal.{u}), OmegaPowerCertificates (level (groundReals M) θ) c.toZFSet) + (a : Ordinal.{u}) : + OmegaPowerCertificates (level (groundReals M) (θ+Ordinal.omega0 ^ (a+1))) a.toZFSet := by + let R := groundReals M + have hmem (γ c : Ordinal.{u}) (hc : c < γ) : c.toZFSet ∈ level R γ := by + rw [ordinal_mem_level_iff] + exact hc.trans_le le_add_self + induction a using Ordinal.limitRecOn with + | zero => exact (hbase 0 zero_le_one).mono (level_mono R le_self_add) + | add_one a ih => + by_cases ha0 : a = 0 + · subst a + simpa only [zero_add] using (hbase 1 le_rfl).mono + (level_mono R (show θ ≤ θ+Ordinal.omega0 ^ ((1 : Ordinal.{u})+1) from le_self_add)) + have ha : 0 < a := pos_iff_ne_zero.mpr ha0 + let b := Ordinal.omega0 ^ (a+1) + let γ := θ+b+1 + have hiγ : θ+b ≤ γ := le_self_add + have hbγ : b < γ := (show b ≤ θ+b from le_add_self).trans_lt (lt_add_one _) + have haγ : Ordinal.omega0 ^ a < γ := + ((Ordinal.opow_lt_opow_iff_right Ordinal.one_lt_omega0).mpr (lt_add_one a)).trans hbγ + have hp := omega_boundary_product_without_offset M hM hT a ha + have hpγ := hp.mono (level_mono R (show b+1 ≤ γ from add_le_add le_add_self le_rfl)) + have hc := omega_certificates_successor_add_five R γ a + (ih.mono (level_mono R hiγ)) (hmem γ _ haγ) (hmem γ b hbγ) hpγ + apply hc.mono (level_mono R ?_) + have hbnext : b < Ordinal.omega0 ^ (a+1+1) := + (Ordinal.opow_lt_opow_iff_right Ordinal.one_lt_omega0).mpr (lt_add_one (a+1)) + have hlim : Order.IsSuccLimit (Ordinal.omega0 ^ (a+1+1)) := + Ordinal.isSuccLimit_opow_left Ordinal.isSuccLimit_omega0 (ne_of_gt (by positivity)) + have hmargin := hlim.add_natCast_lt hbnext 6 + dsimp [γ] + rw [add_assoc θ b 1,add_assoc θ (b+1) 5,add_assoc b 1 5] + exact add_le_add le_rfl (by simpa only [Nat.cast_ofNat,show (1 : Ordinal.{u})+5=6 by norm_num] using hmargin.le) + | limit a ha ih => + let b := Ordinal.omega0 ^ a + let γ := θ+b+1 + have haγ : a < γ := + ((Ordinal.right_le_opow a Ordinal.one_lt_omega0).trans le_add_self).trans_lt (lt_add_one _) + have hlocal (c : Ordinal.{u}) (hc : c < a) : + (Ordinal.omega0 ^ c).toZFSet ∈ level R γ ∧ OmegaPowerCertificates (level R γ) c.toZFSet := by + have hv : Ordinal.omega0 ^ c < b := + (Ordinal.opow_lt_opow_iff_right Ordinal.one_lt_omega0).mpr hc + have hstage : θ+Ordinal.omega0 ^ (c+1) ≤ γ := + (add_le_add le_rfl (Ordinal.opow_le_opow_right Ordinal.omega0_pos (ha.succ_lt hc).le)).trans le_self_add + exact ⟨hmem γ _ ((hv.trans_le le_add_self).trans (lt_add_one _)), + (ih c hc).mono (level_mono R hstage)⟩ + have result := omega_limit_certificates_at_add_five R γ a ha (hmem γ a haγ) + (ground_level_omega_mem M hM hT γ) hlocal + apply result.mono (level_mono R ?_) + have hbnext : b < Ordinal.omega0 ^ (a+1) := + (Ordinal.opow_lt_opow_iff_right Ordinal.one_lt_omega0).mpr (lt_add_one a) + have hlim : Order.IsSuccLimit (Ordinal.omega0 ^ (a+1)) := + Ordinal.isSuccLimit_opow_left Ordinal.isSuccLimit_omega0 (ne_of_gt (by positivity)) + have hmargin := hlim.add_natCast_lt hbnext 6 + dsimp [γ] + rw [add_assoc θ b 1,add_assoc θ (b+1) 5,add_assoc b 1 5] + exact add_le_add le_rfl (by simpa only [Nat.cast_ofNat,show (1 : Ordinal.{u})+5=6 by norm_num] using hmargin.le) + +theorem internal_explicit_omega_threshold (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) : ∃ θ : Ordinal.{u}, θ.toZFSet ∈ M ∧ + ∀ a : Ordinal.{u}, OmegaPowerCertificates + (level (groundReals M) (θ+Ordinal.omega0 ^ (a+1))) a.toZFSet := by + have h1 : (1 : Ordinal.{u}).toZFSet ∈ M := by + simpa only [zero_add] using internal_ordinal_succ M hM hT 0 (internal_ordinal_zero M hM hT) + obtain ⟨θ,hθ,hbound⟩ := uniform_omega_certificates_at_levels M hM hT 1 h1 + exact ⟨θ,hθ,omega_certificates_explicit_bound M hM hT θ + (fun c hc => (hbound θ le_rfl c hc).2.2.1)⟩ + +theorem lower_omega_closure_of_fixed_point (M : ZFSet.{u}) (θ β : Ordinal.{u}) + (hbound : ∀ a : Ordinal.{u}, OmegaPowerCertificates + (level (groundReals M) (θ+Ordinal.omega0 ^ (a+1))) a.toZFSet) + (hβ : Order.IsSuccLimit β) (hθ : θ < β) (hfix : Ordinal.omega0 ^ β = β) : + ∀ c < β, (Ordinal.omega0 ^ c).toZFSet ∈ level (groundReals M) β ∧ + OmegaPowerCertificates (level (groundReals M) β) c.toZFSet := by + intro c hc + have hv : Ordinal.omega0 ^ c < β := hfix ▸ + (Ordinal.opow_lt_opow_iff_right Ordinal.one_lt_omega0).mpr hc + have hs : Ordinal.omega0 ^ (c+1) < β := hfix ▸ + (Ordinal.opow_lt_opow_iff_right Ordinal.one_lt_omega0).mpr (hβ.succ_lt hc) + have hsum : θ+Ordinal.omega0 ^ (c+1) < β := by + rw [← hfix] at hθ hs ⊢ + exact Ordinal.isPrincipal_add_omega0_opow β hθ hs + refine ⟨?_,(hbound c).mono (level_mono _ hsum.le)⟩ + rw [ordinal_mem_level_iff] + exact hv.trans_le le_add_self + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RecursiveSumBound.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RecursiveSumBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfeded32e8bb1c1ee9d062fa085707da10d53865 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RecursiveSumBound.lean @@ -0,0 +1,39 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteSumStep +import OAI.Computability.DegreeRigidity.OrdinalCodes.OrdinalDecoderDomains + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalCoding +universe u + +theorem sum_certificates_finite_bound (M : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (a b : Ordinal.{u}) : + SumCertificates (level (groundReals M) (a+8*b+8)) a b := by + induction b using WellFoundedLT.induction with + | ind b ih => + let R := groundReals M + let γ := a+8*b+1 + have hb8 : b ≤ 8*b := Ordinal.le_mul_right b (by exact_mod_cast (show (0 : ℕ) < 8 by decide) : (0 : Ordinal.{u}) < 8) + have hsmall (t : Ordinal.{u}) (ht : t < b) : a+8*t+8 ≤ a+8*b := by + rw [add_assoc,← mul_add_one] + exact add_le_add le_rfl (mul_le_mul_right (Order.add_one_le_iff.mpr ht) 8) + have hmem (c : Ordinal.{u}) (hc : c ≤ a+8*b) : c.toZFSet ∈ level R γ := by + rw [ordinal_mem_level_iff] + exact (hc.trans_lt (lt_add_one _)).trans_le le_add_self + have ha := hmem a le_self_add + have hb := hmem b (hb8.trans le_add_self) + have hc (t : Ordinal.{u}) (ht : t < b) : + (a+t).toZFSet ∈ level R γ ∧ SumCertificates (level R γ) a t := by + refine ⟨hmem _ (add_le_add le_rfl (ht.le.trans hb8)),?_⟩ + exact (ih t ht).mono (level_mono R ((hsmall t ht).trans le_self_add)) + have result := sum_certificates_at_add_five R γ a b + (ground_level_omega_mem M hM hT γ) ha hb hc + apply result.mono (level_mono R ?_) + dsimp [γ] + rw [add_assoc] + exact add_le_add le_rfl (by norm_num : (1 : Ordinal.{u})+5 ≤ 8) + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RegularBinaryTree.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularBinaryTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4a1bf60b682660488ac6e8e4fcc2c56c6230de5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularBinaryTree.lean @@ -0,0 +1,144 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalRegularSplitter +import Mathlib.Data.List.Induction + +namespace OAI + +namespace TuringRigidity.RegularBinaryTree +open TransitiveNameModel BoundedSetTheory InternalRegularOperations InternalRegularAlgebra +open InternalProjectedGeneric RegularDecisionPartition RegularCodeSplitting + +noncomputable def children (B T U D : ZFSet.{0}) : Bool → ZFSet.{0} := by + classical + exact if h : ∃ f : Bool → ZFSet.{0}, (∀ b, f b ∈ positive B) ∧ + ZFSet.pair (ZFSet.pair U D) (ZFSet.pair (f false) (f true)) ∈ T + then h.choose else fun _ => ∅ + +theorem children_spec (B T U D : ZFSet.{0}) + (hf : FunctionGraph (ZFSet.prod (positive B) B) (ZFSet.prod (positive B) (positive B)) T) + (hU : U ∈ positive B) (hD : D ∈ B) : + (∀ b, children B T U D b ∈ positive B) ∧ + ZFSet.pair (ZFSet.pair U D) + (ZFSet.pair (children B T U D false) (children B T U D true)) ∈ T := by + classical + obtain ⟨y,hy,hxy,_⟩ := hf.2 (ZFSet.pair U D) (ZFSet.pair_mem_prod.mpr ⟨hU,hD⟩) + obtain ⟨V,hV,W,hW,rfl⟩ := ZFSet.mem_prod.mp hy + have hex : ∃ f : Bool → ZFSet.{0}, (∀ b, f b ∈ positive B) ∧ + ZFSet.pair (ZFSet.pair U D) (ZFSet.pair (f false) (f true)) ∈ T := by + refine ⟨(fun b => if b then W else V),?_,hxy⟩ + intro b; cases b; exact hV; exact hW + simp only [children,dite_eq_left hex] + exact hex.choose_spec + +theorem children_unique (B T U D V W : ZFSet.{0}) + (hf : FunctionGraph (ZFSet.prod (positive B) B) (ZFSet.prod (positive B) (positive B)) T) + (hU : U ∈ positive B) (hD : D ∈ B) + (hp : ZFSet.pair (ZFSet.pair U D) (ZFSet.pair V W) ∈ T) : + V = children B T U D false ∧ W = children B T U D true := + ZFSet.pair_inj.mp (hf.functional (ZFSet.pair_mem_prod.mpr ⟨hU,hD⟩) hp + (children_spec B T U D hf hU hD).2) + +noncomputable def tree (c B T : ZFSet.{0}) (E : ℕ → ZFSet.{0}) (s : List Bool) : ZFSet.{0} := + s.reverseRecOn c (fun t b U => children B T U (E t.length) b) + +theorem tree_nil (c B T : ZFSet.{0}) (E : ℕ → ZFSet.{0}) : tree c B T E [] = c := by + simp only [tree,List.reverseRecOn_nil] + +theorem tree_append (c B T : ZFSet.{0}) (E : ℕ → ZFSet.{0}) (s : List Bool) (b : Bool) : + tree c B T E (s ++ [b]) = children B T (tree c B T E s) (E s.length) b := by + simp only [tree,List.reverseRecOn_concat] + +variable (c B T : ZFSet.{0}) (E : ℕ → ZFSet.{0}) +variable (hc : c ∈ positive B) +variable (hf : FunctionGraph (ZFSet.prod (positive B) B) (ZFSet.prod (positive B) (positive B)) T) +variable (hE : ∀ n, E n ∈ B) +variable (hB : ∀ U ∈ B, IsCode c U) +variable (hs : ∀ U ∈ positive B, ∀ D ∈ B, ∀ V W, + ZFSet.pair (ZFSet.pair U D) (ZFSet.pair V W) ∈ T → + V ∈ positive B ∧ W ∈ positive B ∧ Refines c U D V W) + +include hc hf hE + +theorem tree_positive (s : List Bool) : tree c B T E s ∈ positive B := by + induction s using List.reverseRecOn with + | nil => simpa only [tree_nil] using hc + | append_singleton s b ih => + rw [tree_append] + exact (children_spec B T _ _ hf ih (hE s.length)).1 b + +include hs + +theorem tree_refines (s : List Bool) : + Refines c (tree c B T E s) (E s.length) + (tree c B T E (s ++ [false])) (tree c B T E (s ++ [true])) := by + rw [tree_append,tree_append] + have hp := tree_positive c B T E hc hf hE s + exact (hs _ hp _ (hE s.length) _ _ (children_spec B T _ _ hf hp (hE s.length)).2).2.2 + +theorem tree_child_subset (s : List Bool) (b : Bool) : + tree c B T E (s ++ [b]) ⊆ tree c B T E s := by + have h := (tree_refines c B T E hc hf hE hs s).1 + cases b; exact h.1; exact h.2.1 + +theorem tree_append_subset (s t : List Bool) : tree c B T E (s ++ t) ⊆ tree c B T E s := by + induction t using List.reverseRecOn with + | nil => simpa only [List.append_nil] using (show tree c B T E s ⊆ tree c B T E s from fun _ h => h) + | append_singleton t b ih => + rw [←List.append_assoc] + exact fun _ hp => ih (tree_child_subset c B T E hc hf hE hs (s ++ t) b hp) + +theorem tree_prefix (s t : List Bool) (hst : s <+: t) : tree c B T E t ⊆ tree c B T E s := by + obtain ⟨u,rfl⟩ := hst + exact tree_append_subset c B T E hc hf hE hs s u + +theorem tree_incompatible (s u v : List Bool) : + ∀ p ∈ tree c B T E (s ++ [false] ++ u), p ∉ tree c B T E (s ++ [true] ++ v) := by + intro p hp hq + exact (tree_refines c B T E hc hf hE hs s).1.2.2.2.2.1 p + (tree_append_subset c B T E hc hf hE hs (s ++ [false]) u hp) + (tree_append_subset c B T E hc hf hE hs (s ++ [true]) v hq) + +include hB + +theorem level_overlaps (D : ZFSet.{0}) (hD : IsCode c D) (hD0 : D ≠ ∅) (n : ℕ) : + ∃ s : List Bool, s.length = n ∧ ∃ p ∈ tree c B T E s, p ∈ D := by + classical + induction n with + | zero => + obtain he|⟨p,hp⟩ := ZFSet.eq_empty_or_nonempty D + · exact False.elim (hD0 he) + · exact ⟨[],rfl,p,by rw [tree_nil]; exact hD.1 hp,hp⟩ + | succ n ih => + obtain ⟨s,hlen,p,hp,hpD⟩ := ih + have hpart := (tree_refines c B T E hc hf hE hs s).1 + obtain ⟨r,hr,hpr,hrL|hrR⟩ := hpart.2.2.2.2.2 p hp + · have hrC := (hB _ (ZFSet.mem_sep.mp (tree_positive c B T E hc hf hE s)).1).1 hr + exact ⟨s ++ [false],by simp [hlen],r,hrL,code_lower c D hD p hpD r hrC hpr⟩ + · have hrC := (hB _ (ZFSet.mem_sep.mp (tree_positive c B T E hc hf hE s)).1).1 hr + exact ⟨s ++ [true],by simp [hlen],r,hrR,code_lower c D hD p hpD r hrC hpr⟩ + +theorem refines_enumerated (n : ℕ) (hn : E n ≠ ∅) : + ∃ s : List Bool, s.length = n+1 ∧ tree c B T E s ⊆ E n := by + obtain ⟨s,hlen,p,hp,hpE⟩ := level_overlaps c B T E hc hf hE hB hs (E n) (hB _ (hE n)) hn (n+1) + cases s using List.reverseRecOn with + | nil => simp at hlen + | append_singleton s b => + have hslen : s.length = n := by simpa only [List.length_append,List.length_singleton,Nat.add_right_cancel_iff] using hlen + have hd := tree_refines c B T E hc hf hE hs s + have hdec : tree c B T E (s ++ [b]) ⊆ E n ∨ tree c B T E (s ++ [b]) ⊆ neg c (E n) := by + rw [←hslen] + cases b; exact hd.2.1; exact hd.2.2 + rcases hdec with h|h + · exact ⟨s ++ [b],hlen,h⟩ + · exact False.elim ((ZFSet.mem_sep.mp (h hp)).2 p hpE (fun _ h => h)) + +theorem tree_dense + (hDense : ∀ D, IsCode c D → D ≠ ∅ → ∃ n, E n ≠ ∅ ∧ E n ⊆ D) : + ∀ D, IsCode c D → D ≠ ∅ → ∃ s : List Bool, tree c B T E s ⊆ D := by + intro D hD hD0 + obtain ⟨n,hn,hnD⟩ := hDense D hD hD0 + obtain ⟨s,_,hsD⟩ := refines_enumerated c B T E hc hf hE hB hs n hn + exact ⟨s,fun _ hp => hnD (hsD hp)⟩ + +end TuringRigidity.RegularBinaryTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RegularCodeSplitting.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularCodeSplitting.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce0ba0df112880ed5ad3382ed9f4f53a92c69a75 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularCodeSplitting.lean @@ -0,0 +1,131 @@ +import OAI.Computability.DegreeRigidity.SetModels.CountedRegularBasis + +namespace OAI + +namespace TuringRigidity.RegularCodeSplitting +open TransitiveNameModel BoundedSetTheory InternalRegularOperations InternalRegularAlgebra +open InternalRegularOrder InternalBooleanDense + +theorem mem_basic_iff (c p t : ZFSet.{0}) : t ∈ basicCode c p ↔ + t ∈ c ∧ ∀ q ∈ c, t ⊆ q → ∃ r ∈ c, q ⊆ r ∧ p ⊆ r := by + rw [basicCode,bitCode,mem_regular] + apply and_congr_right; intro _ + apply forall_congr'; intro q + apply forall_congr'; intro _ + apply forall_congr'; intro _ + simp only [CohenInternalDecision.below,ZFSet.mem_sep,ZFSet.mem_singleton] + constructor + · rintro ⟨r,⟨hr,x,hx,hxr⟩,hqr⟩ + subst x; exact ⟨r,hr,hqr,hxr⟩ + · rintro ⟨r,hr,hqr,hpr⟩; exact ⟨r,⟨hr,p,rfl,hpr⟩,hqr⟩ + +theorem basic_disjoint (c p q : ZFSet.{0}) + (hinc : ¬ ∃ r ∈ c, p ⊆ r ∧ q ⊆ r) : + ∀ t ∈ basicCode c p, t ∉ basicCode c q := by + intro t htp htq + obtain ⟨r,hr,htr,hpr⟩ := ((mem_basic_iff c p t).mp htp).2 t + ((mem_basic_iff c p t).mp htp).1 (fun _ h => h) + have hrq := code_lower c _ (regular_isCode c _) t htq r hr htr + obtain ⟨s,hs,hrs,hqs⟩ := ((mem_basic_iff c q r).mp hrq).2 r hr (fun _ h => h) + exact hinc ⟨s,hs,fun _ h => hrs (hpr h),hqs⟩ + +noncomputable def remainder (U : ZFSet.{0}) (c V : ZFSet.{0}) : ZFSet.{0} := + U.sep (fun p => p ∈ neg c V) + +theorem remainder_isCode (c U V : ZFSet.{0}) (hU : IsCode c U) (hV : IsCode c V) : + IsCode c (remainder U c V) := by + have he : remainder U c V = infCode c {U,neg c V} := by + apply ZFSet.ext; intro p + simp only [remainder,infCode,ZFSet.mem_sep,ZFSet.mem_pair] + constructor + · rintro ⟨hpu,hpn⟩ + exact ⟨hU.1 hpu,fun W hW => hW.elim (fun h => h ▸ hpu) (fun h => h ▸ hpn)⟩ + · rintro ⟨_,h⟩; exact ⟨h U (Or.inl rfl),h _ (Or.inr rfl)⟩ + rw [he] + exact inf_isCode c _ (fun W hW => (ZFSet.mem_pair.mp hW).elim + (fun h => h ▸ hU) (fun h => h ▸ neg_isCode c V hV)) + +theorem remainder_mem (M c U V : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hU : U ∈ M) (hV : V ∈ M) : remainder U c V ∈ M := by + simpa only [remainder,Formula.Eval,cons_zero,cons_succ] using + sep_mem M hM hT.separation.finitePrefix.bounded (.member 0 1) + (fun _ => neg c V) (fun _ => neg_mem M c V hM hT hc hV) hU + +def Partition (U V W : ZFSet.{0}) : Prop := + V ⊆ U ∧ W ⊆ U ∧ V ≠ ∅ ∧ W ≠ ∅ ∧ + (∀ p ∈ V, p ∉ W) ∧ + ∀ p ∈ U, ∃ r ∈ U, p ⊆ r ∧ (r ∈ V ∨ r ∈ W) + +def partitionFormula (U V W : ℕ) : Formula := + .conj (.subset V U) (.conj (.subset W U) + (.conj (.neg (.empty V)) (.conj (.neg (.empty W)) + (.conj (.allMem V (.neg (.member 0 (W+1)))) + (.allMem U (.existsMem (U+1) (.conj (.subset 1 0) + (.disj (.member 0 (V+2)) (.member 0 (W+2)))))))))) + +theorem partitionFormula_spec (U V W : ℕ) (e : ℕ → ZFSet.{0}) : + (partitionFormula U V W).Eval e ↔ Partition (e U) (e V) (e W) := by + simp only [partitionFormula,Partition,Formula.Eval,Formula.eval_subset,Formula.eval_empty, + Formula.eval_allMem,Formula.eval_disj,cons_zero,cons_succ] + +theorem partition_join (c U V W : ZFSet.{0}) (hU : IsCode c U) + (hV : IsCode c V) (hW : IsCode c W) (h : Partition U V W) : + supCode c {V,W} = U := by + have hF : ∀ X ∈ ({V,W} : ZFSet.{0}), IsCode c X := fun X hX => + (ZFSet.mem_pair.mp hX).elim (fun he => he ▸ hV) (fun he => he ▸ hW) + have hle := (supCode_le_iff c {V,W} U hF hU).mpr (fun X hX => + (ZFSet.mem_pair.mp hX).elim (fun he => he ▸ h.1) (fun he => he ▸ h.2.1)) + apply ZFSet.ext; intro p + refine ⟨fun hp => hle hp,fun hp => ?_⟩ + apply (mem_regular c _ p).mpr + refine ⟨hU.1 hp,fun q hq hpq => ?_⟩ + obtain ⟨r,_,hqr,hr⟩ := h.2.2.2.2.2 q (code_lower c U hU p hp q hq hpq) + refine ⟨r,?_,hqr⟩ + exact hr.elim (fun hr => ZFSet.mem_sUnion.mpr ⟨V,ZFSet.mem_pair.mpr (Or.inl rfl),hr⟩) + (fun hr => ZFSet.mem_sUnion.mpr ⟨W,ZFSet.mem_pair.mpr (Or.inr rfl),hr⟩) + +theorem internal_partition (M c B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hsplit : ∀ p ∈ c, ∃ p0 ∈ c, ∃ p1 ∈ c, p ⊆ p0 ∧ p ⊆ p1 ∧ + ¬ ∃ r ∈ c, p0 ⊆ r ∧ p1 ⊆ r) : + ∀ U ∈ B, U ≠ ∅ → ∃ V ∈ B, ∃ W ∈ B, Partition U V W := by + classical + intro U hUB hU0 + have hUM := ((hB U).mp hUB).1 + have hU := ((hB U).mp hUB).2 + have hex : ∃ p, p ∈ U := by + by_contra h + exact hU0 (ZFSet.ext (fun p => ⟨fun hp => False.elim (h ⟨p,hp⟩), + fun hp => False.elim (ZFSet.notMem_empty p hp)⟩)) + obtain ⟨p,hp⟩ := hex + obtain ⟨p0,hp0,p1,hp1,h0,h1,hinc⟩ := hsplit p (hU.1 hp) + let V := basicCode c p0 + let W := remainder U c V + have hV : IsCode c V := regular_isCode c _ + have hVM := basicCode_mem M c p0 hM hT hc hp0 + have hVU : V ⊆ U := (basicCode_le_iff c p0 U hp0 hU).mpr + (code_lower c U hU p hp p0 hp0 h0) + have hp1U := code_lower c U hU p hp p1 hp1 h1 + have hp1N : p1 ∈ neg c V := by + refine ZFSet.mem_sep.mpr ⟨hp1,fun q hq hp1q => ?_⟩ + obtain ⟨r,hr,hqr,hp0r⟩ := ((mem_basic_iff c p0 q).mp hq).2 q + ((mem_basic_iff c p0 q).mp hq).1 (fun _ h => h) + exact hinc ⟨r,hr,hp0r,fun _ h => hqr (hp1q h)⟩ + have hp1W : p1 ∈ W := ZFSet.mem_sep.mpr ⟨hp1U,hp1N⟩ + refine ⟨V,(hB V).mpr ⟨hVM,hV⟩,W, + (hB W).mpr ⟨remainder_mem M c U V hM hT hc hUM hVM,remainder_isCode c U V hU hV⟩, + hVU,(fun _ h => (ZFSet.mem_sep.mp h).1), + (fun h => ZFSet.notMem_empty p0 (h ▸ mem_basicCode c p0 hp0)), + (fun h => ZFSet.notMem_empty p1 (h ▸ hp1W)),?_,?_⟩ + · intro q hq hqW + exact (ZFSet.mem_sep.mp (ZFSet.mem_sep.mp hqW).2).2 q hq (fun _ h => h) + · intro q hq + by_cases hex : ∃ r ∈ V, q ⊆ r + · obtain ⟨r,hr,hqr⟩ := hex + exact ⟨r,hVU hr,hqr,Or.inl hr⟩ + · exact ⟨q,hq,(fun _ h => h),Or.inr (ZFSet.mem_sep.mpr ⟨hq, + ZFSet.mem_sep.mpr ⟨hU.1 hq,fun r hr hqr => hex ⟨r,hr,hqr⟩⟩⟩)⟩ + +end TuringRigidity.RegularCodeSplitting + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RegularCompletion.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularCompletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..e580b6658d1d321cda9d2ec77651688c7047a20e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularCompletion.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.Syntax.BooleanProjection +import Mathlib.Order.Heyting.Regular +import Mathlib.Order.UpperLower.Principal + +namespace OAI + +namespace TuringRigidity.RegularCompletion +open Set CountableForcing BooleanProjection +universe u +variable {P : Type u} [Preorder P] + +abbrev Algebra (P : Type u) [Preorder P] := Heyting.Regular (LowerSet P) + +noncomputable instance algebraCompleteBoolean : CompleteBooleanAlgebra (Algebra P) where + __ := (inferInstance : BooleanAlgebra (Algebra P)) + sSup := (Heyting.Regular.gi (α := LowerSet P)).liftCompleteLattice.sSup + sInf := (Heyting.Regular.gi (α := LowerSet P)).liftCompleteLattice.sInf + isLUB_sSup := (Heyting.Regular.gi (α := LowerSet P)).liftCompleteLattice.isLUB_sSup + isGLB_sInf := (Heyting.Regular.gi (α := LowerSet P)).liftCompleteLattice.isGLB_sInf + +def basic (p : P) : Algebra P := Heyting.Regular.toRegular (LowerSet.Iic p) + +theorem basic_le_iff (p : P) (a : Algebra P) : basic p ≤ a ↔ p ∈ (a : LowerSet P) := by + exact (Heyting.Regular.gi.gc (LowerSet.Iic p) a).trans LowerSet.Iic_le + +theorem mem_basic (p : P) : p ∈ (basic p : LowerSet P) := + (basic_le_iff p (basic p)).mp le_rfl + +theorem basic_nonzero (p : P) : basic p ≠ ⊥ := by + intro h + have hp := mem_basic p + rw [h] at hp + exact hp + +theorem basic_mono : Monotone (basic : P → Algebra P) := by + intro p q hpq + exact (basic_le_iff p _).mpr ((basic q : LowerSet P).lower hpq (mem_basic q)) + +theorem mem_compl (U : LowerSet P) (p : P) : + p ∈ Uᶜ ↔ ∀ q, q ≤ p → q ∉ U := by + rw [← LowerSet.Iic_le,le_compl_iff_disjoint_left,disjoint_iff] + constructor + · intro h q hqp hq + have hx : q ∈ U ⊓ LowerSet.Iic p := ⟨hq,hqp⟩ + rw [h] at hx + exact hx + · intro h + apply le_antisymm _ bot_le + intro q hq + exact False.elim (h q hq.2 hq.1) + +theorem mem_basic_iff (p q : P) : + q ∈ (basic p : LowerSet P) ↔ ∀ r, r ≤ q → ∃ s, s ≤ r ∧ s ≤ p := by + change q ∈ (LowerSet.Iic p)ᶜᶜ ↔ _ + rw [mem_compl] + simp only [mem_compl,LowerSet.mem_Iic_iff] + classical + simp only [not_forall,not_not,exists_prop] + +theorem basic_dense (a : Algebra P) (ha : a ≠ ⊥) : ∃ p : P, basic p ≤ a := by + classical + by_contra h + have hn : ∀ p, p ∉ (a : LowerSet P) := by + intro p hp + exact h ⟨p,(basic_le_iff p a).mpr hp⟩ + apply ha + apply Heyting.Regular.coe_injective + apply le_antisymm _ bot_le + intro p hp + exact False.elim (hn p hp) + +theorem refine_basic (p : P) (a : Algebra P) (ha : a ≠ ⊥) (hap : a ≤ basic p) : + ∃ q, q ≤ p ∧ basic q ≤ a := by + obtain ⟨r,hr⟩ := basic_dense a ha + obtain ⟨q,hqr,hqp⟩ := (mem_basic_iff p r).mp + ((basic_le_iff r (basic p)).mp (hr.trans hap)) r le_rfl + exact ⟨q,hqp,(basic_mono hqr).trans hr⟩ + +noncomputable def positiveBasic (p : P) : Positive (Algebra P) := + ⟨basic p,basic_nonzero p⟩ + +theorem positiveBasic_dense : Dense (Set.range (positiveBasic : P → Positive (Algebra P))) := by + intro a + obtain ⟨p,hp⟩ := basic_dense a.val a.property + exact ⟨positiveBasic p,hp,p,rfl⟩ + +theorem positiveBasic_countable [Countable P] : + (Set.range (positiveBasic : P → Positive (Algebra P))).Countable := Set.countable_range _ + +end TuringRigidity.RegularCompletion + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RegularDecisionPartition.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularDecisionPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..72ada35d12834edf6612220ffe082e15371f558f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularDecisionPartition.lean @@ -0,0 +1,106 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularCodeSplitting + +namespace OAI + +namespace TuringRigidity.RegularDecisionPartition +open TransitiveNameModel BoundedSetTheory InternalRegularOperations InternalRegularAlgebra +open InternalRegularOrder RegularCodeSplitting + +noncomputable def meet (U V : ZFSet.{0}) : ZFSet.{0} := U.sep (fun p => p ∈ V) + +theorem meet_mem (M U V : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hU : U ∈ M) (hV : V ∈ M) : meet U V ∈ M := by + simpa only [meet,Formula.Eval,cons_zero,cons_succ] using + sep_mem M hM hT.separation.finitePrefix.bounded (.member 0 1) + (fun _ => V) (fun _ => hV) hU + +theorem meet_isCode (c U V : ZFSet.{0}) (hU : IsCode c U) (hV : IsCode c V) : + IsCode c (meet U V) := by + have he : meet U V = remainder U c (neg c V) := by + change U.sep (fun p => p ∈ V) = U.sep (fun p => p ∈ regular c V) + rw [hV.2] + rw [he] + exact remainder_isCode c U (neg c V) hU (neg_isCode c V hV) + +theorem disjoint_le_neg (c U D : ZFSet.{0}) (hU : IsCode c U) (hD : IsCode c D) + (he : meet U D = ∅) : U ⊆ neg c D := by + intro p hp + refine ZFSet.mem_sep.mpr ⟨hU.1 hp,fun q hq hpq => ?_⟩ + have hqM : q ∈ meet U D := ZFSet.mem_sep.mpr + ⟨code_lower c U hU p hp q (hD.1 hq) hpq,hq⟩ + exact ZFSet.notMem_empty q (he ▸ hqM) + +theorem remainder_empty_le (c U D : ZFSet.{0}) (hU : IsCode c U) (hD : IsCode c D) + (he : remainder U c D = ∅) : U ⊆ D := by + classical + intro p hp + rw [←hD.2] + apply (mem_regular c D p).mpr + refine ⟨hU.1 hp,fun q hq hpq => ?_⟩ + by_contra hn + have hqR : q ∈ remainder U c D := ZFSet.mem_sep.mpr + ⟨code_lower c U hU p hp q hq hpq, + ZFSet.mem_sep.mpr ⟨hq,fun r hr hqr => hn ⟨r,hr,hqr⟩⟩⟩ + exact ZFSet.notMem_empty q (he ▸ hqR) + +def Refines (c U D V W : ZFSet.{0}) : Prop := + Partition U V W ∧ (V ⊆ D ∨ V ⊆ neg c D) ∧ (W ⊆ D ∨ W ⊆ neg c D) + +def decidesFormula (c D V : ℕ) : Formula := + .disj (.subset V D) (.allMem V (.conj (.member 0 (c+1)) + (.allMem (D+1) (.neg (.subset 1 0))))) + +theorem decidesFormula_spec (c D V : ℕ) (e : ℕ → ZFSet.{0}) : + (decidesFormula c D V).Eval e ↔ e V ⊆ e D ∨ e V ⊆ neg (e c) (e D) := by + simp only [decidesFormula,Formula.eval_disj,Formula.eval_subset,Formula.eval_allMem, + Formula.Eval,cons_zero,cons_succ] + apply or_congr Iff.rfl + exact ⟨fun h p hp => ZFSet.mem_sep.mpr (h p hp), + fun h p hp => ZFSet.mem_sep.mp (h hp)⟩ + +def refiningFormula (c U D V W : ℕ) : Formula := + .conj (partitionFormula U V W) (.conj (decidesFormula c D V) (decidesFormula c D W)) + +theorem refiningFormula_spec (c U D V W : ℕ) (e : ℕ → ZFSet.{0}) : + (refiningFormula c U D V W).Eval e ↔ Refines (e c) (e U) (e D) (e V) (e W) := by + simp only [refiningFormula,Refines,Formula.Eval,partitionFormula_spec,decidesFormula_spec] + +theorem refining_partition (M c B : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hsplit : ∀ p ∈ c, ∃ p0 ∈ c, ∃ p1 ∈ c, p ⊆ p0 ∧ p ⊆ p1 ∧ + ¬ ∃ r ∈ c, p0 ⊆ r ∧ p1 ⊆ r) + (U D : ZFSet.{0}) (hUB : U ∈ B) (hDB : D ∈ B) (hne : U ≠ ∅) : + ∃ V ∈ B, ∃ W ∈ B, Refines c U D V W := by + classical + have hU := ((hB U).mp hUB).2 + have hD := ((hB D).mp hDB).2 + obtain ⟨V,hVB,W,hWB,hpart⟩ := internal_partition M c B hM hT hc hB hsplit U hUB hne + by_cases hUD : U ⊆ D + · exact ⟨V,hVB,W,hWB,hpart,Or.inl (fun _ h => hUD (hpart.1 h)), + Or.inl (fun _ h => hUD (hpart.2.1 h))⟩ + by_cases hUN : U ⊆ neg c D + · exact ⟨V,hVB,W,hWB,hpart,Or.inr (fun _ h => hUN (hpart.1 h)), + Or.inr (fun _ h => hUN (hpart.2.1 h))⟩ + have hL : meet U D ≠ ∅ := fun h => hUN (disjoint_le_neg c U D hU hD h) + have hR : remainder U c D ≠ ∅ := fun h => hUD (remainder_empty_le c U D hU hD h) + have hUM := ((hB U).mp hUB).1 + have hDM := ((hB D).mp hDB).1 + refine ⟨meet U D,(hB _).mpr ⟨meet_mem M U D hM hT hUM hDM,meet_isCode c U D hU hD⟩, + remainder U c D,(hB _).mpr + ⟨remainder_mem M c U D hM hT hc hUM hDM,remainder_isCode c U D hU hD⟩, + ⟨(fun _ h => (ZFSet.mem_sep.mp h).1),(fun _ h => (ZFSet.mem_sep.mp h).1),hL,hR,?_,?_⟩, + Or.inl (fun _ h => (ZFSet.mem_sep.mp h).2),Or.inr (fun _ h => (ZFSet.mem_sep.mp h).2)⟩ + · intro p hp hpR + exact (ZFSet.mem_sep.mp (ZFSet.mem_sep.mp hpR).2).2 p + (ZFSet.mem_sep.mp hp).2 (fun _ h => h) + · intro p hp + by_cases hex : ∃ q ∈ D, p ⊆ q + · obtain ⟨q,hq,hpq⟩ := hex + have hqU := code_lower c U hU p hp q (hD.1 hq) hpq + exact ⟨q,hqU,hpq,Or.inl (ZFSet.mem_sep.mpr ⟨hqU,hq⟩)⟩ + · exact ⟨p,hp,(fun _ h => h),Or.inr (ZFSet.mem_sep.mpr + ⟨hp,ZFSet.mem_sep.mpr ⟨hU.1 hp,fun q hq hpq => hex ⟨q,hq,hpq⟩⟩⟩)⟩ + +end TuringRigidity.RegularDecisionPartition + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RegularProjection.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b435fec98f5ae1afb38e8abfe8869cfbffc987b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularProjection.lean @@ -0,0 +1,54 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularCompletion +import OAI.Computability.DegreeRigidity.CohenForcing.QuotientDense + +namespace OAI + +namespace TuringRigidity.RegularProjection +open Set CountableForcing ForcingProjection BooleanProjection RegularCompletion +universe u +variable {P : Type u} [Preorder P] + +noncomputable def originalProjection (A : CompleteSublattice (Algebra P)) + (hc : ∀ a ∈ A, aᶜ ∈ A) : Projection P (PartPositive A) where + map p := (forcingProjection A hc).map (positiveBasic p) + mono := fun _ _ h => project_mono A (basic_mono h) + lift := by + intro p a hap + obtain ⟨b,hbp,hba⟩ := (forcingProjection A hc).lift (positiveBasic p) a hap + obtain ⟨q,hqp,hqb⟩ := refine_basic p b.val b.property hbp + exact ⟨q,hqp,(project_mono A hqb).trans hba⟩ + +theorem originalProjection_dense (A : CompleteSublattice (Algebra P)) + (hc : ∀ a ∈ A, aᶜ ∈ A) : Dense (Set.range (originalProjection A hc).map) := by + intro a + obtain ⟨p,hpa⟩ := basic_dense a.val a.property.2 + exact ⟨(originalProjection A hc).map p, + (project_le_iff A _ _ a.property.1).mpr hpa,p,rfl⟩ + +theorem originalProjection_countable_dense [Countable P] + (A : CompleteSublattice (Algebra P)) (hc : ∀ a ∈ A, aᶜ ∈ A) : + (Set.range (originalProjection A hc).map).Countable ∧ + Dense (Set.range (originalProjection A hc).map) := + ⟨Set.countable_range _,originalProjection_dense A hc⟩ + +theorem image_mem_iff (A : CompleteSublattice (Algebra P)) + (hc : ∀ a ∈ A, aᶜ ∈ A) (G : GenericFilter P) (a : PartPositive A) : + a ∈ (imageFilter (originalProjection A hc) G).carrier ↔ + ∃ p ∈ G.carrier, p ∈ (a.val : LowerSet P) := by + change (∃ p ∈ G.carrier, project A (basic p) ≤ a.val) ↔ _ + simp only [project_le_iff A _ _ a.property.1,basic_le_iff] + +theorem countable_quotient_presentation [Countable P] + (A : CompleteSublattice (Algebra P)) (hc : ∀ a ∈ A, aᶜ ∈ A) + (H : GenericFilter (PartPositive A)) (D : Set P) (hD : Dense D) + (hH : ∀ p, ∃ a ∈ H.carrier, + a ∈ QuotientDense.requirement (originalProjection A hc) D p) : + Countable (QuotientConditions (originalProjection A hc) H) ∧ + (∀ p, Dense (QuotientDense.requirement (originalProjection A hc) D p)) ∧ + Dense (QuotientDense.restriction (originalProjection A hc) H D) := + ⟨QuotientDense.quotient_countable _ _, + QuotientDense.requirement_dense _ _ hD,QuotientDense.restriction_dense _ _ _ hH⟩ + +end TuringRigidity.RegularProjection + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeCofinality.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeCofinality.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fcbe59e649bbd67630438885361f38ac08c30f8 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeCofinality.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularTreeFilter + +namespace OAI + +namespace TuringRigidity.RegularTreeCofinality +open TransitiveNameModel BoundedSetTheory CountableForcing InternalRegularOperations +open InternalRegularAlgebra InternalBooleanGeneric InternalBooleanDense RegularTreeFilter +open InternalCohen +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +noncomputable def nodesBelow (B A U : ZFSet.{0}) : ZFSet.{0} := + B.sep (fun V => ∃ w ∈ conditions, ZFSet.pair w V ∈ A ∧ V ⊆ U) + +theorem nodesBelow_mem (M B A U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hB : B ∈ M) (hA : A ∈ M) (hU : U ∈ M) : nodesBelow B A U ∈ M := by + let e := cons conditions (cons A (fun _ => U)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|i + exact conditions_mem M hM hT; exact hA; exact hU + simpa only [nodesBelow,Formula.Eval,Formula.eval_pairMem,Formula.eval_subset, + cons_zero,cons_succ,e] using + sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.conj (.pairMem 0 1 3) (.subset 1 4))) e he hB + +theorem nodesBelow_decision_dense (c B A U : ZFSet.{0}) (f : List Bool → ZFSet.{0}) + (hf : ∀ s, f s ∈ B ∧ IsCode c (f s) ∧ f s ≠ ∅) + (hAs : ∀ s V, ZFSet.pair (wordCode s) V ∈ A ↔ V = f s) + (hden : ∀ V, IsCode c V → V ≠ ∅ → ∃ s, f s ⊆ V) + (hU : IsCode c U) : + Dense {p : Conditions c | label c p ∈ ZFSet.sUnion (nodesBelow B A U) ∪ neg c U} := by + intro p + obtain ⟨q,hqp,hq⟩ := decision_dense c U hU.1 p + rcases ZFSet.mem_union.mp hq with hqU|hqN + · have hb := mem_basicCode c _ (label_mem c q) + have hb0 : basicCode c (label c q) ≠ ∅ := fun he => ZFSet.notMem_empty _ (he ▸ hb) + obtain ⟨s,hs⟩ := hden _ (regular_isCode c _) hb0 + obtain ⟨r,hr,hqr⟩ := refines_condition c _ _ (hf s).2.1 (hf s).2.2 hs + obtain ⟨r,rfl⟩ := label_surjective c ((hf s).2.1.1 hr) + have hsU : f s ⊆ U := fun _ h => + (basicCode_le_iff c _ U (label_mem c q) hU).mpr hqU (hs h) + exact ⟨r,le_trans hqr hqp,ZFSet.mem_union.mpr (Or.inl (ZFSet.mem_sUnion.mpr + ⟨f s,ZFSet.mem_sep.mpr ⟨(hf s).1,wordCode s, + (mem_conditions _).mpr ⟨_,wordCode_function s⟩,(hAs _ _).mpr rfl,hsU⟩,hr⟩))⟩ + · exact ⟨q,hqp,ZFSet.mem_union.mpr (Or.inr hqN)⟩ + +theorem hit_iff_node (M c B A U : ZFSet.{0}) (f : List Bool → ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hB : B ∈ M) (hA : A ∈ M) + (hU : U ∈ M) (hUc : IsCode c U) + (hf : ∀ s, f s ∈ B ∧ IsCode c (f s) ∧ f s ≠ ∅) + (hAs : ∀ s V, ZFSet.pair (wordCode s) V ∈ A ↔ V = f s) + (hden : ∀ V, IsCode c V → V ≠ ∅ → ∃ s, f s ⊆ V) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + Hit G U ↔ ∃ s, Hit G (f s) ∧ f s ⊆ U := by + constructor + · intro hGU + have hFM := nodesBelow_mem M B A U hM hT hB hA hU + obtain ⟨p,hp,hpD⟩ := hG (ZFSet.sUnion (nodesBelow B A U) ∪ neg c U) + (binary_union_mem M hM hT.pairing hT.union (union_mem M hM hT.union hFM) + (neg_mem M c U hM hT hc hU)) + (nodesBelow_decision_dense c B A U f hf hAs hden hUc) + rcases ZFSet.mem_union.mp hpD with hpF|hpN + · obtain ⟨V,hVF,hpV⟩ := ZFSet.mem_sUnion.mp hpF + obtain ⟨_,w,hw,hwV,hVU⟩ := ZFSet.mem_sep.mp hVF + obtain ⟨s,hs⟩ := (prefix_iff_wordCode w).mp ((mem_conditions w).mp hw) + have hV : V = f s := (hAs s V).mp (hs.symm ▸ hwV) + exact ⟨s,⟨p,hp,hV ▸ hpV⟩,hV ▸ hVU⟩ + · exact False.elim (hit_neg_excludes c U (code_lower c U hUc) G ⟨p,hp,hpN⟩ hGU) + · rintro ⟨s,⟨p,hp,hps⟩,hsU⟩ + exact ⟨p,hp,hsU hps⟩ + +theorem hit_basic_iff (M c : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (G : GenericFilter (Conditions c)) + (hG : AtomicForcing.GroundGeneric M G) (p : Conditions c) : + Hit G (basicCode c (label c p)) ↔ p ∈ G.carrier := by + have hpM := hM c hc _ (label_mem c p) + have hsM := singleton_mem M hM hT.pairing hpM + have he := hit_regular_iff M c (CohenInternalDecision.below c {label c p}) hM hT hc + (CohenInternalDecision.below_mem M c _ hM hT hc hsM) + (fun _ h => (ZFSet.mem_sep.mp h).1) (below_lower c _) G hG + change Hit G (basicCode c (label c p)) ↔ _ at he + rw [he] + constructor + · rintro ⟨q,hq,hqp⟩ + obtain ⟨_,r,hr,hrq⟩ := ZFSet.mem_sep.mp hqp + have hrp := ZFSet.mem_singleton.mp hr + have hqp : label c p ⊆ label c q := hrp ▸ hrq + exact G.upper hqp hq + · intro hp + exact ⟨p,hp,ZFSet.mem_sep.mpr ⟨label_mem c p,label c p,ZFSet.mem_singleton.mpr rfl, + fun _ h => h⟩⟩ + +end TuringRigidity.RegularTreeCofinality + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeCompatibility.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeCompatibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..bbf4be86e201dbdfbd0e859f2191785a71da111e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeCompatibility.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularBinaryTree + +namespace OAI + +namespace TuringRigidity.RegularTreeCompatibility + +theorem words_compare (s t : List Bool) : + s <+: t ∨ t <+: s ∨ ∃ a u v : List Bool, + (s = a ++ [false] ++ u ∧ t = a ++ [true] ++ v) ∨ + (s = a ++ [true] ++ u ∧ t = a ++ [false] ++ v) := by + induction s generalizing t with + | nil => exact Or.inl List.nil_prefix + | cons b s ih => + cases t with + | nil => exact Or.inr (Or.inl List.nil_prefix) + | cons d t => + by_cases h : b = d + · subst d + rcases ih t with h|h|⟨a,u,v,h|h⟩ + · exact Or.inl (by simpa only [List.cons_prefix_cons, true_and] using h) + · exact Or.inr (Or.inl (by simpa only [List.cons_prefix_cons, true_and] using h)) + · exact Or.inr (Or.inr ⟨b::a,u,v,Or.inl ⟨by simp [h.1],by simp [h.2]⟩⟩) + · exact Or.inr (Or.inr ⟨b::a,u,v,Or.inr ⟨by simp [h.1],by simp [h.2]⟩⟩) + · cases b <;> cases d + · exact False.elim (h rfl) + · exact Or.inr (Or.inr ⟨[],s,t,Or.inl ⟨rfl,rfl⟩⟩) + · exact Or.inr (Or.inr ⟨[],s,t,Or.inr ⟨rfl,rfl⟩⟩) + · exact False.elim (h rfl) + +theorem comparable_of_overlap (f : List Bool → ZFSet.{0}) + (hd : ∀ a u v : List Bool, ∀ p ∈ f (a ++ [false] ++ u), + p ∉ f (a ++ [true] ++ v)) + (s t : List Bool) (p : ZFSet.{0}) (hp : p ∈ f s) (hq : p ∈ f t) : + s <+: t ∨ t <+: s := by + rcases words_compare s t with h|h|⟨a,u,v,h|h⟩ + · exact Or.inl h + · exact Or.inr h + · exact False.elim (hd a u v p (h.1 ▸ hp) (h.2 ▸ hq)) + · exact False.elim (hd a v u p (h.2 ▸ hq) (h.1 ▸ hp)) + +theorem subset_iff_prefix (f : List Bool → ZFSet.{0}) + (hn : ∀ s, f s ≠ ∅) + (hm : ∀ s t, s <+: t → f t ⊆ f s) + (hd : ∀ a u v : List Bool, ∀ p ∈ f (a ++ [false] ++ u), + p ∉ f (a ++ [true] ++ v)) (s t : List Bool) : + f t ⊆ f s ↔ s <+: t := by + constructor + · intro h + obtain he|⟨p,hp⟩ := ZFSet.eq_empty_or_nonempty (f t) + · exact False.elim (hn t he) + rcases comparable_of_overlap f hd s t p (h hp) hp with hs|⟨u,hu⟩ + · exact hs + cases u with + | nil => + have he : t = s := by simpa only [List.append_nil] using hu + rw [←he] + | cons b u => + have hx : f (t ++ [!b]) ⊆ f t := hm _ _ ⟨[!b],rfl⟩ + obtain he|⟨q,hq⟩ := ZFSet.eq_empty_or_nonempty (f (t ++ [!b])) + · exact False.elim (hn _ he) + have hqs : q ∈ f s := h (hx hq) + have hqs' : q ∈ f (t ++ [b] ++ u) := by simpa only [List.append_assoc,List.singleton_append,hu] using hqs + cases b + · exact False.elim (hd t u [] q hqs' (by simpa using hq)) + · exact False.elim (hd t [] u q (by simpa using hq) hqs') + · exact hm s t + +end TuringRigidity.RegularTreeCompatibility + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeExtension.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeExtension.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4e107ac711a134a3c4e2e598e0ff23b029dfd0a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeExtension.lean @@ -0,0 +1,61 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularTreeRecovery +import OAI.Computability.DegreeRigidity.SetModels.InternalNameEvaluation + +namespace OAI + +namespace TuringRigidity.RegularTreeExtension +open TransitiveNameModel BoundedSetTheory CountableForcing InternalRegularOperations +open InternalRegularAlgebra InternalBooleanGeneric InternalBooleanDense RegularTreeFilter +open RegularTreeRecovery InternalCohen +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem extension_properties (M c : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + let N := genericExtensionSet M c G.carrier + Transitive N ∧ SourceT N ∧ M ⊆ N ∧ genericFilterSet c G.carrier ∈ N := by + let _ : Top (Conditions c) := ⟨Classical.choose G.nonempty⟩ + have ht : ⊤ ∈ G.carrier := Classical.choose_spec G.nonempty + exact ⟨genericExtensionSet_transitive M c hM G.carrier, + extension_sourceT M hM hT hc (InternalCollapse.orderSet_mem M hM hT hc) + (InternalCollapse.orderSet_pair c) G hG ht, + ground_inclusion_set M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht, + genericFilterSet_mem_extension M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc G.carrier ht⟩ + +theorem branch_extension_eq (M c B A : ZFSet.{0}) (f : List Bool → ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hAf : FunctionGraph conditions B A) + (hAs : ∀ s U, ZFSet.pair (wordCode s) U ∈ A ↔ U = f s) + (hf : ∀ s, f s ∈ B ∧ IsCode c (f s) ∧ f s ≠ ∅) + (hroot : f [] = c) + (hm : ∀ s t, s <+: t → f t ⊆ f s) + (hd : ∀ a u v : List Bool, ∀ p ∈ f (a ++ [false] ++ u), + p ∉ f (a ++ [true] ++ v)) + (hden : ∀ U, IsCode c U → U ≠ ∅ → ∃ s, f s ⊆ U) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + let W := pushFilter (RegularTreeFilter.branch c f hroot (fun s => (hf s).2.1) hm hd G) + AtomicForcing.GroundGeneric M W ∧ + genericExtensionSet M conditions W.carrier = genericExtensionSet M c G.carrier := by + let W := pushFilter (RegularTreeFilter.branch c f hroot (fun s => (hf s).2.1) hm hd G) + have hW := branch_ground_generic M c B A f hM hT hBM hAM hAf hAs hf hroot hm hd hden G hG + refine ⟨hW,?_⟩ + have hWM := conditions_mem M hM hT + obtain ⟨hN,hTN,hMN,hgN⟩ := extension_properties M c hM hT hc G hG + obtain ⟨hV,hTV,hMV,hwV⟩ := extension_properties M conditions hM hT hWM W hW + obtain ⟨B',_,_,S,hSM,hSs,k,hkM,_,hks,_⟩ := CountedRegularBasis.internal_basis M c hM hT hc + have hwN : genericFilterSet conditions W.carrier ∈ genericExtensionSet M c G.carrier := by + rw [branchFilterSet_eq c f hroot (fun s => (hf s).2.1) hm hd G B A (fun s => (hf s).1) hAs] + exact branchSet_mem _ B A _ hN hTN (hMN hBM) (hMN hAM) hgN + have hgV : genericFilterSet c G.carrier ∈ genericExtensionSet M conditions W.carrier := by + rw [originalFilterSet_eq c f hroot (fun s => (hf s).2.1) hm hd G M B A S k + hM hT hc hBM hAM (fun s => (hf s).1) (fun s => (hf s).2.2) hAs hden + (fun p hp => (hSs _).mpr ⟨p,hp,rfl⟩) hks hG] + exact recoverySet_mem _ c B A S k _ hV hTV (hMV hc) (hMV hBM) (hMV hAM) (hMV hSM) (hMV hkM) hwV + apply ZFSet.ext; intro x + exact ⟨fun hx => InternalNameEvaluation.extension_subset M _ hN hTN hMN W.carrier hwN hx, + fun hx => InternalNameEvaluation.extension_subset M _ hV hTV hMV G.carrier hgV hx⟩ + +end TuringRigidity.RegularTreeExtension + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeFilter.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeFilter.lean new file mode 100644 index 0000000000000000000000000000000000000000..a236d1d90e0931baf66189c8c4faec3519243d28 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeFilter.lean @@ -0,0 +1,104 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularTreeCompatibility +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenFilters + +namespace OAI + +namespace TuringRigidity.RegularTreeFilter +open TransitiveNameModel BoundedSetTheory CountableForcing InternalRegularOperations +open InternalRegularAlgebra InternalBooleanGeneric InternalBooleanDense InternalBooleanSyntax +open InternalCohen +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem refines_condition (c U p : ZFSet.{0}) (hU : IsCode c U) (hU0 : U ≠ ∅) + (hUp : U ⊆ basicCode c p) : ∃ r ∈ U, p ⊆ r := by + obtain he|⟨q,hq⟩ := ZFSet.eq_empty_or_nonempty U + · exact False.elim (hU0 he) + have hb : q ∈ regular c (CohenInternalDecision.below c {p}) := hUp hq + obtain ⟨r,hr,hqr⟩ := (mem_regular _ _ _).mp hb |>.2 q (hU.1 hq) (fun _ h => h) + obtain ⟨hrc,s,hs,hsr⟩ := ZFSet.mem_sep.mp hr + have hsp := ZFSet.mem_singleton.mp hs + exact ⟨r,code_lower c U hU q hq r hrc hqr,hsp ▸ hsr⟩ + +noncomputable def branch (c : ZFSet.{0}) (f : List Bool → ZFSet.{0}) + (hroot : f [] = c) (hcode : ∀ s, IsCode c (f s)) + (hm : ∀ s t, s <+: t → f t ⊆ f s) + (hd : ∀ a u v : List Bool, ∀ p ∈ f (a ++ [false] ++ u), + p ∉ f (a ++ [true] ++ v)) + (G : GenericFilter (Conditions c)) : GenericFilter CohenBorelForcing.Condition where + carrier := {s | Hit G (f s.word)} + nonempty := by + obtain ⟨p,hp⟩ := G.nonempty + exact ⟨⟨[]⟩,p,hp,hroot.symm ▸ label_mem c p⟩ + upper := by + intro p q hpq hp + obtain ⟨r,hr,hrp⟩ := hp + exact ⟨r,hr,hm q.word p.word hpq hrp⟩ + directed := by + intro p q hp hq + obtain ⟨r,hr,hrp⟩ := hp + obtain ⟨s,hs,hsq⟩ := hq + obtain ⟨t,_,htr,hts⟩ := G.directed hr hs + have htp := code_lower c (f p.word) (hcode _) _ hrp _ (label_mem c t) htr + have htq := code_lower c (f q.word) (hcode _) _ hsq _ (label_mem c t) hts + rcases RegularTreeCompatibility.comparable_of_overlap f hd _ _ _ htp htq with h|h + · exact ⟨q,⟨s,hs,hsq⟩,h,le_rfl⟩ + · exact ⟨p,⟨r,hr,hrp⟩,le_rfl,h⟩ + +noncomputable def nodeFamily (B A D : ZFSet.{0}) : ZFSet.{0} := + B.sep (fun U => ∃ w ∈ D, ZFSet.pair w U ∈ A) + +theorem nodeFamily_mem (M B A D : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hB : B ∈ M) (hA : A ∈ M) (hD : D ∈ M) : nodeFamily B A D ∈ M := by + simpa only [nodeFamily,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ] using + sep_mem M hM hT.separation.finitePrefix.bounded (.existsMem 1 (.pairMem 0 1 3)) + (cons D (fun _ => A)) (by intro i; cases i <;> assumption) hB + +theorem nodeFamily_dense (c B A D : ZFSet.{0}) (f : List Bool → ZFSet.{0}) + (hf : ∀ s, f s ∈ B ∧ IsCode c (f s) ∧ f s ≠ ∅) + (hA : ∀ s U, ZFSet.pair (wordCode s) U ∈ A ↔ U = f s) + (hm : ∀ s t, s <+: t → f t ⊆ f s) + (hden : ∀ U, IsCode c U → U ≠ ∅ → ∃ s, f s ⊆ U) + (hD : Dense {p : CohenBorelForcing.Condition | wordCode p.word ∈ D}) : + Dense {p : Conditions c | label c p ∈ ZFSet.sUnion (nodeFamily B A D)} := by + intro p + have hpB := mem_basicCode c _ (label_mem c p) + have hp0 : basicCode c (label c p) ≠ ∅ := fun he => ZFSet.notMem_empty _ (he ▸ hpB) + obtain ⟨s,hs⟩ := hden _ (regular_isCode c _) hp0 + obtain ⟨t,ht,htD⟩ := hD ⟨s⟩ + have htp : f t.word ⊆ basicCode c (label c p) := fun _ h => hs (hm s t.word ht h) + obtain ⟨r,hr,hpr⟩ := refines_condition c _ _ (hf _).2.1 (hf _).2.2 htp + obtain ⟨r,rfl⟩ := label_surjective c ((hf _).2.1.1 hr) + exact ⟨r,hpr,ZFSet.mem_sUnion.mpr ⟨f t.word, + ZFSet.mem_sep.mpr ⟨(hf _).1,wordCode t.word,htD,(hA _ _).mpr rfl⟩,hr⟩⟩ + +theorem branch_ground_generic (M c B A : ZFSet.{0}) (f : List Bool → ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hBM : B ∈ M) (hAM : A ∈ M) + (hAf : FunctionGraph conditions B A) + (hAs : ∀ s U, ZFSet.pair (wordCode s) U ∈ A ↔ U = f s) + (hf : ∀ s, f s ∈ B ∧ IsCode c (f s) ∧ f s ≠ ∅) + (hroot : f [] = c) + (hm : ∀ s t, s <+: t → f t ⊆ f s) + (hd : ∀ a u v : List Bool, ∀ p ∈ f (a ++ [false] ++ u), + p ∉ f (a ++ [true] ++ v)) + (hden : ∀ U, IsCode c U → U ≠ ∅ → ∃ s, f s ⊆ U) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) : + AtomicForcing.GroundGeneric M + (pushFilter (branch c f hroot (fun s => (hf s).2.1) hm hd G)) := by + apply (groundGeneric_iff M _).mpr + intro D hDM hD + obtain ⟨p,hp,hpD⟩ := hG (ZFSet.sUnion (nodeFamily B A D)) + (union_mem M hM hT.union (nodeFamily_mem M B A D hM hT hBM hAM hDM)) + (nodeFamily_dense c B A D f hf hAs hm hden hD) + obtain ⟨U,hUF,hpU⟩ := ZFSet.mem_sUnion.mp hpD + obtain ⟨_,w,hw,hwU⟩ := ZFSet.mem_sep.mp hUF + obtain ⟨w',hw',U',_,he⟩ := hAf.1 _ hwU + have hwc : w ∈ conditions := (ZFSet.pair_inj.mp he).1 ▸ hw' + obtain ⟨s,hs⟩ := (prefix_iff_wordCode w).mp ((mem_conditions w).mp hwc) + have hUs : U = f s := (hAs s U).mp (hs.symm ▸ hwU) + refine ⟨⟨s⟩,?_,hs.symm ▸ hw⟩ + rw [pull_push] + exact ⟨p,hp,hUs ▸ hpU⟩ + +end TuringRigidity.RegularTreeFilter + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeRecovery.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeRecovery.lean new file mode 100644 index 0000000000000000000000000000000000000000..313b0dabcee2ff0e38627af1ca31abadfc0c4670 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeRecovery.lean @@ -0,0 +1,116 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularTreeCofinality + +namespace OAI + +namespace TuringRigidity.RegularTreeRecovery +open TransitiveNameModel BoundedSetTheory CountableForcing InternalRegularOperations +open InternalRegularAlgebra InternalBooleanGeneric InternalBooleanDense RegularTreeFilter +open RegularTreeCofinality InternalCohen +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +noncomputable def branchSet (B A g : ZFSet.{0}) : ZFSet.{0} := + conditions.sep (fun s => ∃ U ∈ B, ZFSet.pair s U ∈ A ∧ ∃ p ∈ g, p ∈ U) + +theorem branchSet_mem (N B A g : ZFSet.{0}) (hN : Transitive N) (hT : SourceT N) + (hB : B ∈ N) (hA : A ∈ N) (hg : g ∈ N) : branchSet B A g ∈ N := by + let e := cons B (cons A (fun _ => g)) + have he : ∀ i, e i ∈ N := by intro i; rcases i with _|_|i; exact hB; exact hA; exact hg + simpa only [branchSet,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] using + sep_mem N hN hT.separation.finitePrefix.bounded + (.existsMem 1 (.conj (.pairMem 1 0 3) (.existsMem 4 (.member 0 1)))) e he + (conditions_mem N hN hT) + +noncomputable def recoverySet (c B A S k w : ZFSet.{0}) : ZFSet.{0} := + c.sep (fun p => ∃ U ∈ B, ∃ V ∈ S, ∃ s ∈ w, + ZFSet.pair s U ∈ A ∧ ZFSet.pair p V ∈ k ∧ U ⊆ V) + +theorem recoverySet_mem (N c B A S k w : ZFSet.{0}) (hN : Transitive N) (hT : SourceT N) + (hc : c ∈ N) (hB : B ∈ N) (hA : A ∈ N) (hS : S ∈ N) (hk : k ∈ N) (hw : w ∈ N) : + recoverySet c B A S k w ∈ N := by + let e := cons B (cons S (cons w (cons A (fun _ => k)))) + have he : ∀ i, e i ∈ N := by + intro i; rcases i with _|_|_|_|i; exact hB; exact hS; exact hw; exact hA; exact hk + simpa only [recoverySet,Formula.Eval,Formula.eval_pairMem,Formula.eval_subset, + cons_zero,cons_succ,e] using + sep_mem N hN hT.separation.finitePrefix.bounded + (.existsMem 1 (.existsMem 3 (.existsMem 5 + (.conj (.pairMem 0 2 7) (.conj (.pairMem 3 1 8) (.subset 2 1)))))) e he hc + +variable (c : ZFSet.{0}) (f : List Bool → ZFSet.{0}) +variable (hroot : f [] = c) (hcode : ∀ s, IsCode c (f s)) +variable (hm : ∀ s t, s <+: t → f t ⊆ f s) +variable (hd : ∀ a u v : List Bool, ∀ p ∈ f (a ++ [false] ++ u), + p ∉ f (a ++ [true] ++ v)) +variable (G : GenericFilter (Conditions c)) + +theorem word_mem (s : List Bool) : + wordCode s ∈ genericFilterSet conditions (pushFilter (RegularTreeFilter.branch c f hroot hcode hm hd G)).carrier ↔ + Hit G (f s) := by + rw [mem_genericFilterSet] + constructor + · rintro ⟨p,hp,hps⟩ + have he : p = conditionEquiv ⟨s⟩ := label_injective conditions (hps.trans (label_encodeCondition ⟨s⟩).symm) + subst p + simpa only [pushFilter,OrderIso.symm_apply_apply,Set.mem_ofPred_eq,RegularTreeFilter.branch] using hp + · intro h + exact ⟨conditionEquiv ⟨s⟩,by simpa only [pushFilter,OrderIso.symm_apply_apply,Set.mem_ofPred_eq,RegularTreeFilter.branch] using h, + label_encodeCondition ⟨s⟩⟩ + +theorem branchFilterSet_eq (B A : ZFSet.{0}) + (hfB : ∀ s, f s ∈ B) + (hAs : ∀ s U, ZFSet.pair (wordCode s) U ∈ A ↔ U = f s) : + genericFilterSet conditions (pushFilter (RegularTreeFilter.branch c f hroot hcode hm hd G)).carrier = + branchSet B A (genericFilterSet c G.carrier) := by + apply ZFSet.ext; intro w + constructor + · intro hw + obtain ⟨p,_,he⟩ := (mem_genericFilterSet _ _ w).mp hw + have hwc : w ∈ conditions := he ▸ label_mem conditions p + obtain ⟨s,hs⟩ := (prefix_iff_wordCode w).mp ((mem_conditions w).mp hwc) + have hhit := (word_mem c f hroot hcode hm hd G s).mp (hs.symm ▸ hw) + obtain ⟨p,hp,hps⟩ := hhit + exact ZFSet.mem_sep.mpr ⟨hwc,f s,hfB s,hs ▸ (hAs s _).mpr rfl, + label c p,(mem_genericFilterSet c _ _).mpr ⟨p,hp,rfl⟩,hps⟩ + · intro hw + obtain ⟨hwc,U,hUB,hwU,p,hpg,hpU⟩ := ZFSet.mem_sep.mp hw + obtain ⟨s,hs⟩ := (prefix_iff_wordCode w).mp ((mem_conditions w).mp hwc) + have hU := (hAs s U).mp (hs.symm ▸ hwU) + obtain ⟨p,hp,rfl⟩ := (mem_genericFilterSet c _ p).mp hpg + exact hs ▸ (word_mem c f hroot hcode hm hd G s).mpr ⟨p,hp,hU ▸ hpU⟩ + +theorem originalFilterSet_eq (M B A S k : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hB : B ∈ M) (hA : A ∈ M) + (hfB : ∀ s, f s ∈ B) (hf0 : ∀ s, f s ≠ ∅) + (hAs : ∀ s U, ZFSet.pair (wordCode s) U ∈ A ↔ U = f s) + (hden : ∀ U, IsCode c U → U ≠ ∅ → ∃ s, f s ⊆ U) + (hSs : ∀ p ∈ c, basicCode c p ∈ S) + (hks : ∀ p ∈ c, ∀ U, ZFSet.pair p U ∈ k ↔ U = basicCode c p) + (hG : AtomicForcing.GroundGeneric M G) : + genericFilterSet c G.carrier = recoverySet c B A S k + (genericFilterSet conditions (pushFilter (RegularTreeFilter.branch c f hroot hcode hm hd G)).carrier) := by + apply ZFSet.ext; intro p + constructor + · intro hp + obtain ⟨p,hpG,rfl⟩ := (mem_genericFilterSet c _ p).mp hp + have hhit := (hit_basic_iff M c hM hT hc G hG p).mpr hpG + obtain ⟨s,hs,hsB⟩ := (hit_iff_node M c B A _ f hM hT hc hB hA + (basicCode_mem M c _ hM hT hc (label_mem c p)) (regular_isCode c _) + (fun s => ⟨hfB s,hcode s,hf0 s⟩) hAs hden G hG).mp hhit + exact ZFSet.mem_sep.mpr ⟨label_mem c p,f s,hfB s,basicCode c (label c p),hSs _ (label_mem c p), + wordCode s,(word_mem c f hroot hcode hm hd G s).mpr hs,(hAs s _).mpr rfl, + (hks _ (label_mem c p) _).mpr rfl,hsB⟩ + · intro hp + obtain ⟨hpc,U,_,V,_,s,hsw,hsU,hpV,hUV⟩ := ZFSet.mem_sep.mp hp + obtain ⟨p,rfl⟩ := label_surjective c hpc + have hV := (hks _ (label_mem c p) V).mp hpV + obtain ⟨q,_,hqs⟩ := (mem_genericFilterSet _ _ s).mp hsw + have hsc : s ∈ conditions := hqs ▸ label_mem conditions q + obtain ⟨t,ht⟩ := (prefix_iff_wordCode s).mp ((mem_conditions s).mp hsc) + have hU := (hAs t U).mp (ht.symm ▸ hsU) + obtain ⟨r,hr,hrt⟩ := (word_mem c f hroot hcode hm hd G t).mp (ht.symm ▸ hsw) + have hhit : Hit G (basicCode c (label c p)) := ⟨r,hr,hV ▸ hUV (hU.symm ▸ hrt)⟩ + exact (mem_genericFilterSet c _ _).mpr ⟨p,(hit_basic_iff M c hM hT hc G hG p).mp hhit,rfl⟩ + +end TuringRigidity.RegularTreeRecovery + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeRun.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeRun.lean new file mode 100644 index 0000000000000000000000000000000000000000..57455d908059635a92aeef0cf452e7d9f5c29309 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RegularTreeRun.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DegreeRigidity.SetModels.RegularBinaryTree +import OAI.Computability.DegreeRigidity.SetModels.ModelIterationFormula + +namespace OAI + +namespace TuringRigidity.RegularTreeRun +open TransitiveNameModel BoundedSetTheory InternalProjectedGeneric RegularBinaryTree + +noncomputable def bit (w i : ZFSet.{0}) : Bool := by + classical + exact decide (ZFSet.pair i (InternalCohen.bitSet true) ∈ w) + +theorem bit_word (s : List Bool) (n : ℕ) (hn : n < s.length) : + bit (InternalCohen.wordCode s) (natSet n) = s[n] := by + classical + simp only [bit,InternalCohen.pair_mem_wordCode] + cases h : s[n] <;> simp [h,hn] + +noncomputable def run (c B T : ZFSet.{0}) (E : ℕ → ZFSet.{0}) (w : ZFSet.{0}) : ℕ → ZFSet.{0} + | 0 => c + | n+1 => children B T (run c B T E w n) (E n) (bit w (natSet n)) + +theorem run_positive (c B T : ZFSet.{0}) (E : ℕ → ZFSet.{0}) (w : ZFSet.{0}) + (hc : c ∈ positive B) + (hf : FunctionGraph (ZFSet.prod (positive B) B) (ZFSet.prod (positive B) (positive B)) T) + (hE : ∀ n, E n ∈ B) : ∀ n, run c B T E w n ∈ positive B := by + intro n; induction n with + | zero => exact hc + | succ n ih => exact (children_spec B T _ _ hf ih (hE n)).1 _ + +theorem run_take (c B T : ZFSet.{0}) (E : ℕ → ZFSet.{0}) (s : List Bool) + (n : ℕ) (hn : n ≤ s.length) : + run c B T E (InternalCohen.wordCode s) n = tree c B T E (s.take n) := by + induction n with + | zero => simp only [run,List.take_zero,tree_nil] + | succ n ih => + have hlt : n < s.length := hn + rw [run,List.take_succ_eq_append_getElem hlt,tree_append,ih (Nat.le_of_lt hlt), + List.length_take,Nat.min_eq_left (Nat.le_of_lt hlt),bit_word s n hlt] + +theorem run_word (c B T : ZFSet.{0}) (E : ℕ → ZFSet.{0}) (s : List Bool) : + run c B T E (InternalCohen.wordCode s) s.length = tree c B T E s := by + simpa only [List.take_length] using run_take c B T E s s.length le_rfl + +def stepFormula (B P X Y T E w b1 i U V : ℕ) : Formula := + .existsMem B (.existsMem (P+1) (.existsMem (P+2) + (.existsMem (X+3) (.existsMem (Y+4) + (.conj (.orderedPair 1 (U+5) 4) (.conj (.orderedPair 0 3 2) + (.conj (.pairMem (i+5) 4 (E+5)) (.conj (.pairMem 1 0 (T+5)) + (.disj (.conj (.pairMem (i+5) (b1+5) (w+5)) (.equal (V+5) 2)) + (.conj (.neg (.pairMem (i+5) (b1+5) (w+5))) (.equal (V+5) 3))))))))))) + +theorem stepFormula_spec (B T : ZFSet.{0}) (E : ℕ → ZFSet.{0}) (w U V : ZFSet.{0}) (n : ℕ) + (hf : FunctionGraph (ZFSet.prod (positive B) B) (ZFSet.prod (positive B) (positive B)) T) + (hU : U ∈ positive B) (hE : ∀ n, E n ∈ B) + (b p x y t e word b1 i u v : ℕ) (env : ℕ → ZFSet.{0}) + (hb : env b = B) (hp : env p = positive B) + (hx : env x = ZFSet.prod (positive B) B) (hy : env y = ZFSet.prod (positive B) (positive B)) + (ht : env t = T) (he : env e = orbitGraph E) (hw : env word = w) + (h1 : env b1 = InternalCohen.bitSet true) (hi : env i = natSet n) + (hu : env u = U) (hv : env v = V) : + (stepFormula b p x y t e word b1 i u v).Eval env ↔ + V = children B T U (E n) (bit w (natSet n)) := by + classical + simp only [stepFormula,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + Formula.eval_disj,cons_zero,cons_succ,hb,hp,hx,hy,ht,he,hw,h1,hi,hu,hv] + constructor + · rintro ⟨D,_,L,_,R,_,a,_,z,_,ha,hz,hED,haz,hout⟩ + obtain rfl := (orbitGraph_pair E n D).mp hED + subst a; subst z + obtain ⟨hL,hR⟩ := children_unique B T U (E n) L R hf hU (hE n) haz + rcases hout with ⟨hbit,hV⟩|⟨hbit,hV⟩ + · simpa [bit,hbit] using hV.trans hR + · simpa [bit,hbit] using hV.trans hL + · intro hV + have hc := children_spec B T U (E n) hf hU (hE n) + refine ⟨E n,hE n,children B T U (E n) false,hc.1 false, + children B T U (E n) true,hc.1 true,ZFSet.pair U (E n), + ZFSet.pair_mem_prod.mpr ⟨hU,hE n⟩,_,ZFSet.pair_mem_prod.mpr ⟨hc.1 false,hc.1 true⟩, + rfl,rfl,(orbitGraph_pair E n _).mpr rfl,hc.2,?_⟩ + by_cases hbit : ZFSet.pair (natSet n) (InternalCohen.bitSet true) ∈ w + · exact Or.inl ⟨hbit,by simpa [bit,hbit] using hV⟩ + · exact Or.inr ⟨hbit,by simpa [bit,hbit] using hV⟩ + +end TuringRigidity.RegularTreeRun + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RelationCoding.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RelationCoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..2fac6cee772df630ab3dcf31d2ed103057d7f604 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RelationCoding.lean @@ -0,0 +1,112 @@ +import OAI.Computability.DegreeRigidity.Effective.SetCoding + +namespace OAI + +namespace TuringRigidity.RelationCoding +open IndependentFamily SetCoding + +theorem tuple_join_le_eq {n : ℕ} {S : Type*} (b : Degree) + (index : (Fin n × S) → ℕ) (hinj : Function.Injective index) + {v w : Fin n → S} + (he : Finset.univ.sup (fun i => column b (index (i, v i))) ≤ + Finset.univ.sup (fun i => column b (index (i, w i)))) : v = w := by + classical + funext i + let F := Finset.univ.image (fun j => index (j, w j)) + have hl : column b (index (i, v i)) ≤ F.sup (column b) := by + have hv : column b (index (i, v i)) ≤ + Finset.univ.sup (fun j => column b (index (j, v j))) := Finset.le_sup (f := fun j => column b (index (j, v j))) (Finset.mem_univ i) + simpa [F, Finset.sup_image, Function.comp_def] using hv.trans he + have hm := (independence b ⊥ ⊥ bot_le bot_le (index (i, v i)) F).mp (by simpa using hl) + obtain ⟨j, _, hj⟩ := Finset.mem_image.mp hm.2 + have heij := hinj hj + have hji : j = i := congrArg Prod.fst heij + subst j + exact (congrArg Prod.snd heij).symm + +theorem tuple_join_injective {n : ℕ} {S : Type*} (b : Degree) + (index : (Fin n × S) → ℕ) (hinj : Function.Injective index) : + Function.Injective (fun v : Fin n → S => + Finset.univ.sup (fun i => column b (index (i, v i)))) := + fun _ _ h => tuple_join_le_eq b index hinj h.le + +structure RelationCode (n : ℕ) where + coordinates : Fin n → SetCode + tuples : AntichainCode + +def RelationCode.Holds {n : ℕ} (p : RelationCode n) (v : Fin n → Degree) : Prop := + ∃ c : Fin n → Degree, + (∀ i, (p.coordinates i).Graph (v i) (c i)) ∧ + p.tuples.Holds (Finset.univ.sup c) + +theorem countable_relation_coding (n : ℕ) (R : Set (Fin n → Degree)) + (hR : R.Countable) : + ∃ p : RelationCode n, ∀ v, p.Holds v ↔ v ∈ R := by + classical + let P : Fin n → Set Degree := fun i => (fun v => v i) '' R + let S : Set Degree := ⋃ i, P i + have hP : ∀ i, (P i).Countable := fun i => hR.image _ + have hS : S.Countable := Set.countable_iUnion hP + have hPS : ∀ i, P i ⊆ S := fun i => Set.subset_iUnion P i + have : Countable S := hS.to_subtype + let := Encodable.ofCountable (Fin n × S) + let index : Fin n × S → ℕ := Encodable.encode + have hinj : Function.Injective index := Encodable.encode_injective + obtain ⟨b, hb⟩ := CountableBound.countable_bounded S hS + let lift : ∀ i, P i → S := fun i a => ⟨a.val, hPS i a.property⟩ + let idx : ∀ i, P i → ℕ := fun i a => index (i, lift i a) + have hidx : ∀ i, Function.Injective (idx i) := by + intro i a d he + apply Subtype.ext + exact congrArg (fun t : Fin n × S => t.2.val) (hinj he) + have hp : ∀ i, ∃ p : SetCode, p.bound = b ∧ + (∀ x c, p.Graph x c ↔ ∃ a : P i, a.val = x ∧ column b (idx i a) = c) ∧ + ∀ x, p.Holds x ↔ x ∈ P i := by + intro i + exact codes_with_tags (P i) (hP i) b (fun x hx => hb x (hPS i hx)) (idx i) (hidx i) + choose p hpbound hpgraph hpholds using hp + let tuple : R → (Fin n → S) := fun v i => ⟨v.val i, hPS i ⟨v.val, v.property, rfl⟩⟩ + let code : (Fin n → S) → Degree := fun v => + Finset.univ.sup (fun i => column b (index (i, v i))) + let T : Set Degree := Set.range (fun v : R => code (tuple v)) + have : Countable R := hR.to_subtype + have hT : T.Countable := Set.countable_range _ + have hanti : ∀ x ∈ T, ∀ y ∈ T, x ≤ y → x = y := by + rintro x ⟨v, rfl⟩ y ⟨w, rfl⟩ hle + have he : tuple v = tuple w := tuple_join_le_eq b index hinj hle + exact congrArg code he + obtain ⟨pt, hpt⟩ := exists_antichainCode T hT hanti + let q : RelationCode n := ⟨p, pt⟩ + refine ⟨q, ?_⟩ + intro v + constructor + · rintro ⟨c, hc, ht⟩ + have hh : ∀ i, ∃ a : P i, a.val = v i ∧ column b (idx i a) = c i := by + intro i + exact (hpgraph i _ _).mp (hc i) + choose a ha hac using hh + let u : Fin n → S := fun i => lift i (a i) + have hu : code u = Finset.univ.sup c := by + apply congrArg (fun f : Fin n → Degree => Finset.univ.sup f) + funext i + exact hac i + obtain ⟨w, hw⟩ := (hpt _).mp ht + have htu : tuple w = u := tuple_join_injective b index hinj (hw.trans hu.symm) + have hvw : w.val = v := by + funext i + have he := congrArg (fun f : Fin n → S => (f i).val) htu + exact he.trans (ha i) + exact hvw ▸ w.property + · intro hv + let w : R := ⟨v, hv⟩ + let c : Fin n → Degree := fun i => column b (index (i, tuple w i)) + refine ⟨c, ?_, ?_⟩ + · intro i + apply (hpgraph i _ _).mpr + exact ⟨⟨v i, ⟨v, hv, rfl⟩⟩, rfl, rfl⟩ + · apply (hpt _).mpr + exact ⟨w, rfl⟩ + +end TuringRigidity.RelationCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RelationCollapse.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RelationCollapse.lean new file mode 100644 index 0000000000000000000000000000000000000000..16b107ab66960ddb9115f612bd9e43d87e917708 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RelationCollapse.lean @@ -0,0 +1,137 @@ +import OAI.Computability.DegreeRigidity.SetModels.RelationHull +import OAI.Computability.DegreeRigidity.Syntax.CheckGraphConstruction + +namespace OAI + + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory RelationHull +universe u + +def Rel (d r : ZFSet.{u}) (y x : ZFSet.{u}) : Prop := y ∈ d ∧ ZFSet.pair y x ∈ r + +noncomputable def value (d r : ZFSet.{u}) (wf : WellFounded (Rel d r)) : ZFSet.{u} → ZFSet.{u} := + wf.fix (fun x ih => ZFSet.range (fun y : Conditions (predecessors d r x) => + ih (label (predecessors d r x) y) + ((mem_predecessors d r x _).mp (label_mem _ y)))) + +theorem mem_value (d r : ZFSet.{u}) (wf : WellFounded (Rel d r)) (x z : ZFSet.{u}) : + z ∈ value d r wf x ↔ ∃ y ∈ d, ZFSet.pair y x ∈ r ∧ z = value d r wf y := by + rw [value,WellFounded.fix_eq] + rw [ZFSet.mem_range] + constructor + · rintro ⟨y,hy⟩ + obtain ⟨hyd,hyx⟩ := (mem_predecessors d r x _).mp (label_mem _ y) + exact ⟨_,hyd,hyx,hy.symm⟩ + · rintro ⟨y,hyd,hyx,rfl⟩ + obtain ⟨s,rfl⟩ := label_surjective (predecessors d r x) + ((mem_predecessors _ _ _ _).mpr ⟨hyd,hyx⟩) + exact ⟨s,rfl⟩ + +def Step (d r f x v : ZFSet.{u}) : Prop := + (∀ z ∈ v, ∃ y ∈ d, ZFSet.pair y x ∈ r ∧ ZFSet.pair y z ∈ f) ∧ + (∀ y ∈ d, ZFSet.pair y x ∈ r → ∀ z, ZFSet.pair y z ∈ f → z ∈ v) + +def Graph (d r a b f : ZFSet.{u}) : Prop := + a ⊆ d ∧ Closed d r a ∧ + (∀ z ∈ f, ∃ x ∈ a, ∃ y ∈ b, z = ZFSet.pair x y) ∧ + (∀ x ∈ a, ∃ y ∈ b, ZFSet.pair x y ∈ f ∧ + ∀ z ∈ b, ZFSet.pair x z ∈ f → z = y) ∧ + (∀ x ∈ a, ∀ v ∈ b, ZFSet.pair x v ∈ f → + (∀ z ∈ v, ∃ y ∈ d, ZFSet.pair y x ∈ r ∧ ZFSet.pair y z ∈ f) ∧ + (∀ y ∈ d, ZFSet.pair y x ∈ r → ∀ z ∈ b, ZFSet.pair y z ∈ f → z ∈ v)) + +theorem Graph.correct {d r a b f : ZFSet.{u}} (wf : WellFounded (Rel d r)) + (h : Graph d r a b f) (x : ZFSet.{u}) (hx : x ∈ a) + (v : ZFSet.{u}) (hv : v ∈ b) (hfv : ZFSet.pair x v ∈ f) : + v = value d r wf x := by + induction x using wf.induction generalizing v with + | h x ih => + have hs := h.2.2.2.2 x hx v hv hfv + apply ZFSet.ext + intro z + rw [mem_value] + constructor + · intro hz + obtain ⟨y,hyd,hyx,hyz⟩ := hs.1 z hz + obtain ⟨w,hw,t,ht,heq⟩ := h.2.2.1 _ hyz + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + exact ⟨y,hyd,hyx,ih y ⟨hyd,hyx⟩ (h.2.1 x hx y hyd hyx) z ht hyz⟩ + · rintro ⟨y,hyd,hyx,rfl⟩ + have hya := h.2.1 x hx y hyd hyx + obtain ⟨w,hw,hyw,_⟩ := h.2.2.2.1 y hya + rw [←ih y ⟨hyd,hyx⟩ hya w hw hyw] + exact hs.2 y hyd hyx w hw hyw + +theorem Graph.mem_iff {d r a b f : ZFSet.{u}} (wf : WellFounded (Rel d r)) + (h : Graph d r a b f) (z : ZFSet.{u}) : + z ∈ f ↔ ∃ x ∈ a, z = ZFSet.pair x (value d r wf x) := by + constructor + · intro hz + obtain ⟨x,hx,y,hy,rfl⟩ := h.2.2.1 z hz + exact ⟨x,hx,congrArg (ZFSet.pair x) (h.correct wf x hx y hy hz)⟩ + · rintro ⟨x,hx,rfl⟩ + obtain ⟨y,hy,hxy,_⟩ := h.2.2.2.1 x hx + rw [←h.correct wf x hx y hy hxy] + exact hxy + +theorem Graph.unique {d r a b b' f g : ZFSet.{u}} (wf : WellFounded (Rel d r)) + (hf : Graph d r a b f) (hg : Graph d r a b' g) : f = g := by + apply ZFSet.ext + intro z + exact (hf.mem_iff wf z).trans (hg.mem_iff wf z).symm + +theorem graph_of_mem_iff (d r a f : ZFSet.{u}) (wf : WellFounded (Rel d r)) + (ha : a ⊆ d) (hc : Closed d r a) + (hf : ∀ z, z ∈ f ↔ ∃ x ∈ a, z = ZFSet.pair x (value d r wf x)) : + Graph d r a (iterUnion 2 f) f := by + have pair (x : ZFSet.{u}) (hx : x ∈ a) : ZFSet.pair x (value d r wf x) ∈ f := + (hf _).mpr ⟨x,hx,rfl⟩ + have valmem (x : ZFSet.{u}) (hx : x ∈ a) : value d r wf x ∈ iterUnion 2 f := + second_mem_doubleUnion (pair x hx) + refine ⟨ha,hc,?_,?_,?_⟩ + · intro z hz + obtain ⟨x,hx,rfl⟩ := (hf z).mp hz + exact ⟨x,hx,_,valmem x hx,rfl⟩ + · intro x hx + refine ⟨_,valmem x hx,pair x hx,?_⟩ + intro y _ hxy + obtain ⟨w,_,heq⟩ := (hf _).mp hxy + exact (ZFSet.pair_inj.mp heq).1 ▸ (ZFSet.pair_inj.mp heq).2 + · intro x hx v _ hxv + obtain ⟨w,hw,heq⟩ := (hf _).mp hxv + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + constructor + · intro z hz + obtain ⟨y,hyd,hyx,rfl⟩ := (mem_value d r wf x z).mp hz + exact ⟨y,hyd,hyx,pair y (hc x hx y hyd hyx)⟩ + · intro y hyd hyx z _ hyz + obtain ⟨t,_,heq⟩ := (hf _).mp hyz + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + exact (mem_value d r wf x _).mpr ⟨y,hyd,hyx,rfl⟩ + +namespace Code +open Formula + +def step (d r b f x v : ℕ) : Formula := + .conj (allMem v (.existsMem (d+1) + (.conj (pairMem 0 (x+2) (r+2)) (pairMem 0 1 (f+2))))) + (allMem d (imp (pairMem 0 (x+1) (r+1)) + (allMem (b+1) (imp (pairMem 1 0 (f+2)) (.member 0 (v+2)))))) + +def graph (d r a b f : ℕ) : Formula := + .conj (subset a d) (.conj (RelationHull.Code.closed d r a) + (.conj (functionGraph f a b) + (allMem a (allMem (b+1) (imp (pairMem 1 0 (f+2)) + (step (d+2) (r+2) (b+2) (f+2) 1 0)))))) + +theorem eval_graph (d r a b f : ℕ) (e : ℕ → ZFSet.{u}) : + (graph d r a b f).Eval e ↔ Graph (e d) (e r) (e a) (e b) (e f) := by + simp only [graph,step,Graph,Formula.Eval,eval_subset,RelationHull.Code.eval_closed, + eval_functionGraph,eval_allMem,eval_imp,eval_pairMem,cons_zero,cons_succ] + exact and_congr_right (fun _ => and_congr_right (fun _ => and_assoc)) +end Code + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RelationHull.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RelationHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..04f4f09bd8a18f723fcdb249fa34ec6b72208ae2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RelationHull.lean @@ -0,0 +1,177 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalHull + +namespace OAI + + +namespace TuringRigidity.RelationHull +open TransitiveNameModel BoundedSetTheory +universe u + +def Closed (d r b : ZFSet.{u}) : Prop := + ∀ x ∈ b, ∀ y ∈ d, ZFSet.pair y x ∈ r → y ∈ b + +namespace Code +open Formula + +def closed (d r b : ℕ) : Formula := + allMem b (allMem (d+1) (imp (pairMem 0 1 (r+2)) (.member 0 (b+2)))) + +theorem eval_closed (d r b : ℕ) (e : ℕ → ZFSet.{u}) : + (closed d r b).Eval e ↔ Closed (e d) (e r) (e b) := by + simp only [closed,Closed,eval_allMem,eval_imp,eval_pairMem,Formula.Eval,cons_zero,cons_succ] + +def member : Formula := allMem 2 + (imp (.conj (closed 4 5 0) (.member 2 0)) (.member 1 0)) + +theorem eval_member (z x q d r : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + member.Eval (cons z (cons x (cons q (cons d (cons r e))))) ↔ + ∀ b ∈ q, Closed d r b → x ∈ b → z ∈ b := by + simp only [member,eval_allMem,eval_imp,Formula.Eval,eval_closed,cons_zero,cons_succ] + exact forall_congr' (fun b => forall_congr' (fun _ => and_imp)) + +def isHull (b x q d r : ℕ) : Formula := + .conj (.member b q) (.conj (closed d r b) (.conj (.member x b) + (allMem q (imp (.conj (closed (d+1) (r+1) 0) (.member (x+1) 0)) (subset (b+1) 0))))) + +theorem eval_isHull (b x q d r : ℕ) (e : ℕ → ZFSet.{u}) : + (isHull b x q d r).Eval e ↔ e b ∈ e q ∧ Closed (e d) (e r) (e b) ∧ e x ∈ e b ∧ + ∀ a ∈ e q, Closed (e d) (e r) a → e x ∈ a → e b ⊆ a := by + simp only [isHull,Formula.Eval,eval_closed,eval_allMem,eval_imp,eval_subset,cons_zero,cons_succ] + simp only [and_imp] +end Code + +noncomputable def hull (d r q x : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∀ b ∈ q, Closed d r b → x ∈ b → z ∈ b) d + +theorem mem_hull (d r q x z : ZFSet.{u}) : + z ∈ hull d r q x ↔ z ∈ d ∧ ∀ b ∈ q, Closed d r b → x ∈ b → z ∈ b := ZFSet.mem_sep + +theorem hull_subset (d r q x : ZFSet.{u}) : hull d r q x ⊆ d := + fun _ h => (mem_hull _ _ _ _ _).mp h |>.1 + +theorem self_mem (d r q : ZFSet.{u}) {x : ZFSet.{u}} (hx : x ∈ d) : + x ∈ hull d r q x := (mem_hull _ _ _ _ _).mpr ⟨hx,fun _ _ _ h => h⟩ + +theorem hull_closed (d r q x : ZFSet.{u}) : Closed d r (hull d r q x) := by + intro y hy z hz hzy + exact (mem_hull _ _ _ _ _).mpr ⟨hz,fun b hb hbc hxb => + hbc y (((mem_hull _ _ _ _ _).mp hy).2 b hb hbc hxb) z hz hzy⟩ + +theorem hull_least (d r q x b : ZFSet.{u}) (hb : b ∈ q) + (hc : Closed d r b) (hx : x ∈ b) : hull d r q x ⊆ b := + fun _ hz => (mem_hull _ _ _ _ _).mp hz |>.2 b hb hc hx + +theorem hull_mem (M d r q : ZFSet.{u}) (hM : Transitive M) (hS : Separation M) + (hd : d ∈ M) (hr : r ∈ M) (hq : q ∈ M) {x : ZFSet.{u}} (hx : x ∈ M) : + hull d r q x ∈ M := by + let e := cons x (cons q (cons d (cons r (fun _ => r)))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hx + rcases i with _|i; exact hq + rcases i with _|i; exact hd + cases i <;> exact hr + have hs := sep_mem M hM hS Code.member e he hd + have eq : ZFSet.sep (fun z => Code.member.Eval (cons z e)) d = hull d r q x := by + apply ZFSet.ext + intro z + rw [ZFSet.mem_sep,mem_hull] + apply and_congr Iff.rfl + simpa only [e,cons] using Code.eval_member z x q d r (fun _ => r) + exact eq ▸ hs + +theorem isHull_iff (M d r q : ZFSet.{u}) (hM : Transitive M) (hS : Separation M) + (hd : d ∈ M) (hr : r ∈ M) (hqM : q ∈ M) + (hq : ∀ b, b ∈ q ↔ b ∈ M ∧ b ⊆ d) {x b : ZFSet.{u}} (hx : x ∈ d) : + (b ∈ q ∧ Closed d r b ∧ x ∈ b ∧ + ∀ a ∈ q, Closed d r a → x ∈ a → b ⊆ a) ↔ b = hull d r q x := by + have hh := hull_mem M d r q hM hS hd hr hqM (hM d hd x hx) + have hhq := (hq _).mpr ⟨hh,hull_subset d r q x⟩ + constructor + · rintro ⟨hb,hc,hxb,hmin⟩ + apply ZFSet.ext + intro z + exact ⟨fun hz => hmin _ hhq (hull_closed d r q x) (self_mem d r q hx) hz, + fun hz => hull_least d r q x b hb hc hxb hz⟩ + · rintro rfl + exact ⟨hhq,hull_closed d r q x,self_mem d r q hx, + fun a ha hc hx => hull_least d r q x a ha hc hx⟩ + +noncomputable def predecessors (d r x : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun y => ZFSet.pair y x ∈ r) d + +theorem mem_predecessors (d r x y : ZFSet.{u}) : + y ∈ predecessors d r x ↔ y ∈ d ∧ ZFSet.pair y x ∈ r := ZFSet.mem_sep + +theorem predecessors_mem (M : ZFSet.{u}) (hM : Transitive M) (hS : Separation M) + {d r x : ZFSet.{u}} (hd : d ∈ M) (hr : r ∈ M) (hx : x ∈ M) : + predecessors d r x ∈ M := by + simpa only [Formula.eval_pairMem,cons_zero,cons_succ,predecessors] using + sep_mem M hM hS (.pairMem 0 1 2) (cons x (fun _ => r)) + (by intro i; cases i <;> assumption) hd + +theorem collect_hulls (M d r q : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hR : SigmaReplacement M) + (hd : d ∈ M) (hr : r ∈ M) (hqM : q ∈ M) + (hq : ∀ b, b ∈ q ↔ b ∈ M ∧ b ⊆ d) {x : ZFSet.{u}} (hx : x ∈ d) : + ∃ b ∈ M, ∀ z, z ∈ b ↔ ∃ y ∈ predecessors d r x, hull d r q y = z := by + let e := cons q (cons d (fun _ => r)) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hqM + rcases i with _|i; exact hd + exact hr + apply replacement_image M hM hR (.bounded (Code.isHull 0 1 2 3 4)) e he + (predecessors_mem M hM hS hd hr (hM d hd x hx)) (hull d r q) + · intro y hy + exact hull_mem M d r q hM hS hd hr hqM (hM d hd y ((mem_predecessors _ _ _ _).mp hy).1) + · intro y hy b hb + change (Code.isHull 0 1 2 3 4).Realize M (cons b (cons y e)) ↔ _ + rw [Formula.absolute _ M hM _ (by + intro i; rcases i with _|i; exact hb + rcases i with _|i; exact hM d hd y ((mem_predecessors _ _ _ _).mp hy).1 + exact he i),Code.eval_isHull] + exact isHull_iff M d r q hM hS hd hr hqM hq ((mem_predecessors _ _ _ _).mp hy).1 + +theorem hull_unfold (M d r q : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hS : Separation M) (hR : SigmaReplacement M) + (hd : d ∈ M) (hr : r ∈ M) (hqM : q ∈ M) + (hq : ∀ b, b ∈ q ↔ b ∈ M ∧ b ⊆ d) {x : ZFSet.{u}} (hx : x ∈ d) (z : ZFSet.{u}) : + z ∈ hull d r q x ↔ z = x ∨ ∃ y ∈ predecessors d r x, z ∈ hull d r q y := by + obtain ⟨b,hb,hbdef⟩ := collect_hulls M d r q hM hS hR hd hr hqM hq hx + let a := ({x} : ZFSet.{u}) ∪ ZFSet.sUnion b + have ha : a ∈ M := binary_union_mem M hM hP hU + (singleton_mem M hM hP (hM d hd x hx)) (union_mem M hM hU hb) + have ha_def (w : ZFSet.{u}) : w ∈ a ↔ w = x ∨ ∃ y ∈ predecessors d r x, w ∈ hull d r q y := by + simp only [a,ZFSet.mem_union,ZFSet.mem_singleton,ZFSet.mem_sUnion] + constructor + · rintro (h|⟨v,hv,hw⟩) + · exact Or.inl h + · obtain ⟨y,hy,rfl⟩ := (hbdef v).mp hv + exact Or.inr ⟨y,hy,hw⟩ + · rintro (h|⟨y,hy,hw⟩) + · exact Or.inl h + · exact Or.inr ⟨_,(hbdef _).mpr ⟨y,hy,rfl⟩,hw⟩ + have had : a ⊆ d := by + intro w hw + rcases (ha_def w).mp hw with rfl|⟨y,_,hw⟩ + · exact hx + · exact hull_subset d r q y hw + have hac : Closed d r a := by + intro w hw v hv hvw + apply (ha_def v).mpr + rcases (ha_def w).mp hw with rfl|⟨y,hy,hw⟩ + · exact Or.inr ⟨v,(mem_predecessors _ _ _ _).mpr ⟨hv,hvw⟩,self_mem d r q hv⟩ + · exact Or.inr ⟨y,hy,hull_closed d r q y w hw v hv hvw⟩ + have hhq := (hq _).mpr ⟨hull_mem M d r q hM hS hd hr hqM (hM d hd x hx),hull_subset d r q x⟩ + constructor + · intro hz + exact (ha_def z).mp (hull_least d r q x a ((hq a).mpr ⟨ha,had⟩) hac + ((ha_def x).mpr (Or.inl rfl)) hz) + · rintro (rfl|⟨y,hy,hz⟩) + · exact self_mem d r q hx + · obtain ⟨hyd,hyx⟩ := (mem_predecessors _ _ _ _).mp hy + exact hull_least d r q y _ hhq (hull_closed d r q x) + (hull_closed d r q x x (self_mem d r q hx) y hyd hyx) hz + +end TuringRigidity.RelationHull + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RelationPresentation.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RelationPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..38e9f11a6951c9e5e63133fb779e500cf26fa8ba --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RelationPresentation.lean @@ -0,0 +1,144 @@ +import OAI.Computability.DegreeRigidity.Effective.AntichainDecoding +import OAI.Computability.DegreeRigidity.Computability.ArithmeticFinite +import OAI.Computability.DegreeRigidity.OrdinalCodes.IndexTuples + +namespace OAI + +namespace TuringRigidity.RelationPresentation +open IndexPresentation IndexTuples ArithmeticHierarchy AntichainDecoding +open SetCoding RelationCoding BoundedDecoding + +structure ACode where + bound : ℕ + left : ℕ + right : ℕ + +def ACode.Good (Y : Oracle) (p : ACode) : Prop := + Dom Y p.bound ∧ Dom Y p.left ∧ Dom Y p.right +noncomputable def ACode.decode (Y : Oracle) (p : ACode) : AntichainCode := + ⟨value Y p.bound, value Y p.left, value Y p.right⟩ +def ACode.Holds (Y : Oracle) (p : ACode) (x : ℕ) : Prop := + Antichain Y p.bound p.left p.right x + +theorem ACode.holds_iff {Y p x} (hp : ACode.Good Y p) (hx : Dom Y x) : + p.Holds Y x ↔ (p.decode Y).Holds (value Y x) := + antichain_iff hp.1 hp.2.1 hp.2.2 hx + +theorem ACode.sigma (Y : Oracle) (p : ACode) {x : ℕ → ℕ} (hx : Primrec x) : + Sigma Y 5 (fun v => p.Holds Y (x v)) := + antichain_sigma Y (Primrec.const _) (Primrec.const _) (Primrec.const _) hx + +theorem ACode.exists_code (Y : Oracle) (p : AntichainCode) (hp : AntichainBelow p (degree Y)) : + ∃ q : ACode, q.Good Y ∧ q.decode Y = p := by + obtain ⟨b, hb, eb⟩ := value_surjective Y p.bound hp.1 + obtain ⟨l, hl, el⟩ := value_surjective Y p.left hp.2.1 + obtain ⟨r, hr, er⟩ := value_surjective Y p.right hp.2.2 + exact ⟨⟨b,l,r⟩, ⟨hb,hl,hr⟩, by cases p; simp_all [ACode.decode]⟩ + +structure SCode where + bound : ℕ + tags : ACode + decorated : ACode + +def SCode.Good (Y : Oracle) (p : SCode) : Prop := + Dom Y p.bound ∧ p.tags.Good Y ∧ p.decorated.Good Y +noncomputable def SCode.decode (Y : Oracle) (p : SCode) : SetCode := + ⟨value Y p.bound, p.tags.decode Y, p.decorated.decode Y⟩ +def SCode.Graph (Y : Oracle) (p : SCode) (x c : ℕ) : Prop := + LE Y x p.bound ∧ p.tags.Holds Y c ∧ p.decorated.Holds Y (joinIndex x c) + +theorem SCode.graph_iff {Y p x c} (hp : SCode.Good Y p) (hx : Dom Y x) (hc : Dom Y c) : + p.Graph Y x c ↔ (p.decode Y).Graph (value Y x) (value Y c) := by + simp only [SCode.Graph, SetCode.Graph, SCode.decode, le_iff hx hp.1, + ACode.holds_iff hp.2.1 hc, ACode.holds_iff hp.2.2 (join_dom hx hc), join_value hx hc] + +theorem SCode.sigma (Y : Oracle) (p : SCode) {x c : ℕ → ℕ} + (hx : Primrec x) (hc : Primrec c) : Sigma Y 5 (fun v => p.Graph Y (x v) (c v)) := + (le_sigma Y hx (Primrec.const _)).raise.raise.and + ((p.tags.sigma Y hc).and (p.decorated.sigma Y (joinIndex_primrec.comp hx hc))) + +theorem SCode.exists_code (Y : Oracle) (p : SetCode) (hp : SetBelow p (degree Y)) : + ∃ q : SCode, q.Good Y ∧ q.decode Y = p := by + obtain ⟨b, hb, eb⟩ := value_surjective Y p.bound hp.1 + obtain ⟨t, ht, et⟩ := ACode.exists_code Y p.tags hp.2.1 + obtain ⟨d, hd, ed⟩ := ACode.exists_code Y p.decorated hp.2.2 + exact ⟨⟨b,t,d⟩, ⟨hb,ht,hd⟩, by cases p; simp_all [SCode.decode]⟩ + +structure RCode (n : ℕ) where + coordinates : Fin n → SCode + tuples : ACode + +def RCode.Good {n} (Y : Oracle) (p : RCode n) : Prop := + (∀ i, (p.coordinates i).Good Y) ∧ p.tuples.Good Y +noncomputable def RCode.decode {n} (Y : Oracle) (p : RCode n) : RelationCode n := + ⟨fun i => (p.coordinates i).decode Y, p.tuples.decode Y⟩ + +def RCode.Holds {n} (Y : Oracle) (p : RCode n) (v : ℕ) : Prop := + (∀ i : Fin n, Dom Y (entry i.val v)) ∧ ∃ t : ℕ, + (∀ i : Fin n, Dom Y (entry i.val t) ∧ + (p.coordinates i).Graph Y (entry i.val v) (entry i.val t)) ∧ + p.tuples.Holds Y (supIndex n t) + +theorem RCode.sigma {n} (Y : Oracle) (p : RCode n) : Sigma Y 5 (p.Holds Y) := by + let f := Primrec.fst.comp Primrec.unpair + let s := Primrec.snd.comp Primrec.unpair + have hd : Sigma Y 5 (fun v => ∀ i : Fin n, Dom Y (entry i.val v)) := + Form.finite_all (fun i => (dom_pi Y (entry_primrec i.val)).switch.raise.raise) + have hg : Sigma Y 5 (fun v => ∀ i : Fin n, Dom Y (entry i.val (Nat.unpair v).2) ∧ + (p.coordinates i).Graph Y (entry i.val (Nat.unpair v).1) (entry i.val (Nat.unpair v).2)) := + Form.finite_all (fun i => ((dom_pi Y ((entry_primrec i.val).comp s)).switch.raise.raise).and + ((p.coordinates i).sigma Y ((entry_primrec i.val).comp f) ((entry_primrec i.val).comp s))) + have ht := p.tuples.sigma Y ((supIndex_primrec n).comp s) + exact (hd.and ((hg.and ht).ex)).congr (fun v => by simp only [Nat.unpair_pair]; rfl) + +theorem RCode.holds_iff {n Y} {p : RCode n} (hp : p.Good Y) (v : ℕ) : + p.Holds Y v ↔ (∀ i : Fin n, Dom Y (entry i.val v)) ∧ + (p.decode Y).Holds (fun i => value Y (entry i.val v)) := by + unfold RCode.Holds + apply and_congr_right + intro hv + constructor + · rintro ⟨t, ht, htuple⟩ + refine ⟨fun i => value Y (entry i.val t), fun i => ?_, ?_⟩ + · exact (SCode.graph_iff (hp.1 i) (hv i) (ht i).1).mp (ht i).2 + · have h := (ACode.holds_iff hp.2 (sup_dom (fun i => (ht i).1))).mp htuple + simpa only [sup_value (fun i => (ht i).1), RCode.decode] using h + · rintro ⟨c, hc, ht⟩ + have hb : ∀ i, c i ≤ degree Y := by + intro i + exact (hc i).2.1.1.1.trans (value_below Y (p.coordinates i).tags.bound) + choose e he hev using (fun i => value_surjective Y (c i) (hb i)) + obtain ⟨t, het⟩ := tuple_surjective e + have hdom : ∀ i : Fin n, Dom Y (entry i.val t) := fun i => (het i) ▸ he i + have hval : (fun i : Fin n => value Y (entry i.val t)) = c := by + funext i + rw [het i, hev i] + refine ⟨t, fun i => ⟨hdom i, ?_⟩, ?_⟩ + · apply (SCode.graph_iff (hp.1 i) (hv i) (hdom i)).mpr + simpa only [het i, hev i, RCode.decode] using hc i + · apply (ACode.holds_iff hp.2 (sup_dom hdom)).mpr + rw [sup_value hdom, hval] + exact ht + +theorem RCode.exists_code {n} (Y : Oracle) (p : RelationCode n) + (hp : RelationBelow p (degree Y)) : ∃ q : RCode n, q.Good Y ∧ q.decode Y = p := by + choose c hc ec using (fun i => SCode.exists_code Y (p.coordinates i) (hp.1 i)) + obtain ⟨t, ht, et⟩ := ACode.exists_code Y p.tuples hp.2 + refine ⟨⟨c,t⟩, ⟨hc,ht⟩, ?_⟩ + cases p with + | mk coords tuples => + simp only [RCode.decode] + congr + · funext i + exact ec i + +theorem sigma5_decoding {n} (Y : Oracle) (p : RelationCode n) + (hp : RelationBelow p (degree Y)) : + Sigma Y 5 (fun v => (∀ i : Fin n, Dom Y (entry i.val v)) ∧ + p.Holds (fun i => value Y (entry i.val v))) := by + obtain ⟨q, hq, rfl⟩ := RCode.exists_code Y p hp + exact (q.sigma Y).congr (RCode.holds_iff hq) + +end TuringRigidity.RelationPresentation + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RestrictedName.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RestrictedName.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a24e0ed63816d506bbba00894393af00754547f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RestrictedName.lean @@ -0,0 +1,53 @@ +import OAI.Computability.DegreeRigidity.SetModels.NameUnionCode + +namespace OAI + +namespace TuringRigidity.RecursiveNames +open Set CountableForcing +universe u +variable {P : Type u} [Preorder P] + +abbrev Name.Entry (a : Name P) := Σ i : a.arity, {q : P // q ≤ a.tag i} + +noncomputable def Name.entryCode (l : P → ZFSet.{u}) (a : Name P) (s : a.Entry) : ZFSet.{u} := + ZFSet.pair ((a.child s.1).encode l) (l s.2.val) + +noncomputable def Name.support (l : P → ZFSet.{u}) (a : Name P) : ZFSet.{u} := + ZFSet.range (a.entryCode l) + +noncomputable def Name.restrict (l : P → ZFSet.{u}) (a : Name P) (B : ZFSet.{u}) : Name P := + .mk {s : a.Entry // a.entryCode l s ∈ B} (fun s => a.child s.val.1) (fun s => s.val.2.val) + +theorem Name.encode_restrict (l : P → ZFSet.{u}) (a : Name P) (B : ZFSet.{u}) + (hB : B ⊆ a.support l) : (a.restrict l B).encode l = B := by + apply ZFSet.ext + intro z + change z ∈ ZFSet.range _ ↔ _ + rw [ZFSet.mem_range] + constructor + · rintro ⟨s,hs⟩ + exact hs ▸ s.property + · intro hz + obtain ⟨s,hs⟩ := ZFSet.mem_range.mp (hB hz) + exact ⟨⟨s,hs ▸ hz⟩,hs⟩ + +theorem Name.mem_val_restrict (l : P → ZFSet.{u}) (a : Name P) (B : ZFSet.{u}) + (G : Set P) (x : ZFSet.{u}) : x ∈ (a.restrict l B).val G ↔ + ∃ i, ∃ q, q ≤ a.tag i ∧ ZFSet.pair ((a.child i).encode l) (l q) ∈ B ∧ + q ∈ G ∧ (a.child i).val G = x := by + rw [Name.restrict,Name.mem_val] + constructor + · rintro ⟨⟨⟨i,q,hq⟩,hB⟩,hG,hx⟩ + exact ⟨i,q,hq,hB,hG,hx⟩ + · rintro ⟨i,q,hq,hB,hG,hx⟩ + exact ⟨⟨⟨i,⟨q,hq⟩⟩,hB⟩,hG,hx⟩ + +theorem Name.val_restrict_subset (l : P → ZFSet.{u}) (a : Name P) (B : ZFSet.{u}) + (G : GenericFilter P) : (a.restrict l B).val G.carrier ⊆ a.val G.carrier := by + intro x hx + obtain ⟨i,q,hq,_,hqG,hx⟩ := (a.mem_val_restrict l B G.carrier x).mp hx + exact (a.mem_val_children G.carrier x).mpr ⟨i,G.upper hq hqG,hx⟩ + +end TuringRigidity.RecursiveNames + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/RestrictedOmegaRecursion.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/RestrictedOmegaRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f8ee3f77ce251daec272c1a09253b1f70bffe01 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/RestrictedOmegaRecursion.lean @@ -0,0 +1,105 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaRecursionSchemas + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible +open BoundedDefinability SetModelFunctions SentenceCoding +universe u + +theorem internal_omegaGraph_schemas (M : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) (hColl : SigmaCollection M) + (x : ZFSet.{u}) (hxM : x ∈ M) (hxo : x.IsOrdinal) : + ∃ f ∈ M, OmegaGraph M (insert x x) (iterUnion 2 f) f := by + have h1 : (1 : Ordinal.{u}).toZFSet ∈ M := by + rw [← Nat.cast_one,toZFSet_nat] + exact C.transitive _ (omega_mem M C.transitive C.separation C.infinity) _ ((mem_omega _).mpr ⟨1,rfl⟩) + obtain ⟨p,e,he,hp⟩ := uniform_omega_certificate_schemas M C hRep hColl + induction x using ZFSet.inductionOn with + | h x ih => + have cert (y f : ZFSet.{u}) (hy : y ∈ x) (hf : f ∈ M) := hp y (C.transitive x hxM y hy) f hf + obtain ⟨b,hb,hbdef⟩ := hRep p e he x hxM (by + intro y hy + obtain ⟨f,hf,hfg⟩ := ih y hy (C.transitive x hxM y hy) (hxo.mem hy) + refine ⟨f,hf,(cert y f hy hf).mpr + ⟨_,iterUnion_mem M C.transitive C.union hf 2,hfg⟩,?_⟩ + intro g hg hcg + obtain ⟨r,_,hgg⟩ := (cert y g hy hg).mp hcg + exact hgg.unique hfg) + have hbg (f : ZFSet.{u}) : f ∈ b ↔ + ∃ y ∈ x, ∃ r ∈ M, OmegaGraph M (insert y y) r f := by + constructor + · intro hf + have hfM := C.transitive b hb f hf + obtain ⟨y,hy,hc⟩ := (hbdef f hfM).mp hf + exact ⟨y,hy,(cert y f hy hfM).mp hc⟩ + · rintro ⟨y,hy,r,hr,hg⟩ + obtain ⟨f',hf',hg'⟩ := ih y hy (C.transitive x hxM y hy) (hxo.mem hy) + have heq := hg.unique hg' + have hfM : f ∈ M := heq ▸ hf' + exact (hbdef f hfM).mpr ⟨y,hy,(cert y f hy hfM).mpr ⟨r,hr,hg⟩⟩ + let g := ZFSet.sUnion b + have hgM : g ∈ M := union_mem M C.transitive C.union hb + have hg (z : ZFSet.{u}) : z ∈ g ↔ ∃ y ∈ x, z = ZFSet.pair y (omegaNext y) := by + constructor + · intro hz + obtain ⟨f,hf,hzf⟩ := ZFSet.mem_sUnion.mp hz + obtain ⟨y,hy,r,_,hfg⟩ := (hbg f).mp hf + obtain ⟨w,hw,hz⟩ := (hfg.mem_iff z).mp hzf + rcases ZFSet.mem_insert_iff.mp hw with rfl|hw + · exact ⟨w,hy,hz⟩ + · exact ⟨w,hxo.subset_of_mem hy hw,hz⟩ + · rintro ⟨y,hy,hz⟩ + obtain ⟨f,hf,hfg⟩ := ih y hy (C.transitive x hxM y hy) (hxo.mem hy) + exact ZFSet.mem_sUnion.mpr ⟨f,(hbg f).mpr + ⟨y,hy,_,iterUnion_mem M C.transitive C.union hf 2,hfg⟩, + (hfg.mem_iff z).mpr ⟨y,ZFSet.mem_insert_iff.mpr (Or.inl rfl),hz⟩⟩ + have hvalue : stageImage (1 : Ordinal.{u}).toZFSet x g = + (Ordinal.omega0 ^ x.rank).toZFSet := by + apply ZFSet.ext; intro z + rw [mem_stageImage,omegaPower_members,hxo.toZFSet_rank_eq] + apply or_congr_right + constructor + · rintro ⟨y,hy,w,hfw,hz⟩ + obtain ⟨v,_,hp⟩ := (hg _).mp hfw + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact ⟨y,hy,hz⟩ + · rintro ⟨y,hy,hz⟩ + exact ⟨y,hy,_,(hg _).mpr ⟨y,hy,rfl⟩,hz⟩ + have hpow : (Ordinal.omega0 ^ x.rank).toZFSet ∈ M := + hvalue ▸ stageImage_mem_context M C h1 hxM hgM + have hvM : omegaNext x ∈ M := by + rw [omegaNext,Ordinal.opow_add_one] + exact (ordinal_mul_internal_schemas M C.transitive C.pairing C.union C.power C.separation hRep _ Ordinal.omega0 hpow (toZFSet_omega.symm ▸ C.omega_mem)).1 + let f := g ∪ ({ZFSet.pair x (omegaNext x)} : ZFSet.{u}) + have hfM : f ∈ M := binary_union_mem M C.transitive C.pairing C.union hgM + (singleton_mem M C.transitive C.pairing (orderedPair_mem M C.transitive C.pairing hxM hvM)) + have hsucc : (insert x x).IsOrdinal := by + rw [← hxo.toZFSet_rank_eq,← Ordinal.toZFSet_add_one] + exact ZFSet.isOrdinal_toZFSet _ + refine ⟨f,hfM,omegaGraph_of_mem_iff_context M _ f C + (insert_self_mem M C.transitive C.pairing C.union hxM) hfM hsucc ?_⟩ + intro z + change z ∈ g ∪ ({ZFSet.pair x (omegaNext x)} : ZFSet.{u}) ↔ _ + rw [ZFSet.mem_union,ZFSet.mem_singleton,hg] + constructor + · rintro (⟨y,hy,hz⟩|hz) + · exact ⟨y,ZFSet.mem_insert_of_mem _ hy,hz⟩ + · exact ⟨x,ZFSet.mem_insert_iff.mpr (Or.inl rfl),hz⟩ + · rintro ⟨y,hy,hz⟩ + rcases ZFSet.mem_insert_iff.mp hy with rfl|hy + · exact Or.inr hz + · exact Or.inl ⟨y,hy,hz⟩ + +theorem ordinal_omega_opow_schemas (M : ZFSet.{u}) (C : Context M) (hRep : SigmaReplacement M) (hColl : SigmaCollection M) + (a : Ordinal.{u}) (ha : a.toZFSet ∈ M) : (Ordinal.omega0 ^ a).toZFSet ∈ M := by + obtain ⟨f,hf,hg⟩ := internal_omegaGraph_schemas M C hRep hColl a.toZFSet ha (ZFSet.isOrdinal_toZFSet a) + have h1 : (1 : Ordinal.{u}).toZFSet ∈ M := by + rw [← Nat.cast_one,toZFSet_nat] + exact C.transitive _ (omega_mem M C.transitive C.separation C.infinity) _ ((mem_omega _).mpr ⟨1,rfl⟩) + have hv := omegaStageImage _ f a.toZFSet hg.1 (ZFSet.mem_insert_iff.mpr (Or.inl rfl)) hg.mem_iff + rw [Ordinal.rank_toZFSet] at hv + exact hv ▸ stageImage_mem_context M C h1 ha hf + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SelectedColumnArithmeticCone.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SelectedColumnArithmeticCone.lean new file mode 100644 index 0000000000000000000000000000000000000000..43a4ad7d26500e8c22f9fff1decfbf39473ae3c3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SelectedColumnArithmeticCone.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.CohenColumnRealValue +import OAI.Computability.DegreeRigidity.SetModels.ProjectedArithmeticOutputCone + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open RelativeConstructible CohenGroundPoset InternalCohenProjectedGeneric InternalCohenFactor +open OracleJump TableIndices IndexMatrix PersistentRestrictions SetDegreeDecoding +open ElementaryModel FullSetForcing CohenColumnRealName +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder CohenNiceNameConstruction.cohenTop + +theorem selected_column_arithmetic_cone (M K a : ZFSet.{0}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) (hK : K ∈ M) (ha : a ∈ K) + (δ : Ordinal.{0}) (Z : ZFSet.{0}) (φ : SentenceForm) + (I : CountableIdeal) (ρ : I ≃o I) + (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (R : Oracle) (hRM : realCode R ∈ M) + (hR : degree R = (ρ.symm ⟨degree (jump FixedArithmetic.zero),hz⟩).val) + (f : Name (Conditions (poset K))) (hf : f.encode (label (poset K)) ∈ M) + (hfv : ∀ H : GenericFilter (Conditions (poset K)), GroundGeneric M H → + f.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet M (poset K) H.carrier)) δ) + φ (fun _ : Fin φ.bound => Z)) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (hOwn : OwnDegreeExtension (genericExtensionSet M (poset K) G.carrier) + (idealSet I) (automorphismSet ρ) (f.val G.carrier)) + (p₀ : Conditions (poset K)) (hp₀ : p₀ ∈ G.carrier) : + let C := ZFSet.prod K ZFSet.omega + let B := ZFSet.prod {a} ZFSet.omega + let hBC := singleton_coordinates_subset K a ha + ∃ d : ℕ, ∃ p ∈ G.carrier, p ≤ p₀ ∧ + ∀ H : GenericFilter (Conditions (poset K)), GroundGeneric M H → + project C B hBC p ∈ (projected C B hBC H).carrier → + ∃ A X : Oracle, (realName K a).val H.carrier = realCode A ∧ + (∀ n b, ZFSet.pair (ZFSet.pair a (natSet n)) (InternalCohen.bitSet b) ∈ + InternalCollapse.unionGraph H ↔ A n = b) ∧ + Represents (iterate (join A R) 5) (machine d) X ∧ + ∃ u ∈ degreeUniverse (groundReals (genericExtensionSet M (poset K) H.carrier)), + ∃ v ∈ degreeUniverse (groundReals (genericExtensionSet M (poset K) H.carrier)), + realCode A ∈ u ∧ realCode X ∈ v ∧ ZFSet.pair u v ∈ f.val H.carrier := by + intro C B hBC + have hsingle := singleton_mem M hM hT.pairing (hM K hK a ha) + have hC := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hK (sourceT_omega_mem M hM hT) + have hB := product_mem M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hsingle (sourceT_omega_mem M hM hT) + obtain ⟨A,hτv,_,_,_⟩ := projected_real_value M K a hM hT hK ha G hG + obtain ⟨x,y,_,_,_,hxv,d,p,hp,hp₀',hcone⟩ := + projected_arithmetic_output_cone M C B hM hT hC hB hBC δ Z φ I ρ hz R hRM hR + f hf hfv G hG hOwn (realName {a} a) + (realName_internal M {a} a hM hT hsingle (ZFSet.mem_singleton.mpr rfl)) + A hτv p₀ hp₀ + refine ⟨d,p,hp,hp₀',fun H hH hpH => ?_⟩ + obtain ⟨A',X,hx,_,hrep,hout⟩ := hcone H hH hpH + obtain ⟨AH,hτH,hfull,hbits,_⟩ := projected_real_value M K a hM hT hK ha H hH + have he : A' = AH := realCode_injective + (hx.symm.trans ((hxv H hH (hτH.symm ▸ realCode_subset AH)).trans hτH)) + subst A' + exact ⟨AH,X,hfull,hbits,hrep,hout⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SelectedColumnPrefixProgram.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SelectedColumnPrefixProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..16d7de2f44fff72caf7664714d7e2f5986f712c5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SelectedColumnPrefixProgram.lean @@ -0,0 +1,49 @@ +import OAI.Computability.DegreeRigidity.SetModels.SelectedColumnArithmeticCone +import OAI.Computability.DegreeRigidity.CohenForcing.CohenColumnPrefixCone + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open RelativeConstructible CohenGroundPoset InternalCohenProjectedGeneric InternalCohenFactor +open OracleJump TableIndices IndexMatrix PersistentRestrictions SetDegreeDecoding +open ElementaryModel FullSetForcing CohenColumnRealName +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem selected_column_prefix_program (M K a : ZFSet.{0}) [Countable (Conditions M)] + (hM : Transitive M) (hT : SourceT M) (hK : K ∈ M) (ha : a ∈ K) + (δ : Ordinal.{0}) (Z : ZFSet.{0}) (φ : SentenceForm) + (I : CountableIdeal) (ρ : I ≃o I) + (hz : degree (jump FixedArithmetic.zero) ∈ I.carrier) + (R : Oracle) (hRM : realCode R ∈ M) + (hR : degree R = (ρ.symm ⟨degree (jump FixedArithmetic.zero),hz⟩).val) + (f : Name (Conditions (poset K))) (hf : f.encode (label (poset K)) ∈ M) + (hfv : ∀ H : GenericFilter (Conditions (poset K)), GroundGeneric M H → + f.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet M (poset K) H.carrier)) δ) + φ (fun _ : Fin φ.bound => Z)) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (hOwn : OwnDegreeExtension (genericExtensionSet M (poset K) G.carrier) + (idealSet I) (automorphismSet ρ) (f.val G.carrier)) + : ∃ A₀ : Oracle, ∃ d N : ℕ, + (realName K a).val G.carrier = realCode A₀ ∧ + ∀ H : GenericFilter (Conditions (poset K)), GroundGeneric M H → + ∀ A : Oracle, (realName K a).val H.carrier = realCode A → + (∀ n < N, A n = A₀ n) → ∃ X : Oracle, + Represents (iterate (join A R) 5) (machine d) X ∧ + ∃ u ∈ degreeUniverse (groundReals (genericExtensionSet M (poset K) H.carrier)), + ∃ v ∈ degreeUniverse (groundReals (genericExtensionSet M (poset K) H.carrier)), + realCode A ∈ u ∧ realCode X ∈ v ∧ ZFSet.pair u v ∈ f.val H.carrier := by + obtain ⟨d,p,hp,_,hcone⟩ := selected_column_arithmetic_cone M K a hM hT hK ha + δ Z φ I ρ hz R hRM hR f hf hfv G hG hOwn ⊤ (G.upper le_top G.nonempty.choose_spec) + obtain ⟨A₀,hA₀,N,hprefix⟩ := selected_prefix_cone M K a hM hT hK ha G hG p hp + refine ⟨A₀,d,N,hA₀,fun H hH A hA hearly => ?_⟩ + obtain ⟨AH,X,hAH,_,hrep,hout⟩ := hcone H hH (hprefix H hH A hA hearly) + have he : AH = A := realCode_injective (hAH.symm.trans hA) + subst AH + exact ⟨X,hrep,hout⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetDegreeDecoding.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetDegreeDecoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..88ee0bbd7802a7490aeb8ff5965cfb18a4e6c313 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetDegreeDecoding.lean @@ -0,0 +1,138 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelReals +import OAI.Computability.DegreeRigidity.Constructibility.PersistentPresentation + +namespace OAI + +namespace TuringRigidity.SetDegreeDecoding +open BoundedSetTheory TransitiveNameModel SetPresentationDecoding SetModelReals +open PersistentRestrictions PersistentPresentation +universe u +noncomputable section + +def degreeSet (a : Degree) : ZFSet.{u} := + ZFSet.sep (fun x => degree (oracleOf x) = a) (ZFSet.powerset ZFSet.omega) + +@[simp] theorem real_mem_degreeSet (A : Oracle) (a : Degree) : + realSet.{u} A ∈ degreeSet a ↔ degree A = a := by + simp only [degreeSet,ZFSet.mem_sep,ZFSet.mem_powerset,oracleOf_realSet] + exact and_iff_right (realSet_subset A) + +theorem mem_degreeSet (a : Degree) (x : ZFSet.{u}) : + x ∈ degreeSet a ↔ ∃ A, x = realSet A ∧ degree A = a := by + constructor + · intro hx + obtain ⟨hs,he⟩ := ZFSet.mem_sep.mp hx + exact ⟨oracleOf x,(realSet_oracleOf (ZFSet.mem_powerset.mp hs)).symm,he⟩ + · rintro ⟨A,rfl,he⟩ + exact (real_mem_degreeSet A a).mpr he + +theorem degreeSet_injective : Function.Injective degreeSet.{u} := by + intro a b he + obtain ⟨A,rfl⟩ := degree_surjective a + exact (real_mem_degreeSet A b).mp (he ▸ (real_mem_degreeSet A (degree A)).mpr rfl) + +theorem class_eq_degreeSet (M : ZFSet.{u}) + (hLower : ∀ {A B}, B ∈ reals M → Reduces A B → A ∈ reals M) + {d E : ZFSet.{u}} (hd : ∀ x, x ∈ d ↔ ∃ A ∈ reals M, x = realSet A) + (hE : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ E ↔ degree A = degree B) + {A : Oracle} (hA : A ∈ reals M) : + classSet d E (realSet A) = degreeSet (degree A) := by + apply ZFSet.ext + intro x + rw [mem_classSet,mem_degreeSet] + constructor + · rintro ⟨hx,hAx⟩ + obtain ⟨B,hB,rfl⟩ := (hd x).mp hx + exact ⟨B,rfl,((hE A hA B hB).mp hAx).symm⟩ + · rintro ⟨B,rfl,hBA⟩ + have hB : B ∈ reals M := hLower hA ((degree_eq_iff B A).mp hBA).1 + exact ⟨(hd _).mpr ⟨B,hB,rfl⟩,(hE A hA B hB).mpr hBA.symm⟩ + +def idealSet (I : CountableIdeal) : ZFSet.{u} := + ZFSet.sep (fun x => ∃ a ∈ I.carrier, x = degreeSet a) + (ZFSet.powerset (ZFSet.powerset ZFSet.omega)) + +@[simp] theorem mem_idealSet (I : CountableIdeal) (x : ZFSet.{u}) : + x ∈ idealSet I ↔ ∃ a ∈ I.carrier, x = degreeSet a := by + rw [idealSet,ZFSet.mem_sep] + constructor + · exact And.right + · rintro ⟨a,ha,rfl⟩ + refine ⟨ZFSet.mem_powerset.mpr ?_,⟨a,ha,rfl⟩⟩ + intro y hy + exact (ZFSet.mem_sep.mp hy).1 + +theorem quotient_eq_idealSet (M : ZFSet.{u}) + (hLower : ∀ {A B}, B ∈ reals M → Reduces A B → A ∈ reals M) + {d E a : ZFSet.{u}} (hd : ∀ x, x ∈ d ↔ ∃ A ∈ reals M, x = realSet A) + (hE : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ E ↔ degree A = degree B) + {I : CountableIdeal} {A : Oracle} (hA : Presented I A) + (ha : ∀ x, x ∈ a ↔ ∃ n, x = realSet (EncodedForcing.columns A n)) + (hcols : ∀ n, EncodedForcing.columns A n ∈ reals M) : + quotientSet d E a = idealSet I := by + apply ZFSet.ext + intro x + rw [mem_quotientSet,mem_idealSet] + constructor + · rintro ⟨y,hy,hxy⟩ + obtain ⟨n,rfl⟩ := (ha y).mp hy + refine ⟨degree (EncodedForcing.columns A n),(hA _).mpr ⟨n,rfl⟩,?_⟩ + exact hxy.trans (class_eq_degreeSet M hLower hd hE (hcols n)) + · rintro ⟨b,hb,rfl⟩ + obtain ⟨n,hn⟩ := (hA b).mp hb + refine ⟨realSet (EncodedForcing.columns A n),(ha _).mpr ⟨n,rfl⟩,?_⟩ + rw [class_eq_degreeSet M hLower hd hE (hcols n),hn] + +def automorphismSet {I : CountableIdeal} (ρ : I ≃o I) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ b : I, z = ZFSet.pair (degreeSet b.val) (degreeSet (ρ b).val)) + (ZFSet.prod (idealSet I) (idealSet I)) + +@[simp] theorem mem_automorphismSet {I : CountableIdeal} (ρ : I ≃o I) (z : ZFSet.{u}) : + z ∈ automorphismSet ρ ↔ ∃ b : I, z = ZFSet.pair (degreeSet b.val) (degreeSet (ρ b).val) := by + rw [automorphismSet,ZFSet.mem_sep] + constructor + · exact And.right + · rintro ⟨b,rfl⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨(mem_idealSet _ _).mpr ⟨b.val,b.property,rfl⟩, + (mem_idealSet _ _).mpr ⟨(ρ b).val,(ρ b).property,rfl⟩⟩,⟨b,rfl⟩⟩ + +theorem action_eq_automorphismSet (M : ZFSet.{u}) + (hLower : ∀ {A B}, B ∈ reals M → Reduces A B → A ∈ reals M) + {d E a R : ZFSet.{u}} (hd : ∀ x, x ∈ d ↔ ∃ A ∈ reals M, x = realSet A) + (hE : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ E ↔ degree A = degree B) + {I : CountableIdeal} {A : Oracle} (hA : Presented I A) (ρ : I ≃o I) + (ha : ∀ x, x ∈ a ↔ ∃ n, x = realSet (EncodedForcing.columns A n)) + (hcols : ∀ n, EncodedForcing.columns A n ∈ reals M) + (hR : ∀ n m, ZFSet.pair (realSet (EncodedForcing.columns A n)) + (realSet (EncodedForcing.columns A m)) ∈ R ↔ + (ρ ⟨degree (EncodedForcing.columns A n),(hA _).mpr ⟨n,rfl⟩⟩).val = + degree (EncodedForcing.columns A m)) : + actionGraph d E a R = automorphismSet ρ := by + apply ZFSet.ext + intro z + rw [mem_actionGraph,mem_automorphismSet] + constructor + · rintro ⟨x,hx,y,hy,hxy,rfl⟩ + obtain ⟨n,rfl⟩ := (ha x).mp hx + obtain ⟨m,rfl⟩ := (ha y).mp hy + rw [class_eq_degreeSet M hLower hd hE (hcols n), + class_eq_degreeSet M hLower hd hE (hcols m)] + exact ⟨⟨_,(hA _).mpr ⟨n,rfl⟩⟩,by rw [(hR n m).mp hxy]⟩ + · rintro ⟨b,rfl⟩ + obtain ⟨n,hn⟩ := (hA b.val).mp b.property + obtain ⟨m,hm⟩ := (hA (ρ b).val).mp (ρ b).property + have hb : (⟨degree (EncodedForcing.columns A n),(hA _).mpr ⟨n,rfl⟩⟩ : I) = b := + Subtype.ext hn + refine ⟨_,(ha _).mpr ⟨n,rfl⟩,_,(ha _).mpr ⟨m,rfl⟩,?_,?_⟩ + · apply (hR n m).mpr + rw [hb,hm] + · rw [class_eq_degreeSet M hLower hd hE (hcols n), + class_eq_degreeSet M hLower hd hE (hcols m),hn,hm] + +end +end TuringRigidity.SetDegreeDecoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelActionDecoding.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelActionDecoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..e045b76c231b95fa1a6cd8fd31b50455f05b09f0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelActionDecoding.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelIdealDecoding + +namespace OAI + +namespace TuringRigidity.SetModelSatisfaction +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions SetModelSyntax +open SetDegreeDecoding PersistentRestrictions SetModelCountability +universe u +noncomputable section + +theorem decode_action {M : ZFSet.{u}} (C : Context M) {L f : ZFSet.{u}} + (hL : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + (I : CountableIdeal) (hIM : idealSet I ∈ M) (ha : IsAction f (idealSet I) L) : + ∃ ρ : I ≃o I, automorphismSet ρ = f := by + have hi (a : I) : degreeSet.{u} a.val ∈ idealSet I := + (mem_idealSet I _).mpr ⟨a.val,a.property,rfl⟩ + have hm (a : I) : degreeSet.{u} a.val ∈ M := C.transitive _ hIM _ (hi a) + have hex (a : I) : ∃ b : I, ZFSet.pair (degreeSet.{u} a.val) (degreeSet b.val) ∈ f := by + obtain ⟨y,hy,hxy,_⟩ := ha.1.1.2 _ (hi a) + obtain ⟨b,hb,rfl⟩ := (mem_idealSet I y).mp hy + exact ⟨⟨b,hb⟩,hxy⟩ + choose F hF using hex + have hle (a b : I) : F a ≤ F b ↔ a ≤ b := by + have hh := ha.2 _ (hi a) _ (hi b) _ (hi (F a)) _ (hi (F b)) ⟨hF a,hF b⟩ + rw [order_code C hL (hm a) (hm b),order_code C hL (hm (F a)) (hm (F b))] at hh + exact hh.symm + have hinj : Function.Injective F := by + intro a b he + exact le_antisymm ((hle a b).mp (le_of_eq he)) ((hle b a).mp (le_of_eq he.symm)) + have hsurj : Function.Surjective F := by + intro b + obtain ⟨x,hx,hxb⟩ := ha.1.2 _ (hi b) + obtain ⟨a,hac,rfl⟩ := (mem_idealSet I x).mp hx + refine ⟨⟨a,hac⟩,Subtype.ext (degreeSet_injective ?_)⟩ + exact ha.1.1.unique (hi ⟨a,hac⟩) (hi (F ⟨a,hac⟩)) (hi b) (hF ⟨a,hac⟩) hxb + let ρ : I ≃o I := { toEquiv := Equiv.ofBijective F ⟨hinj,hsurj⟩, map_rel_iff' := by intro a b; exact hle a b } + have hpair (a b : I) : ZFSet.pair (degreeSet.{u} a.val) (degreeSet b.val) ∈ f ↔ ρ a = b := by + constructor + · intro hab + apply Subtype.ext + apply degreeSet_injective + exact ha.1.1.unique (hi a) (hi (F a)) (hi b) (hF a) hab + · intro he + have he' : F a = b := he + simpa only [he'] using hF a + refine ⟨ρ,ZFSet.ext (fun z => ?_)⟩ + constructor + · intro hz + obtain ⟨a,rfl⟩ := (mem_automorphismSet ρ z).mp hz + exact (hpair a (ρ a)).mpr rfl + · intro hz + obtain ⟨x,hx,y,hy,rfl⟩ := ha.1.1.1 z hz + obtain ⟨a,hac,rfl⟩ := (mem_idealSet I x).mp hx + obtain ⟨b,hbc,rfl⟩ := (mem_idealSet I y).mp hy + exact (action_code ρ ⟨a,hac⟩ ⟨b,hbc⟩).mpr ((hpair ⟨a,hac⟩ ⟨b,hbc⟩).mp hz) + +theorem ideal_subset_iff {I J : CountableIdeal} : + idealSet.{u} I ⊆ idealSet J ↔ I.carrier ⊆ J.carrier := by + constructor + · intro h a ha + obtain ⟨b,hb,he⟩ := (mem_idealSet J _).mp (h ((mem_idealSet I _).mpr ⟨a,ha,rfl⟩)) + exact (degreeSet_injective he).symm ▸ hb + · exact ideal_subset + +theorem extends_sets_iff {I J : CountableIdeal} (hIJ : I.carrier ⊆ J.carrier) + (ρ : I ≃o I) (σ : J ≃o J) : + automorphismSet.{u} ρ ⊆ automorphismSet σ ↔ Extends hIJ ρ σ := by + constructor + · intro h a + have hh := h ((mem_automorphismSet ρ _).mpr ⟨a,rfl⟩) + have he := (action_code σ ⟨a.val,hIJ a.property⟩ ⟨(ρ a).val,hIJ (ρ a).property⟩).mp hh + exact congrArg Subtype.val he + · exact extends_sets + +end +end TuringRigidity.SetModelSatisfaction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelActionSatisfaction.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelActionSatisfaction.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b77201a4d9b93d776e1f83c05a8e9c4695a6d76 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelActionSatisfaction.lean @@ -0,0 +1,96 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelIdealSatisfaction + +namespace OAI + +namespace TuringRigidity.SetModelSatisfaction +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions SetModelSyntax +open SetDegreeDecoding PersistentRestrictions SetModelCountability +universe u +noncomputable section +variable {M : ZFSet.{u}} + +def actionFormula (f i l : ℕ) : Formula := + .conj (ontoFormula f i i) + (.allMem i (.allMem (i+1) (.allMem (i+2) (.allMem (i+3) + (.imp (.conj (.pairMem 3 1 (f+4)) (.pairMem 2 0 (f+4))) + (.iff (.pairMem 3 2 (l+4)) (.pairMem 1 0 (l+4)))))))) + +def IsAction (f i l : ZFSet.{u}) : Prop := + (FunctionGraph f i i ∧ ∀ y ∈ i, ∃ x ∈ i, ZFSet.pair x y ∈ f) ∧ + ∀ x ∈ i, ∀ y ∈ i, ∀ a ∈ i, ∀ b ∈ i, + ZFSet.pair x a ∈ f ∧ ZFSet.pair y b ∈ f → + (ZFSet.pair x y ∈ l ↔ ZFSet.pair a b ∈ l) + +@[simp] theorem eval_actionFormula (f i l : ℕ) (e : ℕ → ZFSet.{u}) : + (actionFormula f i l).Eval e ↔ IsAction (e f) (e i) (e l) := by + simp only [actionFormula,Formula.Eval,eval_ontoFormula,Formula.eval_allMem, + Formula.eval_imp,Formula.eval_iff,Formula.eval_pairMem,cons_zero,cons_succ,IsAction] + +theorem action_code {I : CountableIdeal} (ρ : I ≃o I) (a b : I) : + ZFSet.pair (degreeSet.{u} a.val) (degreeSet b.val) ∈ automorphismSet ρ ↔ ρ a = b := by + rw [mem_automorphismSet] + constructor + · rintro ⟨c,he⟩ + obtain ⟨ha,hb⟩ := ZFSet.pair_inj.mp he + have ha' : a=c := Subtype.ext (degreeSet_injective ha) + have hb' : b=ρ c := Subtype.ext (degreeSet_injective hb) + rw [ha',hb'] + · intro h + exact ⟨a,by rw [h]⟩ + +theorem action_satisfaction (C : Context M) {L : ZFSet.{u}} + (hL : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + {I : CountableIdeal} (hI : idealSet I ∈ M) (ρ : I ≃o I) : + IsAction (automorphismSet ρ) (idealSet I) L := by + have hm (a : I) : degreeSet.{u} a.val ∈ M := + C.transitive _ hI _ ((mem_idealSet I _).mpr ⟨a.val,a.property,rfl⟩) + have hi (a : I) : degreeSet.{u} a.val ∈ idealSet I := + (mem_idealSet I _).mpr ⟨a.val,a.property,rfl⟩ + refine ⟨⟨⟨?_,?_⟩,?_⟩,?_⟩ + · intro z hz + obtain ⟨a,rfl⟩ := (mem_automorphismSet ρ z).mp hz + exact ⟨degreeSet a.val,hi a,degreeSet (ρ a).val,hi (ρ a),rfl⟩ + · intro x hx + obtain ⟨a,ha,rfl⟩ := (mem_idealSet I x).mp hx + let a' : I := ⟨a,ha⟩ + refine ⟨degreeSet (ρ a').val,hi (ρ a'),(action_code ρ a' (ρ a')).mpr rfl,?_⟩ + intro z hz hxz + obtain ⟨b,hb,rfl⟩ := (mem_idealSet I z).mp hz + have hh := (action_code ρ a' ⟨b,hb⟩).mp hxz + exact congrArg (fun c : I => degreeSet c.val) hh.symm + · intro y hy + obtain ⟨b,hb,rfl⟩ := (mem_idealSet I y).mp hy + let b' : I := ⟨b,hb⟩ + exact ⟨degreeSet (ρ.symm b').val,hi (ρ.symm b'), + (action_code ρ (ρ.symm b') b').mpr (ρ.apply_symm_apply b')⟩ + · intro x hx y hy a ha b hb hab + obtain ⟨x,hxc,rfl⟩ := (mem_idealSet I x).mp hx + obtain ⟨y,hyc,rfl⟩ := (mem_idealSet I y).mp hy + obtain ⟨a,hac,rfl⟩ := (mem_idealSet I a).mp ha + obtain ⟨b,hbc,rfl⟩ := (mem_idealSet I b).mp hb + have hxa := (action_code ρ ⟨x,hxc⟩ ⟨a,hac⟩).mp hab.1 + have hyb := (action_code ρ ⟨y,hyc⟩ ⟨b,hbc⟩).mp hab.2 + rw [order_code C hL (hm ⟨x,hxc⟩) (hm ⟨y,hyc⟩), + order_code C hL (hm ⟨a,hac⟩) (hm ⟨b,hbc⟩)] + change (⟨x,hxc⟩ : I) ≤ ⟨y,hyc⟩ ↔ (⟨a,hac⟩ : I) ≤ ⟨b,hbc⟩ + rw [←hxa,←hyb] + exact ρ.le_iff_le.symm + +theorem extends_sets {I J : CountableIdeal} {ρ : I ≃o I} {σ : J ≃o J} + {hIJ : I.carrier ⊆ J.carrier} (he : Extends hIJ ρ σ) : + automorphismSet.{u} ρ ⊆ automorphismSet σ := by + intro z hz + obtain ⟨a,rfl⟩ := (mem_automorphismSet ρ z).mp hz + exact (mem_automorphismSet σ _).mpr ⟨⟨a.val,hIJ a.property⟩,by rw [he a]⟩ + +theorem ideal_subset {I J : CountableIdeal} (h : I.carrier ⊆ J.carrier) : + idealSet.{u} I ⊆ idealSet J := by + intro x hx + obtain ⟨a,ha,rfl⟩ := (mem_idealSet I x).mp hx + exact (mem_idealSet J _).mpr ⟨a,h ha,rfl⟩ + +end +end TuringRigidity.SetModelSatisfaction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelAddition.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelAddition.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e979c3e1b278ba606f9097ee1dde2cd2680c09e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelAddition.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelRecursion + +namespace OAI + +namespace TuringRigidity.SetModelArithmetic +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelIteration +universe u +noncomputable section + +def setSucc (x : ZFSet.{u}) : ZFSet.{u} := insert x x + +theorem setSucc_nat (n : ℕ) : setSucc (natSet.{u} n) = natSet (n+1) := rfl + +theorem setSucc_omega : ∀ x ∈ ZFSet.omega.{u}, setSucc x ∈ ZFSet.omega := by + intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + exact (mem_omega _).mpr ⟨n+1,rfl⟩ + +def successorSet : ZFSet.{u} := ZFSet.sep + (fun z => ∃ x ∈ ZFSet.omega, z = ZFSet.pair x (setSucc x)) + (ZFSet.prod ZFSet.omega ZFSet.omega) + +theorem pair_mem_successorSet {x y : ZFSet.{u}} (hx : x ∈ ZFSet.omega) (hy : y ∈ ZFSet.omega) : + ZFSet.pair x y ∈ successorSet ↔ y = setSucc x := by + simp only [successorSet,ZFSet.mem_sep,ZFSet.pair_mem_prod,hx,hy,true_and,ZFSet.pair_inj] + constructor + · rintro ⟨a,ha,he,hs⟩ + exact he ▸ hs + · intro h + exact ⟨x,hx,rfl,h⟩ + +def successorFormula : Formula := + .existsMem 1 (.existsMem 2 (.conj (.orderedPair 2 1 0) (.successor 0 1))) + +theorem successorSet_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) : successorSet.{u} ∈ M := by + have hω := omega_mem M hM hS hI + have hprod := product_mem M hM hP hU hPow hS hω hω + have hs := sep_mem M hM hS successorFormula (fun _ => ZFSet.omega) (fun _ => hω) hprod + have eq : ZFSet.sep (fun z => successorFormula.Eval (cons z (fun _ => ZFSet.omega))) + (ZFSet.prod ZFSet.omega ZFSet.omega) = successorSet.{u} := by + apply ZFSet.ext + intro z + simp only [ZFSet.mem_sep,successorFormula,Formula.Eval,Formula.eval_orderedPair, + Formula.eval_successor,cons_zero,cons_succ,successorSet] + apply and_congr Iff.rfl + constructor + · rintro ⟨x,hx,y,hy,hz,rfl⟩ + exact ⟨x,hx,hz⟩ + · rintro ⟨x,hx,rfl⟩ + exact ⟨x,hx,setSucc x,setSucc_omega x hx,rfl,rfl⟩ + exact eq ▸ hs + +def additionSet : ZFSet.{u} := iterationSet ZFSet.omega setSucc + +theorem iterate_setSucc (n m : ℕ) : setSucc^[n] (natSet.{u} m) = natSet (m+n) := by + induction n with + | zero => rfl + | succ n ih => + rw [Function.iterate_succ_apply',ih] + change natSet (m+n+1) = natSet (m+(n+1)) + rw [Nat.add_assoc] + +theorem addition_code (n m k : ℕ) : + ZFSet.pair (ZFSet.pair (natSet.{u} n) (natSet m)) (natSet k) ∈ additionSet ↔ k = n+m := by + rw [additionSet,mem_iterationSet setSucc setSucc_omega] + constructor + · rintro ⟨i,x,hx,he⟩ + obtain ⟨hinput,hout⟩ := ZFSet.pair_inj.mp he + obtain ⟨hi,rfl⟩ := ZFSet.pair_inj.mp hinput + have hin := natSet_injective hi + rw [←hin,iterate_setSucc] at hout + exact (natSet_injective hout).trans (Nat.add_comm m n) + · intro hk + refine ⟨n,natSet m,(mem_omega _).mpr ⟨m,rfl⟩,?_⟩ + rw [iterate_setSucc,hk,Nat.add_comm m n] + +theorem additionSet_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) : additionSet.{u} ∈ M := + iterationSet_mem M hM hP hU hPow hS hI (omega_mem M hM hS hI) + (successorSet_mem M hM hP hU hPow hS hI) setSucc setSucc_omega + (fun _ hx _ hy => pair_mem_successorSet hx hy) + +end +end TuringRigidity.SetModelArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticClosure.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..625f97963a9caf45dc9b542185b9da745a15df9a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticClosure.lean @@ -0,0 +1,74 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelArithmeticSyntax +import OAI.Computability.DegreeRigidity.Computability.ArithmeticRelations + +namespace OAI + +namespace TuringRigidity.SetModelSyntax +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelArithmetic SetModelFunctions +open BoundedDefinability UniformArithmetic Encodable TableIndices IndexMatrix +universe u +noncomputable section + +variable {M : ZFSet.{u}} + +theorem arithmetic_comprehension (C : Context M) {P : Predicate} (hP : Arith P) + (O : Oracles) (hO : ∀ i, O i ∈ reals M) (A : Oracle) + (hA : ∀ n, P O n ↔ A n = true) : A ∈ reals M := by + obtain ⟨Q,hQ,hc⟩ := arith_definition C hP + let e : ℕ → ZFSet.{u} := fun i => realSet (O i) + have he : ∀ i, e i ∈ M := hO + have hs := hQ.sep_mem C e he C.omega_mem + have hspec (n : ℕ) : Q (cons (natSet n) e) ↔ A n = true := by + have hh := hc (cons (natSet n) e) n rfl + have ho : (fun i => oracleOf (cons (natSet n) e (i+1))) = O := by + funext i + exact oracleOf_realSet (O i) + rw [ho] at hh + exact hh.trans (hA n) + have eq : ZFSet.sep (fun x => Q (cons x e)) ZFSet.omega = realSet A := by + apply ZFSet.ext + intro x + by_cases hx : x ∈ ZFSet.omega + · obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + simp only [ZFSet.mem_sep,hspec,nat_mem_realSet] + exact and_iff_right ((mem_omega _).mpr ⟨n,rfl⟩) + · constructor + · intro h + exact (hx (ZFSet.mem_sep.mp h).1).elim + · intro h + exact (hx (realSet_subset A h)).elim + change realSet A ∈ M + exact eq ▸ hs + +theorem tableOracle_mem (C : Context M) {B : Oracle} (hB : B ∈ reals M) (e : ℕ) : + tableOracle B e ∈ reals M := by + have h : Arith (fun O v => tableGraph (O 0) e v) := + tableGraph_arith (parameter_arith 0) (Primrec.const 0) (Primrec.const e) Primrec.id + apply arithmetic_comprehension C h (fun _ => B) (fun _ => hB) (tableOracle B e) + intro n + simp [tableOracle] + +theorem lower_mem (C : Context M) {A B : Oracle} (hB : B ∈ reals M) (hAB : Reduces A B) : + A ∈ reals M := by + obtain ⟨c,hc⟩ := (reduces_iff_represents A B).mp hAB + have hc' : Represents B (machine (encode c)) A := by simpa using hc + rw [←tableOracle_eq hc'] + exact tableOracle_mem C hB (encode c) + +theorem jump_mem (C : Context M) {A : Oracle} (hA : A ∈ reals M) : + OracleJump.jump A ∈ reals M := by + have h : Arith (fun O n => OracleJump.jump (O 0) n = true) := + query_at (jump_arith (parameter_arith 0)) (Primrec.const 0) Primrec.id + exact arithmetic_comprehension C h (fun _ => A) (fun _ => hA) _ (fun _ => Iff.rfl) + +theorem run_membership_definition (C : Context M) {B : OracleFamily} (hB : ArithmeticOracle B) + {c e n z a : ℕ → ℕ} (hc : Primrec c) (he : Primrec e) (hn : Primrec n) + (hz : Primrec z) (ha : Primrec a) : + ArithmeticDefinition M (fun O v => + TableIndices.run (B O (c v)) (machine (e v)) (n v) (z v) = some (a v)) := + arith_definition C (run_arith hB hc he hn hz ha) + +end +end TuringRigidity.SetModelSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticDischarge.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticDischarge.lean new file mode 100644 index 0000000000000000000000000000000000000000..56232073879f58293b9540fb1233634996495662 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticDischarge.lean @@ -0,0 +1,44 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelInternalRelations +import OAI.Computability.DegreeRigidity.SetModels.SetModelArithmeticInterface + +namespace OAI + +namespace TuringRigidity.SetModelSyntax +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelArithmetic SetModelFunctions +open SetDegreeDecoding PersistentRestrictions PersistentPresentation +universe u +noncomputable section +variable {M : ZFSet.{u}} + +theorem realClosure (C : Context M) : PersistenceRealClosure.Closed (reals M) := by + obtain ⟨g,hg,hgc⟩ := internal_jump_graph C + exact realClosure_of_lower_and_jump M C.transitive C.pairing C.union C.power C.separation C.infinity + (lower_mem C) (fun _ h => jump_mem C h) hg hgc + +theorem persistent_sets (C : Context M) + {I : CountableIdeal} {A : Oracle} (hA : Presented I A) (hAM : A ∈ reals M) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + idealSet I ∈ M ∧ automorphismSet ρ ∈ M := by + obtain ⟨g,hg,hgc⟩ := internal_jump_graph C + obtain ⟨E,hE,hEc⟩ := internal_degreeEquality_graph C + exact persistent_model_sets M C.transitive C.pairing C.union C.power C.separation C.infinity + (lower_mem C) (fun _ h => jump_mem C h) hg hgc hE hEc hA hAM ρ hρ hz + +theorem persistent_extension_sets (C : Context M) + {I : CountableIdeal} {A : Oracle} (hA : Presented I A) (hAM : A ∈ reals M) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + {X : Oracle} (hX : X ∈ reals M) : + ∃ (J : CountableIdeal) (σ : J ≃o J) (hIJ : I.carrier ⊆ J.carrier), + degree X ∈ J.carrier ∧ Extends hIJ ρ σ ∧ Persistent J σ ∧ + idealSet J ∈ M ∧ automorphismSet σ ∈ M := by + obtain ⟨g,hg,hgc⟩ := internal_jump_graph C + obtain ⟨E,hE,hEc⟩ := internal_degreeEquality_graph C + exact persistent_model_extension_sets M C.transitive C.pairing C.union C.power C.separation C.infinity + (lower_mem C) (fun _ h => jump_mem C h) hg hgc hE hEc hA hAM ρ hρ hz hX + +end +end TuringRigidity.SetModelSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticInterface.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticInterface.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a4f0338a9eb02d823ecc6f65a30be312ec65f43 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticInterface.lean @@ -0,0 +1,67 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelJoin +import OAI.Computability.DegreeRigidity.SetModels.SetModelPersistence + +namespace OAI + +namespace TuringRigidity.SetModelArithmetic +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelSequences +open SetDegreeDecoding SetModelPersistence PersistentRestrictions PersistentPresentation +universe u +noncomputable section + +theorem realClosure_of_lower_and_jump (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + (hL : ∀ {A B}, B ∈ reals M → Reduces A B → A ∈ reals M) + (hJ : ∀ A ∈ reals M, OracleJump.jump A ∈ reals M) + {g : ZFSet.{u}} (hgM : g ∈ M) + (hg : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ g ↔ B = OracleJump.jump A) : + PersistenceRealClosure.Closed (reals M) := + realClosure_of_arithmetic_graphs M hM hP hU hPow hS hI hL + (fun hA hB => join_mem M hM hP hU hPow hS hI hA hB) hJ + (pairingSet_mem M hM hP hU hPow hS hI) pairingSet_code hgM hg + +theorem persistent_model_sets (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + (hL : ∀ {A B}, B ∈ reals M → Reduces A B → A ∈ reals M) + (hJ : ∀ A ∈ reals M, OracleJump.jump A ∈ reals M) + {g E : ZFSet.{u}} (hgM : g ∈ M) + (hg : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ g ↔ B = OracleJump.jump A) + (hEM : E ∈ M) (hE : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ E ↔ degree A = degree B) + {I : CountableIdeal} {A : Oracle} (hA : Presented I A) (hAM : A ∈ reals M) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + idealSet I ∈ M ∧ automorphismSet ρ ∈ M := + persistent_decoding M hM hP hU hPow hS hI + (realClosure_of_lower_and_jump M hM hP hU hPow hS hI hL hJ hgM hg) + (pairingSet_mem M hM hP hU hPow hS hI) pairingSet_code hEM hE hA hAM ρ hρ hz + +theorem persistent_model_extension_sets (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + (hL : ∀ {A B}, B ∈ reals M → Reduces A B → A ∈ reals M) + (hJ : ∀ A ∈ reals M, OracleJump.jump A ∈ reals M) + {g E : ZFSet.{u}} (hgM : g ∈ M) + (hg : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ g ↔ B = OracleJump.jump A) + (hEM : E ∈ M) (hE : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ E ↔ degree A = degree B) + {I : CountableIdeal} {A : Oracle} (hA : Presented I A) (hAM : A ∈ reals M) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + {X : Oracle} (hX : X ∈ reals M) : + ∃ (J : CountableIdeal) (σ : J ≃o J) (hIJ : I.carrier ⊆ J.carrier), + degree X ∈ J.carrier ∧ Extends hIJ ρ σ ∧ Persistent J σ ∧ + idealSet J ∈ M ∧ automorphismSet σ ∈ M := + persistent_extension_sets M hM hP hU hPow hS hI + (realClosure_of_lower_and_jump M hM hP hU hPow hS hI hL hJ hgM hg) + (pairingSet_mem M hM hP hU hPow hS hI) pairingSet_code hEM hE hA hAM ρ hρ hz hX + +end +end TuringRigidity.SetModelArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticSyntax.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3f6b99ca8051ff8e3bbd6568808cbbff1171c7c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticSyntax.lean @@ -0,0 +1,137 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelPrimrec +import OAI.Computability.DegreeRigidity.Syntax.BoundedDefinability +import OAI.Computability.DegreeRigidity.Computability.UniformArithmetic + +namespace OAI + +namespace TuringRigidity.SetModelSyntax +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelArithmetic SetModelFunctions +open BoundedDefinability UniformArithmetic Encodable +universe u +noncomputable section + +variable {M : ZFSet.{u}} + +def skipInput (k : ℕ) : ℕ → ℕ + | 0 => 0 + | i+1 => i+k+1 + +@[simp] theorem skipInput_zero (k : ℕ) : skipInput k 0 = 0 := rfl +@[simp] theorem skipInput_succ (k i : ℕ) : skipInput k (i+1) = i+k+1 := rfl + +def ArithmeticDefinition (M : ZFSet.{u}) (P : Predicate) : Prop := + ∃ Q : (ℕ → ZFSet.{u}) → Prop, Definable M Q ∧ + ∀ e n, e 0 = natSet n → + (Q e ↔ P (fun i => oracleOf (e (i+1))) n) + +def PairCode (x y z : ZFSet.{u}) : Prop := + ZFSet.pair x y ∈ pairNumbers ∧ ZFSet.pair (ZFSet.pair x y) z ∈ pairingSet + +theorem pairCode_definable (C : Context M) (i j k : ℕ) : + Definable M (fun e => PairCode (e i) (e j) (e k)) := by + refine ⟨tripleFormula (2*i) (2*j) (2*k) 1 3, + cons pairingSet (fun _ => pairNumbers),?_,?_⟩ + · intro n + cases n with + | zero => exact C.pairing_mem + | succ n => exact C.pairNumbers_mem + · intro e + simp only [eval_tripleFormula,mix_even,PairCode] + rfl + +@[simp] theorem pairCode_nat (i j k : ℕ) : + PairCode (natSet.{u} i) (natSet j) (natSet k) ↔ k = Nat.pair i j := by + simp only [PairCode,natPair_mem,true_and,pairing_code] + +theorem pure_definition (C : Context M) (P : ℕ → Prop) (hP : PrimrecPred P) : + ArithmeticDefinition M (fun _ n => P n) := by + obtain ⟨d,hd⟩ := hP + let : DecidablePred P := d + obtain ⟨g,hg,hgc⟩ := primrec_graph C (Primrec.encode.comp hd) + let Q := fun e : ℕ → ZFSet.{u} => ∃ x ∈ ZFSet.omega, + x = natSet 1 ∧ ZFSet.pair (e 0) x ∈ g + have hQ : Definable M Q := + ((equal_param (C.nat_mem 1) 0).and (pairMem_param hg 1 0)).existsParam C.omega_mem + refine ⟨Q,hQ,?_⟩ + intro e n hn + simp only [Q,hn,omega_exists] + constructor + · rintro ⟨k,hk,hgk⟩ + have hk' : k=1 := natSet_injective hk + have hh := (hgc n k).mp hgk + rw [hk'] at hh + by_contra h + simp [h] at hh + · intro h + exact ⟨1,rfl,(hgc n 1).mpr (by simp [h])⟩ + +theorem query_definition (C : Context M) (i : ℕ) : + ArithmeticDefinition M (fun O n => O i n = true) := by + refine ⟨fun e => e 0 ∈ e (i+1),member_definable C 0 (i+1),?_⟩ + intro e n hn + simp [hn,oracleOf] + +theorem ArithmeticDefinition.neg {P : Predicate} (h : ArithmeticDefinition M P) : + ArithmeticDefinition M (fun O n => ¬ P O n) := by + obtain ⟨Q,hQ,hc⟩ := h + exact ⟨fun e => ¬ Q e,hQ.neg,fun e n hn => not_congr (hc e n hn)⟩ + +theorem ArithmeticDefinition.and {P R : Predicate} + (hP : ArithmeticDefinition M P) (hR : ArithmeticDefinition M R) : + ArithmeticDefinition M (fun O n => P O n ∧ R O n) := by + obtain ⟨Q,hQ,hc⟩ := hP + obtain ⟨S,hS,hs⟩ := hR + exact ⟨fun e => Q e ∧ S e,hQ.and hS,fun e n hn => and_congr (hc e n hn) (hs e n hn)⟩ + +theorem ArithmeticDefinition.comp (C : Context M) {P : Predicate} + (h : ArithmeticDefinition M P) {f : ℕ → ℕ} (hf : Primrec f) : + ArithmeticDefinition M (fun O n => P O (f n)) := by + obtain ⟨Q,hQ,hc⟩ := h + obtain ⟨g,hg,hgc⟩ := primrec_graph C hf + let R := fun e : ℕ → ZFSet.{u} => ∃ x ∈ ZFSet.omega, + ZFSet.pair (e 0) x ∈ g ∧ Q (cons x e ∘ skipInput 1) + have hR : Definable M R := + ((pairMem_param hg 1 0).and (hQ.subst (skipInput 1))).existsParam C.omega_mem + refine ⟨R,hR,?_⟩ + intro e n hn + simp only [R,omega_exists,hn,hgc] + constructor + · rintro ⟨k,rfl,hk⟩ + exact (hc (cons (natSet (f n)) e ∘ skipInput 1) (f n) rfl).mp hk + · intro hh + exact ⟨f n,rfl,(hc (cons (natSet (f n)) e ∘ skipInput 1) (f n) rfl).mpr hh⟩ + +theorem ArithmeticDefinition.ex (C : Context M) {P : Predicate} + (h : ArithmeticDefinition M P) : + ArithmeticDefinition M (fun O n => ∃ k, P O (Nat.pair n k)) := by + obtain ⟨Q,hQ,hc⟩ := h + let R := fun e : ℕ → ZFSet.{u} => ∃ x ∈ ZFSet.omega, ∃ y ∈ ZFSet.omega, + PairCode (e 0) x y ∧ Q (cons y (cons x e) ∘ skipInput 2) + have hR : Definable M R := + (((pairCode_definable C 2 1 0).and (hQ.subst (skipInput 2))).existsParam + C.omega_mem).existsParam C.omega_mem + refine ⟨R,hR,?_⟩ + intro e n hn + simp only [R,hn] + simp_rw [omega_exists] + simp only [pairCode_nat] + constructor + · rintro ⟨k,l,rfl,hl⟩ + exact ⟨k,(hc (cons (natSet (Nat.pair n k)) (cons (natSet k) e) ∘ skipInput 2) (Nat.pair n k) rfl).mp hl⟩ + · rintro ⟨k,hk⟩ + exact ⟨k,Nat.pair n k,rfl,(hc (cons (natSet (Nat.pair n k)) (cons (natSet k) e) ∘ skipInput 2) (Nat.pair n k) rfl).mpr hk⟩ + +theorem arith_definition (C : Context M) {P : Predicate} (h : Arith P) : + ArithmeticDefinition M P := by + induction h with + | pure P hP => exact pure_definition C P hP + | query i => exact query_definition C i + | neg h ih => exact ih.neg + | and h k ih ik => exact ih.and ik + | ex h ih => exact ih.ex C + | comp f h hf ih => exact ih.comp C hf + +end +end TuringRigidity.SetModelSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticTree.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e570652832556e78a540800f435a868de48fe77 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelArithmeticTree.lean @@ -0,0 +1,44 @@ +import OAI.Computability.DegreeRigidity.Computability.ArithmeticTreeDefinability +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaModelArithmetic + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic BoundedSetTheory TransitiveNameModel SetModelReals SetModelSyntax +open OmegaModelCore SetModelFunctions +universe u +noncomputable section + +theorem Test.nodeCode_mem {M : ZFSet.{u}} (C : Context M) (t : Test) + (O : Oracles) (hO : ∀ i, O i ∈ reals M) (v : ℕ) : t.nodeCode O v ∈ reals M := + arithmetic_comprehension C (t.nodeCode_arith v) O hO _ (fun _ => Iff.rfl) + +theorem Test.nodeCode_mem_iff (t : Test) (O : Oracles) (v : ℕ) (s : List ℕ) : + natSet.{u} (Encodable.encode s) ∈ realSet (t.nodeCode O v) ↔ s ∈ t.tree O v := by + simp only [nat_mem_realSet,Test.nodeCode,decodeNode_encode,decide_eq_true_eq] + rfl + +theorem Test.nodeCode_definition {M : ZFSet.{u}} (C : Context M) (t : Test) (v : ℕ) : + ArithmeticDefinition M (fun O n => t.nodeCode O v n = true) := + arith_definition C (t.nodeCode_arith v) + +theorem Test.omega_nodeCode {α : Type u} (S : OmegaData α) + (hP : S.PairingAxiom) (hU : S.UnionAxiom) (hS : S.SeparationAxiom) + (t : Test) (O : Oracles) (hO : ∀ i, ∃ a, S.RealCode a (O i)) (v : ℕ) : + ∃ a, S.RealCode a (t.nodeCode O v) := + S.omega_arithmetic_comprehension hP hU hS (t.nodeCode_arith v) O hO _ (fun _ => Iff.rfl) + +theorem Test.omega_nodeCode_correct {α : Type u} (S : OmegaData α) + (hP : S.PairingAxiom) (hU : S.UnionAxiom) (hS : S.SeparationAxiom) + (t : Test) (O : Oracles) (hO : ∀ i, ∃ a, S.RealCode a (O i)) (v : ℕ) : + ∃ a, S.mem a (S.power S.omega) ∧ + ∀ s : List ℕ, S.mem (S.num (Encodable.encode s)) a ↔ s ∈ t.tree O v := by + obtain ⟨a,ha⟩ := t.omega_nodeCode S hP hU hS O hO v + refine ⟨a,ha.1,fun s => ?_⟩ + change S.mem (S.num (Encodable.encode s)) a ↔ t.accepts O v s + simpa only [Test.nodeCode,decodeNode_encode,decide_eq_true_eq] using ha.2 (Encodable.encode s) + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelColumns.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelColumns.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec4397d42451f05e9b5deeea6ba487fd256dee25 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelColumns.lean @@ -0,0 +1,125 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelSequences + +namespace OAI + +namespace TuringRigidity.SetModelColumns +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelSequences +open EncodedForcing +universe u +noncomputable section + +def columnFormula (n b a p w d : ℕ) : Formula := + .allMem w (.allMem (w+1) (.allMem (d+2) + (.imp (.conj (.orderedPair 0 (n+3) 2) (.pairMem 0 1 (p+3))) + (.iff (.member 2 (b+3)) (.member 1 (a+3)))))) + +theorem eval_columnFormula (n b a p w d : ℕ) (e : ℕ → ZFSet.{u}) + (k : ℕ) (A B : Oracle) (hn : e n = natSet k) (hb : e b = realSet B) + (ha : e a = realSet A) (hw : e w = ZFSet.omega) + (hd : e d = ZFSet.prod ZFSet.omega ZFSet.omega) (hp : PairingCode (e p)) : + (columnFormula n b a p w d).Eval e ↔ B = columns A k := by + simp only [columnFormula,Formula.eval_allMem,Formula.eval_imp,Formula.Eval, + Formula.eval_orderedPair,Formula.eval_pairMem,Formula.eval_iff,cons_zero,cons_succ, + hn,hb,ha,hw,hd] + constructor + · intro h + funext i + have hi : natSet.{u} i ∈ ZFSet.omega := (mem_omega _).mpr ⟨i,rfl⟩ + have hm : natSet.{u} (Nat.pair k i) ∈ ZFSet.omega := (mem_omega _).mpr ⟨_,rfl⟩ + have hk : natSet.{u} k ∈ ZFSet.omega := (mem_omega _).mpr ⟨k,rfl⟩ + have hbit := h _ hi _ hm _ (ZFSet.pair_mem_prod.mpr ⟨hk,hi⟩) + ⟨rfl,(hp k i (Nat.pair k i)).mpr rfl⟩ + simp only [nat_mem_realSet] at hbit + change B i = A (Nat.pair k i) + cases hbi : B i <;> cases hai : A (Nat.pair k i) <;> simp_all + · intro h i hi m hm t ht hcond + obtain ⟨j,rfl⟩ := (mem_omega i).mp hi + obtain ⟨l,rfl⟩ := (mem_omega m).mp hm + obtain ⟨rfl,hpkl⟩ := hcond + have hl := (hp k j l).mp hpkl + simp only [nat_mem_realSet,h,columns,hl] + +def columnsFormula : Formula := + .existsMem 1 (.existsMem 3 (.conj (.orderedPair 2 1 0) (columnFormula 1 0 5 6 3 7))) + +theorem columns_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + (hL : ∀ {A B}, B ∈ reals M → Reduces A B → A ∈ reals M) + {p : ZFSet.{u}} (hp : p ∈ M) (hpdef : PairingCode p) + {A : Oracle} (hA : A ∈ reals M) : sequenceSet (columns A) ∈ M := by + obtain ⟨r,hr,hrdef⟩ := internal_reals M hM hPow hS hI + have hω := omega_mem M hM hS hI + let d := ZFSet.prod ZFSet.omega ZFSet.omega + have hd : d ∈ M := product_mem M hM hP hU hPow hS hω hω + have hprod := product_mem M hM hP hU hPow hS hω hr + let e := cons ZFSet.omega (cons r (cons (realSet A) (cons p (fun _ => d)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|i <;> simp only [e,cons_zero,cons_succ] + · exact hω + · exact hr + · exact hA + · exact hp + · exact hd + have hs := sep_mem M hM hS columnsFormula e he hprod + have hφ (z : ZFSet.{u}) : columnsFormula.Eval (cons z e) ↔ + ∃ n, z = ZFSet.pair (natSet n) (realSet (columns A n)) := by + simp only [columnsFormula,Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,e] + rw [omega_exists] + constructor + · rintro ⟨n,b,hb,hz,hcol⟩ + obtain ⟨B,hB,rfl⟩ := (hrdef b).mp hb + have heq := (eval_columnFormula 1 0 5 6 3 7 (cons (realSet B) (cons (natSet n) (cons z e))) n A B rfl rfl rfl rfl rfl hpdef).mp hcol + exact ⟨n,by simpa only [heq] using hz⟩ + · rintro ⟨n,rfl⟩ + have hcn := hL hA (CodingExtraction.column_projection_reduces A n) + refine ⟨n,realSet (columns A n),(hrdef _).mpr ⟨_,hcn,rfl⟩,rfl,?_⟩ + exact (eval_columnFormula 1 0 5 6 3 7 (cons (realSet (columns A n)) (cons (natSet n) + (cons (ZFSet.pair (natSet n) (realSet (columns A n))) e))) n A (columns A n) rfl rfl rfl rfl rfl hpdef).mpr rfl + have eq : ZFSet.sep (fun z => columnsFormula.Eval (cons z e)) (ZFSet.prod ZFSet.omega r) = + sequenceSet (columns A) := by + apply ZFSet.ext + intro z + rw [ZFSet.mem_sep,hφ,mem_sequenceSet] + constructor + · exact And.right + · rintro ⟨n,rfl⟩ + have hcn := hL hA (CodingExtraction.column_projection_reduces A n) + exact ⟨ZFSet.pair_mem_prod.mpr ⟨(mem_omega _).mpr ⟨n,rfl⟩, + (hrdef _).mpr ⟨_,hcn,rfl⟩⟩,⟨n,rfl⟩⟩ + exact eq ▸ hs + +def columnRange (A : Oracle) : ZFSet.{u} := ZFSet.range (fun n : ℕ => realSet (columns A n)) + +@[simp] theorem mem_columnRange (A : Oracle) (x : ZFSet.{u}) : + x ∈ columnRange A ↔ ∃ n, x = realSet (columns A n) := by + rw [columnRange,ZFSet.mem_range] + exact exists_congr (fun _ => eq_comm) + +theorem columnRange_mem (M : ZFSet.{u}) (hM : Transitive M) + (hPow : PowerSet M) (hS : Separation M) (hI : Infinity M) + {A : Oracle} (hcols : ∀ n, columns A n ∈ reals M) + (hseq : sequenceSet (columns A) ∈ M) : columnRange A ∈ M := by + obtain ⟨r,hr,hrdef⟩ := internal_reals M hM hPow hS hI + have hω := omega_mem M hM hS hI + let e := cons ZFSet.omega (fun _ => sequenceSet (columns A)) + have he : ∀ i, e i ∈ M := by intro i; cases i <;> simp [e,hω,hseq] + let φ : Formula := .existsMem 1 (.pairMem 0 1 3) + have hs := sep_mem M hM hS φ e he hr + have eq : ZFSet.sep (fun x => φ.Eval (cons x e)) r = columnRange A := by + apply ZFSet.ext + intro x + simp only [ZFSet.mem_sep,φ,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] + rw [omega_exists] + simp only [pair_mem_sequenceSet,mem_columnRange] + constructor + · exact And.right + · rintro ⟨n,rfl⟩ + exact ⟨(hrdef _).mpr ⟨_,hcols n,rfl⟩,⟨n,rfl⟩⟩ + exact eq ▸ hs + +end +end TuringRigidity.SetModelColumns + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelCountability.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelCountability.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f1fb94317888d2c9eaf199fe6eb48e75a537403 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelCountability.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelArithmeticDischarge + +namespace OAI + +namespace TuringRigidity.SetModelCountability +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions +open BoundedDefinability SetModelSyntax SetDegreeDecoding SetModelSequences +open PersistentRestrictions PersistentPresentation EncodedForcing +universe u +noncomputable section + +def FunctionGraph (f a b : ZFSet.{u}) : Prop := + (∀ z ∈ f, ∃ x ∈ a, ∃ y ∈ b, z = ZFSet.pair x y) ∧ + (∀ x ∈ a, ∃ y ∈ b, ZFSet.pair x y ∈ f ∧ + ∀ z ∈ b, ZFSet.pair x z ∈ f → z = y) + +def ontoFormula (f a b : ℕ) : Formula := + .conj (.functionGraph f a b) (.allMem b (.existsMem (a+1) (.pairMem 0 1 (f+2)))) + +@[simp] theorem eval_ontoFormula (f a b : ℕ) (e : ℕ → ZFSet.{u}) : + (ontoFormula f a b).Eval e ↔ FunctionGraph (e f) (e a) (e b) ∧ + ∀ y ∈ e b, ∃ x ∈ e a, ZFSet.pair x y ∈ e f := by + simp only [ontoFormula,Formula.Eval,Formula.eval_functionGraph,Formula.eval_allMem, + Formula.eval_pairMem,cons_zero,cons_succ,FunctionGraph] + +def InternallyCountable (M a : ZFSet.{u}) : Prop := + ∃ f ∈ M, (ontoFormula 0 1 2).Realize M (cons f (cons ZFSet.omega (fun _ => a))) + +def choiceFormula (f a b : ℕ) : Formula := + .conj (.functionGraph f a b) (.allMem a (.existsMem 0 (.pairMem 1 0 (f+2)))) + +@[simp] theorem eval_choiceFormula (f a b : ℕ) (e : ℕ → ZFSet.{u}) : + (choiceFormula f a b).Eval e ↔ FunctionGraph (e f) (e a) (e b) ∧ + ∀ x ∈ e a, ∃ y ∈ x, ZFSet.pair x y ∈ e f := by + simp only [choiceFormula,Formula.Eval,Formula.eval_functionGraph,Formula.eval_allMem, + Formula.eval_pairMem,cons_zero,cons_succ,FunctionGraph] + +def InternalChoice (M : ZFSet.{u}) : Prop := + ∀ a ∈ M, (∀ x ∈ M, x ∈ a → ∃ y ∈ M, y ∈ x) → + ∃ f ∈ M, (choiceFormula 0 1 2).Realize M + (cons f (cons a (fun _ => ZFSet.sUnion a))) + +variable {M : ZFSet.{u}} + +theorem countable_graph (C : Context M) {a : ZFSet.{u}} (ha : a ∈ M) + (hc : InternallyCountable M a) : + ∃ f ∈ M, FunctionGraph f ZFSet.omega a ∧ + ∀ y ∈ a, ∃ n : ℕ, ZFSet.pair (natSet n) y ∈ f := by + obtain ⟨f,hf,hfc⟩ := hc + have he : ∀ i, cons f (cons ZFSet.omega (fun _ => a)) i ∈ M := by + intro i + rcases i with _|_|i <;> simp [hf,C.omega_mem,ha] + have hh := ((ontoFormula 0 1 2).absolute M C.transitive _ he).mp hfc + rw [eval_ontoFormula] at hh + refine ⟨f,hf,hh.1,?_⟩ + intro y hy + simpa only [cons_zero,cons_succ,omega_exists] using hh.2 y hy + +theorem choice_graph (C : Context M) (hCh : InternalChoice M) + {a : ZFSet.{u}} (ha : a ∈ M) (hne : ∀ x ∈ a, ∃ y, y ∈ x) : + ∃ f ∈ M, FunctionGraph f a (ZFSet.sUnion a) ∧ + ∀ x ∈ a, ∃ y ∈ x, ZFSet.pair x y ∈ f := by + obtain ⟨f,hf,hfc⟩ := hCh a ha (fun x hx hxa => by + obtain ⟨y,hy⟩ := hne x hxa + exact ⟨y,C.transitive x hx y hy,hy⟩) + have hu := union_mem M C.transitive C.union ha + have he : ∀ i, cons f (cons a (fun _ => ZFSet.sUnion a)) i ∈ M := by + intro i + rcases i with _|_|i <;> simp [hf,ha,hu] + exact ⟨f,hf,(eval_choiceFormula 0 1 2 _).mp + (((choiceFormula 0 1 2).absolute M C.transitive _ he).mp hfc)⟩ + +theorem FunctionGraph.unique {f a b x y z : ZFSet.{u}} (h : FunctionGraph f a b) + (hx : x ∈ a) (hy : y ∈ b) (hz : z ∈ b) + (hxy : ZFSet.pair x y ∈ f) (hxz : ZFSet.pair x z ∈ f) : y = z := by + obtain ⟨v,hv,hxv,hu⟩ := h.2 x hx + exact (hu y hy hxy).trans (hu z hz hxz).symm + +theorem composition_mem (C : Context M) {a b c f g : ZFSet.{u}} + (ha : a ∈ M) (hb : b ∈ M) (hc : c ∈ M) (hf : f ∈ M) (hg : g ∈ M) : + ∃ q ∈ M, ∀ z, z ∈ q ↔ ∃ x ∈ a, ∃ y ∈ b, ∃ t ∈ c, + z = ZFSet.pair x t ∧ ZFSet.pair x y ∈ f ∧ ZFSet.pair y t ∈ g := by + let P := fun e : ℕ → ZFSet.{u} => ∃ x ∈ a, ∃ y ∈ b, ∃ t ∈ c, + e 0 = ZFSet.pair x t ∧ ZFSet.pair x y ∈ f ∧ ZFSet.pair y t ∈ g + have hP : Definable M P := + ((((orderedPair_definable C 3 2 0).and + ((pairMem_param hf 2 1).and (pairMem_param hg 1 0))).existsParam hc).existsParam hb).existsParam ha + let q := ZFSet.sep (fun z => P (cons z (fun _ => ZFSet.omega))) (ZFSet.prod a c) + refine ⟨q,hP.sep_mem C _ (fun _ => C.omega_mem) (C.prod_mem ha hc),?_⟩ + intro z + simp only [q,ZFSet.mem_sep,P,cons_zero] + constructor + · exact And.right + · rintro ⟨x,hx,y,hy,t,ht,rfl,hf,hg⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨hx,ht⟩,x,hx,y,hy,t,ht,rfl,hf,hg⟩ + +end +end TuringRigidity.SetModelCountability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelCountableExtensions.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelCountableExtensions.lean new file mode 100644 index 0000000000000000000000000000000000000000..005bc121ddc6eafc808cdeb5bf30371ee21207f4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelCountableExtensions.lean @@ -0,0 +1,39 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelPresentedCountability + +namespace OAI + +namespace TuringRigidity.SetModelCountability +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions SetModelSyntax +open SetDegreeDecoding PersistentRestrictions PersistentPresentation EncodedForcing +universe u +noncomputable section +variable {M : ZFSet.{u}} + +theorem persistent_countable_extensions (C : Context M) (hCh : InternalChoice M) + (I : CountableIdeal) (hI : idealSet I ∈ M) (hct : InternallyCountable M (idealSet I)) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + {X : Oracle} (hX : X ∈ reals M) : + ∃ (J : CountableIdeal) (σ : J ≃o J) (hIJ : I.carrier ⊆ J.carrier), + degree X ∈ J.carrier ∧ Extends hIJ ρ σ ∧ Persistent J σ ∧ + idealSet J ∈ M ∧ automorphismSet σ ∈ M ∧ InternallyCountable M (idealSet J) := by + obtain ⟨A,hAM,hA⟩ := countable_presentation C hCh I hI hct + let B := join A X + let J := JumpIdeal.generated (degree B) + let H := JumpIdealPresentation.presentation B + have hH : Presented J H := JumpIdealPresentation.presents B + have hHM : H ∈ reals M := (realClosure C).presentation ((realClosure C).join hAM hX) + have hIJ : I.carrier ⊆ J.carrier := by + intro y hy + obtain ⟨n,rfl⟩ := (hA y).mp hy + exact J.lower ((CodingExtraction.column_projection_reduces A n).trans + (reduces_join_left A X)) (JumpIdeal.includes _) + have hXJ : degree X ∈ J.carrier := J.lower (reduces_join_right A X) (JumpIdeal.includes _) + obtain ⟨σ,he,hσ⟩ := PersistentExtension.source_4_1_10 I J ρ hρ hz hIJ (JumpIdeal.closed _) + have hs := persistent_sets C hH hHM σ hσ (hIJ hz) + exact ⟨J,σ,hIJ,hXJ,he,hσ,hs.1,hs.2,countable_of_presentation C hH hHM⟩ + +end +end TuringRigidity.SetModelCountability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelCountablePresentation.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelCountablePresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..9db211eda681b92727ab18258f7d9afddd68f78a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelCountablePresentation.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelCountability + +namespace OAI + +namespace TuringRigidity.SetModelCountability +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions SetModelArithmetic +open BoundedDefinability SetModelSyntax SetDegreeDecoding SetModelSequences +open PersistentRestrictions PersistentPresentation EncodedForcing +universe u +noncomputable section +variable {M : ZFSet.{u}} + +theorem countable_presentation (C : Context M) (hCh : InternalChoice M) + (I : CountableIdeal) (hI : idealSet I ∈ M) + (hct : InternallyCountable M (idealSet I)) : + ∃ A ∈ reals M, Presented I A := by + obtain ⟨q,hq,hqf,hqo⟩ := countable_graph C hI hct + have hne : ∀ x ∈ idealSet I, ∃ y, y ∈ x := by + intro x hx + obtain ⟨a,ha,rfl⟩ := (mem_idealSet I x).mp hx + obtain ⟨B,rfl⟩ := degree_surjective a + exact ⟨realSet B,(real_mem_degreeSet B _).mpr rfl⟩ + obtain ⟨g,hg,hgf,hgc⟩ := choice_graph C hCh hI hne + let u := ZFSet.sUnion (idealSet I) + have hu : u ∈ M := union_mem M C.transitive C.union hI + have hex (n : ℕ) : ∃ B : Oracle, degree B ∈ I.carrier ∧ realSet B ∈ u ∧ + ZFSet.pair (natSet n) (degreeSet (degree B)) ∈ q ∧ + ZFSet.pair (degreeSet (degree B)) (realSet B) ∈ g := by + obtain ⟨d,hd,hnd,_⟩ := hqf.2 (natSet n) ((mem_omega _).mpr ⟨n,rfl⟩) + obtain ⟨x,hx,hdx⟩ := hgc d hd + obtain ⟨a,ha,hda⟩ := (mem_idealSet I d).mp hd + rw [hda] at hx + obtain ⟨B,hxB,hBa⟩ := (mem_degreeSet a x).mp hx + refine ⟨B,by simpa only [hBa] using ha,?_,?_,?_⟩ + · exact ZFSet.mem_sUnion.mpr ⟨d,hd,by simpa only [hda,←hxB] using hx⟩ + · simpa only [hda,←hBa] using hnd + · simpa only [hda,hxB,←hBa] using hdx + choose B hB using hex + obtain ⟨p,hp,hpc⟩ := composition_mem C C.omega_mem hI hu hq hg + have hseq : p = sequenceSet B := by + apply ZFSet.ext + intro z + rw [hpc,mem_sequenceSet] + constructor + · rintro ⟨x,hx,d,hd,t,ht,hz,hxd,hdt⟩ + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + have hd' : d = degreeSet (degree (B n)) := hqf.unique + ((mem_omega _).mpr ⟨n,rfl⟩) hd ((mem_idealSet I _).mpr ⟨_,(hB n).1,rfl⟩) + hxd (hB n).2.2.1 + have ht' : t = realSet (B n) := hgf.unique hd ht (hB n).2.1 hdt + (by simpa only [hd'] using (hB n).2.2.2) + exact ⟨n,by rw [hz,ht']⟩ + · rintro ⟨n,rfl⟩ + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,degreeSet (degree (B n)), + (mem_idealSet I _).mpr ⟨_,(hB n).1,rfl⟩,realSet (B n),(hB n).2.1,rfl, + (hB n).2.2.1,(hB n).2.2.2⟩ + have hBM (n : ℕ) : B n ∈ reals M := C.transitive u hu _ (hB n).2.1 + obtain ⟨r,hr,hrc⟩ := internal_reals M C.transitive C.power C.separation C.infinity + let A : Oracle := fun v => B (Nat.unpair v).1 (Nat.unpair v).2 + have hAM : A ∈ reals M := flatten_mem M C.transitive C.pairing C.union C.power + C.separation C.infinity hr hrc C.pairing_mem pairingSet_code B hBM (hseq ▸ hp) + have hcol (n : ℕ) : columns A n = B n := by + funext k + simp only [columns,A,Nat.unpair_pair] + refine ⟨A,hAM,?_⟩ + intro a + constructor + · intro ha + obtain ⟨n,hn⟩ := hqo (degreeSet a) ((mem_idealSet I _).mpr ⟨a,ha,rfl⟩) + have he := hqf.unique ((mem_omega _).mpr ⟨n,rfl⟩) + ((mem_idealSet I _).mpr ⟨_,(hB n).1,rfl⟩) ((mem_idealSet I _).mpr ⟨a,ha,rfl⟩) + (hB n).2.2.1 hn + exact ⟨n,by rw [hcol]; exact degreeSet_injective he⟩ + · rintro ⟨n,hn⟩ + rw [hcol] at hn + exact hn ▸ (hB n).1 + +theorem persistent_mem_of_countable (C : Context M) (hCh : InternalChoice M) + (I : CountableIdeal) (hI : idealSet I ∈ M) (hct : InternallyCountable M (idealSet I)) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + automorphismSet ρ ∈ M := by + obtain ⟨A,hAM,hA⟩ := countable_presentation C hCh I hI hct + exact (persistent_sets C hA hAM ρ hρ hz).2 + +end +end TuringRigidity.SetModelCountability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelDegreeUniverse.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelDegreeUniverse.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6f33e893d4b00d4db409a6c36e2033c683c3c15 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelDegreeUniverse.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelCountableExtensions + +namespace OAI + +namespace TuringRigidity.SetModelSatisfaction +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions SetModelSyntax +open SetPresentationDecoding SetDegreeDecoding UniformArithmetic +universe u +noncomputable section +variable {M : ZFSet.{u}} + +theorem degree_universe (C : Context M) : + ∃ D ∈ M, ∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A) := by + obtain ⟨r,hr,hrc⟩ := internal_reals M C.transitive C.power C.separation C.infinity + obtain ⟨E,hE,hEc⟩ := internal_degreeEquality_graph C + refine ⟨quotientSet r E r,quotient_mem M C.transitive C.power C.separation hr hE hr,?_⟩ + intro x + rw [mem_quotientSet] + constructor + · rintro ⟨a,ha,hx⟩ + obtain ⟨A,hA,rfl⟩ := (hrc a).mp ha + exact ⟨A,hA,hx.trans (class_eq_degreeSet M (lower_mem C) hrc hEc hA)⟩ + · rintro ⟨A,hA,rfl⟩ + exact ⟨realSet A,(hrc _).mpr ⟨A,hA,rfl⟩, + (class_eq_degreeSet M (lower_mem C) hrc hEc hA).symm⟩ + +theorem degree_order (C : Context M) : + ∃ L ∈ M, ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B := by + obtain ⟨r,hr,hrc⟩ := internal_reals M C.transitive C.power C.separation C.infinity + obtain ⟨E,hE,hEc⟩ := internal_degreeEquality_graph C + obtain ⟨R,hR,hRc⟩ := internal_binary_relation C Reduces + (reduces_arith (parameter_arith 0) (parameter_arith 1)) + refine ⟨actionGraph r E r R, + action_mem M C.transitive C.pairing C.union C.power C.separation hr hE hr hR,?_⟩ + intro A hA B hB + rw [mem_actionGraph] + constructor + · rintro ⟨x,hx,y,hy,hxy,he⟩ + obtain ⟨X,hX,rfl⟩ := (hrc x).mp hx + obtain ⟨Y,hY,rfl⟩ := (hrc y).mp hy + rw [class_eq_degreeSet M (lower_mem C) hrc hEc hX, + class_eq_degreeSet M (lower_mem C) hrc hEc hY] at he + obtain ⟨ha,hb⟩ := ZFSet.pair_inj.mp he + have ha' := degreeSet_injective ha + have hb' := degreeSet_injective hb + have hab := (hRc X hX Y hY).mp hxy + exact ((degree_eq_iff A X).mp ha').1.trans + (hab.trans ((degree_eq_iff B Y).mp hb').2) + · intro hab + refine ⟨realSet A,(hrc _).mpr ⟨A,hA,rfl⟩,realSet B,(hrc _).mpr ⟨B,hB,rfl⟩, + (hRc A hA B hB).mpr hab,?_⟩ + rw [class_eq_degreeSet M (lower_mem C) hrc hEc hA, + class_eq_degreeSet M (lower_mem C) hrc hEc hB] + +theorem represented_of_degreeSet_mem (C : Context M) {a : Degree} + (ha : degreeSet.{u} a ∈ M) : ∃ A ∈ reals M, degree A = a := by + obtain ⟨A,rfl⟩ := degree_surjective a + exact ⟨A,C.transitive _ ha _ ((real_mem_degreeSet A _).mpr rfl),rfl⟩ + +end +end TuringRigidity.SetModelSatisfaction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelFunctionGraphs.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelFunctionGraphs.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa47f1aebd013e4dce6bc7c1ef1948c9099fc1f2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelFunctionGraphs.lean @@ -0,0 +1,124 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelPairing +import OAI.Computability.DegreeRigidity.Syntax.BoundedFormulaRename + +namespace OAI + +namespace TuringRigidity.SetModelFunctions +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelIteration SetModelArithmetic +universe u +noncomputable section + +structure Context (M : ZFSet.{u}) : Prop where + transitive : Transitive M + pairing : Pairing M + union : BoundedSetTheory.Union M + power : PowerSet M + separation : Separation M + infinity : Infinity M + +variable {M : ZFSet.{u}} (C : Context M) +include C + +theorem Context.omega_mem : ZFSet.omega.{u} ∈ M := + BoundedSetTheory.omega_mem M C.transitive C.separation C.infinity + +theorem Context.nat_mem (n : ℕ) : natSet.{u} n ∈ M := + C.transitive _ C.omega_mem _ ((mem_omega _).mpr ⟨n,rfl⟩) + +theorem Context.prod_mem {a b : ZFSet.{u}} (ha : a ∈ M) (hb : b ∈ M) : + ZFSet.prod a b ∈ M := + product_mem M C.transitive C.pairing C.union C.power C.separation ha hb + +abbrev GraphCode (g : ZFSet.{u}) (f : ℕ → ℕ) : Prop := + ∀ n m, ZFSet.pair (natSet n) (natSet m) ∈ g ↔ m = f n + +def HasGraph (M : ZFSet.{u}) (f : ℕ → ℕ) : Prop := + ∃ g ∈ M, GraphCode g f + +theorem graph_of_formula (f : ℕ → ℕ) (p : Formula) (e : ℕ → ZFSet.{u}) + (he : ∀ i, e i ∈ M) + (hp : ∀ n m, p.Eval (cons (ZFSet.pair (natSet n) (natSet m)) e) ↔ m = f n) : + HasGraph M f := by + refine ⟨ZFSet.sep (fun z => p.Eval (cons z e)) pairNumbers, + sep_mem M C.transitive C.separation p e he (C.prod_mem C.omega_mem C.omega_mem),?_⟩ + intro n m + simp only [ZFSet.mem_sep,natPair_mem,true_and,hp] + +theorem graph_of_relation (f : ℕ → ℕ) (p : Formula) (e : ℕ → ZFSet.{u}) + (he : ∀ i, e i ∈ M) + (hp : ∀ n m, p.Eval (cons (natSet m) (cons (natSet n) e)) ↔ m = f n) : + HasGraph M f := by + let r : ℕ → ℕ := fun i => if i < 2 then i else i+2 + let q : Formula := .existsMem 1 (.existsMem 2 + (.conj (.orderedPair 2 1 0) (p.rename r))) + let d := cons ZFSet.omega e + apply graph_of_formula C f q d + · intro i + cases i with + | zero => exact C.omega_mem + | succ i => exact he i + · intro n m + simp only [q,d,Formula.Eval,Formula.eval_orderedPair,Formula.eval_rename_comp, + cons_zero,cons_succ] + constructor + · rintro ⟨x,hx,y,hy,hz,hp'⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hz + have hh : cons (natSet m) (cons (natSet n) + (cons (ZFSet.pair (natSet n) (natSet m)) (cons ZFSet.omega e))) ∘ r = + cons (natSet m) (cons (natSet n) e) := by + funext i + rcases i with _|_|i <;> simp [r,cons] + rw [hh] at hp' + exact (hp n m).mp hp' + · intro h + refine ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,natSet m, + (mem_omega _).mpr ⟨m,rfl⟩,rfl,?_⟩ + have hh : cons (natSet m) (cons (natSet n) + (cons (ZFSet.pair (natSet n) (natSet m)) (cons ZFSet.omega e))) ∘ r = + cons (natSet m) (cons (natSet n) e) := by + funext i + rcases i with _|_|i <;> simp [r,cons] + rw [hh] + exact (hp n m).mpr h + +theorem const_graph (k : ℕ) : HasGraph M (fun _ => k) := by + apply graph_of_relation C _ (.equal 0 2) (fun _ => natSet k) (fun _ => C.nat_mem k) + intro n m + exact ⟨fun h => natSet_injective h,fun h => congrArg natSet h⟩ + +theorem id_graph : HasGraph M id := by + apply graph_of_relation C _ (.equal 0 1) (fun _ => ZFSet.omega) (fun _ => C.omega_mem) + intro n m + exact ⟨fun h => natSet_injective h,fun h => congrArg natSet h⟩ + +theorem succ_graph : HasGraph M Nat.succ := by + refine ⟨successorSet,successorSet_mem M C.transitive C.pairing C.union C.power + C.separation C.infinity,?_⟩ + intro n m + rw [pair_mem_successorSet ((mem_omega _).mpr ⟨n,rfl⟩) + ((mem_omega _).mpr ⟨m,rfl⟩),setSucc_nat] + exact ⟨fun h => natSet_injective h,fun h => congrArg natSet h⟩ + +theorem HasGraph.comp {f g : ℕ → ℕ} (hf : HasGraph M f) (hg : HasGraph M g) : + HasGraph M (fun n => f (g n)) := by + obtain ⟨a,ha,hac⟩ := hf + obtain ⟨b,hb,hbc⟩ := hg + let e := cons ZFSet.omega (cons a (fun _ => b)) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|i <;> simp [e,C.omega_mem,ha,hb] + apply graph_of_relation C _ (.existsMem 2 (.conj (.pairMem 2 0 5) (.pairMem 0 1 4))) e he + intro n m + simp only [Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ,e] + rw [omega_exists] + simp only [hac,hbc] + constructor + · rintro ⟨k,rfl,h⟩ + exact h + · intro h + exact ⟨g n,rfl,h⟩ + +end +end TuringRigidity.SetModelFunctions + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelFunctionIteration.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelFunctionIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9d6359240c29b7c25adeabc844cd4ed88b2624c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelFunctionIteration.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelFunctionPairing + +namespace OAI + +namespace TuringRigidity.SetModelFunctions +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelIteration SetModelArithmetic +universe u +noncomputable section +variable {M : ZFSet.{u}} (C : Context M) +include C + +def natLift (f : ℕ → ℕ) (x : ZFSet.{u}) : ZFSet.{u} := + natSet (f (Function.invFun natSet x)) + +omit C in +@[simp] theorem natLift_nat (f : ℕ → ℕ) (n : ℕ) : + natLift f (natSet.{u} n) = natSet (f n) := by + simp only [natLift,Function.leftInverse_invFun natSet_injective n] + +omit C in +theorem natLift_closed (f : ℕ → ℕ) : ∀ x ∈ ZFSet.omega.{u}, natLift f x ∈ ZFSet.omega := by + intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + exact (mem_omega _).mpr ⟨f n,natLift_nat f n⟩ + +omit C in +theorem iterate_natLift (f : ℕ → ℕ) (n m : ℕ) : + (natLift f)^[n] (natSet.{u} m) = natSet (f^[n] m) := by + induction n with + | zero => rfl + | succ n ih => rw [Function.iterate_succ_apply',ih,natLift_nat,Function.iterate_succ_apply'] + +def natIteration (f : ℕ → ℕ) : ZFSet.{u} := iterationSet ZFSet.omega (natLift f) + +omit C in +theorem natIteration_code (f : ℕ → ℕ) (n m k : ℕ) : + ZFSet.pair (ZFSet.pair (natSet.{u} n) (natSet m)) (natSet k) ∈ natIteration f ↔ + k = f^[n] m := by + rw [natIteration,mem_iterationSet _ (natLift_closed f)] + constructor + · rintro ⟨i,x,hx,he⟩ + obtain ⟨hi,hk⟩ := ZFSet.pair_inj.mp he + obtain ⟨hnum,rfl⟩ := ZFSet.pair_inj.mp hi + have hin := natSet_injective hnum + rw [←hin,iterate_natLift] at hk + exact natSet_injective hk + · intro h + refine ⟨n,natSet m,(mem_omega _).mpr ⟨m,rfl⟩,?_⟩ + rw [iterate_natLift,h] + +theorem natIteration_mem {f : ℕ → ℕ} (hf : HasGraph M f) : natIteration.{u} f ∈ M := by + obtain ⟨g,hg,hgc⟩ := hf + apply iterationSet_mem M C.transitive C.pairing C.union C.power C.separation C.infinity + C.omega_mem hg (natLift f) (natLift_closed f) + intro x hx y hy + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + obtain ⟨m,rfl⟩ := (mem_omega y).mp hy + rw [hgc,natLift_nat] + exact ⟨fun h => congrArg natSet h,fun h => natSet_injective h⟩ + +theorem HasGraph.iterate {f : ℕ → ℕ} (hf : HasGraph M f) : + HasGraph M (fun v => f^[(Nat.unpair v).2] (Nat.unpair v).1) := by + let e := cons ZFSet.omega (cons pairNumbers (cons pairingSet (fun _ => natIteration f))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|i <;> + simp [e,C.omega_mem,C.pairNumbers_mem,C.pairing_mem,natIteration_mem C hf] + apply graph_of_relation C _ (.existsMem 2 (.existsMem 3 (.existsMem 5 + (.conj (tripleFormula 2 1 4 7 6) + (.conj (.orderedPair 0 1 2) (.pairMem 0 3 8)))))) e he + intro n m + simp only [Formula.Eval,eval_tripleFormula,Formula.eval_orderedPair,Formula.eval_pairMem, + cons_zero,cons_succ,e] + simp_rw [omega_exists] + simp only [natPair_mem,true_and,pairing_code] + constructor + · rintro ⟨a,b,t,ht,hn,rfl,h⟩ + rw [natIteration_code] at h + simpa only [hn,Nat.unpair_pair] using h + · intro h + refine ⟨(Nat.unpair n).1,(Nat.unpair n).2, + ZFSet.pair (natSet (Nat.unpair n).2) (natSet (Nat.unpair n).1), + natPair_mem _ _,(Nat.pair_unpair n).symm,rfl,?_⟩ + exact (natIteration_code _ _ _ _).mpr h + +end +end TuringRigidity.SetModelFunctions + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelFunctionPairing.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelFunctionPairing.lean new file mode 100644 index 0000000000000000000000000000000000000000..e4620cff1e9e80f402395a02dd190cbda0ca8375 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelFunctionPairing.lean @@ -0,0 +1,77 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelFunctionGraphs + +namespace OAI + +namespace TuringRigidity.SetModelFunctions +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelIteration SetModelArithmetic +universe u +noncomputable section +variable {M : ZFSet.{u}} (C : Context M) +include C + +theorem Context.pairing_mem : pairingSet.{u} ∈ M := + pairingSet_mem M C.transitive C.pairing C.union C.power C.separation C.infinity + +theorem Context.pairNumbers_mem : pairNumbers.{u} ∈ M := C.prod_mem C.omega_mem C.omega_mem + +omit C in +@[simp] theorem pairing_code (n m k : ℕ) : + ZFSet.pair (ZFSet.pair (natSet.{u} n) (natSet m)) (natSet k) ∈ pairingSet ↔ + k = Nat.pair n m := pairingSet_code n m k + +theorem left_graph : HasGraph M (fun n => (Nat.unpair n).1) := by + let e := cons ZFSet.omega (cons pairNumbers (fun _ => pairingSet)) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|i <;> simp [e,C.omega_mem,C.pairNumbers_mem,C.pairing_mem] + apply graph_of_relation C _ (.existsMem 2 (tripleFormula 1 0 2 5 4)) e he + intro n m + simp only [Formula.Eval,eval_tripleFormula,cons_zero,cons_succ,e] + rw [omega_exists] + simp only [natPair_mem,true_and,pairing_code] + constructor + · rintro ⟨k,rfl⟩ + simp + · intro h + exact ⟨(Nat.unpair n).2,by rw [h,Nat.pair_unpair]⟩ + +theorem right_graph : HasGraph M (fun n => (Nat.unpair n).2) := by + let e := cons ZFSet.omega (cons pairNumbers (fun _ => pairingSet)) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|i <;> simp [e,C.omega_mem,C.pairNumbers_mem,C.pairing_mem] + apply graph_of_relation C _ (.existsMem 2 (tripleFormula 0 1 2 5 4)) e he + intro n m + simp only [Formula.Eval,eval_tripleFormula,cons_zero,cons_succ,e] + rw [omega_exists] + simp only [natPair_mem,true_and,pairing_code] + constructor + · rintro ⟨k,rfl⟩ + simp + · intro h + exact ⟨(Nat.unpair n).1,by rw [h,Nat.pair_unpair]⟩ + +theorem HasGraph.pair {f g : ℕ → ℕ} (hf : HasGraph M f) (hg : HasGraph M g) : + HasGraph M (fun n => Nat.pair (f n) (g n)) := by + obtain ⟨a,ha,hac⟩ := hf + obtain ⟨b,hb,hbc⟩ := hg + let e := cons ZFSet.omega (cons a (cons b (cons pairNumbers (fun _ => pairingSet)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|i <;> simp [e,C.omega_mem,ha,hb,C.pairNumbers_mem,C.pairing_mem] + apply graph_of_relation C _ (.existsMem 2 (.existsMem 3 + (.conj (.pairMem 3 1 5) (.conj (.pairMem 3 0 6) (tripleFormula 1 0 2 8 7))))) e he + intro n m + simp only [Formula.Eval,Formula.eval_pairMem,eval_tripleFormula,cons_zero,cons_succ,e] + simp_rw [omega_exists] + simp only [hac,hbc,natPair_mem,true_and,pairing_code] + constructor + · rintro ⟨i,j,rfl,rfl,h⟩ + exact h + · intro h + exact ⟨f n,g n,rfl,rfl,h⟩ + +end +end TuringRigidity.SetModelFunctions + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelGraphImage.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelGraphImage.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e12cfe1b2a562ff92bf9511c050394349b97310 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelGraphImage.lean @@ -0,0 +1,93 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelColumns + +namespace OAI + +namespace TuringRigidity.SetModelColumns +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelSequences +open EncodedForcing +universe u +noncomputable section + +def graphImage (A G : Oracle) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ n m, G (Nat.pair n m) = true ∧ + z = ZFSet.pair (realSet (columns A n)) (realSet (columns A m))) + (ZFSet.prod (columnRange A) (columnRange A)) + +@[simp] theorem mem_graphImage (A G : Oracle) (z : ZFSet.{u}) : + z ∈ graphImage A G ↔ ∃ n m, G (Nat.pair n m) = true ∧ + z = ZFSet.pair (realSet (columns A n)) (realSet (columns A m)) := by + rw [graphImage,ZFSet.mem_sep] + constructor + · exact And.right + · rintro ⟨n,m,hG,rfl⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨(mem_columnRange _ _).mpr ⟨n,rfl⟩, + (mem_columnRange _ _).mpr ⟨m,rfl⟩⟩,⟨n,m,hG,rfl⟩⟩ + +def graphImageFormula : Formula := + .existsMem 1 (.existsMem 2 (.existsMem 4 (.existsMem 5 (.existsMem 10 (.existsMem 7 + (.conj (.orderedPair 6 5 4) (.conj (.pairMem 3 5 9) (.conj (.pairMem 2 4 9) + (.conj (.orderedPair 1 3 2) (.conj (.pairMem 1 0 11) (.member 0 10))))))))))) + +theorem eval_graphImageFormula (A G : Oracle) (p : ZFSet.{u}) (hpdef : PairingCode p) + (z : ZFSet.{u}) : + graphImageFormula.Eval (cons z (cons (columnRange A) (cons ZFSet.omega + (cons (sequenceSet (columns A)) (cons (realSet G) (cons p + (fun _ => ZFSet.prod ZFSet.omega ZFSet.omega))))))) ↔ + ∃ n m, G (Nat.pair n m) = true ∧ + z = ZFSet.pair (realSet (columns A n)) (realSet (columns A m)) := by + simp only [graphImageFormula,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + cons_zero,cons_succ] + constructor + · rintro ⟨x,hx,y,hy,n,hn,m,hm,t,ht,v,hv,hz,hnx,hmy,htnm,htv,hvG⟩ + obtain ⟨i,rfl⟩ := (mem_omega n).mp hn + obtain ⟨j,rfl⟩ := (mem_omega m).mp hm + obtain ⟨k,rfl⟩ := (mem_omega v).mp hv + have hxn := (pair_mem_sequenceSet (columns A) i x).mp hnx + have hym := (pair_mem_sequenceSet (columns A) j y).mp hmy + rw [htnm] at htv + have hk := (hpdef i j k).mp htv + refine ⟨i,j,?_,by simpa only [hxn,hym] using hz⟩ + simpa only [hk] using (nat_mem_realSet G k).mp hvG + · rintro ⟨n,m,hG,hz⟩ + have hn : natSet.{u} n ∈ ZFSet.omega := (mem_omega _).mpr ⟨n,rfl⟩ + have hm : natSet.{u} m ∈ ZFSet.omega := (mem_omega _).mpr ⟨m,rfl⟩ + refine ⟨_,(mem_columnRange A _).mpr ⟨n,rfl⟩,_,(mem_columnRange A _).mpr ⟨m,rfl⟩, + _,hn,_,hm,_,ZFSet.pair_mem_prod.mpr ⟨hn,hm⟩,_,(mem_omega _).mpr ⟨Nat.pair n m,rfl⟩, + hz,(pair_mem_sequenceSet (columns A) n _).mpr rfl, + (pair_mem_sequenceSet (columns A) m _).mpr rfl,rfl, + (hpdef n m (Nat.pair n m)).mpr rfl,(nat_mem_realSet G _).mpr hG⟩ + +theorem graphImage_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + {p : ZFSet.{u}} (hp : p ∈ M) (hpdef : PairingCode p) + {A G : Oracle} (hseq : sequenceSet (columns A) ∈ M) + (ha : columnRange A ∈ M) (hG : G ∈ reals M) : graphImage A G ∈ M := by + have hω := omega_mem M hM hS hI + have hd := product_mem M hM hP hU hPow hS hω hω + have hprod := product_mem M hM hP hU hPow hS ha ha + let e := cons (columnRange A) (cons ZFSet.omega (cons (sequenceSet (columns A)) + (cons (realSet G) (cons p (fun _ => ZFSet.prod ZFSet.omega ZFSet.omega))))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|_|i <;> simp only [e,cons_zero,cons_succ] + · exact ha + · exact hω + · exact hseq + · exact hG + · exact hp + · exact hd + have hs := sep_mem M hM hS graphImageFormula e he hprod + have eq : ZFSet.sep (fun z => graphImageFormula.Eval (cons z e)) + (ZFSet.prod (columnRange A) (columnRange A)) = graphImage A G := by + apply ZFSet.ext + intro z + rw [ZFSet.mem_sep,show graphImageFormula.Eval (cons z e) ↔ _ from + eval_graphImageFormula A G p hpdef z] + simp only [graphImage,ZFSet.mem_sep] + exact eq ▸ hs + +end +end TuringRigidity.SetModelColumns + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelGraphPresentation.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelGraphPresentation.lean new file mode 100644 index 0000000000000000000000000000000000000000..93c075ed80a2337dd0cbbd3b982b4bc2eee108c4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelGraphPresentation.lean @@ -0,0 +1,93 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelActionSatisfaction + +namespace OAI + +namespace TuringRigidity.SetModelSatisfaction +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions SetModelSyntax +open SetDegreeDecoding PersistentRestrictions PersistentPresentation PersistentCountability +open SetModelSequences SetModelColumns SetModelArithmetic EncodedForcing +universe u +noncomputable section + +def graphPresentationFormula : Formula := + .existsMem 1 (.existsMem 2 (.existsMem 5 (.existsMem 6 (.existsMem 8 (.existsMem 9 (.existsMem 13 + (.conj (.orderedPair 0 6 5) (.conj (.pairMem 0 7 13) + (.conj (.pairMem 6 4 9) (.conj (.pairMem 5 3 9) + (.conj (.member 4 2) (.conj (.member 3 1) (.pairMem 2 1 12))))))))))))) + +def graphPresentationEnv (I : CountableIdeal) (A : Oracle) (ρ : I ≃o I) : ℕ → ZFSet.{u} := + cons ZFSet.omega (cons (sequenceSet (columns A)) (cons (columnRange A) + (cons (idealSet I) (cons (automorphismSet ρ) (cons pairingSet (fun _ => pairNumbers)))))) + +theorem eval_graphPresentationFormula {I : CountableIdeal} {A : Oracle} (hA : Presented I A) + (ρ : I ≃o I) (k : ℕ) : + graphPresentationFormula.Eval (cons (natSet k) (graphPresentationEnv.{u} I A ρ)) ↔ Graph ρ hA k := by + simp only [graphPresentationFormula,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + graphPresentationEnv,cons_zero,cons_succ] + constructor + · rintro ⟨n,hn,m,hm,X,hX,Y,hY,a,ha,b,hb,t,ht,htnm,htk,hnX,hmY,hXa,hYb,hab⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + obtain ⟨m,rfl⟩ := (mem_omega m).mp hm + have hk : k = Nat.pair n m := (pairingSet_code n m k).mp (htnm ▸ htk) + obtain rfl := (pair_mem_sequenceSet (columns A) n X).mp hnX + obtain rfl := (pair_mem_sequenceSet (columns A) m Y).mp hmY + obtain ⟨a,hac,rfl⟩ := (mem_idealSet I a).mp ha + obtain ⟨b,hbc,rfl⟩ := (mem_idealSet I b).mp hb + have hna := (real_mem_degreeSet (columns A n) a).mp hXa + have hmb := (real_mem_degreeSet (columns A m) b).mp hYb + have he := (action_code ρ ⟨a,hac⟩ ⟨b,hbc⟩).mp hab + have hn' : entry hA n = ⟨a,hac⟩ := Subtype.ext hna + simp only [hk,PersistentPresentation.Graph,Nat.unpair_pair,hn'] + exact (congrArg Subtype.val he).trans hmb.symm + · intro hg + obtain ⟨⟨n,m⟩,rfl⟩ := Nat.pairEquiv.surjective k + have hn : natSet.{u} n ∈ ZFSet.omega := (mem_omega _).mpr ⟨n,rfl⟩ + have hm : natSet.{u} m ∈ ZFSet.omega := (mem_omega _).mpr ⟨m,rfl⟩ + refine ⟨natSet n,hn,natSet m,hm,realSet (columns A n),(mem_columnRange _ _).mpr ⟨n,rfl⟩, + realSet (columns A m),(mem_columnRange _ _).mpr ⟨m,rfl⟩, + degreeSet (degree (columns A n)),(mem_idealSet I _).mpr ⟨_,(entry hA n).property,rfl⟩, + degreeSet (degree (columns A m)),(mem_idealSet I _).mpr ⟨_,(entry hA m).property,rfl⟩, + ZFSet.pair (natSet n) (natSet m),ZFSet.mem_prod.mpr ⟨_,hn,_,hm,rfl⟩,rfl, + (pairingSet_code _ _ _).mpr rfl,(pair_mem_sequenceSet _ _ _).mpr rfl, + (pair_mem_sequenceSet _ _ _).mpr rfl,(real_mem_degreeSet _ _).mpr rfl, + (real_mem_degreeSet _ _).mpr rfl,?_⟩ + exact (action_code ρ (entry hA n) (entry hA m)).mpr + (Subtype.ext (by simpa [PersistentPresentation.Graph,entry] using hg)) + +theorem internal_graph_presentation {M : ZFSet.{u}} (C : Context M) + {I : CountableIdeal} {A : Oracle} (hA : Presented I A) (hAM : A ∈ reals M) + (hIM : idealSet I ∈ M) (ρ : I ≃o I) (hρM : automorphismSet ρ ∈ M) : + graphOracle hA ρ ∈ reals M := by + have hseq := columns_mem M C.transitive C.pairing C.union C.power C.separation C.infinity + (lower_mem C) C.pairing_mem pairingSet_code hAM + have hcols : ∀ n, columns A n ∈ reals M := + fun n => lower_mem C hAM (CodingExtraction.column_projection_reduces A n) + have hrange := columnRange_mem M C.transitive C.power C.separation C.infinity hcols hseq + have hpairs := product_mem M C.transitive C.pairing C.union C.power C.separation C.omega_mem C.omega_mem + have he : ∀ i, graphPresentationEnv.{u} I A ρ i ∈ M := by + intro i + rcases i with _|_|_|_|_|_|i <;> + simp [graphPresentationEnv,C.omega_mem,hseq,hrange,hIM,hρM,C.pairing_mem,hpairs,pairNumbers] + have hs := sep_mem M C.transitive C.separation graphPresentationFormula _ he C.omega_mem + have heq : ZFSet.sep (fun z => graphPresentationFormula.Eval (cons z (graphPresentationEnv.{u} I A ρ))) + ZFSet.omega = realSet (graphOracle hA ρ) := by + apply ZFSet.ext + intro z + rw [ZFSet.mem_sep] + constructor + · rintro ⟨hz,h⟩ + obtain ⟨n,rfl⟩ := (mem_omega z).mp hz + exact (nat_mem_realSet _ _).mpr (by + simpa [graphOracle] using (eval_graphPresentationFormula hA ρ n).mp h) + · intro hz + obtain ⟨n,rfl⟩ := (mem_omega z).mp (realSet_subset _ hz) + have hn := (nat_mem_realSet _ n).mp hz + exact ⟨(mem_omega _).mpr ⟨n,rfl⟩,(eval_graphPresentationFormula hA ρ n).mpr (by + simpa [graphOracle] using hn)⟩ + change realSet.{u} (graphOracle hA ρ) ∈ M + exact heq ▸ hs + +end +end TuringRigidity.SetModelSatisfaction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelIdealDecoding.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelIdealDecoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..1eba627e039b5c03a00621ee9aae5c2ad26926bf --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelIdealDecoding.lean @@ -0,0 +1,75 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelPersistentSatisfaction + +namespace OAI + +namespace TuringRigidity.SetModelSatisfaction +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions SetModelSyntax +open SetDegreeDecoding PersistentRestrictions SetModelCountability +universe u +noncomputable section +variable {M : ZFSet.{u}} + +theorem externally_countable (C : Context M) {a : ZFSet.{u}} (ha : a ∈ M) + (hct : InternallyCountable M a) : (a : Set ZFSet.{u}).Countable := by + obtain ⟨f,hf,hfg,hfo⟩ := countable_graph C ha hct + have hex (n : ℕ) : ∃ y, y ∈ a ∧ ZFSet.pair (natSet n) y ∈ f := by + obtain ⟨y,hy,hny,_⟩ := hfg.2 (natSet n) ((mem_omega _).mpr ⟨n,rfl⟩) + exact ⟨y,hy,hny⟩ + choose F hF using hex + apply (Set.countable_range F).mono + intro x hx + obtain ⟨n,hn⟩ := hfo x hx + exact ⟨n,hfg.unique ((mem_omega _).mpr ⟨n,rfl⟩) (hF n).1 hx (hF n).2 hn⟩ + +theorem decode_ideal (C : Context M) {D L a : ZFSet.{u}} + (hD : ∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A)) + (hL : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + (haM : a ∈ M) (ha : IsIdeal a D L) (hct : InternallyCountable M a) : + ∃ I : CountableIdeal, idealSet I = a := by + let K : Set Degree := {b | degreeSet b ∈ a} + have hrep {b : Degree} (hb : b ∈ K) : ∃ B ∈ reals M, degree B = b := by + obtain ⟨B,hB,hb'⟩ := (hD _).mp (ha.1 (show degreeSet b ∈ a from hb)) + exact ⟨B,hB,(degreeSet_injective hb').symm⟩ + have hlo {b c : Degree} (hbc : b ≤ c) (hc : c ∈ K) : b ∈ K := by + obtain ⟨B,rfl⟩ := degree_surjective b + obtain ⟨C',hC',hCc⟩ := hrep hc + have hBC : Reduces B C' := by change degree B ≤ degree C'; rw [hCc]; exact hbc + have hB := lower_mem C hC' hBC + have hDB : degreeSet (degree B) ∈ D := (hD _).mpr ⟨B,hB,rfl⟩ + apply ha.2.2.1 (degreeSet c) hc _ hDB + rw [←hCc] + exact (hL B hB C' hC').mpr hBC + have hne : K.Nonempty := by + obtain ⟨x,hx⟩ := ha.2.1 + obtain ⟨A,hA,hxA⟩ := (hD x).mp (ha.1 hx) + exact ⟨degree A,by change degreeSet (degree A) ∈ a; rw [←hxA]; exact hx⟩ + have hcount : K.Countable := + (externally_countable C haM hct).preimage degreeSet_injective + have hjoin {b c : Degree} (hb : b ∈ K) (hc : c ∈ K) : b⊔c ∈ K := by + obtain ⟨z,hz,hbz,hcz⟩ := ha.2.2.2 (degreeSet b) hb (degreeSet c) hc + obtain ⟨A,hA,hzA⟩ := (hD z).mp (ha.1 hz) + have hzK : degree A ∈ K := by change degreeSet (degree A) ∈ a; rw [←hzA]; exact hz + have hbM := C.transitive _ haM (degreeSet b) hb + have hcM := C.transitive _ haM (degreeSet c) hc + have hzM := C.transitive _ haM _ hz + rw [hzA] at hbz hcz hzM + have hbA := (order_code C hL hbM hzM).mp hbz + have hcA := (order_code C hL hcM hzM).mp hcz + exact hlo (sup_le hbA hcA) hzK + let I : CountableIdeal := ⟨K,hne,hcount,fun {_ _} h h' => hlo h h',fun {_ _} h h' => hjoin h h'⟩ + refine ⟨I,?_⟩ + apply ZFSet.ext + intro x + rw [mem_idealSet] + constructor + · rintro ⟨b,hb,rfl⟩ + exact hb + · intro hx + obtain ⟨A,hA,hxA⟩ := (hD x).mp (ha.1 hx) + exact ⟨degree A,by change degreeSet (degree A) ∈ a; rw [←hxA]; exact hx,hxA⟩ + +end +end TuringRigidity.SetModelSatisfaction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelIdealSatisfaction.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelIdealSatisfaction.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b7ab721d771e8fcc95316e796d835c8dbf26c67 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelIdealSatisfaction.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelDegreeUniverse + +namespace OAI + +namespace TuringRigidity.SetModelSatisfaction +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions SetModelSyntax +open SetDegreeDecoding PersistentRestrictions SetModelCountability +universe u +noncomputable section +variable {M : ZFSet.{u}} + +def idealFormula (i d l : ℕ) : Formula := + .conj (.subset i d) (.conj (.existsMem i (.equal 0 0)) + (.conj (.allMem i (.allMem (d+1) (.imp (.pairMem 0 1 (l+2)) (.member 0 (i+2))))) + (.allMem i (.allMem (i+1) (.existsMem (i+2) + (.conj (.pairMem 2 0 (l+3)) (.pairMem 1 0 (l+3)))))))) + +def IsIdeal (a d l : ZFSet.{u}) : Prop := + a ⊆ d ∧ (∃ x, x ∈ a) ∧ + (∀ x ∈ a, ∀ y ∈ d, ZFSet.pair y x ∈ l → y ∈ a) ∧ + (∀ x ∈ a, ∀ y ∈ a, ∃ z ∈ a, ZFSet.pair x z ∈ l ∧ ZFSet.pair y z ∈ l) + +@[simp] theorem eval_idealFormula (i d l : ℕ) (e : ℕ → ZFSet.{u}) : + (idealFormula i d l).Eval e ↔ IsIdeal (e i) (e d) (e l) := by + simp only [idealFormula,Formula.Eval,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_imp,Formula.eval_pairMem,cons_zero,cons_succ,IsIdeal,and_true] + +theorem order_code (C : Context M) {L : ZFSet.{u}} + (hL : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + {a b : Degree} (ha : degreeSet.{u} a ∈ M) (hb : degreeSet.{u} b ∈ M) : + ZFSet.pair (degreeSet a) (degreeSet b) ∈ L ↔ a ≤ b := by + obtain ⟨A,hA,rfl⟩ := represented_of_degreeSet_mem C ha + obtain ⟨B,hB,rfl⟩ := represented_of_degreeSet_mem C hb + exact hL A hA B hB + +theorem ideal_satisfaction (C : Context M) {D L : ZFSet.{u}} + (hD : ∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A)) + (hL : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + (I : CountableIdeal) (hI : idealSet I ∈ M) : IsIdeal (idealSet I) D L := by + have hm {a : Degree} (ha : a ∈ I.carrier) : degreeSet.{u} a ∈ M := + C.transitive _ hI _ ((mem_idealSet I _).mpr ⟨a,ha,rfl⟩) + refine ⟨?_,?_,?_,?_⟩ + · intro x hx + obtain ⟨a,ha,rfl⟩ := (mem_idealSet I x).mp hx + obtain ⟨A,hA,hAa⟩ := represented_of_degreeSet_mem C (hm ha) + exact (hD _).mpr ⟨A,hA,by rw [hAa]⟩ + · obtain ⟨a,ha⟩ := I.nonempty + exact ⟨degreeSet a,(mem_idealSet I _).mpr ⟨a,ha,rfl⟩⟩ + · intro x hx y hy hyx + obtain ⟨a,ha,rfl⟩ := (mem_idealSet I x).mp hx + obtain ⟨B,hB,rfl⟩ := (hD y).mp hy + obtain ⟨A,hA,rfl⟩ := represented_of_degreeSet_mem C (hm ha) + have hba := (hL B hB A hA).mp hyx + exact (mem_idealSet I _).mpr ⟨_,I.lower hba ha,rfl⟩ + · intro x hx y hy + obtain ⟨a,ha,rfl⟩ := (mem_idealSet I x).mp hx + obtain ⟨b,hb,rfl⟩ := (mem_idealSet I y).mp hy + have hc := I.join_mem ha hb + refine ⟨degreeSet (a⊔b),(mem_idealSet I _).mpr ⟨_,hc,rfl⟩, + (order_code C hL (hm ha) (hm hc)).mpr le_sup_left, + (order_code C hL (hm hb) (hm hc)).mpr le_sup_right⟩ + +end +end TuringRigidity.SetModelSatisfaction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelInternalRelations.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelInternalRelations.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f4de1d9b2a030ada0c3bfcceb0e93f8f229fea6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelInternalRelations.lean @@ -0,0 +1,83 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelArithmeticClosure + +namespace OAI + +namespace TuringRigidity.SetModelSyntax +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelArithmetic SetModelFunctions +open BoundedDefinability UniformArithmetic Encodable +universe u +noncomputable section +variable {M : ZFSet.{u}} + +theorem orderedPair_definable (C : Context M) (i j k : ℕ) : + Definable M (fun e => e i = ZFSet.pair (e j) (e k)) := + ⟨.orderedPair (2*i) (2*j) (2*k),fun _ => ZFSet.omega, + fun _ => C.omega_mem,fun e => by simp⟩ + +theorem binary_definition (C : Context M) (R : Oracle → Oracle → Prop) + (hR : Arith (fun O _ => R (O 0) (O 1))) : + Definable M (fun e => R (oracleOf (e 0)) (oracleOf (e 1))) := by + obtain ⟨Q,hQ,hc⟩ := arith_definition C hR + apply (hQ.existsParam C.omega_mem).congr + intro e + rw [omega_exists] + constructor + · rintro ⟨n,hn⟩ + exact (hc (cons (natSet n) e) n rfl).mp hn + · intro h + exact ⟨0,(hc (cons (natSet 0) e) 0 rfl).mpr h⟩ + +theorem internal_binary_relation (C : Context M) (R : Oracle → Oracle → Prop) + (hR : Arith (fun O _ => R (O 0) (O 1))) : + ∃ g ∈ M, ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ g ↔ R A B := by + obtain ⟨r,hr,hrc⟩ := internal_reals M C.transitive C.power C.separation C.infinity + have hd := binary_definition C R hR + let S := fun e : ℕ → ZFSet.{u} => ∃ x ∈ r, ∃ y ∈ r, + e 0 = ZFSet.pair x y ∧ R (oracleOf x) (oracleOf y) + have hS : Definable M S := by + have h := ((orderedPair_definable C 2 1 0).and + (hd.subst (fun i => if i=0 then 1 else 0))).existsParam hr + exact h.existsParam hr + let g := ZFSet.sep (fun z => S (cons z (fun _ => ZFSet.omega))) (ZFSet.prod r r) + refine ⟨g,hS.sep_mem C (fun _ => ZFSet.omega) (fun _ => C.omega_mem) (C.prod_mem hr hr),?_⟩ + intro A hA B hB + have ha : realSet A ∈ r := (hrc _).mpr ⟨A,hA,rfl⟩ + have hb : realSet B ∈ r := (hrc _).mpr ⟨B,hB,rfl⟩ + simp only [g,ZFSet.mem_sep,ZFSet.pair_mem_prod,ha,hb,true_and,S,cons_zero] + constructor + · rintro ⟨x,hx,y,hy,hxy,h⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hxy + simpa only [oracleOf_realSet] using h + · intro h + exact ⟨realSet A,ha,realSet B,hb,rfl,by simpa only [oracleOf_realSet] using h⟩ + +theorem jump_equal_arith : Arith (fun O _ => O 1 = OracleJump.jump (O 0)) := by + have h := ((query_at (parameter_arith 1) (Primrec.const 0) right_primrec).iff + (query_at (jump_arith (parameter_arith 0)) (Primrec.const 0) right_primrec)).all + apply h.congr + intro O v + simp only [right,Nat.unpair_pair] + constructor + · intro hh + funext n + have hn := hh n + cases ha : O 1 n <;> cases hb : OracleJump.jump (O 0) n <;> simp_all + · intro h n + rw [h] + +theorem internal_jump_graph (C : Context M) : + ∃ g ∈ M, ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ g ↔ B = OracleJump.jump A := + internal_binary_relation C (fun A B => B = OracleJump.jump A) jump_equal_arith + +theorem internal_degreeEquality_graph (C : Context M) : + ∃ g ∈ M, ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ g ↔ degree A = degree B := + internal_binary_relation C (fun A B => degree A = degree B) + (degree_equal_arith (parameter_arith 0) (parameter_arith 1)) + +end +end TuringRigidity.SetModelSyntax + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelIteration.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..111003992784fce4fa48d4da66ce4cf7501361fe --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelIteration.lean @@ -0,0 +1,136 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelReals + +namespace OAI + +namespace TuringRigidity.SetModelIteration +open BoundedSetTheory TransitiveNameModel SetModelReals +universe u +noncomputable section + +def finiteGraph (n : ℕ) (f : ℕ → ZFSet.{u}) : ZFSet.{u} := + ZFSet.range (fun i : Fin n => ZFSet.pair (natSet i.val) (f i.val)) + +@[simp] theorem mem_finiteGraph (n : ℕ) (f : ℕ → ZFSet.{u}) (z : ZFSet.{u}) : + z ∈ finiteGraph n f ↔ ∃ i < n, z = ZFSet.pair (natSet i) (f i) := by + rw [finiteGraph,ZFSet.mem_range] + exact ⟨fun ⟨i,hi⟩ => ⟨i.val,i.isLt,hi.symm⟩,fun ⟨i,hi,h⟩ => ⟨⟨i,hi⟩,h.symm⟩⟩ + +@[simp] theorem pair_mem_finiteGraph (n : ℕ) (f : ℕ → ZFSet.{u}) (i : ℕ) (y : ZFSet.{u}) : + ZFSet.pair (natSet i) y ∈ finiteGraph n f ↔ i < n ∧ y = f i := by + rw [mem_finiteGraph] + constructor + · rintro ⟨j,hj,he⟩ + obtain ⟨hn,hy⟩ := ZFSet.pair_inj.mp he + have hi := natSet_injective hn + exact ⟨hi ▸ hj,hi ▸ hy⟩ + · rintro ⟨hi,rfl⟩ + exact ⟨i,hi,rfl⟩ + +theorem finiteGraph_zero (f : ℕ → ZFSet.{u}) : finiteGraph 0 f = ∅ := by + apply ZFSet.ext + intro z + simp only [mem_finiteGraph,Nat.not_lt_zero,false_and,exists_false,ZFSet.notMem_empty] + +theorem finiteGraph_succ (n : ℕ) (f : ℕ → ZFSet.{u}) : + finiteGraph (n+1) f = insert (ZFSet.pair (natSet n) (f n)) (finiteGraph n f) := by + apply ZFSet.ext + intro z + simp only [mem_finiteGraph,ZFSet.mem_insert_iff] + constructor + · rintro ⟨i,hi,he⟩ + rcases Nat.lt_or_eq_of_le (Nat.le_of_lt_succ hi) with hi|rfl + · exact Or.inr ⟨i,hi,he⟩ + · exact Or.inl he + · rintro (he|⟨i,hi,he⟩) + · exact ⟨n,Nat.lt_succ_self n,he⟩ + · exact ⟨i,Nat.lt_succ_of_lt hi,he⟩ + +theorem finiteGraph_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hω : ZFSet.omega.{u} ∈ M) + (n : ℕ) (f : ℕ → ZFSet.{u}) (hf : ∀ i < n, f i ∈ M) : finiteGraph n f ∈ M := by + induction n with + | zero => + rw [finiteGraph_zero] + exact hM _ hω _ ZFSet.omega_zero + | succ n ih => + rw [finiteGraph_succ] + have hn := hM _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩) + have hp := orderedPair_mem M hM hP hn (hf n (Nat.lt_succ_self n)) + have hs := singleton_mem M hM hP hp + have hu := binary_union_mem M hM hP hU hs (ih (fun i hi => hf i (Nat.lt_succ_of_lt hi))) + have he : ({ZFSet.pair (natSet n) (f n)} : ZFSet.{u}) ∪ finiteGraph n f = + insert (ZFSet.pair (natSet n) (f n)) (finiteGraph n f) := by + apply ZFSet.ext + intro z + simp only [ZFSet.mem_union,ZFSet.mem_singleton,ZFSet.mem_insert_iff] + exact he ▸ hu + +def traceFormula (n x y p v g w z : ℕ) : Formula := + .conj (.pairMem z x p) + (.conj (.allMem n (.allMem (v+1) (.imp (.pairMem 1 0 (p+2)) + (.existsMem (w+2) (.conj (.successor 0 2) + (.existsMem (v+3) (.conj (.pairMem 1 0 (p+4)) (.pairMem 2 0 (g+4))))))))) + (.allMem v (.imp (.pairMem (n+1) 0 (p+1)) (.equal 0 (y+1))))) + +def Trace (v g : ZFSet.{u}) (n : ℕ) (x y p : ZFSet.{u}) : Prop := + ZFSet.pair (natSet 0) x ∈ p ∧ + (∀ i < n, ∀ a ∈ v, ZFSet.pair (natSet i) a ∈ p → + ∃ b ∈ v, ZFSet.pair (natSet (i+1)) b ∈ p ∧ ZFSet.pair a b ∈ g) ∧ + ∀ b ∈ v, ZFSet.pair (natSet n) b ∈ p → b = y + +theorem eval_traceFormula (n x y p v g w z : ℕ) (e : ℕ → ZFSet.{u}) + (k : ℕ) (hn : e n = natSet k) (hw : e w = ZFSet.omega) (hz : e z = natSet 0) : + (traceFormula n x y p v g w z).Eval e ↔ Trace (e v) (e g) k (e x) (e y) (e p) := by + simp only [traceFormula,Formula.Eval,Formula.eval_pairMem,Formula.eval_allMem, + Formula.eval_imp,Formula.eval_successor,cons_zero,cons_succ,hn,hw,hz,Trace] + apply and_congr Iff.rfl + apply and_congr _ Iff.rfl + constructor + · intro h i hi a ha hp + obtain ⟨s,_,hs,b,hb,hpb,hgb⟩ := h (natSet i) ((natSet_mem_natSet i k).mpr hi) a ha hp + exact ⟨b,hb,by simpa only [hs,natSet] using hpb,hgb⟩ + · intro h i hi a ha hp + obtain ⟨j,hj,rfl⟩ := (mem_natSet k i).mp hi + obtain ⟨b,hb,hpb,hgb⟩ := h j hj a ha hp + exact ⟨natSet (j+1),(mem_omega _).mpr ⟨j+1,rfl⟩,rfl,b,hb,hpb,hgb⟩ + +theorem iterate_mem {v : ZFSet.{u}} (F : ZFSet.{u} → ZFSet.{u}) + (hF : ∀ x ∈ v, F x ∈ v) {x : ZFSet.{u}} (hx : x ∈ v) (n : ℕ) : F^[n] x ∈ v := by + induction n with + | zero => exact hx + | succ n ih => simpa only [Function.iterate_succ_apply'] using hF _ ih + +theorem trace_correct {v g : ZFSet.{u}} (F : ZFSet.{u} → ZFSet.{u}) + (hF : ∀ x ∈ v, F x ∈ v) + (hg : ∀ x ∈ v, ∀ y ∈ v, ZFSet.pair x y ∈ g ↔ y = F x) + {n : ℕ} {x y p : ZFSet.{u}} (hx : x ∈ v) (ht : Trace v g n x y p) : y = F^[n] x := by + have hp (i : ℕ) (hi : i ≤ n) : ZFSet.pair (natSet i) (F^[i] x) ∈ p := by + induction i with + | zero => exact ht.1 + | succ i ih => + have hv := iterate_mem F hF hx i + obtain ⟨b,hb,hpb,hgb⟩ := ht.2.1 i (by omega) _ hv (ih (by omega)) + have he := (hg _ hv b hb).mp hgb + simpa only [he,Function.iterate_succ_apply'] using hpb + exact (ht.2.2 _ (iterate_mem F hF hx n) (hp n le_rfl)).symm + +theorem finiteGraph_trace {v g : ZFSet.{u}} (F : ZFSet.{u} → ZFSet.{u}) + (hF : ∀ x ∈ v, F x ∈ v) + (hg : ∀ x ∈ v, ∀ y ∈ v, ZFSet.pair x y ∈ g ↔ y = F x) + {x : ZFSet.{u}} (hx : x ∈ v) (n : ℕ) : + Trace v g n x (F^[n] x) (finiteGraph (n+1) (fun i => F^[i] x)) := by + refine ⟨(pair_mem_finiteGraph _ _ _ _).mpr ⟨by omega,rfl⟩,?_,?_⟩ + · intro i hi a ha hpa + have he := ((pair_mem_finiteGraph _ _ _ _).mp hpa).2 + subst a + refine ⟨F^[i+1] x,iterate_mem F hF hx (i+1), + (pair_mem_finiteGraph _ _ _ _).mpr ⟨by omega,rfl⟩,?_⟩ + apply (hg _ (iterate_mem F hF hx i) _ (iterate_mem F hF hx (i+1))).mpr + exact Function.iterate_succ_apply' F i x + · intro b _ hpb + exact ((pair_mem_finiteGraph _ _ _ _).mp hpb).2 + +end +end TuringRigidity.SetModelIteration + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelJoin.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelJoin.lean new file mode 100644 index 0000000000000000000000000000000000000000..4dc4cadef7aca6ea4daf3184510b4c6985b3f179 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelJoin.lean @@ -0,0 +1,66 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelPairing +import OAI.Computability.DegreeRigidity.Computability.Joins + +namespace OAI + +namespace TuringRigidity.SetModelArithmetic +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelIteration +universe u +noncomputable section + +theorem natSet_successor_eq (n m : ℕ) : + natSet.{u} n = insert (natSet m) (natSet m) ↔ n = m+1 := by + change natSet n = natSet (m+1) ↔ n = m+1 + exact natSet_injective.eq_iff + +theorem join_true_iff (A B : Oracle) (v : ℕ) : join A B v = true ↔ + ∃ n, (v = 2*n ∧ A n = true) ∨ (v = 2*n+1 ∧ B n = true) := by + constructor + · intro h + have hv : v = 2*(v/2) ∨ v = 2*(v/2)+1 := by omega + refine ⟨v/2,?_⟩ + rcases hv with he|he + · exact Or.inl ⟨he,(join_even A B (v/2)).symm.trans ((congrArg (join A B) he).symm.trans h)⟩ + · exact Or.inr ⟨he,(join_odd A B (v/2)).symm.trans ((congrArg (join A B) he).symm.trans h)⟩ + · rintro ⟨n,⟨rfl,hA⟩|⟨rfl,hB⟩⟩ + · exact (join_even A B n).trans hA + · exact (join_odd A B n).trans hB + +def joinFormula : Formula := + .existsMem 1 (.disj (.conj (tripleFormula 0 0 1 5 6) (.member 0 3)) + (.existsMem 2 (.conj (tripleFormula 1 1 0 6 7) + (.conj (.successor 2 0) (.member 1 5))))) + +theorem eval_joinFormula (A B : Oracle) (v : ℕ) : + joinFormula.Eval (cons (natSet.{u} v) (cons ZFSet.omega (cons (realSet A) + (cons (realSet B) (cons additionSet (fun _ => pairNumbers)))))) ↔ join A B v = true := by + simp only [joinFormula,Formula.Eval,Formula.eval_disj,eval_tripleFormula, + Formula.eval_successor,cons_zero,cons_succ] + simp_rw [omega_exists] + simp only [natPair_mem,true_and,addition_code,natSet_successor_eq,nat_mem_realSet] + rw [join_true_iff] + simp [two_mul] + +theorem join_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + {A B : Oracle} (hA : A ∈ reals M) (hB : B ∈ reals M) : join A B ∈ reals M := by + have hω := omega_mem M hM hS hI + have hd : pairNumbers.{u} ∈ M := product_mem M hM hP hU hPow hS hω hω + have ha := additionSet_mem M hM hP hU hPow hS hI + let e := cons ZFSet.omega (cons (realSet A) (cons (realSet B) + (cons additionSet (fun _ => pairNumbers)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|i <;> simp only [e,cons_zero,cons_succ] + · exact hω + · exact hA + · exact hB + · exact ha + · exact hd + exact real_comprehension M hM hS hI (join A B) joinFormula e he (eval_joinFormula A B) + +end +end TuringRigidity.SetModelArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelMultiplication.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelMultiplication.lean new file mode 100644 index 0000000000000000000000000000000000000000..4180dcc31bbe63fbf7df3543a12129235ca2cd67 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelMultiplication.lean @@ -0,0 +1,117 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelMultiplicationStep + +namespace OAI + +namespace TuringRigidity.SetModelArithmetic +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelIteration +universe u +noncomputable section + +def mulFormula (n m k i d D z : ℕ) : Formula := + .existsMem d (.existsMem (d+1) (.existsMem (D+2) + (.conj (.orderedPair 2 (m+3) (z+3)) (.conj (.orderedPair 1 (m+3) (k+3)) + (.conj (.orderedPair 0 (n+3) 2) (.pairMem 0 1 (i+3))))))) + +theorem eval_mulFormula (n m k i d D z : ℕ) (e : ℕ → ZFSet.{u}) (a b c : ℕ) + (hn : e n = natSet a) (hm : e m = natSet b) (hk : e k = natSet c) + (hi : e i = multiplicationIteration) (hd : e d = pairNumbers) + (hD : e D = ZFSet.prod ZFSet.omega pairNumbers) (hz : e z = natSet 0) : + (mulFormula n m k i d D z).Eval e ↔ c = a*b := by + simp only [mulFormula,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + cons_zero,cons_succ,hn,hm,hk,hi,hd,hD,hz] + constructor + · rintro ⟨s,hs,t,ht,w,hw,hsb,htbc,hwas,hwt⟩ + change ZFSet.pair w t ∈ iterationSet pairNumbers addStep at hwt + obtain ⟨q,x,hx,he⟩ := (mem_iterationSet addStep addStep_closed _).mp hwt + obtain ⟨hleft,hright⟩ := ZFSet.pair_inj.mp he + rw [hwas] at hleft + obtain ⟨hqa,hxs⟩ := ZFSet.pair_inj.mp hleft + have hq := natSet_injective hqa + rw [←hxs,hsb,←hq] at hright + change t = addStep^[a] (numberPair (b,0)) at hright + rw [iterate_addStep,htbc] at hright + exact natSet_injective (ZFSet.pair_inj.mp hright).2 + · intro hc + have hs : numberPair.{u} (b,0) ∈ pairNumbers := (mem_pairNumbers _).mpr ⟨_,rfl⟩ + have ht : numberPair.{u} (b,c) ∈ pairNumbers := (mem_pairNumbers _).mpr ⟨_,rfl⟩ + have hw : ZFSet.pair (natSet a) (numberPair.{u} (b,0)) ∈ ZFSet.prod ZFSet.omega pairNumbers := + ZFSet.pair_mem_prod.mpr ⟨(mem_omega _).mpr ⟨a,rfl⟩,hs⟩ + refine ⟨numberPair (b,0),hs,numberPair (b,c),ht,_,hw,rfl,rfl,rfl,?_⟩ + exact (mem_iterationSet addStep addStep_closed _).mpr + ⟨a,numberPair (b,0),hs,by rw [iterate_addStep,hc]⟩ + +def multiplicationSet : ZFSet.{u} := ZFSet.sep + (fun z => ∃ n m, z = ZFSet.pair (numberPair (n,m)) (natSet (n*m))) + (ZFSet.prod pairNumbers ZFSet.omega) + +theorem multiplication_code (n m k : ℕ) : + ZFSet.pair (numberPair.{u} (n,m)) (natSet k) ∈ multiplicationSet ↔ k = n*m := by + simp only [multiplicationSet,ZFSet.mem_sep,ZFSet.pair_mem_prod] + constructor + · rintro ⟨_,a,b,he⟩ + obtain ⟨hin,hout⟩ := ZFSet.pair_inj.mp he + have hab := numberPair_injective hin + have hn : n = a := congrArg Prod.fst hab + have hm : m = b := congrArg Prod.snd hab + simpa only [←hn,←hm] using natSet_injective hout + · intro hk + exact ⟨⟨(mem_pairNumbers _).mpr ⟨_,rfl⟩,(mem_omega _).mpr ⟨k,rfl⟩⟩, + n,m,by rw [hk]⟩ + +def multiplicationFormula : Formula := + .existsMem 1 (.existsMem 2 (.existsMem 3 (.existsMem 5 + (.conj (.orderedPair 4 0 1) (.conj (.orderedPair 0 3 2) + (mulFormula 3 2 1 7 6 8 9)))))) + +theorem multiplicationSet_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) : multiplicationSet.{u} ∈ M := by + have hω := omega_mem M hM hS hI + have h0 : natSet.{u} 0 ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨0,rfl⟩) + have hd : pairNumbers.{u} ∈ M := product_mem M hM hP hU hPow hS hω hω + have hD := product_mem M hM hP hU hPow hS hω hd + have hi := multiplicationIteration_mem M hM hP hU hPow hS hI + have hprod := product_mem M hM hP hU hPow hS hd hω + let e := cons ZFSet.omega (cons pairNumbers (cons multiplicationIteration + (cons (ZFSet.prod ZFSet.omega pairNumbers) (fun _ => natSet 0)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|i <;> simp only [e,cons_zero,cons_succ] + · exact hω + · exact hd + · exact hi + · exact hD + · exact h0 + have hs := sep_mem M hM hS multiplicationFormula e he hprod + have hφ (z : ZFSet.{u}) : multiplicationFormula.Eval (cons z e) ↔ + ∃ n m, z = ZFSet.pair (numberPair (n,m)) (natSet (n*m)) := by + simp only [multiplicationFormula,Formula.Eval,Formula.eval_orderedPair, + cons_zero,cons_succ,e] + constructor + · rintro ⟨n,hn,m,hm,k,hk,t,ht,hz,htnm,hmu⟩ + obtain ⟨a,rfl⟩ := (mem_omega n).mp hn + obtain ⟨b,rfl⟩ := (mem_omega m).mp hm + obtain ⟨c,rfl⟩ := (mem_omega k).mp hk + have hc := (eval_mulFormula 3 2 1 7 6 8 9 + (cons t (cons (natSet c) (cons (natSet b) (cons (natSet a) (cons z e))))) + a b c rfl rfl rfl rfl rfl rfl rfl).mp hmu + exact ⟨a,b,by simpa only [htnm,hc,numberPair] using hz⟩ + · rintro ⟨n,m,rfl⟩ + refine ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,natSet m,(mem_omega _).mpr ⟨m,rfl⟩, + natSet (n*m),(mem_omega _).mpr ⟨n*m,rfl⟩,numberPair (n,m), + (mem_pairNumbers _).mpr ⟨_,rfl⟩,rfl,rfl,?_⟩ + exact (eval_mulFormula 3 2 1 7 6 8 9 + (cons (numberPair (n,m)) (cons (natSet (n*m)) (cons (natSet m) (cons (natSet n) + (cons (ZFSet.pair (numberPair (n,m)) (natSet (n*m))) e))))) + n m (n*m) rfl rfl rfl rfl rfl rfl rfl).mpr rfl + have eq : ZFSet.sep (fun z => multiplicationFormula.Eval (cons z e)) + (ZFSet.prod pairNumbers ZFSet.omega) = multiplicationSet.{u} := by + apply ZFSet.ext + intro z + simp only [ZFSet.mem_sep,hφ,multiplicationSet] + exact eq ▸ hs + +end +end TuringRigidity.SetModelArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelMultiplicationStep.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelMultiplicationStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..12211b6a9e349bb219139e7596890b0c10f3a549 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelMultiplicationStep.lean @@ -0,0 +1,123 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelAddition + +namespace OAI + +namespace TuringRigidity.SetModelArithmetic +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelIteration +universe u +noncomputable section + +def numberPair (q : ℕ × ℕ) : ZFSet.{u} := ZFSet.pair (natSet q.1) (natSet q.2) + +theorem numberPair_injective : Function.Injective numberPair.{u} := by + intro a b h + obtain ⟨hl,hr⟩ := ZFSet.pair_inj.mp h + exact Prod.ext (natSet_injective hl) (natSet_injective hr) + +def pairNumbers := ZFSet.prod ZFSet.omega.{u} ZFSet.omega + +theorem mem_pairNumbers (x : ZFSet.{u}) : x ∈ pairNumbers ↔ ∃ q, x = numberPair q := by + constructor + · intro hx + obtain ⟨a,ha,b,hb,rfl⟩ := ZFSet.mem_prod.mp hx + obtain ⟨n,rfl⟩ := (mem_omega a).mp ha + obtain ⟨m,rfl⟩ := (mem_omega b).mp hb + exact ⟨(n,m),rfl⟩ + · rintro ⟨q,rfl⟩ + exact ZFSet.pair_mem_prod.mpr ⟨(mem_omega _).mpr ⟨q.1,rfl⟩,(mem_omega _).mpr ⟨q.2,rfl⟩⟩ + +def addStep (x : ZFSet.{u}) : ZFSet.{u} := + let q := Function.invFun numberPair x + numberPair (q.1,q.1+q.2) + +@[simp] theorem addStep_numberPair (n m : ℕ) : + addStep (numberPair.{u} (n,m)) = numberPair (n,n+m) := by + have h := Function.leftInverse_invFun numberPair_injective (n,m) + change Function.invFun numberPair.{u} (numberPair (n,m)) = (n,m) at h + simp only [addStep,h] + +theorem addStep_closed : ∀ x ∈ pairNumbers.{u}, addStep x ∈ pairNumbers := by + intro x hx + obtain ⟨⟨n,m⟩,rfl⟩ := (mem_pairNumbers x).mp hx + rw [addStep_numberPair] + exact (mem_pairNumbers _).mpr ⟨(n,n+m),rfl⟩ + +def addStepSet : ZFSet.{u} := ZFSet.sep (fun z => ∃ x ∈ pairNumbers, z = ZFSet.pair x (addStep x)) + (ZFSet.prod pairNumbers pairNumbers) + +theorem pair_mem_addStepSet {x y : ZFSet.{u}} (hx : x ∈ pairNumbers) (hy : y ∈ pairNumbers) : + ZFSet.pair x y ∈ addStepSet ↔ y = addStep x := by + simp only [addStepSet,ZFSet.mem_sep,ZFSet.pair_mem_prod,hx,hy,true_and,ZFSet.pair_inj] + constructor + · rintro ⟨a,ha,he,hs⟩ + exact he ▸ hs + · intro h + exact ⟨x,hx,rfl,h⟩ + +def addStepFormula : Formula := + .existsMem 1 (.existsMem 2 (.existsMem 3 (.existsMem 5 (.existsMem 6 + (.conj (.orderedPair 5 1 0) (.conj (.orderedPair 1 4 3) + (.conj (.orderedPair 0 4 2) (.pairMem 1 2 8)))))))) + +theorem eval_addStepFormula (z : ZFSet.{u}) : + addStepFormula.Eval (cons z (cons ZFSet.omega (cons pairNumbers (fun _ => additionSet)))) ↔ + ∃ x ∈ pairNumbers, z = ZFSet.pair x (addStep x) := by + simp only [addStepFormula,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + cons_zero,cons_succ] + constructor + · rintro ⟨n,hn,m,hm,k,hk,x,hx,y,hy,hz,hxnm,hynk,hadd⟩ + obtain ⟨i,rfl⟩ := (mem_omega n).mp hn + obtain ⟨j,rfl⟩ := (mem_omega m).mp hm + obtain ⟨l,rfl⟩ := (mem_omega k).mp hk + rw [hxnm] at hadd + have hl := (addition_code i j l).mp hadd + refine ⟨x,hx,?_⟩ + rw [hz,hxnm,hynk,hl] + exact congrArg (ZFSet.pair (numberPair (i,j))) (addStep_numberPair i j).symm + · rintro ⟨x,hx,hz⟩ + obtain ⟨⟨i,j⟩,rfl⟩ := (mem_pairNumbers x).mp hx + have hy : numberPair.{u} (i,i+j) ∈ pairNumbers := (mem_pairNumbers _).mpr ⟨_,rfl⟩ + refine ⟨natSet i,(mem_omega _).mpr ⟨i,rfl⟩,natSet j,(mem_omega _).mpr ⟨j,rfl⟩, + natSet (i+j),(mem_omega _).mpr ⟨i+j,rfl⟩,numberPair (i,j),hx,numberPair (i,i+j),hy, + ?_,rfl,rfl,(addition_code i j (i+j)).mpr rfl⟩ + simpa only [addStep_numberPair] using hz + +theorem addStepSet_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) : addStepSet.{u} ∈ M := by + have hω := omega_mem M hM hS hI + have hp : pairNumbers.{u} ∈ M := product_mem M hM hP hU hPow hS hω hω + have ha := additionSet_mem M hM hP hU hPow hS hI + have hprod := product_mem M hM hP hU hPow hS hp hp + let e := cons ZFSet.omega (cons pairNumbers (fun _ => additionSet)) + have he : ∀ i, e i ∈ M := by intro i; rcases i with _|_|i <;> simp [e,hω,hp,ha] + have hs := sep_mem M hM hS addStepFormula e he hprod + have eq : ZFSet.sep (fun z => addStepFormula.Eval (cons z e)) (ZFSet.prod pairNumbers pairNumbers) = + addStepSet.{u} := by + apply ZFSet.ext + intro z + simp only [ZFSet.mem_sep,show ∀ z, addStepFormula.Eval (cons z e) ↔ _ from eval_addStepFormula, + addStepSet] + exact eq ▸ hs + +theorem iterate_addStep (n m : ℕ) : + addStep^[n] (numberPair.{u} (m,0)) = numberPair (m,n*m) := by + induction n with + | zero => simp only [Function.iterate_zero,Function.id_def,Nat.zero_mul] + | succ n ih => rw [Function.iterate_succ_apply',ih,addStep_numberPair,Nat.succ_mul,Nat.add_comm] + +def multiplicationIteration : ZFSet.{u} := iterationSet pairNumbers addStep + +theorem multiplicationIteration_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) : multiplicationIteration.{u} ∈ M := by + have hω := omega_mem M hM hS hI + exact iterationSet_mem M hM hP hU hPow hS hI + (product_mem M hM hP hU hPow hS hω hω) + (addStepSet_mem M hM hP hU hPow hS hI) addStep addStep_closed + (fun _ hx _ hy => pair_mem_addStepSet hx hy) + +end +end TuringRigidity.SetModelArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelOmegaJump.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelOmegaJump.lean new file mode 100644 index 0000000000000000000000000000000000000000..29e9a31e16ec0170d6882ec2e2b6ea501294b3e1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelOmegaJump.lean @@ -0,0 +1,60 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelSequences + +namespace OAI + +namespace TuringRigidity.SetModelSequences +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelIteration +open JumpIdealPresentation OracleJump +universe u +noncomputable section + +theorem omegaJump_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + (hJ : ∀ A ∈ reals M, jump A ∈ reals M) + {p g : ZFSet.{u}} (hp : p ∈ M) (hpdef : PairingCode p) (hgM : g ∈ M) + (hg : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ g ↔ B = jump A) + {A : Oracle} (hA : A ∈ reals M) : omegaJump A ∈ reals M := by + obtain ⟨r,hr,hrdef⟩ := internal_reals M hM hPow hS hI + let F : ZFSet.{u} → ZFSet.{u} := fun x => realSet (jump (oracleOf x)) + have hF : ∀ x ∈ r, F x ∈ r := by + intro x hx + obtain ⟨B,hB,rfl⟩ := (hrdef x).mp hx + exact (hrdef _).mpr ⟨jump B,hJ B hB,by simp only [F,oracleOf_realSet]⟩ + have hfg : ∀ x ∈ r, ∀ y ∈ r, ZFSet.pair x y ∈ g ↔ y = F x := by + intro x hx y hy + obtain ⟨B,hB,rfl⟩ := (hrdef x).mp hx + obtain ⟨C,hC,rfl⟩ := (hrdef y).mp hy + simpa only [F,oracleOf_realSet,realSet_injective.eq_iff] using hg B hB C hC + have hq := iterationSet_mem M hM hP hU hPow hS hI hr hgM F hF hfg + have hiter : ∀ n, F^[n] (realSet A) = realSet (OracleJump.iterate A n) := by + intro n + induction n with + | zero => rfl + | succ n ih => simp only [Function.iterate_succ_apply',ih,F,oracleOf_realSet,OracleJump.iterate] + have hs := sequence_mem_of_iteration M hM hP hU hPow hS hI hr F hF hq + ((hrdef _).mpr ⟨A,hA,rfl⟩) (OracleJump.iterate A) hiter + have hj : ∀ n, OracleJump.iterate A n ∈ reals M := by + intro n + induction n with + | zero => exact hA + | succ n ih => exact hJ _ ih + exact flatten_mem M hM hP hU hPow hS hI hr hrdef hp hpdef _ hj hs + +theorem realClosure_of_arithmetic_graphs (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + (hL : ∀ {A B}, B ∈ reals M → Reduces A B → A ∈ reals M) + (hJoin : ∀ {A B}, A ∈ reals M → B ∈ reals M → join A B ∈ reals M) + (hJ : ∀ A ∈ reals M, jump A ∈ reals M) + {p g : ZFSet.{u}} (hp : p ∈ M) (hpdef : PairingCode p) (hgM : g ∈ M) + (hg : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ g ↔ B = jump A) : + PersistenceRealClosure.Closed (reals M) := + ⟨hL,hJoin,fun hA => omegaJump_mem M hM hP hU hPow hS hI hJ hp hpdef hgM hg hA⟩ + +end +end TuringRigidity.SetModelSequences + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPairing.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPairing.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a6d74db9d00e42db1bb6ceb14a7aaf3edbeeb08 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPairing.lean @@ -0,0 +1,123 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelMultiplication +import OAI.Computability.DegreeRigidity.SetModels.SetModelSequences + +namespace OAI + +namespace TuringRigidity.SetModelArithmetic +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelIteration SetModelSequences +universe u +noncomputable section + +def tripleFormula (i j k r d : ℕ) : Formula := .existsMem d + (.conj (.orderedPair 0 (i+1) (j+1)) (.pairMem 0 (k+1) (r+1))) + +@[simp] theorem eval_tripleFormula (i j k r d : ℕ) (e : ℕ → ZFSet.{u}) : + (tripleFormula i j k r d).Eval e ↔ + ZFSet.pair (e i) (e j) ∈ e d ∧ ZFSet.pair (ZFSet.pair (e i) (e j)) (e k) ∈ e r := by + simp only [tripleFormula,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + cons_zero,cons_succ] + constructor + · rintro ⟨t,ht,rfl,h⟩ + exact ⟨ht,h⟩ + · rintro ⟨ht,h⟩ + exact ⟨_,ht,rfl,h⟩ + +@[simp] theorem natPair_mem (n m : ℕ) : + ZFSet.pair (natSet.{u} n) (natSet m) ∈ pairNumbers := + (mem_pairNumbers _).mpr ⟨(n,m),rfl⟩ + +theorem multiplication_code' (n m k : ℕ) : + ZFSet.pair (ZFSet.pair (natSet.{u} n) (natSet m)) (natSet k) ∈ multiplicationSet ↔ k = n*m := + multiplication_code n m k + +def pairFormula (n m k a b d w : ℕ) : Formula := + .disj (.conj (.member n m) (.existsMem w + (.conj (tripleFormula (m+1) (m+1) 0 (b+1) (d+1)) + (tripleFormula 0 (n+1) (k+1) (a+1) (d+1))))) + (.conj (.neg (.member n m)) (.existsMem w + (.conj (tripleFormula (n+1) (n+1) 0 (b+1) (d+1)) + (.existsMem (w+1) (.conj (tripleFormula 1 (n+2) 0 (a+2) (d+2)) + (tripleFormula 0 (m+2) (k+2) (a+2) (d+2))))))) + +theorem eval_pairFormula (n m k a b d w : ℕ) (e : ℕ → ZFSet.{u}) (i j l : ℕ) + (hn : e n = natSet i) (hm : e m = natSet j) (hk : e k = natSet l) + (ha : e a = additionSet) (hb : e b = multiplicationSet) + (hd : e d = pairNumbers) (hw : e w = ZFSet.omega) : + (pairFormula n m k a b d w).Eval e ↔ l = Nat.pair i j := by + simp only [pairFormula,Formula.eval_disj,Formula.Eval,eval_tripleFormula, + cons_zero,cons_succ,hn,hm,hk,ha,hb,hd,hw,natSet_mem_natSet] + simp_rw [omega_exists] + simp only [natPair_mem,true_and,addition_code,multiplication_code'] + by_cases h : i < j <;> simp [h,Nat.pair] + +def pairingSet : ZFSet.{u} := ZFSet.sep + (fun z => ∃ n m, z = ZFSet.pair (numberPair (n,m)) (natSet (Nat.pair n m))) + (ZFSet.prod pairNumbers ZFSet.omega) + +theorem pairingSet_code : PairingCode pairingSet.{u} := by + intro n m k + simp only [pairingSet,ZFSet.mem_sep,ZFSet.pair_mem_prod,natPair_mem,true_and] + constructor + · rintro ⟨_,a,b,he⟩ + obtain ⟨hin,hout⟩ := ZFSet.pair_inj.mp he + have hab : (n,m) = (a,b) := numberPair_injective hin + have hn : n = a := congrArg Prod.fst hab + have hm : m = b := congrArg Prod.snd hab + simpa only [←hn,←hm] using natSet_injective hout + · intro hk + exact ⟨(mem_omega _).mpr ⟨k,rfl⟩,n,m,by simp only [hk,numberPair]⟩ + +def pairingFormula : Formula := + .existsMem 1 (.existsMem 2 (.existsMem 3 (.existsMem 5 + (.conj (.orderedPair 4 0 1) (.conj (.orderedPair 0 3 2) + (pairFormula 3 2 1 7 8 6 5)))))) + +theorem pairingSet_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) : pairingSet.{u} ∈ M := by + have hω := omega_mem M hM hS hI + have hd : pairNumbers.{u} ∈ M := product_mem M hM hP hU hPow hS hω hω + have ha := additionSet_mem M hM hP hU hPow hS hI + have hb := multiplicationSet_mem M hM hP hU hPow hS hI + have hprod := product_mem M hM hP hU hPow hS hd hω + let e := cons ZFSet.omega (cons pairNumbers (cons additionSet (fun _ => multiplicationSet))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|i <;> simp only [e,cons_zero,cons_succ] + · exact hω + · exact hd + · exact ha + · exact hb + have hs := sep_mem M hM hS pairingFormula e he hprod + have hφ (z : ZFSet.{u}) : pairingFormula.Eval (cons z e) ↔ + ∃ n m, z = ZFSet.pair (numberPair (n,m)) (natSet (Nat.pair n m)) := by + simp only [pairingFormula,Formula.Eval,Formula.eval_orderedPair, + cons_zero,cons_succ,e] + constructor + · rintro ⟨n,hn,m,hm,k,hk,t,ht,hz,htnm,hpr⟩ + obtain ⟨a,rfl⟩ := (mem_omega n).mp hn + obtain ⟨b,rfl⟩ := (mem_omega m).mp hm + obtain ⟨c,rfl⟩ := (mem_omega k).mp hk + have hc := (eval_pairFormula 3 2 1 7 8 6 5 + (cons t (cons (natSet c) (cons (natSet b) (cons (natSet a) (cons z e))))) + a b c rfl rfl rfl rfl rfl rfl rfl).mp hpr + exact ⟨a,b,by simpa only [htnm,hc,numberPair] using hz⟩ + · rintro ⟨n,m,rfl⟩ + refine ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,natSet m,(mem_omega _).mpr ⟨m,rfl⟩, + natSet (Nat.pair n m),(mem_omega _).mpr ⟨Nat.pair n m,rfl⟩,numberPair (n,m), + natPair_mem n m,rfl,rfl,?_⟩ + exact (eval_pairFormula 3 2 1 7 8 6 5 + (cons (numberPair (n,m)) (cons (natSet (Nat.pair n m)) (cons (natSet m) (cons (natSet n) + (cons (ZFSet.pair (numberPair (n,m)) (natSet (Nat.pair n m))) e))))) + n m (Nat.pair n m) rfl rfl rfl rfl rfl rfl rfl).mpr rfl + have eq : ZFSet.sep (fun z => pairingFormula.Eval (cons z e)) + (ZFSet.prod pairNumbers ZFSet.omega) = pairingSet.{u} := by + apply ZFSet.ext + intro z + simp only [ZFSet.mem_sep,hφ,pairingSet] + exact eq ▸ hs + +end +end TuringRigidity.SetModelArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPersistence.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPersistence.lean new file mode 100644 index 0000000000000000000000000000000000000000..83e758c395865229e29ca45a1b7a59d66d258101 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPersistence.lean @@ -0,0 +1,93 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelGraphImage +import OAI.Computability.DegreeRigidity.SetModels.SetDegreeDecoding +import OAI.Computability.DegreeRigidity.SetModels.SetModelOmegaJump + +namespace OAI + +namespace TuringRigidity.SetModelPersistence +open BoundedSetTheory TransitiveNameModel SetPresentationDecoding SetModelReals +open SetDegreeDecoding SetModelSequences SetModelColumns EncodedForcing +open PersistentRestrictions PersistentPresentation PersistentCountability +universe u +noncomputable section + +theorem graphImage_action {I : CountableIdeal} {A G : Oracle} + (hA : Presented I A) (ρ : I ≃o I) (hG : ∀ v, G v = true ↔ Graph ρ hA v) + (n m : ℕ) : + ZFSet.pair (realSet.{u} (columns A n)) (realSet (columns A m)) ∈ graphImage A G ↔ + (ρ (entry hA n)).val = degree (columns A m) := by + rw [mem_graphImage] + constructor + · rintro ⟨i,j,hGij,hpair⟩ + obtain ⟨hi,hj⟩ := ZFSet.pair_inj.mp hpair + have hi' := realSet_injective hi + have hj' := realSet_injective hj + have he : entry hA n = entry hA i := Subtype.ext (congrArg degree hi') + have hh := (hG (Nat.pair i j)).mp hGij + simpa only [PersistentPresentation.Graph,Nat.unpair_pair,he,hj'] using hh + · intro h + refine ⟨n,m,(hG _).mpr ?_,rfl⟩ + simpa only [PersistentPresentation.Graph,Nat.unpair_pair] using h + +theorem persistent_decoding (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + (hC : PersistenceRealClosure.Closed (reals M)) + {p E : ZFSet.{u}} (hp : p ∈ M) (hpdef : PairingCode p) (hEM : E ∈ M) + (hE : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ E ↔ degree A = degree B) + {I : CountableIdeal} {A : Oracle} (hA : Presented I A) (hAM : A ∈ reals M) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + idealSet I ∈ M ∧ automorphismSet ρ ∈ M := by + obtain ⟨r,hr,hrdef⟩ := internal_reals M hM hPow hS hI + have hcols : ∀ n, columns A n ∈ reals M := + fun n => hC.lower hAM (CodingExtraction.column_projection_reduces A n) + have hseq := columns_mem M hM hP hU hPow hS hI hC.lower hp hpdef hAM + have ha := columnRange_mem M hM hPow hS hI hcols hseq + have hi := quotient_mem M hM hPow hS hr hEM ha + have hieq := quotient_eq_idealSet M hC.lower hrdef hE hA (mem_columnRange A) hcols + refine ⟨hieq ▸ hi,?_⟩ + let G := graphOracle hA ρ + have hGM : G ∈ reals M := PersistenceRealClosure.graph_mem hC hA hAM ρ hρ hz + have hG : ∀ v, G v = true ↔ Graph ρ hA v := fun v => by simp [G,graphOracle] + have hR := graphImage_mem M hM hP hU hPow hS hI hp hpdef hseq ha hGM + have hm := action_mem M hM hP hU hPow hS hr hEM ha hR + have heq := action_eq_automorphismSet M hC.lower hrdef hE hA ρ + (mem_columnRange A) hcols (graphImage_action hA ρ hG) + exact heq ▸ hm + +theorem persistent_extension_sets (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + (hC : PersistenceRealClosure.Closed (reals M)) + {p E : ZFSet.{u}} (hp : p ∈ M) (hpdef : PairingCode p) (hEM : E ∈ M) + (hE : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (realSet A) (realSet B) ∈ E ↔ degree A = degree B) + {I : CountableIdeal} {A : Oracle} (hA : Presented I A) (hAM : A ∈ reals M) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) + {X : Oracle} (hX : X ∈ reals M) : + ∃ (J : CountableIdeal) (σ : J ≃o J) (hIJ : I.carrier ⊆ J.carrier), + degree X ∈ J.carrier ∧ Extends hIJ ρ σ ∧ Persistent J σ ∧ + idealSet J ∈ M ∧ automorphismSet σ ∈ M := by + let B := join A X + let J := JumpIdeal.generated (degree B) + let H := JumpIdealPresentation.presentation B + have hH : Presented J H := JumpIdealPresentation.presents B + have hHM : H ∈ reals M := hC.presentation (hC.join hAM hX) + have hIJ : I.carrier ⊆ J.carrier := by + intro y hy + obtain ⟨n,rfl⟩ := (hA y).mp hy + exact J.lower ((CodingExtraction.column_projection_reduces A n).trans + (reduces_join_left A X)) (JumpIdeal.includes _) + have hXJ : degree X ∈ J.carrier := J.lower (reduces_join_right A X) (JumpIdeal.includes _) + obtain ⟨σ,he,hσ⟩ := PersistentExtension.source_4_1_10 I J ρ hρ hz hIJ (JumpIdeal.closed _) + have hsets := persistent_decoding M hM hP hU hPow hS hI hC hp hpdef hEM hE + hH hHM σ hσ (hIJ hz) + exact ⟨J,σ,hIJ,hXJ,he,hσ,hsets⟩ + +end +end TuringRigidity.SetModelPersistence + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPersistenceDecoding.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPersistenceDecoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..c47697864fbc546ca8299c1ad941f7b20785dc46 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPersistenceDecoding.lean @@ -0,0 +1,51 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelActionDecoding + +namespace OAI + +namespace TuringRigidity.SetModelSatisfaction +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions SetModelSyntax +open SetDegreeDecoding PersistentRestrictions SetModelCountability +universe u +noncomputable section + +theorem decode_persistence_extension {M : ZFSet.{u}} (C : Context M) + {D L : ZFSet.{u}} (hDM : D ∈ M) (hLM : L ∈ M) + (hD : ∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A)) + (hL : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + (I : CountableIdeal) (hI : idealSet I ∈ M) (ρ : I ≃o I) (hρ : automorphismSet ρ ∈ M) + (hp : persistenceFormula.Realize M (cons D (cons L (cons (idealSet I) + (cons (automorphismSet ρ) (fun _ => ZFSet.omega)))))) + {X : Oracle} (hX : X ∈ reals M) : + ∃ (J : CountableIdeal) (hIJ : I.carrier ⊆ J.carrier) (σ : J ≃o J), + degree X ∈ J.carrier ∧ Extends hIJ ρ σ := by + have hxD : degreeSet.{u} (degree X) ∈ D := (hD _).mpr ⟨X,hX,rfl⟩ + have hxM := C.transitive _ hDM _ hxD + rw [persistenceFormula,InternalFormula.realize_allMem] at hp + obtain ⟨a,ha,f,hf,c,hc,hmat⟩ := hp _ hxM hxD + let e := cons c (cons f (cons a (cons (degreeSet (degree X)) (cons D (cons L + (cons (idealSet I) (cons (automorphismSet ρ) (fun _ => ZFSet.omega)))))))) + have heM : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|_|_|_|_|i <;> simp [e,hc,hf,ha,hxM,hDM,hLM,hI,hρ,C.omega_mem] + have hm := (persistenceMatrix.absolute M C.transitive e heM).mp hmat + simp only [persistenceMatrix,Formula.Eval,eval_idealFormula,eval_ontoFormula, + eval_actionFormula,Formula.eval_subset,cons_zero,cons_succ,e] at hm + obtain ⟨hideal,honto,hact,hsub,hfsub,hxa⟩ := hm + have hct : InternallyCountable M a := by + have hec : ∀ i, cons c (cons ZFSet.omega (fun _ => a)) i ∈ M := by + intro i + rcases i with _|_|i <;> simp [hc,C.omega_mem,ha] + exact ⟨c,hc,((ontoFormula 0 1 2).absolute M C.transitive _ hec).mpr + ((eval_ontoFormula 0 1 2 _).mpr honto)⟩ + obtain ⟨J,rfl⟩ := decode_ideal C hD hL ha hideal hct + obtain ⟨σ,rfl⟩ := decode_action C hL J ha hact + have hIJ := ideal_subset_iff.mp hsub + refine ⟨J,hIJ,σ,?_,(extends_sets_iff hIJ ρ σ).mp hfsub⟩ + obtain ⟨a,ha,he⟩ := (mem_idealSet J _).mp hxa + exact (degreeSet_injective he).symm ▸ ha + +end +end TuringRigidity.SetModelSatisfaction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPersistentSatisfaction.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPersistentSatisfaction.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f3830e685fd265243a9c22e30345da342e68c32 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPersistentSatisfaction.lean @@ -0,0 +1,99 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelActionSatisfaction + +namespace OAI + +namespace TuringRigidity.SetModelSatisfaction +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions SetModelSyntax +open SetDegreeDecoding PersistentRestrictions SetModelCountability +universe u +noncomputable section + +inductive InternalFormula where + | bounded (p : Formula) + | conj (p q : InternalFormula) + | neg (p : InternalFormula) + | existsSet (p : InternalFormula) + +def InternalFormula.Realize (M : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : InternalFormula → Prop + | .bounded p => p.Realize M e + | .conj p q => p.Realize M e ∧ q.Realize M e + | .neg p => ¬ p.Realize M e + | .existsSet p => ∃ x ∈ M, p.Realize M (cons x e) + +def InternalFormula.allMem (i : ℕ) (p : InternalFormula) : InternalFormula := + .neg (.existsSet (.conj (.bounded (.member 0 (i+1))) (.neg p))) + +@[simp] theorem InternalFormula.realize_allMem (i : ℕ) (p : InternalFormula) + (M : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (InternalFormula.allMem i p).Realize M e ↔ + ∀ x ∈ M, x ∈ e i → p.Realize M (cons x e) := by + classical + simp [InternalFormula.allMem,InternalFormula.Realize,Formula.Realize] + +def persistenceMatrix : Formula := + .conj (idealFormula 2 4 5) (.conj (ontoFormula 0 8 2) + (.conj (actionFormula 1 2 5) (.conj (.subset 6 2) + (.conj (.subset 7 1) (.member 3 2))))) + +def persistenceFormula : InternalFormula := + .allMem 0 (.existsSet (.existsSet (.existsSet (.bounded persistenceMatrix)))) + +variable {M : ZFSet.{u}} + +theorem persistent_satisfaction (C : Context M) (hCh : InternalChoice M) + {D L : ZFSet.{u}} (hDM : D ∈ M) (hLM : L ∈ M) + (hD : ∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A)) + (hL : ∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) + (I : CountableIdeal) (hI : idealSet I ∈ M) (hct : InternallyCountable M (idealSet I)) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + persistenceFormula.Realize M (cons D (cons L (cons (idealSet I) + (cons (automorphismSet ρ) (fun _ => ZFSet.omega))))) := by + have hρM := persistent_mem_of_countable C hCh I hI hct ρ hρ hz + rw [persistenceFormula,InternalFormula.realize_allMem] + intro x hxM hxD + obtain ⟨X,hX,rfl⟩ := (hD x).mp hxD + obtain ⟨J,σ,hIJ,hXJ,he,hσ,hJM,hσM,hctJ⟩ := + persistent_countable_extensions C hCh I hI hct ρ hρ hz hX + obtain ⟨c,hc,hcc⟩ := hctJ + have hec : ∀ i, cons c (cons ZFSet.omega (fun _ => idealSet J)) i ∈ M := by + intro i + rcases i with _|_|i <;> simp [hc,C.omega_mem,hJM] + have honto := ((ontoFormula 0 1 2).absolute M C.transitive _ hec).mp hcc + rw [eval_ontoFormula] at honto + refine ⟨idealSet J,hJM,automorphismSet σ,hσM,c,hc,?_⟩ + change persistenceMatrix.Realize M _ + let e := cons c (cons (automorphismSet σ) (cons (idealSet J) + (cons (degreeSet (degree X)) (cons D (cons L (cons (idealSet I) + (cons (automorphismSet ρ) (fun _ => ZFSet.omega)))))))) + have heM : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|_|_|_|_|i <;> + simp [e,hc,hσM,hJM,hxM,hDM,hLM,hI,hρM,C.omega_mem] + apply (persistenceMatrix.absolute M C.transitive e heM).mpr + simp only [persistenceMatrix,Formula.Eval,eval_idealFormula,eval_ontoFormula, + eval_actionFormula,Formula.eval_subset,cons_zero,cons_succ,e] + exact ⟨ideal_satisfaction C hD hL J hJM,honto,action_satisfaction C hL hJM σ, + ideal_subset hIJ,extends_sets he,(mem_idealSet J _).mpr ⟨_,hXJ,rfl⟩⟩ + +theorem source_4_2_5_transitive (C : Context M) (hCh : InternalChoice M) + (I : CountableIdeal) (hI : idealSet I ∈ M) (hct : InternallyCountable M (idealSet I)) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + ∃ D ∈ M, ∃ L ∈ M, + (∀ x, x ∈ D ↔ ∃ A ∈ reals M, x = degreeSet (degree A)) ∧ + (∀ A ∈ reals M, ∀ B ∈ reals M, + ZFSet.pair (degreeSet (degree A)) (degreeSet (degree B)) ∈ L ↔ Reduces A B) ∧ + automorphismSet ρ ∈ M ∧ + persistenceFormula.Realize M (cons D (cons L (cons (idealSet I) + (cons (automorphismSet ρ) (fun _ => ZFSet.omega))))) := by + obtain ⟨D,hDM,hD⟩ := degree_universe C + obtain ⟨L,hLM,hL⟩ := degree_order C + exact ⟨D,hDM,L,hLM,hD,hL,persistent_mem_of_countable C hCh I hI hct ρ hρ hz, + persistent_satisfaction C hCh hDM hLM hD hL I hI hct ρ hρ hz⟩ + +end +end TuringRigidity.SetModelSatisfaction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPresentedCountability.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPresentedCountability.lean new file mode 100644 index 0000000000000000000000000000000000000000..161e8cd7305ba2bd3ec6d84187bb3daebef7e0f5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPresentedCountability.lean @@ -0,0 +1,117 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelCountablePresentation + +namespace OAI + +namespace TuringRigidity.SetModelCountability +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions SetModelArithmetic +open SetPresentationDecoding SetDegreeDecoding SetModelSequences SetModelColumns SetModelSyntax +open PersistentRestrictions PersistentPresentation EncodedForcing +universe u +noncomputable section +variable {M : ZFSet.{u}} + +theorem ideal_mem_of_presentation (C : Context M) {I : CountableIdeal} {A : Oracle} + (hA : Presented I A) (hAM : A ∈ reals M) : idealSet I ∈ M := by + obtain ⟨r,hr,hrc⟩ := internal_reals M C.transitive C.power C.separation C.infinity + obtain ⟨E,hE,hEc⟩ := internal_degreeEquality_graph C + have hcols : ∀ n, columns A n ∈ reals M := + fun n => lower_mem C hAM (CodingExtraction.column_projection_reduces A n) + have hs := columns_mem M C.transitive C.pairing C.union C.power C.separation C.infinity + (lower_mem C) C.pairing_mem pairingSet_code hAM + have ha := columnRange_mem M C.transitive C.power C.separation C.infinity hcols hs + have hi := quotient_mem M C.transitive C.power C.separation hr hE ha + have he := quotient_eq_idealSet M (lower_mem C) hrc hEc hA (mem_columnRange A) hcols + exact he ▸ hi + +def degreeSequence (A : Oracle) : ZFSet.{u} := + ZFSet.range (fun n : ℕ => ZFSet.pair (natSet n) (degreeSet (degree (columns A n)))) + +@[simp] theorem mem_degreeSequence (A : Oracle) (z : ZFSet.{u}) : + z ∈ degreeSequence A ↔ ∃ n, z = ZFSet.pair (natSet n) (degreeSet (degree (columns A n))) := by + rw [degreeSequence,ZFSet.mem_range] + exact exists_congr (fun n => eq_comm) + +@[simp] theorem pair_mem_degreeSequence (A : Oracle) (n : ℕ) (x : ZFSet.{u}) : + ZFSet.pair (natSet n) x ∈ degreeSequence A ↔ x = degreeSet (degree (columns A n)) := by + rw [mem_degreeSequence] + constructor + · rintro ⟨m,he⟩ + obtain ⟨hn,hx⟩ := ZFSet.pair_inj.mp he + exact natSet_injective hn ▸ hx + · intro h + exact ⟨n,by rw [h]⟩ + +def degreeSequenceFormula : Formula := + .existsMem 1 (.existsMem 3 (.existsMem 6 + (.conj (.orderedPair 3 2 0) (.conj (.pairMem 2 1 6) (classFormula 0 1 5 8))))) + +theorem degreeSequence_mem (C : Context M) {I : CountableIdeal} {A : Oracle} + (hA : Presented I A) (hAM : A ∈ reals M) : degreeSequence.{u} A ∈ M := by + obtain ⟨r,hr,hrc⟩ := internal_reals M C.transitive C.power C.separation C.infinity + obtain ⟨E,hE,hEc⟩ := internal_degreeEquality_graph C + have hcols : ∀ n, columns A n ∈ reals M := + fun n => lower_mem C hAM (CodingExtraction.column_projection_reduces A n) + have hs := columns_mem M C.transitive C.pairing C.union C.power C.separation C.infinity + (lower_mem C) C.pairing_mem pairingSet_code hAM + have hi := ideal_mem_of_presentation C hA hAM + let e := cons ZFSet.omega (cons r (cons (sequenceSet (columns A)) (cons (idealSet I) (fun _ => E)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|i <;> simp [e,C.omega_mem,hr,hs,hi,hE] + have hp := sep_mem M C.transitive C.separation degreeSequenceFormula e he + (C.prod_mem C.omega_mem hi) + have eq : ZFSet.sep (fun z => degreeSequenceFormula.Eval (cons z e)) + (ZFSet.prod ZFSet.omega (idealSet I)) = degreeSequence A := by + apply ZFSet.ext + intro z + simp only [ZFSet.mem_sep,degreeSequenceFormula,Formula.Eval,Formula.eval_orderedPair, + Formula.eval_pairMem,eval_classFormula,cons_zero,cons_succ,e,mem_degreeSequence] + constructor + · rintro ⟨_,n,hn,x,hx,c,hc,hz,hnx,hcx⟩ + obtain ⟨k,rfl⟩ := (mem_omega n).mp hn + have hx' := (pair_mem_sequenceSet _ _ _).mp hnx + have hc' : c = degreeSet (degree (columns A k)) := by + rw [hcx,hx'] + exact class_eq_degreeSet M (lower_mem C) hrc hEc (hcols k) + exact ⟨k,by rw [hz,hc']⟩ + · rintro ⟨n,rfl⟩ + have hn : natSet.{u} n ∈ ZFSet.omega := (mem_omega _).mpr ⟨n,rfl⟩ + have hdn : degreeSet (degree (columns A n)) ∈ idealSet I := + (mem_idealSet I _).mpr ⟨_,(hA _).mpr ⟨n,rfl⟩,rfl⟩ + refine ⟨ZFSet.pair_mem_prod.mpr ⟨hn,hdn⟩,natSet n,hn,realSet (columns A n), + (hrc _).mpr ⟨_,hcols n,rfl⟩,_,hdn,rfl,(pair_mem_sequenceSet _ _ _).mpr rfl,?_⟩ + exact (class_eq_degreeSet M (lower_mem C) hrc hEc (hcols n)).symm + exact eq ▸ hp + +theorem countable_of_presentation (C : Context M) {I : CountableIdeal} {A : Oracle} + (hA : Presented I A) (hAM : A ∈ reals M) : InternallyCountable M (idealSet I) := by + have hs := degreeSequence_mem C hA hAM + have hi := ideal_mem_of_presentation C hA hAM + let e := cons (degreeSequence A) (cons ZFSet.omega (fun _ => idealSet I)) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|i <;> simp [e,hs,C.omega_mem,hi] + refine ⟨degreeSequence A,hs,((ontoFormula 0 1 2).absolute M C.transitive e he).mpr ?_⟩ + rw [eval_ontoFormula] + change FunctionGraph (degreeSequence A) ZFSet.omega (idealSet I) ∧ _ + refine ⟨⟨?_,?_⟩,?_⟩ + · intro z hz + obtain ⟨n,rfl⟩ := (mem_degreeSequence A z).mp hz + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,_, + (mem_idealSet I _).mpr ⟨_,(hA _).mpr ⟨n,rfl⟩,rfl⟩,rfl⟩ + · intro x hx + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + refine ⟨_,(mem_idealSet I _).mpr ⟨_,(hA _).mpr ⟨n,rfl⟩,rfl⟩, + (pair_mem_degreeSequence _ _ _).mpr rfl,?_⟩ + intro z hz hnz + exact (pair_mem_degreeSequence _ _ _).mp hnz + · intro y hy + obtain ⟨a,ha,rfl⟩ := (mem_idealSet I y).mp hy + obtain ⟨n,hn⟩ := (hA a).mp ha + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,(pair_mem_degreeSequence _ _ _).mpr + (congrArg degreeSet hn.symm)⟩ + +end +end TuringRigidity.SetModelCountability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPrimrec.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPrimrec.lean new file mode 100644 index 0000000000000000000000000000000000000000..be8eb4e39ac8a13d2baf6197551093fae4cb1152 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelPrimrec.lean @@ -0,0 +1,63 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelFunctionIteration +import Mathlib.Computability.Primrec.Basic + +namespace OAI + +namespace TuringRigidity.SetModelFunctions +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelIteration SetModelArithmetic +universe u +noncomputable section + +variable {M : ZFSet.{u}} + +theorem HasGraph.congr {f g : ℕ → ℕ} (hf : HasGraph M f) (h : ∀ n, f n = g n) : + HasGraph M g := (funext h) ▸ hf + +def recValue (f g : ℕ → ℕ) (z n : ℕ) : ℕ := + n.rec (f z) (fun y ih => g (Nat.pair z (Nat.pair y ih))) + +def recStep (g : ℕ → ℕ) (s : ℕ) : ℕ := + Nat.pair (Nat.unpair s).1 (Nat.pair ((Nat.unpair (Nat.unpair s).2).1+1) (g s)) + +def recStart (f : ℕ → ℕ) (z : ℕ) : ℕ := Nat.pair z (Nat.pair 0 (f z)) + +theorem iterate_recStep (f g : ℕ → ℕ) (z n : ℕ) : + (recStep g)^[n] (recStart f z) = Nat.pair z (Nat.pair n (recValue f g z n)) := by + induction n with + | zero => rfl + | succ n ih => + rw [Function.iterate_succ_apply',ih] + simp only [recStep,Nat.unpair_pair,recValue] + +theorem HasGraph.prec (C : Context M) {f g : ℕ → ℕ} + (hf : HasGraph M f) (hg : HasGraph M g) : + HasGraph M (Nat.unpaired (recValue f g)) := by + have hs : HasGraph M (recStep g) := + HasGraph.pair C (left_graph C) (HasGraph.pair C + (HasGraph.comp C (succ_graph C) (HasGraph.comp C (left_graph C) (right_graph C))) hg) + have hz : HasGraph M (recStart f) := + HasGraph.pair C (id_graph C) (HasGraph.pair C (const_graph C 0) hf) + have hp := HasGraph.pair C (HasGraph.comp C hz (left_graph C)) (right_graph C) + have hi := HasGraph.comp C (HasGraph.iterate C hs) hp + have h := HasGraph.comp C (HasGraph.comp C (right_graph C) (right_graph C)) hi + apply h.congr + intro v + simp only [Nat.unpair_pair,iterate_recStep,Nat.unpaired] + +theorem natPrimrec_graph (C : Context M) {f : ℕ → ℕ} (hf : Nat.Primrec f) : HasGraph M f := by + induction hf with + | zero => exact const_graph C 0 + | succ => exact succ_graph C + | left => exact left_graph C + | right => exact right_graph C + | pair hf hg ihf ihg => exact HasGraph.pair C ihf ihg + | comp hf hg ihf ihg => exact HasGraph.comp C ihf ihg + | prec hf hg ihf ihg => exact HasGraph.prec C ihf ihg + +theorem primrec_graph (C : Context M) {f : ℕ → ℕ} (hf : Primrec f) : HasGraph M f := + natPrimrec_graph C (Primrec.nat_iff.mp hf) + +end +end TuringRigidity.SetModelFunctions + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelReals.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelReals.lean new file mode 100644 index 0000000000000000000000000000000000000000..af23481fb3cee63350b00e460b9315cd572d3490 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelReals.lean @@ -0,0 +1,101 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalInfinity +import OAI.Computability.DegreeRigidity.SetModels.SetPresentationDecoding + +namespace OAI + +namespace TuringRigidity.SetModelReals +open BoundedSetTheory TransitiveNameModel SetPresentationDecoding +universe u +noncomputable section + +def realSet (A : Oracle) : ZFSet.{u} := + ZFSet.sep (fun x => ∃ n, x = natSet n ∧ A n = true) ZFSet.omega + +@[simp] theorem nat_mem_realSet (A : Oracle) (n : ℕ) : + natSet.{u} n ∈ realSet A ↔ A n = true := by + simp only [realSet,ZFSet.mem_sep] + constructor + · rintro ⟨_,m,hm,hA⟩ + exact natSet_injective hm ▸ hA + · intro hA + exact ⟨(mem_omega _).mpr ⟨n,rfl⟩,⟨n,rfl,hA⟩⟩ + +theorem realSet_subset (A : Oracle) : realSet.{u} A ⊆ ZFSet.omega := + fun _ h => (ZFSet.mem_sep.mp h).1 + +theorem realSet_injective : Function.Injective realSet.{u} := by + intro A B he + funext n + have h : A n = true ↔ B n = true := by rw [← nat_mem_realSet,he,nat_mem_realSet] + cases ha : A n <;> cases hb : B n <;> simp_all + +def oracleOf (x : ZFSet.{u}) : Oracle := by + classical + exact fun n => decide (natSet n ∈ x) + +@[simp] theorem oracleOf_realSet (A : Oracle) : oracleOf (realSet.{u} A) = A := by + funext n + simp only [oracleOf,nat_mem_realSet] + cases A n <;> rfl + +theorem realSet_oracleOf {x : ZFSet.{u}} (hx : x ⊆ ZFSet.omega) : + realSet (oracleOf x) = x := by + apply ZFSet.ext + intro y + constructor + · intro hy + obtain ⟨n,rfl⟩ := (mem_omega y).mp (realSet_subset _ hy) + simpa [oracleOf] using (nat_mem_realSet _ n).mp hy + · intro hy + obtain ⟨n,rfl⟩ := (mem_omega y).mp (hx hy) + apply (nat_mem_realSet _ _).mpr + simpa [oracleOf] using hy + +def reals (M : ZFSet.{u}) : Set Oracle := {A | realSet A ∈ M} + +theorem internal_reals (M : ZFSet.{u}) (hM : Transitive M) + (hPow : PowerSet M) (hS : Separation M) (hI : Infinity M) : + ∃ r ∈ M, ∀ x, x ∈ r ↔ ∃ A ∈ reals M, x = realSet A := by + obtain ⟨r,hr,hrdef⟩ := internal_power M hM hPow (omega_mem M hM hS hI) + refine ⟨r,hr,fun x => ?_⟩ + rw [hrdef] + constructor + · rintro ⟨hxM,hx⟩ + exact ⟨oracleOf x,by simpa only [reals,Set.mem_ofPred_eq,realSet_oracleOf hx] using hxM, + (realSet_oracleOf hx).symm⟩ + · rintro ⟨A,hA,rfl⟩ + exact ⟨hA,realSet_subset A⟩ + +theorem omega_exists (P : ZFSet.{u} → Prop) : + (∃ x ∈ ZFSet.omega, P x) ↔ ∃ n, P (natSet n) := by + constructor + · rintro ⟨x,hx,hP⟩ + obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + exact ⟨n,hP⟩ + · rintro ⟨n,hP⟩ + exact ⟨_,(mem_omega _).mpr ⟨n,rfl⟩,hP⟩ + +theorem real_formula_absolute (M : ZFSet.{u}) (hM : Transitive M) + (φ : Formula) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + φ.Realize M e ↔ φ.Eval e := φ.absolute M hM e he + +theorem real_comprehension (M : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hI : Infinity M) + (A : Oracle) (φ : Formula) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hφ : ∀ n, φ.Eval (cons (natSet n) e) ↔ A n = true) : A ∈ reals M := by + have h := sep_mem M hM hS φ e he (omega_mem M hM hS hI) + have eq : ZFSet.sep (fun x => φ.Eval (cons x e)) ZFSet.omega = realSet A := by + apply ZFSet.ext + intro x + by_cases hx : x ∈ ZFSet.omega + · obtain ⟨n,rfl⟩ := (mem_omega x).mp hx + simp only [ZFSet.mem_sep,hx,true_and,nat_mem_realSet,hφ] + · simp only [ZFSet.mem_sep,hx,false_and] + exact iff_false_intro (fun h => hx (realSet_subset A h)) |>.symm + change realSet A ∈ M + exact eq ▸ h + +end +end TuringRigidity.SetModelReals + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelRecursion.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3013ec044592117b25bf23dae2bfa6badbc1e0d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelRecursion.lean @@ -0,0 +1,109 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelIteration + +namespace OAI + +namespace TuringRigidity.SetModelIteration +open BoundedSetTheory TransitiveNameModel SetModelReals +universe u +noncomputable section + +def iterationSet (v : ZFSet.{u}) (F : ZFSet.{u} → ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ n : ℕ, ∃ x ∈ v, + z = ZFSet.pair (ZFSet.pair (natSet n) x) (F^[n] x)) + (ZFSet.prod (ZFSet.prod ZFSet.omega v) v) + +theorem mem_iterationSet {v : ZFSet.{u}} (F : ZFSet.{u} → ZFSet.{u}) + (hF : ∀ x ∈ v, F x ∈ v) (z : ZFSet.{u}) : + z ∈ iterationSet v F ↔ ∃ n : ℕ, ∃ x ∈ v, + z = ZFSet.pair (ZFSet.pair (natSet n) x) (F^[n] x) := by + rw [iterationSet,ZFSet.mem_sep] + constructor + · exact And.right + · rintro ⟨n,x,hx,rfl⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨ZFSet.pair_mem_prod.mpr + ⟨(mem_omega _).mpr ⟨n,rfl⟩,hx⟩,iterate_mem F hF hx n⟩,⟨n,x,hx,rfl⟩⟩ + +def iterationFormula : Formula := + .existsMem 1 (.existsMem 3 (.existsMem 4 (.existsMem 9 (.existsMem 8 + (.conj (.orderedPair 5 1 2) (.conj (.orderedPair 1 4 3) + (traceFormula 4 3 2 0 7 8 6 10))))))) + +theorem eval_iterationFormula (z v g p d : ZFSet.{u}) : + iterationFormula.Eval (cons z (cons ZFSet.omega (cons v (cons g + (cons p (cons (natSet 0) (fun _ => d))))))) ↔ + ∃ n : ℕ, ∃ x ∈ v, ∃ y ∈ v, ∃ t ∈ d, ∃ s ∈ p, + z = ZFSet.pair t y ∧ t = ZFSet.pair (natSet n) x ∧ Trace v g n x y s := by + simp only [iterationFormula,Formula.Eval,cons_zero,cons_succ] + rw [omega_exists] + apply exists_congr + intro n + apply exists_congr + intro x + apply and_congr Iff.rfl + apply exists_congr + intro y + apply and_congr Iff.rfl + apply exists_congr + intro t + apply and_congr Iff.rfl + apply exists_congr + intro s + apply and_congr Iff.rfl + simp only [Formula.eval_orderedPair,cons_zero,cons_succ] + apply and_congr Iff.rfl + apply and_congr Iff.rfl + exact eval_traceFormula _ _ _ _ _ _ _ _ _ n rfl rfl rfl + +theorem iterationSet_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + {v g : ZFSet.{u}} (hv : v ∈ M) (hgM : g ∈ M) + (F : ZFSet.{u} → ZFSet.{u}) (hF : ∀ x ∈ v, F x ∈ v) + (hg : ∀ x ∈ v, ∀ y ∈ v, ZFSet.pair x y ∈ g ↔ y = F x) : + iterationSet v F ∈ M := by + have hω := omega_mem M hM hS hI + have h0 : natSet.{u} 0 ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨0,rfl⟩) + let d := ZFSet.prod ZFSet.omega v + have hd : d ∈ M := product_mem M hM hP hU hPow hS hω hv + obtain ⟨p,hp,hpdef⟩ := internal_power M hM hPow hd + have hprod := product_mem M hM hP hU hPow hS hd hv + let e := cons ZFSet.omega (cons v (cons g (cons p (cons (natSet 0) (fun _ => d))))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|_|i <;> simp only [e,cons_zero,cons_succ] + · exact hω + · exact hv + · exact hgM + · exact hp + · exact h0 + · exact hd + have hs := sep_mem M hM hS iterationFormula e he hprod + have eq : ZFSet.sep (fun z => iterationFormula.Eval (cons z e)) (ZFSet.prod d v) = + iterationSet v F := by + apply ZFSet.ext + intro z + rw [ZFSet.mem_sep,mem_iterationSet F hF, + show iterationFormula.Eval (cons z e) ↔ _ from eval_iterationFormula z v g p d] + constructor + · rintro ⟨_,n,x,hx,y,hy,t,ht,s,hs,hz,htx,htrace⟩ + exact ⟨n,x,hx,by rw [hz,htx,trace_correct F hF hg hx htrace]⟩ + · rintro ⟨n,x,hx,rfl⟩ + let s := finiteGraph (n+1) (fun i => F^[i] x) + have hsM : s ∈ M := finiteGraph_mem M hM hP hU hω _ _ + (fun i _ => hM v hv _ (iterate_mem F hF hx i)) + have hsD : s ⊆ d := by + intro z hz + obtain ⟨i,hi,rfl⟩ := (mem_finiteGraph _ _ _).mp hz + exact ZFSet.pair_mem_prod.mpr ⟨(mem_omega _).mpr ⟨i,rfl⟩,iterate_mem F hF hx i⟩ + have hsP := (hpdef s).mpr ⟨hsM,hsD⟩ + have htD : ZFSet.pair (natSet n) x ∈ d := + ZFSet.pair_mem_prod.mpr ⟨(mem_omega _).mpr ⟨n,rfl⟩,hx⟩ + refine ⟨ZFSet.pair_mem_prod.mpr ⟨htD,iterate_mem F hF hx n⟩, + n,x,hx,_,iterate_mem F hF hx n,_,htD,s,hsP,rfl,rfl,?_⟩ + exact finiteGraph_trace F hF hg hx n + exact eq ▸ hs + +end +end TuringRigidity.SetModelIteration + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelSequences.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelSequences.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb43b1042aa652a9615c9668c6546a1cb0ea5c72 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelSequences.lean @@ -0,0 +1,148 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelRecursion +import OAI.Computability.DegreeRigidity.Constructibility.PersistenceRealClosure + +namespace OAI + +namespace TuringRigidity.SetModelSequences +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelIteration +universe u +noncomputable section + +def sequenceSet (F : ℕ → Oracle) : ZFSet.{u} := + ZFSet.range (fun n : ℕ => ZFSet.pair (natSet n) (realSet (F n))) + +@[simp] theorem mem_sequenceSet (F : ℕ → Oracle) (z : ZFSet.{u}) : + z ∈ sequenceSet F ↔ ∃ n, z = ZFSet.pair (natSet n) (realSet (F n)) := by + rw [sequenceSet,ZFSet.mem_range] + exact exists_congr (fun n => eq_comm) + +@[simp] theorem pair_mem_sequenceSet (F : ℕ → Oracle) (n : ℕ) (x : ZFSet.{u}) : + ZFSet.pair (natSet n) x ∈ sequenceSet F ↔ x = realSet (F n) := by + rw [mem_sequenceSet] + constructor + · rintro ⟨m,he⟩ + obtain ⟨hn,hx⟩ := ZFSet.pair_inj.mp he + exact natSet_injective hn ▸ hx + · intro h + exact ⟨n,by rw [h]⟩ + +def sliceFormula : Formula := + .existsMem 1 (.existsMem 3 (.existsMem 7 + (.conj (.orderedPair 3 2 1) (.conj (.orderedPair 0 2 6) (.pairMem 0 1 7))))) + +theorem eval_sliceFormula (z r a q d : ZFSet.{u}) : + sliceFormula.Eval (cons z (cons ZFSet.omega (cons r (cons a (cons q (fun _ => d)))))) ↔ + ∃ n : ℕ, ∃ b ∈ r, ∃ t ∈ d, + z = ZFSet.pair (natSet n) b ∧ t = ZFSet.pair (natSet n) a ∧ ZFSet.pair t b ∈ q := by + simp only [sliceFormula,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + cons_zero,cons_succ] + rw [omega_exists] + +theorem sequence_mem_of_iteration (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + {r : ZFSet.{u}} (hr : r ∈ M) (F : ZFSet.{u} → ZFSet.{u}) + (hF : ∀ x ∈ r, F x ∈ r) (hq : iterationSet r F ∈ M) + {A : Oracle} (hA : realSet A ∈ r) (B : ℕ → Oracle) + (hB : ∀ n, F^[n] (realSet A) = realSet (B n)) : sequenceSet B ∈ M := by + have hω := omega_mem M hM hS hI + let d := ZFSet.prod ZFSet.omega r + have hd : d ∈ M := product_mem M hM hP hU hPow hS hω hr + have ha := hM r hr _ hA + let e := cons ZFSet.omega (cons r (cons (realSet A) (cons (iterationSet r F) (fun _ => d)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|i <;> simp only [e,cons_zero,cons_succ] + · exact hω + · exact hr + · exact ha + · exact hq + · exact hd + have hs := sep_mem M hM hS sliceFormula e he hd + have eq : ZFSet.sep (fun z => sliceFormula.Eval (cons z e)) d = sequenceSet B := by + apply ZFSet.ext + intro z + rw [ZFSet.mem_sep,mem_sequenceSet, + show sliceFormula.Eval (cons z e) ↔ _ from eval_sliceFormula z r (realSet A) (iterationSet r F) d] + constructor + · rintro ⟨_,n,b,hb,t,ht,hz,htA,hqt⟩ + obtain ⟨m,x,hx,hpair⟩ := (mem_iterationSet F hF _).mp hqt + obtain ⟨hfirst,hsecond⟩ := ZFSet.pair_inj.mp hpair + rw [htA] at hfirst + obtain ⟨hn,hxA⟩ := ZFSet.pair_inj.mp hfirst + have hnm := natSet_injective hn + refine ⟨n,?_⟩ + rw [hz,hsecond,←hxA,←hnm,hB] + · rintro ⟨n,rfl⟩ + have hb : realSet (B n) ∈ r := hB n ▸ iterate_mem F hF hA n + have hn : natSet.{u} n ∈ ZFSet.omega := (mem_omega _).mpr ⟨n,rfl⟩ + refine ⟨ZFSet.pair_mem_prod.mpr ⟨hn,hb⟩,n,_,hb,_, + ZFSet.pair_mem_prod.mpr ⟨hn,hA⟩,rfl,rfl,?_⟩ + exact (mem_iterationSet F hF _).mpr ⟨n,realSet A,hA,by rw [hB]⟩ + exact eq ▸ hs + +def PairingCode (p : ZFSet.{u}) : Prop := ∀ n k m : ℕ, + ZFSet.pair (ZFSet.pair (natSet n) (natSet k)) (natSet m) ∈ p ↔ m = Nat.pair n k + +def flattenFormula : Formula := + .existsMem 1 (.existsMem 2 (.existsMem 7 (.existsMem 5 + (.conj (.orderedPair 1 3 2) (.conj (.pairMem 1 4 8) + (.conj (.pairMem 3 0 7) (.member 2 0))))))) + +theorem eval_flattenFormula (m : ℕ) (r q p d : ZFSet.{u}) : + flattenFormula.Eval (cons (natSet m) (cons ZFSet.omega + (cons r (cons q (cons p (fun _ => d)))))) ↔ + ∃ n k : ℕ, ∃ t ∈ d, ∃ b ∈ r, + t = ZFSet.pair (natSet n) (natSet k) ∧ ZFSet.pair t (natSet m) ∈ p ∧ + ZFSet.pair (natSet n) b ∈ q ∧ natSet k ∈ b := by + simp only [flattenFormula,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + cons_zero,cons_succ] + rw [omega_exists] + apply exists_congr + intro n + rw [omega_exists] + +theorem flatten_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hI : Infinity M) + {r p : ZFSet.{u}} (hr : r ∈ M) + (hrdef : ∀ x, x ∈ r ↔ ∃ A ∈ reals M, x = realSet A) + (hp : p ∈ M) (hpdef : PairingCode p) (F : ℕ → Oracle) + (hF : ∀ n, F n ∈ reals M) (hq : sequenceSet F ∈ M) : + (fun v => F (Nat.unpair v).1 (Nat.unpair v).2) ∈ reals M := by + have hω := omega_mem M hM hS hI + let d := ZFSet.prod ZFSet.omega ZFSet.omega + have hd : d ∈ M := product_mem M hM hP hU hPow hS hω hω + let e := cons ZFSet.omega (cons r (cons (sequenceSet F) (cons p (fun _ => d)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|i <;> simp only [e,cons_zero,cons_succ] + · exact hω + · exact hr + · exact hq + · exact hp + · exact hd + apply real_comprehension M hM hS hI _ flattenFormula e he + intro m + rw [show flattenFormula.Eval (cons (natSet m) e) ↔ _ from eval_flattenFormula m r (sequenceSet F) p d] + constructor + · rintro ⟨n,k,t,ht,b,hb,htnk,hpm,hqb,hkb⟩ + rw [htnk] at hpm + have hm := (hpdef n k m).mp hpm + have hbF := (pair_mem_sequenceSet F n b).mp hqb + rw [hbF] at hkb + simpa only [hm,Nat.unpair_pair] using (nat_mem_realSet _ _).mp hkb + · intro hm + let n := (Nat.unpair m).1 + let k := (Nat.unpair m).2 + have hn : natSet.{u} n ∈ ZFSet.omega := (mem_omega _).mpr ⟨n,rfl⟩ + have hk : natSet.{u} k ∈ ZFSet.omega := (mem_omega _).mpr ⟨k,rfl⟩ + refine ⟨n,k,_,ZFSet.pair_mem_prod.mpr ⟨hn,hk⟩,_, + (hrdef _).mpr ⟨F n,hF n,rfl⟩,rfl,?_,(pair_mem_sequenceSet F n _).mpr rfl,?_⟩ + · exact (hpdef n k m).mpr (Nat.pair_unpair m).symm + · exact (nat_mem_realSet _ _).mpr hm + +end +end TuringRigidity.SetModelSequences + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelTreeRelations.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelTreeRelations.lean new file mode 100644 index 0000000000000000000000000000000000000000..e68f1116061c233d6e9eb4bf5a9691d4cb331a5d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetModelTreeRelations.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelArithmeticTree +import OAI.Computability.DegreeRigidity.Syntax.SetRankCertificate + +namespace OAI + +namespace TuringRigidity.ArithmeticTree +open UniformArithmetic BoundedSetTheory TransitiveNameModel SetModelReals SetModelSyntax +open SetModelArithmetic SetModelFunctions SetModelSequences Encodable +universe u +noncomputable section +attribute [local instance] Classical.propDecidable + +def Test.canonicalNode (t : Test) (O : Oracles) (v n : ℕ) : Prop := + encode (decodeNode n) = n ∧ t.accepts O v (decodeNode n) + +def Test.edgePredicate (t : Test) (O : Oracles) (v n m : ℕ) : Prop := + t.canonicalNode O v n ∧ t.canonicalNode O v m ∧ ∃ a, decodeNode n = decodeNode m ++ [a] + +theorem Test.canonical_arith (t : Test) (v : ℕ) : Arith (fun O n => t.canonicalNode O v n) := + (Arith.pure _ (Primrec.eq.comp (Primrec.encode.comp decodeNode_primrec) Primrec.id)).and + (t.accepts_arith decodeNode_primrec (Primrec.const v)) + +theorem Test.edge_arith (t : Test) (v : ℕ) : + Arith (fun O n => t.edgePredicate O v (left n) (right n)) := by + have hc := ((t.canonical_arith v).comp _ left_primrec).and + ((t.canonical_arith v).comp _ right_primrec) + have he : Arith (fun _ n => + decodeNode (left (left n)) = decodeNode (right (left n)) ++ [right n]) := + .pure _ (Primrec.eq.comp (decodeNode_primrec.comp (left_primrec.comp left_primrec)) + (Primrec.list_concat.comp (decodeNode_primrec.comp (right_primrec.comp left_primrec)) right_primrec)) + exact (hc.and he.ex).congr (fun _ _ => by simp only [Test.edgePredicate,left,right,Nat.unpair_pair,and_assoc]) + +def relationSet (A : Oracle) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ x ∈ realSet A, ZFSet.pair z x ∈ pairingSet) pairNumbers + +theorem relationSet_pair (A : Oracle) (n m : ℕ) : + ZFSet.pair (natSet.{u} n) (natSet m) ∈ relationSet A ↔ A (Nat.pair n m) = true := by + simp only [relationSet,ZFSet.mem_sep,natPair_mem,true_and] + constructor + · rintro ⟨x,hx,hp⟩ + obtain ⟨k,rfl⟩ := (mem_omega _).mp (realSet_subset A hx) + have hk := (pairingSet_code n m k).mp hp + simpa only [hk,nat_mem_realSet] using hx + · intro hA + exact ⟨natSet (Nat.pair n m),(nat_mem_realSet _ _).mpr hA, + (pairingSet_code n m _).mpr rfl⟩ + +theorem relationSet_mem {M : ZFSet.{u}} (C : Context M) {A : Oracle} (hA : A ∈ reals M) : + relationSet A ∈ M := by + let φ : Formula := .existsMem 1 (.pairMem 1 0 3) + let e := cons (realSet A) (fun _ => pairingSet.{u}) + have he : ∀ i, e i ∈ M := by + intro i + cases i with + | zero => exact hA + | succ i => exact C.pairing_mem + have h := sep_mem M C.transitive C.separation φ e he C.pairNumbers_mem + have heq : ZFSet.sep (fun z => φ.Eval (cons z e)) pairNumbers = relationSet A := by + apply ZFSet.ext + intro z + simp only [relationSet,ZFSet.mem_sep,φ,e,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ] + exact heq ▸ h + +theorem Test.internal_relations {M : ZFSet.{u}} (C : Context M) (t : Test) + (O : Oracles) (hO : ∀ i, O i ∈ reals M) (v : ℕ) : + ∃ d ∈ M, ∃ r ∈ M, + (∀ n, natSet n ∈ d ↔ t.canonicalNode O v n) ∧ + (∀ n m, ZFSet.pair (natSet n) (natSet m) ∈ r ↔ t.edgePredicate O v n m) := by + let A : Oracle := fun n => decide (t.canonicalNode O v n) + let B : Oracle := fun n => decide (t.edgePredicate O v (left n) (right n)) + have hA : A ∈ reals M := arithmetic_comprehension C (t.canonical_arith v) O hO A + (fun n => by simp [A]) + have hB : B ∈ reals M := arithmetic_comprehension C (t.edge_arith v) O hO B + (fun n => by simp [B]) + refine ⟨realSet A,hA,relationSet B,relationSet_mem C hB,?_,?_⟩ + · intro n + simp [A] + · intro n m + simp [relationSet_pair,B,left,right] + +theorem Test.internal_tree {M : ZFSet.{u}} (C : Context M) (t : Test) + (O : Oracles) (hO : ∀ i, O i ∈ reals M) (v : ℕ) : + ∃ d ∈ M, ∃ r ∈ M, + (∀ x : t.tree O v, natSet (encode x.val) ∈ d) ∧ + (∀ x y : t.tree O v, ZFSet.pair (natSet (encode x.val)) (natSet (encode y.val)) ∈ r ↔ + t.Child O v x y) := by + obtain ⟨d,hd,r,hr,hD,hR⟩ := t.internal_relations C O hO v + refine ⟨d,hd,r,hr,fun x => (hD _).mpr ?_,fun x y => ?_⟩ + · exact ⟨by simp,by simpa only [decodeNode_encode] using (show t.accepts O v x.val from x.property)⟩ + · rw [hR] + have hx : t.canonicalNode O v (encode x.val) := ⟨by simp,by + simpa only [decodeNode_encode] using (show t.accepts O v x.val from x.property)⟩ + have hy : t.canonicalNode O v (encode y.val) := ⟨by simp,by + simpa only [decodeNode_encode] using (show t.accepts O v y.val from y.property)⟩ + simp only [Test.edgePredicate,hx,hy,true_and,decodeNode_encode,Test.Child] + +end +end TuringRigidity.ArithmeticTree + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SetPresentationDecoding.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SetPresentationDecoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e4ce003d78cc3ab9770c70d1f14cddb6cd9ddf3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SetPresentationDecoding.lean @@ -0,0 +1,138 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaSyntax + +namespace OAI + +namespace TuringRigidity.SetPresentationDecoding +open BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def classSet (d E x : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun y => ZFSet.pair x y ∈ E) d + +@[simp] theorem mem_classSet (d E x y : ZFSet.{u}) : + y ∈ classSet d E x ↔ y ∈ d ∧ ZFSet.pair x y ∈ E := ZFSet.mem_sep + +def classFormula (c x d E : ℕ) : Formula := + .conj (.subset c d) (.allMem d (.iff (.member 0 (c+1)) (.pairMem (x+1) 0 (E+1)))) + +@[simp] theorem eval_classFormula (c x d E : ℕ) (e : ℕ → ZFSet.{u}) : + (classFormula c x d E).Eval e ↔ e c = classSet (e d) (e E) (e x) := by + simp only [classFormula,Formula.Eval,Formula.eval_subset,Formula.eval_allMem, + Formula.eval_iff,Formula.eval_pairMem,cons_zero,cons_succ] + constructor + · rintro ⟨hsub,h⟩ + apply ZFSet.ext + intro y + rw [mem_classSet] + exact ⟨fun hy => ⟨hsub hy,(h y (hsub hy)).mp hy⟩, + fun hy => (h y hy.1).mpr hy.2⟩ + · intro h + rw [h] + exact ⟨fun _ hy => (mem_classSet _ _ _ _).mp hy |>.1, + fun y hy => by simp [hy]⟩ + +theorem class_mem (M : ZFSet.{u}) (hM : Transitive M) (hS : Separation M) + {d E x : ZFSet.{u}} (hd : d ∈ M) (hE : E ∈ M) (hx : x ∈ M) : + classSet d E x ∈ M := by + let e := cons x (cons E (fun _ => d)) + have he : ∀ i, e i ∈ M := by intro i; cases i with + | zero => exact hx + | succ i => cases i <;> simp [e,hd,hE] + simpa only [Formula.eval_pairMem,e,cons_zero,cons_succ,classSet] using + sep_mem M hM hS (.pairMem 1 0 2) e he hd + +noncomputable def quotientSet (d E a : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun c => ∃ x ∈ a, c = classSet d E x) (ZFSet.powerset d) + +@[simp] theorem mem_quotientSet (d E a c : ZFSet.{u}) : + c ∈ quotientSet d E a ↔ ∃ x ∈ a, c = classSet d E x := by + simp only [quotientSet,ZFSet.mem_sep,ZFSet.mem_powerset] + constructor + · exact And.right + · rintro ⟨x,hx,rfl⟩ + exact ⟨fun y hy => (mem_classSet _ _ _ _).mp hy |>.1,⟨x,hx,rfl⟩⟩ + +theorem quotient_mem (M : ZFSet.{u}) (hM : Transitive M) + (hPow : PowerSet M) (hS : Separation M) + {d E a : ZFSet.{u}} (hd : d ∈ M) (hE : E ∈ M) (ha : a ∈ M) : + quotientSet d E a ∈ M := by + obtain ⟨p,hp,hpdef⟩ := internal_power M hM hPow hd + let e := cons a (cons d (fun _ => E)) + have he : ∀ i, e i ∈ M := by intro i; cases i with + | zero => exact ha + | succ i => cases i <;> simp [e,hd,hE] + let φ : Formula := .existsMem 1 (classFormula 1 0 3 4) + have h := sep_mem M hM hS φ e he hp + have eq : ZFSet.sep (fun c => φ.Eval (cons c e)) p = quotientSet d E a := by + apply ZFSet.ext + intro c + simp only [ZFSet.mem_sep,φ,Formula.Eval,eval_classFormula,cons_zero,cons_succ,e, + mem_quotientSet] + constructor + · exact And.right + · rintro ⟨x,hx,rfl⟩ + refine ⟨(hpdef _).mpr ⟨class_mem M hM hS hd hE (hM a ha x hx),?_⟩,⟨x,hx,rfl⟩⟩ + intro y hy + exact (mem_classSet _ _ _ _).mp hy |>.1 + exact eq ▸ h + +noncomputable def actionGraph (d E a R : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ x ∈ a, ∃ y ∈ a, + ZFSet.pair x y ∈ R ∧ z = ZFSet.pair (classSet d E x) (classSet d E y)) + (ZFSet.prod (quotientSet d E a) (quotientSet d E a)) + +@[simp] theorem mem_actionGraph (d E a R z : ZFSet.{u}) : + z ∈ actionGraph d E a R ↔ ∃ x ∈ a, ∃ y ∈ a, + ZFSet.pair x y ∈ R ∧ z = ZFSet.pair (classSet d E x) (classSet d E y) := by + rw [actionGraph,ZFSet.mem_sep] + constructor + · exact And.right + · intro h + obtain ⟨x,hx,y,hy,hxy,rfl⟩ := h + exact ⟨ZFSet.pair_mem_prod.mpr ⟨(mem_quotientSet _ _ _ _).mpr ⟨x,hx,rfl⟩, + (mem_quotientSet _ _ _ _).mpr ⟨y,hy,rfl⟩⟩,⟨x,hx,y,hy,hxy,rfl⟩⟩ + +def actionFormula : Formula := + .existsMem 1 (.existsMem 2 (.conj (.pairMem 1 0 6) + (.existsMem 7 (.existsMem 8 (.conj (classFormula 1 3 6 7) + (.conj (classFormula 0 2 6 7) (.orderedPair 4 1 0))))))) + +theorem eval_actionFormula (z a d E R q : ZFSet.{u}) : + actionFormula.Eval (cons z (cons a (cons d (cons E (cons R (fun _ => q)))))) ↔ + ∃ x ∈ a, ∃ y ∈ a, ZFSet.pair x y ∈ R ∧ + ∃ c ∈ q, ∃ b ∈ q, c = classSet d E x ∧ b = classSet d E y ∧ z = ZFSet.pair c b := by + simp only [actionFormula,Formula.Eval,Formula.eval_pairMem,eval_classFormula, + Formula.eval_orderedPair,cons_zero,cons_succ] + +theorem action_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + {d E a R : ZFSet.{u}} (hd : d ∈ M) (hE : E ∈ M) (ha : a ∈ M) (hR : R ∈ M) : + actionGraph d E a R ∈ M := by + let q := quotientSet d E a + have hq := quotient_mem M hM hPow hS hd hE ha + have hprod := product_mem M hM hP hU hPow hS hq hq + let e := cons a (cons d (cons E (cons R (fun _ => q)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|_|_|_|i <;> simp [e,ha,hd,hE,hR,q,hq] + have h := sep_mem M hM hS actionFormula e he hprod + have eq : ZFSet.sep (fun z => actionFormula.Eval (cons z e)) (ZFSet.prod q q) = + actionGraph d E a R := by + apply ZFSet.ext + intro z + rw [ZFSet.mem_sep,mem_actionGraph,show actionFormula.Eval (cons z e) ↔ _ from + eval_actionFormula z a d E R q] + constructor + · rintro ⟨_,x,hx,y,hy,hR,c,hc,b,hb,rfl,rfl,hz⟩ + exact ⟨x,hx,y,hy,hR,hz⟩ + · intro h + obtain ⟨x,hx,y,hy,hxy,rfl⟩ := h + have hxq : classSet d E x ∈ q := (mem_quotientSet _ _ _ _).mpr ⟨x,hx,rfl⟩ + have hyq : classSet d E y ∈ q := (mem_quotientSet _ _ _ _).mpr ⟨y,hy,rfl⟩ + exact ⟨ZFSet.pair_mem_prod.mpr ⟨hxq,hyq⟩, + ⟨x,hx,y,hy,hxy,_,hxq,_,hyq,rfl,rfl,rfl⟩⟩ + exact eq ▸ h + +end TuringRigidity.SetPresentationDecoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ShuffleRequirements.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ShuffleRequirements.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc1ad8df7885831f34e481da8bd84efb0978dfdf --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ShuffleRequirements.lean @@ -0,0 +1,180 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteShuffle + +namespace OAI + +namespace TuringRigidity.ShuffleRequirements +open FiniteShuffle GenericCoding Set + +def Realizes (s : List Bool) (G : Oracle) : Prop := + Agree s.length (fun i => s.getD i false) G + +theorem realizes_initial (A G : Oracle) (n : ℕ) : + Realizes (initial A n) G ↔ Agree n A G := by + change (∀ i, i < (initial A n).length → (initial A n).getD i false = G i) ↔ _ + simp only [prefix_length] + constructor + · intro h i hi + rw [←prefix_getD A n i hi] + exact h i hi + · intro h i hi + rw [prefix_getD A n i hi] + exact h i hi + +theorem getD_of_prefix {s t : List Bool} (h : s <+: t) (i : ℕ) (hi : i < s.length) : + s.getD i false = t.getD i false := by + obtain ⟨u,rfl⟩ := h + simp [List.getD,List.getElem?_append,hi] + +theorem realizes_mono {s t : List Bool} {G : Oracle} (h : s <+: t) (hg : Realizes t G) : + Realizes s G := fun i hi => (getD_of_prefix h i hi).trans (hg i (lt_of_lt_of_le hi h.length_le)) + +theorem realizes_default (s : List Bool) : Realizes s (fun i => s.getD i false) := + fun _ _ => rfl + +theorem realizes_isOpen (s : List Bool) : IsOpen {G | Realizes s G} := by + have he : {G | Realizes s G} = ⋂ i : Fin s.length, {G : Oracle | G i = s.getD i false} := by + ext G + simp only [mem_ofPred_eq,mem_iInter] + exact ⟨fun h i => (h i i.isLt).symm,fun h i hi => (h ⟨i,hi⟩).symm⟩ + rw [he] + apply isOpen_iInter_of_finite + intro i + have hc : Continuous (fun G : Oracle => G (i : ℕ)) := continuous_apply _ + simpa only [Set.preimage,Set.mem_singleton_iff] using + (isOpen_discrete ({s.getD i false} : Set Bool)).preimage hc + +def Transfer (D : List Bool → Prop) (s : List Bool) : Prop := + ∀ A, ∃ t, D t ∧ ∀ G, Realizes s G → Realizes t (code A G) + +theorem transfer_mono (D : List Bool → Prop) {s t : List Bool} + (h : s <+: t) (hs : Transfer D s) : Transfer D t := by + intro A + obtain ⟨r,hr,hG⟩ := hs A + exact ⟨r,hr,fun G hg => hG G (realizes_mono h hg)⟩ + +theorem transfer_denseOpen (D : List Bool → Prop) (hd : DenseOpen D) : DenseOpen (Transfer D) := by + refine ⟨?_,fun _ _ h hs => transfer_mono D h hs⟩ + intro s + let G : Oracle := fun i => s.getD i false + obtain ⟨m,H,hnm,hGH,hb,hD⟩ := all_extension D hd (s.length+1) G + refine ⟨initial H (2*m),?_,?_⟩ + · rw [←prefix_default s] + apply initial_prefix (n := s.length) (m := 2*m) (by omega) + exact hGH.mono (by omega) + · intro A + obtain ⟨l,hl,hDl⟩ := hD A + refine ⟨initial (code A H) l,hDl,?_⟩ + intro K hK + apply (realizes_initial _ _ _).mpr + exact code_agree (fun _ _ => rfl) + (((realizes_initial H K (2*m)).mp hK).mono (by omega)) + +def OpenSet (D : List Bool → Prop) : Set Oracle := {G | ∃ s, D s ∧ Realizes s G} + +theorem openSet_isOpen (D : List Bool → Prop) : IsOpen (OpenSet D) := by + have he : OpenSet D = ⋃ s : List Bool, ⋃ (_ : D s), {G | Realizes s G} := by + ext G; simp [OpenSet] + rw [he] + exact isOpen_iUnion (fun s => isOpen_iUnion (fun _ => realizes_isOpen s)) + +theorem openSet_measurable (D : List Bool → Prop) : MeasurableSet (OpenSet D) := + (openSet_isOpen D).measurableSet + +def GenericFor (D : ℕ → List Bool → Prop) (G : Oracle) : Prop := ∀ n, G ∈ OpenSet (D n) + +theorem generic_transfer (D : ℕ → List Bool → Prop) (G : Oracle) + (hg : GenericFor (fun n => Transfer (D n)) G) (A : Oracle) : GenericFor D (code A G) := by + intro n + obtain ⟨s,hs,hGs⟩ := hg n + obtain ⟨t,ht,hGt⟩ := hs A + exact ⟨t,ht,hGt G hGs⟩ + +def OddHit (N : ℕ) (s : List Bool) : Prop := + ∃ i, N ≤ i ∧ 2*i+1 < s.length ∧ s.getD (2*i+1) false = true + +theorem oddHit_denseOpen (N : ℕ) : DenseOpen (OddHit N) := by + constructor + · intro s + let i := N+s.length + let H : Oracle := fun j => if j < s.length then s.getD j false else true + refine ⟨initial H (2*i+2),?_,i,by omega,by simp,?_⟩ + · rw [←prefix_default s] + apply initial_prefix (n := s.length) (m := 2*i+2) (by dsimp [i]; omega) + intro j hj + simp [H,hj] + · rw [prefix_getD _ _ _ (by omega)] + simp [H,show ¬2*i+1 Transfer (D n)) G := by + intro n + simpa [OpenSet,Requirements,Nat.unpair_pair] using hg (Nat.pair n 1) + have h2 : GenericFor OddHit G := by + intro n + simpa [OpenSet,Requirements,Nat.unpair_pair] using hg (Nat.pair n 2) + exact ⟨h0,infiniteOdd_of_hits G h2,fun A => generic_transfer D G h1 A⟩ + +theorem coded_dense (D : List Bool → Prop) (hd : DenseOpen D) (s : ℕ) : + ∃ t, BorelGeneric.Ext s t ∧ D (BorelGeneric.word t) := by + obtain ⟨u,hu,hD⟩ := hd.1 (BorelGeneric.word s ++ [false]) + obtain ⟨t,ht⟩ := BorelGeneric.word_surjective u + refine ⟨t,⟨?_,?_⟩,by simpa [ht] using hD⟩ + · rw [ht] + exact (List.prefix_append _ _).trans hu + · have hl := hu.length_le + simp only [List.length_append,List.length_singleton] at hl + rw [ht] + omega + +theorem realizes_iff_meets (G : Oracle) (s : ℕ) : + Realizes (BorelGeneric.word s) G ↔ BorelGeneric.Meets G s := by + exact ⟨fun h i hi => (h i hi).symm,fun h i hi => (h i hi).symm⟩ + +theorem requirements_borel {X : Type*} [MeasurableSpace X] + (D : ℕ → List Bool → Prop) (n t : ℕ) : + MeasurableSet {_x : X | Requirements D n (BorelGeneric.word t)} := by + by_cases h : Requirements D n (BorelGeneric.word t) <;> simp [h] + +theorem borel_all_generic_selection {X : Type*} [MeasurableSpace X] + (D : ℕ → List Bool → Prop) (hd : ∀ n, DenseOpen (D n)) : + ∃ G : X → Oracle, Measurable G ∧ ∀ x, + GenericFor D (G x) ∧ InfiniteOdd (G x) ∧ ∀ A, GenericFor D (code A (G x)) := by + let R : X → ℕ → ℕ → Prop := fun _ n t => Requirements D n (BorelGeneric.word t) + have hR : ∀ x n s, ∃ t, BorelGeneric.Ext s t ∧ R x n t := + fun _ n s => coded_dense _ (requirements_denseOpen D hd n) s + obtain ⟨G,hG,hreq⟩ := BorelGeneric.borel_generic_selection R hR (requirements_borel D) + refine ⟨G,hG,fun x => requirements_spec D (G x) ?_⟩ + intro n + obtain ⟨t,ht,hGt⟩ := hreq x n + exact ⟨BorelGeneric.word t,ht,(realizes_iff_meets _ _).mpr hGt⟩ + +end TuringRigidity.ShuffleRequirements + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SkolemHull.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SkolemHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..4234132884216af65d712ff30a850de994953027 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SkolemHull.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.SetModels.FiniteClosure + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace FiniteTuple + +noncomputable def hull (d q s : ZFSet.{u}) (n : ℕ) (g : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun x => ∀ h ∈ q, s ⊆ h → Closed n g h → x ∈ h) d + +theorem mem_hull (d q s x : ZFSet.{u}) (n : ℕ) (g : ZFSet.{u}) : + x ∈ hull d q s n g ↔ x ∈ d ∧ ∀ h ∈ q, s ⊆ h → Closed n g h → x ∈ h := ZFSet.mem_sep + +def hullFormula (n : ℕ) : Formula := + .allMem 1 (.imp (.subset 3 0) (.imp (closedFormula n 4 5 6 7 8 0) (.member 1 0))) + +theorem hull_mem (M d q s c g : ZFSet.{u}) (n : ℕ) (hM : Transitive M) + (hS : Separation M) (hd : d ∈ M) (hqM : q ∈ M) (hs : s ∈ M) (hcM : c ∈ M) + (h0 : (∅ : ZFSet.{u}) ∈ M) (hgM : g ∈ M) (haM : space d n ∈ M) + (hq : ∀ h, h ∈ q ↔ h ∈ M ∧ h ⊆ d) (hc : Transitive c) (hac : space d n ⊆ c) + (hg : g ⊆ ZFSet.prod (space d n) d) : hull d q s n g ∈ M := by + let e := cons q (cons s (cons (space d n) (cons d (cons c (cons ∅ (cons g (fun _ => d))))))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hqM + rcases i with _|i; exact hs + rcases i with _|i; exact haM + rcases i with _|i; exact hd + rcases i with _|i; exact hcM + rcases i with _|i; exact h0 + rcases i with _|i; exact hgM + exact hd + have hsep := sep_mem M hM hS (hullFormula n) e he hd + have heq : ZFSet.sep (fun x => (hullFormula n).Eval (cons x e)) d = hull d q s n g := by + apply ZFSet.ext; intro x + rw [ZFSet.mem_sep,mem_hull] + apply and_congr_right; intro _ + simp only [hullFormula,Formula.eval_allMem,Formula.eval_imp,Formula.eval_subset, + Formula.Eval,cons_zero,cons_succ] + apply forall_congr'; intro h + apply forall_congr'; intro hh + apply imp_congr_right; intro _ + have heval := eval_closedFormula n 4 5 6 7 8 0 (cons h (cons x e)) + rfl hc hac rfl hg ((hq h).mp hh).2 + exact imp_congr heval Iff.rfl + exact heq ▸ hsep + +theorem hull_subset (d q s : ZFSet.{u}) (n : ℕ) (g : ZFSet.{u}) : hull d q s n g ⊆ d := + fun _ hx => (mem_hull _ _ _ _ _ _).mp hx |>.1 + +theorem seed_subset_hull (d q s : ZFSet.{u}) (n : ℕ) (g : ZFSet.{u}) (hs : s ⊆ d) : + s ⊆ hull d q s n g := + fun _x hx => (mem_hull _ _ _ _ _ _).mpr ⟨hs hx,fun _ _ hsh _ => hsh hx⟩ + +theorem hull_closed (d q s : ZFSet.{u}) (n : ℕ) (g : ZFSet.{u}) + (hg : g ⊆ ZFSet.prod (space d n) d) : Closed n g (hull d q s n g) := by + intro xs hlen hxs y hy + have hyd : y ∈ d := by + obtain ⟨t,_,v,hv,hp⟩ := ZFSet.mem_prod.mp (hg hy) + obtain ⟨_,rfl⟩ := ZFSet.pair_inj.mp hp + exact hv + refine (mem_hull _ _ _ _ _ _).mpr ⟨hyd,?_⟩ + intro h hh hsh hclosed + exact hclosed xs hlen (fun x hx => ((mem_hull _ _ _ _ _ _).mp (hxs x hx)).2 h hh hsh hclosed) y hy + +theorem hull_least (d q s h : ZFSet.{u}) (n : ℕ) (g : ZFSet.{u}) + (hh : h ∈ q) (hs : s ⊆ h) (hc : Closed n g h) : hull d q s n g ⊆ h := + fun _ hx => ((mem_hull _ _ _ _ _ _).mp hx).2 h hh hs hc + +theorem internal_finite_hull (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) + {d s g : ZFSet.{u}} (hd : d ∈ M) (hs : s ∈ M) (hgM : g ∈ M) (n : ℕ) + (hsd : s ⊆ d) (hg : g ⊆ ZFSet.prod (space d n) d) : + ∃ h ∈ M, s ⊆ h ∧ h ⊆ d ∧ Closed n g h ∧ + ∀ v ∈ M, v ⊆ d → s ⊆ v → Closed n g v → h ⊆ v := by + obtain ⟨q,hqM,hq⟩ := internal_power M hM hPow hd + have ha := space_mem M hM hP hU hPow hS hd n + obtain ⟨c,hc,hct,hac⟩ := internal_transitive_container M hM hP hU hS hR hI ha + have h0 : (∅ : ZFSet.{u}) ∈ M := hM _ (omega_mem M hM hS hI) _ ZFSet.omega_zero + refine ⟨hull d q s n g,hull_mem M d q s c g n hM hS hd hqM hs hc h0 hgM ha hq hct + (fun x hx => hct _ hac x hx) hg,seed_subset_hull d q s n g hsd, + hull_subset d q s n g,hull_closed d q s n g hg,?_⟩ + intro v hv hvd hsv hcv + exact hull_least d q s v n g ((hq v).mpr ⟨hv,hvd⟩) hsv hcv + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SkolemOperations.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SkolemOperations.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5b0b5de66772adf3ba82b25bb69072e8fd284bf --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SkolemOperations.lean @@ -0,0 +1,120 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCoverInjection +import OAI.Computability.DegreeRigidity.SetModels.FiniteSkolem + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace FiniteTerm + +noncomputable def labelGraph (a b g o : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ x ∈ a, ∃ y ∈ b, z = ZFSet.pair (ZFSet.pair o x) y ∧ ZFSet.pair x y ∈ g) + (ZFSet.prod (ZFSet.prod {o} a) b) + +theorem labelGraph_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + {a b g o : ZFSet.{u}} (ha : a ∈ M) (hb : b ∈ M) (hg : g ∈ M) (ho : o ∈ M) : + labelGraph a b g o ∈ M := by + simpa only [labelGraph,Formula.Eval,Formula.eval_leftPair,Formula.eval_pairMem,cons_zero,cons_succ] using + sep_mem M hM hS (.existsMem 1 (.existsMem 3 (.conj (.leftPair 2 5 1 0) (.pairMem 1 0 6)))) + (cons a (cons b (cons o (fun _ => g)))) (by + intro i; rcases i with _|i; exact ha + rcases i with _|i; exact hb + rcases i with _|i; exact ho + exact hg) + (product_mem M hM hP hU hPow hS + (product_mem M hM hP hU hPow hS (singleton_mem M hM hP ho) ha) hb) + +theorem labelGraph_shape {a b g o z : ZFSet.{u}} (hz : z ∈ labelGraph a b g o) : + ∃ x ∈ a, ∃ y ∈ b, z = ZFSet.pair (ZFSet.pair o x) y ∧ ZFSet.pair x y ∈ g := + (ZFSet.mem_sep.mp hz).2 + +theorem labelGraph_contains {a b g o x y : ZFSet.{u}} (hg : g ⊆ ZFSet.prod a b) + (hxy : ZFSet.pair x y ∈ g) : ZFSet.pair (ZFSet.pair o x) y ∈ labelGraph a b g o := by + obtain ⟨x',hx,y',hy,hp⟩ := ZFSet.mem_prod.mp (hg hxy) + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact ZFSet.mem_sep.mpr ⟨ZFSet.mem_prod.mpr + ⟨_,ZFSet.mem_prod.mpr ⟨o,ZFSet.mem_singleton.mpr rfl,x,hx,rfl⟩,y,hy,rfl⟩,x,hx,y,hy,rfl,hxy⟩ + +theorem labelGraph_functional {a b g o : ZFSet.{u}} (hg : Functional g) : + Functional (labelGraph a b g o) := by + intro c x y hx hy + obtain ⟨u,_,v,_,he,huv⟩ := labelGraph_shape hx + obtain ⟨hcu,rfl⟩ := ZFSet.pair_inj.mp he + obtain ⟨u',_,v',_,he,huv'⟩ := labelGraph_shape hy + obtain ⟨hcu',rfl⟩ := ZFSet.pair_inj.mp he + have huu := (ZFSet.pair_inj.mp (hcu.symm.trans hcu')).2 + subst u' + exact hg u x y huv huv' + +theorem Functional.union {f g : ZFSet.{u}} (hf : Functional f) (hg : Functional g) + (hdis : ∀ a x y, ZFSet.pair a x ∈ f → ZFSet.pair a y ∈ g → False) : Functional (f ∪ g) := by + intro a x y hx hy + rcases ZFSet.mem_union.mp hx with hx|hx <;> rcases ZFSet.mem_union.mp hy with hy|hy + · exact hf a x y hx hy + · exact False.elim (hdis a x y hx hy) + · exact False.elim (hdis a y x hy hx) + · exact hg a x y hx hy + +theorem skolem_functional {d g : ZFSet.{u}} {n : ℕ} {φ : Formula} {e : ℕ → ZFSet.{u}} + (hg : FiniteTuple.SkolemGraph d n φ e g) : Functional g := by + intro c x y hx hy + have hp := (ZFSet.mem_sep.mp (hg.1 hx)).1 + obtain ⟨c',hc,x',_,he⟩ := ZFSet.mem_prod.mp hp + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + obtain ⟨xs,hlen,_,rfl⟩ := (FiniteTuple.mem_space d c n).mp hc + exact hg.functional xs hlen hx hy + +theorem internal_skolem_operations (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) + {d : ZFSet.{u}} (hd : d ∈ M) (n : ℕ) (fs : List Formula) (start : ℕ) : + ∃ O ∈ M, Functional O ∧ + (∀ z ∈ O, ∃ i, start ≤ i ∧ ∃ c v, z = ZFSet.pair (ZFSet.pair (natSet i) c) v) ∧ + ∀ φ ∈ fs, ∃ i : ℕ, ∃ g ∈ M, FiniteTuple.SkolemGraph d n φ (fun _ => d) g ∧ + ∀ c v, ZFSet.pair c v ∈ g → ZFSet.pair (ZFSet.pair (natSet i) c) v ∈ O := by + have hω := omega_mem M hM hS hI + have hn (n : ℕ) : natSet.{u} n ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩) + have ha := FiniteTuple.space_mem M hM hP hU hPow hS hd n + induction fs generalizing start with + | nil => exact ⟨∅,hn 0,by intro a x y hx; exact False.elim (by simp at hx),by simp,by simp⟩ + | cons φ fs ih => + obtain ⟨O,hO,hOf,hOs,hOg⟩ := ih (start+1) + obtain ⟨g,hg,hgs⟩ := FiniteTuple.internal_skolem_graph M hM hP hU hPow hS hR hI hAC hd n φ + (fun _ => d) (fun _ => hd) + let f := labelGraph (FiniteTuple.space d n) d g (natSet start) + have hf : f ∈ M := labelGraph_mem M hM hP hU hPow hS ha hd hg (hn start) + have hff : Functional f := labelGraph_functional (skolem_functional hgs) + have hfshape (z : ZFSet.{u}) (hz : z ∈ f) : + ∃ c v, z = ZFSet.pair (ZFSet.pair (natSet start) c) v := by + obtain ⟨c,_,v,_,he,_⟩ := labelGraph_shape hz + exact ⟨c,v,he⟩ + refine ⟨f ∪ O,binary_union_mem M hM hP hU hf hO,hff.union hOf ?_,?_,?_⟩ + · intro a x y hx hy + obtain ⟨c,v,hc⟩ := hfshape _ hx + obtain ⟨i,hi,b,w,hb⟩ := hOs _ hy + have hac := (ZFSet.pair_inj.mp hc).1 + have hab := (ZFSet.pair_inj.mp hb).1 + have he := natSet_injective (ZFSet.pair_inj.mp (hac.symm.trans hab)).1 + omega + · intro z hz + rcases ZFSet.mem_union.mp hz with hz|hz + · obtain ⟨c,v,he⟩ := hfshape z hz + exact ⟨start,le_refl _,c,v,he⟩ + · obtain ⟨i,hi,c,v,he⟩ := hOs z hz + exact ⟨i,by omega,c,v,he⟩ + · intro ψ hψ + rcases List.mem_cons.mp hψ with rfl|hψ + · refine ⟨start,g,hg,hgs,?_⟩ + intro c v hcv + exact ZFSet.mem_union.mpr (Or.inl (labelGraph_contains + (fun z hz => (ZFSet.mem_sep.mp (hgs.1 hz)).1) hcv)) + · obtain ⟨i,v,hv,hvs,hvo⟩ := hOg ψ hψ + exact ⟨i,v,hv,hvs,fun c x hcx => ZFSet.mem_union.mpr (Or.inr (hvo c x hcx))⟩ + +end FiniteTerm +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/SmallWitnessBound.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/SmallWitnessBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d8e7629a12203516fe76582879a5e72f3ab4d78 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/SmallWitnessBound.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalStructureCollapse + +namespace OAI + + +namespace TuringRigidity.RelationCollapse +open TransitiveNameModel BoundedSetTheory +universe u + +theorem codedRelation_structureMap {k d f : ZFSet.{u}} {j : ZFSet.{u} → ZFSet.{u}} + (hf : Presents d f j) (hj : ∀ x ∈ d, j x ∈ k) + (hi : ∀ x ∈ d, ∀ y ∈ d, j x = j y → x = y) + (wf : WellFounded (Rel k (codedRelation k d f))) + (x : ZFSet.{u}) (hx : x ∈ d) : + value k (codedRelation k d f) wf (j x) = structureMap d x := by + induction x using ZFSet.inductionOn with + | h x ih => + apply ZFSet.ext + intro z + rw [structureMap,mem_value,mem_value] + constructor + · rintro ⟨u,_,hux,hz⟩ + obtain ⟨y,hy,w,hw,hyw,rfl,hwx⟩ := (codedRelation_pair hf hj u (j x)).mp hux + have hwx' : x = w := hi x hx w hw hwx + subst w + rw [ih y hyw hy] at hz + exact ⟨y,hy,(membershipRelation_pair d y x).mpr ⟨hy,hx,hyw⟩,hz⟩ + · rintro ⟨y,hy,hyx,hz⟩ + have hyx' := ((membershipRelation_pair d y x).mp hyx).2.2 + exact ⟨j y,hj y hy,(codedRelation_pair hf hj _ _).mpr + ⟨y,hy,x,hx,hyx',rfl,rfl⟩,hz.trans (ih y hyx' hy).symm⟩ + +theorem internal_structure_value_bound (M k : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hk : k ∈ M) : + ∃ W ∈ M, ∀ d ∈ M, ∀ f ∈ M, ∀ j : ZFSet.{u} → ZFSet.{u}, + Presents d f j → (∀ x ∈ d, j x ∈ k) → + (∀ x ∈ d, ∀ y ∈ d, j x = j y → x = y) → + ∀ x ∈ d, structureMap d x ∈ W := by + obtain ⟨W,hW,hbound⟩ := internal_value_bound M k hM hP hU hPow hS hR hk + refine ⟨W,hW,?_⟩ + intro d hd f hf j hfj hj hi x hx + have hr := codedRelation_mem M hM hP hU hPow hS.bounded hk hd hf + have wf := codedRelation_wellFounded hfj hj hi + have hv := hbound _ hr (codedRelation_on k d f) wf (j x) (hj x hx) + rwa [codedRelation_structureMap hfj hj hi wf x hx] at hv + +theorem internal_small_witness_bound (M k : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hk : k ∈ M) : + ∃ W ∈ M, ∀ d ∈ M, StructureExtensional d → + ∀ f ∈ M, ∀ j : ZFSet.{u} → ZFSet.{u}, Presents d f j → + (∀ x ∈ d, j x ∈ k) → (∀ x ∈ d, ∀ y ∈ d, j x = j y → x = y) → + ∀ t : ZFSet.{u}, Transitive t → t ⊆ d → ∀ e : ℕ → ZFSet.{u}, (∀ i, e i ∈ t) → + ∀ φ : SigmaFormula, ∀ x ∈ d, φ.Realize d (cons x e) → + ∃ y ∈ W, φ.Realize M (cons y e) := by + obtain ⟨W,hW,hbound⟩ := internal_structure_value_bound M k hM hP hU hPow hS hR hk + refine ⟨W,hW,?_⟩ + intro d hd hext f hf j hfj hj hi t ht htd e he φ x hx hφ + obtain ⟨b,hb,g,_,_,hbt,hbdef,htransfer⟩ := + internal_structure_collapse M d hM hP hU hPow hS.bounded hR hd hext + have henv : ∀ i, cons x e i ∈ d := by + intro i; cases i with + | zero => exact hx + | succ i => exact htd (he i) + have hcollapse := (htransfer φ (cons x e) henv).mp hφ + have hfix : (fun i => structureMap d (cons x e i)) = cons (structureMap d x) e := by + funext i + cases i with + | zero => rfl + | succ i => exact structureMap_fixed ht htd (e i) (he i) + have henvb : ∀ i, (fun i => structureMap d (cons x e i)) i ∈ b := + fun i => (hbdef _).mpr ⟨cons x e i,henv i,rfl⟩ + have hup := φ.upward b M hbt hM (fun y hy => hM b hb y hy) _ henvb hcollapse + rw [hfix] at hup + exact ⟨structureMap d x,hbound d hd f hf j hfj hj hi x hx,hup⟩ + +end TuringRigidity.RelationCollapse + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/TransitiveNameModel.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/TransitiveNameModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ba501d44d07902b791ba80f5c45260f728116c3 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/TransitiveNameModel.lean @@ -0,0 +1,107 @@ +import OAI.Computability.DegreeRigidity.SetModels.NameEncoding +import OAI.Computability.DegreeRigidity.SetModels.NameExtension + +namespace OAI + +namespace TuringRigidity.TransitiveNameModel +open Set RecursiveNames +universe u + +abbrev Conditions (p : ZFSet.{u}) : Type u := Shrink p + +noncomputable def label (p : ZFSet.{u}) (q : Conditions p) : ZFSet.{u} := + ((equivShrink p).symm q).val + +theorem label_injective (p : ZFSet.{u}) : Function.Injective (label p) := + fun _ _ h => (equivShrink p).symm.injective (Subtype.ext h) + +theorem label_mem (p : ZFSet.{u}) (q : Conditions p) : label p q ∈ p := + ((equivShrink p).symm q).property + +def names (M p : ZFSet.{u}) : Set (Name (Conditions p)) := + {τ | Name.encode (label p) τ ∈ M} + +def Transitive (M : ZFSet.{u}) : Prop := ∀ x ∈ M, ∀ y ∈ x, y ∈ M + +def genericExtension (M p : ZFSet.{u}) (G : Set (Conditions p)) : Set ZFSet.{u} := + extension (names M p) G + +theorem names_childClosed (M p : ZFSet.{u}) (hM : Transitive M) : + ChildClosed (names M p) := by + intro τ hτ σ hσ + cases τ with + | mk ι child tag => + obtain ⟨i,rfl⟩ := hσ + change Name.encode (label p) (.mk ι child tag) ∈ M at hτ + have hp : ZFSet.pair (Name.encode (label p) (child i)) (label p (tag i)) ∈ M := + hM (Name.encode (label p) (.mk ι child tag)) hτ _ (ZFSet.mem_range_self i) + have hs : ({Name.encode (label p) (child i)} : ZFSet.{u}) ∈ M := + hM _ hp _ (ZFSet.mem_pair.mpr (Or.inl rfl)) + exact hM _ hs _ (ZFSet.mem_singleton.mpr rfl) + +theorem genericExtension_transitive (M p : ZFSet.{u}) (hM : Transitive M) + (G : Set (Conditions p)) : + ∀ x ∈ genericExtension M p G, ∀ y ∈ x, y ∈ genericExtension M p G := + extension_transitive _ (names_childClosed M p hM) G + +noncomputable def valueOnCode (p : ZFSet.{u}) (G : Set (Conditions p)) + (x : ZFSet.{u}) : ZFSet.{u} := by + classical + exact if h : ∃ τ : Name (Conditions p), Name.encode (label p) τ = x + then Name.val G h.choose else ∅ + +theorem valueOnCode_encode (p : ZFSet.{u}) (G : Set (Conditions p)) + (τ : Name (Conditions p)) : + valueOnCode p G (Name.encode (label p) τ) = Name.val G τ := by + classical + have h : ∃ σ : Name (Conditions p), Name.encode (label p) σ = Name.encode (label p) τ := + ⟨τ,rfl⟩ + rw [valueOnCode,dite_eq_left h] + exact Name.val_eq_of_encode_eq _ (label_injective p) G _ τ h.choose_spec + +theorem genericExtension_countable (M p : ZFSet.{u}) + (hM : (M : Set ZFSet.{u}).Countable) (G : Set (Conditions p)) : + (genericExtension M p G).Countable := by + apply (hM.image (valueOnCode p G)).mono + rintro x ⟨τ,hτ,rfl⟩ + exact ⟨Name.encode (label p) τ,hτ,valueOnCode_encode p G τ⟩ + +noncomputable def genericExtensionSet (M p : ZFSet.{u}) (G : Set (Conditions p)) : + ZFSet.{u} := ZFSet.range + (fun x : {x : M // ∃ τ : Name (Conditions p), Name.encode (label p) τ = x.val} => + valueOnCode p G x.val.val) + +theorem genericExtensionSet_coe (M p : ZFSet.{u}) (G : Set (Conditions p)) : + (genericExtensionSet M p G : Set ZFSet.{u}) = genericExtension M p G := by + ext x + change x ∈ ZFSet.range _ ↔ _ + rw [ZFSet.mem_range] + constructor + · rintro ⟨⟨⟨c,hc⟩,τ,hτ⟩,hx⟩ + refine ⟨τ,?_,?_⟩ + · change Name.encode (label p) τ ∈ M + simpa only [hτ] using hc + · have hv := valueOnCode_encode p G τ + rw [hτ] at hv + exact hv.symm.trans hx + · rintro ⟨τ,hτ,rfl⟩ + exact ⟨⟨⟨Name.encode (label p) τ,hτ⟩,τ,rfl⟩,valueOnCode_encode p G τ⟩ + +theorem genericExtensionSet_transitive (M p : ZFSet.{u}) (hM : Transitive M) + (G : Set (Conditions p)) : Transitive (genericExtensionSet M p G) := by + intro x hx y hy + have hx' : x ∈ genericExtension M p G := by + rw [←genericExtensionSet_coe]; exact hx + have hy' := genericExtension_transitive M p hM G x hx' y hy + rw [←genericExtensionSet_coe] at hy' + exact hy' + +theorem ground_subset (M p : ZFSet.{u}) [Top (Conditions p)] + (hcheck : ∀ x ∈ M, Name.encode (label p) (Name.check x) ∈ M) + (G : Set (Conditions p)) (hG : ⊤ ∈ G) : + (M : Set ZFSet.{u}) ⊆ genericExtension M p G := + ground_subset_extension _ _ hcheck G hG + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/TwoRealHull.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/TwoRealHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..a692f1b866b0f4ff06c8056ccf8a4c3acb2d5f61 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/TwoRealHull.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteOverwriteHull +import OAI.Computability.DegreeRigidity.Representation.OriginalRealCohenFactorization + +namespace OAI + + +namespace TuringRigidity.TwoRealHull +open TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open RealGeneratedModel CohenColumnRealName InternalCountableOrdinals +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem contains_join_iff (M : ZFSet.{0}) (X Y : Oracle) + (hN : Contains M (realCode X) (RealGeneratedModel.hull M (realCode X))) (W : ZFSet.{0}) : + Contains M (realCode (join X Y)) W ↔ + Contains (RealGeneratedModel.hull M (realCode X)) (realCode Y) W := by + constructor + · rintro ⟨hW,hTW,hMW,hXY⟩ + have hX := sourceT_real_lower W hW hTW hXY (reduces_join_left X Y) + have hY := sourceT_real_lower W hW hTW hXY (reduces_join_right X Y) + refine ⟨hW,hTW,?_,hY⟩ + intro z hz + exact ((mem_hull M (realCode X) z ⟨_,hN⟩).mp hz) W ⟨hW,hTW,hMW,hX⟩ + · rintro ⟨hW,hTW,hNW,hY⟩ + exact ⟨hW,hTW,fun z hz => hNW (hN.2.2.1 hz), + sourceT_real_join W hW hTW (hNW hN.2.2.2) hY⟩ + +theorem hull_join (M : ZFSet.{0}) (X Y : Oracle) + (hN : Contains M (realCode X) (RealGeneratedModel.hull M (realCode X))) + (hJ : Contains M (realCode (join X Y)) (RealGeneratedModel.hull M (realCode (join X Y)))) : + RealGeneratedModel.hull (RealGeneratedModel.hull M (realCode X)) (realCode Y) = + RealGeneratedModel.hull M (realCode (join X Y)) := by + apply hull_eq_of_least _ _ _ ((contains_join_iff M X Y hN _).mp hJ) + intro W hW z hz + exact ((mem_hull M (realCode (join X Y)) z ⟨_,hJ⟩).mp hz) W + ((contains_join_iff M X Y hN W).mpr hW) + +theorem joined_factorization (M K : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : FirstUncountable M K) + (G : GenericFilter (Conditions (poset K))) (hG : GroundGeneric M G) + (X Y : Oracle) + (hX : realCode X ∈ genericExtensionSet M (poset K) G.carrier) + (hY : realCode Y ∈ genericExtensionSet M (poset K) G.carrier) : + let N := RealGeneratedModel.hull M (realCode X) + let H := RealGeneratedModel.hull N (realCode Y) + Contains M (realCode X) N ∧ Contains N (realCode Y) H ∧ + ∃ U : GenericFilter (Conditions (poset K)), GroundGeneric H U ∧ + genericExtensionSet H (poset K) U.carrier = genericExtensionSet M (poset K) G.carrier := by + dsimp only + obtain ⟨hE,hTE,_,_⟩ := RegularTreeExtension.extension_properties M (poset K) hM hT + (CohenGroundPoset.conditions_mem M _ hM hT + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + hK.2.1 (sourceT_omega_mem M hM hT))) G hG + obtain ⟨hN,_,_,_⟩ := OriginalRealCohenFactorization.real_factorization M K hM hT hK + G hG (realCode X) hX (realCode_subset X) + obtain ⟨hJ,U,hU,hUE⟩ := OriginalRealCohenFactorization.real_factorization M K hM hT hK + G hG (realCode (join X Y)) (sourceT_real_join _ hE hTE hX hY) (realCode_subset _) + have hNJ := (contains_join_iff M X Y hN _).mp hJ + have he := hull_join M X Y hN hJ + rw [←he] at hNJ hU hUE + exact ⟨hN,hNJ,U,hU,hUE⟩ + +end TuringRigidity.TwoRealHull + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/UnionIteration.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/UnionIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..7a566ec0f7cd2b24e1c842aca706ef80b0db83a2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/UnionIteration.lean @@ -0,0 +1,145 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalInfinity +import OAI.Computability.DegreeRigidity.Syntax.CheckGraphConstruction + +namespace OAI + +namespace TuringRigidity.TransitiveNameModel +open BoundedSetTheory +universe u + +def FunctionGraph (d r f : ZFSet.{u}) : Prop := + (∀ z ∈ f, ∃ x ∈ d, ∃ y ∈ r, z = ZFSet.pair x y) ∧ + (∀ x ∈ d, ∃ y ∈ r, ZFSet.pair x y ∈ f ∧ + ∀ z ∈ r, ZFSet.pair x z ∈ f → z = y) + +theorem FunctionGraph.value_mem {d r f x y : ZFSet.{u}} + (h : FunctionGraph d r f) (hp : ZFSet.pair x y ∈ f) : y ∈ r := by + obtain ⟨a,_,b,hb,he⟩ := h.1 _ hp + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact hb + +theorem FunctionGraph.functional {d r f x y z : ZFSet.{u}} + (h : FunctionGraph d r f) (hx : x ∈ d) + (hy : ZFSet.pair x y ∈ f) (hz : ZFSet.pair x z ∈ f) : y = z := by + obtain ⟨v,_,_,hu⟩ := h.2 x hx + exact (hu y (h.value_mem hy) hy).trans (hu z (h.value_mem hz) hz).symm + +def UnionIteration (k r f a : ZFSet.{u}) : Prop := FunctionGraph k r f ∧ + ZFSet.pair ∅ a ∈ f ∧ + ∀ i ∈ k, ∀ j ∈ k, j = insert i i → ∀ v ∈ r, ∀ w ∈ r, + ZFSet.pair i v ∈ f → ZFSet.pair j w ∈ f → w = ZFSet.sUnion v + +theorem UnionIteration.correct {n : ℕ} {r f a : ZFSet.{u}} + (h : UnionIteration (natSet (n+1)) r f a) (i : ℕ) (hi : i ≤ n) + (v : ZFSet.{u}) (hv : ZFSet.pair (natSet i) v ∈ f) : v = iterUnion i a := by + induction i generalizing v with + | zero => exact h.1.functional ((natSet_mem_natSet 0 (n+1)).mpr (Nat.zero_lt_succ n)) hv h.2.1 + | succ i ih => + have hik := (natSet_mem_natSet i (n+1)).mpr (Nat.lt_succ_of_le (Nat.le_of_succ_le hi)) + have hjk := (natSet_mem_natSet (i+1) (n+1)).mpr (Nat.lt_succ_of_le hi) + obtain ⟨w,hw,hfw,_⟩ := h.1.2 _ hik + have he := h.2.2 _ hik _ hjk rfl w hw v (h.1.value_mem hv) hfw hv + rw [ih (Nat.le_of_succ_le hi) w hfw] at he + exact he + +noncomputable def unionGraph (a : ZFSet.{u}) (n : ℕ) : ZFSet.{u} := + ZFSet.range (fun i : Fin (n+1) => ZFSet.pair (natSet i.val) (iterUnion i.val a)) + +theorem mem_unionGraph (a z : ZFSet.{u}) (n : ℕ) : + z ∈ unionGraph a n ↔ ∃ i ≤ n, z = ZFSet.pair (natSet i) (iterUnion i a) := by + rw [unionGraph,ZFSet.mem_range] + exact ⟨fun ⟨i,hi⟩ => ⟨i.val,Nat.le_of_lt_succ i.isLt,hi.symm⟩, + fun ⟨i,hi,hz⟩ => ⟨⟨i,Nat.lt_succ_of_le hi⟩,hz.symm⟩⟩ + +theorem unionGraph_pair (a x v : ZFSet.{u}) (n : ℕ) : + ZFSet.pair x v ∈ unionGraph a n ↔ ∃ i ≤ n, x = natSet i ∧ v = iterUnion i a := by + rw [mem_unionGraph] + exact exists_congr (fun i => and_congr_right (fun _ => ZFSet.pair_inj)) + +theorem unionGraph_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + (hU : BoundedSetTheory.Union M) (hω : ZFSet.omega.{u} ∈ M) + {a : ZFSet.{u}} (ha : a ∈ M) (n : ℕ) : unionGraph a n ∈ M := by + have hn (n : ℕ) : natSet.{u} n ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩) + induction n with + | zero => + have he : unionGraph a 0 = ({ZFSet.pair (natSet 0) a} : ZFSet.{u}) := by + apply ZFSet.ext; intro z + simp only [mem_unionGraph,Nat.le_zero_eq,ZFSet.mem_singleton] + simp only [exists_eq_left,iterUnion] + rw [he] + exact singleton_mem M hM hP (orderedPair_mem M hM hP (hn 0) ha) + | succ n ih => + have he : unionGraph a (n+1) = unionGraph a n ∪ + ({ZFSet.pair (natSet (n+1)) (iterUnion (n+1) a)} : ZFSet.{u}) := by + apply ZFSet.ext; intro z + rw [mem_unionGraph,ZFSet.mem_union,mem_unionGraph,ZFSet.mem_singleton] + constructor + · rintro ⟨i,hi,hz⟩ + rcases Nat.lt_or_eq_of_le hi with hi|rfl + · exact Or.inl ⟨i,Nat.le_of_lt_succ hi,hz⟩ + · exact Or.inr hz + · rintro (⟨i,hi,hz⟩|hz) + · exact ⟨i,Nat.le.step hi,hz⟩ + · exact ⟨n+1,le_refl _,hz⟩ + rw [he] + exact binary_union_mem M hM hP hU ih + (singleton_mem M hM hP (orderedPair_mem M hM hP (hn (n+1)) + (iterUnion_mem M hM hU ha (n+1)))) + +theorem unionGraph_valid (a : ZFSet.{u}) (n : ℕ) : + UnionIteration (natSet (n+1)) (iterUnion 2 (unionGraph a n)) (unionGraph a n) a := by + have hpair (i : ℕ) (hi : i ≤ n) : + ZFSet.pair (natSet i) (iterUnion i a) ∈ unionGraph a n := + (unionGraph_pair a _ _ n).mpr ⟨i,hi,rfl,rfl⟩ + refine ⟨⟨?_,?_⟩,hpair 0 (Nat.zero_le n),?_⟩ + · intro z hz + obtain ⟨i,hi,rfl⟩ := (mem_unionGraph a z n).mp hz + exact ⟨_,(natSet_mem_natSet i (n+1)).mpr (Nat.lt_succ_of_le hi),_,second_mem_doubleUnion hz,rfl⟩ + · intro x hx + obtain ⟨i,hi,rfl⟩ := (mem_natSet (n+1) x).mp hx + have hp := hpair i (Nat.le_of_lt_succ hi) + refine ⟨_,second_mem_doubleUnion hp,hp,?_⟩ + intro v _ hv + obtain ⟨j,_,he,hv⟩ := (unionGraph_pair a _ v n).mp hv + obtain rfl := natSet_injective he + exact hv + · intro x _ y _ hxy v _ w _ hxv hyw + obtain ⟨i,_,rfl,rfl⟩ := (unionGraph_pair a x v n).mp hxv + obtain ⟨j,_,rfl,rfl⟩ := (unionGraph_pair a y w n).mp hyw + have he : j = i+1 := natSet_injective hxy + rw [he]; rfl + +namespace IterationFormula +open Formula + +def unionOf (b a : ℕ) : Formula := .conj + (allMem b (.existsMem (a+1) (.member 1 0))) + (allMem a (allMem 0 (.member 0 (b+2)))) + +@[simp] theorem eval_unionOf (b a : ℕ) (e : ℕ → ZFSet.{u}) : + (unionOf b a).Eval e ↔ e b = ZFSet.sUnion (e a) := by + simp only [unionOf,Formula.Eval,eval_allMem,cons_zero,cons_succ] + constructor + · rintro ⟨hf,hb⟩ + apply ZFSet.ext; intro z; rw [ZFSet.mem_sUnion] + exact ⟨hf z,fun ⟨y,hy,hz⟩ => hb y hy z hz⟩ + · intro h; rw [h] + exact ⟨fun z hz => ZFSet.mem_sUnion.mp hz, + fun y hy z hz => ZFSet.mem_sUnion.mpr ⟨y,hy,hz⟩⟩ + +def iteration (k r f a e : ℕ) : Formula := .conj (functionGraph f k r) + (.conj (pairMem e a f) + (allMem k (allMem (k+1) (imp (successor 0 1) + (allMem (r+2) (allMem (r+3) + (imp (.conj (pairMem 3 1 (f+4)) (pairMem 2 0 (f+4))) (unionOf 0 1)))))))) + +theorem eval_iteration (k r f a e : ℕ) (env : ℕ → ZFSet.{u}) (he : env e = ∅) : + (iteration k r f a e).Eval env ↔ UnionIteration (env k) (env r) (env f) (env a) := by + simp only [iteration,Formula.Eval,eval_functionGraph,eval_pairMem, + eval_allMem,eval_imp,eval_successor,eval_unionOf,cons_zero,cons_succ, + UnionIteration,FunctionGraph,he,and_imp] +end IterationFormula + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/ValidFirstUncountable.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/ValidFirstUncountable.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d1c9a9ed6c72c12111b21b569084dfeff1b3f0c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/ValidFirstUncountable.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalUncountableSentence +import OAI.Computability.DegreeRigidity.SetModels.InternalGraphEquiv +import OAI.Computability.DegreeRigidity.SetModels.ElementarySchemas + +namespace OAI + +namespace TuringRigidity.ValidFirstUncountable +open TransitiveNameModel BoundedSetTheory ElementaryModel InternalCountableOrdinals +open InternalUncountableSentence InternalGraphEquiv + +theorem card_le_of_graph (A B f : ZFSet.{0}) (hf : FunctionGraph A B f) + (hs : ∀ y ∈ B, ∃ x ∈ A, ZFSet.pair x y ∈ f) : B.card ≤ A.card := by + have hsurj : Function.Surjective (graphMap A B f hf) := by + intro y + obtain ⟨x,hx,hxy⟩ := hs (label B y) (label_mem B y) + obtain ⟨x,rfl⟩ := label_surjective A hx + exact ⟨x,label_injective B (hf.functional (label_mem A x) (graphMap_spec A B f hf x) hxy)⟩ + exact Cardinal.mk_le_of_surjective hsurj + +theorem ambient_larger_ordinal (W : ZFSet.{0}) : + ∃ K : ZFSet.{0}, K.IsOrdinal ∧ K ≠ ∅ ∧ + ¬ (∃ f, FunctionGraph W K f ∧ ∀ y ∈ K, ∃ x ∈ W, ZFSet.pair x y ∈ f) := by + let K : ZFSet.{0} := (Order.succ W.card).ord.toZFSet + have hcard : K.card = Order.succ W.card := by + dsimp only [K] + rw [Ordinal.card_toZFSet,Cardinal.card_ord] + refine ⟨K,ZFSet.isOrdinal_toZFSet _,?_,?_⟩ + · intro he + have hh := congrArg ZFSet.card he + rw [hcard,ZFSet.card_empty] at hh + exact Cardinal.succ_ne_zero W.card hh + · rintro ⟨f,hf,hs⟩ + have hle := card_le_of_graph W K f hf hs + rw [hcard] at hle + exact (Order.lt_succ W.card).not_ge hle + +theorem ambient_sentence (e : ℕ → ZFSet.{0}) : + (SentenceForm.ex uncountableOrdinalSentence).Sat Set.univ e := by + obtain ⟨K,hK,hne,hunc⟩ := ambient_larger_ordinal (e 0) + refine ⟨K,Set.mem_univ _,?_⟩ + change (fromBounded _).Sat _ _ ∧ (¬ (fromBounded _).Sat _ _) ∧ ¬ (countableSentence 0 1).Sat _ _ + rw [bounded_univ,bounded_univ] + constructor + · simp only [Formula.Eval,Formula.eval_transitive,Formula.eval_allMem,cons_zero] + exact ZFSet.isOrdinal_iff_forall_mem_isTransitive.mp hK + constructor + · simpa only [Formula.eval_empty,cons_zero] using hne + · rintro ⟨f,_,hf⟩ + exact hunc ⟨f,(ontoMatrix_spec 0 2 1 _).mp ((bounded_univ _ _).mp hf)⟩ + +theorem firstUncountable_exists (M : ZFSet.{0}) (hM : Transitive M) (hV : Valid M) + (hne : ∃ a, a ∈ M) : ∃ K, FirstUncountable M K := by + have hT := hV.sourceT hM hne + have hω := sourceT_omega_mem M hM hT + have h := hV (.ex uncountableOrdinalSentence) ambient_sentence (fun _ => ZFSet.omega) (fun _ => hω) + obtain ⟨L,hL,hs⟩ := h + have he : ∀ i, cons L (fun _ => ZFSet.omega) i ∈ M := by + intro i; cases i; exact hL; exact hω + obtain ⟨hord,hunc⟩ := (uncountableOrdinalSentence_spec M hM _ he rfl).mp hs + obtain ⟨K,hK,_⟩ := firstUncountable_below M L hM hL hord hunc + exact ⟨K,hK⟩ + +theorem firstUncountable_unique_exists (M : ZFSet.{0}) (hM : Transitive M) (hV : Valid M) + (hne : ∃ a, a ∈ M) : ∃! K, FirstUncountable M K := by + obtain ⟨K,hK⟩ := firstUncountable_exists M hM hV hne + exact ⟨K,hK,fun L hL => InternalCountableOrdinals.unique M L K hL hK⟩ + +end TuringRigidity.ValidFirstUncountable + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/WeakNameAvoidance.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/WeakNameAvoidance.lean new file mode 100644 index 0000000000000000000000000000000000000000..f522cdd7903b7ec6f827175b19934f2ca6052d70 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/WeakNameAvoidance.lean @@ -0,0 +1,60 @@ +import OAI.Computability.DegreeRigidity.SetModels.CountableNameAvoidance +import OAI.Computability.DegreeRigidity.SetModels.WeakNameDifference +import OAI.Computability.DegreeRigidity.Representation.GroundGenericRequirements + +namespace OAI + + +namespace TuringRigidity.FullSetForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] [OrderTop (Conditions c)] + +theorem exists_generic_omitting_subset_without_choice (M N : ZFSet.{u}) [Countable (Conditions N)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hMN : M ⊆ N) + (hc : c ∈ M) {o a S : ZFSet.{u}} (hoM : o ∈ M) (ha : a ∈ M) + (hSa : S ⊆ a) (hSM : S ∉ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (p : Conditions c) : + ∃ G : GenericFilter (Conditions c), p ∈ G.carrier ∧ GroundGeneric N G ∧ + S ∉ genericExtensionSet M c G.carrier := by + have ht₀ := encoded_check_mem M c hM hP hU hPow + hS.bounded hR hI hc hc + obtain ⟨ts,hts,hcover⟩ := ground_name_sequence M N hMN (Name.check c) ht₀ + let E : ℕ → Set (Conditions c) := fun n => NameDifference a S (ts n) + have hE : ∀ n, Dense (E n) := fun n => + nameDifference_dense_without_choice M hM hP hU hPow hS hR hI hc hoM ha hSa hSM ho (ts n) (hts n) + obtain ⟨G,hp,hG,hGE⟩ := ground_generic_with_requirements N ⟨c,hMN hc⟩ E hE p + refine ⟨G,hp,hG,?_⟩ + intro hSG + obtain ⟨t,ht,hval⟩ := (mem_extensionSet M c G.carrier S).mp hSG + obtain ⟨n,hn⟩ := hcover t ht + obtain ⟨q,hq,hqn⟩ := hGE n + have hGM : GroundGeneric M G := fun D hD hd => hG D (hMN hD) hd + have hne := nameDifference_ne_value_without_choice M hM hP hU hPow hS hR hI hc hoM ha ho (ts n) (hts n) G hGM hq hqn + apply hne + exact (Name.val_eq_of_encode_eq (label c) (label_injective c) G.carrier (ts n) t hn).trans hval + +theorem subset_mem_iff_all_generic_extensions_without_choice (M N : ZFSet.{u}) [Countable (Conditions N)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hMN : M ⊆ N) + (hc : c ∈ M) {o a S : ZFSet.{u}} (hoM : o ∈ M) (ha : a ∈ M) (hSa : S ⊆ a) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (p : Conditions c) : + S ∈ M ↔ ∀ G : GenericFilter (Conditions c), GroundGeneric N G → p ∈ G.carrier → + S ∈ genericExtensionSet M c G.carrier := by + classical + constructor + · intro hSM G _ hp + exact ground_inclusion_set M c hM hP hU hPow + hS.bounded hR hI hc + G.carrier (G.upper le_top hp) hSM + · intro h + by_contra hSM + obtain ⟨G,hp,hG,hSG⟩ := exists_generic_omitting_subset_without_choice M N hM hP hU hPow hS hR hI hMN hc hoM ha hSa hSM ho p + exact hSG (h G hG hp) + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/WeakNameDifference.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/WeakNameDifference.lean new file mode 100644 index 0000000000000000000000000000000000000000..b76fa4772aea275ea37686b6851d8b3cfd2e5242 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/WeakNameDifference.lean @@ -0,0 +1,68 @@ +import OAI.Computability.DegreeRigidity.SetModels.NameDifferenceDense +import OAI.Computability.DegreeRigidity.Syntax.WeakCheckedMembership + +namespace OAI + + +namespace TuringRigidity.FullSetForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] [OrderTop (Conditions c)] + +theorem nameDifference_dense_without_choice (M : ZFSet.{u}) + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) + (hc : c ∈ M) {o a S : ZFSet.{u}} (hoM : o ∈ M) (ha : a ∈ M) + (hSa : S ⊆ a) (hSM : S ∉ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (t : Name (Conditions c)) (ht : t.encode (label c) ∈ M) : + Dense (NameDifference a S t) := by + classical + intro p + by_contra h + have avoid : ∀ q, q ≤ p → ¬ (q ∈ NameDifference a S t) := by + simpa only [not_exists,not_and] using h + obtain ⟨b,hb,hdef⟩ := internal_forced_members_without_choice M hM hP hU hPow hS hR hI hc hoM ha ho t ht p + have hbS : b = S := by + apply ZFSet.ext + intro x + rw [hdef x] + constructor + · rintro ⟨hxa,hf⟩ + by_contra hx + exact avoid p le_rfl ⟨x,hxa,Or.inr ⟨hx,hf⟩⟩ + · intro hx + refine ⟨hSa hx,mem_of_dense _ _ p ?_⟩ + intro q hqp + by_contra hn + have hneg : ∀ r, r ≤ q → ¬ MemForces (Name.check x) t r := by + simpa only [not_exists,not_and] using hn + exact avoid q hqp ⟨x,hSa hx,Or.inl ⟨hx,hneg⟩⟩ + exact hSM (hbS ▸ hb) + +theorem nameDifference_ne_value_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) + (hc : c ∈ M) {o a S : ZFSet.{u}} (hoM : o ∈ M) (ha : a ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (t : Name (Conditions c)) (ht : t.encode (label c) ∈ M) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) + {p : Conditions c} (hp : p ∈ G.carrier) (hd : p ∈ NameDifference a S t) : + t.val G.carrier ≠ S := by + obtain ⟨x,hxa,hd⟩ := hd + have hxM := hM a ha x hxa + have hcheck := encoded_check_mem M c hM hP hU hPow hS.bounded hR hI hc hxM + have htop : ⊤ ∈ G.carrier := G.upper le_top hp + have truth := (internal_atomic_truth M hM hP hU hPow hS.bounded hR hI + hc hoM ho G hG (Name.check x) t hcheck ht).2 + rw [Name.val_check G.carrier htop] at truth + intro hval + rw [hval] at truth + rcases hd with ⟨hx,hneg⟩|⟨hx,hpos⟩ + · obtain ⟨q,hq,hf⟩ := truth.mp hx + obtain ⟨r,_,hrp,hrq⟩ := G.directed hp hq + exact hneg r hrp (mem_mono _ _ hrq hf) + · exact hx (truth.mpr ⟨p,hp,hpos⟩) + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/SetModels/WeakRealDescent.lean b/lean/OAI/Computability/DegreeRigidity/SetModels/WeakRealDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..e45aa084d9236ab2bd88bcf3756a86ff64d91074 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/SetModels/WeakRealDescent.lean @@ -0,0 +1,44 @@ +import OAI.Computability.DegreeRigidity.Representation.RealCollapseReconstruction +import OAI.Computability.DegreeRigidity.SetModels.WeakNameAvoidance + +namespace OAI + +namespace TuringRigidity.FullSetForcing +open TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +open SetDegreeDecoding PersistentRestrictions +universe u +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem persistent_graph_mem_of_real_family (M N : ZFSet.{u}) [Countable (Conditions N)] + (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) + (hPow : PowerSet M) (hS : SigmaSeparation M) (hR : SigmaReplacement M) + (hI : Infinity M) (hMN : M ⊆ N) + {R : ZFSet.{u}} (hRM : R ∈ M) + (hreal : ∀ x ∈ R, ∃ B : Oracle, SetModelReals.realSet B = x) + (I : CountableIdeal) (hIM : idealSet I ∈ M) + (hIR : ∀ d, d ∈ I.carrier ↔ ∃ B : Oracle, SetModelReals.realSet B ∈ R ∧ degree B = d) + (ρ : I ≃o I) (hρ : Persistent I ρ) + (hz : degree (OracleJump.jump FixedArithmetic.zero) ∈ I.carrier) : + automorphismSet ρ ∈ M := by + have hω := omega_mem M hM hS.bounded hI + obtain ⟨c,hc,hcdef⟩ := InternalCollapse.conditions_exist_without_choice M hM hP hU hPow hS.bounded hω hRM + have h0 : (∅ : ZFSet.{u}) ∈ c := + (hcdef ∅).mpr ⟨hM _ hω _ ZFSet.omega_zero,InternalCollapse.prefix_empty R⟩ + let _ := InternalCollapse.top c h0 + have hoM := InternalCollapse.orderSet_mem_without_choice M hM hP hU hPow hS.bounded hc + have hprod := product_mem M hM hP hU hPow hS.bounded hIM hIM + have hbound : automorphismSet.{u} ρ ⊆ ZFSet.prod (idealSet I) (idealSet I) := + fun _ h => (ZFSet.mem_sep.mp h).1 + have hne : ∃ x, x ∈ R := by + obtain ⟨d,hd⟩ := I.nonempty + obtain ⟨B,hB,_⟩ := (hIR d).mp hd + exact ⟨_,hB⟩ + apply (subset_mem_iff_all_generic_extensions_without_choice M N hM hP hU hPow hS hR hI hMN + hc hoM hprod hbound (InternalCollapse.orderSet_pair c) (⊤ : Conditions c)).mpr + intro G hG _ + exact InternalCollapse.real_collapse_reconstructs M hM hP hU hPow hS hR hI hRM hc hcdef + hne hreal I hIR ρ hρ hz G (fun D hD hd => hG D (hMN hD) hd) + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicCertificate.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..8efecdd0000c77743b6db4f78cf45cee6b82a2b9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicCertificate.lean @@ -0,0 +1,110 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalAtomicTruth + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory +universe u + +namespace AtomicFormula +open Formula + +def product (d k : ℕ) : Formula := + .conj (allMem k (.existsMem (d+1) (.existsMem (d+2) (orderedPair 2 1 0)))) + (allMem d (allMem (d+1) (.existsMem (k+2) (orderedPair 0 2 1)))) + +theorem eval_product (d k : ℕ) (e : ℕ → ZFSet.{u}) : + (product d k).Eval e ↔ e k = ZFSet.prod (e d) (e d) := by + simp only [product,Formula.Eval,eval_allMem,eval_orderedPair,cons_zero,cons_succ] + constructor + · rintro ⟨h₁,h₂⟩ + apply ZFSet.ext + intro z + constructor + · intro hz + obtain ⟨x,hx,y,hy,hz⟩ := h₁ z hz + exact ZFSet.mem_prod.mpr ⟨x,hx,y,hy,hz⟩ + · intro hz + obtain ⟨x,hx,y,hy,rfl⟩ := ZFSet.mem_prod.mp hz + obtain ⟨v,hv,rfl⟩ := h₂ x hx y hy + exact hv + · intro hk + constructor + · intro z hz + rw [hk] at hz + exact ZFSet.mem_prod.mp hz + · intro x hx y hy + exact ⟨_,hk ▸ ZFSet.mem_prod.mpr ⟨x,hx,y,hy,rfl⟩,rfl⟩ + +def graph (d c k o f : ℕ) : Formula := + .conj (allMem f (.existsMem (k+1) (.existsMem (c+2) (orderedPair 2 1 0)))) + (allMem d (allMem (d+1) (allMem (c+2) + (iff (triple (k+3) (f+3) 2 1 0) (step (d+3) (c+3) (k+3) (o+3) (f+3) 2 1 0))))) + +theorem eval_graph (d c k o f : ℕ) (e : ℕ → ZFSet.{u}) + (hk : e k = ZFSet.prod (e d) (e d)) : + (graph d c k o f).Eval e ↔ Graph (e d) (e c) (e o) (e f) := by + simp only [graph,Formula.Eval,eval_allMem,eval_orderedPair,eval_iff,eval_triple,eval_step, + cons_zero,cons_succ,hk,Graph] + constructor + · rintro ⟨h₁,h₂⟩ + refine ⟨fun z hz => ZFSet.mem_prod.mpr (h₁ z hz),?_⟩ + intro x hx y hy q hq + exact (triple_pair hx hy).symm.trans (h₂ x hx y hy q hq) + · rintro ⟨h₁,h₂⟩ + refine ⟨fun z hz => ZFSet.mem_prod.mp (h₁ hz),?_⟩ + intro x hx y hy q hq + exact (triple_pair hx hy).trans (h₂ x hx y hy q hq) + +def membership (d c k o f x y p : ℕ) : Formula := + allMem c (imp (pairMem 0 (p+1) (o+1)) + (matchF false (d+1) (c+1) (k+1) (o+1) (f+1) (x+1) (y+1) 0)) + +def query (isMem : Bool) (d c k o f x y p : ℕ) : Formula := + if isMem then membership d c k o f x y p else triple k f x y p + +def matrix (isMem : Bool) : Formula := + .conj (transitive 2) (.conj (.member 4 2) (.conj (.member 5 2) + (.conj (product 2 1) (.conj (graph 2 6 1 7 0) (query isMem 2 6 1 7 0 4 5 3))))) + +def certificate (isMem : Bool) : SigmaFormula := + .existsSet (.existsSet (.existsSet (.bounded (matrix isMem)))) +end AtomicFormula + +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem eval_membership {d o f : ZFSet.{u}} (hd : Transitive d) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (hf : Graph d c o f) (a b : Name (Conditions c)) + (ha : a.encode (label c) ∈ d) (hb : b.encode (label c) ∈ d) (p : Conditions c) + (e : ℕ → ZFSet.{u}) (di ci ki oi fi xi yi pi : ℕ) + (he : e di = d ∧ e ci = c ∧ e ki = ZFSet.prod d d ∧ e oi = o ∧ e fi = f ∧ + e xi = a.encode (label c) ∧ e yi = b.encode (label c) ∧ e pi = label c p) : + (AtomicFormula.membership di ci ki oi fi xi yi pi).Eval e ↔ MemForces a b p := by + rcases he with ⟨hd',hc',hk',ho',hf',hx',hy',hp'⟩ + simp only [AtomicFormula.membership,Formula.eval_allMem,Formula.eval_imp, + Formula.eval_pairMem,AtomicFormula.eval_matchF,cons_zero,cons_succ, + hd',hc',hk',ho',hf',hx',hy',hp'] + have step (q : Conditions c) : + Match false d c (ZFSet.prod d d) o f (a.encode (label c)) (b.encode (label c)) (label c q) ↔ + ∃ r, r ≤ q ∧ Witness a b r := by + rw [match_encode false hd ho b hb q] + simp only [Bool.false_eq_true,ite_false] + cases b with + | mk κ b t => + have hchild (j) : (b j).encode (label c) ∈ d := names_childClosed d c hd (.mk κ b t) hb (b j) ⟨j,rfl⟩ + have hrel (j) (r : Conditions c) := (triple_pair ha (hchild j)).trans + (hf.correct hd ho a (b j) ha (hchild j) r) + simp only [Name.arity,Name.child,Name.tag,hrel,Witness] + cases b with + | mk κ b t => + constructor + · intro h q hq + exact (step q).mp (h _ (label_mem c q) ((ho q p).mpr hq)) + · intro h q hq hqp + obtain ⟨r,rfl⟩ := label_surjective c hq + exact (step r).mpr (h r ((ho r p).mp hqp)) + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicDecisionFormula.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicDecisionFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..56b62656b4417d547f94a051ffd686725805df28 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicDecisionFormula.lean @@ -0,0 +1,134 @@ +import OAI.Computability.DegreeRigidity.Syntax.AtomicGraphCorrect +import OAI.Computability.DegreeRigidity.Syntax.AtomicRequirements + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory +universe u + +def CodeWitness (d c k o f x y p : ZFSet.{u}) : Prop := + ∃ b ∈ d, ∃ t ∈ c, ZFSet.pair b t ∈ y ∧ ZFSet.pair p t ∈ o ∧ Triple k f x b p + +def CodeNeg (d c k o f x y p : ZFSet.{u}) : Prop := + ∀ q ∈ c, ZFSet.pair q p ∈ o → ¬ CodeWitness d c k o f x y q + +def CodeRefute (d c k o f x y p : ZFSet.{u}) : Prop := + ∃ a ∈ d, ∃ s ∈ c, ZFSet.pair a s ∈ x ∧ ZFSet.pair p s ∈ o ∧ CodeNeg d c k o f a y p + +namespace AtomicFormula +open Formula + +def witness (d c k o f x y p : ℕ) : Formula := + .existsMem d (.existsMem (c+1) + (.conj (pairMem 1 0 (y+2)) (.conj (pairMem (p+2) 0 (o+2)) + (triple (k+2) (f+2) (x+2) 1 (p+2))))) + +theorem eval_witness (d c k o f x y p : ℕ) (e : ℕ → ZFSet.{u}) : + (witness d c k o f x y p).Eval e ↔ + CodeWitness (e d) (e c) (e k) (e o) (e f) (e x) (e y) (e p) := by + simp only [witness,Formula.Eval,eval_pairMem,eval_triple,cons_zero,cons_succ,CodeWitness] + +def negMem (d c k o f x y p : ℕ) : Formula := + allMem c (imp (pairMem 0 (p+1) (o+1)) + (.neg (witness (d+1) (c+1) (k+1) (o+1) (f+1) (x+1) (y+1) 0))) + +theorem eval_negMem (d c k o f x y p : ℕ) (e : ℕ → ZFSet.{u}) : + (negMem d c k o f x y p).Eval e ↔ + CodeNeg (e d) (e c) (e k) (e o) (e f) (e x) (e y) (e p) := by + simp only [negMem,eval_allMem,eval_imp,Formula.Eval,eval_pairMem,eval_witness, + cons_zero,cons_succ,CodeNeg] + +def refute (d c k o f x y p : ℕ) : Formula := + .existsMem d (.existsMem (c+1) + (.conj (pairMem 1 0 (x+2)) (.conj (pairMem (p+2) 0 (o+2)) + (negMem (d+2) (c+2) (k+2) (o+2) (f+2) 1 (y+2) (p+2))))) + +theorem eval_refute (d c k o f x y p : ℕ) (e : ℕ → ZFSet.{u}) : + (refute d c k o f x y p).Eval e ↔ + CodeRefute (e d) (e c) (e k) (e o) (e f) (e x) (e y) (e p) := by + simp only [refute,Formula.Eval,eval_pairMem,eval_negMem,cons_zero,cons_succ,CodeRefute] + +def memTest (d c k o f x y p : ℕ) : Formula := + disj (witness d c k o f x y p) (negMem d c k o f x y p) + +def eqTest (d c k o f x y p : ℕ) : Formula := + disj (triple k f x y p) (disj (refute d c k o f x y p) (refute d c k o f y x p)) +end AtomicFormula + +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +omit [Preorder (Conditions c)] in +private theorem child_mem {d : ZFSet.{u}} (hd : Transitive d) + (a : Name (Conditions c)) (ha : a.encode (label c) ∈ d) (i : a.arity) : + (a.child i).encode (label c) ∈ d := by + apply names_childClosed d c hd a ha + cases a + exact ⟨i,rfl⟩ + +theorem codeWitness_iff {d o f : ZFSet.{u}} (hd : Transitive d) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (hf : Graph d c o f) (a b : Name (Conditions c)) + (ha : a.encode (label c) ∈ d) (hb : b.encode (label c) ∈ d) (p : Conditions c) : + CodeWitness d c (ZFSet.prod d d) o f (a.encode (label c)) (b.encode (label c)) (label c p) ↔ + Witness a b p := by + have hrel (j) := (triple_pair ha (child_mem hd b hb j)).trans + (hf.correct hd ho a (b.child j) ha (child_mem hd b hb j) p) + cases b with + | mk κ b t => + constructor + · rintro ⟨x,hx,s,hs,hxs,hps,he⟩ + obtain ⟨j,hj,hjs⟩ := (pair_mem_encode _ _ _ _).mp hxs + subst x + subst s + exact ⟨j,(ho p (t j)).mp hps,(hrel j).mp he⟩ + · rintro ⟨j,hj,he⟩ + exact ⟨_,child_mem hd _ hb j,_,label_mem c (t j), + (pair_mem_encode _ _ _ _).mpr ⟨j,rfl,rfl⟩,(ho p (t j)).mpr hj,(hrel j).mpr he⟩ + +theorem negMem_iff_no_witness (a b : Name (Conditions c)) (p : Conditions c) : + NegMem a b p ↔ ∀ q, q ≤ p → ¬ Witness a b q := by + constructor + · intro h q hq hw + exact h q hq (witness_mem a b q hw) + · intro h q hq hm + cases b with + | mk κ b t => + obtain ⟨r,hr,hw⟩ := hm q le_rfl + exact h r (hr.trans hq) hw + +theorem codeNeg_iff {d o f : ZFSet.{u}} (hd : Transitive d) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (hf : Graph d c o f) (a b : Name (Conditions c)) + (ha : a.encode (label c) ∈ d) (hb : b.encode (label c) ∈ d) (p : Conditions c) : + CodeNeg d c (ZFSet.prod d d) o f (a.encode (label c)) (b.encode (label c)) (label c p) ↔ + NegMem a b p := by + rw [negMem_iff_no_witness] + constructor + · intro h q hq hw + exact h _ (label_mem c q) ((ho q p).mpr hq) ((codeWitness_iff hd ho hf a b ha hb q).mpr hw) + · intro h q hq hqp hw + obtain ⟨r,rfl⟩ := label_surjective c hq + exact h r ((ho r p).mp hqp) ((codeWitness_iff hd ho hf a b ha hb r).mp hw) + +theorem codeRefute_iff {d o f : ZFSet.{u}} (hd : Transitive d) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (hf : Graph d c o f) (a b : Name (Conditions c)) + (ha : a.encode (label c) ∈ d) (hb : b.encode (label c) ∈ d) (p : Conditions c) : + CodeRefute d c (ZFSet.prod d d) o f (a.encode (label c)) (b.encode (label c)) (label c p) ↔ + ∃ i, p ≤ a.tag i ∧ NegMem (a.child i) b p := by + constructor + · rintro ⟨x,hx,s,hs,hxs,hps,hn⟩ + obtain ⟨i,hi,his⟩ := (pair_mem_encode _ _ _ _).mp hxs + subst x + subst s + exact ⟨i,(ho p (a.tag i)).mp hps, + (codeNeg_iff hd ho hf _ b (child_mem hd a ha i) hb p).mp hn⟩ + · rintro ⟨i,hi,hn⟩ + exact ⟨_,child_mem hd a ha i,_,label_mem c (a.tag i), + (pair_mem_encode _ _ _ _).mpr ⟨i,rfl,rfl⟩,(ho p (a.tag i)).mpr hi, + (codeNeg_iff hd ho hf _ b (child_mem hd a ha i) hb p).mpr hn⟩ + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicDefinability.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicDefinability.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b0b264b8cc9a42f226433a8ba7530d2a4506378 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicDefinability.lean @@ -0,0 +1,91 @@ +import OAI.Computability.DegreeRigidity.Syntax.AtomicCertificate + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +def Atomic (isMem : Bool) (a b : Name (Conditions c)) (p : Conditions c) : Prop := + if isMem then MemForces a b p else EqForces a b p + +private theorem eval_matrix (isMem : Bool) (d k o f : ZFSet.{u}) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (a b : Name (Conditions c)) (p : Conditions c) (tail : ℕ → ZFSet.{u}) : + (AtomicFormula.matrix isMem).Eval (cons f (cons k (cons d (cons (label c p) + (cons (a.encode (label c)) (cons (b.encode (label c)) (cons c (cons o tail)))))))) ↔ + Transitive d ∧ a.encode (label c) ∈ d ∧ b.encode (label c) ∈ d ∧ + k = ZFSet.prod d d ∧ Graph d c o f ∧ Atomic isMem a b p := by + let e := cons f (cons k (cons d (cons (label c p) + (cons (a.encode (label c)) (cons (b.encode (label c)) (cons c (cons o tail))))))) + have query (hd : Transitive d) (ha : a.encode (label c) ∈ d) + (hb : b.encode (label c) ∈ d) (hk : k = ZFSet.prod d d) (hf : Graph d c o f) : + (AtomicFormula.query isMem 2 6 1 7 0 4 5 3).Eval e ↔ Atomic isMem a b p := by + cases isMem + · simp only [AtomicFormula.query,Atomic,Bool.false_eq_true,ite_false,AtomicFormula.eval_triple] + change Triple k f (a.encode (label c)) (b.encode (label c)) (label c p) ↔ _ + rw [hk] + exact (triple_pair ha hb).trans (hf.correct hd ho a b ha hb p) + · exact eval_membership hd ho hf a b ha hb p e 2 6 1 7 0 4 5 3 + ⟨rfl,rfl,hk,rfl,rfl,rfl,rfl,rfl⟩ + change (AtomicFormula.matrix isMem).Eval e ↔ _ + simp only [AtomicFormula.matrix,Formula.Eval,Formula.eval_transitive, + AtomicFormula.eval_product,cons_zero,cons_succ,e] + constructor + · rintro ⟨hd,ha,hb,hk,hgraph,hquery⟩ + have hf := (AtomicFormula.eval_graph 2 6 1 7 0 e hk).mp hgraph + exact ⟨hd,ha,hb,hk,hf,(query hd ha hb hk hf).mp hquery⟩ + · rintro ⟨hd,ha,hb,hk,hf,hq⟩ + exact ⟨hd,ha,hb,hk,(AtomicFormula.eval_graph 2 6 1 7 0 e hk).mpr hf, + (query hd ha hb hk hf).mpr hq⟩ + +theorem realize_atomicCertificate (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (isMem : Bool) (a b : Name (Conditions c)) + (ha : a.encode (label c) ∈ M) (hb : b.encode (label c) ∈ M) (p : Conditions c) : + (AtomicFormula.certificate isMem).Realize M (cons (label c p) + (cons (a.encode (label c)) (cons (b.encode (label c)) (cons c (cons o (fun _ => c)))))) ↔ + Atomic isMem a b p := by + have hp : label c p ∈ M := hM c hc _ (label_mem c p) + let e := cons (label c p) (cons (a.encode (label c)) + (cons (b.encode (label c)) (cons c (cons o (fun _ => c))))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hp + rcases i with _|i; exact ha + rcases i with _|i; exact hb + rcases i with _|i; exact hc + rcases i with _|i; exact hoM + exact hc + have matrix (d k f : ZFSet.{u}) (hd : d ∈ M) (hk : k ∈ M) (hf : f ∈ M) : + (AtomicFormula.matrix isMem).Realize M (cons f (cons k (cons d e))) ↔ + Transitive d ∧ a.encode (label c) ∈ d ∧ b.encode (label c) ∈ d ∧ + k = ZFSet.prod d d ∧ Graph d c o f ∧ Atomic isMem a b p := by + have he' : ∀ i, cons f (cons k (cons d e)) i ∈ M := by + intro i + rcases i with _|i; exact hf + rcases i with _|i; exact hk + rcases i with _|i; exact hd + exact he i + exact (Formula.absolute _ M hM _ he').trans (eval_matrix isMem d k o f ho a b p _) + change (∃ d ∈ M, ∃ k ∈ M, ∃ f ∈ M, + (AtomicFormula.matrix isMem).Realize M (cons f (cons k (cons d e)))) ↔ _ + constructor + · rintro ⟨d,hd,k,hk,f,hf,hm⟩ + exact ((matrix d k f hd hk hf).mp hm).2.2.2.2.2 + · intro h + obtain ⟨d,hd,hdT,hdab⟩ := internal_transitive_container M hM hP hU hS hR hI + (pair_mem M hM hP ha hb) + have had : a.encode (label c) ∈ d := hdT _ hdab _ (ZFSet.mem_pair.mpr (Or.inl rfl)) + have hbd : b.encode (label c) ∈ d := hdT _ hdab _ (ZFSet.mem_pair.mpr (Or.inr rfl)) + have hk := product_mem M hM hP hU hPow hS hd hd + obtain ⟨f,hf,hfG⟩ := internal_atomic_graph M hM hP hU hPow hS hd hc hoM + exact ⟨d,hd,_,hk,f,hf,(matrix d _ f hd hk hf).mpr ⟨hdT,had,hbd,rfl,hfG,h⟩⟩ + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicEncoding.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..ebbab9d39d7c5034ac7f3c0dcbcb3c7022415806 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicEncoding.lean @@ -0,0 +1,84 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.AtomicForcing + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open Set RecursiveNames +universe u +variable {P : Type u} [Preorder P] + +theorem eq_of_encode_eq (l : P → ZFSet.{u}) (hl : Function.Injective l) + (a b : Name P) (h : a.encode l = b.encode l) (p : P) : EqForces a b p := by + induction a generalizing b p with + | mk ι a s ih => + cases b with + | mk κ b t => + constructor + · intro i q _ hs + have hx : ZFSet.pair ((a i).encode l) (l (s i)) ∈ + Name.encode l (.mk ι a s) := ZFSet.mem_range_self i + rw [h] at hx + obtain ⟨j,hj⟩ := ZFSet.mem_range.mp hx + obtain ⟨hc,ht⟩ := ZFSet.pair_inj.mp hj + exact ⟨q,le_rfl,j,by simpa only [hl ht] using hs,ih i (b j) hc.symm q⟩ + · intro j q _ ht + have hx : ZFSet.pair ((b j).encode l) (l (t j)) ∈ + Name.encode l (.mk κ b t) := ZFSet.mem_range_self j + rw [←h] at hx + obtain ⟨i,hi⟩ := ZFSet.mem_range.mp hx + obtain ⟨hc,hs⟩ := ZFSet.pair_inj.mp hi + exact ⟨q,le_rfl,i,by simpa only [hl hs] using ht,ih i (b j) hc q⟩ + +theorem eq_encode_congr (l : P → ZFSet.{u}) (hl : Function.Injective l) + {a b c d : Name P} (hac : a.encode l = c.encode l) + (hbd : b.encode l = d.encode l) (p : P) : EqForces a b p ↔ EqForces c d p := by + have ha := eq_of_encode_eq l hl a c hac p + have hb := eq_of_encode_eq l hl b d hbd p + exact ⟨fun h => eq_trans c b d p (eq_trans c a b p (eq_symm _ _ _ ha) h) hb, + fun h => eq_trans a d b p (eq_trans a c d p ha h) (eq_symm _ _ _ hb)⟩ + +theorem mem_congr_left {a b c : Name P} {p : P} (he : EqForces a b p) + (h : MemForces a c p) : MemForces b c p := by + cases c with + | mk κ c t => + intro q hq + obtain ⟨r,hr,j,hj,hf⟩ := h q hq + exact ⟨r,hr,j,hj,eq_trans _ _ _ r (eq_symm _ _ _ (eq_mono _ _ (hr.trans hq) he)) hf⟩ + +theorem mem_congr_right {a b c : Name P} {p : P} (he : EqForces b c p) + (h : MemForces a b p) : MemForces a c p := by + cases b with + | mk κ b t => + cases c with + | mk μ c v => + intro q hq + obtain ⟨r,hr,j,hj,hf⟩ := h q hq + obtain ⟨w,hw,k,hk,hg⟩ := he.1 j r (hr.trans hq) hj + exact ⟨w,hw.trans hr,k,hk,eq_trans _ _ _ w (eq_mono _ _ hw hf) hg⟩ + +theorem mem_encode_congr (l : P → ZFSet.{u}) (hl : Function.Injective l) + {a b c d : Name P} (hac : a.encode l = c.encode l) + (hbd : b.encode l = d.encode l) (p : P) : MemForces a b p ↔ MemForces c d p := by + have ha := eq_of_encode_eq l hl a c hac p + have hb := eq_of_encode_eq l hl b d hbd p + exact ⟨fun h => mem_congr_right hb (mem_congr_left ha h), + fun h => mem_congr_right (eq_symm _ _ _ hb) (mem_congr_left (eq_symm _ _ _ ha) h)⟩ + +noncomputable def EncodedEq {l : P → ZFSet.{u}} (a b : EncodedName l) (p : P) : Prop := + EqForces a.property.choose b.property.choose p +noncomputable def EncodedMem {l : P → ZFSet.{u}} (a b : EncodedName l) (p : P) : Prop := + MemForces a.property.choose b.property.choose p + +theorem encodedEq_toEncoded (l : P → ZFSet.{u}) (hl : Function.Injective l) + (a b : Name P) (p : P) : EncodedEq (a.toEncoded l) (b.toEncoded l) p ↔ EqForces a b p := + eq_encode_congr l hl (a.toEncoded l).property.choose_spec + (b.toEncoded l).property.choose_spec p + +theorem encodedMem_toEncoded (l : P → ZFSet.{u}) (hl : Function.Injective l) + (a b : Name P) (p : P) : EncodedMem (a.toEncoded l) (b.toEncoded l) p ↔ MemForces a b p := + mem_encode_congr l hl (a.toEncoded l).property.choose_spec + (b.toEncoded l).property.choose_spec p + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicFormula.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..c68f5f007a862a1540df1fb807e67c247a4461de --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicFormula.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalFixedPoint + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open TransitiveNameModel BoundedSetTheory +universe u + +def Triple (k f a b q : ZFSet.{u}) : Prop := + ∃ v ∈ k, v = ZFSet.pair a b ∧ ZFSet.pair v q ∈ f + +def Match (flip : Bool) (d c k o f a y q : ZFSet.{u}) : Prop := + ∃ r ∈ c, ZFSet.pair r q ∈ o ∧ ∃ b ∈ d, ∃ t ∈ c, + ZFSet.pair b t ∈ y ∧ ZFSet.pair r t ∈ o ∧ + Triple k f (if flip then b else a) (if flip then a else b) r + +def Side (flip : Bool) (d c k o f x y p : ZFSet.{u}) : Prop := + ∀ a ∈ d, ∀ s ∈ c, ZFSet.pair a s ∈ x → + ∀ q ∈ c, ZFSet.pair q p ∈ o → ZFSet.pair q s ∈ o → Match flip d c k o f a y q + +def Step (d c k o f x y p : ZFSet.{u}) : Prop := + Side false d c k o f x y p ∧ Side true d c k o f y x p + +def Vertex (d c k o f z : ZFSet.{u}) : Prop := + ∃ x ∈ d, ∃ y ∈ d, ∃ q ∈ c, ∃ v ∈ k, + v = ZFSet.pair x y ∧ z = ZFSet.pair v q ∧ Step d c k o f x y q + +namespace AtomicFormula +open Formula + +def triple (k f a b q : ℕ) : Formula := + .existsMem k (.conj (orderedPair 0 (a+1) (b+1)) (pairMem 0 (q+1) (f+1))) + +theorem eval_triple (k f a b q : ℕ) (e : ℕ → ZFSet.{u}) : + (triple k f a b q).Eval e ↔ Triple (e k) (e f) (e a) (e b) (e q) := by + simp only [triple,Formula.Eval,eval_orderedPair,eval_pairMem,cons_zero,cons_succ,Triple] + +def matchF (flip : Bool) (d c k o f a y q : ℕ) : Formula := + .existsMem c (.conj (pairMem 0 (q+1) (o+1)) + (.existsMem (d+1) (.existsMem (c+2) + (.conj (pairMem 1 0 (y+3)) (.conj (pairMem 2 0 (o+3)) + (triple (k+3) (f+3) (if flip then 1 else a+3) (if flip then a+3 else 1) 2)))))) + +theorem eval_matchF (flip : Bool) (d c k o f a y q : ℕ) (e : ℕ → ZFSet.{u}) : + (matchF flip d c k o f a y q).Eval e ↔ + Match flip (e d) (e c) (e k) (e o) (e f) (e a) (e y) (e q) := by + cases flip <;> simp only [matchF,Formula.Eval,eval_pairMem,eval_triple, + cons_zero,cons_succ,Match,Bool.false_eq_true,ite_false,ite_true] + +def side (flip : Bool) (d c k o f x y p : ℕ) : Formula := + allMem d (allMem (c+1) (imp (pairMem 1 0 (x+2)) + (allMem (c+2) (imp (.conj (pairMem 0 (p+3) (o+3)) (pairMem 0 1 (o+3))) + (matchF flip (d+3) (c+3) (k+3) (o+3) (f+3) 2 (y+3) 0))))) + +theorem eval_side (flip : Bool) (d c k o f x y p : ℕ) (e : ℕ → ZFSet.{u}) : + (side flip d c k o f x y p).Eval e ↔ + Side flip (e d) (e c) (e k) (e o) (e f) (e x) (e y) (e p) := by + simp only [side,eval_allMem,eval_imp,Formula.Eval,eval_pairMem,eval_matchF, + cons_zero,cons_succ,Side,and_imp] + +def step (d c k o f x y p : ℕ) : Formula := + .conj (side false d c k o f x y p) (side true d c k o f y x p) + +theorem eval_step (d c k o f x y p : ℕ) (e : ℕ → ZFSet.{u}) : + (step d c k o f x y p).Eval e ↔ + Step (e d) (e c) (e k) (e o) (e f) (e x) (e y) (e p) := by + simp only [step,Formula.Eval,eval_side,Step] + +def vertex (d c k o f z : ℕ) : Formula := + .existsMem d (.existsMem (d+1) (.existsMem (c+2) (.existsMem (k+3) + (.conj (orderedPair 0 3 2) (.conj (orderedPair (z+4) 0 1) + (step (d+4) (c+4) (k+4) (o+4) (f+4) 3 2 1)))))) + +theorem eval_vertex (d c k o f z : ℕ) (e : ℕ → ZFSet.{u}) : + (vertex d c k o f z).Eval e ↔ Vertex (e d) (e c) (e k) (e o) (e f) (e z) := by + simp only [vertex,Formula.Eval,eval_orderedPair,eval_step,cons_zero,cons_succ,Vertex] +end AtomicFormula + +theorem match_mono (flip : Bool) (d c k o f g a y q : ZFSet.{u}) + (hfg : f ⊆ g) (h : Match flip d c k o f a y q) : Match flip d c k o g a y q := by + obtain ⟨r,hr,hrq,b,hb,t,ht,hbt,hrt,v,hv,hve,hvf⟩ := h + exact ⟨r,hr,hrq,b,hb,t,ht,hbt,hrt,v,hv,hve,hfg hvf⟩ + +theorem step_mono (d c k o f g x y p : ZFSet.{u}) (hfg : f ⊆ g) + (h : Step d c k o f x y p) : Step d c k o g x y p := by + exact ⟨fun a ha s hs hax q hq hqp hqs => + match_mono _ _ _ _ _ _ _ _ _ _ hfg (h.1 a ha s hs hax q hq hqp hqs), + fun a ha s hs hay q hq hqp hqs => + match_mono _ _ _ _ _ _ _ _ _ _ hfg (h.2 a ha s hs hay q hq hqp hqs)⟩ + +theorem vertex_mono (d c k o f g z : ZFSet.{u}) (hfg : f ⊆ g) + (h : Vertex d c k o f z) : Vertex d c k o g z := by + obtain ⟨x,hx,y,hy,q,hq,v,hv,hve,hze,hs⟩ := h + exact ⟨x,hx,y,hy,q,hq,v,hv,hve,hze,step_mono _ _ _ _ _ _ _ _ _ hfg hs⟩ + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicGraph.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3e6a213ec6ad3c83639378b47f737d05a36d327 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicGraph.lean @@ -0,0 +1,55 @@ +import OAI.Computability.DegreeRigidity.Syntax.AtomicFormula + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open TransitiveNameModel BoundedSetTheory +universe u + +def Graph (d c o f : ZFSet.{u}) : Prop := + f ⊆ ZFSet.prod (ZFSet.prod d d) c ∧ + ∀ x ∈ d, ∀ y ∈ d, ∀ q ∈ c, + ZFSet.pair (ZFSet.pair x y) q ∈ f ↔ Step d c (ZFSet.prod d d) o f x y q + +theorem vertex_pair (d c o f x y q : ZFSet.{u}) (hx : x ∈ d) (hy : y ∈ d) (hq : q ∈ c) : + Vertex d c (ZFSet.prod d d) o f (ZFSet.pair (ZFSet.pair x y) q) ↔ + Step d c (ZFSet.prod d d) o f x y q := by + constructor + · rintro ⟨a,ha,b,hb,r,hr,v,hv,hve,hze,hs⟩ + obtain ⟨hp,hq'⟩ := ZFSet.pair_inj.mp hze + have hab := ZFSet.pair_inj.mp (hp.trans hve) + rcases hab with ⟨rfl,rfl⟩ + simpa only [hq'] using hs + · intro hs + exact ⟨x,hx,y,hy,q,hq,_,ZFSet.mem_prod.mpr ⟨x,hx,y,hy,rfl⟩,rfl,rfl,hs⟩ + +theorem internal_atomic_graph (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + {d c o : ZFSet.{u}} (hd : d ∈ M) (hc : c ∈ M) (ho : o ∈ M) : + ∃ f ∈ M, Graph d c o f := by + let k := ZFSet.prod d d + let a := ZFSet.prod k c + have hk : k ∈ M := product_mem M hM hP hU hPow hS hd hd + have ha : a ∈ M := product_mem M hM hP hU hPow hS hk hc + let e := cons d (cons c (cons k (cons o (fun _ => d)))) + have he : ∀ i, e i ∈ M := by + intro i + rcases i with _|i; exact hd + rcases i with _|i; exact hc + rcases i with _|i; exact hk + rcases i with _|i; exact ho + exact hd + let φ := AtomicFormula.vertex 2 3 4 5 1 0 + have hφ (f z : ZFSet.{u}) : φ.Eval (cons z (cons f e)) ↔ Vertex d c k o f z := + AtomicFormula.eval_vertex 2 3 4 5 1 0 _ + obtain ⟨f,hf,hfa,hfdef⟩ := internal_fixed_point M hM hU hPow hS φ e he a ha (by + intro f g _ _ hfg z _ h + exact (hφ g z).mpr (vertex_mono _ _ _ _ _ _ _ hfg ((hφ f z).mp h))) + refine ⟨f,hf,hfa,fun x hx y hy q hq => ?_⟩ + have hz : ZFSet.pair (ZFSet.pair x y) q ∈ a := + ZFSet.mem_prod.mpr ⟨_,ZFSet.mem_prod.mpr ⟨x,hx,y,hy,rfl⟩,q,hq,rfl⟩ + exact (hfdef _ hz).trans ((hφ f _).trans (vertex_pair d c o f x y q hx hy hq)) + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicGraphCorrect.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicGraphCorrect.lean new file mode 100644 index 0000000000000000000000000000000000000000..475e23bab257de07ba2086097c743e84dd5e8444 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicGraphCorrect.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DegreeRigidity.Syntax.AtomicGraph +import OAI.Computability.DegreeRigidity.Syntax.AtomicEncoding +import OAI.Computability.DegreeRigidity.SetModels.NameUnionCode + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem triple_pair {d f x y q : ZFSet.{u}} (hx : x ∈ d) (hy : y ∈ d) : + Triple (ZFSet.prod d d) f x y q ↔ ZFSet.pair (ZFSet.pair x y) q ∈ f := by + constructor + · rintro ⟨v,_,rfl,h⟩; exact h + · intro h + exact ⟨_,ZFSet.mem_prod.mpr ⟨x,hx,y,hy,rfl⟩,rfl,h⟩ + +omit [Preorder (Conditions c)] in +private theorem child_code_mem {d : ZFSet.{u}} (hd : Transitive d) + (a : Name (Conditions c)) (ha : a.encode (label c) ∈ d) (i : a.arity) : + (a.child i).encode (label c) ∈ d := by + apply names_childClosed d c hd a ha + cases a + exact ⟨i,rfl⟩ + +theorem match_encode (flip : Bool) {d k o f a : ZFSet.{u}} (hd : Transitive d) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (b : Name (Conditions c)) (hb : b.encode (label c) ∈ d) (q : Conditions c) : + Match flip d c k o f a (b.encode (label c)) (label c q) ↔ + ∃ r, r ≤ q ∧ ∃ j, r ≤ b.tag j ∧ + Triple k f (if flip then (b.child j).encode (label c) else a) + (if flip then a else (b.child j).encode (label c)) (label c r) := by + constructor + · rintro ⟨r,hr,hrq,x,hx,t,ht,hxt,hrt,hf⟩ + obtain ⟨s,rfl⟩ := label_surjective c hr + obtain ⟨j,hj,hjt⟩ := (pair_mem_encode (label c) b x t).mp hxt + subst x + subst t + exact ⟨s,(ho s q).mp hrq,j,(ho s (b.tag j)).mp hrt,hf⟩ + · rintro ⟨r,hrq,j,hrj,hf⟩ + exact ⟨label c r,label_mem c r,(ho r q).mpr hrq, + _,child_code_mem hd b hb j,_,label_mem c (b.tag j), + (pair_mem_encode _ _ _ _).mpr ⟨j,rfl,rfl⟩,(ho r (b.tag j)).mpr hrj,hf⟩ + +theorem side_encode (flip : Bool) {d k o f : ZFSet.{u}} (hd : Transitive d) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (a b : Name (Conditions c)) (ha : a.encode (label c) ∈ d) + (hb : b.encode (label c) ∈ d) (p : Conditions c) : + Side flip d c k o f (a.encode (label c)) (b.encode (label c)) (label c p) ↔ + ∀ i, Below p (a.tag i) (fun r => ∃ j, r ≤ b.tag j ∧ + Triple k f (if flip then (b.child j).encode (label c) else (a.child i).encode (label c)) + (if flip then (a.child i).encode (label c) else (b.child j).encode (label c)) (label c r)) := by + constructor + · intro h i q hqp hqi + have hm := h _ (child_code_mem hd a ha i) _ (label_mem c (a.tag i)) + ((pair_mem_encode _ _ _ _).mpr ⟨i,rfl,rfl⟩) _ (label_mem c q) + ((ho q p).mpr hqp) ((ho q (a.tag i)).mpr hqi) + exact (match_encode flip hd ho b hb q).mp hm + · intro h x hx s hs hxs q hq hqp hqs + obtain ⟨i,hi,his⟩ := (pair_mem_encode (label c) a x s).mp hxs + subst x + subst s + obtain ⟨r,rfl⟩ := label_surjective c hq + exact (match_encode flip hd ho b hb r).mpr + (h i r ((ho r p).mp hqp) ((ho r (a.tag i)).mp hqs)) + +theorem Graph.correct {d o f : ZFSet.{u}} (hd : Transitive d) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (hf : Graph d c o f) (a b : Name (Conditions c)) + (ha : a.encode (label c) ∈ d) (hb : b.encode (label c) ∈ d) (p : Conditions c) : + ZFSet.pair (ZFSet.pair (a.encode (label c)) (b.encode (label c))) (label c p) ∈ f ↔ + EqForces a b p := by + induction a generalizing b p with + | mk ι a s ih => + cases b with + | mk κ b t => + have hai (i) : (a i).encode (label c) ∈ d := child_code_mem hd _ ha i + have hbj (j) : (b j).encode (label c) ∈ d := child_code_mem hd _ hb j + have hrel (i j) (q : Conditions c) : + Triple (ZFSet.prod d d) f ((a i).encode (label c)) ((b j).encode (label c)) (label c q) ↔ + EqForces (a i) (b j) q := + (triple_pair (hai i) (hbj j)).trans (ih i (b j) (hai i) (hbj j) q) + rw [hf.2 _ ha _ hb _ (label_mem c p)] + change (Side false _ _ _ _ _ _ _ _ ∧ Side true _ _ _ _ _ _ _ _) ↔ _ + rw [side_encode false hd ho _ _ ha hb p, side_encode true hd ho _ _ hb ha p] + simp only [Bool.false_eq_true,ite_false,ite_true,Name.arity,Name.child,Name.tag] + simp only [Below,hrel,EqForces] + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicRequirements.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicRequirements.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6ecbc3da6936da2a97691132e59198f0a9b503f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicRequirements.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DegreeRigidity.Syntax.AtomicEncoding +import OAI.Computability.DegreeRigidity.SetModels.NameExtension + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open Set RecursiveNames CountableForcing +universe u +variable {P : Type u} [Preorder P] + +def Witness (a : Name P) : Name P → P → Prop + | .mk _ b t, p => ∃ j, p ≤ t j ∧ EqForces a (b j) p + +def NegMem (a b : Name P) (p : P) : Prop := ∀ q, q ≤ p → ¬ MemForces a b q + +def MemTest (a b : Name P) : Set P := {p | Witness a b p ∨ NegMem a b p} + +def Refute : Name P → Name P → P → Prop + | .mk _ a s, .mk _ b t, p => + (∃ i, p ≤ s i ∧ NegMem (a i) (.mk _ b t) p) ∨ + (∃ j, p ≤ t j ∧ NegMem (b j) (.mk _ a s) p) + +def EqTest (a b : Name P) : Set P := {p | EqForces a b p ∨ Refute a b p} + +theorem witness_mono (a b : Name P) {p q : P} (hq : q ≤ p) + (h : Witness a b p) : Witness a b q := by + cases b with + | mk κ b t => + obtain ⟨j,hj,he⟩ := h + exact ⟨j,hq.trans hj,eq_mono _ _ hq he⟩ + +theorem witness_mem (a b : Name P) (p : P) (h : Witness a b p) : MemForces a b p := by + cases b with + | mk κ b t => + intro q hq + exact ⟨q,le_rfl,witness_mono _ _ hq h⟩ + +theorem memTest_dense (a b : Name P) : Dense (MemTest a b) := by + classical + intro p + by_cases h : ∃ q, q ≤ p ∧ Witness a b q + · obtain ⟨q,hq,hw⟩ := h + exact ⟨q,hq,Or.inl hw⟩ + · refine ⟨p,le_rfl,Or.inr ?_⟩ + intro q hq hm + cases b with + | mk κ b t => + obtain ⟨r,hr,hw⟩ := hm q le_rfl + exact h ⟨r,hr.trans hq,hw⟩ + +theorem eqTest_dense (a b : Name P) : Dense (EqTest a b) := by + classical + cases a with + | mk ι a s => + cases b with + | mk κ b t => + intro p + by_cases he : EqForces (.mk ι a s) (.mk κ b t) p + · exact ⟨p,le_rfl,Or.inl he⟩ + · change ¬ ((∀ i, Below p (s i) _) ∧ (∀ j, Below p (t j) _)) at he + simp only [not_and_or, not_forall, Below] at he + rcases he with ⟨i,q,hq⟩ | ⟨j,q,hq⟩ + · obtain ⟨hqp,hqs,hn⟩ := hq + refine ⟨q,hqp,Or.inr (Or.inl ⟨i,hqs,?_⟩)⟩ + intro r hr hm + obtain ⟨w,hw,k,hk,hf⟩ := hm r le_rfl + exact hn ⟨w,hw.trans hr,k,hk,hf⟩ + · obtain ⟨hqp,hqt,hn⟩ := hq + refine ⟨q,hqp,Or.inr (Or.inr ⟨j,hqt,?_⟩)⟩ + intro r hr hm + obtain ⟨w,hw,i,hi,hf⟩ := hm r le_rfl + exact hn ⟨w,hw.trans hr,i,hi,eq_symm _ _ _ hf⟩ + +structure Generic (N : Set (Name P)) (G : GenericFilter P) : Prop where + memTest : ∀ a ∈ N, ∀ b ∈ N, ∃ p ∈ G.carrier, p ∈ MemTest a b + eqTest : ∀ a ∈ N, ∀ b ∈ N, ∃ p ∈ G.carrier, p ∈ EqTest a b + +theorem generic_witness {N : Set (Name P)} {G : GenericFilter P} + (hG : Generic N G) {a b : Name P} (ha : a ∈ N) (hb : b ∈ N) + {p : P} (hp : p ∈ G.carrier) (hm : MemForces a b p) : + ∃ q ∈ G.carrier, Witness a b q := by + obtain ⟨q,hq,hw | hn⟩ := hG.memTest a ha b hb + · exact ⟨q,hq,hw⟩ + · obtain ⟨r,hr,hrp,hrq⟩ := G.directed hp hq + exact False.elim (hn r hrq (mem_mono _ _ hrp hm)) + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicTruth.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicTruth.lean new file mode 100644 index 0000000000000000000000000000000000000000..dca84ac7582720cf2c4dc748608a928961c64762 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/AtomicTruth.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DegreeRigidity.Syntax.AtomicRequirements + +namespace OAI + +namespace TuringRigidity.AtomicForcing +open Set RecursiveNames CountableForcing +universe u +variable {P : Type u} [Preorder P] + +private theorem mem_truth_step {N : Set (Name P)} {G : GenericFilter P} + (hG : Generic N G) (a : Name P) (κ : Type u) (b : κ → Name P) (t : κ → P) + (ha : a ∈ N) (hb : Name.mk κ b t ∈ N) + (he : ∀ j, Name.val G.carrier a = Name.val G.carrier (b j) ↔ + ∃ p ∈ G.carrier, EqForces a (b j) p) : + Name.val G.carrier a ∈ Name.val G.carrier (.mk κ b t) ↔ + ∃ p ∈ G.carrier, MemForces a (.mk κ b t) p := by + constructor + · intro hm + obtain ⟨j,hj,hv⟩ := (Name.mem_val _ _ _ _ _).mp hm + obtain ⟨p,hp,hf⟩ := (he j).mp hv.symm + obtain ⟨r,hr,hrp,hrj⟩ := G.directed hp hj + exact ⟨r,hr,witness_mem _ _ _ ⟨j,hrj,eq_mono _ _ hrp hf⟩⟩ + · rintro ⟨p,hp,hm⟩ + obtain ⟨q,hq,j,hj,hf⟩ := generic_witness hG ha hb hp hm + exact (Name.mem_val _ _ _ _ _).mpr ⟨j,G.upper hj hq,((he j).mpr ⟨q,hq,hf⟩).symm⟩ + +theorem eq_truth {N : Set (Name P)} (hN : ChildClosed N) (G : GenericFilter P) + (hG : Generic N G) (a b : Name P) (ha : a ∈ N) (hb : b ∈ N) : + Name.val G.carrier a = Name.val G.carrier b ↔ + ∃ p ∈ G.carrier, EqForces a b p := by + induction a generalizing b with + | mk ι a s ih => + cases b with + | mk κ b t => + have ha' (i) : a i ∈ N := hN _ ha _ ⟨i,rfl⟩ + have hb' (j) : b j ∈ N := hN _ hb _ ⟨j,rfl⟩ + have left (i) : Name.val G.carrier (a i) ∈ Name.val G.carrier (.mk κ b t) ↔ + ∃ p ∈ G.carrier, MemForces (a i) (.mk κ b t) p := + mem_truth_step hG (a i) κ b t (ha' i) hb (fun j => ih i (b j) (ha' i) (hb' j)) + have right (j) : Name.val G.carrier (b j) ∈ Name.val G.carrier (.mk ι a s) ↔ + ∃ p ∈ G.carrier, MemForces (b j) (.mk ι a s) p := by + apply mem_truth_step hG (b j) ι a s (hb' j) ha + intro i + constructor + · intro he + obtain ⟨p,hp,hf⟩ := (ih i (b j) (ha' i) (hb' j)).mp he.symm + exact ⟨p,hp,eq_symm _ _ _ hf⟩ + · rintro ⟨p,hp,hf⟩ + exact ((ih i (b j) (ha' i) (hb' j)).mpr ⟨p,hp,eq_symm _ _ _ hf⟩).symm + constructor + · intro hv + obtain ⟨p,hp,he | hn⟩ := hG.eqTest _ ha _ hb + · exact ⟨p,hp,he⟩ + · rcases hn with ⟨i,hi,hn⟩ | ⟨j,hj,hn⟩ + · have hm : Name.val G.carrier (a i) ∈ Name.val G.carrier (.mk κ b t) := by + rw [←hv] + exact (Name.mem_val _ _ _ _ _).mpr ⟨i,G.upper hi hp,rfl⟩ + obtain ⟨q,hq,hf⟩ := (left i).mp hm + obtain ⟨r,hr,hrp,hrq⟩ := G.directed hp hq + exact False.elim (hn r hrp (mem_mono _ _ hrq hf)) + · have hm : Name.val G.carrier (b j) ∈ Name.val G.carrier (.mk ι a s) := by + rw [hv] + exact (Name.mem_val _ _ _ _ _).mpr ⟨j,G.upper hj hp,rfl⟩ + obtain ⟨q,hq,hf⟩ := (right j).mp hm + obtain ⟨r,hr,hrp,hrq⟩ := G.directed hp hq + exact False.elim (hn r hrp (mem_mono _ _ hrq hf)) + · rintro ⟨p,hp,he⟩ + apply ZFSet.ext + intro x + constructor + · intro hx + obtain ⟨i,hi,rfl⟩ := (Name.mem_val _ _ _ _ _).mp hx + obtain ⟨r,hr,hrp,hri⟩ := G.directed hp hi + exact (left i).mpr ⟨r,hr,fun q hq => he.1 i q (hq.trans hrp) (hq.trans hri)⟩ + · intro hx + obtain ⟨j,hj,rfl⟩ := (Name.mem_val _ _ _ _ _).mp hx + obtain ⟨r,hr,hrp,hrj⟩ := G.directed hp hj + apply (right j).mpr + refine ⟨r,hr,?_⟩ + intro q hq + obtain ⟨w,hw,i,hi,hf⟩ := he.2 j q (hq.trans hrp) (hq.trans hrj) + exact ⟨w,hw,i,hi,eq_symm _ _ _ hf⟩ + +theorem mem_truth {N : Set (Name P)} (hN : ChildClosed N) (G : GenericFilter P) + (hG : Generic N G) (a b : Name P) (ha : a ∈ N) (hb : b ∈ N) : + Name.val G.carrier a ∈ Name.val G.carrier b ↔ + ∃ p ∈ G.carrier, MemForces a b p := by + cases b with + | mk κ b t => + exact mem_truth_step hG a κ b t ha hb + (fun j => eq_truth hN G hG a (b j) ha (hN _ hb _ ⟨j,rfl⟩)) + +end TuringRigidity.AtomicForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanEvaluationWitness.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanEvaluationWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5771a65cebcaafee085ab54e50cb67c879310cc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanEvaluationWitness.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DegreeRigidity.Syntax.BooleanTruthReading + +namespace OAI + +namespace TuringRigidity.BooleanExpressionTruth +open TransitiveNameModel BoundedSetTheory BooleanExpressionCertificate + +def GoodTruth (K B R Y : ZFSet.{0}) : Prop := + Y ⊆ K ∧ ∀ t ∈ K, t ∈ Y ↔ step K B R Y t + +theorem GoodTruth.agrees {K B R Y : ZFSet.{0}} (hK : Transitive K) (hy : GoodTruth K B R Y) : + ∀ t ∈ K, t ∈ Y ↔ value B R t := by + have hp : BoundedTruthRecursion.Partial formula (parameters K B R) K K Y := + ⟨hK,fun _ h => h,hy.1,fun t ht => (hy.2 t ht).trans (formula_spec K B R Y t).symm⟩ + intro t ht + exact (BoundedTruthRecursion.partial_sound formula (parameters K B R) K K Y (valueSet K B R) + (formula_local K B R) hp (valueSet_fixed K B R hK) t ht).trans + (ZFSet.mem_sep.trans (and_iff_right ht)) + +theorem valueSet_good (K B R : ZFSet.{0}) (hK : Transitive K) : GoodTruth K B R (valueSet K B R) := + ⟨fun _ h => (ZFSet.mem_sep.mp h).1, + fun t ht => (valueSet_fixed K B R hK t ht).trans (formula_spec K B R _ t)⟩ + +def Evaluated (c B Q S R K Y U : ZFSet.{0}) : Prop := + Transitive K ∧ GoodTruth K B R Y ∧ ∃ g ∈ K, Certificate c B Q S K g ∧ + ∃ t ∈ K, ZFSet.pair t U ∈ g ∧ t ∈ Y + +def truthSlots (t Y K B R z0 z1 z2 : ℕ) : ℕ → ℕ + | 0 => t + | 1 => Y + | 2 => K + | 3 => B + | 4 => R + | 5 => z0 + | 6 => z1 + | _ => z2 + +def truthAt (t Y K B R z0 z1 z2 : ℕ) : Formula := formula.rename (truthSlots t Y K B R z0 z1 z2) + +theorem truthAt_spec (t Y K B R z0 z1 z2 : ℕ) (e : ℕ → ZFSet.{0}) + (h0 : e z0 = natSet 0) (h1 : e z1 = natSet 1) (h2 : e z2 = natSet 2) : + (truthAt t Y K B R z0 z1 z2).Eval e ↔ step (e K) (e B) (e R) (e Y) (e t) := by + have eq : e ∘ truthSlots t Y K B R z0 z1 z2 = cons (e t) (cons (e Y) (parameters (e K) (e B) (e R))) := by + funext i + rcases i with _|_|_|_|_|_|_|i + rfl; rfl; rfl; rfl; rfl; exact h0; exact h1; exact h2 + rw [truthAt,Formula.eval_rename_comp,eq,formula_spec] + +def goodTruthFormula (K B R Y z0 z1 z2 : ℕ) : Formula := + .conj (.subset Y K) (.allMem K (.iff (.member 0 (Y+1)) + (truthAt 0 (Y+1) (K+1) (B+1) (R+1) (z0+1) (z1+1) (z2+1)))) + +theorem goodTruthFormula_spec (K B R Y z0 z1 z2 : ℕ) (e : ℕ → ZFSet.{0}) + (h0 : e z0 = natSet 0) (h1 : e z1 = natSet 1) (h2 : e z2 = natSet 2) : + (goodTruthFormula K B R Y z0 z1 z2).Eval e ↔ GoodTruth (e K) (e B) (e R) (e Y) := by + simp only [goodTruthFormula,Formula.Eval,Formula.eval_subset,Formula.eval_allMem,Formula.eval_iff, + cons_zero,cons_succ,GoodTruth] + apply and_congr Iff.rfl + apply forall_congr'; intro t + apply imp_congr_right; intro _ + exact iff_congr Iff.rfl (truthAt_spec _ _ _ _ _ _ _ _ _ h0 h1 h2) + +def evaluatedFormula (c B Q S R K Y U z0 z1 z2 : ℕ) : Formula := + .conj (.transitive K) (.conj (goodTruthFormula K B R Y z0 z1 z2) + (.existsMem K (.conj (certificateFormula (c+1) (B+1) (Q+1) (S+1) (K+1) 0 (z0+1) (z1+1) (z2+1)) + (.existsMem (K+1) (.conj (.pairMem 0 (U+2) 1) (.member 0 (Y+2))))))) + +theorem evaluatedFormula_spec (c B Q S R K Y U z0 z1 z2 : ℕ) (e : ℕ → ZFSet.{0}) + (h0 : e z0 = natSet 0) (h1 : e z1 = natSet 1) (h2 : e z2 = natSet 2) : + (evaluatedFormula c B Q S R K Y U z0 z1 z2).Eval e ↔ + Evaluated (e c) (e B) (e Q) (e S) (e R) (e K) (e Y) (e U) := by + simp only [evaluatedFormula,Formula.Eval,Formula.eval_transitive,Formula.eval_pairMem, + cons_zero,cons_succ,Evaluated] + apply and_congr Iff.rfl + apply and_congr (goodTruthFormula_spec _ _ _ _ _ _ _ _ h0 h1 h2) + apply exists_congr; intro g + apply and_congr_right; intro _ + exact and_congr (certificateFormula_spec _ _ _ _ _ _ _ _ _ _ h0 h1 h2) Iff.rfl + +def evaluationParameters (W c B Q S R : ZFSet.{0}) : ℕ → ZFSet.{0} := + cons W (cons c (cons B (cons Q (cons S (cons R + (cons (natSet 0) (cons (natSet 1) (fun _ => natSet 2)))))))) + +def evaluationBody : Formula := .existsMem 2 (evaluatedFormula 4 5 6 7 8 0 1 2 9 10 11) + +theorem evaluationBody_realize (N W c B Q S R Y U : ZFSet.{0}) (hN : Transitive N) + (he : ∀ i, evaluationParameters W c B Q S R i ∈ N) (hY : Y ∈ N) (hU : U ∈ N) : + evaluationBody.Realize N (cons Y (cons U (evaluationParameters W c B Q S R))) ↔ + ∃ K ∈ W, Evaluated c B Q S R K Y U := by + rw [Formula.absolute _ N hN _ (by + intro i; rcases i with _|_|i; exact hY; exact hU; exact he i)] + change (∃ K ∈ W, (evaluatedFormula 4 5 6 7 8 0 1 2 9 10 11).Eval + (cons K (cons Y (cons U (evaluationParameters W c B Q S R))))) ↔ _ + apply exists_congr; intro K + apply and_congr_right; intro _ + exact evaluatedFormula_spec _ _ _ _ _ _ _ _ _ _ _ _ rfl rfl rfl + +end TuringRigidity.BooleanExpressionTruth + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionAssembly.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionAssembly.lean new file mode 100644 index 0000000000000000000000000000000000000000..d436cdd78e4efc469628daa6c62175f2fee9cde0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionAssembly.lean @@ -0,0 +1,101 @@ +import OAI.Computability.DegreeRigidity.Syntax.BooleanExpressionSyntax + +namespace OAI + +namespace TuringRigidity.BooleanExpressionCertificate +open TransitiveNameModel BoundedSetTheory InternalBooleanSyntax +open InternalRegularOperations InternalRegularAlgebra + +theorem tag_mem (M : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (n : ℕ) {x : ZFSet.{0}} (hx : x ∈ M) : FiniteTerm.tag n x ∈ M := + orderedPair_mem M hM hT.pairing + (hM _ (sourceT_omega_mem M hM hT) _ ((mem_omega _).mpr ⟨n,rfl⟩)) hx + +theorem witness_of_certificate (M c B Q S K g t U : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hKM : K ∈ M) (hgM : g ∈ M) + (hg : Certificate c B Q S K g) (hp : ZFSet.pair t U ∈ g) : + ∃ L ∈ M, Witness c B Q S L U := by + obtain ⟨L,hLM,hL,hpair⟩ := internal_transitive_container M hM hT.pairing hT.union + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity + (pair_mem M hM hT.pairing hKM hgM) + have hKL := hL _ hpair K (ZFSet.mem_pair.mpr (Or.inl rfl)) + have hgL := hL _ hpair g (ZFSet.mem_pair.mpr (Or.inr rfl)) + have hsub : K ⊆ L := fun x hx => hL K hKL x hx + exact ⟨L,hLM,hL,g,hgL,hg.enlarge hsub,t,hsub (hg.step hp).1,hp⟩ + +theorem seed_certified (M c B Q S U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hUM : U ∈ M) (hUB : U ∈ B) (hUS : U ∈ S) : U ∈ certified M c B Q S := by + let t := FiniteTerm.tag 0 U + let K := ({t} : ZFSet.{0}) + let g := ({ZFSet.pair t U} : ZFSet.{0}) + have htM : t ∈ M := tag_mem M hM hT 0 hUM + have htK : t ∈ K := ZFSet.mem_singleton.mpr rfl + have hg : Certificate c B Q S K g := by + intro z hz + exact ⟨t,htK,U,hUB,ZFSet.mem_singleton.mp hz,Or.inl ⟨hUS,rfl⟩⟩ + exact ZFSet.mem_sep.mpr ⟨hUB,witness_of_certificate M c B Q S K g t U hM hT + (singleton_mem M hM hT.pairing htM) + (singleton_mem M hM hT.pairing (orderedPair_mem M hM hT.pairing htM hUM)) hg + (ZFSet.mem_singleton.mpr rfl)⟩ + +theorem neg_certified (M c B Q S U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hU : U ∈ certified M c B Q S) : neg c U ∈ certified M c B Q S := by + obtain ⟨hUB,K,hKM,hK,g,hgK,hg,t,htK,hp⟩ := ZFSet.mem_sep.mp hU + have hUM := ((hB U).mp hUB).1 + have hVM := neg_mem M c U hM hT hc hUM + have hVB := internal_complement M c B hM hT hc hB hUB + let s := FiniteTerm.tag 1 t + have hsM : s ∈ M := tag_mem M hM hT 1 (hM K hKM t htK) + let L := K ∪ ({s} : ZFSet.{0}) + have hKL : K ⊆ L := fun _ h => ZFSet.mem_union.mpr (Or.inl h) + have hsL : s ∈ L := ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_singleton.mpr rfl)) + have hs : Step c B Q S L g s (neg c U) := + Or.inr (Or.inl ⟨t,hKL htK,U,hUB,rfl,hp,rfl⟩) + let f := g ∪ ({ZFSet.pair s (neg c U)} : ZFSet.{0}) + have hf := (hg.enlarge hKL).insert hsL hVB hs + have hLM : L ∈ M := binary_union_mem M hM hT.pairing hT.union hKM + (singleton_mem M hM hT.pairing hsM) + have hfM : f ∈ M := binary_union_mem M hM hT.pairing hT.union (hM K hKM g hgK) + (singleton_mem M hM hT.pairing (orderedPair_mem M hM hT.pairing hsM hVM)) + exact ZFSet.mem_sep.mpr ⟨hVB,witness_of_certificate M c B Q S L f s _ hM hT hLM hfM hf + (ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_singleton.mpr rfl)))⟩ + +theorem Certificate.sUnion {c B Q S K a : ZFSet.{0}} + (ha : ∀ g ∈ a, Certificate c B Q S K g) : Certificate c B Q S K (ZFSet.sUnion a) := by + intro z hz + obtain ⟨g,hga,hzg⟩ := ZFSet.mem_sUnion.mp hz + obtain ⟨t,ht,U,hU,he,hs⟩ := ha g hga z hzg + exact ⟨t,ht,U,hU,he,hs.mono (fun _ h => h) (fun z hz => ZFSet.mem_sUnion.mpr ⟨g,hga,hz⟩)⟩ + +noncomputable def goodGraphs (a c B Q S K : ZFSet.{0}) : ZFSet.{0} := + a.sep (Certificate c B Q S K) + +theorem goodGraphs_mem (M a c B Q S K : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (ha : a ∈ M) (hc : c ∈ M) (hB : B ∈ M) (hQ : Q ∈ M) (hS : S ∈ M) (hK : K ∈ M) : + goodGraphs a c B Q S K ∈ M := by + let e := cons K (parameters c B Q S) + have he : ∀ i, e i ∈ M := by + intro i; cases i with + | zero => exact hK + | succ i => exact parameters_mem M c B Q S hM hT hc hB hQ hS i + have spec (g : ZFSet.{0}) : + (certificateFormula 2 3 4 5 1 0 6 7 8).Eval (cons g e) ↔ Certificate c B Q S K g := + certificateFormula_spec _ _ _ _ _ _ _ _ _ _ rfl rfl rfl + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (certificateFormula 2 3 4 5 1 0 6 7 8) e he ha + simpa only [spec,goodGraphs] using hs + +noncomputable def children (K F g : ZFSet.{0}) : ZFSet.{0} := + K.sep (fun t => ∃ U ∈ F, ZFSet.pair t U ∈ g) + +theorem children_mem (M K F g : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : K ∈ M) (hF : F ∈ M) (hg : g ∈ M) : children K F g ∈ M := by + have hs := sep_mem M hM hT.separation.finitePrefix.bounded + (.existsMem 1 (.pairMem 1 0 3)) (cons F (fun _ => g)) + (by intro i; cases i <;> assumption) hK + simpa only [children,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ] using hs + +end TuringRigidity.BooleanExpressionCertificate + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionCertificate.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..e529f38f97d3744b48ae543f83b1f00830f07584 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionCertificate.lean @@ -0,0 +1,113 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBooleanGeneric +import OAI.Computability.DegreeRigidity.Syntax.FiniteTerm + +namespace OAI + +namespace TuringRigidity.BooleanExpressionCertificate +open TransitiveNameModel BoundedSetTheory InternalRegularOperations InternalRegularAlgebra +open InternalBooleanGeneric CountableForcing +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +def Step (c B Q S K g t U : ZFSet.{0}) : Prop := + (U ∈ S ∧ t = FiniteTerm.tag 0 U) ∨ + (∃ s ∈ K, ∃ V ∈ B, t = FiniteTerm.tag 1 s ∧ + ZFSet.pair s V ∈ g ∧ U = neg c V) ∨ + (∃ T ∈ K, ∃ F ∈ Q, t = FiniteTerm.tag 2 T ∧ U = supCode c F ∧ + (∀ s ∈ T, ∃ V ∈ F, ZFSet.pair s V ∈ g) ∧ + (∀ V ∈ F, ∃ s ∈ T, ZFSet.pair s V ∈ g)) + +def Certificate (c B Q S K g : ZFSet.{0}) : Prop := + ∀ z ∈ g, ∃ t ∈ K, ∃ U ∈ B, z = ZFSet.pair t U ∧ Step c B Q S K g t U + +theorem Step.mono {c B Q S K L g h t U : ZFSet.{0}} + (hKL : K ⊆ L) (hgh : g ⊆ h) (hs : Step c B Q S K g t U) : + Step c B Q S L h t U := by + rcases hs with hs | hs | hs + · exact Or.inl hs + · obtain ⟨s,hs,V,hV,ht,hp,hU⟩ := hs + exact Or.inr (Or.inl ⟨s,hKL hs,V,hV,ht,hgh hp,hU⟩) + · obtain ⟨T,hT,F,hF,ht,hU,hTF,hFT⟩ := hs + exact Or.inr (Or.inr ⟨T,hKL hT,F,hF,ht,hU, + fun s hs => (hTF s hs).imp (fun V h => ⟨h.1,hgh h.2⟩), + fun V hV => (hFT V hV).imp (fun s h => ⟨h.1,hgh h.2⟩)⟩) + +theorem Certificate.step {c B Q S K g t U : ZFSet.{0}} + (hg : Certificate c B Q S K g) (hp : ZFSet.pair t U ∈ g) : + t ∈ K ∧ U ∈ B ∧ Step c B Q S K g t U := by + obtain ⟨s,hs,V,hV,he,hstep⟩ := hg _ hp + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hs,hV,hstep⟩ + +theorem Certificate.enlarge {c B Q S K L g : ZFSet.{0}} + (hg : Certificate c B Q S K g) (hKL : K ⊆ L) : Certificate c B Q S L g := by + intro z hz + obtain ⟨t,ht,U,hU,he,hs⟩ := hg z hz + exact ⟨t,hKL ht,U,hU,he,hs.mono hKL (fun _ h => h)⟩ + +theorem Certificate.union {c B Q S K g h : ZFSet.{0}} + (hg : Certificate c B Q S K g) (hh : Certificate c B Q S K h) : + Certificate c B Q S K (g ∪ h) := by + intro z hz + rcases ZFSet.mem_union.mp hz with hz | hz + · obtain ⟨t,ht,U,hU,he,hs⟩ := hg z hz + exact ⟨t,ht,U,hU,he,hs.mono (fun _ h => h) (fun _ h => ZFSet.mem_union.mpr (Or.inl h))⟩ + · obtain ⟨t,ht,U,hU,he,hs⟩ := hh z hz + exact ⟨t,ht,U,hU,he,hs.mono (fun _ h => h) (fun _ h => ZFSet.mem_union.mpr (Or.inr h))⟩ + +theorem Certificate.insert {c B Q S K g t U : ZFSet.{0}} + (hg : Certificate c B Q S K g) (ht : t ∈ K) (hU : U ∈ B) + (hs : Step c B Q S K g t U) : + Certificate c B Q S K (g ∪ ({ZFSet.pair t U} : ZFSet.{0})) := by + have hgg : g ⊆ g ∪ ({ZFSet.pair t U} : ZFSet.{0}) := + fun _ h => ZFSet.mem_union.mpr (Or.inl h) + intro z hz + rcases ZFSet.mem_union.mp hz with hz | hz + · obtain ⟨s,hs,V,hV,he,hstep⟩ := hg z hz + exact ⟨s,hs,V,hV,he,hstep.mono (fun _ h => h) hgg⟩ + · have he := ZFSet.mem_singleton.mp hz + exact ⟨t,ht,U,hU,he,hs.mono (fun _ h => h) hgg⟩ + +theorem Certificate.induction {c B Q S K g : ZFSet.{0}} + (hg : Certificate c B Q S K g) (P : ZFSet.{0} → Prop) + (hseed : ∀ U ∈ S, P U) + (hneg : ∀ U ∈ B, P U → P (neg c U)) + (hsup : ∀ F ∈ Q, (∀ U ∈ F, P U) → P (supCode c F)) + (t U : ZFSet.{0}) (hp : ZFSet.pair t U ∈ g) : P U := by + have wf : WellFounded (fun a b : ZFSet.{0} => ZFSet.rank a < ZFSet.rank b) := + InvImage.wf ZFSet.rank Ordinal.lt_wf + induction t using wf.induction generalizing U with + | h t ih => + rcases (hg.step hp).2.2 with hs | hs | hs + · exact hseed U hs.1 + · obtain ⟨s,_,V,hV,rfl,hchild,rfl⟩ := hs + exact hneg V hV (ih s (FiniteTerm.pair_rank_right _ _) V hchild) + · obtain ⟨T,_,F,hF,rfl,rfl,_,hFT⟩ := hs + apply hsup F hF + intro V hV + obtain ⟨s,hs,hp⟩ := hFT V hV + exact ih s ((ZFSet.rank_lt_of_mem hs).trans (FiniteTerm.pair_rank_right _ _)) V hp + +theorem Certificate.generic_agreement (M c B Q S K g : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) + (hg : Certificate c B Q S K g) + (G H : GenericFilter (Conditions c)) + (hG : AtomicForcing.GroundGeneric M G) (hH : AtomicForcing.GroundGeneric M H) + (hseed : ∀ U ∈ S, Hit G U ↔ Hit H U) + (t U : ZFSet.{0}) (hp : ZFSet.pair t U ∈ g) : Hit G U ↔ Hit H U := by + apply hg.induction (fun U => Hit G U ↔ Hit H U) hseed ?_ ?_ t U hp + · intro V hV ih + obtain ⟨hVM,hVc⟩ := (hB V).mp hV + rw [hit_complement_iff M c V hM hT hc hVM hVc G hG, + hit_complement_iff M c V hM hT hc hVM hVc H hH,ih] + · intro F hF ih + obtain ⟨hFM,hFB⟩ := (hQ F).mp hF + have hFc := fun U hU => ((hB U).mp (hFB hU)).2 + rw [hit_supCode_iff M c F hM hT hc hFM hFc G hG, + hit_supCode_iff M c F hM hT hc hFM hFc H hH] + exact exists_congr (fun U => and_congr_right (fun hU => ih U hU)) + +end TuringRigidity.BooleanExpressionCertificate + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionCoverage.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionCoverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c231c9025591bbb18d57d28f7e2249d8e00b52f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionCoverage.lean @@ -0,0 +1,101 @@ +import OAI.Computability.DegreeRigidity.Syntax.BooleanExpressionAssembly + +namespace OAI + +namespace TuringRigidity.BooleanExpressionCertificate +open TransitiveNameModel BoundedSetTheory InternalBooleanSyntax InternalGeneratedAlgebra +open InternalRegularOperations InternalRegularAlgebra + +theorem sup_certified (M c B Q S F : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hSM : S ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) (hFQ : F ∈ Q) + (hFC : F ⊆ certified M c B Q S) : supCode c F ∈ certified M c B Q S := by + obtain ⟨hFM,hFB⟩ := (hQ F).mp hFQ + have he := parameters_mem M c B Q S hM hT hc hBM hQM hSM + have hColl := sigma_collection M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix hT.replacement.finitePrefix hT.infinity hT.choice + obtain ⟨W,hWM,hW⟩ := hColl (.bounded witnessBody) (parameters c B Q S) he F hFM (by + intro U hUF + obtain ⟨_,K,hKM,hK⟩ := ZFSet.mem_sep.mp (hFC hUF) + exact ⟨K,hKM,(witnessBody_realize M c B Q S K U hM he hKM (hM F hFM U hUF)).mpr hK⟩) + obtain ⟨L,hLM,hL,hWL⟩ := internal_transitive_container M hM hT.pairing hT.union + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hWM + have hKL (K : ZFSet.{0}) (hK : K ∈ W) : K ⊆ L := + fun t ht => hL K (hL W hWL K hK) t ht + let a := goodGraphs (ZFSet.sUnion W) c B Q S L + have haM : a ∈ M := goodGraphs_mem M _ c B Q S L hM hT + (union_mem M hM hT.union hWM) hc hBM hQM hSM hLM + let g := ZFSet.sUnion a + have hgM : g ∈ M := union_mem M hM hT.union haM + have hg : Certificate c B Q S L g := Certificate.sUnion (fun f hf => (ZFSet.mem_sep.mp hf).2) + have htotal (U : ZFSet.{0}) (hUF : U ∈ F) : ∃ t ∈ L, ZFSet.pair t U ∈ g := by + obtain ⟨K,hKW,hK⟩ := hW U hUF + obtain ⟨_,f,hfK,hf,t,htK,hp⟩ := + (witnessBody_realize M c B Q S K U hM he (hM W hWM K hKW) (hM F hFM U hUF)).mp hK + have hfa : f ∈ a := ZFSet.mem_sep.mpr ⟨ZFSet.mem_sUnion.mpr ⟨K,hKW,hfK⟩,hf.enlarge (hKL K hKW)⟩ + exact ⟨t,hKL K hKW htK,ZFSet.mem_sUnion.mpr ⟨f,hfa,hp⟩⟩ + let T := children L F g + have hTM : T ∈ M := children_mem M L F g hM hT hLM hFM hgM + let s := FiniteTerm.tag 2 T + have hsM : s ∈ M := tag_mem M hM hT 2 hTM + let D := L ∪ ({T,s} : ZFSet.{0}) + have hLD : L ⊆ D := fun _ h => ZFSet.mem_union.mpr (Or.inl h) + have hTD : T ∈ D := ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_pair.mpr (Or.inl rfl))) + have hsD : s ∈ D := ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_pair.mpr (Or.inr rfl))) + have hDM : D ∈ M := binary_union_mem M hM hT.pairing hT.union hLM (pair_mem M hM hT.pairing hTM hsM) + have hVB := internal_join M c B F hM hT hc hB hFM + have hVM := ((hB _).mp hVB).1 + have hs : Step c B Q S D g s (supCode c F) := by + refine Or.inr (Or.inr ⟨T,hTD,F,hFQ,rfl,rfl,?_,?_⟩) + · exact fun t ht => (ZFSet.mem_sep.mp ht).2 + · intro U hUF + obtain ⟨t,htL,hp⟩ := htotal U hUF + exact ⟨t,ZFSet.mem_sep.mpr ⟨htL,U,hUF,hp⟩,hp⟩ + let f := g ∪ ({ZFSet.pair s (supCode c F)} : ZFSet.{0}) + have hfM : f ∈ M := binary_union_mem M hM hT.pairing hT.union hgM + (singleton_mem M hM hT.pairing (orderedPair_mem M hM hT.pairing hsM hVM)) + have hf := (hg.enlarge hLD).insert hsD hVB hs + exact ZFSet.mem_sep.mpr ⟨hVB,witness_of_certificate M c B Q S D f s _ hM hT hDM hfM hf + (ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_singleton.mpr rfl)))⟩ + +theorem certified_closed (M c B Q S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hSM : S ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) : Closed c B Q (certified M c B Q S) := + ⟨fun _ h => (ZFSet.mem_sep.mp h).1, + fun U hU => neg_certified M c B Q S U hM hT hc hB hU, + fun F hF hFC => sup_certified M c B Q S F hM hT hc hBM hQM hSM hB hQ hF hFC⟩ + +theorem generated_certificate (M c B Q S U : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hSM : S ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) (hSB : S ⊆ B) + (hU : U ∈ generated c B Q S) : ∃ K ∈ M, Witness c B Q S K U := by + have hC := certified_closed M c B Q S hM hT hc hBM hQM hSM hB hQ + have hCM := certified_mem M c B Q S hM hT hc hBM hQM hSM + have hCQ := (hQ _).mpr ⟨hCM,hC.1⟩ + have hSC : S ⊆ certified M c B Q S := by + intro V hV + exact seed_certified M c B Q S V hM hT (hM S hSM V hV) (hSB hV) hV + exact (ZFSet.mem_sep.mp (generated_le c B Q S _ hCQ hSC hC hU)).2 + +theorem certified_eq_generated (M c B Q S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hSM : S ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) (hSB : S ⊆ B) : + certified M c B Q S = generated c B Q S := by + have hA := generated_closed c B Q S (algebra_closed M c B Q hM hT hc hB hQ) + apply ZFSet.ext; intro U + constructor + · intro hU + obtain ⟨_,K,_,_,g,_,hg,t,_,hp⟩ := ZFSet.mem_sep.mp hU + exact hg.induction (fun V => V ∈ generated c B Q S) (fun V hV => seeds_subset c B Q S hSB hV) + (fun V _ hV => hA.2.1 V hV) (fun F hF hFA => hA.2.2 F hF (fun V hV => hFA V hV)) t U hp + · intro hU + exact ZFSet.mem_sep.mpr ⟨generated_subset c B Q S hU, + generated_certificate M c B Q S U hM hT hc hBM hQM hSM hB hQ hSB hU⟩ + +end TuringRigidity.BooleanExpressionCertificate + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionSyntax.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..c027ba13872eb02f4be91f339e4a35d8bbf3cc6a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionSyntax.lean @@ -0,0 +1,111 @@ +import OAI.Computability.DegreeRigidity.Syntax.BooleanExpressionCertificate + +namespace OAI + +namespace TuringRigidity.BooleanExpressionCertificate +open TransitiveNameModel BoundedSetTheory InternalBooleanSyntax + +def stepFormula (c B Q S K g t U z0 z1 z2 : ℕ) : Formula := + .disj (.conj (.member U S) (.orderedPair t z0 U)) + (.disj + (.existsMem K (.existsMem (B+1) + (.conj (.orderedPair (t+2) (z1+2) 1) + (.conj (.pairMem 1 0 (g+2)) (negFormula (c+2) 0 (U+2)))))) + (.existsMem K (.existsMem (Q+1) + (.conj (.orderedPair (t+2) (z2+2) 1) + (.conj (supFormula (c+2) 0 (U+2)) + (.conj (.allMem 1 (.existsMem 1 (.pairMem 1 0 (g+4)))) + (.allMem 0 (.existsMem 2 (.pairMem 0 1 (g+4)))))))))) + +theorem stepFormula_spec (c B Q S K g t U z0 z1 z2 : ℕ) (e : ℕ → ZFSet.{0}) + (h0 : e z0 = natSet 0) (h1 : e z1 = natSet 1) (h2 : e z2 = natSet 2) : + (stepFormula c B Q S K g t U z0 z1 z2).Eval e ↔ + Step (e c) (e B) (e Q) (e S) (e K) (e g) (e t) (e U) := by + simp only [stepFormula,Formula.eval_disj,Formula.Eval,Formula.eval_orderedPair, + Formula.eval_pairMem,Formula.eval_allMem,negFormula_spec,supFormula_spec, + cons_zero,cons_succ,h0,h1,h2,Step,FiniteTerm.tag] + +def certificateFormula (c B Q S K g z0 z1 z2 : ℕ) : Formula := + .allMem g (.existsMem (K+1) (.existsMem (B+2) + (.conj (.orderedPair 2 1 0) + (stepFormula (c+3) (B+3) (Q+3) (S+3) (K+3) (g+3) 1 0 (z0+3) (z1+3) (z2+3))))) + +theorem certificateFormula_spec (c B Q S K g z0 z1 z2 : ℕ) (e : ℕ → ZFSet.{0}) + (h0 : e z0 = natSet 0) (h1 : e z1 = natSet 1) (h2 : e z2 = natSet 2) : + (certificateFormula c B Q S K g z0 z1 z2).Eval e ↔ + Certificate (e c) (e B) (e Q) (e S) (e K) (e g) := by + simp only [certificateFormula,Formula.eval_allMem,Formula.Eval, + Formula.eval_orderedPair,cons_zero,cons_succ,Certificate] + apply forall_congr'; intro z + apply imp_congr_right; intro _ + apply exists_congr; intro t + apply and_congr_right; intro _ + apply exists_congr; intro U + apply and_congr_right; intro _ + apply and_congr_right; intro _ + exact stepFormula_spec _ _ _ _ _ _ _ _ _ _ _ _ h0 h1 h2 + +def Witness (c B Q S K U : ZFSet.{0}) : Prop := + Transitive K ∧ ∃ g ∈ K, Certificate c B Q S K g ∧ + ∃ t ∈ K, ZFSet.pair t U ∈ g + +def witnessFormula (c B Q S K U z0 z1 z2 : ℕ) : Formula := + .conj (.allMem K (.subset 0 (K+1))) + (.existsMem K (.conj + (certificateFormula (c+1) (B+1) (Q+1) (S+1) (K+1) 0 (z0+1) (z1+1) (z2+1)) + (.existsMem (K+1) (.pairMem 0 (U+2) 1)))) + +theorem witnessFormula_spec (c B Q S K U z0 z1 z2 : ℕ) (e : ℕ → ZFSet.{0}) + (h0 : e z0 = natSet 0) (h1 : e z1 = natSet 1) (h2 : e z2 = natSet 2) : + (witnessFormula c B Q S K U z0 z1 z2).Eval e ↔ + Witness (e c) (e B) (e Q) (e S) (e K) (e U) := by + simp only [witnessFormula,Formula.Eval,Formula.eval_allMem,Formula.eval_subset, + Formula.eval_pairMem,cons_zero,cons_succ,Witness,TransitiveNameModel.Transitive] + apply and_congr Iff.rfl + apply exists_congr; intro g + apply and_congr_right; intro _ + exact and_congr (certificateFormula_spec _ _ _ _ _ _ _ _ _ _ h0 h1 h2) Iff.rfl + +def parameters (c B Q S : ZFSet.{0}) : ℕ → ZFSet.{0} := + cons c (cons B (cons Q (cons S (cons (natSet 0) (cons (natSet 1) (fun _ => natSet 2)))))) + +theorem parameters_mem (M c B Q S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : B ∈ M) (hQ : Q ∈ M) (hS : S ∈ M) : + ∀ i, parameters c B Q S i ∈ M := by + intro i + rcases i with _|_|_|_|_|_|i + exact hc; exact hB; exact hQ; exact hS + all_goals exact hM _ (sourceT_omega_mem M hM hT) _ ((mem_omega _).mpr ⟨_,rfl⟩) + +def witnessBody : Formula := witnessFormula 2 3 4 5 0 1 6 7 8 + +theorem witnessBody_realize (M c B Q S K U : ZFSet.{0}) (hM : Transitive M) + (he : ∀ i, parameters c B Q S i ∈ M) (hK : K ∈ M) (hU : U ∈ M) : + witnessBody.Realize M (cons K (cons U (parameters c B Q S))) ↔ Witness c B Q S K U := by + rw [Formula.absolute _ M hM _ (by + intro i; rcases i with _|_|i; exact hK; exact hU; exact he i)] + exact witnessFormula_spec _ _ _ _ _ _ _ _ _ _ rfl rfl rfl + +noncomputable def certified (M c B Q S : ZFSet.{0}) : ZFSet.{0} := + B.sep (fun U => ∃ K ∈ M, Witness c B Q S K U) + +theorem certified_mem (M c B Q S : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hB : B ∈ M) (hQ : Q ∈ M) (hS : S ∈ M) : certified M c B Q S ∈ M := by + have he := parameters_mem M c B Q S hM hT hc hB hQ hS + obtain ⟨a,ha,hspec⟩ := hT.separation.finitePrefix + (.existsSet (.bounded witnessBody)) (parameters c B Q S) he B hB + have eq : a = certified M c B Q S := by + apply ZFSet.ext; intro U + rw [certified,ZFSet.mem_sep] + constructor + · intro hU + obtain ⟨hUB,K,hKM,hK⟩ := (hspec U (hM _ ha _ hU)).mp hU + exact ⟨hUB,K,hKM,(witnessBody_realize M c B Q S K U hM he hKM (hM _ hB _ hUB)).mp hK⟩ + · rintro ⟨hUB,K,hKM,hK⟩ + have hUM := hM _ hB _ hUB + exact (hspec U hUM).mpr ⟨hUB,K,hKM,(witnessBody_realize M c B Q S K U hM he hKM hUM).mpr hK⟩ + exact eq ▸ ha + +end TuringRigidity.BooleanExpressionCertificate + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionTruth.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionTruth.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b75661827480cbb3d09930cbd6cca386d8a4357 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanExpressionTruth.lean @@ -0,0 +1,109 @@ +import OAI.Computability.DegreeRigidity.Syntax.BooleanExpressionCoverage +import OAI.Computability.DegreeRigidity.Syntax.BoundedTruthRecursion + +namespace OAI + +namespace TuringRigidity.BooleanExpressionTruth +open TransitiveNameModel BoundedSetTheory + +theorem rankWF : WellFounded (fun a b : ZFSet.{0} => ZFSet.rank a < ZFSet.rank b) := + InvImage.wf ZFSet.rank Ordinal.lt_wf + +def body (B R t : ZFSet.{0}) (rec : ∀ s : ZFSet.{0}, ZFSet.rank s < ZFSet.rank t → Prop) : Prop := + (∃ U ∈ B, t = FiniteTerm.tag 0 U ∧ U ∈ R) ∨ + (∃ s, ∃ h : t = FiniteTerm.tag 1 s, + ¬ rec s (by rw [h]; exact FiniteTerm.pair_rank_right _ _)) ∨ + (∃ T, ∃ h : t = FiniteTerm.tag 2 T, ∃ s, ∃ hs : s ∈ T, + rec s (by rw [h]; exact (ZFSet.rank_lt_of_mem hs).trans (FiniteTerm.pair_rank_right _ _))) + +noncomputable def value (B R : ZFSet.{0}) : ZFSet.{0} → Prop := rankWF.fix (body B R) + +theorem value_unfold (B R t : ZFSet.{0}) : value B R t ↔ + (∃ U ∈ B, t = FiniteTerm.tag 0 U ∧ U ∈ R) ∨ + (∃ s, t = FiniteTerm.tag 1 s ∧ ¬ value B R s) ∨ + (∃ T, t = FiniteTerm.tag 2 T ∧ ∃ s ∈ T, value B R s) := by + change rankWF.fix (body B R) t ↔ _ + rw [WellFounded.fix_eq] + simp only [body,value,exists_prop] + +theorem payload_mem (D : ZFSet.{0}) (hD : Transitive D) (n : ℕ) (s : ZFSet.{0}) + (ht : FiniteTerm.tag n s ∈ D) : s ∈ D := by + have hp := hD _ ht _ (ZFSet.mem_pair.mpr (Or.inr rfl)) + exact hD _ hp _ (ZFSet.mem_pair.mpr (Or.inr rfl)) + +def step (K B R Y t : ZFSet.{0}) : Prop := + (∃ U ∈ B, t = FiniteTerm.tag 0 U ∧ U ∈ R) ∨ + (∃ s ∈ K, t = FiniteTerm.tag 1 s ∧ s ∉ Y) ∨ + (∃ T ∈ K, t = FiniteTerm.tag 2 T ∧ ∃ s ∈ T, s ∈ Y) + +def formula : Formula := + .disj (.existsMem 3 (.conj (.orderedPair 1 6 0) (.member 0 5))) + (.disj (.existsMem 2 (.conj (.orderedPair 1 7 0) (.neg (.member 0 2)))) + (.existsMem 2 (.conj (.orderedPair 1 8 0) (.existsMem 0 (.member 0 3))))) + +def parameters (K B R : ZFSet.{0}) : ℕ → ZFSet.{0} := + cons K (cons B (cons R (cons (natSet 0) (cons (natSet 1) (fun _ => natSet 2))))) + +theorem formula_spec (K B R Y t : ZFSet.{0}) : + formula.Eval (cons t (cons Y (parameters K B R))) ↔ step K B R Y t := by + simp only [formula,Formula.eval_disj,Formula.Eval,Formula.eval_orderedPair, + parameters,cons_zero,cons_succ,step,FiniteTerm.tag] + +theorem formula_local (K B R : ZFSet.{0}) : BoundedTruthRecursion.Local formula (parameters K B R) := by + intro D hD t ht Y Z ha + rw [formula_spec,formula_spec] + apply or_congr Iff.rfl + apply or_congr + · apply exists_congr; intro s + apply and_congr_right; intro _ + apply and_congr_right; intro he + have hsD := payload_mem D hD 1 s (he ▸ ht) + have hlt : ZFSet.rank s < ZFSet.rank t := by rw [he]; exact FiniteTerm.pair_rank_right _ _ + exact not_congr (ha s hsD hlt) + · apply exists_congr; intro T + apply and_congr_right; intro _ + apply and_congr_right; intro he + have hTD := payload_mem D hD 2 T (he ▸ ht) + apply exists_congr; intro s + apply and_congr_right; intro hs + have hlt : ZFSet.rank s < ZFSet.rank t := by + rw [he]; exact (ZFSet.rank_lt_of_mem hs).trans (FiniteTerm.pair_rank_right _ _) + exact ha s (hD T hTD s hs) hlt + +noncomputable def valueSet (K B R : ZFSet.{0}) : ZFSet.{0} := K.sep (value B R) + +theorem valueSet_fixed (K B R : ZFSet.{0}) (hK : Transitive K) : + ∀ t ∈ K, t ∈ valueSet K B R ↔ formula.Eval (cons t (cons (valueSet K B R) (parameters K B R))) := by + intro t ht + rw [valueSet,ZFSet.mem_sep,and_iff_right ht,value_unfold,formula_spec] + apply or_congr Iff.rfl + apply or_congr + · constructor + · rintro ⟨s,he,hs⟩ + have hsK := payload_mem K hK 1 s (he ▸ ht) + exact ⟨s,hsK,he,fun h => hs (ZFSet.mem_sep.mp h).2⟩ + · rintro ⟨s,hsK,he,hs⟩ + exact ⟨s,he,fun hv => hs (ZFSet.mem_sep.mpr ⟨hsK,hv⟩)⟩ + · constructor + · rintro ⟨T,he,s,hs,hv⟩ + have hTK := payload_mem K hK 2 T (he ▸ ht) + exact ⟨T,hTK,he,s,hs,ZFSet.mem_sep.mpr ⟨hK T hTK s hs,hv⟩⟩ + · rintro ⟨T,_,he,s,hs,hv⟩ + exact ⟨T,he,s,hs,(ZFSet.mem_sep.mp hv).2⟩ + +theorem valueSet_mem (N K B R : ZFSet.{0}) (hN : Transitive N) (hT : SourceT N) + (hKN : K ∈ N) (hK : Transitive K) (hB : B ∈ N) (hR : R ∈ N) : valueSet K B R ∈ N := by + have he : ∀ i, parameters K B R i ∈ N := by + intro i; rcases i with _|_|_|_|_|i + exact hKN; exact hB; exact hR + all_goals exact hN _ (sourceT_omega_mem N hN hT) _ ((mem_omega _).mpr ⟨_,rfl⟩) + have hi := BoundedTruthRecursion.truth_internal N K (valueSet K B R) hN hT hKN hK + formula (parameters K B R) he (formula_local K B R) (valueSet_fixed K B R hK) + have eq : K.sep (fun t => t ∈ valueSet K B R) = valueSet K B R := by + apply ZFSet.ext; intro t + simp only [valueSet,ZFSet.mem_sep,and_self_left] + exact eq ▸ hi + +end TuringRigidity.BooleanExpressionTruth + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanFilterReconstruction.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanFilterReconstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..a95c1e8f1e86782d2a58c73c28ec64b34d08f45b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanFilterReconstruction.lean @@ -0,0 +1,131 @@ +import OAI.Computability.DegreeRigidity.Syntax.BooleanEvaluationWitness +import OAI.Computability.DegreeRigidity.Representation.SameRealBooleanFilter + +namespace OAI + +namespace TuringRigidity.BooleanFilterReconstruction +open TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalBooleanSyntax +open InternalBooleanBits InternalBooleanGeneric InternalGeneratedAlgebra InternalProjectedGeneric +open BooleanExpressionCertificate BooleanExpressionTruth +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + codeOrder codePreorder + +theorem witness_bound (M c B Q S A : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hSM : S ∈ M) (hAM : A ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) (hSB : S ⊆ B) + (hA : A ⊆ generated c B Q S) : + ∃ W ∈ M, ∀ U ∈ A, ∃ K ∈ W, Witness c B Q S K U := by + have he := parameters_mem M c B Q S hM hT hc hBM hQM hSM + have hColl := sigma_collection M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix hT.replacement.finitePrefix hT.infinity hT.choice + obtain ⟨W,hWM,hW⟩ := hColl (.bounded witnessBody) (BooleanExpressionCertificate.parameters c B Q S) he A hAM (by + intro U hU + obtain ⟨K,hKM,hK⟩ := generated_certificate M c B Q S U hM hT hc hBM hQM hSM hB hQ hSB (hA hU) + exact ⟨K,hKM,(witnessBody_realize M c B Q S K U hM he hKM (hM A hAM U hU)).mpr hK⟩) + refine ⟨W,hWM,?_⟩ + intro U hU + obtain ⟨K,hKW,hK⟩ := hW U hU + exact ⟨K,hKW,(witnessBody_realize M c B Q S K U hM he (hM W hWM K hKW) (hM A hAM U hU)).mp hK⟩ + +theorem hit_values_mem (M N c B Q S A W R : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hN : Transitive N) (hTN : SourceT N) + (hc : c ∈ M) (hcN : c ∈ N) (hBN : B ∈ N) (hQN : Q ∈ N) (hSN : S ∈ N) + (hAN : A ∈ N) (hWN : W ∈ N) (hRN : R ∈ N) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) + (hbound : ∀ U ∈ A, ∃ K ∈ W, Witness c B Q S K U) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) + (hseed : ∀ U ∈ S, U ∈ R ↔ Hit G U) : A.sep (Hit G) ∈ N := by + let e := evaluationParameters W c B Q S R + have he : ∀ i, e i ∈ N := by + intro i; rcases i with _|_|_|_|_|_|_|_|i + exact hWN; exact hcN; exact hBN; exact hQN; exact hSN; exact hRN + all_goals exact hN _ (sourceT_omega_mem N hN hTN) _ ((mem_omega _).mpr ⟨_,rfl⟩) + have spec (U : ZFSet.{0}) (hUA : U ∈ A) : + (∃ Y ∈ N, evaluationBody.Realize N (cons Y (cons U e))) ↔ Hit G U := by + constructor + · rintro ⟨Y,hYN,hbody⟩ + obtain ⟨K,_,hK,hy,g,_,hg,t,htK,hp,htY⟩ := + (evaluationBody_realize N W c B Q S R Y U hN he hYN (hN A hAN U hUA)).mp hbody + have hv := (hy.agrees hK t htK).mp htY + exact (certificate_value M c B Q S K g R hM hT hc hB hQ hg G hG hseed t U hp).mp hv + · intro hhit + obtain ⟨K,hKW,hK,g,hgK,hg,t,htK,hp⟩ := hbound U hUA + have hKN := hN W hWN K hKW + have hYN := valueSet_mem N K B R hN hTN hKN hK hBN hRN + have hv := (certificate_value M c B Q S K g R hM hT hc hB hQ hg G hG hseed t U hp).mpr hhit + refine ⟨valueSet K B R,hYN, + (evaluationBody_realize N W c B Q S R _ U hN he hYN (hN A hAN U hUA)).mpr ?_⟩ + exact ⟨K,hKW,hK,valueSet_good K B R hK,g,hgK,hg,t,htK,hp,ZFSet.mem_sep.mpr ⟨htK,hv⟩⟩ + obtain ⟨a,ha,hspec⟩ := hTN.separation.finitePrefix (.existsSet (.bounded evaluationBody)) e he A hAN + have eq : a = A.sep (Hit G) := by + apply ZFSet.ext; intro U + constructor + · intro hU + obtain ⟨hUA,hbody⟩ := (hspec U (hN a ha U hU)).mp hU + exact ZFSet.mem_sep.mpr ⟨hUA,(spec U hUA).mp hbody⟩ + · intro hU + obtain ⟨hUA,hhit⟩ := ZFSet.mem_sep.mp hU + exact (hspec U (hN A hAN U hUA)).mpr ⟨hUA,(spec U hUA).mpr hhit⟩ + exact eq ▸ ha + +theorem projected_filter_eq_hits (M c B Q A : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) (hBM : B ∈ M) (hAM : A ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) (hA : Closed c B Q A) + (G : GenericFilter (Conditions c)) : + genericFilterSet (positive A) (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier = + A.sep (Hit G) := by + apply ZFSet.ext; intro U + rw [mem_genericFilterSet,ZFSet.mem_sep] + constructor + · rintro ⟨q,hq,rfl⟩ + exact ⟨(ZFSet.mem_sep.mp (label_mem (positive A) q)).1,hq⟩ + · rintro ⟨hUA,p,hp,hpU⟩ + have hU0 : U ≠ ∅ := fun he => ZFSet.notMem_empty _ (he ▸ hpU) + obtain ⟨q,hq⟩ := label_surjective (positive A) (ZFSet.mem_sep.mpr ⟨hUA,hU0⟩) + refine ⟨q,?_,hq⟩ + change Hit G (label (positive A) q) + rw [hq] + exact ⟨p,hp,hpU⟩ + +theorem projected_filter_mem_from_real (M N c B Q A : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hN : Transitive N) (hTN : SourceT N) (hMN : M ⊆ N) + (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hAM : A ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) (hA : Closed c B Q A) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) + (hAe : A = generated c B Q (seeds c B E)) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (hGt : ⊤ ∈ G.carrier) + (hX : (InternalNiceName.nice E : RecursiveNames.Name (Conditions c)).val G.carrier ∈ N) : + genericFilterSet (positive A) (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier ∈ N := by + have hSM := seeds_mem M c B hM hT hc hBM E hE hgraph + obtain ⟨W,hWM,hbound⟩ := witness_bound M c B Q (seeds c B E) A hM hT hc hBM hQM hSM hAM hB hQ + (fun _ h => (ZFSet.mem_sep.mp h).1) (fun _ h => hAe ▸ h) + have hRN := seedTruth_mem N c B hN hTN (hMN hc) (hMN hBM) E + (fun n => ⟨hMN (hE n).1,(hE n).2⟩) (hMN hgraph) _ hX + rw [projected_filter_eq_hits M c B Q A hM hT hc hBM hAM hB hQ hA G] + exact hit_values_mem M N c B Q (seeds c B E) A W _ hM hT hN hTN hc (hMN hc) (hMN hBM) + (hMN hQM) (hMN hSM) (hMN hAM) (hMN hWM) hRN hB hQ hbound G hG + (fun U hU => seedTruth_hit M c B hM hT hc E hE G hG hGt U hU) + +theorem projected_extension_least_for_real (M N c B Q A : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hN : Transitive N) (hTN : SourceT N) (hMN : M ⊆ N) + (hc : c ∈ M) (hBM : B ∈ M) (hQM : Q ∈ M) (hAM : A ∈ M) + (hB : ∀ V, V ∈ B ↔ V ∈ M ∧ IsCode c V) + (hQ : ∀ a, a ∈ Q ↔ a ∈ M ∧ a ⊆ B) (hA : Closed c B Q A) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ M) + (hAe : A = generated c B Q (seeds c B E)) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) (hGt : ⊤ ∈ G.carrier) + (hX : (InternalNiceName.nice E : RecursiveNames.Name (Conditions c)).val G.carrier ∈ N) : + genericExtensionSet M (positive A) + (projected M c B Q A hM hT hc hBM hAM hB hQ hA G).carrier ⊆ N := by + apply InternalNameEvaluation.extension_subset M N hN hTN hMN + exact projected_filter_mem_from_real M N c B Q A hM hT hN hTN hMN hc hBM hQM hAM hB hQ hA + E hE hgraph hAe G hG hGt hX + +end TuringRigidity.BooleanFilterReconstruction + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanProjection.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..070535c19006009ee0bdda165744843b00e72071 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanProjection.lean @@ -0,0 +1,110 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.ForcingProjection +import Mathlib.Order.CompleteSublattice +import Mathlib.Order.CompleteBooleanAlgebra +import Mathlib.Data.Set.Countable + +namespace OAI + +namespace TuringRigidity.BooleanProjection +open Set CountableForcing ForcingProjection +universe u +variable {B : Type u} [CompleteBooleanAlgebra B] + +noncomputable def project (A : CompleteSublattice B) (b : B) : B := + sInf {a | a ∈ A ∧ b ≤ a} + +theorem project_mem (A : CompleteSublattice B) (b : B) : project A b ∈ A := + A.sInfClosed (fun _ h => h.1) + +theorem le_project (A : CompleteSublattice B) (b : B) : b ≤ project A b := + le_sInf (fun _ h => h.2) + +theorem project_le_iff (A : CompleteSublattice B) (b a : B) (ha : a ∈ A) : + project A b ≤ a ↔ b ≤ a := + ⟨fun h => (le_project A b).trans h,fun h => sInf_le ⟨ha,h⟩⟩ + +theorem project_fixed (A : CompleteSublattice B) (a : B) (ha : a ∈ A) : + project A a = a := + le_antisymm ((project_le_iff A a a ha).mpr le_rfl) (le_project A a) + +theorem project_mono (A : CompleteSublattice B) : Monotone (project A) := by + intro b c hbc + exact (project_le_iff A b _ (project_mem A c)).mpr (hbc.trans (le_project A c)) + +theorem project_bot (A : CompleteSublattice B) : project A ⊥ = ⊥ := + project_fixed A ⊥ A.bot_mem + +theorem project_nonzero (A : CompleteSublattice B) {b : B} (hb : b ≠ ⊥) : + project A b ≠ ⊥ := by + intro h + exact hb (le_bot_iff.mp (h ▸ le_project A b)) + +theorem project_inf (A : CompleteSublattice B) + (hcompl : ∀ a ∈ A, aᶜ ∈ A) (b a : B) (ha : a ∈ A) : + project A (b ⊓ a) = project A b ⊓ a := by + apply le_antisymm + · exact le_inf (project_mono A inf_le_left) ((project_le_iff A _ a ha).mpr inf_le_right) + · let c := project A (b ⊓ a) + have hb : b ≤ c ⊔ aᶜ := by + calc + b = b ⊓ a ⊔ b ⊓ aᶜ := (sup_inf_inf_compl).symm + _ ≤ c ⊔ aᶜ := sup_le_sup (le_project A _) inf_le_right + have hc : c ⊔ aᶜ ∈ A := A.supClosed' (project_mem A _) (hcompl a ha) + have hp : project A b ≤ c ⊔ aᶜ := (project_le_iff A _ _ hc).mpr hb + calc + project A b ⊓ a ≤ (c ⊔ aᶜ) ⊓ a := inf_le_inf_right a hp + _ = c ⊓ a := by rw [inf_sup_right]; simp + _ ≤ c := inf_le_left + +def Positive (B : Type u) [Bot B] := {b : B // b ≠ ⊥} + +instance positiveOrder : PartialOrder (Positive B) := + inferInstanceAs (PartialOrder {b : B // b ≠ ⊥}) + +def PartPositive (A : CompleteSublattice B) := {a : B // a ∈ A ∧ a ≠ ⊥} + +instance partPositiveOrder (A : CompleteSublattice B) : PartialOrder (PartPositive A) := + inferInstanceAs (PartialOrder {a : B // a ∈ A ∧ a ≠ ⊥}) + +noncomputable def forcingProjection (A : CompleteSublattice B) + (hcompl : ∀ a ∈ A, aᶜ ∈ A) : Projection (Positive B) (PartPositive A) where + map b := ⟨project A b.val,project_mem A _,project_nonzero A b.property⟩ + mono := fun _ _ h => project_mono A h + lift := by + intro b a hab + have he : project A (b.val ⊓ a.val) = a.val := by + rw [project_inf A hcompl _ _ a.property.1,inf_eq_right.mpr hab] + have hn : b.val ⊓ a.val ≠ ⊥ := by + intro h + exact a.property.2 (by rw [← he,h,project_bot]) + exact ⟨⟨b.val ⊓ a.val,hn⟩,inf_le_left,he.le⟩ + +theorem forcingProjection_exact (A : CompleteSublattice B) + (hcompl : ∀ a ∈ A, aᶜ ∈ A) (b : Positive B) (a : PartPositive A) + (hab : a ≤ (forcingProjection A hcompl).map b) : + ∃ c, c ≤ b ∧ (forcingProjection A hcompl).map c = a := by + change a.val ≤ project A b.val at hab + have he : project A (b.val ⊓ a.val) = a.val := by + rw [project_inf A hcompl _ _ a.property.1,inf_eq_right.mpr hab] + have hn : b.val ⊓ a.val ≠ ⊥ := by + intro h + exact a.property.2 (by rw [← he,h,project_bot]) + exact ⟨⟨b.val ⊓ a.val,hn⟩,inf_le_left,Subtype.ext he⟩ + +theorem projected_dense (A : CompleteSublattice B) + (hcompl : ∀ a ∈ A, aᶜ ∈ A) (D : Set (Positive B)) (hD : Dense D) : + Dense ((forcingProjection A hcompl).map '' D) := by + intro a + obtain ⟨b,hba,hbD⟩ := hD ⟨a.val,a.property.2⟩ + refine ⟨(forcingProjection A hcompl).map b,?_,b,hbD,rfl⟩ + exact (project_le_iff A b.val a.val a.property.1).mpr hba + +theorem projected_countable_dense (A : CompleteSublattice B) + (hcompl : ∀ a ∈ A, aᶜ ∈ A) (D : Set (Positive B)) + (hc : D.Countable) (hd : Dense D) : + ∃ E : Set (PartPositive A), E.Countable ∧ Dense E := + ⟨(forcingProjection A hcompl).map '' D,hc.image _,projected_dense A hcompl D hd⟩ + +end TuringRigidity.BooleanProjection + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanTruthReading.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanTruthReading.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb66c237e07f48db3ec9e5f0fba2fd1bda47229b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BooleanTruthReading.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DegreeRigidity.Syntax.BooleanExpressionTruth + +namespace OAI + +namespace TuringRigidity.BooleanExpressionTruth +open TransitiveNameModel BoundedSetTheory CountableForcing +open InternalRegularOperations InternalRegularAlgebra InternalBooleanBits InternalBooleanGeneric +open BooleanExpressionCertificate +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + +theorem value_seed (B R U : ZFSet.{0}) (hU : U ∈ B) : + value B R (FiniteTerm.tag 0 U) ↔ U ∈ R := by + rw [value_unfold] + simp [FiniteTerm.tag_inj,hU] + +theorem value_neg (B R t : ZFSet.{0}) : + value B R (FiniteTerm.tag 1 t) ↔ ¬ value B R t := by + rw [value_unfold] + simp [FiniteTerm.tag_inj] + +theorem value_sup (B R T : ZFSet.{0}) : + value B R (FiniteTerm.tag 2 T) ↔ ∃ t ∈ T, value B R t := by + rw [value_unfold] + simp [FiniteTerm.tag_inj] + +theorem certificate_value (M c B Q S K g R : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) + (hB : ∀ U, U ∈ B ↔ U ∈ M ∧ IsCode c U) + (hQ : ∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ B) + (hg : Certificate c B Q S K g) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) + (hseed : ∀ U ∈ S, U ∈ R ↔ Hit G U) + (t U : ZFSet.{0}) (hp : ZFSet.pair t U ∈ g) : value B R t ↔ Hit G U := by + induction t using rankWF.induction generalizing U with + | h t ih => + have hUB := (hg.step hp).2.1 + rcases (hg.step hp).2.2 with hs | hs | hs + · obtain ⟨hUS,rfl⟩ := hs + exact (value_seed B R U hUB).trans (hseed U hUS) + · obtain ⟨s,_,V,hVB,rfl,hchild,rfl⟩ := hs + obtain ⟨hVM,hVc⟩ := (hB V).mp hVB + rw [value_neg,hit_complement_iff M c V hM hT hc hVM hVc G hG, + ih s (FiniteTerm.pair_rank_right _ _) V hchild] + · obtain ⟨T,_,F,hFQ,rfl,rfl,hTF,hFT⟩ := hs + obtain ⟨hFM,hFB⟩ := (hQ F).mp hFQ + rw [value_sup,hit_supCode_iff M c F hM hT hc hFM (fun V hV => ((hB V).mp (hFB hV)).2) G hG] + constructor + · rintro ⟨s,hs,hv⟩ + obtain ⟨V,hVF,hchild⟩ := hTF s hs + exact ⟨V,hVF,(ih s ((ZFSet.rank_lt_of_mem hs).trans (FiniteTerm.pair_rank_right _ _)) V hchild).mp hv⟩ + · rintro ⟨V,hVF,hv⟩ + obtain ⟨s,hs,hchild⟩ := hFT V hVF + exact ⟨s,hs,(ih s ((ZFSet.rank_lt_of_mem hs).trans (FiniteTerm.pair_rank_right _ _)) V hchild).mpr hv⟩ + +noncomputable def seedTruth (c B : ZFSet.{0}) (E : ℕ → ZFSet.{0}) (X : ZFSet.{0}) : ZFSet.{0} := + B.sep (fun U => ∃ n, natSet n ∈ X ∧ U = bitCode c (E n)) + +theorem seedTruth_mem (N c B : ZFSet.{0}) (hN : Transitive N) (hT : SourceT N) + (hc : c ∈ N) (hB : B ∈ N) (E : ℕ → ZFSet.{0}) + (hE : ∀ n, E n ∈ N ∧ E n ⊆ c) (hgraph : orbitGraph E ∈ N) + (X : ZFSet.{0}) (hX : X ∈ N) : seedTruth c B E X ∈ N := by + obtain ⟨Q,hQ,hQdef⟩ := internal_power N hN hT.powerSet hc + let e := cons c (cons ZFSet.omega (cons Q (cons (orbitGraph E) (fun _ => X)))) + have he : ∀ i, e i ∈ N := by + intro i; rcases i with _|_|_|_|i + exact hc; exact sourceT_omega_mem N hN hT; exact hQ; exact hgraph; exact hX + let φ : Formula := .existsMem 2 (.conj (.member 0 6) + (.existsMem 4 (.conj (.pairMem 1 0 6) (bitFormula 3 0 2)))) + have spec (U : ZFSet.{0}) : φ.Eval (cons U e) ↔ ∃ n, natSet n ∈ X ∧ U = bitCode c (E n) := by + simp only [φ,Formula.Eval,Formula.eval_pairMem,bitFormula_spec,e,cons_zero,cons_succ] + constructor + · rintro ⟨n,hn,hnX,V,_,hp,hU⟩ + obtain ⟨n,rfl⟩ := (mem_omega n).mp hn + have hV := (orbitGraph_pair E n V).mp hp + exact ⟨n,hnX,hV ▸ hU⟩ + · rintro ⟨n,hnX,hU⟩ + exact ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,hnX,E n,(hQdef _).mpr (hE n), + (orbitGraph_pair E n _).mpr rfl,hU⟩ + have hs := sep_mem N hN hT.separation.finitePrefix.bounded φ e he hB + simpa only [spec,seedTruth] using hs + +theorem seedTruth_hit (M c B : ZFSet.{0}) [Top (Conditions c)] + (hM : Transitive M) (hT : SourceT M) (hc : c ∈ M) + (E : ℕ → ZFSet.{0}) (hE : ∀ n, E n ∈ M ∧ E n ⊆ c) + (G : GenericFilter (Conditions c)) (hG : AtomicForcing.GroundGeneric M G) + (hGt : ⊤ ∈ G.carrier) (U : ZFSet.{0}) (hUS : U ∈ seeds c B E) : + U ∈ seedTruth c B E ((InternalNiceName.nice E : RecursiveNames.Name (Conditions c)).val G.carrier) ↔ Hit G U := by + constructor + · intro h + obtain ⟨_,n,hn,rfl⟩ := ZFSet.mem_sep.mp h + exact (hit_bit_iff M c hM hT hc E hE G hG hGt n).mpr hn + · intro h + obtain ⟨hUB,n,rfl⟩ := ZFSet.mem_sep.mp hUS + exact ZFSet.mem_sep.mpr ⟨hUB,n,(hit_bit_iff M c hM hT hc E hE G hG hGt n).mp h,rfl⟩ + +end TuringRigidity.BooleanExpressionTruth + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedAutomorphismOutput.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedAutomorphismOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..5e436a1ca8a5e89b3cdfad40233a0b06e9cdb374 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedAutomorphismOutput.lean @@ -0,0 +1,43 @@ +import OAI.Computability.DegreeRigidity.Representation.AutomorphismOutputSentence + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open TransitiveNameModel BoundedSetTheory SetDegreeDecoding PersistentRestrictions +universe u + +def boundedOutputFormula : Formula := + .existsMem 3 (.existsMem 4 (.conj (.member 3 1) + (.conj (.member 4 0) (.pairMem 1 0 2)))) + +theorem boundedOutputFormula_raw (f x y D : ZFSet.{u}) : + boundedOutputFormula.Eval (cons f (cons x (cons y (fun _ => D)))) ↔ + ∃ d ∈ D, ∃ b ∈ D, x ∈ d ∧ y ∈ b ∧ ZFSet.pair d b ∈ f := by + simp only [boundedOutputFormula,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ] + +theorem boundedOutputFormula_spec (I : CountableIdeal) (σ : I ≃o I) + (A : Oracle) (hA : degree A ∈ I.carrier) (y : ZFSet.{u}) : + boundedOutputFormula.Eval + (cons (automorphismSet σ) (cons (realCode A) (cons y (fun _ => idealSet I)))) ↔ + ∃ B : Oracle, realCode B = y ∧ degree B = (σ ⟨degree A,hA⟩).val := by + rw [boundedOutputFormula_raw] + constructor + · rintro ⟨d,_,b,_,had,hbb,hf⟩ + obtain ⟨a,hpair⟩ := (mem_automorphismSet σ _).mp hf + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hpair + have ha : degree A = a.val := (real_mem_degreeSet A a.val).mp had + have ha' : (⟨degree A,hA⟩ : I) = a := Subtype.ext ha + obtain ⟨B,hB,hdeg⟩ := (mem_degreeSet (σ a).val y).mp hbb + exact ⟨B,hB.symm,by rwa [ha']⟩ + · rintro ⟨B,hB,hdeg⟩ + have hi (a : I) : degreeSet.{u} a.val ∈ idealSet I := + (mem_idealSet I _).mpr ⟨a.val,a.property,rfl⟩ + refine ⟨degreeSet (degree A),hi ⟨degree A,hA⟩, + degreeSet (σ ⟨degree A,hA⟩).val,hi (σ ⟨degree A,hA⟩), + (real_mem_degreeSet A _).mpr rfl,?_,?_⟩ + · rw [←hB]; exact (real_mem_degreeSet B _).mpr hdeg + · exact (mem_automorphismSet σ _).mpr ⟨⟨degree A,hA⟩,rfl⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedCertificate.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..0871a4567079c482817bef9b5906796b4c6ced12 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedCertificate.lean @@ -0,0 +1,115 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedSupport + +namespace OAI + + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing +universe u + +namespace CertificateCode + +def slots : ℕ → ℕ → (ℕ → ℕ) → Formula + | 0, d, _v => .equal d d + | n+1, d, v => .conj (slots n d v) (.member (v n) d) + +theorem eval_slots (n d : ℕ) (v : ℕ → ℕ) (env : ℕ → ZFSet.{u}) : + (slots n d v).Eval env ↔ ∀ i, i < n → env (v i) ∈ env d := by + induction n with + | zero => simp [slots,Formula.Eval] + | succ n ih => + simp only [slots,Formula.Eval,ih] + constructor + · rintro ⟨h,hlast⟩ i hi + rcases Nat.lt_succ_iff_lt_or_eq.mp hi with hi|rfl + · exact h i hi + · exact hlast + · intro h; exact ⟨fun i hi => h i (by omega),h n (by omega)⟩ + +def matrix (φ : Formula) (ci oi pi : ℕ) (v : ℕ → ℕ) : Formula := + .conj (.transitive 2) (.conj (AtomicFormula.product 2 1) + (.conj (AtomicFormula.graph 2 (ci+3) 1 (oi+3) 0) + (.conj (slots (bound φ+1) 2 (fun i => v i+3)) + (code φ 2 (ci+3) 1 (oi+3) 0 + (fun i => truncate (bound φ+1) v i+3) (pi+3))))) + +def certificate (φ : Formula) (ci oi pi : ℕ) (v : ℕ → ℕ) : SigmaFormula := + .existsSet (.existsSet (.existsSet (.bounded (matrix φ ci oi pi v)))) +end CertificateCode + +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem eval_certificate_matrix (φ : Formula) (d k f o : ZFSet.{u}) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (e : ℕ → Name (Conditions c)) (p : Conditions c) + (env : ℕ → ZFSet.{u}) (ci oi pi : ℕ) (v : ℕ → ℕ) + (hc : env ci = c) (ho' : env oi = o) (hp : env pi = label c p) + (hv : ∀ i, env (v i) = (e i).encode (label c)) : + (CertificateCode.matrix φ ci oi pi v).Eval (cons f (cons k (cons d env))) ↔ + Transitive d ∧ k = ZFSet.prod d d ∧ Graph d c o f ∧ + (∀ i, i < bound φ+1 → (e i).encode (label c) ∈ d) ∧ Forces e φ p := by + have query (hd : Transitive d) (hk : k = ZFSet.prod d d) (hf : Graph d c o f) + (hs : ∀ i, i < bound φ+1 → (e i).encode (label c) ∈ d) : + (code φ 2 (ci+3) 1 (oi+3) 0 + (fun i => truncate (bound φ+1) v i+3) (pi+3)).Eval + (cons f (cons k (cons d env))) ↔ Forces e φ p := by + let e' := truncate (bound φ+1) e + have he' (i) : (e' i).encode (label c) ∈ d := by + dsimp only [e',truncate] + split + · exact hs i (by assumption) + · exact hs 0 (by omega) + have ht (i) : env (truncate (bound φ+1) v i) = (e' i).encode (label c) := by + dsimp only [e',truncate] + split <;> exact hv _ + exact (eval_code φ hd ho hf e' he' p (cons f (cons k (cons d env))) + 2 (ci+3) 1 (oi+3) 0 (fun i => truncate (bound φ+1) v i+3) (pi+3) + ⟨rfl,hc,hk,ho',rfl,hp⟩ ht).trans + (forces_congr φ e' e (fun i hi => ite_eq_left (by omega)) p) + simp only [CertificateCode.matrix,Formula.Eval,Formula.eval_transitive, + AtomicFormula.eval_product,CertificateCode.eval_slots,cons_zero,cons_succ,hv] + constructor + · rintro ⟨hd,hk,hgraph,hs,hquery⟩ + have hf : Graph d c o f := by + have h := (AtomicFormula.eval_graph 2 (ci+3) 1 (oi+3) 0 _ hk).mp hgraph + simpa only [cons_zero,cons_succ,hc,ho'] using h + exact ⟨hd,hk,hf,hs,(query hd hk hf hs).mp hquery⟩ + · rintro ⟨hd,hk,hf,hs,hq⟩ + refine ⟨hd,hk,?_,hs,(query hd hk hf hs).mpr hq⟩ + apply (AtomicFormula.eval_graph 2 (ci+3) 1 (oi+3) 0 _ hk).mpr + simpa only [cons_zero,cons_succ,hc,ho'] using hf + +theorem realize_boundedCertificate (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) + {o : ZFSet.{u}} + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (φ : Formula) (e : ℕ → Name (Conditions c)) (p : Conditions c) + (env : ℕ → ZFSet.{u}) (henv : ∀ i, env i ∈ M) + (ci oi pi : ℕ) (v : ℕ → ℕ) + (hc : env ci = c) (ho' : env oi = o) (hp : env pi = label c p) + (hv : ∀ i, env (v i) = (e i).encode (label c)) : + (CertificateCode.certificate φ ci oi pi v).Realize M env ↔ Forces e φ p := by + have matrix (d k f : ZFSet.{u}) (hd : d ∈ M) (hk : k ∈ M) (hf : f ∈ M) := + (Formula.absolute (CertificateCode.matrix φ ci oi pi v) M hM + (cons f (cons k (cons d env))) (by + intro i; rcases i with _|i; exact hf + rcases i with _|i; exact hk + rcases i with _|i; exact hd + exact henv i)).trans (eval_certificate_matrix φ d k f o ho e p env ci oi pi v hc ho' hp hv) + change (∃ d ∈ M, ∃ k ∈ M, ∃ f ∈ M, _) ↔ _ + constructor + · rintro ⟨d,hd,k,hk,f,hf,hm⟩ + exact ((matrix d k f hd hk hf).mp hm).2.2.2.2 + · intro hforce + have he (i) : (e i).encode (label c) ∈ M := hv i ▸ henv (v i) + obtain ⟨d,hd,hdT,_,hs⟩ := finite_container M hM hP hU hS hR hI + (fun i => (e i).encode (label c)) he (bound φ+1) + have hk := product_mem M hM hP hU hPow hS hd hd + obtain ⟨f,hf,hfG⟩ := internal_atomic_graph M hM hP hU hPow hS hd + (hc ▸ henv ci) (ho' ▸ henv oi) + exact ⟨d,hd,_,hk,f,hf,(matrix d _ f hd hk hf).mpr ⟨hdT,rfl,hfG,hs,hforce⟩⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedDecoding.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedDecoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..abe30bd22db8cca5c9bc404a45c569bc42770b26 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedDecoding.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.SetModels.RelationCoding + +namespace OAI + +namespace TuringRigidity.BoundedDecoding +open AntichainParameters SetCoding RelationCoding + +def AntichainBelow (p : AntichainCode) (y : Degree) : Prop := + p.bound ≤ y ∧ p.left ≤ y ∧ p.right ≤ y + +def LocalNontrivial (y b g₀ g₁ x : Degree) : Prop := + x ≤ b ∧ ∃ z : Degree, z ≤ y ∧ z ≤ g₀ ⊔ x ∧ z ≤ g₁ ⊔ x ∧ ¬ z ≤ x + +def LocalAntichain (y : Degree) (p : AntichainCode) (x : Degree) : Prop := + LocalNontrivial y p.bound p.left p.right x ∧ + ∀ w : Degree, w ≤ y → LocalNontrivial y p.bound p.left p.right w → + w ≤ x → x ≤ w + +theorem local_nontrivial_iff (y b g₀ g₁ x : Degree) (hb : b ≤ y) (hg₀ : g₀ ≤ y) : + LocalNontrivial y b g₀ g₁ x ↔ NontrivialCommonLower b g₀ g₁ x := by + constructor + · rintro ⟨hx, z, _, hz₀, hz₁, hn⟩ + exact ⟨hx, z, hz₀, hz₁, hn⟩ + · rintro ⟨hx, z, hz₀, hz₁, hn⟩ + exact ⟨hx, z, hz₀.trans (sup_le hg₀ (hx.trans hb)), hz₀, hz₁, hn⟩ + +theorem local_antichain_iff (y : Degree) (p : AntichainCode) (hp : AntichainBelow p y) + (x : Degree) : LocalAntichain y p x ↔ p.Holds x := by + unfold LocalAntichain AntichainCode.Holds CodedAntichain + simp only [local_nontrivial_iff y p.bound p.left p.right _ hp.1 hp.2.1] + constructor + · rintro ⟨hx, hmin⟩ + exact ⟨hx, fun w hw hle => hmin w (hw.1.trans hp.1) hw hle⟩ + · rintro ⟨hx, hmin⟩ + exact ⟨hx, fun w _ hw hle => hmin w hw hle⟩ + +def SetBelow (p : SetCode) (y : Degree) : Prop := + p.bound ≤ y ∧ AntichainBelow p.tags y ∧ AntichainBelow p.decorated y + +def LocalGraph (y : Degree) (p : SetCode) (x c : Degree) : Prop := + x ≤ p.bound ∧ LocalAntichain y p.tags c ∧ LocalAntichain y p.decorated (x ⊔ c) + +def LocalSet (y : Degree) (p : SetCode) (x : Degree) : Prop := + ∃ c : Degree, c ≤ y ∧ LocalGraph y p x c + +theorem local_graph_iff (y : Degree) (p : SetCode) (hp : SetBelow p y) (x c : Degree) : + LocalGraph y p x c ↔ p.Graph x c := by + simp only [LocalGraph, SetCode.Graph, local_antichain_iff y p.tags hp.2.1, + local_antichain_iff y p.decorated hp.2.2] + +theorem graph_bounded {y : Degree} {p : SetCode} (hp : SetBelow p y) + {x c : Degree} (h : p.Graph x c) : x ≤ y ∧ c ≤ y := + ⟨h.1.trans hp.1, h.2.1.1.1.trans hp.2.1.1⟩ + +theorem local_set_iff (y : Degree) (p : SetCode) (hp : SetBelow p y) (x : Degree) : + LocalSet y p x ↔ p.Holds x := by + simp only [LocalSet, local_graph_iff y p hp, SetCode.Holds] + exact ⟨fun ⟨c, _, hc⟩ => ⟨c, hc⟩, fun ⟨c, hc⟩ => ⟨c, (graph_bounded hp hc).2, hc⟩⟩ + +def RelationBelow {n : ℕ} (p : RelationCode n) (y : Degree) : Prop := + (∀ i, SetBelow (p.coordinates i) y) ∧ AntichainBelow p.tuples y + +def LocalRelation {n : ℕ} (y : Degree) (p : RelationCode n) (v : Fin n → Degree) : Prop := + ∃ c : Fin n → Degree, (∀ i, c i ≤ y ∧ LocalGraph y (p.coordinates i) (v i) (c i)) ∧ + LocalAntichain y p.tuples (Finset.univ.sup c) + +theorem local_relation_iff {n : ℕ} (y : Degree) (p : RelationCode n) + (hp : RelationBelow p y) (v : Fin n → Degree) : + LocalRelation y p v ↔ p.Holds v := by + unfold LocalRelation RelationCode.Holds + simp only [local_antichain_iff y p.tuples hp.2, local_graph_iff y _ (hp.1 _)] + constructor + · rintro ⟨c, hc, ht⟩ + exact ⟨c, fun i => (hc i).2, ht⟩ + · rintro ⟨c, hc, ht⟩ + exact ⟨c, fun i => ⟨(graph_bounded (hp.1 i) (hc i)).2, hc i⟩, ht⟩ + +end TuringRigidity.BoundedDecoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedDefinability.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedDefinability.lean new file mode 100644 index 0000000000000000000000000000000000000000..100eda631a4f516ba7c605fede9bfb7c25c786cb --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedDefinability.lean @@ -0,0 +1,153 @@ +import OAI.Computability.DegreeRigidity.SetModels.SetModelFunctionGraphs + +namespace OAI + +namespace TuringRigidity.BoundedDefinability +open BoundedSetTheory TransitiveNameModel SetModelReals SetModelFunctions +universe u +noncomputable section + +def mix (e d : ℕ → ZFSet.{u}) (n : ℕ) : ZFSet.{u} := + if n % 2 = 0 then e (n/2) else d (n/2) + +@[simp] theorem mix_even (e d : ℕ → ZFSet.{u}) (n : ℕ) : mix e d (2*n) = e n := by + simp [mix] + +@[simp] theorem mix_odd (e d : ℕ → ZFSet.{u}) (n : ℕ) : mix e d (2*n+1) = d n := by + simp [mix,Nat.add_div] + +theorem parity_ext {α : Sort*} {f g : ℕ → α} (he : ∀ n, f (2*n) = g (2*n)) + (ho : ∀ n, f (2*n+1) = g (2*n+1)) : f = g := by + funext n + have hm : n%2 < 2 := Nat.mod_lt n (by decide) + by_cases h : n%2=0 + · have hn : n=2*(n/2) := by omega + rw [hn] + exact he _ + · have hn : n=2*(n/2)+1 := by omega + rw [hn] + exact ho _ + +def slotMap (r s : ℕ → ℕ) (n : ℕ) : ℕ := + if n%2=0 then 2*r (n/2) else 2*s (n/2)+1 + +@[simp] theorem slotMap_even (r s : ℕ → ℕ) (n : ℕ) : slotMap r s (2*n) = 2*r n := by + simp [slotMap] +@[simp] theorem slotMap_odd (r s : ℕ → ℕ) (n : ℕ) : slotMap r s (2*n+1) = 2*s n+1 := by + simp [slotMap,Nat.add_div] + +@[simp] theorem mix_slotMap (e d : ℕ → ZFSet.{u}) (r s : ℕ → ℕ) : + mix e d ∘ slotMap r s = mix (e ∘ r) (d ∘ s) := by + apply parity_ext <;> intro n <;> simp + +def Definable (M : ZFSet.{u}) (P : (ℕ → ZFSet.{u}) → Prop) : Prop := + ∃ p : Formula, ∃ d : ℕ → ZFSet.{u}, (∀ i, d i ∈ M) ∧ + ∀ e, p.Eval (mix e d) ↔ P e + +variable {M : ZFSet.{u}} {P Q : (ℕ → ZFSet.{u}) → Prop} + +theorem Definable.congr (h : Definable M P) (he : ∀ e, P e ↔ Q e) : Definable M Q := by + obtain ⟨p,d,hd,hp⟩ := h + exact ⟨p,d,hd,fun e => (hp e).trans (he e)⟩ + +theorem Definable.subst (h : Definable M P) (r : ℕ → ℕ) : + Definable M (fun e => P (e ∘ r)) := by + obtain ⟨p,d,hd,hp⟩ := h + refine ⟨p.rename (slotMap r id),d,hd,?_⟩ + intro e + simpa only [Formula.eval_rename_comp,mix_slotMap,Function.comp_id] using hp (e ∘ r) + +theorem Definable.neg (h : Definable M P) : Definable M (fun e => ¬ P e) := by + obtain ⟨p,d,hd,hp⟩ := h + exact ⟨.neg p,d,hd,fun e => not_congr (hp e)⟩ + +theorem Definable.and (hP : Definable M P) (hQ : Definable M Q) : + Definable M (fun e => P e ∧ Q e) := by + obtain ⟨p,d,hd,hp⟩ := hP + obtain ⟨q,c,hc,hq⟩ := hQ + refine ⟨.conj (p.rename (slotMap id (fun i => 2*i))) + (q.rename (slotMap id (fun i => 2*i+1))),mix d c,?_,?_⟩ + · intro i + unfold mix + split <;> first | exact hd _ | exact hc _ + · intro e + simp only [Formula.Eval,Formula.eval_rename_comp,mix_slotMap,Function.comp_id] + have hd' : mix d c ∘ (fun i => 2*i) = d := by funext i; simp + have hc' : mix d c ∘ (fun i => 2*i+1) = c := by funext i; simp + rw [hd',hc',hp,hq] + +def bindSlots (n : ℕ) : ℕ := + if n%2=0 then if n/2=0 then 0 else 2*(n/2-1)+1 else 2*(n/2)+2 + +@[simp] theorem bindSlots_zero : bindSlots 0 = 0 := rfl +@[simp] theorem bindSlots_even_succ (n : ℕ) : bindSlots (2*(n+1)) = 2*n+1 := by + simp [bindSlots] +@[simp] theorem bindSlots_odd (n : ℕ) : bindSlots (2*n+1) = 2*n+2 := by + simp [bindSlots,Nat.add_div] + +theorem bind_mix (x : ZFSet.{u}) (e d : ℕ → ZFSet.{u}) : + cons x (mix e d) ∘ bindSlots = mix (cons x e) d := by + apply parity_ext + · intro n + cases n with + | zero => rfl + | succ n => simp + · intro n + simp [show 2*n+2 = (2*n+1)+1 from by omega] + +theorem Definable.existsMem (h : Definable M P) (i : ℕ) : + Definable M (fun e => ∃ x ∈ e i, P (cons x e)) := by + obtain ⟨p,d,hd,hp⟩ := h + refine ⟨.existsMem (2*i) (p.rename bindSlots),d,hd,?_⟩ + intro e + simp only [Formula.Eval,mix_even,Formula.eval_rename_comp,bind_mix,hp] + +theorem Definable.existsParam (h : Definable M P) {a : ZFSet.{u}} (ha : a ∈ M) : + Definable M (fun e => ∃ x ∈ a, P (cons x e)) := by + obtain ⟨p,d,hd,hp⟩ := h + let r := slotMap id Nat.succ + refine ⟨.existsMem 1 ((p.rename r).rename bindSlots),cons a d,?_,?_⟩ + · intro i + cases i with + | zero => exact ha + | succ i => exact hd i + · intro e + have hd' : cons a d ∘ Nat.succ = d := rfl + simp only [r,Formula.Eval,Formula.eval_rename_comp,bind_mix,mix_slotMap,Function.comp_id,hd',hp, + show mix e (cons a d) 1 = a from rfl] + +theorem equal_definable (C : Context M) (i j : ℕ) : Definable M (fun e => e i = e j) := + ⟨.equal (2*i) (2*j),fun _ => ZFSet.omega,fun _ => C.omega_mem,fun e => by simp [Formula.Eval]⟩ + +theorem member_definable (C : Context M) (i j : ℕ) : Definable M (fun e => e i ∈ e j) := + ⟨.member (2*i) (2*j),fun _ => ZFSet.omega,fun _ => C.omega_mem,fun e => by simp [Formula.Eval]⟩ + +theorem equal_param {a : ZFSet.{u}} (ha : a ∈ M) (i : ℕ) : + Definable M (fun e => e i = a) := + ⟨.equal (2*i) 1,fun _ => a,fun _ => ha,fun e => by simp [Formula.Eval,mix]⟩ + +theorem pairMem_param {a : ZFSet.{u}} (ha : a ∈ M) (i j : ℕ) : + Definable M (fun e => ZFSet.pair (e i) (e j) ∈ a) := + ⟨.pairMem (2*i) (2*j) 1,fun _ => a,fun _ => ha,fun e => by simp [mix]⟩ + +theorem Definable.sep_mem (C : Context M) (h : Definable M P) (e : ℕ → ZFSet.{u}) + (he : ∀ i, e i ∈ M) {a : ZFSet.{u}} (ha : a ∈ M) : + ZFSet.sep (fun x => P (cons x e)) a ∈ M := by + obtain ⟨p,d,hd,hp⟩ := h + let q := p.rename bindSlots + have hm : ∀ i, mix e d i ∈ M := by + intro i + unfold mix + split <;> first | exact he _ | exact hd _ + have hs := BoundedSetTheory.sep_mem M C.transitive C.separation q (mix e d) hm ha + have hh : ZFSet.sep (fun x => q.Eval (cons x (mix e d))) a = + ZFSet.sep (fun x => P (cons x e)) a := by + apply ZFSet.ext + intro x + simp only [ZFSet.mem_sep,q,Formula.eval_rename_comp,bind_mix,hp] + exact hh ▸ hs + +end +end TuringRigidity.BoundedDefinability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedFormulaRename.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedFormulaRename.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f7f82610809874197d6337b17ecea7a0684df40 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedFormulaRename.lean @@ -0,0 +1,13 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteTuple + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +universe u + +@[simp] theorem Formula.eval_rename_comp (p : Formula) (r : ℕ → ℕ) (e : ℕ → ZFSet.{u}) : + (p.rename r).Eval e ↔ p.Eval (e ∘ r) := Formula.eval_rename p r e +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedHierarchyCertificates.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedHierarchyCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..be05672f602b38a7ff4c82d89d27588436a98296 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedHierarchyCertificates.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DegreeRigidity.Constructibility.HierarchyWitnessCollection + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +theorem hierarchy_checked_at_levels (M s d r f : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) + (hs : s ∈ relativeModel M (groundReals M)) + (hd : d ∈ relativeModel M (groundReals M)) + (hr : r ∈ relativeModel M (groundReals M)) + (hf : f ∈ relativeModel M (groundReals M)) + (hg : HierarchyGraph (relativeModel M (groundReals M)) s d r f) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ + ∀ δ : Ordinal.{u}, δ.toZFSet ∈ M → γ ≤ δ → + s ∈ level (groundReals M) δ ∧ d ∈ level (groundReals M) δ ∧ + r ∈ level (groundReals M) δ ∧ f ∈ level (groundReals M) δ ∧ + ZFSet.omega ∈ level (groundReals M) δ ∧ + ZFSet.prod ZFSet.omega ZFSet.omega ∈ level (groundReals M) δ ∧ + (∀ p : SentenceForm, family p ∈ level (groundReals M) δ) ∧ + (∀ p : SentenceForm, supportGraph p ∈ level (groundReals M) δ) ∧ + CheckedHierarchyGraph (level (groundReals M) δ) ZFSet.omega + (ZFSet.prod ZFSet.omega ZFSet.omega) s d r f := by + let R := groundReals M + let N := relativeModel M R + have hR := groundReals_mem M hM hT + have C := ground_relative_context M hM hT + have hRN : R ∈ N := (mem_relativeModel M R R hM hT hR).mpr + (parameter_in_relativeModel M R hM hT) + obtain ⟨B,hB,hbounds,hq,hb⟩ := relative_certificate_bounds M hM hT + obtain ⟨W,hW,hw⟩ := hierarchy_witness_collection C + (relativeModel_sigma_collection M R hM hT hR) hRN hB hq hb hs hd hr hf hg + let e := cons R (cons B (cons W (cons s (cons d (cons r (cons f + (cons ZFSet.omega (fun _ => ZFSet.prod ZFSet.omega ZFSet.omega)))))))) + have he (i : ℕ) (_hi : i < 9) : InRelativeModel M R (e i) := by + apply (mem_relativeModel M R _ hM hT hR).mp + rcases i with _|_|_|_|_|_|_|_|i + · exact hRN + · exact hB + · exact hW + · exact hs + · exact hd + · exact hr + · exact hf + · exact C.omega_mem + · exact C.prod_mem C.omega_mem C.omega_mem + obtain ⟨γ,hγ,hγe⟩ := finite_parameters_in_relative_level M R hM hT e 9 he + refine ⟨γ,hγ,?_⟩ + intro δ hδ hγδ + have hin (i : ℕ) (hi : i < 9) : e i ∈ level R δ := level_mono R hγδ (hγe i hi) + have ht := level_transitive R δ + have hsub : level R δ ⊆ N := fun x hx => + (mem_relativeModel M R x hM hT hR).mpr ⟨δ,hδ,hx⟩ + have hbound := hbounds.between ht hsub (hin 0 (by decide)) (hin 1 (by decide)) + refine ⟨hin 3 (by decide),hin 4 (by decide),hin 5 (by decide),hin 6 (by decide), + hin 7 (by decide),hin 8 (by decide), + (fun p => ht R (hin 0 (by decide)) _ (hq p)), + (fun p => ht B (hin 1 (by decide)) _ (hb p)),hg.1,hg.2.1,?_⟩ + intro x hx v hv hpair + obtain ⟨c,hc,A,hA,v',hv',G,hG,T,hTT,H,hH,Z,hZ,hpair',hstep,hdef⟩ := hw x hx + obtain ⟨v0,_,_,hu⟩ := hg.2.1.2 x hx + have heq : v' = v := (hu v' hv' hpair').trans (hu v hv hpair).symm + subst v' + have hcL := ht W (hin 2 (by decide)) c hc + refine ⟨A,ht c hcL A hA,hstep,R,hin 0 (by decide),B,hin 1 (by decide),hbound, + G,ht c hcL G hG,T,ht c hcL T hTT,H,ht c hcL H hH,Z,ht c hcL Z hZ,hdef⟩ + +theorem relative_hierarchy_recognition_at_levels (M d r f : ZFSet.{u}) + (hM : Transitive M) (hT : SourceT M) + (hd : d ∈ relativeModel M (groundReals M)) + (hr : r ∈ relativeModel M (groundReals M)) + (hf : f ∈ relativeModel M (groundReals M)) + (hg : HierarchyGraph (relativeModel M (groundReals M)) (seed (groundReals M)) d r f) : + ∃ γ : Ordinal.{u}, γ.toZFSet ∈ M ∧ + ∀ δ : Ordinal.{u}, δ.toZFSet ∈ M → γ ≤ δ → + f ∈ level (groundReals M) δ ∧ + ∀ g : ZFSet.{u}, CheckedHierarchyGraph (level (groundReals M) δ) ZFSet.omega + (ZFSet.prod ZFSet.omega ZFSet.omega) (seed (groundReals M)) d r g ↔ g = f := by + have hR := groundReals_mem M hM hT + have hs := seed_mem_collection _ _ (ground_relative_context M hM hT) + (relativeModel_sigma_replacement M _ hM hT hR) + ((mem_relativeModel M _ _ hM hT hR).mpr (parameter_in_relativeModel M _ hM hT)) + obtain ⟨γ,hγ,hγspec⟩ := hierarchy_checked_at_levels M _ d r f hM hT hs hd hr hf hg + refine ⟨γ,hγ,?_⟩ + intro δ hδ hγδ + obtain ⟨_,_,_,hfL,_,_,hfamily,hsupport,hchecked⟩ := hγspec δ hδ hγδ + exact ⟨hfL,fun g => ⟨fun h => (h.sound hfamily hsupport).unique hg, + fun heq => heq ▸ hchecked⟩⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedOmegaGraph.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedOmegaGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..1400a2f69cbf685419975dc9ba81d20b9f6f3241 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedOmegaGraph.lean @@ -0,0 +1,123 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.LimitOmegaCertificates +import OAI.Computability.DegreeRigidity.SetModels.FinitePresentation + +namespace OAI + +namespace TuringRigidity.OrdinalArithmetic +open TransitiveNameModel BoundedSetTheory RelationCollapse ElementaryModel RelativeConstructible OrdinalCoding +universe u + +noncomputable def boundedOmegaNextPairSentence : SentenceForm := + .conj (.ex (.conj (.member 0 2) (.ex (fromBounded (.orderedPair 2 1 0))))) omegaNextPairSentence + +theorem boundedOmegaNextPairSentence_spec (A : ZFSet.{u}) (hA : Transitive A) + (hω : ZFSet.omega.{u} ∈ A) (a : Ordinal.{u}) (ha : Order.IsSuccLimit a) + (haA : a.toZFSet ∈ A) + (hpow : ∀ c < a, (Ordinal.omega0 ^ c).toZFSet ∈ A ∧ OmegaPowerCertificates A c.toZFSet) + (z : ZFSet.{u}) (hz : z ∈ A) : + boundedOmegaNextPairSentence.Sat (A : Set ZFSet) (cons z (fun _ => a.toZFSet)) ↔ + ∃ x ∈ a.toZFSet, z = ZFSet.pair x (omegaNext x) := by + let e := cons z (fun _ => a.toZFSet) + have he (i : ℕ) : e i ∈ A := by cases i; exact hz; exact haA + have hbound : (SentenceForm.ex (.conj (.member 0 2) (.ex (fromBounded (.orderedPair 2 1 0))))).Sat + (A : Set ZFSet) e ↔ ∃ x ∈ a.toZFSet, ∃ y ∈ A, z = ZFSet.pair x y := by + change (∃ x ∈ A, x ∈ a.toZFSet ∧ ∃ y ∈ A, + (fromBounded (.orderedPair 2 1 0)).Sat (A : Set ZFSet) (cons y (cons x e))) ↔ _ + have hp (x y : ZFSet.{u}) (hx : x ∈ A) (hy : y ∈ A) : + (fromBounded (.orderedPair 2 1 0)).Sat (A : Set ZFSet) (cons y (cons x e)) ↔ + z = ZFSet.pair x y := by + rw [bounded_sat,Formula.absolute _ A hA _ (by + intro i; rcases i with _|_|i; exact hy; exact hx; exact he i)] + exact Formula.eval_orderedPair _ _ _ _ + constructor + · rintro ⟨x,hx,hxa,y,hy,h⟩ + exact ⟨x,hxa,y,hy,(hp x y hx hy).mp h⟩ + · rintro ⟨x,hx,y,hy,h⟩ + have hxA := hA _ haA _ hx + exact ⟨x,hxA,hx,y,hy,(hp x y hxA hy).mpr h⟩ + change (_ ∧ omegaNextPairSentence.Sat (A : Set ZFSet) e) ↔ _ + rw [hbound,omegaNextPairSentence_semantics A hA e he] + constructor + · rintro ⟨⟨x,hx,y,hy,hzxy⟩,x',hx',y',hy',k,hk,⟨ho,hks,hzp⟩,hp⟩ + have heq : ZFSet.pair x y = ZFSet.pair x' y' := hzxy.symm.trans hzp + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp heq + have hv := (codePowerAt_sound A hA hω 1 0 _ (by + intro i; rcases i with _|_|_|i + exact hk; exact hy'; exact hx'; exact he i) hp).2 + change y = (Ordinal.omega0 ^ k.rank).toZFSet at hv + have hsucc : k = (x.rank+1).toZFSet := by + rw [Ordinal.toZFSet_add_one,ho.toZFSet_rank_eq,hks] + rw [hsucc,Ordinal.rank_toZFSet] at hv + exact ⟨x,hx,hzxy.trans (congrArg (ZFSet.pair x) hv)⟩ + · rintro ⟨x,hx,hzdef⟩ + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + have hc : c < a := by simpa only [Ordinal.toZFSet_mem_toZFSet_iff] using hc + have hs : c+1 < a := ha.succ_lt hc + have hxA := hA _ haA _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hc) + have hk := hA _ haA _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hs) + obtain ⟨hy,hcert⟩ := hpow (c+1) hs + have hzdef' : z = ZFSet.pair c.toZFSet (Ordinal.omega0 ^ (c+1)).toZFSet := by + simpa only [omegaNext,Ordinal.rank_toZFSet] using hzdef + refine ⟨⟨c.toZFSet,Ordinal.toZFSet_mem_toZFSet_iff.mpr hc,_,hy,hzdef'⟩, + c.toZFSet,hxA,_,hy,(c+1).toZFSet,hk, + ⟨ZFSet.isOrdinal_toZFSet _,Ordinal.toZFSet_add_one c,hzdef'⟩,?_⟩ + apply codePowerAt_of_certificates A hA hω 1 0 _ (fun i => by + rcases i with _|_|_|i; exact hk; exact hy; exact hxA; exact he i) hcert + simp only [cons_zero,cons_succ,Ordinal.rank_toZFSet] + +theorem omega_limit_certificates_at_add_five (R : ZFSet.{u}) (γ a : Ordinal.{u}) + (ha : Order.IsSuccLimit a) (haA : a.toZFSet ∈ level R γ) + (hω : ZFSet.omega.{u} ∈ level R γ) + (hpow : ∀ c < a, (Ordinal.omega0 ^ c).toZFSet ∈ level R γ ∧ + OmegaPowerCertificates (level R γ) c.toZFSet) : + OmegaPowerCertificates (level R (γ+5)) a.toZFSet := by + let A := level R (γ+2) + let f := A.sep (fun z => boundedOmegaNextPairSentence.Sat (A : Set ZFSet) + (cons z (fun _ => a.toZFSet))) + have h02 : γ ≤ γ+2 := le_self_add + have h25 : γ+2 ≤ γ+5 := add_le_add le_rfl (by exact_mod_cast (show (2 : ℕ) ≤ 5 by decide)) + have h05 := h02.trans h25 + have h35 : γ+3 ≤ γ+5 := add_le_add le_rfl (by exact_mod_cast (show (3 : ℕ) ≤ 5 by decide)) + have ha2 := level_mono R h02 haA + have hpow2 (c : Ordinal.{u}) (hc : c < a) : + (Ordinal.omega0 ^ c).toZFSet ∈ A ∧ OmegaPowerCertificates A c.toZFSet := + ⟨level_mono R h02 (hpow c hc).1,(hpow c hc).2.mono (level_mono R h02)⟩ + have hspec := boundedOmegaNextPairSentence_spec A (level_transitive R (γ+2)) + (level_mono R h02 hω) a ha ha2 hpow2 + have hf : f ∈ level R (γ+3) := by + have h := separation_mem_definablePower A boundedOmegaNextPairSentence (fun _ => a.toZFSet) + (fun _ _ => ha2) + change f ∈ definablePower A at h + have h' : f ∈ level R (γ+2+1) := by rw [level_succ]; exact h + simpa only [add_assoc,show (2 : Ordinal.{u})+1=3 by norm_num] using h' + have hexact (z : ZFSet.{u}) : z ∈ f ↔ ∃ x ∈ a.toZFSet, z = ZFSet.pair x (omegaNext x) := by + change z ∈ A.sep _ ↔ _ + rw [ZFSet.mem_sep] + constructor + · rintro ⟨hz,h⟩; exact (hspec z hz).mp h + · rintro ⟨x,hx,rfl⟩ + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + have hc : c < a := by simpa only [Ordinal.toZFSet_mem_toZFSet_iff] using hc + have hy : omegaNext c.toZFSet ∈ level R γ := by + simpa only [omegaNext,Ordinal.rank_toZFSet] using (hpow (c+1) (ha.succ_lt hc)).1 + have hz := orderedPair_mem_level_add_two R γ + (level_transitive R γ _ haA _ (Ordinal.toZFSet_mem_toZFSet_iff.mpr hc)) hy + exact ⟨hz,(hspec _ hz).mpr ⟨_,Ordinal.toZFSet_mem_toZFSet_iff.mpr hc,rfl⟩⟩ + have hr : iterUnion 2 f ∈ level R (γ+5) := by + simpa only [Nat.cast_ofNat,add_assoc,show (3 : Ordinal.{u})+2=5 by norm_num] using + iterUnion_mem_level_add R (γ+3) hf 2 + refine ⟨level_mono R h05 haA,f,level_mono R h35 hf,_,hr, + omegaGraph_of_exact_pairs _ _ f (ZFSet.isOrdinal_toZFSet a) hexact ?_,?_⟩ + · intro x hx + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + rw [Ordinal.rank_toZFSet] + exact level_mono R h05 (hpow c hc).1 + · intro x hx + obtain ⟨c,hc,rfl⟩ := Ordinal.mem_toZFSet_iff.mp hx + obtain ⟨_,g,hg,r,hr,hgraph,hprod⟩ := (hpow (c+1) (ha.succ_lt hc)).2 + exact (hprod c.toZFSet (Ordinal.toZFSet_mem_toZFSet_iff.mpr (lt_add_one c))).mono + (level_mono R h05) + +end TuringRigidity.OrdinalArithmetic + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedRecursive.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedRecursive.lean new file mode 100644 index 0000000000000000000000000000000000000000..6036c7deb233bc82ecd465973b5726297be97e8d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedRecursive.lean @@ -0,0 +1,53 @@ +import OAI.Computability.DegreeRigidity.Effective.UniformOracle + +namespace OAI + +namespace TuringRigidity.BoundedRecursive +open UniformOracle + +def allBelow (f : ℕ → ℕ) (a : ℕ) : ℕ → ℕ + | 0 => 1 + | n+1 => if allBelow f a n = 1 ∧ f (Nat.pair a n) = 1 then 1 else 0 + +theorem allBelow_spec (f : ℕ → ℕ) (a n : ℕ) : + allBelow f a n = 1 ↔ ∀ i < n, f (Nat.pair a i) = 1 := by + induction n with + | zero => simp [allBelow] + | succ n ih => + simp only [allBelow, ite_eq_left_iff, Nat.zero_ne_one, imp_false, not_not, ih] + exact ⟨fun ⟨h, hn⟩ i hi => (Nat.lt_succ_iff_lt_or_eq.mp hi).elim (h i) (fun he => he ▸ hn), + fun h => ⟨fun i hi => h i (Nat.lt_succ_of_lt hi), h n (Nat.lt_succ_self n)⟩⟩ + +theorem allBelow_binary (f : ℕ → ℕ) (a n : ℕ) : allBelow f a n = 0 ∨ allBelow f a n = 1 := by + cases n with + | zero => exact Or.inr rfl + | succ n => unfold allBelow; split <;> simp + +theorem allBelow_recursive {O : Set (ℕ →. ℕ)} {f : ℕ → ℕ} + (hf : Nat.RecursiveIn O (fun n => Part.some (f n))) : + Nat.RecursiveIn O (fun z => Part.some (allBelow f (Nat.unpair z).1 (Nat.unpair z).2)) := by + have harg := total_pair (O := O) (total_primrec (Primrec.fst.comp Primrec.unpair)) + (total_primrec (Primrec.fst.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair)))) + have hval := total_comp hf harg + have hprev := total_primrec (O := O) + (Primrec.snd.comp (Primrec.unpair.comp (Primrec.snd.comp Primrec.unpair))) + have htest := total_primrec (O := O) + (Primrec.ite ((Primrec.eq.comp (Primrec.fst.comp Primrec.unpair) (Primrec.const 1)).and + (Primrec.eq.comp (Primrec.snd.comp Primrec.unpair) (Primrec.const 1))) + (Primrec.const 1) (Primrec.const 0)) + have hstep := total_comp htest (total_pair hprev hval) + have hrec := Nat.RecursiveIn.prec (total_primrec (O := O) (Primrec.const 1)) hstep + apply hrec.of_eq + intro z + generalize hz : Nat.unpair z = v + obtain ⟨a, n⟩ := v + simp only [Nat.unpair_pair, Part.bind_eq_bind] + clear hz + induction n with + | zero => rfl + | succ n ih => + simp only [ih, Part.bind_some, allBelow] + +end TuringRigidity.BoundedRecursive + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedRelations.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedRelations.lean new file mode 100644 index 0000000000000000000000000000000000000000..2818383cea9719e5006717672f6d337ff56c2c3d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedRelations.lean @@ -0,0 +1,91 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelProducts + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +namespace Formula +def imp (φ ψ : Formula) : Formula := disj (.neg φ) ψ +def iff (φ ψ : Formula) : Formula := .conj (imp φ ψ) (imp ψ φ) + +@[simp] theorem eval_imp (φ ψ : Formula) (e : ℕ → ZFSet.{u}) : + (imp φ ψ).Eval e ↔ (φ.Eval e → ψ.Eval e) := by + classical + simp only [imp, eval_disj, Eval] + constructor + · intro h hp; exact h.elim (fun hn => False.elim (hn hp)) id + · intro h; by_cases hp : φ.Eval e + · exact Or.inr (h hp) + · exact Or.inl hp + +@[simp] theorem eval_iff (φ ψ : Formula) (e : ℕ → ZFSet.{u}) : + (iff φ ψ).Eval e ↔ (φ.Eval e ↔ ψ.Eval e) := by + simp only [iff, Eval, eval_imp, iff_def] + +def subset (a b : ℕ) : Formula := allMem a (.member 0 (b+1)) +def transitive (a : ℕ) : Formula := allMem a (subset 0 (a+1)) + +@[simp] theorem eval_subset (a b : ℕ) (e : ℕ → ZFSet.{u}) : + (subset a b).Eval e ↔ e a ⊆ e b := by + simp only [subset, eval_allMem, Eval, cons_zero, cons_succ] + rfl + +@[simp] theorem eval_transitive (a : ℕ) (e : ℕ → ZFSet.{u}) : + (transitive a).Eval e ↔ Transitive (e a) := by + simp only [transitive, eval_allMem, eval_subset, cons_zero, cons_succ] + rfl + +def functionGraph (f d v : ℕ) : Formula := + .conj (allMem f (.existsMem (d+1) (.existsMem (v+2) (orderedPair 2 1 0)))) + (allMem d (.existsMem (v+1) + (.conj (pairMem 1 0 (f+2)) + (allMem (v+2) (imp (pairMem 2 0 (f+3)) (.equal 0 1)))))) + +@[simp] theorem eval_functionGraph (f d v : ℕ) (e : ℕ → ZFSet.{u}) : + (functionGraph f d v).Eval e ↔ + (∀ z ∈ e f, ∃ x ∈ e d, ∃ y ∈ e v, z = ZFSet.pair x y) ∧ + (∀ x ∈ e d, ∃ y ∈ e v, ZFSet.pair x y ∈ e f ∧ + ∀ z ∈ e v, ZFSet.pair x z ∈ e f → z = y) := by + simp only [functionGraph, Eval, eval_allMem, eval_orderedPair, + eval_pairMem, eval_imp, cons_zero, cons_succ] + +end Formula + +inductive SigmaFormula where + | bounded (φ : Formula) + | existsSet (φ : SigmaFormula) + +def SigmaFormula.Realize (M : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : SigmaFormula → Prop + | .bounded φ => φ.Realize M e + | .existsSet φ => ∃ x ∈ M, φ.Realize M (cons x e) + +def SigmaReplacement (M : ZFSet.{u}) : Prop := + ∀ (φ : SigmaFormula) (e : ℕ → ZFSet.{u}), (∀ i, e i ∈ M) → + ∀ a ∈ M, + (∀ x ∈ a, ∃ y ∈ M, φ.Realize M (cons y (cons x e)) ∧ + ∀ z ∈ M, φ.Realize M (cons z (cons x e)) → z = y) → + ∃ b ∈ M, ∀ y ∈ M, y ∈ b ↔ ∃ x ∈ a, φ.Realize M (cons y (cons x e)) + +theorem replacement_image (M : ZFSet.{u}) (hM : Transitive M) + (hR : SigmaReplacement M) (φ : SigmaFormula) (e : ℕ → ZFSet.{u}) + (he : ∀ i, e i ∈ M) {a : ZFSet.{u}} (ha : a ∈ M) + (F : ZFSet.{u} → ZFSet.{u}) (hF : ∀ x ∈ a, F x ∈ M) + (hφ : ∀ x ∈ a, ∀ y ∈ M, φ.Realize M (cons y (cons x e)) ↔ y = F x) : + ∃ b ∈ M, ∀ y, y ∈ b ↔ ∃ x ∈ a, F x = y := by + obtain ⟨b,hb,hbdef⟩ := hR φ e he a ha (fun x hx => + ⟨F x,hF x hx,(hφ x hx _ (hF x hx)).mpr rfl, + fun z hz h => (hφ x hx z hz).mp h⟩) + refine ⟨b,hb,fun y => ?_⟩ + constructor + · intro hy + have hyM := hM b hb y hy + obtain ⟨x,hx,hxy⟩ := (hbdef y hyM).mp hy + exact ⟨x,hx,((hφ x hx y hyM).mp hxy).symm⟩ + · rintro ⟨x,hx,rfl⟩ + exact (hbdef _ (hF x hx)).mpr ⟨x,hx,(hφ x hx _ (hF x hx)).mpr rfl⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedSeparationName.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedSeparationName.lean new file mode 100644 index 0000000000000000000000000000000000000000..82d99b1c06de0d4e167449740df1f3ab480fcc59 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedSeparationName.lean @@ -0,0 +1,105 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalBoundedTruth +import OAI.Computability.DegreeRigidity.SetModels.NameSupport + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem separation_name (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) + (φ : BoundedSetTheory.Formula) (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) + (e : ℕ → Name (Conditions c)) (he : ∀ i, (e i).encode (label c) ∈ M) : + ∃ B ∈ M, B ⊆ a.support (label c) ∧ ∀ x, + x ∈ (a.restrict (label c) B).val G.carrier ↔ x ∈ a.val G.carrier ∧ + φ.Eval (cons x (fun i => (e i).val G.carrier)) := by + obtain ⟨d,hd,hdT,had,hnd⟩ := finite_container M hM hP hU hS hR hI + (fun i => (push a e i).encode (label c)) + (by intro i; cases i <;> simp only [push_zero,push_succ]; exact ha; exact he _) (bound φ+2) + let e' := truncate (bound φ) e + have he' (i) : (e' i).encode (label c) ∈ d := by + dsimp only [e',truncate] + split + · exact hnd (i+1) (by omega) + · exact hnd 1 (by omega) + have hai (i) : (a.child i).encode (label c) ∈ d := + names_childClosed d c hdT a had _ (child_relation a i) + have hpush (i) (n) : (push (a.child i) e' n).encode (label c) ∈ d := by + cases n with + | zero => exact hai i + | succ n => exact he' n + obtain ⟨f,hf,hfG⟩ := internal_atomic_graph M hM hP hU hPow hS hd hc hoM + let k := ZFSet.prod d d + have hk : k ∈ M := product_mem M hM hP hU hPow hS hd hd + let env := cons d (cons c (cons k (cons o (cons f (fun i => (e' i).encode (label c)))))) + have henv : ∀ i, env i ∈ M := by + intro i + rcases i with _|i; exact hd + rcases i with _|i; exact hc + rcases i with _|i; exact hk + rcases i with _|i; exact hoM + rcases i with _|i; exact hf + exact hM d hd _ (he' i) + let ψ := Formula.existsMem 1 (.existsMem 3 (.conj (Formula.orderedPair 2 1 0) + (code φ 3 4 5 6 7 (push 1 (fun i => i+8)) 0))) + let B := ZFSet.sep (fun z => ψ.Eval (cons z env)) (a.support (label c)) + have hBM : B ∈ M := sep_mem M hM hS ψ env henv + (support_mem M hM hP hU hPow hS hc hoM ho a ha) + have hBsub : B ⊆ a.support (label c) := fun z hz => (ZFSet.mem_sep.mp hz).1 + have query (i : a.arity) (q : Conditions c) (z : ZFSet.{u}) := + eval_code φ hdT ho hfG (push (a.child i) e') (hpush i) q + (cons (label c q) (cons ((a.child i).encode (label c)) (cons z env))) + 3 4 5 6 7 (push 1 (fun n => n+8)) 0 ⟨rfl,rfl,rfl,rfl,rfl,rfl⟩ + (by intro n; cases n <;> rfl) + have hB (i : a.arity) (q : Conditions c) (hq : q ≤ a.tag i) : + ZFSet.pair ((a.child i).encode (label c)) (label c q) ∈ B ↔ Forces (push (a.child i) e') φ q := by + have hs : ZFSet.pair ((a.child i).encode (label c)) (label c q) ∈ a.support (label c) := + ZFSet.mem_range.mpr ⟨⟨i,⟨q,hq⟩⟩,rfl⟩ + change _ ∈ ZFSet.sep _ _ ↔ _ + rw [ZFSet.mem_sep,and_iff_right hs] + change (Formula.existsMem 1 _).Eval _ ↔ _ + simp only [Formula.Eval,Formula.eval_orderedPair,cons_zero,cons_succ,env] + constructor + · rintro ⟨x,hx,r,hr,hxr,hφ⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hxr + exact (query i q _).mp hφ + · intro hφ + exact ⟨_,hai i,_,label_mem c q,rfl,(query i q _).mpr hφ⟩ + have ht (i : a.arity) : + φ.Eval (cons ((a.child i).val G.carrier) (fun n => (e n).val G.carrier)) ↔ + ∃ p ∈ G.carrier, Forces (push (a.child i) e') φ p := by + have hfinite : φ.Eval (cons ((a.child i).val G.carrier) (fun n => (e n).val G.carrier)) ↔ + φ.Eval (fun n => (push (a.child i) e' n).val G.carrier) := by + apply eval_congr + intro n hn + cases n with + | zero => rfl + | succ n => + simp only [cons_succ,push_succ] + dsimp only [e',truncate] + rw [ite_eq_left (by omega)] + exact hfinite.trans (internal_bounded_truth M hM hP hU hPow hS hR hI hc hoM ho G hG φ _ + (fun n => hM d hd _ (hpush i n))) + refine ⟨B,hBM,hBsub,fun x => ?_⟩ + constructor + · intro hx + have hxa := a.val_restrict_subset (label c) B G hx + obtain ⟨i,q,hqi,hqb,hqG,hix⟩ := (a.mem_val_restrict (label c) B G.carrier x).mp hx + have hφ := (ht i).mpr ⟨q,hqG,(hB i q hqi).mp hqb⟩ + exact ⟨hxa,hix ▸ hφ⟩ + · rintro ⟨hxa,hφ⟩ + obtain ⟨i,hi,hix⟩ := (a.mem_val_children G.carrier x).mp hxa + obtain ⟨p,hp,hf⟩ := (ht i).mp (hix ▸ hφ) + obtain ⟨q,hq,hqp,hqi⟩ := G.directed hp hi + exact (a.mem_val_restrict (label c) B G.carrier x).mpr + ⟨i,q,hqi,(hB i q hqi).mpr (forces_mono φ _ hqp hf),hq,hix⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedSetTheory.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedSetTheory.lean new file mode 100644 index 0000000000000000000000000000000000000000..da398f83aaa720f2807864530c9ebb266d084985 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedSetTheory.lean @@ -0,0 +1,222 @@ +import OAI.Computability.DegreeRigidity.SetModels.TransitiveNameModel + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory +open Set +open TransitiveNameModel (Transitive) +universe u + +inductive Formula where + | equal (i j : ℕ) + | member (i j : ℕ) + | conj (φ ψ : Formula) + | neg (φ : Formula) + | existsMem (i : ℕ) (φ : Formula) + +def cons (x : ZFSet.{u}) (env : ℕ → ZFSet.{u}) : ℕ → ZFSet.{u} + | 0 => x + | n+1 => env n + +@[simp] theorem cons_zero (x : ZFSet.{u}) (env : ℕ → ZFSet.{u}) : cons x env 0 = x := rfl +@[simp] theorem cons_succ (x : ZFSet.{u}) (env : ℕ → ZFSet.{u}) (n : ℕ) : + cons x env (n+1) = env n := rfl + +def Formula.Eval (env : ℕ → ZFSet.{u}) : Formula → Prop + | .equal i j => env i = env j + | .member i j => env i ∈ env j + | .conj φ ψ => Eval env φ ∧ Eval env ψ + | .neg φ => ¬ Eval env φ + | .existsMem i φ => ∃ x ∈ env i, Eval (cons x env) φ + +def Formula.Realize (M : ZFSet.{u}) (env : ℕ → ZFSet.{u}) : Formula → Prop + | .equal i j => env i = env j + | .member i j => env i ∈ env j + | .conj φ ψ => Realize M env φ ∧ Realize M env ψ + | .neg φ => ¬ Realize M env φ + | .existsMem i φ => ∃ x ∈ M, x ∈ env i ∧ Realize M (cons x env) φ + +theorem Formula.absolute (φ : Formula) (M : ZFSet.{u}) (hM : Transitive M) + (env : ℕ → ZFSet.{u}) (he : ∀ i, env i ∈ M) : + φ.Realize M env ↔ φ.Eval env := by + induction φ generalizing env with + | equal => rfl + | member => rfl + | conj φ ψ ihφ ihψ => exact and_congr (ihφ env he) (ihψ env he) + | neg φ ih => exact not_congr (ih env he) + | existsMem i φ ih => + constructor + · rintro ⟨x,hx,hi,hφ⟩ + exact ⟨x,hi,(ih (cons x env) (fun n => by cases n <;> simp [cons,he,hx])).mp hφ⟩ + · rintro ⟨x,hi,hφ⟩ + have hx := hM _ (he i) _ hi + exact ⟨x,hx,hi,(ih (cons x env) (fun n => by cases n <;> simp [cons,he,hx])).mpr hφ⟩ + +def Pairing (M : ZFSet.{u}) : Prop := + ∀ a ∈ M, ∀ b ∈ M, ∃ c ∈ M, ∀ x ∈ M, x ∈ c ↔ x = a ∨ x = b + +def Union (M : ZFSet.{u}) : Prop := + ∀ a ∈ M, ∃ b ∈ M, ∀ x ∈ M, x ∈ b ↔ ∃ y ∈ M, y ∈ a ∧ x ∈ y + +def PowerSet (M : ZFSet.{u}) : Prop := + ∀ a ∈ M, ∃ b ∈ M, ∀ x ∈ M, x ∈ b ↔ ∀ y ∈ M, y ∈ x → y ∈ a + +def Separation (M : ZFSet.{u}) : Prop := + ∀ (φ : Formula) (env : ℕ → ZFSet.{u}), (∀ i, env i ∈ M) → + ∀ a ∈ M, ∃ b ∈ M, ∀ x ∈ M, x ∈ b ↔ x ∈ a ∧ φ.Realize M (cons x env) + +theorem pair_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + {a b : ZFSet.{u}} (ha : a ∈ M) (hb : b ∈ M) : ({a,b} : ZFSet.{u}) ∈ M := by + obtain ⟨c,hc,hcdef⟩ := hP a ha b hb + have hc' : c = ({a,b} : ZFSet.{u}) := by + apply ZFSet.ext + intro x + constructor + · intro hx + exact ZFSet.mem_pair.mpr ((hcdef x (hM c hc x hx)).mp hx) + · intro hx + have hx' := ZFSet.mem_pair.mp hx + have hxM : x ∈ M := hx'.elim (fun h => h ▸ ha) (fun h => h ▸ hb) + exact (hcdef x hxM).mpr hx' + exact hc' ▸ hc + +theorem singleton_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + {a : ZFSet.{u}} (ha : a ∈ M) : ({a} : ZFSet.{u}) ∈ M := by + simpa using pair_mem M hM hP ha ha + +theorem orderedPair_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + {a b : ZFSet.{u}} (ha : a ∈ M) (hb : b ∈ M) : ZFSet.pair a b ∈ M := by + exact pair_mem M hM hP (singleton_mem M hM hP ha) (pair_mem M hM hP ha hb) + +theorem union_mem (M : ZFSet.{u}) (hM : Transitive M) (hU : Union M) + {a : ZFSet.{u}} (ha : a ∈ M) : ZFSet.sUnion a ∈ M := by + obtain ⟨b,hb,hbdef⟩ := hU a ha + have he : b = ZFSet.sUnion a := by + apply ZFSet.ext + intro x + constructor + · intro hx + obtain ⟨y,_,hy,hxy⟩ := (hbdef x (hM b hb x hx)).mp hx + exact ZFSet.mem_sUnion.mpr ⟨y,hy,hxy⟩ + · intro hx + obtain ⟨y,hy,hxy⟩ := ZFSet.mem_sUnion.mp hx + have hyM := hM a ha y hy + exact (hbdef x (hM y hyM x hxy)).mpr ⟨y,hyM,hy,hxy⟩ + exact he ▸ hb + +theorem internal_power (M : ZFSet.{u}) (hM : Transitive M) (hP : PowerSet M) + {a : ZFSet.{u}} (ha : a ∈ M) : + ∃ b ∈ M, ∀ x, x ∈ b ↔ x ∈ M ∧ x ⊆ a := by + obtain ⟨b,hb,hbdef⟩ := hP a ha + refine ⟨b,hb,fun x => ?_⟩ + constructor + · intro hx + have hxM := hM b hb x hx + exact ⟨hxM,fun y hy => (hbdef x hxM).mp hx y (hM x hxM y hy) hy⟩ + · rintro ⟨hxM,hsub⟩ + exact (hbdef x hxM).mpr (fun y _ hy => hsub hy) + +theorem sep_mem (M : ZFSet.{u}) (hM : Transitive M) (hS : Separation M) + (φ : Formula) (env : ℕ → ZFSet.{u}) (he : ∀ i, env i ∈ M) + {a : ZFSet.{u}} (ha : a ∈ M) : + ZFSet.sep (fun x => φ.Eval (cons x env)) a ∈ M := by + obtain ⟨b,hb,hbdef⟩ := hS φ env he a ha + have heq : b = ZFSet.sep (fun x => φ.Eval (cons x env)) a := by + apply ZFSet.ext + intro x + constructor + · intro hx + have hxM := hM b hb x hx + obtain ⟨hxa,hφ⟩ := (hbdef x hxM).mp hx + refine ZFSet.mem_sep.mpr ⟨hxa,?_⟩ + exact (φ.absolute M hM _ (fun n => by cases n <;> simp [cons,he,hxM])).mp hφ + · intro hx + obtain ⟨hxa,hφ⟩ := ZFSet.mem_sep.mp hx + have hxM := hM a ha x hxa + apply (hbdef x hxM).mpr + exact ⟨hxa,(φ.absolute M hM _ (fun n => by cases n <;> simp [cons,he,hxM])).mpr hφ⟩ + exact heq ▸ hb + +namespace Formula + +def disj (φ ψ : Formula) : Formula := .neg (.conj (.neg φ) (.neg ψ)) +def allMem (i : ℕ) (φ : Formula) : Formula := .neg (.existsMem i (.neg φ)) + +@[simp] theorem eval_disj (φ ψ : Formula) (env : ℕ → ZFSet.{u}) : + (disj φ ψ).Eval env ↔ φ.Eval env ∨ ψ.Eval env := by + classical + simp only [disj,Eval] + constructor + · intro h + by_cases hφ : φ.Eval env + · exact Or.inl hφ + · exact Or.inr (Classical.byContradiction (fun hψ => h ⟨hφ,hψ⟩)) + · intro h hn + exact h.elim hn.1 hn.2 + +@[simp] theorem eval_allMem (i : ℕ) (φ : Formula) (env : ℕ → ZFSet.{u}) : + (allMem i φ).Eval env ↔ ∀ x ∈ env i, φ.Eval (cons x env) := by + classical + simp [allMem,Eval] + +def singleton (s a : ℕ) : Formula := + .conj (.member a s) (allMem s (.equal 0 (a+1))) + +def unorderedPair (s a b : ℕ) : Formula := + .conj (.member a s) (.conj (.member b s) + (allMem s (disj (.equal 0 (a+1)) (.equal 0 (b+1))))) + +@[simp] theorem eval_singleton (s a : ℕ) (env : ℕ → ZFSet.{u}) : + (singleton s a).Eval env ↔ env s = ({env a} : ZFSet.{u}) := by + simp only [singleton,Eval,eval_allMem,cons_zero,cons_succ] + constructor + · rintro ⟨ha,hall⟩ + apply ZFSet.ext + intro x + rw [ZFSet.mem_singleton] + exact ⟨hall x,fun hx => hx ▸ ha⟩ + · intro h + simp [h] + +@[simp] theorem eval_unorderedPair (s a b : ℕ) (env : ℕ → ZFSet.{u}) : + (unorderedPair s a b).Eval env ↔ env s = ({env a,env b} : ZFSet.{u}) := by + simp only [unorderedPair,Eval,eval_allMem,eval_disj,cons_zero,cons_succ] + constructor + · rintro ⟨ha,hb,hall⟩ + apply ZFSet.ext + intro x + rw [ZFSet.mem_pair] + exact ⟨hall x,fun hx => hx.elim (fun h => h ▸ ha) (fun h => h ▸ hb)⟩ + · intro h + simp [h] + +def orderedPair (s a b : ℕ) : Formula := + .conj (allMem s (disj (singleton 0 (a+1)) (unorderedPair 0 (a+1) (b+1)))) + (.conj (.existsMem s (singleton 0 (a+1))) + (.existsMem s (unorderedPair 0 (a+1) (b+1)))) + +@[simp] theorem eval_orderedPair (s a b : ℕ) (env : ℕ → ZFSet.{u}) : + (orderedPair s a b).Eval env ↔ env s = ZFSet.pair (env a) (env b) := by + simp only [orderedPair,Eval,eval_allMem,eval_disj,eval_singleton, + eval_unorderedPair,cons_zero,cons_succ] + constructor + · rintro ⟨hall,⟨x,hx,hxa⟩,y,hy,hyab⟩ + apply ZFSet.ext + intro z + change z ∈ env s ↔ z ∈ ({({env a} : ZFSet.{u}),({env a,env b} : ZFSet.{u})} : ZFSet.{u}) + rw [ZFSet.mem_pair] + exact ⟨hall z,fun hz => hz.elim (fun h => h ▸ hxa ▸ hx) (fun h => h ▸ hyab ▸ hy)⟩ + · intro h + rw [h] + simp [ZFSet.pair] + +def pairMem (a b s : ℕ) : Formula := .existsMem s (orderedPair 0 (a+1) (b+1)) + +@[simp] theorem eval_pairMem (a b s : ℕ) (env : ℕ → ZFSet.{u}) : + (pairMem a b s).Eval env ↔ ZFSet.pair (env a) (env b) ∈ env s := by + simp [pairMem,Eval] +end Formula + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedSupport.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..70c2ee18df8bccfe9221279545a7072f08cfc501 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedSupport.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.BoundedForcingCode +import OAI.Computability.DegreeRigidity.SetModels.InternalContainer + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory +universe u + +def bound : BoundedSetTheory.Formula → ℕ + | .equal i j => max (i+1) (j+1) + | .member i j => max (i+1) (j+1) + | .conj φ ψ => max (bound φ) (bound ψ) + | .neg φ => bound φ + | .existsMem i φ => max (i+1) (bound φ - 1) + +theorem forces_congr {P : Type u} [Preorder P] (φ : BoundedSetTheory.Formula) + (e e' : ℕ → Name P) (h : ∀ i, i < bound φ → e i = e' i) (p : P) : + Forces e φ p ↔ Forces e' φ p := by + induction φ generalizing e e' p with + | equal i j => simp only [Forces,h i (by simp [bound]),h j (by simp [bound])] + | member i j => simp only [Forces,h i (by simp [bound]),h j (by simp [bound])] + | conj φ ψ ihφ ihψ => + exact and_congr (ihφ e e' (fun i hi => h i (by simp only [bound]; omega)) p) + (ihψ e e' (fun i hi => h i (by simp only [bound]; omega)) p) + | neg φ ih => + exact forall_congr' (fun q => imp_congr_right (fun _ => not_congr (ih e e' h q))) + | existsMem i φ ih => + have hei := h i (by simp only [bound]; omega) + change (fun a : Name P => ∃ j : a.arity, p ≤ a.tag j ∧ Forces (push (a.child j) e) φ p) (e i) ↔ _ + rw [hei] + apply exists_congr + intro j + apply and_congr_right + intro _ + apply ih + intro n hn + cases n with + | zero => rfl + | succ n => + simp only [push_succ] + exact h n (by simp only [bound]; omega) + +theorem eval_congr (φ : BoundedSetTheory.Formula) (e e' : ℕ → ZFSet.{u}) + (h : ∀ i, i < bound φ → e i = e' i) : φ.Eval e ↔ φ.Eval e' := by + induction φ generalizing e e' with + | equal i j => simp only [Formula.Eval,h i (by simp [bound]),h j (by simp [bound])] + | member i j => simp only [Formula.Eval,h i (by simp [bound]),h j (by simp [bound])] + | conj φ ψ ihφ ihψ => + exact and_congr (ihφ e e' (fun i hi => h i (by simp only [bound]; omega))) + (ihψ e e' (fun i hi => h i (by simp only [bound]; omega))) + | neg φ ih => exact not_congr (ih e e' h) + | existsMem i φ ih => + have hei := h i (by simp only [bound]; omega) + simp only [Formula.Eval,hei] + apply exists_congr + intro x + apply and_congr_right + intro _ + apply ih + intro n hn + cases n with + | zero => rfl + | succ n => exact h n (by simp only [bound]; omega) + +def truncate {α : Sort*} (n : ℕ) (e : ℕ → α) (i : ℕ) : α := if i < n then e i else e 0 + +theorem truncate_forces {P : Type u} [Preorder P] (φ : BoundedSetTheory.Formula) + (e : ℕ → Name P) (p : P) : Forces (truncate (bound φ) e) φ p ↔ Forces e φ p := + forces_congr φ _ e (fun _ hi => ite_eq_left hi) p + +theorem finite_container (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (n : ℕ) : + ∃ d ∈ M, Transitive d ∧ e 0 ∈ d ∧ ∀ i, i < n → e i ∈ d := by + induction n with + | zero => + obtain ⟨d,hd,hdT,he0⟩ := internal_transitive_container M hM hP hU hS hR hI (he 0) + exact ⟨d,hd,hdT,he0,fun i hi => False.elim (Nat.not_lt_zero i hi)⟩ + | succ n ih => + obtain ⟨d,hd,hdT,he0,hen⟩ := ih + obtain ⟨v,hv,hvT,hvpair⟩ := internal_transitive_container M hM hP hU hS hR hI + (pair_mem M hM hP hd (he n)) + have hdv : d ∈ v := hvT _ hvpair _ (ZFSet.mem_pair.mpr (Or.inl rfl)) + have hnv : e n ∈ v := hvT _ hvpair _ (ZFSet.mem_pair.mpr (Or.inr rfl)) + refine ⟨v,hv,hvT,hvT d hdv _ he0,fun i hi => ?_⟩ + rcases Nat.lt_succ_iff_lt_or_eq.mp hi with hi | rfl + · exact hvT d hdv _ (hen i hi) + · exact hnv + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedTruthRecursion.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedTruthRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..754485a7c18b53344cce1b416b451302c24d8445 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/BoundedTruthRecursion.lean @@ -0,0 +1,196 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTheory +import OAI.Computability.DegreeRigidity.Syntax.FiniteTerm +import OAI.Computability.DegreeRigidity.Syntax.BoundedFormulaRename + +namespace OAI + +namespace TuringRigidity.BoundedTruthRecursion +open TransitiveNameModel BoundedSetTheory + +def Local (φ : Formula) (e : ℕ → ZFSet.{0}) : Prop := + ∀ D : ZFSet.{0}, Transitive D → ∀ t ∈ D, ∀ Y Z : ZFSet.{0}, + (∀ s ∈ D, ZFSet.rank s < ZFSet.rank t → (s ∈ Y ↔ s ∈ Z)) → + (φ.Eval (cons t (cons Y e)) ↔ φ.Eval (cons t (cons Z e))) + +def Partial (φ : Formula) (e : ℕ → ZFSet.{0}) (K D Y : ZFSet.{0}) : Prop := + Transitive D ∧ D ⊆ K ∧ Y ⊆ D ∧ + ∀ t ∈ D, t ∈ Y ↔ φ.Eval (cons t (cons Y e)) + +theorem partial_sound (φ : Formula) (e : ℕ → ZFSet.{0}) (K D Y Z : ZFSet.{0}) + (hl : Local φ e) (hp : Partial φ e K D Y) + (hz : ∀ t ∈ K, t ∈ Z ↔ φ.Eval (cons t (cons Z e))) : + ∀ t ∈ D, t ∈ Y ↔ t ∈ Z := by + have wf : WellFounded (fun a b : ZFSet.{0} => ZFSet.rank a < ZFSet.rank b) := + InvImage.wf ZFSet.rank Ordinal.lt_wf + intro t + induction t using wf.induction with + | h t ih => + intro ht + exact (hp.2.2.2 t ht).trans ((hl D hp.1 t ht Y Z + (fun s hs hst => ih s hst hs)).trans (hz t (hp.2.1 ht)).symm) + +def dropSlots : ℕ → ℕ + | 0 => 0 + | 1 => 1 + | n+2 => n+4 + +def partialFormula (φ : Formula) : Formula := + .conj (.transitive 1) (.conj (.subset 1 2) (.conj (.subset 0 1) + (.allMem 1 (.iff (.member 0 1) (φ.rename dropSlots))))) + +theorem partialFormula_spec (φ : Formula) (e : ℕ → ZFSet.{0}) (K D Y : ZFSet.{0}) : + (partialFormula φ).Eval (cons Y (cons D (cons K e))) ↔ Partial φ e K D Y := by + simp only [partialFormula,Formula.Eval,Formula.eval_transitive,Formula.eval_subset, + Formula.eval_allMem,Formula.eval_iff,Formula.eval_rename_comp,cons_zero,cons_succ,Partial] + have eq (t : ZFSet.{0}) : cons t (cons Y (cons D (cons K e))) ∘ dropSlots = cons t (cons Y e) := by + funext i; rcases i with _|_|i <;> rfl + simp only [eq] + +noncomputable def domain (φ : Formula) (e : ℕ → ZFSet.{0}) (K Q : ZFSet.{0}) : ZFSet.{0} := + K.sep (fun t => ∃ D ∈ Q, ∃ Y ∈ Q, Partial φ e K D Y ∧ t ∈ D) + +noncomputable def truth (φ : Formula) (e : ℕ → ZFSet.{0}) (K Q : ZFSet.{0}) : ZFSet.{0} := + K.sep (fun t => ∃ D ∈ Q, ∃ Y ∈ Q, Partial φ e K D Y ∧ t ∈ Y) + +def candidateSlots : ℕ → ℕ + | 0 => 0 + | 1 => 1 + | n+2 => n+4 + +def unionFormula (φ : Formula) (which : ℕ) : Formula := + .existsMem 1 (.existsMem 2 (.conj ((partialFormula φ).rename candidateSlots) (.member 2 which))) + +theorem unionFormula_spec (φ : Formula) (e : ℕ → ZFSet.{0}) (K Q t : ZFSet.{0}) (which : ℕ) : + (unionFormula φ which).Eval (cons t (cons Q (cons K e))) ↔ + ∃ D ∈ Q, ∃ Y ∈ Q, Partial φ e K D Y ∧ + t ∈ cons Y (cons D (cons t (cons Q (cons K e)))) which := by + simp only [unionFormula,Formula.Eval,Formula.eval_rename_comp,cons_zero,cons_succ] + have eq (D Y : ZFSet.{0}) : + cons Y (cons D (cons t (cons Q (cons K e)))) ∘ candidateSlots = cons Y (cons D (cons K e)) := by + funext i; rcases i with _|_|i <;> rfl + simp only [eq,partialFormula_spec] + +theorem domain_truth_mem (M K Q : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hK : K ∈ M) (hQ : Q ∈ M) (φ : Formula) (e : ℕ → ZFSet.{0}) (he : ∀ i, e i ∈ M) : + domain φ e K Q ∈ M ∧ truth φ e K Q ∈ M := by + have henv : ∀ i, cons Q (cons K e) i ∈ M := by + intro i; rcases i with _|_|i; exact hQ; exact hK; exact he i + constructor + · have hs := sep_mem M hM hT.separation.finitePrefix.bounded (unionFormula φ 1) _ henv hK + simpa only [unionFormula_spec,cons_succ,cons_zero,domain] using hs + · have hs := sep_mem M hM hT.separation.finitePrefix.bounded (unionFormula φ 0) _ henv hK + simpa only [unionFormula_spec,cons_succ,cons_zero,truth] using hs + +theorem domain_transitive (φ : Formula) (e : ℕ → ZFSet.{0}) (K Q : ZFSet.{0}) : + Transitive (domain φ e K Q) := by + intro t ht s hst + obtain ⟨_,D,hD,Y,hY,hp,htD⟩ := ZFSet.mem_sep.mp ht + have hsD := hp.1 t htD s hst + exact ZFSet.mem_sep.mpr ⟨hp.2.1 hsD,D,hD,Y,hY,hp,hsD⟩ + +theorem truth_subset_domain (φ : Formula) (e : ℕ → ZFSet.{0}) (K Q : ZFSet.{0}) : + truth φ e K Q ⊆ domain φ e K Q := by + intro t ht + obtain ⟨htK,D,hD,Y,hY,hp,htY⟩ := ZFSet.mem_sep.mp ht + exact ZFSet.mem_sep.mpr ⟨htK,D,hD,Y,hY,hp,hp.2.2.1 htY⟩ + +theorem truth_agrees (φ : Formula) (e : ℕ → ZFSet.{0}) (K Q Z : ZFSet.{0}) + (hl : Local φ e) (hz : ∀ t ∈ K, t ∈ Z ↔ φ.Eval (cons t (cons Z e))) : + ∀ t ∈ domain φ e K Q, t ∈ truth φ e K Q ↔ t ∈ Z := by + intro t ht + constructor + · intro h + obtain ⟨_,D,_,Y,_,hp,htY⟩ := ZFSet.mem_sep.mp h + exact (partial_sound φ e K D Y Z hl hp hz t (hp.2.2.1 htY)).mp htY + · intro h + obtain ⟨htK,D,hD,Y,hY,hp,htD⟩ := ZFSet.mem_sep.mp ht + exact ZFSet.mem_sep.mpr ⟨htK,D,hD,Y,hY,hp,(partial_sound φ e K D Y Z hl hp hz t htD).mpr h⟩ + +theorem partial_of_agrees (φ : Formula) (e : ℕ → ZFSet.{0}) (K D Y Z : ZFSet.{0}) + (hl : Local φ e) (hz : ∀ t ∈ K, t ∈ Z ↔ φ.Eval (cons t (cons Z e))) + (hD : Transitive D) (hDK : D ⊆ K) (hYD : Y ⊆ D) + (ha : ∀ t ∈ D, t ∈ Y ↔ t ∈ Z) : Partial φ e K D Y := by + refine ⟨hD,hDK,hYD,?_⟩ + intro t ht + exact (ha t ht).trans ((hz t (hDK ht)).trans + (hl D hD t ht Y Z (fun s hs _ => ha s hs)).symm) + +theorem truth_internal (M K Z : ZFSet.{0}) (hM : Transitive M) (hT : SourceT M) + (hKM : K ∈ M) (hK : Transitive K) (φ : Formula) (e : ℕ → ZFSet.{0}) + (he : ∀ i, e i ∈ M) (hl : Local φ e) + (hz : ∀ t ∈ K, t ∈ Z ↔ φ.Eval (cons t (cons Z e))) : + K.sep (fun t => t ∈ Z) ∈ M := by + classical + obtain ⟨Q,hQM,hQ⟩ := internal_power M hM hT.powerSet hKM + let D := domain φ e K Q + let Y := truth φ e K Q + obtain ⟨hDM,hYM⟩ := domain_truth_mem M K Q hM hT hKM hQM φ e he + have hD : Transitive D := domain_transitive φ e K Q + have hDK : D ⊆ K := fun _ h => (ZFSet.mem_sep.mp h).1 + have hYD : Y ⊆ D := truth_subset_domain φ e K Q + have ha : ∀ t ∈ D, t ∈ Y ↔ t ∈ Z := truth_agrees φ e K Q Z hl hz + have hcover (t : ZFSet.{0}) : t ∈ K → t ∈ D := by + induction t using ZFSet.inductionOn with + | h t ih => + intro htK + by_cases htD : t ∈ D + · exact htD + have hchildren : t ⊆ D := fun s hs => ih s hs (hK t htK s hs) + let D' := D ∪ ({t} : ZFSet.{0}) + let Y' := if t ∈ Z then Y ∪ ({t} : ZFSet.{0}) else Y + have hDD' : D ⊆ D' := fun _ h => ZFSet.mem_union.mpr (Or.inl h) + have htD' : t ∈ D' := ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_singleton.mpr rfl)) + have hD' : Transitive D' := by + intro a ha b hb + rcases ZFSet.mem_union.mp ha with ha | ha + · exact hDD' (hD a ha b hb) + · have ha := ZFSet.mem_singleton.mp ha + subst a + exact hDD' (hchildren hb) + have hD'K : D' ⊆ K := by + intro a ha + rcases ZFSet.mem_union.mp ha with ha | ha + · exact hDK ha + · exact (ZFSet.mem_singleton.mp ha) ▸ htK + have hY'D' : Y' ⊆ D' := by + intro a ha + dsimp [Y'] at ha + split_ifs at ha + · rcases ZFSet.mem_union.mp ha with ha | ha + · exact hDD' (hYD ha) + · exact (ZFSet.mem_singleton.mp ha) ▸ htD' + · exact hDD' (hYD ha) + have ha' : ∀ a ∈ D', a ∈ Y' ↔ a ∈ Z := by + intro a haD' + by_cases hat : a = t + · subst a + have htY : t ∉ Y := fun h => htD (hYD h) + simp only [Y'] + split_ifs with htZ <;> simp [htZ,htY] + · have haD : a ∈ D := (ZFSet.mem_union.mp haD').resolve_right (fun h => hat (ZFSet.mem_singleton.mp h)) + have hae := ha a haD + dsimp [Y'] + split_ifs <;> simpa only [ZFSet.mem_union,ZFSet.mem_singleton,hat,or_false] using hae + have htM := hM K hKM t htK + have hsM := singleton_mem M hM hT.pairing htM + have hD'M : D' ∈ M := binary_union_mem M hM hT.pairing hT.union hDM hsM + have hY'M : Y' ∈ M := by + dsimp [Y']; split_ifs + · exact binary_union_mem M hM hT.pairing hT.union hYM hsM + · exact hYM + exact ZFSet.mem_sep.mpr ⟨htK,D',(hQ _).mpr ⟨hD'M,hD'K⟩, + Y',(hQ _).mpr ⟨hY'M,fun _ h => hD'K (hY'D' h)⟩, + partial_of_agrees φ e K D' Y' Z hl hz hD' hD'K hY'D' ha',htD'⟩ + have eq : Y = K.sep (fun t => t ∈ Z) := by + apply ZFSet.ext; intro t + constructor + · intro ht + exact ZFSet.mem_sep.mpr ⟨hDK (hYD ht),(ha t (hYD ht)).mp ht⟩ + · intro ht + obtain ⟨htK,htZ⟩ := ZFSet.mem_sep.mp ht + exact (ha t (hcover t htK)).mpr htZ + exact eq ▸ hYM + +end TuringRigidity.BoundedTruthRecursion + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/CertificateMatrix.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/CertificateMatrix.lean new file mode 100644 index 0000000000000000000000000000000000000000..54025dc355b2d6a7664106c416e8cdd6bddcfccc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/CertificateMatrix.lean @@ -0,0 +1,102 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.IndexedOrder +import OAI.Computability.DegreeRigidity.Syntax.BoundedRecursive + +namespace OAI + +namespace TuringRigidity.CertificateMatrix +open Encodable UniformOracle TableIndices IndexMatrix IndexedOrder BoundedRecursive + +def table (c : ℕ) : List (ℕ × ℕ) := (decode c).getD [] + +theorem table_primrec : Primrec table := Primrec.option_getD.comp Primrec.decode (Primrec.const []) + +def entry (c j : ℕ) : ℕ × ℕ := (table c).getD j (0, 0) + +theorem entry_primrec : Primrec₂ entry := + (Primrec.list_getD (0, 0)).comp (table_primrec.comp Primrec.fst) Primrec.snd + +def entryCheck (Y : Oracle) (v : ℕ) : ℕ := + let e := (Nat.unpair (Nat.unpair v).1).1 + let c := (Nat.unpair (Nat.unpair v).1).2 + let j := (Nat.unpair v).2 + if TableIndices.run Y (machine e) j (entry c j).2 = some (entry c j).1 then 1 else 0 + +theorem entryCheck_recursive (Y : Oracle) : + Nat.RecursiveIn {oracleFunction Y} (fun v => Part.some (entryCheck Y v)) := by + let O : Set (ℕ →. ℕ) := {oracleFunction Y} + let fst := Primrec.fst.comp Primrec.unpair + let snd := Primrec.snd.comp Primrec.unpair + let e := fst.comp fst + let c := snd.comp fst + let j := snd + let en := entry_primrec.comp c j + have hv := total_comp (run_uniform_recursive Y) + (total_pair (total_primrec e) (total_pair (total_primrec j) + (total_primrec (Primrec.snd.comp en)))) + have hw := total_primrec (O := O) (Primrec.encode.comp (Primrec.option_some.comp (Primrec.fst.comp en))) + have heq := total_primrec (O := O) + (Primrec.ite (Primrec.eq.comp fst snd) (Primrec.const 1) (Primrec.const 0)) + exact (total_comp heq (total_pair hv hw)).of_eq (fun v => by simp only [entryCheck, Nat.unpair_pair, Encodable.encode_injective.eq_iff]) + +def readsCheck (Y : Oracle) (v : ℕ) : ℕ := + allBelow (entryCheck Y) v (table (Nat.unpair v).2).length + +theorem readsCheck_recursive (Y : Oracle) : + Nat.RecursiveIn {oracleFunction Y} (fun v => Part.some (readsCheck Y v)) := by + have ha := total_pair (O := {oracleFunction Y}) (total_primrec Primrec.id) + (total_primrec (Primrec.list_length.comp (table_primrec.comp (Primrec.snd.comp Primrec.unpair)))) + exact (total_comp (allBelow_recursive (entryCheck_recursive Y)) ha).of_eq (fun v => by simp [readsCheck]) + +theorem readsCheck_spec (Y : Oracle) (e c : ℕ) : + readsCheck Y (Nat.pair e c) = 1 ↔ Reads Y (machine e) (table c) := by + rw [readsCheck, Nat.unpair_pair, allBelow_spec] + simp only [entryCheck, Nat.unpair_pair, ite_eq_left_iff, Nat.zero_ne_one, imp_false, not_not] + constructor + · intro h j + have hh := h j.val j.isLt + simpa [entry, List.getD_eq_getElem?_getD, List.getElem?_eq_getElem j.isLt] using hh + · intro h j hj + have hh := h ⟨j, hj⟩ + simpa [entry, List.getD_eq_getElem?_getD, List.getElem?_eq_getElem hj] using hh + +instance (Y : Oracle) (e : Nat.Partrec.Code) (L : List (ℕ × ℕ)) : Decidable (Reads Y e L) := by + unfold Reads + infer_instance + +instance (Y : Oracle) (e d : Nat.Partrec.Code) (n a z : ℕ) : Decidable (Certificate Y e d n a z) := by + unfold Certificate + infer_instance + +theorem certificate_recursive (Y : Oracle) : + Nat.RecursiveIn {oracleFunction Y} (fun v => Part.some + (if Certificate Y (machine (Nat.unpair v).1) (machine (Nat.unpair (Nat.unpair v).2).1) + (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).1 + (Nat.unpair (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).2).1 + (Nat.unpair (Nat.unpair (Nat.unpair (Nat.unpair v).2).2).2).2 then 1 else 0)) := by + let O : Set (ℕ →. ℕ) := {oracleFunction Y} + let fst := Primrec.fst.comp Primrec.unpair + let snd := Primrec.snd.comp Primrec.unpair + let e := fst + let d := fst.comp snd + let n := fst.comp (snd.comp snd) + let a := fst.comp (snd.comp (snd.comp snd)) + let z := snd.comp (snd.comp (snd.comp snd)) + let L := table_primrec.comp (fst.comp z) + let vs := Primrec.list_map L (Primrec.fst.comp Primrec.snd).to₂ + have hread := total_comp (readsCheck_recursive Y) + (total_pair (total_primrec e) (total_primrec (fst.comp z))) + let ve := Nat.Partrec.Code.primrec_evaln.comp + (((snd.comp z).pair (machine_primrec.comp d)).pair + (Primrec₂.natPair.comp (Primrec.encode.comp vs) n)) + have heval := total_primrec (O := O) + (Primrec.ite (Primrec.eq.comp ve (Primrec.option_some.comp a)) (Primrec.const 1) (Primrec.const 0)) + have hand := total_primrec (O := O) + (Primrec.ite ((Primrec.eq.comp fst (Primrec.const 1)).and (Primrec.eq.comp snd (Primrec.const 1))) + (Primrec.const 1) (Primrec.const 0)) + exact (total_comp hand (total_pair hread heval)).of_eq (fun v => by + simp only [Nat.unpair_pair, readsCheck_spec, Certificate, values, table] + split_ifs <;> simp_all) + +end TuringRigidity.CertificateMatrix + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/CheckGraphConstruction.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/CheckGraphConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..d7b040005179e7c7dcf592d633749c3046420fe2 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/CheckGraphConstruction.lean @@ -0,0 +1,109 @@ +import OAI.Computability.DegreeRigidity.Syntax.CheckedCode +import OAI.Computability.DegreeRigidity.SetModels.NameUnionCode + +namespace OAI + +namespace TuringRigidity.TransitiveNameModel +open RecursiveNames BoundedSetTheory +universe u + +theorem second_mem_doubleUnion {a b f : ZFSet.{u}} (h : ZFSet.pair a b ∈ f) : + b ∈ iterUnion 2 f := by + apply ZFSet.mem_sUnion.mpr + refine ⟨({a,b} : ZFSet.{u}),?_,ZFSet.mem_pair.mpr (Or.inr rfl)⟩ + exact ZFSet.mem_sUnion.mpr ⟨_,h,ZFSet.mem_pair.mpr (Or.inr rfl)⟩ + +def taggedImageFormula : Formula := + .existsMem 1 (.existsMem 4 (.conj (.pairMem 1 0 4) (.orderedPair 2 0 6))) + +theorem eval_taggedImageFormula (z x f r t : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + taggedImageFormula.Eval (cons z (cons x (cons f (cons r (cons t e))))) ↔ + ∃ y ∈ x, ∃ w ∈ r, ZFSet.pair y w ∈ f ∧ z = ZFSet.pair w t := by + simp only [taggedImageFormula,Formula.Eval,Formula.eval_pairMem, + Formula.eval_orderedPair,cons_zero,cons_succ] + +noncomputable def taggedImage (x f t : ZFSet.{u}) : ZFSet.{u} := + ZFSet.sep (fun z => ∃ y ∈ x, ∃ w ∈ iterUnion 2 f, + ZFSet.pair y w ∈ f ∧ z = ZFSet.pair w t) + (ZFSet.prod (iterUnion 2 f) ({t} : ZFSet.{u})) + +theorem mem_taggedImage (x f t z : ZFSet.{u}) : + z ∈ taggedImage x f t ↔ ∃ y ∈ x, ∃ w, ZFSet.pair y w ∈ f ∧ z = ZFSet.pair w t := by + rw [taggedImage,ZFSet.mem_sep] + constructor + · rintro ⟨_,y,hy,w,_,hfw,hz⟩ + exact ⟨y,hy,w,hfw,hz⟩ + · rintro ⟨y,hy,w,hfw,rfl⟩ + have hw := second_mem_doubleUnion hfw + exact ⟨ZFSet.mem_prod.mpr ⟨w,hw,t,ZFSet.mem_singleton.mpr rfl,rfl⟩, + y,hy,w,hw,hfw,rfl⟩ + +theorem taggedImage_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + {x f t : ZFSet.{u}} (hx : x ∈ M) (hf : f ∈ M) (ht : t ∈ M) : + taggedImage x f t ∈ M := by + have hr := iterUnion_mem M hM hU hf 2 + let e := cons x (cons f (cons (iterUnion 2 f) (cons t (fun _ => x)))) + have he : ∀ i, e i ∈ M := by + intro i; cases i with + | zero => exact hx + | succ i => cases i with + | zero => exact hf + | succ i => cases i with + | zero => exact hr + | succ i => cases i <;> assumption + have hs := sep_mem M hM hS taggedImageFormula e he + (product_mem M hM hP hU hPow hS hr (singleton_mem M hM hP ht)) + have heq : ZFSet.sep (fun z => taggedImageFormula.Eval (cons z e)) + (ZFSet.prod (iterUnion 2 f) ({t} : ZFSet.{u})) = taggedImage x f t := by + apply ZFSet.ext + intro z + simp only [taggedImage,ZFSet.mem_sep] + exact and_congr_right (fun _ => eval_taggedImageFormula z x f _ t _) + exact heq ▸ hs + +theorem CheckGraph.mem_iff {d r f t : ZFSet.{u}} (h : CheckGraph d r f t) + (z : ZFSet.{u}) : + z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (checkedCode t x) := by + constructor + · intro hz + obtain ⟨x,hx,y,hy,rfl⟩ := h.2.1 z hz + exact ⟨x,hx,by rw [h.correct x hx y hy hz]⟩ + · rintro ⟨x,hx,rfl⟩ + obtain ⟨y,hy,hfy,_⟩ := h.2.2.1 x hx + rw [←h.correct x hx y hy hfy] + exact hfy + +theorem checkGraph_of_mem_iff (d f t : ZFSet.{u}) (hd : Transitive d) + (hf : ∀ z, z ∈ f ↔ ∃ x ∈ d, z = ZFSet.pair x (checkedCode t x)) : + CheckGraph d (iterUnion 2 f) f t := by + have hpair (x v : ZFSet.{u}) : ZFSet.pair x v ∈ f ↔ x ∈ d ∧ v = checkedCode t x := by + rw [hf] + constructor + · rintro ⟨y,hy,he⟩ + obtain ⟨rfl,hv⟩ := ZFSet.pair_inj.mp he + exact ⟨hy,hv⟩ + · rintro ⟨hx,rfl⟩ + exact ⟨x,hx,rfl⟩ + refine ⟨hd,?_,?_,?_⟩ + · intro z hz + obtain ⟨x,hx,rfl⟩ := (hf z).mp hz + exact ⟨x,hx,checkedCode t x,second_mem_doubleUnion hz,rfl⟩ + · intro x hx + have hp := (hpair x _).mpr ⟨hx,rfl⟩ + exact ⟨_,second_mem_doubleUnion hp,hp,fun v _ hv => (hpair x v).mp hv |>.2⟩ + · intro x hx v _ hv + have he := (hpair x v).mp hv |>.2 + subst v + constructor + · intro z hz + obtain ⟨y,hy,rfl⟩ := (mem_checkedCode t x z).mp hz + have hp := (hpair y _).mpr ⟨hd x hx y hy,rfl⟩ + exact ⟨y,hy,_,second_mem_doubleUnion hp,hp,rfl⟩ + · intro y hy w _ hw + rw [(hpair y w).mp hw |>.2] + exact (mem_checkedCode t x _).mpr ⟨y,hy,rfl⟩ + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/CheckedCode.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/CheckedCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..b48031c9fa5240ad8bd9d9b475bf6a3230a5ddca --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/CheckedCode.lean @@ -0,0 +1,121 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedRelations + +namespace OAI + +namespace TuringRigidity.TransitiveNameModel +open RecursiveNames BoundedSetTheory +universe u + +noncomputable def checkedCode (t x : ZFSet.{u}) : ZFSet.{u} := + ZFSet.range (fun y : Shrink x => + ZFSet.pair (checkedCode t ((equivShrink x).symm y).val) t) +termination_by x +decreasing_by exact ((equivShrink x).symm y).property + +theorem mem_checkedCode (t x z : ZFSet.{u}) : + z ∈ checkedCode t x ↔ ∃ y ∈ x, z = ZFSet.pair (checkedCode t y) t := by + rw [checkedCode, ZFSet.mem_range] + constructor + · rintro ⟨y,hy⟩ + exact ⟨_,((equivShrink x).symm y).property,hy.symm⟩ + · rintro ⟨y,hy,hz⟩ + refine ⟨equivShrink x ⟨y,hy⟩,?_⟩ + simpa using hz.symm + +theorem encode_checkPSet {P : Type u} [Top P] (l : P → ZFSet.{u}) (x : PSet.{u}) : + (Name.checkPSet x : Name P).encode l = checkedCode (l ⊤) (ZFSet.mk x) := by + induction x with + | mk ι child ih => + apply ZFSet.ext + intro z + change z ∈ ZFSet.range _ ↔ _ + rw [ZFSet.mem_range,mem_checkedCode] + constructor + · rintro ⟨i,hi⟩ + refine ⟨ZFSet.mk (child i),?_,by simpa only [ih] using hi.symm⟩ + change ∃ j, PSet.Equiv (child i) (child j) + exact ⟨i,PSet.Equiv.refl _⟩ + · rintro ⟨y,hy,hz⟩ + induction y using Quotient.inductionOn with + | h y => + change ∃ i, PSet.Equiv y (child i) at hy + obtain ⟨i,hi⟩ := hy + have he : ZFSet.mk y = ZFSet.mk (child i) := Quotient.sound hi + change z = ZFSet.pair (checkedCode (l ⊤) (ZFSet.mk y)) (l ⊤) at hz + rw [he] at hz + exact ⟨i,by simpa only [ih] using hz.symm⟩ + +theorem encode_check {P : Type u} [Top P] (l : P → ZFSet.{u}) (x : ZFSet.{u}) : + (Name.check x : Name P).encode l = checkedCode (l ⊤) x := by + rw [Name.check,encode_checkPSet,ZFSet.mk_out] + +def RecursionStep (f r t x v : ZFSet.{u}) : Prop := + (∀ z ∈ v, ∃ y ∈ x, ∃ w ∈ r, ZFSet.pair y w ∈ f ∧ z = ZFSet.pair w t) ∧ + (∀ y ∈ x, ∀ w ∈ r, ZFSet.pair y w ∈ f → ZFSet.pair w t ∈ v) + +def CheckGraph (d r f t : ZFSet.{u}) : Prop := + Transitive d ∧ + (∀ z ∈ f, ∃ x ∈ d, ∃ y ∈ r, z = ZFSet.pair x y) ∧ + (∀ x ∈ d, ∃ y ∈ r, ZFSet.pair x y ∈ f ∧ + ∀ z ∈ r, ZFSet.pair x z ∈ f → z = y) ∧ + (∀ x ∈ d, ∀ y ∈ r, ZFSet.pair x y ∈ f → RecursionStep f r t x y) + +theorem CheckGraph.correct {d r f t : ZFSet.{u}} (h : CheckGraph d r f t) + (x : ZFSet.{u}) (hx : x ∈ d) (v : ZFSet.{u}) (hv : v ∈ r) + (hfv : ZFSet.pair x v ∈ f) : v = checkedCode t x := by + induction x using ZFSet.inductionOn generalizing v with + | h x ih => + have hs := h.2.2.2 x hx v hv hfv + apply ZFSet.ext + intro z + rw [mem_checkedCode] + constructor + · intro hz + obtain ⟨y,hy,w,hw,hfw,rfl⟩ := hs.1 z hz + exact ⟨y,hy,by rw [ih y hy (h.1 x hx y hy) w hw hfw]⟩ + · rintro ⟨y,hy,rfl⟩ + obtain ⟨w,hw,hfw,_⟩ := h.2.2.1 y (h.1 x hx y hy) + rw [←ih y hy (h.1 x hx y hy) w hw hfw] + exact hs.2 y hy w hw hfw + +theorem CheckGraph.unique {d r s f g t : ZFSet.{u}} + (hf : CheckGraph d r f t) (hg : CheckGraph d s g t) : f = g := by + apply ZFSet.ext + intro z + have forward {r s f g : ZFSet.{u}} (hf : CheckGraph d r f t) + (hg : CheckGraph d s g t) (hz : z ∈ f) : z ∈ g := by + obtain ⟨x,hx,y,hy,rfl⟩ := hf.2.1 z hz + obtain ⟨v,hv,hgv,_⟩ := hg.2.2.1 x hx + have he := (hf.correct x hx y hy hz).trans (hg.correct x hx v hv hgv).symm + exact he ▸ hgv + exact ⟨forward hf hg,forward hg hf⟩ + +namespace CheckFormula +open BoundedSetTheory.Formula + +def step (f r t x v : ℕ) : Formula := + .conj (allMem v (.existsMem (x+1) (.existsMem (r+2) + (.conj (pairMem 1 0 (f+3)) (orderedPair 2 0 (t+3)))))) + (allMem x (allMem (r+1) (imp (pairMem 1 0 (f+2)) + (.existsMem (v+2) (orderedPair 0 1 (t+3)))))) + +theorem eval_step (f r t x v : ℕ) (e : ℕ → ZFSet.{u}) : + (step f r t x v).Eval e ↔ RecursionStep (e f) (e r) (e t) (e x) (e v) := by + simp only [step, Formula.Eval, eval_allMem, eval_pairMem, eval_orderedPair, + eval_imp, cons_zero, cons_succ, RecursionStep] + simp only [exists_eq_right] + +def graph (d r f t : ℕ) : Formula := + .conj (transitive d) (.conj (functionGraph f d r) + (allMem d (allMem (r+1) (imp (pairMem 1 0 (f+2)) (step (f+2) (r+2) (t+2) 1 0))))) + +theorem eval_graph (d r f t : ℕ) (e : ℕ → ZFSet.{u}) : + (graph d r f t).Eval e ↔ CheckGraph (e d) (e r) (e f) (e t) := by + simp only [graph, Formula.Eval, eval_transitive, eval_functionGraph, + eval_allMem, eval_imp, eval_pairMem, eval_step, cons_zero, cons_succ, CheckGraph] + exact and_congr_right (fun _ => and_assoc) +end CheckFormula + +end TuringRigidity.TransitiveNameModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/CheckedDefSuccessor.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/CheckedDefSuccessor.lean new file mode 100644 index 0000000000000000000000000000000000000000..81c3dc4836b1f4b845450adf2b5559b1ae2e4bff --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/CheckedDefSuccessor.lean @@ -0,0 +1,47 @@ +import OAI.Computability.DegreeRigidity.Syntax.VariableCertificateBounds +import OAI.Computability.DegreeRigidity.Constructibility.DomainParameterizedSyntax +import OAI.Computability.DegreeRigidity.Constructibility.ContextDefinablePower + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +def CheckedDefSuccessor (N w s A D : ZFSet.{u}) : Prop := + ∃ Q ∈ N, ∃ B ∈ N, (PowerBound N w Q ∧ PowerBound N s B) ∧ + ∃ G ∈ N, ∃ T ∈ N, ∃ H ∈ N, ∃ Z ∈ N, DefSystem Q B A G T H Z D + +theorem checkedDefSuccessor_domainDefinable {M : ZFSet.{u}} (C : Context M) : + DomainDefinable M (fun N e => CheckedDefSuccessor N (e 2) (e 3) (e 1) (e 0)) := by + have hs := (defSystem_allBounds C 5 4 7 3 2 1 0 6).toDomain.existsSet.existsSet.existsSet.existsSet + have hb := (powerBound_domainDefinable C 4 1).and (powerBound_domainDefinable C 5 0) + exact (hb.and hs).existsSet.existsSet + +theorem CheckedDefSuccessor.sound {N A D : ZFSet.{u}} + (hf : ∀ p : SentenceForm, family p ∈ N) + (hs : ∀ p : SentenceForm, supportGraph p ∈ N) + (h : CheckedDefSuccessor N ZFSet.omega (ZFSet.prod ZFSet.omega ZFSet.omega) A D) : + D = definablePower A := by + obtain ⟨Q,_,B,_,hb,G,_,T,_,H,_,Z,_,hd⟩ := h + exact hd.exact (fun p => (hb.1 _).mpr ⟨hf p,family_subset_omega p⟩) + (fun p => (hb.2 _).mpr ⟨hs p,supportGraph_subset p⟩) + +theorem checkedDefSuccessor_of_context (M A D : ZFSet.{u}) (C : Context M) (hA : A ∈ M) : + CheckedDefSuccessor M ZFSet.omega (ZFSet.prod ZFSet.omega ZFSet.omega) A D ↔ + D = definablePower A := by + constructor + · exact CheckedDefSuccessor.sound + (family_mem M C.transitive C.pairing C.union C.omega_mem) + (supportGraph_mem M C.transitive C.pairing C.union C.omega_mem) + · rintro rfl + obtain ⟨Q,hQ,hq,hf⟩ := internal_family_bound M C.transitive C.pairing C.union C.power C.omega_mem + obtain ⟨B,hB,hb⟩ := internal_power M C.transitive C.power (C.prod_mem C.omega_mem C.omega_mem) + have hs (p : SentenceForm) : supportGraph p ∈ B := (hb _).mpr + ⟨supportGraph_mem M C.transitive C.pairing C.union C.omega_mem p,supportGraph_subset p⟩ + exact ⟨Q,hQ,B,hB,⟨hq,hb⟩,internal_defSystem_of_context M C Q B A hA hf hs⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/CheckedHierarchySyntax.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/CheckedHierarchySyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..daf6461d5b5b68e75abb08035a9c2a09a1a37dfa --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/CheckedHierarchySyntax.lean @@ -0,0 +1,61 @@ +import OAI.Computability.DegreeRigidity.Syntax.CheckedDefSuccessor +import OAI.Computability.DegreeRigidity.Constructibility.DomainSyntaxClosure +import OAI.Computability.DegreeRigidity.Constructibility.UniformHierarchyStage + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +def CheckedHierarchyGraph (N w sq s d r f : ZFSet.{u}) : Prop := + Transitive d ∧ FunctionGraph d r f ∧ + ∀ x ∈ d, ∀ v ∈ r, ZFSet.pair x v ∈ f → + ∃ A ∈ N, StageStep s f r x A ∧ CheckedDefSuccessor N w sq A v + +theorem checkedHierarchyGraph_domainDefinable {M : ZFSet.{u}} (C : Context M) + (w sq s d r f : ℕ) : + DomainDefinable M (fun N e => CheckedHierarchyGraph N (e w) (e sq) (e s) (e d) (e r) (e f)) := by + have hd := (defAllMem (defSubset C 0 (d+1)) d).toDomain + have hf := (functionGraph_definable C d r f).toDomain + have hv := (checkedDefSuccessor_domainDefinable C).subst + (fun i => match i with | 0 => 1 | 1 => 0 | 2 => w+3 | _ => sq+3) + have hs := (stageStep_definable C (s+3) (f+3) (r+3) 2 0).toDomain.and hv + have hi := (defPairMem C 1 0 (f+2)).toDomain.imp hs.existsSet + exact hd.and (hf.and ((hi.allMem C (r+1)).allMem C d)) + +theorem CheckedHierarchyGraph.sound {N s d r f : ZFSet.{u}} + (hf : ∀ p : SentenceForm, family p ∈ N) + (hs : ∀ p : SentenceForm, supportGraph p ∈ N) + (h : CheckedHierarchyGraph N ZFSet.omega (ZFSet.prod ZFSet.omega ZFSet.omega) s d r f) : + HierarchyGraph N s d r f := by + refine ⟨h.1,h.2.1,?_⟩ + intro x hx v hv hpair + obtain ⟨A,hA,hstep,hdef⟩ := h.2.2 x hx v hv hpair + exact ⟨A,hA,hstep,hdef.sound hf hs⟩ + +theorem checkedHierarchyGraph_of_context (N s d r f : ZFSet.{u}) (C : Context N) : + CheckedHierarchyGraph N ZFSet.omega (ZFSet.prod ZFSet.omega ZFSet.omega) s d r f ↔ + HierarchyGraph N s d r f := by + constructor + · exact CheckedHierarchyGraph.sound + (family_mem N C.transitive C.pairing C.union C.omega_mem) + (supportGraph_mem N C.transitive C.pairing C.union C.omega_mem) + · intro h + refine ⟨h.1,h.2.1,?_⟩ + intro x hx v hv hpair + obtain ⟨A,hA,hstep,hdef⟩ := h.2.2 x hx v hv hpair + exact ⟨A,hA,hstep,(checkedDefSuccessor_of_context N A v C hA).mpr hdef⟩ + +theorem CheckedHierarchyGraph.stage_exact {N R d r f x A : ZFSet.{u}} + (hf : ∀ p : SentenceForm, family p ∈ N) + (hs : ∀ p : SentenceForm, supportGraph p ∈ N) + (h : CheckedHierarchyGraph N ZFSet.omega (ZFSet.prod ZFSet.omega ZFSet.omega) + (seed R) d r f) (hx : x ∈ d) (hstep : StageStep (seed R) f r x A) : + A = stage R x := + ((h.sound hf hs).stageStep_iff x hx A).mp hstep + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/CheckedMembershipSeparation.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/CheckedMembershipSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..ecff4194cec604320caf9efe7e1c5f9ab431f566 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/CheckedMembershipSeparation.lean @@ -0,0 +1,105 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCheckedValue +import OAI.Computability.DegreeRigidity.CohenForcing.FullSetForcing + +namespace OAI + + +namespace TuringRigidity.FullSetForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +open ElementaryModel SentenceForm +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + +noncomputable def checkedMembershipFormula : SentenceForm := + .ex (.conj (checkedValueFormula.rename (fun i => match i with | 0 => 0 | 1 => 1 | _ => 6)) + (code (.member 0 1) 2 3 4 (fun i => match i with | 0 => 0 | _ => 5))) + +theorem checkedMembership_spec (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {o : ZFSet.{u}} (ho : ∀ r s : Conditions c, + ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (t : Name (Conditions c)) (p : Conditions c) (x : ZFSet.{u}) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (h0 : e 0 = x) (h1 : e 1 = c) (h2 : e 2 = o) (h3 : e 3 = label c p) + (h4 : e 4 = t.encode (label c)) (h5 : e 5 = label c ⊤) : + checkedMembershipFormula.Sat (M : Set ZFSet) e ↔ MemForces (Name.check x) t p := by + let v : ℕ → ℕ := fun i => match i with | 0 => 0 | _ => 5 + let k : ℕ → ℕ := fun i => match i with | 0 => 0 | 1 => 1 | _ => 6 + let names : ℕ → Name (Conditions c) := fun i => match i with | 0 => Name.check x | _ => t + have hc : c ∈ M := h1 ▸ he 1 + have hx : x ∈ M := h0 ▸ he 0 + have hcheck : (Name.check x : Name (Conditions c)).encode (label c) ∈ M := + encoded_check_mem M c hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc hx + have henv (z : ZFSet.{u}) (hz : z ∈ M) : ∀ i, cons z e i ∈ M := by + intro i; cases i; exact hz; exact he _ + have checked (z : ZFSet.{u}) (hz : z ∈ M) : + (checkedValueFormula.rename k).Sat (M : Set ZFSet) (cons z e) ↔ + z = (Name.check x : Name (Conditions c)).encode (label c) := by + rw [sat_rename,checkedValue_spec M hM hT _ (fun i => henv z hz (k i))] + simp only [k,cons_zero,cons_succ,h0,h5,encode_check] + have forcing (z : ZFSet.{u}) (hz : z ∈ M) + (hzv : z = (Name.check x : Name (Conditions c)).encode (label c)) : + (code (.member 0 1) 2 3 4 v).Sat (M : Set ZFSet) (cons z e) ↔ + MemForces (Name.check x) t p := by + exact realize_code M hM hT ho (.member 0 1) names p (cons z e) (henv z hz) + 2 3 4 v h1 h2 h3 (by intro i; cases i; exact hzv; exact h4) + change (∃ z ∈ M, (checkedValueFormula.rename k).Sat _ (cons z e) ∧ _) ↔ _ + constructor + · rintro ⟨z,hz,hzv,hf⟩ + exact (forcing z hz ((checked z hz).mp hzv)).mp hf + · intro hf + exact ⟨_,hcheck,(checked _ hcheck).mpr rfl,(forcing _ hcheck rfl).mpr hf⟩ + +noncomputable def checkedValueSigma : SigmaFormula := + .existsSet (.existsSet (.existsSet (.bounded (.conj (CheckFormula.graph 2 1 0 5) + (.conj (.member 4 2) (.conj (.member 3 1) (.pairMem 4 3 0))))))) + +noncomputable def checkedMembershipSigma : SigmaFormula := + .existsSet (.conj + (checkedValueSigma.rename (fun i => match i with | 0 => 0 | 1 => 1 | _ => 6)) + (BoundedForcing.SigmaCode.forcing (.bounded (.member 0 1)) 2 3 4 + (fun i => match i with | 0 => 0 | _ => 5))) + +theorem checkedMembershipSigma_spec (M : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + checkedMembershipSigma.Realize M e ↔ checkedMembershipFormula.Sat (M : Set ZFSet) e := by + change (∃ z ∈ M, (SigmaFormula.conj _ _).Realize M (cons z e)) ↔ + ∃ z ∈ M, (SentenceForm.conj _ _).Sat (M : Set ZFSet) (cons z e) + apply exists_congr; intro z + apply and_congr_right; intro _ + rw [SigmaFormula.realize_conj] + change (_ ∧ _) ↔ (_ ∧ _) + rw [SigmaFormula.realize_rename,sat_rename] + exact and_congr (sigma_sat checkedValueSigma M _).symm + (sigma_sat (BoundedForcing.SigmaCode.forcing (.bounded (.member 0 1)) 2 3 4 + (fun i => match i with | 0 => 0 | _ => 5)) M _).symm + +theorem internal_forced_members (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (hc : c ∈ M) {o a : ZFSet.{u}} + (hoM : o ∈ M) (ha : a ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (t : Name (Conditions c)) (ht : t.encode (label c) ∈ M) (p : Conditions c) : + ∃ b ∈ M, ∀ x, x ∈ b ↔ x ∈ a ∧ MemForces (Name.check x) t p := by + let e := cons c (cons o (cons (label c p) (cons (t.encode (label c)) (fun _ => label c ⊤)))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|i + exact hc + exact hoM + exact hM c hc _ (label_mem c p) + exact ht + exact hM c hc _ (label_mem c ⊤) + obtain ⟨b,hb,hdef⟩ := hT.separation.finitePrefix checkedMembershipSigma e he a ha + have spec (x : ZFSet.{u}) (hx : x ∈ M) := checkedMembership_spec M hM hT ho t p x + (cons x e) (by intro i; cases i; exact hx; exact he _) rfl rfl rfl rfl rfl rfl + refine ⟨b,hb,fun x => ?_⟩ + constructor + · intro hx + have hxM := hM b hb x hx + obtain ⟨hxa,hf⟩ := (hdef x hxM).mp hx + exact ⟨hxa,(spec x hxM).mp ((checkedMembershipSigma_spec M _).mp hf)⟩ + · rintro ⟨hxa,hf⟩ + have hxM := hM a ha x hxa + exact (hdef x hxM).mpr ⟨hxa,(checkedMembershipSigma_spec M _).mpr ((spec x hxM).mpr hf)⟩ + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/DefinablePower.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/DefinablePower.lean new file mode 100644 index 0000000000000000000000000000000000000000..c87d967c70311b1783d1a5b4406b4c9b0e1e00cc --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/DefinablePower.lean @@ -0,0 +1,84 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementaryLanguage + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def tupleEnv {n : ℕ} (v : Fin n → ZFSet.{u}) (i : ℕ) : ZFSet.{u} := + if h : i < n then v ⟨i,h⟩ else ∅ + +theorem tupleEnv_lt {n : ℕ} (v : Fin n → ZFSet.{u}) (i : Fin n) : + tupleEnv v i = v i := by simp [tupleEnv] + +noncomputable def definedSubset (A : ZFSet.{u}) (p : SentenceForm) + {n : ℕ} (v : Fin n → ZFSet.{u}) : ZFSet.{u} := + A.sep (fun x => p.Sat (A : Set ZFSet) (cons x (tupleEnv v))) + +theorem mem_definedSubset (A x : ZFSet.{u}) (p : SentenceForm) + {n : ℕ} (v : Fin n → ZFSet.{u}) : + x ∈ definedSubset A p v ↔ x ∈ A ∧ p.Sat (A : Set ZFSet) (cons x (tupleEnv v)) := + ZFSet.mem_sep + +def DefinableOver (A S : ZFSet.{u}) : Prop := + ∃ (n : ℕ) (p : SentenceForm) (v : Fin n → ZFSet.{u}), + p.bound ≤ n + 1 ∧ (∀ i, v i ∈ A) ∧ S = definedSubset A p v + +noncomputable def definablePower (A : ZFSet.{u}) : ZFSet.{u} := + (ZFSet.powerset A).sep (DefinableOver A) + +theorem definableOver_subset {A S : ZFSet.{u}} (h : DefinableOver A S) : S ⊆ A := by + obtain ⟨n,p,v,_,_,rfl⟩ := h + exact fun _ hx => (mem_definedSubset A _ p v).mp hx |>.1 + +theorem mem_definablePower (A S : ZFSet.{u}) : + S ∈ definablePower A ↔ DefinableOver A S := by + rw [definablePower,ZFSet.mem_sep] + exact ⟨And.right,fun h => ⟨ZFSet.mem_powerset.mpr (definableOver_subset h),h⟩⟩ + +theorem subset_of_mem_definablePower {A S : ZFSet.{u}} + (h : S ∈ definablePower A) : S ⊆ A := + definableOver_subset ((mem_definablePower A S).mp h) + +theorem separation_mem_definablePower (A : ZFSet.{u}) (p : SentenceForm) + (e : ℕ → ZFSet.{u}) (he : ∀ i, i < p.bound → e i ∈ A) : + A.sep (fun x => p.Sat (A : Set ZFSet) (cons x e)) ∈ definablePower A := by + apply (mem_definablePower A _).mpr + let v : Fin p.bound → ZFSet.{u} := fun i => e i + refine ⟨p.bound,p,v,by omega,fun i => he i i.isLt,?_⟩ + apply ZFSet.ext; intro x + rw [ZFSet.mem_sep,mem_definedSubset] + apply and_congr_right; intro _ + apply p.finite_support + intro i hi + cases i with + | zero => rfl + | succ i => + change e i = tupleEnv v i + simp [tupleEnv,v,show i < p.bound by omega] + +theorem self_mem_definablePower (A : ZFSet.{u}) : A ∈ definablePower A := by + apply (mem_definablePower A A).mpr + refine ⟨0,.equal 0 0,Fin.elim0,by decide,fun i => Fin.elim0 i,?_⟩ + apply ZFSet.ext; intro x + simp [mem_definedSubset,SentenceForm.Sat] + +theorem subset_definablePower {A : ZFSet.{u}} (hA : Transitive A) : A ⊆ definablePower A := by + intro S hS + apply (mem_definablePower A S).mpr + refine ⟨1,.member 0 1,fun _ => S,by decide,fun _ => hS,?_⟩ + apply ZFSet.ext; intro x + simp only [mem_definedSubset,SentenceForm.Sat,cons_zero,cons_succ] + simp only [tupleEnv,show 0 < 1 by decide,dite_eq_left] + exact ⟨fun hx => ⟨hA S hS x hx,hx⟩,And.right⟩ + +theorem definablePower_transitive {A : ZFSet.{u}} (hA : Transitive A) : + Transitive (definablePower A) := by + intro S hS x hx + exact subset_definablePower hA (subset_of_mem_definablePower hS hx) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/DefinableSubsetCertificates.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/DefinableSubsetCertificates.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd7904d210da51418f88f25a524283ee2898a0be --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/DefinableSubsetCertificates.lean @@ -0,0 +1,120 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformInternalSatisfaction + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +variable {M : ZFSet.{u}} + +def ParameterAdequate (Q B G c t : ZFSet.{u}) : Prop := + ∃ n ∈ ZFSet.omega, ∃ g ∈ G, ∃ b ∈ ZFSet.omega, + t = ZFSet.pair n g ∧ BoundWitness Q B c b ∧ ∀ x ∈ b, x ∈ n ∨ x = n + +theorem parameterAdequate_definable (C : Context M) {Q B G : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (hG : G ∈ M) (c t : ℕ) : + Definable M (fun e => ParameterAdequate Q B G (e c) (e t)) := + ((((defOrderedPair C (t+3) 2 1).and ((boundWitness_definable C hQ hB (c+3) 0).and + (defAllMem (defOr (member_definable C 0 3) (equal_definable C 0 3)) 0))).existsParam + C.omega_mem).existsParam hG).existsParam C.omega_mem + +theorem parameterAdequate_spec (Q B G c : ZFSet.{u}) + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hG : tupleGraph v ∈ G) : + ParameterAdequate Q B G c (tupleCode v) ↔ + ∃ p : SentenceForm, c = natSet (Encodable.encode p) ∧ p.bound ≤ n+1 := by + constructor + · rintro ⟨m,_,g,_,b,_,he,hb,hle⟩ + have hm : m = natSet n := (ZFSet.pair_inj.mp he).1.symm + obtain ⟨p,hp,rfl⟩ := (boundWitness_spec Q B c b hQ hB).mp hb + refine ⟨p,hp,(natSet_subset_iff p.bound (n+1)).mp ?_⟩ + intro x hx + have h := hle x hx + rw [hm] at h + exact ZFSet.mem_insert_iff.mpr h.symm + · rintro ⟨p,rfl,hp⟩ + refine ⟨natSet n,(mem_omega _).mpr ⟨n,rfl⟩,tupleGraph v,hG, + natSet p.bound,(mem_omega _).mpr ⟨p.bound,rfl⟩,rfl, + (boundWitness_spec Q B _ _ hQ hB).mpr ⟨p,rfl,rfl⟩,?_⟩ + intro x hx + have hs := (natSet_subset_iff p.bound (n+1)).mpr hp hx + exact (ZFSet.mem_insert_iff.mp hs).symm + +def DefinesSubset (A G T Z c t S : ZFSet.{u}) : Prop := + S ⊆ A ∧ ∀ x ∈ A, x ∈ S ↔ + ∃ s ∈ T, TuplePrefix A G t x s ∧ ZFSet.pair c s ∈ Z + +theorem definesSubset_definable (C : Context M) {G : ZFSet.{u}} + (hG : G ∈ M) (a T Z c t S : ℕ) : + Definable M (fun e => DefinesSubset (e a) G (e T) (e Z) (e c) (e t) (e S)) := + (defSubset C S a).and (defAllMem (defIff (member_definable C 0 (S+1)) + (((tuplePrefix_definable C hG (a+2) (t+2) 1 0).and + (defPairMem C (c+2) 0 (Z+2))).existsMem (T+1))) a) + +theorem definesSubset_spec (A G S : ZFSet.{u}) + (hG : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → tupleGraph v ∈ G) + (p : SentenceForm) {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) + (hb : p.bound ≤ n+1) : + DefinesSubset A G (tupleSpace A) (satisfactionSet A) + (natSet (Encodable.encode p)) (tupleCode v) S ↔ S = definedSubset A p v := by + have hstep (x : ZFSet.{u}) (hx : x ∈ A) : + (∃ s ∈ tupleSpace A, TuplePrefix A G (tupleCode v) x s ∧ + ZFSet.pair (natSet (Encodable.encode p)) s ∈ satisfactionSet A) ↔ + p.Sat (A : Set ZFSet) (cons x (tupleEnv v)) := by + let w : Fin (n+1) → ZFSet.{u} := Fin.cases (motive := fun _ => ZFSet.{u}) x v + have hw : ∀ i : Fin (n+1), w i ∈ A := fun i => Fin.cases hx hv i + have ht : tupleCode w ∈ tupleSpace A := (mem_tupleSpace A _).mpr ⟨n+1,w,hw,rfl⟩ + have he : tupleEnv w = cons x (tupleEnv v) := tupleEnv_cons x v + constructor + · rintro ⟨s,_,hs,hp⟩ + have hs' := (tuplePrefix_spec A G hG v hv x s hx).mp hs + rw [hs'] at hp + exact he ▸ (satisfactionSet_spec A p w hw hb).mp hp + · intro hp + refine ⟨tupleCode w,ht,(tuplePrefix_spec A G hG v hv x _ hx).mpr rfl,?_⟩ + exact (satisfactionSet_spec A p w hw hb).mpr (he ▸ hp) + constructor + · rintro ⟨hsub,hdef⟩ + apply ZFSet.ext; intro x + rw [mem_definedSubset] + exact ⟨fun hx => ⟨hsub hx,(hstep x (hsub hx)).mp ((hdef x (hsub hx)).mp hx)⟩, + fun ⟨hx,hp⟩ => (hdef x hx).mpr ((hstep x hx).mpr hp)⟩ + · rintro rfl + refine ⟨fun x hx => (mem_definedSubset A x p v).mp hx |>.1,?_⟩ + intro x hx + rw [mem_definedSubset] + exact (and_iff_right hx).trans (hstep x hx).symm + +def DefinitionWitness (Q B G A T Z S : ZFSet.{u}) : Prop := + ∃ c ∈ ZFSet.omega, ∃ t ∈ T, + ParameterAdequate Q B G c t ∧ DefinesSubset A G T Z c t S + +theorem definitionWitness_definable (C : Context M) {Q B G : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (hG : G ∈ M) (a T Z S : ℕ) : + Definable M (fun e => DefinitionWitness Q B G (e a) (e T) (e Z) (e S)) := + (((parameterAdequate_definable C hQ hB hG 1 0).and + (definesSubset_definable C hG (a+2) (T+2) (Z+2) 1 0 (S+2))).existsMem (T+1)).existsParam C.omega_mem + +theorem definitionWitness_spec (Q B G A S : ZFSet.{u}) + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) + (hG : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → tupleGraph v ∈ G) : + DefinitionWitness Q B G A (tupleSpace A) (satisfactionSet A) S ↔ DefinableOver A S := by + constructor + · rintro ⟨c,_,t,ht,ha,hd⟩ + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp ht + obtain ⟨p,rfl,hp⟩ := (parameterAdequate_spec Q B G c hQ hB v (hG n v hv)).mp ha + exact ⟨n,p,v,hp,hv,(definesSubset_spec A G S hG p v hv hp).mp hd⟩ + · rintro ⟨n,p,v,hp,hv,rfl⟩ + exact ⟨_,(mem_omega _).mpr ⟨Encodable.encode p,rfl⟩, + _,(mem_tupleSpace A _).mpr ⟨n,v,hv,rfl⟩, + (parameterAdequate_spec Q B G _ hQ hB v (hG n v hv)).mpr ⟨p,rfl,hp⟩, + (definesSubset_spec A G _ hG p v hv hp).mpr rfl⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/DefinedOutputTailCone.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/DefinedOutputTailCone.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc603343d578afd9286222177d6d1dab62f4460e --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/DefinedOutputTailCone.lean @@ -0,0 +1,88 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenTailTruth +import OAI.Computability.DegreeRigidity.CohenForcing.InternalCohenProjectionSymmetry +import OAI.Computability.DegreeRigidity.Constructibility.UniformDefinitionSymmetry +import OAI.Computability.DegreeRigidity.Effective.UniformDegreeUniverseName +import OAI.Computability.DegreeRigidity.Syntax.BoundedAutomorphismOutput +import OAI.Computability.DegreeRigidity.CohenForcing.CohenNiceNameConstruction + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory CountableForcing AtomicForcing +open RelativeConstructible CohenGroundPoset InternalCohenRestriction InternalCohenProjectedGeneric +open InternalCohenProjectionSymmetry InternalCohenFactor +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem defined_output_tail_cone (M C B : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hct : (M : Set ZFSet.{0}).Countable) + (hC : C ∈ M) (hB : B ∈ M) (hBC : B ⊆ C) + (δ : Ordinal.{0}) (Z : ZFSet.{0}) (φ : ElementaryModel.SentenceForm) + (f x y : Name (Conditions (conditions C))) + (hf : f.encode (label (conditions C)) ∈ M) + (hx : x.encode (label (conditions C)) ∈ M) + (hy : y.encode (label (conditions C)) ∈ M) + (hfv : ∀ G : GenericFilter (Conditions (conditions C)), GroundGeneric M G → + f.val G.carrier = definedSubset + (level (groundReals (genericExtensionSet M (conditions C) G.carrier)) δ) + φ (fun _ : Fin φ.bound => Z)) + (hxfix : ∀ a : Conditions (conditions C) ≃o Conditions (conditions C), + (∀ s, restrict B (label _ (a s)) = restrict B (label _ s)) → + ∀ G : GenericFilter (Conditions (conditions C)), + x.val (AutomorphismName.mapFilter a G).carrier = x.val G.carrier) + (hyfix : ∀ a : Conditions (conditions C) ≃o Conditions (conditions C), + (∀ s, restrict B (label _ (a s)) = restrict B (label _ s)) → + ∀ G : GenericFilter (Conditions (conditions C)), + y.val (AutomorphismName.mapFilter a G).carrier = y.val G.carrier) + (G : GenericFilter (Conditions (conditions C))) (hG : GroundGeneric M G) + (houtput : ∃ d ∈ degreeUniverse (groundReals (genericExtensionSet M (conditions C) G.carrier)), + ∃ b ∈ degreeUniverse (groundReals (genericExtensionSet M (conditions C) G.carrier)), + x.val G.carrier ∈ d ∧ y.val G.carrier ∈ b ∧ ZFSet.pair d b ∈ f.val G.carrier) + (p₀ : Conditions (conditions C)) (hp₀ : p₀ ∈ G.carrier) : + ∃ p ∈ G.carrier, p ≤ p₀ ∧ + ∀ H : GenericFilter (Conditions (conditions C)), GroundGeneric M H → + project C B hBC p ∈ (projected C B hBC H).carrier → + ∃ d ∈ degreeUniverse (groundReals (genericExtensionSet M (conditions C) H.carrier)), + ∃ b ∈ degreeUniverse (groundReals (genericExtensionSet M (conditions C) H.carrier)), + x.val H.carrier ∈ d ∧ y.val H.carrier ∈ b ∧ ZFSet.pair d b ∈ f.val H.carrier := by + have hc := conditions_mem M C hM hT hC + have ho := InternalCollapse.orderSet_mem M hM hT hc + have ht (H : GenericFilter (Conditions (conditions C))) : ⊤ ∈ H.carrier := by + obtain ⟨q,hq⟩ := H.nonempty; exact H.upper le_top hq + obtain ⟨D,hD,hDv⟩ := uniform_degreeUniverse_name M hM hT hc ho (InternalCollapse.orderSet_pair _) + let e := push f (push x (push y (fun _ => D))) + have he (i : ℕ) : (e i).encode (label (conditions C)) ∈ M := by + rcases i with _|_|_|i + exact hf; exact hx; exact hy; exact hD + have hev (H : GenericFilter (Conditions (conditions C))) : (fun i => (e i).val H.carrier) = + cons (f.val H.carrier) (cons (x.val H.carrier) (cons (y.val H.carrier) (fun _ => D.val H.carrier))) := by + funext i; rcases i with _|_|_|i <;> rfl + have hinv : ∀ w ∈ M, ∀ a : Conditions (conditions C) ≃o Conditions (conditions C), + (∀ s t, ZFSet.pair (label _ s) (label _ t) ∈ w ↔ t = a s) → + (∀ s, restrict B (label _ (a s)) = restrict B (label _ s)) → + ∀ H : GenericFilter (Conditions (conditions C)), GroundGeneric M H → + (boundedOutputFormula.Eval (fun i => (e i).val (AutomorphismName.mapFilter a H).carrier) ↔ + boundedOutputFormula.Eval (fun i => (e i).val H.carrier)) := by + intro w hw a ha hfix H hH + have hHa := InternalOrderIsoTransport.map_ground_generic M _ _ w hM hT hc hc hw a ha H hH + have hExt := InternalOrderIsoTransport.extension_eq M _ _ w hM hT hc hc hw a ha H hH + rw [hev _,hev H,hxfix a hfix H,hyfix a hfix H,hfv _ hHa,hfv H hH, + hDv _ hHa (ht _),hDv H hH (ht H),hExt] + have hφ : boundedOutputFormula.Eval (fun i => (e i).val G.carrier) := by + rw [hev G,boundedOutputFormula_raw,hDv G hG (ht G)] + exact houtput + obtain ⟨r,hr,hrφ⟩ := (internal_bounded_truth M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix.bounded hT.replacement.finitePrefix hT.infinity hc ho + (InternalCollapse.orderSet_pair _) G hG boundedOutputFormula e he).mp hφ + obtain ⟨p,hp,hp₀',hpr⟩ := G.directed hp₀ hr + refine ⟨p,hp,hp₀',?_⟩ + intro H hH hpH + have hv := cone_truth_of_internal_tail_symmetry M C B hM hT hct hC hB hBC + boundedOutputFormula e he hinv p (forces_mono _ e hpr hrφ) H hH + ((projected_cone_iff C B hBC H p).mp hpH) + rw [hev H,boundedOutputFormula_raw,hDv H hH (ht H)] at hv + exact hv + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/DefinedPrefixRemoval.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/DefinedPrefixRemoval.lean new file mode 100644 index 0000000000000000000000000000000000000000..01ca96d79044c98f76778bb96a892a015e98e448 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/DefinedPrefixRemoval.lean @@ -0,0 +1,77 @@ +import OAI.Computability.DegreeRigidity.CohenForcing.CohenPrefixOverwrite +import OAI.Computability.DegreeRigidity.Effective.UniformTableSimulation +import OAI.Computability.DegreeRigidity.SetModels.ModelDegreeUniverse +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleGroundReals + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open TransitiveNameModel BoundedSetTheory CountableForcing RecursiveNames AtomicForcing +open CohenGroundPoset CohenColumnRealName CohenFiniteFlip FiniteOverwrite +open TableIndices IndexMatrix +open ElementaryModel +attribute [local instance] InternalCollapse.order InternalCollapse.collapsePreorder + CohenNiceNameConstruction.cohenTop + +theorem equidegree_mem_ownDegree (E u : ZFSet.{0}) (hE : Transitive E) (hT : SourceT E) + (hu : u ∈ degreeUniverse (groundReals E)) (A B : Oracle) + (hB : realCode B ∈ u) (he : degree A = degree B) : realCode A ∈ u := by + obtain ⟨C,hC,rfl⟩ := (mem_degreeUniverse _ _).mp hu + have hmem := actual_degreeCode_membership E hE hT (groundReals E) + (realCode_mem_groundReals E) ((realCode_mem_groundReals E C).mp hC) + exact (hmem A).mpr (he.trans ((hmem B).mp hB)) + +theorem defined_value_extension_eq (M c : ZFSet.{0}) (δ : Ordinal.{0}) + (Z : ZFSet.{0}) (φ : SentenceForm) (f : Name (Conditions c)) + (hfv : ∀ H : GenericFilter (Conditions c), GroundGeneric M H → + f.val H.carrier = definedSubset (level (groundReals (genericExtensionSet M c H.carrier)) δ) + φ (fun _ : Fin φ.bound => Z)) + (G H : GenericFilter (Conditions c)) (hG : GroundGeneric M G) (hH : GroundGeneric M H) + (he : genericExtensionSet M c G.carrier = genericExtensionSet M c H.carrier) : + f.val G.carrier = f.val H.carrier := by + rw [hfv G hG,hfv H hH,he] + +theorem remove_defined_program_prefix (M K a : ZFSet.{0}) + (hM : Transitive M) (hT : SourceT M) (hK : K ∈ M) (ha : a ∈ K) + (δ : Ordinal.{0}) (Z : ZFSet.{0}) (φ : SentenceForm) + (f : Name (Conditions (poset K))) + (hfv : ∀ H : GenericFilter (Conditions (poset K)), GroundGeneric M H → + f.val H.carrier = definedSubset + (level (groundReals (genericExtensionSet M (poset K) H.carrier)) δ) + φ (fun _ : Fin φ.bound => Z)) + (R A₀ : Oracle) (d ℓ : ℕ) + (hprog : ∀ H : GenericFilter (Conditions (poset K)), GroundGeneric M H → + ∀ A : Oracle, (realName K a).val H.carrier = realCode A → + (∀ n < ℓ, A n = A₀ n) → ∃ X : Oracle, + Represents (join A R) (machine d) X ∧ + ∃ u ∈ degreeUniverse (groundReals (genericExtensionSet M (poset K) H.carrier)), + ∃ v ∈ degreeUniverse (groundReals (genericExtensionSet M (poset K) H.carrier)), + realCode A ∈ u ∧ realCode X ∈ v ∧ ZFSet.pair u v ∈ f.val H.carrier) : + ∃ e : ℕ, ∀ H : GenericFilter (Conditions (poset K)), GroundGeneric M H → + ∀ A : Oracle, (realName K a).val H.carrier = realCode A → ∃ X : Oracle, + Represents (join A R) (machine e) X ∧ + ∃ u ∈ degreeUniverse (groundReals (genericExtensionSet M (poset K) H.carrier)), + ∃ v ∈ degreeUniverse (groundReals (genericExtensionSet M (poset K) H.carrier)), + realCode A ∈ u ∧ realCode X ∈ v ∧ ZFSet.pair u v ∈ f.val H.carrier := by + let s := FiniteShuffle.initial A₀ ℓ + obtain ⟨e,he⟩ := (overwrite_join_program s R).table_simulation d + refine ⟨e,fun H hH A hv => ?_⟩ + let Hs := prefixFilter K a s A H + obtain ⟨hHs,hExt,hval⟩ := prefixFilter_properties M K a hM hT hK ha s A H hH hv + have hprefix : ∀ n < ℓ, overwrite s A n = A₀ n := by + intro n hn + rw [overwrite_below _ _ _ (by simpa [s] using hn),FiniteShuffle.prefix_getD _ _ _ hn] + obtain ⟨X,hX,u,hu,v,hv',hAu,hXv,hpair⟩ := hprog Hs hHs (overwrite s A) hval hprefix + have hfEq := defined_value_extension_eq M (poset K) δ Z φ f hfv Hs H hHs hH hExt + rw [hExt] at hu hv' + rw [hfEq] at hpair + obtain ⟨hE,hTE,_,_⟩ := RegularTreeExtension.extension_properties M (poset K) hM hT + (manyColumn_internal M K hM hT hK).1 H hH + exact ⟨X,he A X hX,u,hu,v,hv', + equidegree_mem_ownDegree _ u hE hTE hu A (overwrite s A) hAu + (degree_overwrite s A).symm,hXv,hpair⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteFragment.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteFragment.lean new file mode 100644 index 0000000000000000000000000000000000000000..35d34a0056ab82189f3ac2685460a37fcc6d6e38 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteFragment.lean @@ -0,0 +1,151 @@ +import OAI.Computability.DegreeRigidity.Effective.TupleFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace Formula + +def scope : Formula → ℕ + | .equal i j | .member i j => max (i+1) (j+1) + | .conj φ ψ => max φ.scope ψ.scope + | .neg φ => φ.scope + | .existsMem i φ => max (i+1) (φ.scope-1) + +theorem realize_congr (φ : Formula) (d : ZFSet.{u}) (e f : ℕ → ZFSet.{u}) + (h : ∀ i, i < φ.scope → e i = f i) : φ.Realize d e ↔ φ.Realize d f := by + induction φ generalizing e f with + | equal i j => simp only [Realize,h i (by simp [scope]),h j (by simp [scope])] + | member i j => simp only [Realize,h i (by simp [scope]),h j (by simp [scope])] + | conj φ ψ ihφ ihψ => + exact and_congr (ihφ e f (fun i hi => h i (by simp only [scope]; omega))) + (ihψ e f (fun i hi => h i (by simp only [scope]; omega))) + | neg φ ih => exact not_congr (ih e f h) + | existsMem i φ ih => + simp only [Realize,h i (by simp only [scope]; omega)] + apply exists_congr; intro x + apply and_congr_right; intro _ + apply and_congr_right; intro _ + apply ih; intro j hj + cases j with + | zero => rfl + | succ j => exact h j (by simp only [scope]; omega) + +def width : Formula → ℕ + | .equal i j | .member i j => max (i+1) (j+1) + | .conj φ ψ => max φ.width ψ.width + | .neg φ => φ.width + | .existsMem i φ => max (i+1) φ.width + +theorem scope_le_width (φ : Formula) : φ.scope ≤ φ.width := by + induction φ <;> simp only [scope,width] at * <;> omega +end Formula +namespace FiniteTuple + +def takeEnv : ℕ → (ℕ → ZFSet.{u}) → List ZFSet.{u} + | 0,_ => [] + | n+1,e => e 0 :: takeEnv n (fun i => e (i+1)) + +@[simp] theorem length_takeEnv (n : ℕ) (e : ℕ → ZFSet.{u}) : (takeEnv n e).length = n := by + induction n generalizing e with + | zero => rfl + | succ n ih => simp only [takeEnv,List.length_cons,ih] + +theorem takeEnv_mem (n : ℕ) (e : ℕ → ZFSet.{u}) (h : ZFSet.{u}) (he : ∀ i, e i ∈ h) : + ∀ x ∈ takeEnv n e, x ∈ h := by + induction n generalizing e with + | zero => simp [takeEnv] + | succ n ih => + intro x hx + rcases List.mem_cons.mp hx with rfl|hx + · exact he 0 + · exact ih (fun i => e (i+1)) (fun i => he (i+1)) x hx + +theorem takeEnv_agree (n : ℕ) (e f : ℕ → ZFSet.{u}) (i : ℕ) (hi : i < n) : + prepend (takeEnv n e) f i = e i := by + induction n generalizing e i with + | zero => omega + | succ n ih => cases i with + | zero => rfl + | succ i => exact ih (fun j => e (j+1)) i (Nat.lt_of_succ_lt_succ hi) + +def witnessBody (n i : ℕ) (φ : Formula) : Formula := + .conj (.member 0 (i+1)) (relativizeBounded (n+1) φ) + +theorem eval_witnessBody (n i : ℕ) (φ : Formula) (hn : i < n) (hφ : φ.scope ≤ n+1) + (d x : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (witnessBody n i φ).Eval (cons x (prepend (takeEnv n e) (fun _ => d))) ↔ + x ∈ e i ∧ φ.Realize d (cons x e) := by + simp only [witnessBody,Formula.Eval,cons_zero,cons_succ,eval_relativizeBounded] + rw [takeEnv_agree n e _ i hn] + have hd : prepend (takeEnv n e) (fun _ => d) n = d := by + simpa only [length_takeEnv,Nat.add_zero] using prepend_tail (takeEnv n e) (fun _ => d) 0 + rw [hd] + apply and_congr_right; intro _ + apply φ.realize_congr; intro j hj + cases j with + | zero => rfl + | succ j => exact takeEnv_agree n e _ j (by omega) + +def occurrences : Formula → List (ℕ × Formula) + | .equal _ _ | .member _ _ => [] + | .conj φ ψ => occurrences φ ++ occurrences ψ + | .neg φ => occurrences φ + | .existsMem i φ => (i,φ) :: occurrences φ + +def fragment (n : ℕ) (φ : Formula) : List Formula := + (occurrences φ).map (fun p => witnessBody n p.1 p.2) + +theorem occurrence_width (φ : Formula) (i : ℕ) (ψ : Formula) + (hm : (i,ψ) ∈ occurrences φ) : i < φ.width ∧ ψ.scope ≤ φ.width+1 := by + induction φ with + | equal => simp [occurrences] at hm + | member => simp [occurrences] at hm + | conj φ θ ihφ ihθ => + rcases List.mem_append.mp hm with hm|hm + · have hh := ihφ hm; simp only [Formula.width]; omega + · have hh := ihθ hm; simp only [Formula.width]; omega + | neg φ ih => exact ih hm + | existsMem j φ ih => + rcases List.mem_cons.mp hm with hp|hm + · obtain ⟨rfl,rfl⟩ := Prod.mk.inj hp + have hh := Formula.scope_le_width ψ + simp only [Formula.width]; omega + · have hh := ih hm; simp only [Formula.width]; omega + +def Witnesses (d h : ZFSet.{u}) (φ : Formula) : Prop := + ∀ i ψ, (i,ψ) ∈ occurrences φ → + ∀ e : ℕ → ZFSet.{u}, (∀ j, e j ∈ h) → + (∃ x ∈ d, x ∈ e i ∧ ψ.Realize d (cons x e)) → + ∃ x ∈ h, x ∈ e i ∧ ψ.Realize d (cons x e) + +theorem realize_of_witnesses (d h : ZFSet.{u}) (hhd : h ⊆ d) (φ : Formula) + (hw : Witnesses d h φ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ h) : + φ.Realize h e ↔ φ.Realize d e := by + induction φ generalizing e with + | equal => rfl + | member => rfl + | conj φ ψ ihφ ihψ => + have hwφ : Witnesses d h φ := fun i θ hi => hw i θ (List.mem_append_left _ hi) + have hwψ : Witnesses d h ψ := fun i θ hi => hw i θ (List.mem_append_right _ hi) + exact and_congr (ihφ hwφ e he) (ihψ hwψ e he) + | neg φ ih => exact not_congr (ih hw e he) + | existsMem i φ ih => + have hwφ : Witnesses d h φ := fun j θ hj => hw j θ (List.mem_cons_of_mem _ hj) + have env (x : ZFSet.{u}) (hx : x ∈ h) : ∀ j, cons x e j ∈ h := by + intro j; cases j with + | zero => exact hx + | succ j => exact he j + constructor + · rintro ⟨x,hx,hxi,hφ⟩ + exact ⟨x,hhd hx,hxi,(ih hwφ (cons x e) (env x hx)).mp hφ⟩ + · intro hφ + obtain ⟨x,hx,hxi,hψ⟩ := hw i φ (List.mem_cons_self) e he hφ + exact ⟨x,hx,hxi,(ih hwφ (cons x e) (env x hx)).mpr hψ⟩ + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteGraphSatisfaction.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteGraphSatisfaction.lean new file mode 100644 index 0000000000000000000000000000000000000000..098d530b762cd0a84c5b972490eea70d976653e1 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteGraphSatisfaction.lean @@ -0,0 +1,81 @@ +import OAI.Computability.DegreeRigidity.Syntax.SetSatisfactionBounded +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleTupleSpace + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +def prependValues (w : ℕ → ZFSet.{u}) : ℕ → (ℕ → ZFSet.{u}) → ℕ → ZFSet.{u} + | 0, e => e + | n+1, e => prependValues w n (cons (w n) e) + +theorem prependValues_tail (w : ℕ → ZFSet.{u}) (n : ℕ) (e : ℕ → ZFSet.{u}) (i : ℕ) : + prependValues w n e (n+i) = e i := by + induction n generalizing e i with + | zero => simp [prependValues] + | succ n ih => + change prependValues w n (cons (w n) e) (n+1+i) = e i + rw [show n+1+i = n+(i+1) by omega,ih] + rfl + +theorem prependValues_lt (w : ℕ → ZFSet.{u}) (n : ℕ) (e : ℕ → ZFSet.{u}) + (i : ℕ) (hi : i < n) : prependValues w n e i = w i := by + induction n generalizing e with + | zero => omega + | succ n ih => + by_cases hin : i < n + · exact ih _ hin + · have he : i = n := by omega + subst i + exact prependValues_tail w n (cons (w n) e) 0 + +def readGraph : ℕ → ℕ → ℕ → (ℕ → ℕ) → Formula → Formula + | 0, _, _, _, ψ => ψ + | n+1, a, g, idx, ψ => .existsMem a + (.conj (.pairMem (idx n+1) 0 (g+1)) + (readGraph n (a+1) (g+1) (fun i => idx i+1) ψ)) + +theorem readGraph_eval (n a g : ℕ) (idx : ℕ → ℕ) (ψ : Formula) + (e w : ℕ → ZFSet.{u}) (hw : ∀ i, i < n → w i ∈ e a) + (hg : ∀ i, i < n → ∀ y ∈ e a, + (ZFSet.pair (e (idx i)) y ∈ e g ↔ y = w i)) : + (readGraph n a g idx ψ).Eval e ↔ ψ.Eval (prependValues w n e) := by + induction n generalizing a g idx e with + | zero => rfl + | succ n ih => + simp only [readGraph,Formula.Eval,Formula.eval_pairMem,cons_zero,cons_succ] + constructor + · rintro ⟨x,hx,hpair,hbody⟩ + have he : x = w n := (hg n (by omega) x hx).mp hpair + subst x + exact (ih (a+1) (g+1) (fun i => idx i+1) (cons (w n) e) + (fun i hi => hw i (by omega)) (fun i hi => hg i (by omega))).mp hbody + · intro h + refine ⟨w n,hw n (by omega),(hg n (by omega) _ (hw n (by omega))).mpr rfl,?_⟩ + exact (ih (a+1) (g+1) (fun i => idx i+1) (cons (w n) e) + (fun i hi => hw i (by omega)) (fun i hi => hg i (by omega))).mpr h + +def graphTruth (p : SentenceForm) (a g : ℕ) (idx : ℕ → ℕ) : Formula := + readGraph p.bound a g idx (setBounded p (p.bound+a) id) + +theorem graphTruth_spec (p : SentenceForm) (a g : ℕ) (idx : ℕ → ℕ) + (e : ℕ → ZFSet.{u}) {n : ℕ} (v : Fin n → ZFSet.{u}) + (hv : ∀ i, v i ∈ e a) (hb : p.bound ≤ n) (hg : e g = tupleGraph v) + (hi : ∀ i, i < p.bound → e (idx i) = natSet i) : + (graphTruth p a g idx).Eval e ↔ p.Sat (e a : Set ZFSet) (tupleEnv v) := by + have hw (i : ℕ) (h : i < p.bound) : tupleEnv v i ∈ e a := by + simpa [tupleEnv,show i < n by omega] using hv ⟨i,by omega⟩ + have hlookup (i : ℕ) (h : i < p.bound) (y : ZFSet.{u}) (_hy : y ∈ e a) : + ZFSet.pair (e (idx i)) y ∈ e g ↔ y = tupleEnv v i := by + rw [hg,hi i h] + simpa [tupleEnv,show i < n by omega] using tupleGraph_pair v ⟨i,by omega⟩ y + rw [graphTruth,readGraph_eval p.bound a g idx _ e (tupleEnv v) hw hlookup,setBounded_eval, + prependValues_tail] + exact p.finite_support _ _ _ (fun i h => prependValues_lt _ _ _ i h) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteModelGraph.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteModelGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..be365f52a5499644d9db1bdea54e41fc78bc7b5a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteModelGraph.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DegreeRigidity.SetModels.ModelReals + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +noncomputable def finiteModelGraph (f : ℕ → ZFSet.{u}) : ℕ → ZFSet.{u} + | 0 => {ZFSet.pair (natSet 0) (f 0)} + | n+1 => finiteModelGraph f n ∪ ({ZFSet.pair (natSet (n+1)) (f (n+1))} : ZFSet.{u}) + +theorem mem_finiteModelGraph (f : ℕ → ZFSet.{u}) (n : ℕ) (z : ZFSet.{u}) : + z ∈ finiteModelGraph f n ↔ ∃ i, i ≤ n ∧ z = ZFSet.pair (natSet i) (f i) := by + induction n with + | zero => + rw [finiteModelGraph,ZFSet.mem_singleton] + constructor + · intro h; exact ⟨0,le_rfl,h⟩ + · rintro ⟨i,hi,h⟩ + have he : i = 0 := Nat.eq_zero_of_le_zero hi + simpa only [he] using h + | succ n ih => + rw [finiteModelGraph,ZFSet.mem_union,ZFSet.mem_singleton,ih] + constructor + · rintro (⟨i,hi,hz⟩|hz) + · exact ⟨i,Nat.le_succ_of_le hi,hz⟩ + · exact ⟨n+1,le_rfl,hz⟩ + · rintro ⟨i,hi,hz⟩ + by_cases hin : i ≤ n + · exact Or.inl ⟨i,hin,hz⟩ + · have he : i = n+1 := by omega + exact Or.inr (he ▸ hz) + +theorem finiteModelGraph_pair (f : ℕ → ZFSet.{u}) (n i : ℕ) (y : ZFSet.{u}) : + ZFSet.pair (natSet i) y ∈ finiteModelGraph f n ↔ i ≤ n ∧ y = f i := by + rw [mem_finiteModelGraph] + constructor + · rintro ⟨j,hj,he⟩ + obtain ⟨hij,hy⟩ := ZFSet.pair_inj.mp he + have heq := natSet_injective hij + subst j + exact ⟨hj,hy⟩ + · rintro ⟨hi,rfl⟩ + exact ⟨i,hi,rfl⟩ + +theorem finiteModelGraph_function (R : ZFSet.{u}) (f : ℕ → ZFSet.{u}) (hf : ∀ i, f i ∈ R) (n : ℕ) : + TransitiveNameModel.FunctionGraph (natSet (n+1)) R (finiteModelGraph.{u} f n) := by + constructor + · intro z hz + obtain ⟨i,hi,rfl⟩ := (mem_finiteModelGraph f n z).mp hz + exact ⟨natSet i,(natSet_mem_natSet i (n+1)).mpr (by omega),f i, + hf i,rfl⟩ + · intro x hx + obtain ⟨i,hi,rfl⟩ := (mem_natSet (n+1) x).mp hx + have hin : i ≤ n := by omega + refine ⟨f i,hf i, + (finiteModelGraph_pair f n i _).mpr ⟨hin,rfl⟩,?_⟩ + intro y _ hy + exact ((finiteModelGraph_pair f n i y).mp hy).2 + +theorem finiteModelGraph_mem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hω : ZFSet.omega.{u} ∈ M) + (f : ℕ → ZFSet.{u}) (hf : ∀ i, f i ∈ M) (n : ℕ) : finiteModelGraph f n ∈ M := by + have hn (i : ℕ) : natSet.{u} i ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨i,rfl⟩) + induction n with + | zero => exact singleton_mem M hM hP (orderedPair_mem M hM hP (hn 0) (hf 0)) + | succ n ih => + exact binary_union_mem M hM hP hU ih + (singleton_mem M hM hP (orderedPair_mem M hM hP (hn (n+1)) (hf (n+1)))) + +theorem internal_finite_model_graph_bound (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hω : ZFSet.omega.{u} ∈ M) (R : ZFSet.{u}) (hR : R ∈ M) : + ∃ Q ∈ M, (∀ F, F ∈ Q ↔ F ∈ M ∧ F ⊆ ZFSet.prod ZFSet.omega R) ∧ + ∀ f : ℕ → ZFSet.{u}, (∀ i, f i ∈ R) → ∀ n, finiteModelGraph f n ∈ Q := by + obtain ⟨Q,hQ,hQdef⟩ := internal_power M hM hPow (product_mem M hM hP hU hPow hS hω hR) + refine ⟨Q,hQ,hQdef,?_⟩ + intro f hf n + apply (hQdef _).mpr + refine ⟨finiteModelGraph_mem M hM hP hU hω f (fun i => hM _ hR _ (hf i)) n,?_⟩ + intro z hz + obtain ⟨i,_,rfl⟩ := (mem_finiteModelGraph f n z).mp hz + exact ZFSet.mem_prod.mpr ⟨_,(mem_omega _).mpr ⟨i,rfl⟩,_,hf i,rfl⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteSatisfactionCertificate.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteSatisfactionCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3870d97b5245f81d85bf71640d66b03b059ae3c --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteSatisfactionCertificate.lean @@ -0,0 +1,153 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalSatisfactionSlice +import OAI.Computability.DegreeRigidity.Constructibility.ConstructibleSuccessorCode + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +def subformulas : SentenceForm → List SentenceForm + | .equal i j => [.equal i j] + | .member i j => [.member i j] + | .conj p q => .conj p q :: (subformulas p ++ subformulas q) + | .neg p => .neg p :: subformulas p + | .ex p => .ex p :: subformulas p + +theorem self_mem_subformulas (p : SentenceForm) : p ∈ subformulas p := by + cases p <;> simp [subformulas] + +theorem subformulas_closed (p q : SentenceForm) (hq : q ∈ subformulas p) : + ∀ r ∈ subformulas q, r ∈ subformulas p := by + induction p with + | equal i j => + have he : q = .equal i j := by simpa [subformulas] using hq + subst q; exact fun _ hr => hr + | member i j => + have he : q = .member i j := by simpa [subformulas] using hq + subst q; exact fun _ hr => hr + | conj p s ihp ihs => + simp only [subformulas,List.mem_cons,List.mem_append] at hq ⊢ + rcases hq with rfl|hq|hq + · intro r hr; simpa only [subformulas,List.mem_cons,List.mem_append] using hr + · intro r hr; exact Or.inr (Or.inl (ihp hq r hr)) + · intro r hr; exact Or.inr (Or.inr (ihs hq r hr)) + | neg p ih => + simp only [subformulas,List.mem_cons] at hq ⊢ + rcases hq with rfl|hq + · intro r hr; simpa only [subformulas,List.mem_cons] using hr + · intro r hr; exact Or.inr (ih hq r hr) + | ex p ih => + simp only [subformulas,List.mem_cons] at hq ⊢ + rcases hq with rfl|hq + · intro r hr; simpa only [subformulas,List.mem_cons] using hr + · intro r hr; exact Or.inr (ih hq r hr) + +noncomputable def finiteSatisfaction (A : ZFSet.{u}) (ps : List SentenceForm) : ZFSet.{u} := + ZFSet.sUnion (ZFSet.range (fun i : Fin ps.length => + ZFSet.prod ({natSet (Encodable.encode ps[i])} : ZFSet.{u}) (truthSlice A ps[i]))) + +theorem mem_finiteSatisfaction (A z : ZFSet.{u}) (ps : List SentenceForm) : + z ∈ finiteSatisfaction A ps ↔ ∃ p ∈ ps, ∃ t ∈ truthSlice A p, + z = ZFSet.pair (natSet (Encodable.encode p)) t := by + rw [finiteSatisfaction,ZFSet.mem_sUnion] + constructor + · rintro ⟨s,hs,hz⟩ + obtain ⟨i,rfl⟩ := ZFSet.mem_range.mp hs + obtain ⟨k,hk,t,ht,hz⟩ := ZFSet.mem_prod.mp hz + rw [ZFSet.mem_singleton] at hk + subst k + exact ⟨ps[i],List.getElem_mem i.isLt,t,ht,hz⟩ + · rintro ⟨p,hp,t,ht,rfl⟩ + obtain ⟨i,hi,rfl⟩ := List.mem_iff_getElem.mp hp + refine ⟨_,ZFSet.mem_range_self ⟨i,hi⟩,?_⟩ + exact ZFSet.mem_prod.mpr ⟨_,ZFSet.mem_singleton.mpr rfl,t,ht,rfl⟩ + +theorem finiteSatisfaction_record (A : ZFSet.{u}) (ps : List SentenceForm) + (p : SentenceForm) {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) : + ZFSet.pair (natSet (Encodable.encode p)) (tupleCode v) ∈ finiteSatisfaction A ps ↔ + p ∈ ps ∧ p.bound ≤ n ∧ p.Sat (A : Set ZFSet) (tupleEnv v) := by + rw [mem_finiteSatisfaction] + constructor + · rintro ⟨q,hq,t,ht,he⟩ + obtain ⟨hc,ht'⟩ := ZFSet.pair_inj.mp he + have hpq : p = q := Encodable.encode_injective (natSet_injective hc) + subst q; subst t + exact ⟨hq,(truthSlice_record A p v hv).mp ht⟩ + · rintro ⟨hp,hb,hs⟩ + exact ⟨p,hp,tupleCode v,(truthSlice_record A p v hv).mpr ⟨hb,hs⟩,rfl⟩ + +theorem finiteSatisfaction_mem (M A : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) (ps : List SentenceForm) : finiteSatisfaction A ps ∈ M := by + have hω := sourceT_omega_mem M hM hT + have hn (n : ℕ) : natSet.{u} n ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩) + apply union_mem M hM hT.union + apply finite_range_mem M hM hT.pairing hT.union (hn 0) + intro i + exact product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + (singleton_mem M hM hT.pairing (hn _)) (truthSlice_mem M A hM hT hA ps[i]) + +theorem finiteSatisfaction_subset (A : ZFSet.{u}) (ps : List SentenceForm) : + finiteSatisfaction A ps ⊆ satisfactionSet A := by + intro z hz + obtain ⟨p,_,t,ht,rfl⟩ := (mem_finiteSatisfaction A z ps).mp hz + exact (ZFSet.mem_sep.mp ht).2 + +theorem finiteSatisfaction_covers (A : ZFSet.{u}) (p : SentenceForm) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) : + ZFSet.pair (natSet (Encodable.encode p)) (tupleCode v) ∈ finiteSatisfaction A (subformulas p) ↔ + ZFSet.pair (natSet (Encodable.encode p)) (tupleCode v) ∈ satisfactionSet A := by + rw [finiteSatisfaction_record A _ p v hv,satisfactionSet_record A p v hv] + exact and_iff_right (self_mem_subformulas p) + +def accepts (S : ZFSet.{u}) (p : SentenceForm) {n : ℕ} (v : Fin n → ZFSet.{u}) : Prop := + ZFSet.pair (natSet (Encodable.encode p)) (tupleCode v) ∈ S + +theorem certificate_correct (A : ZFSet.{u}) (root p : SentenceForm) + (hp : p ∈ subformulas root) {n : ℕ} (v : Fin n → ZFSet.{u}) + (hv : ∀ i, v i ∈ A) (hb : p.bound ≤ n) : + accepts (finiteSatisfaction A (subformulas root)) p v ↔ p.Sat (A : Set ZFSet) (tupleEnv v) := by + rw [accepts,finiteSatisfaction_record A _ p v hv] + exact ⟨fun h => h.2.2,fun h => ⟨hp,hb,h⟩⟩ + +theorem certificate_conj (A : ZFSet.{u}) (root p q : SentenceForm) + (hp : SentenceForm.conj p q ∈ subformulas root) {n : ℕ} (v : Fin n → ZFSet.{u}) + (hv : ∀ i, v i ∈ A) (hb : (SentenceForm.conj p q).bound ≤ n) : + accepts (finiteSatisfaction A (subformulas root)) (.conj p q) v ↔ + accepts (finiteSatisfaction A (subformulas root)) p v ∧ + accepts (finiteSatisfaction A (subformulas root)) q v := by + have hp' := subformulas_closed root _ hp p (by simp [subformulas,self_mem_subformulas]) + have hq' := subformulas_closed root _ hp q (by simp [subformulas,self_mem_subformulas]) + have hbp : p.bound ≤ n := by simp only [SentenceForm.bound] at hb; omega + have hbq : q.bound ≤ n := by simp only [SentenceForm.bound] at hb; omega + rw [certificate_correct A root _ hp v hv hb,certificate_correct A root p hp' v hv hbp, + certificate_correct A root q hq' v hv hbq] + rfl + +theorem certificate_neg (A : ZFSet.{u}) (root p : SentenceForm) + (hp : SentenceForm.neg p ∈ subformulas root) {n : ℕ} (v : Fin n → ZFSet.{u}) + (hv : ∀ i, v i ∈ A) (hb : p.bound ≤ n) : + accepts (finiteSatisfaction A (subformulas root)) (.neg p) v ↔ + ¬ accepts (finiteSatisfaction A (subformulas root)) p v := by + have hp' := subformulas_closed root _ hp p (by simp [subformulas,self_mem_subformulas]) + rw [certificate_correct A root _ hp v hv hb,certificate_correct A root p hp' v hv hb] + rfl + +theorem certificate_ex (A : ZFSet.{u}) (root p : SentenceForm) + (hp : SentenceForm.ex p ∈ subformulas root) {n : ℕ} (v : Fin n → ZFSet.{u}) + (hv : ∀ i, v i ∈ A) (hb : (SentenceForm.ex p).bound ≤ n) : + accepts (finiteSatisfaction A (subformulas root)) (.ex p) v ↔ + ∃ x ∈ A, accepts (finiteSatisfaction A (subformulas root)) p (Fin.cases x v) := by + have hp' := subformulas_closed root _ hp p (by simp [subformulas,self_mem_subformulas]) + have hbp : p.bound ≤ n+1 := by simp only [SentenceForm.bound] at hb; omega + rw [certificate_correct A root _ hp v hv hb] + change (∃ x ∈ A, p.Sat (A : Set ZFSet) (cons x (tupleEnv v))) ↔ _ + apply exists_congr; intro x + apply and_congr_right; intro hx + rw [certificate_correct A root p hp' (Fin.cases x v) (fun i => Fin.cases hx hv i) hbp, + tupleEnv_cons] + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteTerm.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteTerm.lean new file mode 100644 index 0000000000000000000000000000000000000000..e1ed2b12bf33e6e9de7ea3ecf8555e243e4a62bd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/FiniteTerm.lean @@ -0,0 +1,105 @@ +import OAI.Computability.DegreeRigidity.Effective.FiniteCodeBound +import Mathlib.SetTheory.ZFC.Rank + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace FiniteTerm + +noncomputable def tag (n : ℕ) (x : ZFSet.{u}) : ZFSet.{u} := ZFSet.pair (natSet n) x + +theorem tag_inj (n m : ℕ) (x y : ZFSet.{u}) : tag n x = tag m y ↔ n = m ∧ x = y := by + rw [tag,tag,ZFSet.pair_inj] + exact and_congr ⟨fun h => natSet_injective h,fun h => congrArg natSet h⟩ Iff.rfl + +inductive Eval (A B L O D : ZFSet.{u}) : ZFSet.{u} → ZFSet.{u} → Prop + | leaf {a x : ZFSet.{u}} : a ∈ A → x ∈ D → ZFSet.pair a x ∈ L → Eval A B L O D (tag 0 a) x + | app {o c x y : ZFSet.{u}} : o ∈ B → Eval A B L O D c x → y ∈ D → + ZFSet.pair (ZFSet.pair o x) y ∈ O → Eval A B L O D (tag 1 (ZFSet.pair o c)) y + | pair {a b x y : ZFSet.{u}} : Eval A B L O D a x → Eval A B L O D b y → + ZFSet.pair x y ∈ D → Eval A B L O D (tag 2 (ZFSet.pair a b)) (ZFSet.pair x y) + +theorem Eval.value_mem {A B L O D c x : ZFSet.{u}} (h : Eval A B L O D c x) : x ∈ D := by + cases h with + | leaf _ hx _ => exact hx + | app _ _ hx _ => exact hx + | pair _ _ hx => exact hx + +theorem Eval.code_finite {A B L O D t c x : ZFSet.{u}} + (hA : A ⊆ t) (hB : B ⊆ t) (hn : ∀ n, natSet.{u} n ∈ t) + (h : Eval A B L O D c x) : FiniteTuple.FiniteCode t c := by + induction h with + | leaf ha _ _ => exact (FiniteTuple.FiniteCode.atom _ (hn 0)).orderedPair (.atom _ (hA ha)) + | app ho _ _ _ ih => + exact (FiniteTuple.FiniteCode.atom _ (hn 1)).orderedPair + ((FiniteTuple.FiniteCode.atom _ (hB ho)).orderedPair ih) + | pair _ _ _ iha ihb => exact (FiniteTuple.FiniteCode.atom _ (hn 2)).orderedPair (iha.orderedPair ihb) + +def Step (A B L O K D f c v : ZFSet.{u}) : Prop := + (∃ a ∈ A, c = tag 0 a ∧ ZFSet.pair a v ∈ L) ∨ + (∃ o ∈ B, ∃ a ∈ K, ∃ x ∈ D, c = tag 1 (ZFSet.pair o a) ∧ + ZFSet.pair a x ∈ f ∧ ZFSet.pair (ZFSet.pair o x) v ∈ O) ∨ + (∃ a ∈ K, ∃ b ∈ K, ∃ x ∈ D, ∃ y ∈ D, c = tag 2 (ZFSet.pair a b) ∧ + ZFSet.pair a x ∈ f ∧ ZFSet.pair b y ∈ f ∧ v = ZFSet.pair x y) + +def Certificate (A B L O K D f : ZFSet.{u}) : Prop := + ∀ z ∈ f, ∃ c ∈ K, ∃ v ∈ D, z = ZFSet.pair c v ∧ Step A B L O K D f c v + +theorem Step.mono {A B L O K D f g c v : ZFSet.{u}} (hfg : f ⊆ g) + (h : Step A B L O K D f c v) : Step A B L O K D g c v := by + rcases h with h|h|h + · exact Or.inl h + · obtain ⟨o,ho,a,ha,x,hx,hc,hax,hox⟩ := h + exact Or.inr (Or.inl ⟨o,ho,a,ha,x,hx,hc,hfg hax,hox⟩) + · obtain ⟨a,ha,b,hb,x,hx,y,hy,hc,hax,hby,hv⟩ := h + exact Or.inr (Or.inr ⟨a,ha,b,hb,x,hx,y,hy,hc,hfg hax,hfg hby,hv⟩) + +theorem Certificate.subset {A B L O K D f : ZFSet.{u}} (hf : Certificate A B L O K D f) : + f ⊆ ZFSet.prod K D := by + intro z hz + obtain ⟨c,hc,v,hv,hz,_⟩ := hf z hz + exact ZFSet.mem_prod.mpr ⟨c,hc,v,hv,hz⟩ + +theorem Certificate.step {A B L O K D f c v : ZFSet.{u}} + (hf : Certificate A B L O K D f) (hp : ZFSet.pair c v ∈ f) : + c ∈ K ∧ v ∈ D ∧ Step A B L O K D f c v := by + obtain ⟨c',hc,v',hv,he,hs⟩ := hf _ hp + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp he + exact ⟨hc,hv,hs⟩ + +theorem pair_rank_left (x y : ZFSet.{u}) : ZFSet.rank x < ZFSet.rank (ZFSet.pair x y) := by + have ha : x ∈ ({x,y} : ZFSet.{u}) := ZFSet.mem_pair.mpr (Or.inl rfl) + have hb : ({x,y} : ZFSet.{u}) ∈ ZFSet.pair x y := ZFSet.mem_pair.mpr (Or.inr rfl) + exact (ZFSet.rank_lt_of_mem ha).trans (ZFSet.rank_lt_of_mem hb) + +theorem pair_rank_right (x y : ZFSet.{u}) : ZFSet.rank y < ZFSet.rank (ZFSet.pair x y) := by + have ha : y ∈ ({x,y} : ZFSet.{u}) := ZFSet.mem_pair.mpr (Or.inr rfl) + have hb : ({x,y} : ZFSet.{u}) ∈ ZFSet.pair x y := ZFSet.mem_pair.mpr (Or.inr rfl) + exact (ZFSet.rank_lt_of_mem ha).trans (ZFSet.rank_lt_of_mem hb) + +theorem Certificate.sound {A B L O K D f : ZFSet.{u}} + (hf : Certificate A B L O K D f) (c v : ZFSet.{u}) + (hp : ZFSet.pair c v ∈ f) : Eval A B L O D c v := by + have wf : WellFounded (fun a b : ZFSet.{u} => ZFSet.rank a < ZFSet.rank b) := + InvImage.wf ZFSet.rank Ordinal.lt_wf + induction c using wf.induction generalizing v with + | h c ih => + have hv := (hf.step hp).2.1 + rcases (hf.step hp).2.2 with h|h|h + · obtain ⟨a,ha,rfl,hav⟩ := h + exact .leaf ha hv hav + · obtain ⟨o,ho,a,_,x,_,rfl,hax,hov⟩ := h + have hlt := (pair_rank_right o a).trans (pair_rank_right (natSet 1) (ZFSet.pair o a)) + exact .app ho (ih a hlt x hax) hv hov + · obtain ⟨a,_,b,_,x,_,y,_,rfl,hax,hby,rfl⟩ := h + have ha := (pair_rank_left a b).trans (pair_rank_right (natSet 2) (ZFSet.pair a b)) + have hb := (pair_rank_right a b).trans (pair_rank_right (natSet 2) (ZFSet.pair a b)) + exact .pair (ih a ha x hax) (ih b hb y hby) hv + +end FiniteTerm +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/FormulaIsomorphism.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/FormulaIsomorphism.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f0a93a4428541f59be4cac3519f6902b55d3635 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/FormulaIsomorphism.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaSyntax + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +universe u + +theorem map_cons (j : ZFSet.{u} → ZFSet.{u}) (x : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (fun i => j (cons x e i)) = cons (j x) (fun i => j (e i)) := by + funext i; cases i <;> rfl + +theorem Formula.realize_isomorphism (A B : ZFSet.{u}) (j : ZFSet.{u} → ZFSet.{u}) + (hin : ∀ x ∈ A, j x ∈ B) + (hout : ∀ y ∈ B, ∃ x ∈ A, j x = y) + (hi : ∀ x ∈ A, ∀ y ∈ A, j x = j y → x = y) + (hm : ∀ x ∈ A, ∀ y ∈ A, j x ∈ j y ↔ x ∈ y) + (φ : Formula) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) : + φ.Realize A e ↔ φ.Realize B (fun i => j (e i)) := by + induction φ generalizing e with + | equal i k => + exact ⟨congrArg j,hi _ (he i) _ (he k)⟩ + | member i k => exact (hm _ (he i) _ (he k)).symm + | conj φ ψ ihφ ihψ => exact and_congr (ihφ e he) (ihψ e he) + | neg φ ih => exact not_congr (ih e he) + | existsMem i φ ih => + have he' (x : ZFSet.{u}) (hx : x ∈ A) : ∀ n, cons x e n ∈ A := by + intro n; cases n with + | zero => exact hx + | succ n => exact he n + constructor + · rintro ⟨x,hx,hxi,hφ⟩ + refine ⟨j x,hin x hx,(hm x hx (e i) (he i)).mpr hxi,?_⟩ + have h := (ih (cons x e) (he' x hx)).mp hφ + rwa [map_cons] at h + · rintro ⟨y,hy,hyi,hφ⟩ + obtain ⟨x,hx,rfl⟩ := hout y hy + refine ⟨x,hx,(hm x hx (e i) (he i)).mp hyi,?_⟩ + apply (ih (cons x e) (he' x hx)).mpr + rwa [map_cons] + +theorem SigmaFormula.realize_isomorphism (A B : ZFSet.{u}) (j : ZFSet.{u} → ZFSet.{u}) + (hin : ∀ x ∈ A, j x ∈ B) + (hout : ∀ y ∈ B, ∃ x ∈ A, j x = y) + (hi : ∀ x ∈ A, ∀ y ∈ A, j x = j y → x = y) + (hm : ∀ x ∈ A, ∀ y ∈ A, j x ∈ j y ↔ x ∈ y) + (φ : SigmaFormula) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ A) : + φ.Realize A e ↔ φ.Realize B (fun i => j (e i)) := by + induction φ generalizing e with + | bounded φ => exact φ.realize_isomorphism A B j hin hout hi hm e he + | existsSet φ ih => + have he' (x : ZFSet.{u}) (hx : x ∈ A) : ∀ n, cons x e n ∈ A := by + intro n; cases n with + | zero => exact hx + | succ n => exact he n + constructor + · rintro ⟨x,hx,hφ⟩ + refine ⟨j x,hin x hx,?_⟩ + have h := (ih (cons x e) (he' x hx)).mp hφ + rwa [map_cons] at h + · rintro ⟨y,hy,hφ⟩ + obtain ⟨x,hx,rfl⟩ := hout y hy + apply Exists.intro x + refine ⟨hx,?_⟩ + apply (ih (cons x e) (he' x hx)).mpr + rwa [map_cons] + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/LevySigmaNormalization.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/LevySigmaNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..74dbc571d56ef072981cf1d28c1a61ca92db74cf --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/LevySigmaNormalization.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaDisjunction + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +inductive LevySigma where + | bounded (φ : Formula) + | conj (φ ψ : LevySigma) + | disj (φ ψ : LevySigma) + | existsSet (φ : LevySigma) + | existsMem (a : ℕ) (φ : LevySigma) + | allMem (a : ℕ) (φ : LevySigma) + +namespace LevySigma +def Realize (M : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : LevySigma → Prop + | .bounded φ => φ.Realize M e + | .conj φ ψ => φ.Realize M e ∧ ψ.Realize M e + | .disj φ ψ => φ.Realize M e ∨ ψ.Realize M e + | .existsSet φ => ∃ x ∈ M, φ.Realize M (cons x e) + | .existsMem a φ => ∃ x ∈ M, x ∈ e a ∧ φ.Realize M (cons x e) + | .allMem a φ => ∀ x ∈ M, x ∈ e a → φ.Realize M (cons x e) + +def normalize : LevySigma → SigmaFormula + | .bounded φ => .bounded φ + | .conj φ ψ => .conj φ.normalize ψ.normalize + | .disj φ ψ => .disj φ.normalize ψ.normalize + | .existsSet φ => .existsSet φ.normalize + | .existsMem a φ => .existsMem a φ.normalize + | .allMem a φ => .allMem a φ.normalize + +theorem normalize_correct (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hC : SigmaCollection M) + (φ : LevySigma) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + φ.normalize.Realize M e ↔ φ.Realize M e := by + have hω := omega_mem M hM hS hI + have h0 := hM _ hω _ ZFSet.omega_zero + induction φ generalizing e with + | bounded φ => rfl + | conj φ ψ ihφ ihψ => exact (SigmaFormula.realize_conj _ _ _ _).trans (and_congr (ihφ e he) (ihψ e he)) + | disj φ ψ ihφ ihψ => exact (SigmaFormula.realize_disj M h0 _ _ _).trans (or_congr (ihφ e he) (ihψ e he)) + | existsSet φ ih => + simp only [normalize,SigmaFormula.Realize,Realize] + apply exists_congr; intro x + apply and_congr_right; intro hx + exact ih (cons x e) (by intro i; cases i <;> simp [cons,he,hx]) + | existsMem a φ ih => + rw [normalize,SigmaFormula.realize_existsMem] + change (∃ x ∈ M, x ∈ e a ∧ _) ↔ ∃ x ∈ M, x ∈ e a ∧ _ + apply exists_congr; intro x + apply and_congr_right; intro hx + exact and_congr_right (fun _ => ih (cons x e) (by intro i; cases i <;> simp [cons,he,hx])) + | allMem a φ ih => + rw [normalize,SigmaFormula.realize_allMem M hM hP hU hS hR hI hC _ _ _ he] + change (∀ x ∈ e a, _) ↔ ∀ x ∈ M, x ∈ e a → _ + constructor + · intro h x hx hxa + exact (ih (cons x e) (by intro i; cases i <;> simp [cons,he,hx])).mp (h x hxa) + · intro h x hxa + have hx := hM _ (he a) x hxa + exact (ih (cons x e) (by intro i; cases i <;> simp [cons,he,hx])).mpr (h x hx hxa) +end LevySigma + +def LevySigmaSeparation (M : ZFSet.{u}) : Prop := + ∀ (φ : LevySigma) (e : ℕ → ZFSet.{u}), (∀ i, e i ∈ M) → ∀ a ∈ M, + ∃ b ∈ M, ∀ x ∈ M, x ∈ b ↔ x ∈ a ∧ φ.Realize M (cons x e) + +def LevySigmaReplacement (M : ZFSet.{u}) : Prop := + ∀ (φ : LevySigma) (e : ℕ → ZFSet.{u}), (∀ i, e i ∈ M) → ∀ a ∈ M, + (∀ x ∈ a, ∃ y ∈ M, φ.Realize M (cons y (cons x e)) ∧ + ∀ z ∈ M, φ.Realize M (cons z (cons x e)) → z = y) → + ∃ b ∈ M, ∀ y ∈ M, y ∈ b ↔ ∃ x ∈ a, φ.Realize M (cons y (cons x e)) + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/LevySigmaSchemas.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/LevySigmaSchemas.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f6e4c6ff7ccd5ff7d1300c2d27b0dec06de7a87 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/LevySigmaSchemas.lean @@ -0,0 +1,72 @@ +import OAI.Computability.DegreeRigidity.Syntax.LevySigmaNormalization + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +theorem levy_sigma_schemas (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) : + LevySigmaSeparation M ∧ LevySigmaReplacement M := by + have hC := sigma_collection M hM hP hU hPow hS hR hI hAC + have correct := LevySigma.normalize_correct M hM hP hU hS.bounded hR hI hC + constructor + · intro φ e he a ha + obtain ⟨b,hb,hbdef⟩ := hS φ.normalize e he a ha + refine ⟨b,hb,?_⟩ + intro x hx + rw [hbdef x hx,correct φ (cons x e) (by intro i; cases i <;> simp [cons,he,hx])] + · intro φ e he a ha htotal + have eq (x y : ZFSet.{u}) (hx : x ∈ M) (hy : y ∈ M) : + φ.normalize.Realize M (cons y (cons x e)) ↔ φ.Realize M (cons y (cons x e)) := + correct φ _ (by + intro i; rcases i with _|i; exact hy + rcases i with _|i; exact hx + exact he i) + obtain ⟨b,hb,hbdef⟩ := hR φ.normalize e he a ha (by + intro x hx + have hxM := hM a ha x hx + obtain ⟨y,hy,hφ,hu⟩ := htotal x hx + exact ⟨y,hy,(eq x y hxM hy).mpr hφ,fun z hz h => hu z hz ((eq x z hxM hz).mp h)⟩) + refine ⟨b,hb,?_⟩ + intro y hy + rw [hbdef y hy] + apply exists_congr; intro x + exact and_congr_right (fun hx => eq x y (hM a ha x hx) hy) + +def SigmaFormula.toLevy : SigmaFormula → LevySigma + | .bounded φ => .bounded φ + | .existsSet φ => .existsSet φ.toLevy + +theorem SigmaFormula.realize_toLevy (φ : SigmaFormula) (M : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + φ.toLevy.Realize M e ↔ φ.Realize M e := by + induction φ generalizing e with + | bounded φ => rfl + | existsSet φ ih => + simp only [toLevy,LevySigma.Realize,Realize] + apply exists_congr; intro x + exact and_congr_right (fun _ => ih (cons x e)) + +theorem LevySigmaSeparation.finitePrefix {M : ZFSet.{u}} (hS : LevySigmaSeparation M) : SigmaSeparation M := by + intro φ e he a ha + obtain ⟨b,hb,hbdef⟩ := hS φ.toLevy e he a ha + exact ⟨b,hb,fun x hx => (hbdef x hx).trans (and_congr_right (fun _ => φ.realize_toLevy M _))⟩ + +theorem LevySigmaReplacement.finitePrefix {M : ZFSet.{u}} (hR : LevySigmaReplacement M) : SigmaReplacement M := by + intro φ e he a ha htotal + obtain ⟨b,hb,hbdef⟩ := hR φ.toLevy e he a ha (by + intro x hx + obtain ⟨y,hy,hφ,hu⟩ := htotal x hx + exact ⟨y,hy,(φ.realize_toLevy M _).mpr hφ,fun z hz h => hu z hz ((φ.realize_toLevy M _).mp h)⟩) + refine ⟨b,hb,?_⟩ + intro y hy + rw [hbdef y hy] + apply exists_congr; intro x + exact and_congr_right (fun _ => φ.realize_toLevy M _) + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/MembershipInterpretation.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/MembershipInterpretation.lean new file mode 100644 index 0000000000000000000000000000000000000000..2493953f9c72f587615e3876f31c41eb1959003a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/MembershipInterpretation.lean @@ -0,0 +1,32 @@ +import OAI.Computability.DegreeRigidity.SetModels.ExtensionBasicAxioms +import OAI.Computability.DegreeRigidity.SetModels.RecursiveNameSymmetry + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory +universe u + +def Formula.toMembership : Formula → RecursiveNames.Formula + | .equal i j => .equal i j + | .member i j => .member i j + | .conj φ ψ => .conj φ.toMembership ψ.toMembership + | .neg φ => .neg φ.toMembership + | .existsMem i φ => .existsSet (.conj (.member 0 (i+1)) φ.toMembership) + +theorem Formula.realize_toMembership (φ : Formula) (M : ZFSet.{u}) + (env : ℕ → ZFSet.{u}) : + φ.toMembership.Realize (M : Set ZFSet.{u}) env ↔ φ.Realize M env := by + induction φ generalizing env with + | equal => rfl + | member => rfl + | conj φ ψ ihφ ihψ => exact and_congr (ihφ env) (ihψ env) + | neg φ ih => exact not_congr (ih env) + | existsMem i φ ih => + have hcons (x : ZFSet.{u}) : (fun n => if n = 0 then x else env (n-1)) = cons x env := by + funext n + cases n <;> simp [cons] + simp [toMembership,RecursiveNames.Formula.Realize,Formula.Realize,hcons,ih] + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/PiOneOneSatisfaction.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/PiOneOneSatisfaction.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3bae033c8de1068b2bf3d7435368091ccddd635 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/PiOneOneSatisfaction.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DegreeRigidity.Representation.SourceTArithmeticAbsoluteness +import OAI.Computability.DegreeRigidity.Computability.ArithmeticParameterFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel UniformArithmetic ArithmeticPersistence ArithmeticTree +universe u + +namespace Formula + +def piOneOneMatrix (φ : Formula) : Formula := + allMem 0 (oracleParameters φ 2 3 4 (fun i => match i with | 0 => 5 | 1 => 6 | _+2 => 0)) +end Formula + +noncomputable def piOneOneEnv (S Q : ZFSet.{u}) (A R : Oracle) (v : ℕ) : ℕ → ZFSet.{u} := + cons S (cons ZFSet.omega (cons Q (cons (natSet v) (cons (realCode A) (fun _ => realCode R))))) + +theorem eval_piOneOneMatrix {φ : Formula} {P : Predicate} (hφ : DefinesArithmetic.{u} φ P) + (S Q : ZFSet.{u}) (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ Q) + (hS : ∀ x ∈ S, ∃ H : Oracle, realCode H = x) (A R : Oracle) (v : ℕ) : + (Formula.piOneOneMatrix φ).Eval (piOneOneEnv S Q A R v) ↔ + ∀ H : Oracle, realCode H ∈ S → P (parameters A R H) v := by + simp only [Formula.piOneOneMatrix,Formula.eval_allMem] + have he (H : Oracle) : + (Formula.oracleParameters φ 2 3 4 (fun i => match i with | 0 => 5 | 1 => 6 | _+2 => 0)).Eval + (cons (realCode H) (piOneOneEnv S Q A R v)) ↔ P (parameters A R H) v := by + apply Formula.oracleParameters_spec hφ 2 3 4 _ _ rfl hQ _ _ v rfl + intro i; rcases i with _|i; rfl + rcases i with _|i <;> rfl + constructor + · intro h H hH + exact (he H).mp (h (realCode H) hH) + · intro h x hx + obtain ⟨H,rfl⟩ := hS x hx + exact (he H).mpr (h H hx) + +theorem sourceT_piOneOne_satisfaction (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + {φ : Formula} {P : Predicate} (hφ : DefinesArithmetic.{u} φ P) (hP : Arith P) + (S Q : ZFSet.{u}) (hSM : S ∈ M) (hQM : Q ∈ M) + (hS : ∀ H : Oracle, realCode H ∈ S ↔ H ∈ modelReals M) + (hSd : ∀ x ∈ S, ∃ H : Oracle, realCode H = x) + (hQ : ∀ f : ℕ → ℕ, ∀ k, finiteNaturalGraph f k ∈ Q) + (A R : Oracle) (hA : A ∈ modelReals M) (hR : R ∈ modelReals M) (v : ℕ) : + (Formula.piOneOneMatrix φ).Realize M (piOneOneEnv S Q A R v) ↔ + ∀ H : Oracle, P (parameters A R H) v := by + have hω := sourceT_omega_mem M hM hT + have he : ∀ i, piOneOneEnv S Q A R v i ∈ M := by + intro i; rcases i with _|i; exact hSM + rcases i with _|i; exact hω + rcases i with _|i; exact hQM + rcases i with _|i; exact hM _ hω _ ((mem_omega _).mpr ⟨v,rfl⟩) + rcases i with _|i; exact hA + exact hR + rw [Formula.absolute _ M hM _ he,eval_piOneOneMatrix hφ S Q hQ hSd A R v] + simp only [hS] + exact sourceT_forall_arithmetic_real M hM hT hP A R hA hR v + +theorem sourceT_persistence_formula : ∃ φ : Formula, ∀ M : ZFSet.{u}, + Transitive M → SourceT M → ∃ S Q : ZFSet.{u}, S ∈ M ∧ Q ∈ M ∧ + ∀ A R : Oracle, A ∈ modelReals M → R ∈ modelReals M → + ((Formula.piOneOneMatrix φ).Realize M (piOneOneEnv S Q A R 0) ↔ Property A R) := by + obtain ⟨P,hP,hiff⟩ := source_4_2_1 + obtain ⟨φ,hφ⟩ := arithmetic_bounded_definition.{u} hP + refine ⟨φ,fun M hM hT => ?_⟩ + have hS := hT.separation.finitePrefix.bounded + obtain ⟨Q,hQM,_,hQ⟩ := internal_finite_natural_graph_bound M hM hT.pairing hT.union hT.powerSet hS + (sourceT_omega_mem M hM hT) + obtain ⟨S,hSM,hS,hSd⟩ := internal_real_power M hM hT + have hd : ∀ x ∈ S, ∃ H : Oracle, realCode H = x := by + intro x hx; obtain ⟨H,_,hH⟩ := hSd x hx; exact ⟨H,hH⟩ + exact ⟨S,Q,hSM,hQM,fun A R hA hR => + (sourceT_piOneOne_satisfaction M hM hT hφ hP S Q hSM hQM hS hd hQ A R hA hR 0).trans + (hiff A R).symm⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/PrimitivePredicateFormula.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/PrimitivePredicateFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0947b76ca5141d448898f1a5087d7e0a3bbb327 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/PrimitivePredicateFormula.lean @@ -0,0 +1,43 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalPrimitiveGraph + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +universe u + +def DefinesPredicate (φ : Formula) (P : ℕ → Prop) : Prop := + ∀ e : ℕ → ZFSet.{u}, e 1 = ZFSet.omega → + (∀ g : ℕ → ℕ, ∀ k, finiteNaturalGraph g k ∈ e 2) → ∀ n, e 0 = natSet n → + (φ.Eval e ↔ P n) + +def Formula.numericalPredicate (φ : Formula) : Formula := .existsMem 1 + (.conj (unary φ 2 3 1 0) (.neg (.empty 0))) + +theorem primitive_predicate_bounded {P : ℕ → Prop} (hP : PrimrecPred P) : + ∃ φ : Formula, DefinesPredicate.{u} φ P := by + obtain ⟨inst,hP⟩ := hP + let : DecidablePred P := inst + let f := fun n => Encodable.encode (decide (P n)) + have hf : Nat.Primrec f := Primrec.nat_iff.mp (Primrec.encode.comp hP) + obtain ⟨φ,hφ⟩ := primitive_bounded_definition.{u} hf + refine ⟨φ.numericalPredicate,?_⟩ + intro e ho hQ n hn + have hw (w : ZFSet.{u}) := Formula.unary_spec hφ 2 3 1 0 (cons w e) ho hQ n hn + have htest : (natSet.{u} (f n) ≠ ∅) ↔ P n := by + change (natSet.{u} (f n) ≠ natSet 0) ↔ P n + rw [natSet_injective.ne_iff] + dsimp [f] + by_cases h : P n <;> simp [h] + simp only [Formula.numericalPredicate,Formula.Eval,Formula.eval_empty,cons_zero] + constructor + · rintro ⟨w,_,hf',hne⟩ + obtain rfl := (hw w).mp hf' + exact htest.mp hne + · intro h + refine ⟨natSet (f n),?_,(hw _).mpr rfl,htest.mpr h⟩ + rw [ho]; exact (mem_omega _).mpr ⟨f n,rfl⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SatisfactionCertificateBound.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SatisfactionCertificateBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..da6ecb343f11093a6ec4fdb6a55931918f4f51f6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SatisfactionCertificateBound.lean @@ -0,0 +1,45 @@ +import OAI.Computability.DegreeRigidity.Syntax.SatisfactionRecursion + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +theorem satisfactionSet_subset_product (A : ZFSet.{u}) : + satisfactionSet A ⊆ ZFSet.prod ZFSet.omega (tupleSpace A) := by + intro z hz + obtain ⟨⟨⟨n,p,v⟩,_,_⟩,rfl⟩ := ZFSet.mem_range.mp hz + exact ZFSet.mem_prod.mpr ⟨natSet (Encodable.encode p),(mem_omega _).mpr ⟨_,rfl⟩, + tupleCode (fun i => label A (v i)), + (mem_tupleSpace A _).mpr ⟨n,_,fun i => label_mem A (v i),rfl⟩,rfl⟩ + +theorem internal_certificate_bound (M A : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) : + ∃ Q ∈ M, + (∀ S, S ∈ Q ↔ S ∈ M ∧ S ⊆ ZFSet.prod ZFSet.omega (tupleSpace A)) ∧ + ∀ ps : List SentenceForm, finiteSatisfaction A ps ∈ Q := by + obtain ⟨Q,hQ,hdef⟩ := internal_power M hM hT.powerSet + (product_mem M hM hT.pairing hT.union hT.powerSet hT.separation.finitePrefix.bounded + (sourceT_omega_mem M hM hT) (tupleSpace_mem M A hM hT hA)) + refine ⟨Q,hQ,hdef,fun ps => (hdef _).mpr ⟨finiteSatisfaction_mem M A hM hT hA ps,?_⟩⟩ + exact fun z hz => satisfactionSet_subset_product A (finiteSatisfaction_subset A ps hz) + +theorem satisfaction_iff_bounded_recursion (M A : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) : + ∃ Q ∈ M, ∀ (p : SentenceForm) (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → + (accepts (satisfactionSet A) p v ↔ ∃ S ∈ Q, TruthRecursion A p S ∧ accepts S p v) := by + obtain ⟨Q,hQ,hdef,hfinite⟩ := internal_certificate_bound M A hM hT hA + refine ⟨Q,hQ,fun p n v hv => ?_⟩ + constructor + · intro hs + exact ⟨finiteSatisfaction A (subformulas p),hfinite _,finiteSatisfaction_recursion A p, + (finiteSatisfaction_covers A p v hv).mpr hs⟩ + · rintro ⟨S,hS,hrec,haccept⟩ + exact (satisfaction_iff_internal_recursion M A hM hT hA p v hv).mpr + ⟨S,(hdef S).mp hS |>.1,hrec,haccept⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SatisfactionRecursion.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SatisfactionRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a1ab4f59a00fa8417e4d16163e7154943e1f322 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SatisfactionRecursion.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.Syntax.FiniteSatisfactionCertificate + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +def truthStep (A S : ZFSet.{u}) {n : ℕ} (v : Fin n → ZFSet.{u}) : SentenceForm → Prop + | .equal i j => tupleEnv v i = tupleEnv v j + | .member i j => tupleEnv v i ∈ tupleEnv v j + | .conj p q => accepts S p v ∧ accepts S q v + | .neg p => ¬ accepts S p v + | .ex p => ∃ x ∈ A, accepts S p (Fin.cases x v) + +def TruthRecursion (A : ZFSet.{u}) (root : SentenceForm) (S : ZFSet.{u}) : Prop := + (∀ z ∈ S, ∃ p ∈ subformulas root, ∃ (n : ℕ) (v : Fin n → ZFSet.{u}), + (∀ i, v i ∈ A) ∧ p.bound ≤ n ∧ z = ZFSet.pair (natSet (Encodable.encode p)) (tupleCode v)) ∧ + ∀ p ∈ subformulas root, ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), + (∀ i, v i ∈ A) → p.bound ≤ n → (accepts S p v ↔ truthStep A S v p) + +theorem finiteSatisfaction_recursion (A : ZFSet.{u}) (root : SentenceForm) : + TruthRecursion A root (finiteSatisfaction A (subformulas root)) := by + constructor + · intro z hz + obtain ⟨p,hp,t,ht,rfl⟩ := (mem_finiteSatisfaction A z _).mp hz + obtain ⟨n,v,hv,rfl⟩ := (mem_tupleSpace A t).mp (ZFSet.mem_sep.mp ht).1 + exact ⟨p,hp,n,v,hv,((truthSlice_record A p v hv).mp ht).1,rfl⟩ + · intro p hp n v hv hb + cases p with + | equal i j => exact certificate_correct A root _ hp v hv hb + | member i j => exact certificate_correct A root _ hp v hv hb + | conj p q => exact certificate_conj A root p q hp v hv hb + | neg p => exact certificate_neg A root p hp v hv hb + | ex p => exact certificate_ex A root p hp v hv hb + +theorem TruthRecursion.correct {A S : ZFSet.{u}} {root : SentenceForm} + (h : TruthRecursion A root S) (p : SentenceForm) (hp : p ∈ subformulas root) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) (hb : p.bound ≤ n) : + accepts S p v ↔ p.Sat (A : Set ZFSet) (tupleEnv v) := by + induction p generalizing n with + | equal i j => exact h.2 _ hp n v hv hb + | member i j => exact h.2 _ hp n v hv hb + | conj p q ihp ihq => + have hp' := subformulas_closed root _ hp p (by simp [subformulas,self_mem_subformulas]) + have hq' := subformulas_closed root _ hp q (by simp [subformulas,self_mem_subformulas]) + have hbp : p.bound ≤ n := by simp only [SentenceForm.bound] at hb; omega + have hbq : q.bound ≤ n := by simp only [SentenceForm.bound] at hb; omega + exact (h.2 _ hp n v hv hb).trans (and_congr (ihp hp' v hv hbp) (ihq hq' v hv hbq)) + | neg p ih => + have hp' := subformulas_closed root _ hp p (by simp [subformulas,self_mem_subformulas]) + exact (h.2 _ hp n v hv hb).trans (not_congr (ih hp' v hv hb)) + | ex p ih => + have hp' := subformulas_closed root _ hp p (by simp [subformulas,self_mem_subformulas]) + have hbp : p.bound ≤ n+1 := by simp only [SentenceForm.bound] at hb; omega + refine (h.2 (.ex p) hp n v hv hb).trans ?_ + simp only [truthStep,SentenceForm.Sat] + apply exists_congr; intro x + apply and_congr_right; intro hx + rw [ih hp' (Fin.cases x v) (fun i => Fin.cases hx hv i) hbp,tupleEnv_cons] + +theorem TruthRecursion.unique {A S T : ZFSet.{u}} {root : SentenceForm} + (hS : TruthRecursion A root S) (hT : TruthRecursion A root T) : S = T := by + have sub {U V : ZFSet.{u}} (hU : TruthRecursion A root U) (hV : TruthRecursion A root V) : U ⊆ V := by + intro z hz + obtain ⟨p,hp,n,v,hv,hb,rfl⟩ := hU.1 z hz + exact (hV.correct p hp v hv hb).mpr ((hU.correct p hp v hv hb).mp hz) + exact ZFSet.ext (fun _ => ⟨fun hz => sub hS hT hz,fun hz => sub hT hS hz⟩) + +theorem internal_truthRecursion (M A : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) (p : SentenceForm) : + ∃ S ∈ M, TruthRecursion A p S ∧ ∀ T, TruthRecursion A p T → T = S := by + refine ⟨finiteSatisfaction A (subformulas p),finiteSatisfaction_mem M A hM hT hA _, + finiteSatisfaction_recursion A p,?_⟩ + exact fun T h => h.unique (finiteSatisfaction_recursion A p) + +theorem satisfaction_iff_internal_recursion (M A : ZFSet.{u}) (hM : Transitive M) + (hT : SourceT M) (hA : A ∈ M) (p : SentenceForm) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) : + accepts (satisfactionSet A) p v ↔ + ∃ S ∈ M, TruthRecursion A p S ∧ accepts S p v := by + constructor + · intro h + exact ⟨finiteSatisfaction A (subformulas p),finiteSatisfaction_mem M A hM hT hA _, + finiteSatisfaction_recursion A p,(finiteSatisfaction_covers A p v hv).mpr h⟩ + · rintro ⟨S,_,hS,hs⟩ + have he := hS.unique (finiteSatisfaction_recursion A p) + rw [he] at hs + exact (finiteSatisfaction_covers A p v hv).mp hs + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SatisfactionSystemCertificate.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SatisfactionSystemCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd2deb9e36fb23577bef4dde616109e78abf9252 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SatisfactionSystemCertificate.lean @@ -0,0 +1,74 @@ +import OAI.Computability.DegreeRigidity.Effective.TupleSystemCertificate + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions +universe u + +def SatisfactionSystem (Q B A G T H Z : ZFSet.{u}) : Prop := + TupleSystem A G T ∧ + (∀ c ∈ ZFSet.omega, ∀ F ∈ Q, LeastFamily Q c F → + ∃ S ∈ H, SetTruthRecursion Q B G A T F S) ∧ + (∀ z ∈ Z, SatisfactionWitness Q B G H A T z) ∧ + ∀ c ∈ ZFSet.omega, ∀ t ∈ T, ∀ S ∈ H, + TruthWitness Q B G A T c S → ZFSet.pair c t ∈ S → ZFSet.pair c t ∈ Z + +theorem satisfactionSystem_definable {M : ZFSet.{u}} (C : Context M) + {Q B : ZFSet.{u}} (hQ : Q ∈ M) (hB : B ∈ M) (a G T H Z : ℕ) : + Definable M (fun e => SatisfactionSystem Q B (e a) (e G) (e T) (e H) (e Z)) := by + have ht := defAllParam (defAllParam (defImp (leastFamily_param C hQ 1 0) + ((setTruthRecursion_variable C hQ hB (a+3) (G+3) (T+3) 1 0).existsMem (H+2))) hQ) C.omega_mem + have hn := defAllMem (satisfactionWitness_variable C hQ hB (a+1) (G+1) (H+1) (T+1) 0) Z + have hc := defAllParam (defAllMem (defAllMem + (defImp (truthWitness_variable C hQ hB (a+3) (G+3) (T+3) 2 0) + (defImp (defPairMem C 2 1 0) (defPairMem C 2 1 (Z+3)))) (H+2)) (T+1)) C.omega_mem + exact (tupleSystem_definable C a G T).and (ht.and (hn.and hc)) + +theorem SatisfactionSystem.exact {Q B A G T H Z : ZFSet.{u}} + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) + (h : SatisfactionSystem Q B A G T H Z) : + T = tupleSpace A ∧ Z = satisfactionSet A ∧ + (∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → tupleGraph v ∈ G) ∧ + ∀ p : SentenceForm, finiteSatisfaction A (subformulas p) ∈ H := by + obtain ⟨ht,hg⟩ := h.1.exact + subst T + have hh (p : SentenceForm) : finiteSatisfaction A (subformulas p) ∈ H := by + obtain ⟨S,hS,hs⟩ := h.2.1 _ ((mem_omega _).mpr ⟨Encodable.encode p,rfl⟩) + (family p) (hQ p) ((leastFamily_spec Q _ p (hQ p)).mpr rfl) + have he := ((setTruthRecursion_spec Q B G A S hQ hB hg p).mp hs).unique + (finiteSatisfaction_recursion A p) + exact he ▸ hS + refine ⟨rfl,?_,hg,hh⟩ + apply ZFSet.ext; intro z + rw [← satisfactionWitness_spec Q B G H A z hQ hB hg hh] + constructor + · exact h.2.2.1 z + · rintro ⟨c,hc,t,ht,S,hS,hs,hct,rfl⟩ + exact h.2.2.2 c hc t ht S hS hs hct + +theorem satisfactionSystem_canonical (Q B A G H : ZFSet.{u}) + (hQ : ∀ p : SentenceForm, family p ∈ Q) + (hB : ∀ p : SentenceForm, supportGraph p ∈ B) + (hG : ∀ (n : ℕ) (v : Fin n → ZFSet.{u}), (∀ i, v i ∈ A) → tupleGraph v ∈ G) + (hH : ∀ p : SentenceForm, finiteSatisfaction A (subformulas p) ∈ H) : + SatisfactionSystem Q B A G (tupleSpace A) H (satisfactionSet A) := by + refine ⟨tupleSystem_canonical A G hG,?_,?_,?_⟩ + · intro c _ F _ hf + obtain ⟨p,rfl⟩ := setClosed_valid F hf.2.1 c hf.1 + have he := (leastFamily_spec Q F p (hQ p)).mp hf + subst F + exact ⟨_,hH p,(setTruthRecursion_spec Q B G A _ hQ hB hG p).mpr + (finiteSatisfaction_recursion A p)⟩ + · intro z hz + exact (satisfactionWitness_spec Q B G H A z hQ hB hG hH).mpr hz + · intro c hc t ht S hS hs hct + exact (satisfactionWitness_spec Q B G H A _ hQ hB hG hH).mp + ⟨c,hc,t,ht,S,hS,hs,hct,rfl⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceCode.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceCode.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d32bc6780f19c9437b4d5219242426ae07ba411 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceCode.lean @@ -0,0 +1,78 @@ +import OAI.Computability.DegreeRigidity.SetModels.ElementaryLanguage + +namespace OAI + + +namespace TuringRigidity.SentenceCoding +open ElementaryModel + +def atom (n : ℕ) : ℕ := Nat.pair 0 n +def cell (a b : ℕ) : ℕ := Nat.pair (a+1) b +def binary (tag a b : ℕ) : ℕ := cell (atom tag) (cell a (cell b (atom 0))) +def unary (tag a : ℕ) : ℕ := cell (atom tag) (cell a (atom 0)) + +theorem encode_equal (i j : ℕ) : + Encodable.encode (SentenceForm.equal i j) = binary 0 (atom i) (atom j) := rfl +theorem encode_member (i j : ℕ) : + Encodable.encode (SentenceForm.member i j) = binary 1 (atom i) (atom j) := rfl +theorem encode_conj (p q : SentenceForm) : + Encodable.encode (SentenceForm.conj p q) = binary 2 (Encodable.encode p) (Encodable.encode q) := rfl +theorem encode_neg (p : SentenceForm) : + Encodable.encode (SentenceForm.neg p) = unary 3 (Encodable.encode p) := rfl +theorem encode_ex (p : SentenceForm) : + Encodable.encode (SentenceForm.ex p) = unary 4 (Encodable.encode p) := rfl + +theorem cell_left_lt (a b : ℕ) : a < cell a b := by + have h := Nat.left_le_pair (a+1) b + unfold cell; omega + +theorem cell_right_le (a b : ℕ) : b ≤ cell a b := Nat.right_le_pair _ _ + +theorem binary_left_lt (t a b : ℕ) : a < binary t a b := + lt_of_lt_of_le (cell_left_lt a _) (cell_right_le _ _) +theorem binary_right_lt (t a b : ℕ) : b < binary t a b := + lt_of_lt_of_le (cell_left_lt b _) (le_trans (cell_right_le _ _) (cell_right_le _ _)) +theorem unary_child_lt (t a : ℕ) : a < unary t a := + lt_of_lt_of_le (cell_left_lt a _) (cell_right_le _ _) + +def Step (C : ℕ → Prop) (c : ℕ) : Prop := + (∃ i j, c = binary 0 (atom i) (atom j)) ∨ + (∃ i j, c = binary 1 (atom i) (atom j)) ∨ + (∃ a b, c = binary 2 a b ∧ C a ∧ C b) ∨ + (∃ a, c = unary 3 a ∧ C a) ∨ + (∃ a, c = unary 4 a ∧ C a) + +def Children (C : ℕ → Prop) : SentenceForm → Prop + | .equal _ _ | .member _ _ => True + | .conj p q => C (Encodable.encode p) ∧ C (Encodable.encode q) + | .neg p | .ex p => C (Encodable.encode p) + +theorem step_encode (C : ℕ → Prop) (p : SentenceForm) : + Step C (Encodable.encode p) ↔ Children C p := by + cases p <;> + simp [Step,Children,encode_equal,encode_member,encode_conj,encode_neg,encode_ex, + binary,unary,cell,atom,Nat.pair_eq_pair] + +def Closed (C : ℕ → Prop) : Prop := ∀ c, C c → Step C c + +theorem Closed.valid {C : ℕ → Prop} (h : Closed C) (c : ℕ) (hc : C c) : + ∃ p : SentenceForm, c = Encodable.encode p := by + induction c using Nat.strong_induction_on with + | h c ih => + rcases h c hc with he|hm|ha|hn|hx + · obtain ⟨i,j,rfl⟩ := he; exact ⟨.equal i j,(encode_equal i j).symm⟩ + · obtain ⟨i,j,rfl⟩ := hm; exact ⟨.member i j,(encode_member i j).symm⟩ + · obtain ⟨a,b,rfl,ha,hb⟩ := ha + obtain ⟨p,rfl⟩ := ih a (binary_left_lt _ _ _) ha + obtain ⟨q,rfl⟩ := ih b (binary_right_lt _ _ _) hb + exact ⟨.conj p q,(encode_conj p q).symm⟩ + · obtain ⟨a,rfl,ha⟩ := hn + obtain ⟨p,rfl⟩ := ih a (unary_child_lt _ _) ha + exact ⟨.neg p,(encode_neg p).symm⟩ + · obtain ⟨a,rfl,ha⟩ := hx + obtain ⟨p,rfl⟩ := ih a (unary_child_lt _ _) ha + exact ⟨.ex p,(encode_ex p).symm⟩ + +end TuringRigidity.SentenceCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceCodeDefinability.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceCodeDefinability.lean new file mode 100644 index 0000000000000000000000000000000000000000..338418f22b4cae81cc14fe56c9ba3c4aa174222a --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceCodeDefinability.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DegreeRigidity.Syntax.SentenceCode +import OAI.Computability.DegreeRigidity.SetModels.SetModelArithmeticSyntax + +namespace OAI + + +namespace TuringRigidity.SentenceCoding +open BoundedSetTheory TransitiveNameModel BoundedDefinability SetModelFunctions SetModelSyntax +universe u + +variable {M : ZFSet.{u}} + +theorem defOr {P Q : (ℕ → ZFSet.{u}) → Prop} + (hP : Definable M P) (hQ : Definable M Q) : Definable M (fun e => P e ∨ Q e) := + (hP.neg.and hQ.neg).neg.congr (fun _ => by tauto) + +theorem defImp {P Q : (ℕ → ZFSet.{u}) → Prop} + (hP : Definable M P) (hQ : Definable M Q) : Definable M (fun e => P e → Q e) := + (hP.and hQ.neg).neg.congr (fun _ => by tauto) + +theorem defAllMem {P : (ℕ → ZFSet.{u}) → Prop} + (h : Definable M P) (i : ℕ) : Definable M (fun e => ∀ x ∈ e i, P (cons x e)) := + (h.neg.existsMem i).neg.congr (fun _ => by simp) + +theorem defAllParam {P : (ℕ → ZFSet.{u}) → Prop} {a : ZFSet.{u}} + (h : Definable M P) (ha : a ∈ M) : Definable M (fun e => ∀ x ∈ a, P (cons x e)) := + (h.neg.existsParam ha).neg.congr (fun _ => by simp) + +theorem defMemberParam {a : ZFSet.{u}} (ha : a ∈ M) (i : ℕ) : + Definable M (fun e => e i ∈ a) := + ⟨.member (2*i) 1,fun _ => a,fun _ => ha,fun e => by simp [Formula.Eval,mix]⟩ + +theorem defSubset (C : Context M) (i j : ℕ) : Definable M (fun e => e i ⊆ e j) := + defAllMem (member_definable C 0 (j+1)) i + +def UnaryGraph (f : ℕ → ℕ) (x y : ZFSet.{u}) : Prop := + ∃ n : ℕ, x = natSet n ∧ y = natSet (f n) + +def BinaryGraph (f : ℕ → ℕ → ℕ) (x y z : ZFSet.{u}) : Prop := + ∃ n m : ℕ, x = natSet n ∧ y = natSet m ∧ z = natSet (f n m) + +theorem unaryGraph_definable (C : Context M) (f : ℕ → ℕ) (hf : Primrec f) (i j : ℕ) : + Definable M (fun e => UnaryGraph f (e i) (e j)) := by + obtain ⟨g,hg,hcode⟩ := primrec_graph C hf + refine (((defMemberParam C.omega_mem i).and (defMemberParam C.omega_mem j)).and + (pairMem_param hg i j)).congr ?_ + intro e + simp only [UnaryGraph,mem_omega] + constructor + · rintro ⟨⟨⟨n,hn⟩,⟨m,hm⟩⟩,h⟩ + refine ⟨n,hn,?_⟩ + have hm' : m = f n := (hcode n m).mp (by rwa [hn,hm] at h) + rw [← hm',hm] + · rintro ⟨n,hn,hm⟩ + exact ⟨⟨⟨n,hn⟩,⟨f n,hm⟩⟩,by rw [hn,hm]; exact (hcode n (f n)).mpr rfl⟩ + +theorem binaryGraph_definable (C : Context M) (f : ℕ → ℕ → ℕ) + (hf : Primrec₂ f) (i j k : ℕ) : + Definable M (fun e => BinaryGraph f (e i) (e j) (e k)) := by + have hu : Primrec (Nat.unpaired f) := hf.comp (Primrec.fst.comp Primrec.unpair) (Primrec.snd.comp Primrec.unpair) + have hd := ((pairCode_definable C (i+1) (j+1) 0).and + (unaryGraph_definable C (Nat.unpaired f) hu 0 (k+1))).existsParam C.omega_mem + refine hd.congr ?_ + intro e + simp only [cons_zero,cons_succ,UnaryGraph,BinaryGraph] + constructor + · rintro ⟨z,_,hz,n,hn,hk⟩ + have hxy := hz.1 + obtain ⟨a,ha,b,hb,he⟩ := ZFSet.mem_prod.mp hxy + obtain ⟨hi,hj⟩ := ZFSet.pair_inj.mp he + obtain ⟨a,rfl⟩ := (mem_omega a).mp ha + obtain ⟨b,rfl⟩ := (mem_omega b).mp hb + have heq : n = Nat.pair a b := (pairCode_nat a b n).mp (by rwa [hi,hj,hn] at hz) + exact ⟨a,b,hi,hj,by rw [heq] at hk; simpa [Nat.unpaired,Nat.unpair_pair] using hk⟩ + · rintro ⟨a,b,hi,hj,hk⟩ + refine ⟨natSet (Nat.pair a b),(mem_omega _).mpr ⟨_,rfl⟩,?_,Nat.pair a b,rfl,?_⟩ + · rw [hi,hj]; exact (pairCode_nat a b _).mpr rfl + · simpa [Nat.unpaired,Nat.unpair_pair] using hk + +theorem atom_primrec : Primrec atom := Primrec₂.natPair.comp (Primrec.const 0) Primrec.id + +theorem cell_primrec : Primrec₂ cell := + Primrec₂.natPair.comp (Primrec.succ.comp Primrec.fst) Primrec.snd + +theorem binary_primrec (t : ℕ) : Primrec₂ (binary t) := + cell_primrec.comp (Primrec.const (atom t)) + (cell_primrec.comp Primrec.fst (cell_primrec.comp Primrec.snd (Primrec.const (atom 0)))) + +theorem unary_primrec (t : ℕ) : Primrec (unary t) := + cell_primrec.comp (Primrec.const (atom t)) + (cell_primrec.comp Primrec.id (Primrec.const (atom 0))) + +theorem atomic_primrec (t : ℕ) : Primrec₂ (fun i j => binary t (atom i) (atom j)) := + (binary_primrec t).comp (atom_primrec.comp Primrec.fst) (atom_primrec.comp Primrec.snd) + +end TuringRigidity.SentenceCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceCodeFamily.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceCodeFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..711bd20cd91a6fa79452a01f9f8087872134c310 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceCodeFamily.lean @@ -0,0 +1,133 @@ +import OAI.Computability.DegreeRigidity.Syntax.SentenceCode +import OAI.Computability.DegreeRigidity.Syntax.FiniteSatisfactionCertificate + +namespace OAI + + +namespace TuringRigidity.SentenceCoding +open ElementaryModel RelativeConstructible BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def family (p : SentenceForm) : ZFSet.{u} := + ZFSet.range (fun i : Fin (subformulas p).length => + natSet (Encodable.encode (subformulas p)[i])) + +theorem mem_family (p : SentenceForm) (z : ZFSet.{u}) : + z ∈ family p ↔ ∃ q ∈ subformulas p, z = natSet (Encodable.encode q) := by + rw [family,ZFSet.mem_range] + constructor + · rintro ⟨i,rfl⟩; exact ⟨_,List.getElem_mem i.isLt,rfl⟩ + · rintro ⟨q,hq,rfl⟩ + obtain ⟨i,hi,rfl⟩ := List.mem_iff_getElem.mp hq + exact ⟨⟨i,hi⟩,rfl⟩ + +theorem code_mem_family (p q : SentenceForm) : + natSet.{u} (Encodable.encode q) ∈ family p ↔ q ∈ subformulas p := by + rw [mem_family] + constructor + · rintro ⟨r,hr,he⟩ + have h : q = r := Encodable.encode_injective (natSet_injective he) + exact h ▸ hr + · intro h; exact ⟨q,h,rfl⟩ + +theorem family_subset_omega (p : SentenceForm) : family p ⊆ ZFSet.omega.{u} := by + intro z hz + obtain ⟨q,_,rfl⟩ := (mem_family p z).mp hz + exact (mem_omega _).mpr ⟨_,rfl⟩ + +theorem family_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + (hU : BoundedSetTheory.Union M) (hω : ZFSet.omega.{u} ∈ M) (p : SentenceForm) : + family p ∈ M := by + have hn (k : ℕ) : natSet.{u} k ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨k,rfl⟩) + exact finite_range_mem M hM hP hU (hn 0) _ _ (fun _ => hn _) + +theorem family_closed (p : SentenceForm) : + Closed (fun n => natSet.{u} n ∈ family p) := by + intro n hn + obtain ⟨q,hq,he⟩ := (mem_family p _).mp hn + have he' := natSet_injective he + subst n + rw [step_encode] + have hc := subformulas_closed p q hq + cases q with + | equal i j => trivial + | member i j => trivial + | conj a b => + exact ⟨(code_mem_family p a).mpr (hc a (by simp [subformulas,self_mem_subformulas])), + (code_mem_family p b).mpr (hc b (by simp [subformulas,self_mem_subformulas]))⟩ + | neg a => exact (code_mem_family p a).mpr (hc a (by simp [subformulas,self_mem_subformulas])) + | ex a => exact (code_mem_family p a).mpr (hc a (by simp [subformulas,self_mem_subformulas])) + +theorem Closed.subformulas {C : ℕ → Prop} (h : Closed C) (p : SentenceForm) + (hp : C (Encodable.encode p)) : ∀ q ∈ subformulas p, C (Encodable.encode q) := by + induction p with + | equal i j => simpa [RelativeConstructible.subformulas] using hp + | member i j => simpa [RelativeConstructible.subformulas] using hp + | conj p r ihp ihr => + have hc := (step_encode C (.conj p r)).mp (h _ hp) + intro q hq + simp only [RelativeConstructible.subformulas,List.mem_cons,List.mem_append] at hq + rcases hq with rfl|hq|hq + · exact hp + · exact ihp hc.1 q hq + · exact ihr hc.2 q hq + | neg p ih => + have hc := (step_encode C (.neg p)).mp (h _ hp) + intro q hq + simp only [RelativeConstructible.subformulas,List.mem_cons] at hq + rcases hq with rfl|hq + · exact hp + · exact ih hc q hq + | ex p ih => + have hc := (step_encode C (.ex p)).mp (h _ hp) + intro q hq + simp only [RelativeConstructible.subformulas,List.mem_cons] at hq + rcases hq with rfl|hq + · exact hp + · exact ih hc q hq + +def SetClosed (S : ZFSet.{u}) : Prop := + S ⊆ ZFSet.omega ∧ Closed (fun n => natSet n ∈ S) + +theorem family_setClosed (p : SentenceForm) : SetClosed (family.{u} p) := + ⟨family_subset_omega p,family_closed p⟩ + +theorem family_least (p : SentenceForm) (S : ZFSet.{u}) (hS : SetClosed S) + (hp : natSet (Encodable.encode p) ∈ S) : family p ⊆ S := by + intro z hz + obtain ⟨q,hq,rfl⟩ := (mem_family p z).mp hz + exact hS.2.subformulas p hp q hq + +def LeastFamily (Q c S : ZFSet.{u}) : Prop := + c ∈ S ∧ SetClosed S ∧ + ∀ T ∈ Q, c ∈ T → SetClosed T → S ⊆ T + +theorem leastFamily_spec (Q S : ZFSet.{u}) (p : SentenceForm) (hQ : family p ∈ Q) : + LeastFamily Q (natSet (Encodable.encode p)) S ↔ S = family p := by + constructor + · rintro ⟨hc,hs,hm⟩ + exact ZFSet.ext (fun z => ⟨fun hz => hm _ hQ + ((code_mem_family p p).mpr (self_mem_subformulas p)) (family_setClosed p) hz, + fun hz => family_least p S hs hc hz⟩) + · rintro rfl + exact ⟨(code_mem_family p p).mpr (self_mem_subformulas p),family_setClosed p, + fun T _ hc hs => family_least p T hs hc⟩ + +theorem setClosed_valid (S : ZFSet.{u}) (hS : SetClosed S) (c : ZFSet.{u}) (hc : c ∈ S) : + ∃ p : SentenceForm, c = natSet (Encodable.encode p) := by + obtain ⟨n,rfl⟩ := (mem_omega c).mp (hS.1 hc) + obtain ⟨p,rfl⟩ := hS.2.valid n hc + exact ⟨p,rfl⟩ + +theorem internal_family_bound (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hω : ZFSet.omega.{u} ∈ M) : + ∃ Q ∈ M, (∀ S, S ∈ Q ↔ S ∈ M ∧ S ⊆ ZFSet.omega) ∧ + ∀ p : SentenceForm, family p ∈ Q := by + obtain ⟨Q,hQ,hdef⟩ := internal_power M hM hPow hω + exact ⟨Q,hQ,hdef,fun p => (hdef _).mpr + ⟨family_mem M hM hP hU hω p,family_subset_omega p⟩⟩ + +end TuringRigidity.SentenceCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceFamilyFormula.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceFamilyFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8959c54e8e86911bd06dd637e4875e37c0d97dd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceFamilyFormula.lean @@ -0,0 +1,107 @@ +import OAI.Computability.DegreeRigidity.Syntax.SentenceCodeFamily +import OAI.Computability.DegreeRigidity.Syntax.SentenceCodeDefinability + +namespace OAI + + +namespace TuringRigidity.SentenceCoding +open ElementaryModel BoundedSetTheory TransitiveNameModel BoundedDefinability SetModelFunctions +universe u + +variable {M : ZFSet.{u}} + +def SetStep (S c : ZFSet.{u}) : Prop := + (∃ x ∈ ZFSet.omega, ∃ y ∈ ZFSet.omega, BinaryGraph (fun i j => binary 0 (atom i) (atom j)) x y c) ∨ + (∃ x ∈ ZFSet.omega, ∃ y ∈ ZFSet.omega, BinaryGraph (fun i j => binary 1 (atom i) (atom j)) x y c) ∨ + (∃ x ∈ S, ∃ y ∈ S, BinaryGraph (binary 2) x y c) ∨ + (∃ x ∈ S, UnaryGraph (unary 3) x c) ∨ + (∃ x ∈ S, UnaryGraph (unary 4) x c) + +theorem setStep_nat (S : ZFSet.{u}) (n : ℕ) : + SetStep S (natSet n) ↔ Step (fun k => natSet k ∈ S) n := by + simp only [SetStep,Step,BinaryGraph,UnaryGraph] + have hn (a b : ℕ) : natSet.{u} a = natSet b ↔ a = b := natSet_injective.eq_iff + simp only [hn] + constructor + · intro h + rcases h with h|h|h|h|h + · obtain ⟨x,_,y,_,i,j,_,_,he⟩ := h; exact Or.inl ⟨i,j,he⟩ + · obtain ⟨x,_,y,_,i,j,_,_,he⟩ := h; exact Or.inr (Or.inl ⟨i,j,he⟩) + · obtain ⟨x,hx,y,hy,i,j,rfl,rfl,he⟩ := h + exact Or.inr (Or.inr (Or.inl ⟨i,j,he,hx,hy⟩)) + · obtain ⟨x,hx,i,rfl,he⟩ := h + exact Or.inr (Or.inr (Or.inr (Or.inl ⟨i,he,hx⟩))) + · obtain ⟨x,hx,i,rfl,he⟩ := h + exact Or.inr (Or.inr (Or.inr (Or.inr ⟨i,he,hx⟩))) + · intro h + have hw (k : ℕ) : natSet.{u} k ∈ ZFSet.omega := (mem_omega _).mpr ⟨k,rfl⟩ + rcases h with h|h|h|h|h + · obtain ⟨i,j,he⟩ := h + exact Or.inl ⟨_,hw i,_,hw j,i,j,rfl,rfl,he⟩ + · obtain ⟨i,j,he⟩ := h + exact Or.inr (Or.inl ⟨_,hw i,_,hw j,i,j,rfl,rfl,he⟩) + · obtain ⟨i,j,he,hi,hj⟩ := h + exact Or.inr (Or.inr (Or.inl ⟨_,hi,_,hj,i,j,rfl,rfl,he⟩)) + · obtain ⟨i,he,hi⟩ := h + exact Or.inr (Or.inr (Or.inr (Or.inl ⟨_,hi,i,rfl,he⟩))) + · obtain ⟨i,he,hi⟩ := h + exact Or.inr (Or.inr (Or.inr (Or.inr ⟨_,hi,i,rfl,he⟩))) + +theorem setStep_definable (C : Context M) (s c : ℕ) : + Definable M (fun e => SetStep (e s) (e c)) := by + have he := ((binaryGraph_definable C _ (atomic_primrec 0) 1 0 (c+2)).existsParam + C.omega_mem).existsParam C.omega_mem + have hm := ((binaryGraph_definable C _ (atomic_primrec 1) 1 0 (c+2)).existsParam + C.omega_mem).existsParam C.omega_mem + have ha := ((binaryGraph_definable C _ (binary_primrec 2) 1 0 (c+2)).existsMem (s+1)).existsMem s + have hn := (unaryGraph_definable C _ (unary_primrec 3) 0 (c+1)).existsMem s + have hx := (unaryGraph_definable C _ (unary_primrec 4) 0 (c+1)).existsMem s + exact defOr he (defOr hm (defOr ha (defOr hn hx))) + +theorem setClosed_spec (S : ZFSet.{u}) : + SetClosed S ↔ S ⊆ ZFSet.omega ∧ ∀ c ∈ S, SetStep S c := by + constructor + · rintro ⟨hs,hc⟩ + refine ⟨hs,fun c hm => ?_⟩ + obtain ⟨n,rfl⟩ := (mem_omega c).mp (hs hm) + exact (setStep_nat S n).mpr (hc n hm) + · rintro ⟨hs,hc⟩ + exact ⟨hs,fun n hn => (setStep_nat S n).mp (hc _ hn)⟩ + +theorem setClosed_definable (C : Context M) (s : ℕ) : + Definable M (fun e => SetClosed (e s)) := by + have hs := defAllMem (defMemberParam C.omega_mem 0) s + have hc := defAllMem (setStep_definable C (s+1) 0) s + exact (hs.and hc).congr (fun e => (setClosed_spec (e s)).symm) + +theorem leastFamily_definable (C : Context M) (q c s : ℕ) : + Definable M (fun e => LeastFamily (e q) (e c) (e s)) := by + have hm := defAllMem (defImp (member_definable C (c+1) 0) + (defImp (setClosed_definable C 0) (defSubset C (s+1) 0))) q + exact (member_definable C c s).and ((setClosed_definable C s).and hm) + +theorem uniform_family_definition (C : Context M) : + ∃ Q ∈ M, ∃ p : Formula, ∃ d : ℕ → ZFSet.{u}, (∀ i, d i ∈ M) ∧ + ∀ c S, p.Eval (mix (cons c (fun _ => S)) d) ↔ + ∃ root : SentenceForm, c = natSet (Encodable.encode root) ∧ S = family root := by + obtain ⟨Q,hQ,_,hf⟩ := internal_family_bound M C.transitive C.pairing C.union C.power C.omega_mem + have hd : Definable M (fun e => LeastFamily Q (e 0) (e 1)) := by + + have hs : ({Q} : ZFSet.{u}) ∈ M := singleton_mem M C.transitive C.pairing hQ + exact (((equal_param hQ 0).and (leastFamily_definable C 0 1 2)).existsParam hs).congr + (fun e => by simp only [ZFSet.mem_singleton,cons_zero,cons_succ]; simp) + obtain ⟨p,d,hd,hdef⟩ := hd + refine ⟨Q,hQ,p,d,hd,?_⟩ + intro c S + rw [hdef] + change LeastFamily Q c S ↔ _ + constructor + · intro h + obtain ⟨root,hr⟩ := setClosed_valid S h.2.1 c h.1 + exact ⟨root,hr,(leastFamily_spec Q S root (hf root)).mp (hr ▸ h)⟩ + · rintro ⟨root,rfl,rfl⟩ + exact (leastFamily_spec Q (family root) root (hf root)).mpr rfl + +end TuringRigidity.SentenceCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceInlining.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceInlining.lean new file mode 100644 index 0000000000000000000000000000000000000000..e86d5882a387adbda043496ddaea3f97aa79c4e5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceInlining.lean @@ -0,0 +1,96 @@ +import OAI.Computability.DegreeRigidity.Syntax.FiniteGraphSatisfaction +import OAI.Computability.DegreeRigidity.SetModels.ElementarySatisfaction + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +def skipValue (i : ℕ) : ℕ := match i with | 0 => 0 | j+1 => j+2 + +theorem skipValue_env (x y : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (fun i => cons x (cons y e) (skipValue i)) = cons x e := by + funext i; cases i <;> rfl + +def bindComputed : ℕ → (ℕ → SentenceForm) → SentenceForm → SentenceForm + | 0, _, p => p + | n+1, f, p => .ex (.conj (f n) + (bindComputed n (fun i => (f i).rename skipValue) p)) + +theorem bindComputed_spec (M : ZFSet.{u}) (n : ℕ) + (f : ℕ → SentenceForm) (p : SentenceForm) (e w : ℕ → ZFSet.{u}) + (hw : ∀ i, i < n → w i ∈ M) + (hf : ∀ i, i < n → ∀ x ∈ M, + (f i).Sat (M : Set ZFSet) (cons x e) ↔ x = w i) : + (bindComputed n f p).Sat (M : Set ZFSet) e ↔ + p.Sat (M : Set ZFSet) (prependValues w n e) := by + induction n generalizing f e with + | zero => rfl + | succ n ih => + have hf' (y : ZFSet.{u}) : ∀ i, i < n → ∀ x ∈ M, + ((f i).rename skipValue).Sat (M : Set ZFSet) (cons x (cons y e)) ↔ x = w i := by + intro i hi x hx + rw [SentenceForm.sat_rename,skipValue_env] + exact hf i (by omega) x hx + change (∃ x ∈ M, (f n).Sat (M : Set ZFSet) (cons x e) ∧ + (bindComputed n (fun i => (f i).rename skipValue) p).Sat + (M : Set ZFSet) (cons x e)) ↔ _ + constructor + · rintro ⟨x,hx,hfx,hp⟩ + obtain rfl := (hf n (by omega) x hx).mp hfx + exact (ih _ _ (fun i hi => hw i (by omega)) (hf' (w n))).mp hp + · intro hp + exact ⟨w n,hw n (by omega),(hf n (by omega) _ (hw n (by omega))).mpr rfl, + (ih _ _ (fun i hi => hw i (by omega)) (hf' (w n))).mpr hp⟩ + +noncomputable def subsetBody (n out a : ℕ) (p : SentenceForm) : SentenceForm := + SentenceForm.all (SentenceForm.iff (.member 0 (n+out+1)) + (.conj (.member 0 (n+a+1)) (fromBounded (setBounded p (n+a+1) id)))) + +theorem subsetBody_spec (M : ZFSet.{u}) (hM : Transitive M) + (n out a : ℕ) (p : SentenceForm) (hp : p.bound ≤ n+1) + (e w : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) (hw : ∀ i, i < n → w i ∈ M) : + (subsetBody n out a p).Sat (M : Set ZFSet) (prependValues w n e) ↔ + e out = definedSubset (e a) p (fun i : Fin n => w i) := by + have hpre (i : ℕ) : prependValues w n e i ∈ M := by + by_cases hi : i < n + · rw [prependValues_lt _ _ _ _ hi]; exact hw i hi + · have hi' : i = n+(i-n) := by omega + rw [hi',prependValues_tail]; exact he _ + have htruth (x : ZFSet.{u}) (hx : x ∈ M) : + (fromBounded (setBounded p (n+a+1) id)).Sat (M : Set ZFSet) + (cons x (prependValues w n e)) ↔ + p.Sat (e a : Set ZFSet) (cons x (tupleEnv (fun i : Fin n => w i))) := by + rw [bounded_sat,setBounded_absolute p M hM _ _ _ + (by intro i; cases i; exact hx; exact hpre _)] + simp only [cons_succ,prependValues_tail,id_eq] + apply p.finite_support + intro i hi + cases i with + | zero => rfl + | succ i => + change prependValues w n e i = tupleEnv (fun j : Fin n => w j) i + rw [prependValues_lt _ _ _ _ (by omega)] + simp [tupleEnv,show i < n by omega] + simp only [subsetBody,SentenceForm.sat_all,SentenceForm.sat_iff,SentenceForm.Sat, + cons_zero,cons_succ,prependValues_tail] + constructor + · intro h + apply ZFSet.ext; intro x + rw [mem_definedSubset] + constructor + · intro hx + have hxM := hM _ (he out) x hx + obtain ⟨ha,ht⟩ := (h x hxM).mp hx + exact ⟨ha,(htruth x hxM).mp ht⟩ + · rintro ⟨ha,ht⟩ + have hxM := hM _ (he a) x ha + exact (h x hxM).mpr ⟨ha,(htruth x hxM).mpr ht⟩ + · intro h x hx + rw [h,mem_definedSubset] + exact and_congr Iff.rfl (htruth x hx).symm + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceSupportCertificate.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceSupportCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..97ebe891ff680b9331bc632179cb2d9f96a9f737 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceSupportCertificate.lean @@ -0,0 +1,116 @@ +import OAI.Computability.DegreeRigidity.Syntax.SentenceCodeFamily + +namespace OAI + + +namespace TuringRigidity.SentenceCoding +open ElementaryModel RelativeConstructible BoundedSetTheory TransitiveNameModel +universe u + +noncomputable def supportGraph (p : SentenceForm) : ZFSet.{u} := + ZFSet.range (fun i : Fin (subformulas p).length => + ZFSet.pair (natSet (Encodable.encode (subformulas p)[i])) (natSet (subformulas p)[i].bound)) + +theorem mem_supportGraph (p : SentenceForm) (z : ZFSet.{u}) : + z ∈ supportGraph p ↔ ∃ q ∈ subformulas p, + z = ZFSet.pair (natSet (Encodable.encode q)) (natSet q.bound) := by + rw [supportGraph,ZFSet.mem_range] + constructor + · rintro ⟨i,rfl⟩; exact ⟨_,List.getElem_mem i.isLt,rfl⟩ + · rintro ⟨q,hq,rfl⟩ + obtain ⟨i,hi,rfl⟩ := List.mem_iff_getElem.mp hq + exact ⟨⟨i,hi⟩,rfl⟩ + +def HasBound (G : ZFSet.{u}) (p : SentenceForm) (n : ℕ) : Prop := + ZFSet.pair (natSet (Encodable.encode p)) (natSet n) ∈ G + +theorem supportGraph_bound (p q : SentenceForm) (n : ℕ) : + HasBound (supportGraph.{u} p) q n ↔ q ∈ subformulas p ∧ n = q.bound := by + rw [HasBound,mem_supportGraph] + constructor + · rintro ⟨r,hr,he⟩ + obtain ⟨hc,hb⟩ := ZFSet.pair_inj.mp he + have hqr : q = r := Encodable.encode_injective (natSet_injective hc) + subst r + exact ⟨hr,natSet_injective hb⟩ + · rintro ⟨hq,rfl⟩; exact ⟨q,hq,rfl⟩ + +def SupportStep (G : ZFSet.{u}) : SentenceForm → ℕ → Prop + | .equal i j, b | .member i j, b => b = max i j + 1 + | .conj p q, b => ∃ i j, HasBound G p i ∧ HasBound G q j ∧ b = max i j + | .neg p, b => HasBound G p b + | .ex p, b => ∃ i, HasBound G p i ∧ b = i-1 + +def SupportRecursion (root : SentenceForm) (G : ZFSet.{u}) : Prop := + (∀ z ∈ G, ∃ p ∈ subformulas root, ∃ n : ℕ, + z = ZFSet.pair (natSet (Encodable.encode p)) (natSet n)) ∧ + ∀ p ∈ subformulas root, ∀ n, HasBound G p n ↔ SupportStep G p n + +theorem supportGraph_recursion (root : SentenceForm) : SupportRecursion root (supportGraph.{u} root) := by + constructor + · intro z hz + obtain ⟨p,hp,rfl⟩ := (mem_supportGraph root z).mp hz + exact ⟨p,hp,p.bound,rfl⟩ + · intro p hp n + rw [supportGraph_bound, and_iff_right hp] + have hc := subformulas_closed root p hp + cases p with + | equal i j => rfl + | member i j => rfl + | conj p q => + have hp' := hc p (by simp [subformulas,self_mem_subformulas]) + have hq' := hc q (by simp [subformulas,self_mem_subformulas]) + simp [SupportStep,supportGraph_bound,hp',hq',SentenceForm.bound] + | neg p => + have hp' := hc p (by simp [subformulas,self_mem_subformulas]) + simp [SupportStep,supportGraph_bound,hp',SentenceForm.bound] + | ex p => + have hp' := hc p (by simp [subformulas,self_mem_subformulas]) + simp [SupportStep,supportGraph_bound,hp',SentenceForm.bound] + +theorem SupportRecursion.correct {root : SentenceForm} {G : ZFSet.{u}} + (h : SupportRecursion root G) (p : SentenceForm) (hp : p ∈ subformulas root) (n : ℕ) : + HasBound G p n ↔ n = p.bound := by + induction p generalizing n with + | equal i j => exact h.2 _ hp n + | member i j => exact h.2 _ hp n + | conj p q ihp ihq => + have hp' := subformulas_closed root _ hp p (by simp [subformulas,self_mem_subformulas]) + have hq' := subformulas_closed root _ hp q (by simp [subformulas,self_mem_subformulas]) + rw [h.2 _ hp n] + simp [SupportStep,ihp hp',ihq hq',SentenceForm.bound] + | neg p ih => + have hp' := subformulas_closed root _ hp p (by simp [subformulas,self_mem_subformulas]) + exact (h.2 _ hp n).trans (ih hp' n) + | ex p ih => + have hp' := subformulas_closed root _ hp p (by simp [subformulas,self_mem_subformulas]) + rw [h.2 _ hp n] + simp [SupportStep,ih hp',SentenceForm.bound] + +theorem SupportRecursion.unique {root : SentenceForm} {G : ZFSet.{u}} + (h : SupportRecursion root G) : G = supportGraph root := by + apply ZFSet.ext; intro z + constructor + · intro hz + obtain ⟨p,hp,n,rfl⟩ := h.1 z hz + exact (supportGraph_bound root p n).mpr ⟨hp,(h.correct p hp n).mp hz⟩ + · intro hz + obtain ⟨p,hp,rfl⟩ := (mem_supportGraph root z).mp hz + exact (h.correct p hp p.bound).mpr rfl + +theorem supportGraph_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + (hU : BoundedSetTheory.Union M) (hω : ZFSet.omega.{u} ∈ M) (p : SentenceForm) : + supportGraph p ∈ M := by + have hn (k : ℕ) : natSet.{u} k ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨k,rfl⟩) + exact finite_range_mem M hM hP hU (hn 0) _ _ + (fun _ => orderedPair_mem M hM hP (hn _) (hn _)) + +theorem supportGraph_subset (p : SentenceForm) : + supportGraph p ⊆ ZFSet.prod ZFSet.omega.{u} ZFSet.omega := by + intro z hz + obtain ⟨q,_,rfl⟩ := (mem_supportGraph p z).mp hz + exact ZFSet.mem_prod.mpr ⟨_,(mem_omega _).mpr ⟨_,rfl⟩,_,(mem_omega _).mpr ⟨_,rfl⟩,rfl⟩ + +end TuringRigidity.SentenceCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceSupportFormula.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceSupportFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..d30752cd279447a1851340367018d7f14f46cf8b --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SentenceSupportFormula.lean @@ -0,0 +1,101 @@ +import OAI.Computability.DegreeRigidity.Syntax.SentenceSupportCertificate +import OAI.Computability.DegreeRigidity.Syntax.SentenceFamilyFormula + +namespace OAI + + +namespace TuringRigidity.SentenceCoding +open ElementaryModel RelativeConstructible BoundedSetTheory TransitiveNameModel +open BoundedDefinability SetModelFunctions SetModelReals +universe u + +variable {M : ZFSet.{u}} + +def SetSupportStep (G c b : ZFSet.{u}) : Prop := + (∃ i ∈ ZFSet.omega, ∃ j ∈ ZFSet.omega, + BinaryGraph (fun i j => binary 0 (atom i) (atom j)) i j c ∧ BinaryGraph (fun i j => max i j + 1) i j b) ∨ + (∃ i ∈ ZFSet.omega, ∃ j ∈ ZFSet.omega, + BinaryGraph (fun i j => binary 1 (atom i) (atom j)) i j c ∧ BinaryGraph (fun i j => max i j + 1) i j b) ∨ + (∃ i ∈ ZFSet.omega, ∃ j ∈ ZFSet.omega, ∃ a ∈ ZFSet.omega, ∃ d ∈ ZFSet.omega, + BinaryGraph (binary 2) i j c ∧ ZFSet.pair i a ∈ G ∧ ZFSet.pair j d ∈ G ∧ BinaryGraph max a d b) ∨ + (∃ i ∈ ZFSet.omega, UnaryGraph (unary 3) i c ∧ ZFSet.pair i b ∈ G) ∨ + (∃ i ∈ ZFSet.omega, ∃ a ∈ ZFSet.omega, + UnaryGraph (unary 4) i c ∧ ZFSet.pair i a ∈ G ∧ UnaryGraph (fun n => n-1) a b) + +theorem setSupportStep_encode (G : ZFSet.{u}) (p : SentenceForm) (b : ℕ) : + SetSupportStep G (natSet (Encodable.encode p)) (natSet b) ↔ SupportStep G p b := by + unfold SetSupportStep + simp_rw [omega_exists] + simp only [BinaryGraph,UnaryGraph,natSet_injective.eq_iff] + cases p <;> + simp [SupportStep,HasBound,encode_equal,encode_member,encode_conj,encode_neg,encode_ex, + binary,unary,cell,atom,Nat.pair_eq_pair] + +theorem defPairMem (C : Context M) (i j g : ℕ) : + Definable M (fun e => ZFSet.pair (e i) (e j) ∈ e g) := + ⟨.pairMem (2*i) (2*j) (2*g),fun _ => ZFSet.omega,fun _ => C.omega_mem, + fun e => by simp only [Formula.eval_pairMem,mix_even]⟩ + +theorem defOrderedPair (C : Context M) (z i j : ℕ) : + Definable M (fun e => e z = ZFSet.pair (e i) (e j)) := + ⟨.orderedPair (2*z) (2*i) (2*j),fun _ => ZFSet.omega,fun _ => C.omega_mem, + fun e => by simp only [Formula.eval_orderedPair,mix_even]⟩ + +theorem defIff {P Q : (ℕ → ZFSet.{u}) → Prop} + (hp : Definable M P) (hq : Definable M Q) : Definable M (fun e => P e ↔ Q e) := + ((defImp hp hq).and (defImp hq hp)).congr (fun _ => iff_def.symm) + +theorem setSupportStep_definable (C : Context M) (g c b : ℕ) : + Definable M (fun e => SetSupportStep (e g) (e c) (e b)) := by + have hm : Primrec₂ (fun i j : ℕ => max i j + 1) := Primrec.succ.comp Primrec.nat_max + have ha (t : ℕ) := (((binaryGraph_definable C _ (atomic_primrec t) 1 0 (c+2)).and + (binaryGraph_definable C _ hm 1 0 (b+2))).existsParam C.omega_mem).existsParam C.omega_mem + have hc := (((((binaryGraph_definable C _ (binary_primrec 2) 3 2 (c+4)).and + ((defPairMem C 3 1 (g+4)).and ((defPairMem C 2 0 (g+4)).and + (binaryGraph_definable C max Primrec.nat_max 1 0 (b+4))))).existsParam C.omega_mem).existsParam + C.omega_mem).existsParam C.omega_mem).existsParam C.omega_mem + have hn := ((unaryGraph_definable C _ (unary_primrec 3) 0 (c+1)).and + (defPairMem C 0 (b+1) (g+1))).existsParam C.omega_mem + have hp : Primrec (fun n : ℕ => n-1) := Primrec.nat_sub.comp Primrec.id (Primrec.const 1) + have hx := (((unaryGraph_definable C _ (unary_primrec 4) 1 (c+2)).and + ((defPairMem C 1 0 (g+2)).and (unaryGraph_definable C _ hp 0 (b+2)))).existsParam + C.omega_mem).existsParam C.omega_mem + exact defOr (ha 0) (defOr (ha 1) (defOr hc (defOr hn hx))) + +def SetSupportRecursion (F G : ZFSet.{u}) : Prop := + (∀ z ∈ G, ∃ c ∈ F, ∃ b ∈ ZFSet.omega, z = ZFSet.pair c b) ∧ + ∀ c ∈ F, ∀ b ∈ ZFSet.omega, ZFSet.pair c b ∈ G ↔ SetSupportStep G c b + +theorem setSupportRecursion_spec (root : SentenceForm) (G : ZFSet.{u}) : + SetSupportRecursion (family root) G ↔ SupportRecursion root G := by + constructor + · rintro ⟨hn,hr⟩ + constructor + · intro z hz + obtain ⟨c,hc,b,hb,rfl⟩ := hn z hz + obtain ⟨p,hp,rfl⟩ := (mem_family root c).mp hc + obtain ⟨n,rfl⟩ := (mem_omega b).mp hb + exact ⟨p,hp,n,rfl⟩ + · intro p hp n + exact (hr _ ((code_mem_family root p).mpr hp) _ ((mem_omega _).mpr ⟨n,rfl⟩)).trans + (setSupportStep_encode G p n) + · rintro ⟨hn,hr⟩ + constructor + · intro z hz + obtain ⟨p,hp,n,rfl⟩ := hn z hz + exact ⟨_,(code_mem_family root p).mpr hp,_,(mem_omega _).mpr ⟨n,rfl⟩,rfl⟩ + · intro c hc b hb + obtain ⟨p,hp,rfl⟩ := (mem_family root c).mp hc + obtain ⟨n,rfl⟩ := (mem_omega b).mp hb + exact (hr p hp n).trans (setSupportStep_encode G p n).symm + +theorem setSupportRecursion_definable (C : Context M) (f g : ℕ) : + Definable M (fun e => SetSupportRecursion (e f) (e g)) := by + have hn := defAllMem (((defOrderedPair C 2 1 0).existsParam C.omega_mem).existsMem (f+1)) g + have hr := defAllMem (defAllParam (defIff (defPairMem C 1 0 (g+2)) + (setSupportStep_definable C (g+2) 1 0)) C.omega_mem) f + exact hn.and hr + +end TuringRigidity.SentenceCoding + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SetRankCertificate.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SetRankCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..98db8668984ed80c412b364135a97045e8ddb603 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SetRankCertificate.lean @@ -0,0 +1,76 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedRelations +import Mathlib.SetTheory.ZFC.Rank + +namespace OAI + +namespace TuringRigidity.SetRankCertificate +open BoundedSetTheory TransitiveNameModel +universe u +noncomputable section + +def RankMap (d r b g : ZFSet.{u}) : Prop := + ((∀ z ∈ g, ∃ x ∈ d, ∃ y ∈ b, z = ZFSet.pair x y) ∧ + (∀ x ∈ d, ∃ y ∈ b, ZFSet.pair x y ∈ g ∧ + ∀ z ∈ b, ZFSet.pair x z ∈ g → z = y)) ∧ + (∀ x ∈ d, ∀ y ∈ d, ∀ a ∈ b, ∀ c ∈ b, + ZFSet.pair x y ∈ r → ZFSet.pair x a ∈ g → ZFSet.pair y c ∈ g → a ∈ c) + +def rankFormula (d r b g : ℕ) : Formula := + .conj (.functionGraph g d b) + (.allMem d (.allMem (d+1) (.allMem (b+2) (.allMem (b+3) + (.imp (.pairMem 3 2 (r+4)) + (.imp (.pairMem 3 1 (g+4)) (.imp (.pairMem 2 0 (g+4)) (.member 1 0)))))))) + +theorem eval_rankFormula (d r b g : ℕ) (e : ℕ → ZFSet.{u}) : + (rankFormula d r b g).Eval e ↔ RankMap (e d) (e r) (e b) (e g) := by + simp only [rankFormula,Formula.Eval,Formula.eval_functionGraph,Formula.eval_allMem, + Formula.eval_imp,Formula.eval_pairMem,cons_zero,cons_succ,RankMap] + +theorem rankMap_sound {α : Type u} {rel : α → α → Prop} {d r b g : ZFSet.{u}} + (e : α → ZFSet.{u}) (hd : ∀ x, e x ∈ d) + (hr : ∀ x y, rel x y → ZFSet.pair (e x) (e y) ∈ r) (h : RankMap d r b g) : + WellFounded rel := by + let rank : α → ZFSet.{u} := fun x => (h.1.2 (e x) (hd x)).choose + have hb (x) : rank x ∈ b := (h.1.2 (e x) (hd x)).choose_spec.1 + have hg (x) : ZFSet.pair (e x) (rank x) ∈ g := (h.1.2 (e x) (hd x)).choose_spec.2.1 + have hm (x y) (hxy : rel x y) : rank x ∈ rank y := + h.2 (e x) (hd x) (e y) (hd y) (rank x) (hb x) (rank y) (hb y) + (hr x y hxy) (hg x) (hg y) + exact Subrelation.wf (fun {x y} hxy => ZFSet.rank_lt_of_mem (hm x y hxy)) + (InvImage.wf (fun x => (rank x).rank) Ordinal.lt_wf) + +def rankedFormula : SigmaFormula := + .existsSet (.existsSet (.bounded (rankFormula 2 3 1 0))) + +theorem realize_rankedFormula (M : ZFSet.{u}) (hM : Transitive M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + rankedFormula.Realize M e ↔ ∃ b ∈ M, ∃ g ∈ M, RankMap (e 0) (e 1) b g := by + simp only [rankedFormula,SigmaFormula.Realize] + apply exists_congr + intro b + apply and_congr_right + intro hb + apply exists_congr + intro g + apply and_congr_right + intro hg + have henv : ∀ i, cons g (cons b e) i ∈ M := by + intro i + rcases i with _|_|i <;> simp only [cons_zero,cons_succ] + · exact hg + · exact hb + · exact he i + exact ((rankFormula 2 3 1 0).absolute M hM _ henv).trans (eval_rankFormula _ _ _ _ _) + +theorem internal_rank_sound {α : Type u} {rel : α → α → Prop} + (M : ZFSet.{u}) (hM : Transitive M) (env : ℕ → ZFSet.{u}) + (he : ∀ i, env i ∈ M) (e : α → ZFSet.{u}) (hd : ∀ x, e x ∈ env 0) + (hr : ∀ x y, rel x y → ZFSet.pair (e x) (e y) ∈ env 1) + (h : rankedFormula.Realize M env) : WellFounded rel := by + obtain ⟨b,hb,g,hg,h⟩ := (realize_rankedFormula M hM env he).mp h + exact rankMap_sound e hd hr h + +end +end TuringRigidity.SetRankCertificate + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SetSatisfactionBounded.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SetSatisfactionBounded.lean new file mode 100644 index 0000000000000000000000000000000000000000..e1d525bd5def39fa6d764a79804034e6fbf1a6ae --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SetSatisfactionBounded.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DegreeRigidity.Syntax.DefinablePower + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel +universe u + +def setBounded : SentenceForm → ℕ → (ℕ → ℕ) → Formula + | .equal i j, _, v => .equal (v i) (v j) + | .member i j, _, v => .member (v i) (v j) + | .conj p q, a, v => .conj (setBounded p a v) (setBounded q a v) + | .neg p, a, v => .neg (setBounded p a v) + | .ex p, a, v => .existsMem a + (setBounded p (a+1) (fun i => match i with | 0 => 0 | j+1 => v j+1)) + +theorem setBounded_eval (p : SentenceForm) (a : ℕ) (v : ℕ → ℕ) + (e : ℕ → ZFSet.{u}) : + (setBounded p a v).Eval e ↔ p.Sat (e a : Set ZFSet) (fun i => e (v i)) := by + induction p generalizing a v e with + | equal => rfl + | member => rfl + | conj p q ihp ihq => exact and_congr (ihp a v e) (ihq a v e) + | neg p ih => exact not_congr (ih a v e) + | ex p ih => + simp only [setBounded,Formula.Eval,SentenceForm.Sat] + apply exists_congr; intro x + apply and_congr_right; intro _ + have he : (fun i => cons x e (match i with | 0 => 0 | j+1 => v j+1)) = + cons x (fun i => e (v i)) := by funext i; cases i <;> rfl + exact (ih (a+1) _ (cons x e)).trans (he ▸ Iff.rfl) + +theorem setBounded_absolute (p : SentenceForm) (M : ZFSet.{u}) (hM : Transitive M) + (a : ℕ) (v : ℕ → ℕ) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (setBounded p a v).Realize M e ↔ p.Sat (e a : Set ZFSet) (fun i => e (v i)) := + ((setBounded p a v).absolute M hM e he).trans (setBounded_eval p a v e) + +theorem definedSubset_mem (M A : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hA : A ∈ M) (p : SentenceForm) + {n : ℕ} (v : Fin n → ZFSet.{u}) (hv : ∀ i, v i ∈ A) (hb : p.bound ≤ n+1) : + definedSubset A p v ∈ M := by + let f : ℕ → ZFSet.{u} := fun i => if h : i < n then v ⟨i,h⟩ else A + let e := cons A f + let shift : ℕ → ℕ := fun i => match i with | 0 => 0 | j+1 => j+2 + have he : ∀ i, e i ∈ M := by + intro i; cases i with + | zero => exact hA + | succ i => + dsimp [e,cons,f] + split + next h => exact hM A hA _ (hv ⟨i,h⟩) + next => exact hA + have hs := sep_mem M hM hS (setBounded p 1 shift) e he hA + have heq : A.sep (fun x => (setBounded p 1 shift).Eval (cons x e)) = + definedSubset A p v := by + apply ZFSet.ext; intro x + rw [ZFSet.mem_sep,mem_definedSubset,setBounded_eval] + apply and_congr_right; intro _ + apply p.finite_support + intro i hi + cases i with + | zero => rfl + | succ i => + change f i = tupleEnv v i + have hin : i < n := by omega + simp [f,tupleEnv,hin] + exact heq ▸ hs + +theorem definablePower_subset_model (M A : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hA : A ∈ M) : definablePower A ⊆ M := by + intro S hS' + obtain ⟨n,p,v,hb,hv,rfl⟩ := (mem_definablePower A S).mp hS' + exact definedSubset_mem M A hM hS hA p v hv hb + +theorem definablePower_internal_bound (M A : ZFSet.{u}) (hM : Transitive M) + (hS : Separation M) (hP : PowerSet M) (hA : A ∈ M) : + ∃ Q ∈ M, (∀ S, S ∈ Q ↔ S ∈ M ∧ S ⊆ A) ∧ definablePower A ⊆ Q := by + obtain ⟨Q,hQ,hdef⟩ := internal_power M hM hP hA + exact ⟨Q,hQ,hdef,fun S hS' => (hdef S).mpr + ⟨definablePower_subset_model M A hM hS hA hS',subset_of_mem_definablePower hS'⟩⟩ + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaBoundedUniversal.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaBoundedUniversal.lean new file mode 100644 index 0000000000000000000000000000000000000000..74bf84d1d142f79f55afc85e865cb8cd7bd0b3d6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaBoundedUniversal.lean @@ -0,0 +1,109 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaDomainCollection + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace Formula + +def envBound : ℕ → Formula + | 0 => .equal 0 0 + | n+1 => .conj (envBound n) (.member (n+1) 0) + +theorem eval_envBound (n : ℕ) (e : ℕ → ZFSet.{u}) : + (envBound n).Eval e ↔ ∀ i, i < n → e (i+1) ∈ e 0 := by + induction n with + | zero => simp [envBound,Eval] + | succ n ih => + simp only [envBound,Eval,ih] + constructor + · rintro ⟨h,hn⟩ i hi + rcases Nat.lt_succ_iff_lt_or_eq.mp hi with hi|rfl + · exact h i hi + · exact hn + · intro h + exact ⟨fun i hi => h i (Nat.lt_succ_of_lt hi),h n (Nat.lt_succ_self n)⟩ +end Formula +namespace SigmaFormula + +def skipDomain : ℕ → ℕ + | 0 => 0 + | i+1 => i+2 + +def allDomainMatrix (a : ℕ) (φ : SigmaFormula) : Formula := + .conj (.transitive 0) (.conj (.existsMem 0 (.empty 0)) + (.conj (.envBound φ.scope) (.conj (.member (a+1) 0) + (.allMem (a+1) (FiniteTuple.relativizeSigma 1 (φ.rename skipDomain)))))) + +def allMem (a : ℕ) (φ : SigmaFormula) : SigmaFormula := .existsSet (.bounded (allDomainMatrix a φ)) + +theorem eval_allDomainMatrix (a : ℕ) (φ : SigmaFormula) (d : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (allDomainMatrix a φ).Eval (cons d e) ↔ Transitive d ∧ (∅ : ZFSet.{u}) ∈ d ∧ + (∀ i, i < φ.scope → e i ∈ d) ∧ e a ∈ d ∧ ∀ x ∈ e a, φ.Realize d (cons x e) := by + simp only [allDomainMatrix,Formula.Eval,Formula.eval_transitive,Formula.eval_empty, + Formula.eval_envBound,Formula.eval_allMem,FiniteTuple.eval_relativizeSigma, + realize_rename,cons_zero,cons_succ] + have eq (x : ZFSet.{u}) : (fun i => cons x (cons d e) (skipDomain i)) = cons x e := by + funext i; cases i <;> rfl + simp only [eq,exists_eq_right] + +theorem realize_allMem (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hC : SigmaCollection M) + (a : ℕ) (φ : SigmaFormula) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + (allMem a φ).Realize M e ↔ ∀ x ∈ e a, φ.Realize M (cons x e) := by + classical + let e' := fun i => if i < φ.scope then e i else (∅ : ZFSet.{u}) + have congr (d x : ZFSet.{u}) : φ.Realize d (cons x e) ↔ φ.Realize d (cons x e') := by + apply φ.realize_congr; intro i hi + cases i with + | zero => rfl + | succ i => exact (ite_eq_left (show i < φ.scope by omega)).symm + have matrix (d : ZFSet.{u}) (hd : d ∈ M) : + (allDomainMatrix a φ).Realize M (cons d e) ↔ Transitive d ∧ (∅ : ZFSet.{u}) ∈ d ∧ + (∀ i, i < φ.scope → e i ∈ d) ∧ e a ∈ d ∧ ∀ x ∈ e a, φ.Realize d (cons x e) := by + rw [Formula.absolute _ M hM _ (by intro i; cases i <;> simp [cons,he,hd])] + exact eval_allDomainMatrix a φ d e + change (∃ d ∈ M, _) ↔ _ + constructor + · rintro ⟨d,hd,h⟩ + obtain ⟨hdt,h0,heD,haD,hφ⟩ := (matrix d hd).mp h + have he' : ∀ i, e' i ∈ d := by + intro i; dsimp [e']; split_ifs with hi + · exact heD i hi + · exact h0 + intro x hx + apply (congr M x).mpr + exact φ.transitive_upward hdt hM (fun y hy => hM d hd y hy) (cons x e') + (by intro i; cases i with + | zero => exact hdt _ haD x hx + | succ i => exact he' i) ((congr d x).mp (hφ x hx)) + · intro hφ + have hω := omega_mem M hM hS hI + let ee := cons (e a) (cons ZFSet.omega e) + have hee : ∀ i, ee i ∈ M := by + intro i; rcases i with _|i; exact he a + rcases i with _|i; exact hω + exact he i + obtain ⟨t,ht,htt,hat,hentries⟩ := BoundedForcing.finite_container M hM hP hU hS hR hI + ee hee (φ.scope+2) + have hωt : ZFSet.omega.{u} ∈ t := hentries 1 (by omega) + have h0t : (∅ : ZFSet.{u}) ∈ t := htt _ hωt _ ZFSet.omega_zero + have he' : ∀ i, e' i ∈ t := by + intro i; dsimp [e']; split_ifs with hi + · exact hentries (i+2) (by omega) + · exact h0t + obtain ⟨D,hD,hDT,htD,hφD⟩ := internal_bounded_domain M hM hP hU hS hR hI hC + (he a) ht htt hat e' he' φ (fun x hx => (congr M x).mp (hφ x hx)) + refine ⟨D,hD,(matrix D hD).mpr ⟨hDT,htD h0t,?_,htD hat,?_⟩⟩ + · intro i hi + exact htD (hentries (i+2) (by omega)) + · intro x hx + exact (congr D x).mpr (hφD x hx) +end SigmaFormula + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaCollection.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaCollection.lean new file mode 100644 index 0000000000000000000000000000000000000000..8434ebe6948a7b18caf7178eb3d096df2c470bf6 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaCollection.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DegreeRigidity.Constructibility.UniformSigmaHull +import OAI.Computability.DegreeRigidity.Syntax.BoundedSupport + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace SigmaFormula + +def scope : SigmaFormula → ℕ + | .bounded φ => φ.scope + | .existsSet φ => φ.scope-1 + +theorem realize_congr (φ : SigmaFormula) (d : ZFSet.{u}) (e f : ℕ → ZFSet.{u}) + (h : ∀ i, i < φ.scope → e i = f i) : φ.Realize d e ↔ φ.Realize d f := by + induction φ generalizing e f with + | bounded φ => exact φ.realize_congr d e f h + | existsSet φ ih => + simp only [Realize] + apply exists_congr; intro x + apply and_congr_right; intro _ + apply ih; intro j hj + cases j with + | zero => rfl + | succ j => exact h j (by change j < φ.scope-1; omega) +end SigmaFormula + +theorem internal_sigma_request_bound (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) + (φ : SigmaFormula) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + {a : ZFSet.{u}} (ha : a ∈ M) : + ∃ W ∈ M, ∀ x ∈ a, (∃ y ∈ M, φ.Realize M (cons y (cons x e))) → + ∃ y ∈ W, φ.Realize M (cons y (cons x e)) := by + have hω := omega_mem M hM hS.bounded hI + let ee := cons a (cons ZFSet.omega e) + have hee : ∀ i, ee i ∈ M := by + intro i; rcases i with _|i; exact ha + rcases i with _|i; exact hω + exact he i + obtain ⟨t,ht,htt,hat,hentries⟩ := BoundedForcing.finite_container M hM hP hU hS.bounded hR hI + ee hee (φ.scope+2) + have hωt : ZFSet.omega.{u} ∈ t := hentries 1 (by omega) + have h0t : (∅ : ZFSet.{u}) ∈ t := htt _ hωt _ ZFSet.omega_zero + let e' := fun i => if i < φ.scope then e i else ∅ + have he' : ∀ i, e' i ∈ t := by + intro i; dsimp [e']; split_ifs with hi + · exact hentries (i+2) (by omega) + · exact h0t + have congr (x y : ZFSet.{u}) : φ.Realize M (cons y (cons x e)) ↔ + φ.Realize M (cons y (cons x e')) := by + apply φ.realize_congr; intro i hi + rcases i with _|i; rfl + rcases i with _|i; rfl + exact (ite_eq_left (show i < φ.scope by omega)).symm + obtain ⟨W,hW,hbound⟩ := FiniteTuple.internal_uniform_sigma_witness_bound M t hM hP hU hPow hS hR hI hAC ht htt h0t + refine ⟨W,hW,?_⟩ + intro x hx hy + have henv : ∀ i, cons x e' i ∈ t := by + intro i; cases i with + | zero => exact htt a hat x hx + | succ i => exact he' i + obtain ⟨z,hz,hφ⟩ := hbound (cons x e') henv φ (by + obtain ⟨y,hy,hφ⟩ := hy + exact ⟨y,hy,(congr x y).mp hφ⟩) + exact ⟨z,hz,(congr x z).mpr hφ⟩ + +def SigmaCollection (M : ZFSet.{u}) : Prop := + ∀ (φ : SigmaFormula) (e : ℕ → ZFSet.{u}), (∀ i, e i ∈ M) → ∀ a ∈ M, + (∀ x ∈ a, ∃ y ∈ M, φ.Realize M (cons y (cons x e))) → + ∃ W ∈ M, ∀ x ∈ a, ∃ y ∈ W, φ.Realize M (cons y (cons x e)) + +theorem sigma_collection (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) : + SigmaCollection M := by + intro φ e he a ha htotal + obtain ⟨W,hW,hbound⟩ := internal_sigma_request_bound M hM hP hU hPow hS hR hI hAC φ e he ha + exact ⟨W,hW,fun x hx => hbound x hx (htotal x hx)⟩ + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaCollectionClosure.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaCollectionClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce9966ad454a8641f707b48e45afd08b26aa330d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaCollectionClosure.lean @@ -0,0 +1,28 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaParameterizedClosure + +namespace OAI + +namespace TuringRigidity.BoundedDefinability +open BoundedSetTheory TransitiveNameModel +open BoundedDefinability SetModelFunctions +universe u +theorem SigmaDefinable.allMem_collection {M : ZFSet.{u}} {P : (ℕ → ZFSet.{u}) → Prop} + (C : Context M) (hRep : SigmaReplacement M) (hC : SigmaCollection M) + (h : SigmaDefinable M P) (a : ℕ) : + SigmaDefinable M (fun e => ∀ x ∈ e a, P (cons x e)) := by + obtain ⟨p,d,hd,hp⟩ := h + refine ⟨.allMem (2*a) (p.rename bindSlots),d,hd,?_⟩ + intro e he + rw [SigmaFormula.realize_allMem M C.transitive C.pairing C.union C.separation + hRep C.infinity hC _ _ _ (by + intro i; unfold mix; split <;> first | exact he _ | exact hd _),mix_even] + apply forall_congr'; intro x + apply forall_congr'; intro hx + rw [SigmaFormula.realize_rename] + change p.Realize M (cons x (mix e d) ∘ bindSlots) ↔ _ + rw [bind_mix] + exact hp (cons x e) (by intro i; cases i; exact C.transitive _ (he a) x hx; exact he _) + +end TuringRigidity.BoundedDefinability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaDefinability.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaDefinability.lean new file mode 100644 index 0000000000000000000000000000000000000000..60e0c7a485762232c6c7ff72c873cb9b6ba76bd0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaDefinability.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedCertificate +import OAI.Computability.DegreeRigidity.SetModels.InternalNameValidity +import OAI.Computability.DegreeRigidity.Syntax.SigmaSyntax +import OAI.Computability.DegreeRigidity.CohenForcing.SigmaForcing + +namespace OAI + + +namespace TuringRigidity.BoundedForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing +universe u + +namespace SigmaCode + +def forcing : SigmaFormula → ℕ → ℕ → ℕ → (ℕ → ℕ) → SigmaFormula + | .bounded φ, ci,oi,pi,v => CertificateCode.certificate φ ci oi pi v + | .existsSet φ, ci,oi,pi,v => .existsSet + (SigmaFormula.conj (NameValidity.Code.valid (ci+1) 0) + (forcing φ (ci+1) (oi+1) (pi+1) (push 0 (fun i => v i+1)))) +end SigmaCode + +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem realize_sigmaForcing (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) + {o : ZFSet.{u}} + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (φ : SigmaFormula) (e : ℕ → Name (Conditions c)) (p : Conditions c) + (env : ℕ → ZFSet.{u}) (henv : ∀ i, env i ∈ M) + (ci oi pi : ℕ) (v : ℕ → ℕ) + (hc : env ci = c) (ho' : env oi = o) (hp : env pi = label c p) + (hv : ∀ i, env (v i) = (e i).encode (label c)) : + (SigmaCode.forcing φ ci oi pi v).Realize M env ↔ SigmaForces M e φ p := by + induction φ generalizing e env ci oi pi v with + | bounded φ => + exact realize_boundedCertificate M hM hP hU hPow hS hR hI ho φ e p env henv ci oi pi v hc ho' hp hv + | existsSet φ ih => + have henv' (x : ZFSet.{u}) (hx : x ∈ M) : ∀ i, cons x env i ∈ M := by + intro i; cases i <;> simp only [cons_zero,cons_succ]; exact hx; exact henv _ + have valid (x : ZFSet.{u}) (hx : x ∈ M) : + (NameValidity.Code.valid (ci+1) 0).Realize M (cons x env) ↔ + ∃ a : Name (Conditions c), a.encode (label c) = x := by + have h := NameValidity.realize_valid M hM hP hU hPow hS hR hI + (cons x env) (henv' x hx) (ci+1) 0 + change (NameValidity.Code.valid (ci+1) 0).Realize M (cons x env) ↔ + (∃ a : Name (Conditions (env ci)), a.encode (label (env ci)) = x) at h + rw [hc] at h + exact h + have sub (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) := + ih (push a e) (cons (a.encode (label c)) env) (henv' _ ha) + (ci+1) (oi+1) (pi+1) (push 0 (fun i => v i+1)) hc ho' hp + (by intro i; cases i <;> simp only [push_zero,push_succ,cons_zero,cons_succ,hv]) + simp only [SigmaCode.forcing,SigmaFormula.Realize,SigmaFormula.realize_conj] + constructor + · rintro ⟨x,hx,hvalid,hforce⟩ + obtain ⟨a,rfl⟩ := (valid x hx).mp hvalid + exact ⟨a,hx,(sub a hx).mp hforce⟩ + · rintro ⟨a,ha,hforce⟩ + exact ⟨_,ha,(valid _ ha).mpr ⟨a,rfl⟩,(sub a ha).mpr hforce⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaDisjunction.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaDisjunction.lean new file mode 100644 index 0000000000000000000000000000000000000000..3654969146db14fcaab583876eab9cb24f2e26e9 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaDisjunction.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaBoundedUniversal + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +universe u +namespace SigmaFormula + +def boundedDisj (b : Formula) : SigmaFormula → SigmaFormula + | .bounded c => .bounded (.disj b c) + | .existsSet φ => .existsSet (boundedDisj (b.rename Nat.succ) φ) + +def disj : SigmaFormula → SigmaFormula → SigmaFormula + | .bounded b,ψ => boundedDisj b ψ + | .existsSet φ,ψ => .existsSet (disj φ (ψ.rename Nat.succ)) + +theorem realize_boundedDisj (M : ZFSet.{u}) (h0 : (∅ : ZFSet.{u}) ∈ M) + (b : Formula) (φ : SigmaFormula) (e : ℕ → ZFSet.{u}) : + (boundedDisj b φ).Realize M e ↔ b.Realize M e ∨ φ.Realize M e := by + induction φ generalizing b e with + | bounded c => simp only [boundedDisj,Realize,Formula.disj,Formula.Realize]; tauto + | existsSet φ ih => + change (∃ x ∈ M, (boundedDisj (b.rename Nat.succ) φ).Realize M (cons x e)) ↔ _ + simp_rw [ih,Formula.realize_rename] + change (∃ x ∈ M, b.Realize M e ∨ φ.Realize M (cons x e)) ↔ + b.Realize M e ∨ ∃ x ∈ M, φ.Realize M (cons x e) + constructor + · rintro ⟨x,hx,h|h⟩ + · exact Or.inl h + · exact Or.inr ⟨x,hx,h⟩ + · rintro (h|⟨x,hx,h⟩) + · exact ⟨∅,h0,Or.inl h⟩ + · exact ⟨x,hx,Or.inr h⟩ + +theorem realize_disj (M : ZFSet.{u}) (h0 : (∅ : ZFSet.{u}) ∈ M) + (φ ψ : SigmaFormula) (e : ℕ → ZFSet.{u}) : + (disj φ ψ).Realize M e ↔ φ.Realize M e ∨ ψ.Realize M e := by + induction φ generalizing ψ e with + | bounded b => exact realize_boundedDisj M h0 b ψ e + | existsSet φ ih => + change (∃ x ∈ M, (disj φ (ψ.rename Nat.succ)).Realize M (cons x e)) ↔ _ + simp_rw [ih,realize_rename] + change (∃ x ∈ M, φ.Realize M (cons x e) ∨ ψ.Realize M e) ↔ + (∃ x ∈ M, φ.Realize M (cons x e)) ∨ ψ.Realize M e + constructor + · rintro ⟨x,hx,h|h⟩ + · exact Or.inl ⟨x,hx,h⟩ + · exact Or.inr h + · rintro (⟨x,hx,h⟩|h) + · exact ⟨x,hx,Or.inl h⟩ + · exact ⟨∅,h0,Or.inr h⟩ + +def existsMem (a : ℕ) (φ : SigmaFormula) : SigmaFormula := + .existsSet (.andBounded (.member 0 (a+1)) φ) + +theorem realize_existsMem (M : ZFSet.{u}) (a : ℕ) (φ : SigmaFormula) (e : ℕ → ZFSet.{u}) : + (existsMem a φ).Realize M e ↔ ∃ x ∈ M, x ∈ e a ∧ φ.Realize M (cons x e) := by + simp only [existsMem,Realize,realize_andBounded,Formula.Realize,cons_zero,cons_succ] +end SigmaFormula + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaDomainCollection.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaDomainCollection.lean new file mode 100644 index 0000000000000000000000000000000000000000..e31db6b66e0605e523c5b570e1148915a7504625 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaDomainCollection.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaTransitiveWitness + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace SigmaFormula + +def domainVars : ℕ → ℕ + | 0 => 1 + | i+1 => i+3 + +def domainRequest (φ : SigmaFormula) : SigmaFormula := .bounded + (.conj (.transitive 0) (.conj (.subset 2 0) (FiniteTuple.relativizeSigma 0 (φ.rename domainVars)))) + +theorem realize_domainRequest (φ : SigmaFormula) (M : ZFSet.{u}) (hM : Transitive M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) {d x t : ZFSet.{u}} + (hd : d ∈ M) (hx : x ∈ M) (ht : t ∈ M) : + φ.domainRequest.Realize M (cons d (cons x (cons t e))) ↔ + Transitive d ∧ t ⊆ d ∧ φ.Realize d (cons x e) := by + have he' : ∀ i, cons d (cons x (cons t e)) i ∈ M := by + intro i; rcases i with _|i; exact hd + rcases i with _|i; exact hx + rcases i with _|i; exact ht + exact he i + rw [domainRequest,Realize,Formula.absolute _ M hM _ he'] + simp only [Formula.Eval,Formula.eval_transitive,Formula.eval_subset,FiniteTuple.eval_relativizeSigma, + realize_rename,cons_zero,cons_succ] + have eq : (fun i => cons d (cons x (cons t e)) (domainVars i)) = cons x e := by + funext i; cases i <;> rfl + rw [eq] + +theorem internal_bounded_domain (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hC : SigmaCollection M) + {a t : ZFSet.{u}} (ha : a ∈ M) (ht : t ∈ M) (htt : Transitive t) (hat : a ∈ t) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ t) (φ : SigmaFormula) + (hφ : ∀ x ∈ a, φ.Realize M (cons x e)) : + ∃ D ∈ M, Transitive D ∧ t ⊆ D ∧ ∀ x ∈ a, φ.Realize D (cons x e) := by + have heM := fun i => hM t ht _ (he i) + have hxe (x : ZFSet.{u}) (hx : x ∈ a) : ∀ i, cons x e i ∈ t := by + intro i; cases i with + | zero => exact htt a hat x hx + | succ i => exact he i + obtain ⟨B,hB,hbound⟩ := hC φ.domainRequest (cons t e) + (by intro i; cases i <;> simp [cons,ht,heM]) a ha (by + intro x hx + obtain ⟨d,hd,hdt,htd,hdφ⟩ := internal_transitive_witness M hM hP hU hS hR hI ht + (cons x e) (hxe x hx) φ (hφ x hx) + exact ⟨d,hd,(realize_domainRequest φ M hM e heM hd (hM a ha x hx) ht).mpr ⟨hdt,htd,hdφ⟩⟩) + let C := ZFSet.sep (fun d => Transitive d ∧ t ⊆ d) B + have hCmem : C ∈ M := by + simpa only [Formula.Eval,Formula.eval_transitive,Formula.eval_subset,cons_zero,cons_succ] using + sep_mem M hM hS (.conj (.transitive 0) (.subset 1 0)) (fun _ => t) (fun _ => ht) hB + let D := t ∪ ZFSet.sUnion C + have hDM : D ∈ M := binary_union_mem M hM hP hU ht (union_mem M hM hU hCmem) + have htD : t ⊆ D := fun _ hy => ZFSet.mem_union.mpr (Or.inl hy) + have hDT : Transitive D := by + intro x hx y hy + rcases ZFSet.mem_union.mp hx with hx|hx + · exact htD (htt x hx y hy) + · obtain ⟨d,hd,hxd⟩ := ZFSet.mem_sUnion.mp hx + have hdt := (ZFSet.mem_sep.mp hd).2.1 + exact ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_sUnion.mpr ⟨d,hd,hdt x hxd y hy⟩)) + refine ⟨D,hDM,hDT,htD,?_⟩ + intro x hx + obtain ⟨d,hdB,hdφ⟩ := hbound x hx + have hdM := hM B hB d hdB + obtain ⟨hdt,htd,hdφ⟩ := (realize_domainRequest φ M hM e heM hdM (hM a ha x hx) ht).mp hdφ + have hdC : d ∈ C := ZFSet.mem_sep.mpr ⟨hdB,hdt,htd⟩ + have hdD : d ⊆ D := fun y hy => ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_sUnion.mpr ⟨d,hdC,hy⟩)) + exact φ.transitive_upward hdt hDT hdD (cons x e) (fun i => htd (hxe x hx i)) hdφ +end SigmaFormula + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaHull.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaHull.lean new file mode 100644 index 0000000000000000000000000000000000000000..27547d0b37d75100f1d7eb62245e6dd2ecc428ec --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaHull.lean @@ -0,0 +1,118 @@ +import OAI.Computability.DegreeRigidity.SetModels.FragmentHull + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace SigmaFormula + +def matrix : SigmaFormula → Formula + | .bounded φ => φ + | .existsSet φ => matrix φ + +def prefixLength : SigmaFormula → ℕ + | .bounded _ => 0 + | .existsSet φ => prefixLength φ+1 + +def feed : List ZFSet.{u} → (ℕ → ZFSet.{u}) → (ℕ → ZFSet.{u}) + | [],e => e + | x::xs,e => feed xs (cons x e) + +theorem feed_mem (xs : List ZFSet.{u}) (e : ℕ → ZFSet.{u}) (d : ZFSet.{u}) + (hxs : ∀ x ∈ xs, x ∈ d) (he : ∀ i, e i ∈ d) : ∀ i, feed xs e i ∈ d := by + induction xs generalizing e with + | nil => exact he + | cons x xs ih => + have he' : ∀ i, cons x e i ∈ d := by + intro i; cases i with + | zero => exact hxs x List.mem_cons_self + | succ i => exact he i + exact ih (cons x e) (fun y hy => hxs y (List.mem_cons_of_mem _ hy)) he' + +theorem realize_iff_prefix (φ : SigmaFormula) (d : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + φ.Realize d e ↔ ∃ xs : List ZFSet.{u}, xs.length = φ.prefixLength ∧ + (∀ x ∈ xs, x ∈ d) ∧ φ.matrix.Realize d (feed xs e) := by + induction φ generalizing e with + | bounded φ => + constructor + · intro h; exact ⟨[],rfl,by simp,h⟩ + · rintro ⟨xs,hlen,_,hφ⟩ + have heq : xs = [] := List.length_eq_zero_iff.mp hlen + subst xs; exact hφ + | existsSet φ ih => + constructor + · rintro ⟨x,hx,hφ⟩ + obtain ⟨xs,hlen,hxs,hmat⟩ := (ih (cons x e)).mp hφ + refine ⟨x::xs,congrArg Nat.succ hlen,?_,hmat⟩ + intro y hy; rcases List.mem_cons.mp hy with rfl|hy + · exact hx + · exact hxs y hy + · rintro ⟨xs,hlen,hxs,hmat⟩ + cases xs with + | nil => simp [prefixLength] at hlen + | cons x xs => + refine ⟨x,hxs x List.mem_cons_self,(ih (cons x e)).mpr ?_⟩ + exact ⟨xs,Nat.succ.inj hlen,fun y hy => hxs y (List.mem_cons_of_mem _ hy),hmat⟩ +end SigmaFormula +namespace FiniteTuple + +noncomputable def elements : List ZFSet.{u} → ZFSet.{u} + | [] => ∅ + | x::xs => ({x} : ZFSet.{u}) ∪ elements xs + +theorem mem_elements (x : ZFSet.{u}) (xs : List ZFSet.{u}) : x ∈ elements xs ↔ x ∈ xs := by + induction xs with + | nil => simp [elements] + | cons y xs ih => simp only [elements,ZFSet.mem_union,ZFSet.mem_singleton,ih,List.mem_cons] + +theorem elements_mem (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) + (hU : BoundedSetTheory.Union M) (h0 : (∅ : ZFSet.{u}) ∈ M) + (xs : List ZFSet.{u}) (hxs : ∀ x ∈ xs, x ∈ M) : elements xs ∈ M := by + induction xs with + | nil => exact h0 + | cons x xs ih => + exact binary_union_mem M hM hP hU + (singleton_mem M hM hP (hxs x List.mem_cons_self)) + (ih (fun y hy => hxs y (List.mem_cons_of_mem _ hy))) + +theorem internal_sigma_witness_hull (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : Separation M) (hR : SigmaReplacement M) (hI : Infinity M) (hAC : Choice M) + {t x : ZFSet.{u}} (ht : t ∈ M) (hx : x ∈ M) (φ : SigmaFormula) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ t) (hφ : φ.Realize M (cons x e)) : + ∃ h ∈ M, t ⊆ h ∧ x ∈ h ∧ RelationCollapse.StructureExtensional h ∧ + φ.Realize h (cons x e) := by + obtain ⟨xs,hlen,hxs,hmat⟩ := (φ.realize_iff_prefix M (cons x e)).mp hφ + have h0 : (∅ : ZFSet.{u}) ∈ M := hM _ (omega_mem M hM hS hI) _ ZFSet.omega_zero + let s := t ∪ elements (x::xs) + have hs : s ∈ M := binary_union_mem M hM hP hU ht + (elements_mem M hM hP hU h0 (x::xs) (by + intro y hy; rcases List.mem_cons.mp hy with rfl|hy; exact hx; exact hxs y hy)) + have hts : t ⊆ s := fun _ hy => ZFSet.mem_union.mpr (Or.inl hy) + have hxsS : ∀ y ∈ x::xs, y ∈ s := + fun y hy => ZFSet.mem_union.mpr (Or.inr ((mem_elements y (x::xs)).mpr hy)) + obtain ⟨d,hd,hdt,hsd⟩ := internal_transitive_container M hM hP hU hS hR hI hs + have hsd' : s ⊆ d := fun y hy => hdt _ hsd y hy + have henvS : ∀ i, cons x e i ∈ s := by + intro i; cases i with + | zero => exact hxsS x List.mem_cons_self + | succ i => exact hts (he i) + have hfeedS := SigmaFormula.feed_mem xs (cons x e) s + (fun y hy => hxsS y (List.mem_cons_of_mem _ hy)) henvS + have hfeedM : ∀ i, SigmaFormula.feed xs (cons x e) i ∈ M := fun i => hM s hs _ (hfeedS i) + have hfeedD : ∀ i, SigmaFormula.feed xs (cons x e) i ∈ d := fun i => hsd' (hfeedS i) + have hmatD : φ.matrix.Realize d (SigmaFormula.feed xs (cons x e)) := + (φ.matrix.absolute d hdt _ hfeedD).mpr ((φ.matrix.absolute M hM _ hfeedM).mp hmat) + obtain ⟨h,hh,hsh,_,hext,htransfer⟩ := + internal_fragment_hull M hM hP hU hPow hS hR hI hAC hd hs hdt hsd' φ.matrix + refine ⟨h,hh,fun y hy => hsh (hts hy),hsh (hxsS x List.mem_cons_self),hext,?_⟩ + apply (φ.realize_iff_prefix h (cons x e)).mpr + exact ⟨xs,hlen,fun y hy => hsh (hxsS y (List.mem_cons_of_mem _ hy)), + (htransfer _ (fun i => hsh (hfeedS i))).mpr hmatD⟩ + +end FiniteTuple +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaInterpretation.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaInterpretation.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8719d7b31655de98b36f73e9b8544022e0e7296 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaInterpretation.lean @@ -0,0 +1,55 @@ +import OAI.Computability.DegreeRigidity.Representation.GenericFilterName +import OAI.Computability.DegreeRigidity.Syntax.MembershipInterpretation + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +def SigmaFormula.toMembership : SigmaFormula → RecursiveNames.Formula + | .bounded φ => φ.toMembership + | .existsSet φ => .existsSet φ.toMembership + +theorem SigmaFormula.realize_toMembership (φ : SigmaFormula) (M : ZFSet.{u}) + (e : ℕ → ZFSet.{u}) : + φ.toMembership.Realize (M : Set ZFSet.{u}) e ↔ φ.Realize M e := by + induction φ generalizing e with + | bounded φ => exact φ.realize_toMembership M e + | existsSet φ ih => + have hc (x : ZFSet.{u}) : (fun n => if n = 0 then x else e (n-1)) = cons x e := by + funext n; cases n <;> simp [cons] + simp only [toMembership,RecursiveNames.Formula.Realize,SigmaFormula.Realize,hc] + exact exists_congr (fun x => and_congr_right (fun _ => ih (cons x e))) + +def SigmaSeparation (M : ZFSet.{u}) : Prop := + ∀ (φ : SigmaFormula) (e : ℕ → ZFSet.{u}), (∀ i, e i ∈ M) → + ∀ a ∈ M, ∃ b ∈ M, ∀ x ∈ M, x ∈ b ↔ x ∈ a ∧ φ.Realize M (cons x e) + +theorem SigmaSeparation.bounded {M : ZFSet.{u}} (h : SigmaSeparation M) : Separation M := + fun φ e he a ha => h (.bounded φ) e he a ha + +theorem SigmaFormula.upward (φ : SigmaFormula) (M N : ZFSet.{u}) + (hM : Transitive M) (hN : Transitive N) (hMN : M ⊆ N) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + φ.Realize M e → φ.Realize N e := by + induction φ generalizing e with + | bounded φ => + exact fun h => (φ.absolute N hN e (fun i => hMN (he i))).mpr + ((φ.absolute M hM e he).mp h) + | existsSet φ ih => + rintro ⟨x,hx,hφ⟩ + exact ⟨x,hMN hx,ih (cons x e) (fun i => by cases i <;> simp [cons,he,hx]) hφ⟩ + +theorem ground_sigma_upward (M p : ZFSet.{u}) [Top (Conditions p)] + (hM : Transitive M) (hP : Pairing M) (hU : Union M) + (hPow : PowerSet M) (hS : SigmaSeparation M) (hR : SigmaReplacement M) + (hI : Infinity M) (hp : p ∈ M) (G : Set (Conditions p)) (hG : ⊤ ∈ G) + (φ : SigmaFormula) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + φ.Realize M e → φ.Realize (genericExtensionSet M p G) e := + φ.upward M _ hM (genericExtensionSet_transitive M p hM G) + (ground_inclusion_set M p hM hP hU hPow hS.bounded hR hI hp G hG) e he + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaParameterized.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaParameterized.lean new file mode 100644 index 0000000000000000000000000000000000000000..22ed408d34f318b78bb96739c9547416265561b0 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaParameterized.lean @@ -0,0 +1,64 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedDefinability +import OAI.Computability.DegreeRigidity.Syntax.SigmaSyntax + +namespace OAI + + +namespace TuringRigidity.BoundedDefinability +open BoundedSetTheory TransitiveNameModel SetModelFunctions +universe u + +def SigmaDefinable (M : ZFSet.{u}) (P : (ℕ → ZFSet.{u}) → Prop) : Prop := + ∃ p : SigmaFormula, ∃ d : ℕ → ZFSet.{u}, (∀ i, d i ∈ M) ∧ + ∀ e, (∀ i, e i ∈ M) → (p.Realize M (mix e d) ↔ P e) + +variable {M : ZFSet.{u}} {P Q : (ℕ → ZFSet.{u}) → Prop} + +theorem Definable.toSigma (hM : Transitive M) (h : Definable M P) : SigmaDefinable M P := by + obtain ⟨p,d,hd,hp⟩ := h + refine ⟨.bounded p,d,hd,?_⟩ + intro e he + exact (p.absolute M hM (mix e d) (by + intro i; unfold mix; split <;> first | exact he _ | exact hd _)).trans (hp e) + +theorem SigmaDefinable.existsSet (h : SigmaDefinable M P) : + SigmaDefinable M (fun e => ∃ x ∈ M, P (cons x e)) := by + obtain ⟨p,d,hd,hp⟩ := h + refine ⟨.existsSet (p.rename bindSlots),d,hd,?_⟩ + intro e he + simp only [SigmaFormula.Realize,SigmaFormula.realize_rename] + apply exists_congr; intro x + apply and_congr_right; intro hx + have hh := bind_mix x e d + change (p.Realize M (cons x (mix e d) ∘ bindSlots)) ↔ _ + rw [hh] + exact hp (cons x e) (by intro i; cases i; exact hx; exact he _) + +theorem SigmaDefinable.congr (h : SigmaDefinable M P) + (hPQ : ∀ e, (∀ i, e i ∈ M) → (P e ↔ Q e)) : SigmaDefinable M Q := by + obtain ⟨p,d,hd,hp⟩ := h + exact ⟨p,d,hd,fun e he => (hp e he).trans (hPQ e he)⟩ + +theorem SigmaDefinable.binary (F : ZFSet.{u} → ZFSet.{u}) + (h : SigmaDefinable M (fun e => e 0 = F (e 1))) : + ∃ p : SigmaFormula, ∃ d : ℕ → ZFSet.{u}, (∀ i, d i ∈ M) ∧ + ∀ x ∈ M, ∀ y ∈ M, p.Realize M (cons y (cons x d)) ↔ y = F x := by + obtain ⟨p,d,hd,hp⟩ := h + let r : ℕ → ℕ := fun i => if i % 2 = 0 then (if i / 2 = 0 then 0 else 1) else i/2+2 + refine ⟨p.rename r,d,hd,?_⟩ + intro x hx y hy + rw [SigmaFormula.realize_rename] + have he : cons y (cons x d) ∘ r = mix (cons y (fun _ => x)) d := by + apply parity_ext + · intro n + cases n with + | zero => rfl + | succ n => simp [r,show ¬ 2 * (n+1) ≤ 1 by omega] + · intro n; simp [r,Nat.add_div] + change p.Realize M (cons y (cons x d) ∘ r) ↔ _ + rw [he] + exact hp (cons y (fun _ => x)) (by intro i; cases i; exact hy; exact hx) + +end TuringRigidity.BoundedDefinability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaParameterizedClosure.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaParameterizedClosure.lean new file mode 100644 index 0000000000000000000000000000000000000000..672e20e32a89bc4e5cc6e2c12d20965e0cab11de --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaParameterizedClosure.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaParameterized +import OAI.Computability.DegreeRigidity.Representation.SourceTheory + +namespace OAI + + +namespace TuringRigidity.BoundedDefinability +open BoundedSetTheory TransitiveNameModel SetModelFunctions +universe u +variable {M : ZFSet.{u}} {P Q : (ℕ → ZFSet.{u}) → Prop} + +theorem SigmaDefinable.subst (h : SigmaDefinable M P) (r : ℕ → ℕ) : + SigmaDefinable M (fun e => P (e ∘ r)) := by + obtain ⟨p,d,hd,hp⟩ := h + refine ⟨p.rename (slotMap r id),d,hd,?_⟩ + intro e he + rw [SigmaFormula.realize_rename] + change p.Realize M (mix e d ∘ slotMap r id) ↔ _ + simpa only [mix_slotMap,Function.comp_id] using hp (e ∘ r) (fun i => he (r i)) + +theorem SigmaDefinable.and (hP : SigmaDefinable M P) (hQ : SigmaDefinable M Q) : + SigmaDefinable M (fun e => P e ∧ Q e) := by + obtain ⟨p,d,hd,hp⟩ := hP + obtain ⟨q,c,hc,hq⟩ := hQ + refine ⟨.conj (p.rename (slotMap id (fun i => 2*i))) + (q.rename (slotMap id (fun i => 2*i+1))),mix d c,?_,?_⟩ + · intro i; unfold mix; split <;> first | exact hd _ | exact hc _ + · intro e he + rw [SigmaFormula.realize_conj,SigmaFormula.realize_rename,SigmaFormula.realize_rename] + have hd' : mix d c ∘ (fun i => 2*i) = d := by funext i; simp + have hc' : mix d c ∘ (fun i => 2*i+1) = c := by funext i; simp + change p.Realize M (mix e (mix d c) ∘ slotMap id (fun i => 2*i)) ∧ + q.Realize M (mix e (mix d c) ∘ slotMap id (fun i => 2*i+1)) ↔ _ + rw [mix_slotMap,mix_slotMap,Function.comp_id,hd',hc',hp e he,hq e he] + +theorem SigmaDefinable.or (h0 : (∅ : ZFSet.{u}) ∈ M) + (hP : SigmaDefinable M P) (hQ : SigmaDefinable M Q) : + SigmaDefinable M (fun e => P e ∨ Q e) := by + obtain ⟨p,d,hd,hp⟩ := hP + obtain ⟨q,c,hc,hq⟩ := hQ + refine ⟨.disj (p.rename (slotMap id (fun i => 2*i))) + (q.rename (slotMap id (fun i => 2*i+1))),mix d c,?_,?_⟩ + · intro i; unfold mix; split <;> first | exact hd _ | exact hc _ + · intro e he + rw [SigmaFormula.realize_disj M h0,SigmaFormula.realize_rename,SigmaFormula.realize_rename] + have hd' : mix d c ∘ (fun i => 2*i) = d := by funext i; simp + have hc' : mix d c ∘ (fun i => 2*i+1) = c := by funext i; simp + change p.Realize M (mix e (mix d c) ∘ slotMap id (fun i => 2*i)) ∨ + q.Realize M (mix e (mix d c) ∘ slotMap id (fun i => 2*i+1)) ↔ _ + rw [mix_slotMap,mix_slotMap,Function.comp_id,hd',hc',hp e he,hq e he] + +theorem SigmaDefinable.impBounded (C : Context M) + (hP : Definable M P) (hQ : SigmaDefinable M Q) : + SigmaDefinable M (fun e => P e → Q e) := by + apply ((hP.neg.toSigma C.transitive).or (C.nat_mem 0) hQ).congr + intro e _ + classical + tauto + +theorem SigmaDefinable.allMem (hM : Transitive M) (hT : SourceT M) + (h : SigmaDefinable M P) (a : ℕ) : + SigmaDefinable M (fun e => ∀ x ∈ e a, P (cons x e)) := by + obtain ⟨p,d,hd,hp⟩ := h + have hC := sigma_collection M hM hT.pairing hT.union hT.powerSet + hT.separation.finitePrefix hT.replacement.finitePrefix hT.infinity hT.choice + refine ⟨.allMem (2*a) (p.rename bindSlots),d,hd,?_⟩ + intro e he + rw [SigmaFormula.realize_allMem M hM hT.pairing hT.union hT.separation.finitePrefix.bounded + hT.replacement.finitePrefix hT.infinity hC _ _ _ (by + intro i; unfold mix; split <;> first | exact he _ | exact hd _),mix_even] + apply forall_congr'; intro x + apply forall_congr'; intro hx + rw [SigmaFormula.realize_rename] + change p.Realize M (cons x (mix e d) ∘ bindSlots) ↔ _ + rw [bind_mix] + exact hp (cons x e) (by intro i; cases i; exact hM _ (he a) x hx; exact he _) + +end TuringRigidity.BoundedDefinability + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaSeparationName.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaSeparationName.lean new file mode 100644 index 0000000000000000000000000000000000000000..7bcc871d844a1c4e9b8bdc74a4ee9f46d22c7f78 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaSeparationName.lean @@ -0,0 +1,121 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaDefinability +import OAI.Computability.DegreeRigidity.Syntax.SigmaInterpretation + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u + +theorem sigma_sep_mem (M : ZFSet.{u}) (hM : Transitive M) (hS : SigmaSeparation M) + (φ : SigmaFormula) (env : ℕ → ZFSet.{u}) (he : ∀ i, env i ∈ M) + {a : ZFSet.{u}} (ha : a ∈ M) : + ZFSet.sep (fun x => φ.Realize M (cons x env)) a ∈ M := by + obtain ⟨b,hb,hdef⟩ := hS φ env he a ha + have eq : b = ZFSet.sep (fun x => φ.Realize M (cons x env)) a := by + apply ZFSet.ext + intro x + rw [ZFSet.mem_sep] + constructor + · intro hx; exact (hdef x (hM b hb x hx)).mp hx + · intro hx; exact (hdef x (hM a ha x hx.1)).mpr hx + exact eq ▸ hb + +end TuringRigidity.BoundedSetTheory + +namespace TuringRigidity.BoundedForcing +open Set RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] + +theorem sigma_separation_name (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : SigmaSeparation M) + (hR : SigmaReplacement M) (hI : Infinity M) (hc : c ∈ M) + {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) + (φ : SigmaFormula) (a : Name (Conditions c)) (ha : a.encode (label c) ∈ M) + (e : ℕ → Name (Conditions c)) (he : ∀ i, (e i).encode (label c) ∈ M) : + ∃ B ∈ M, B ⊆ a.support (label c) ∧ ∀ x, + x ∈ (a.restrict (label c) B).val G.carrier ↔ x ∈ a.val G.carrier ∧ + φ.Realize (genericExtensionSet M c G.carrier) + (cons x (fun i => (e i).val G.carrier)) := by + let env := cons c (cons o (fun i => (e i).encode (label c))) + have henv : ∀ i, env i ∈ M := by + intro i; rcases i with _|i; exact hc + rcases i with _|i; exact hoM + exact he i + let ψ := SigmaFormula.existsSet (.existsSet + (SigmaFormula.andBounded (.orderedPair 2 1 0) + (SigmaCode.forcing φ 3 4 0 (push 1 (fun i => i+5))))) + let B := ZFSet.sep (fun z => ψ.Realize M (cons z env)) (a.support (label c)) + have hBM : B ∈ M := sigma_sep_mem M hM hS ψ env henv + (support_mem M hM hP hU hPow hS.bounded hc hoM ho a ha) + have hBsub : B ⊆ a.support (label c) := fun z hz => (ZFSet.mem_sep.mp hz).1 + have hai (i) : (a.child i).encode (label c) ∈ M := + names_childClosed M c hM a ha _ (child_relation a i) + have hpush (i) (n) : (push (a.child i) e n).encode (label c) ∈ M := by + cases n with + | zero => exact hai i + | succ n => exact he n + have hpair (z x q : ZFSet.{u}) (hz : z ∈ M) (hx : x ∈ M) (hq : q ∈ M) : + (Formula.orderedPair 2 1 0).Realize M (cons q (cons x (cons z env))) ↔ z = ZFSet.pair x q := by + rw [Formula.absolute _ M hM _ (by + intro n; rcases n with _|n; exact hq + rcases n with _|n; exact hx + rcases n with _|n; exact hz + exact henv n)] + exact Formula.eval_orderedPair 2 1 0 _ + have hB (i : a.arity) (q : Conditions c) (hq : q ≤ a.tag i) : + ZFSet.pair ((a.child i).encode (label c)) (label c q) ∈ B ↔ + SigmaForces M (push (a.child i) e) φ q := by + let z := ZFSet.pair ((a.child i).encode (label c)) (label c q) + have hqM := hM c hc _ (label_mem c q) + have hz : z ∈ M := orderedPair_mem M hM hP (hai i) hqM + have query := realize_sigmaForcing M hM hP hU hPow hS.bounded hR hI ho φ + (push (a.child i) e) q + (cons (label c q) (cons ((a.child i).encode (label c)) (cons z env))) + (by + intro n; rcases n with _|n; exact hqM + rcases n with _|n; exact hai i + rcases n with _|n; exact hz + exact henv n) + 3 4 0 (push 1 (fun n => n+5)) rfl rfl rfl + (by intro n; cases n <;> rfl) + have hs : z ∈ a.support (label c) := ZFSet.mem_range.mpr ⟨⟨i,⟨q,hq⟩⟩,rfl⟩ + change z ∈ ZFSet.sep _ _ ↔ _ + rw [ZFSet.mem_sep,and_iff_right hs] + simp only [ψ,SigmaFormula.Realize,SigmaFormula.realize_andBounded] + constructor + · rintro ⟨x,hx,r,hr,hxr,hφ⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp ((hpair z x r hz hx hr).mp hxr) + exact query.mp hφ + · intro hφ + exact ⟨_,hai i,_,hqM,(hpair z _ _ hz (hai i) hqM).mpr rfl,query.mpr hφ⟩ + have ht (i : a.arity) : + φ.Realize (genericExtensionSet M c G.carrier) + (cons ((a.child i).val G.carrier) (fun n => (e n).val G.carrier)) ↔ + ∃ p ∈ G.carrier, SigmaForces M (push (a.child i) e) φ p := by + have hev : (fun n => (push (a.child i) e n).val G.carrier) = + cons ((a.child i).val G.carrier) (fun n => (e n).val G.carrier) := by + funext n; cases n <;> rfl + rw [←hev] + exact internal_sigma_truth M hM hP hU hPow hS.bounded hR hI hc hoM ho G hG φ _ (hpush i) + refine ⟨B,hBM,hBsub,fun x => ?_⟩ + constructor + · intro hx + have hxa := a.val_restrict_subset (label c) B G hx + obtain ⟨i,q,hqi,hqb,hqG,hix⟩ := (a.mem_val_restrict (label c) B G.carrier x).mp hx + have hφ := (ht i).mpr ⟨q,hqG,(hB i q hqi).mp hqb⟩ + exact ⟨hxa,hix ▸ hφ⟩ + · rintro ⟨hxa,hφ⟩ + obtain ⟨i,hi,hix⟩ := (a.mem_val_children G.carrier x).mp hxa + obtain ⟨p,hp,hf⟩ := (ht i).mp (hix ▸ hφ) + obtain ⟨q,hq,hqp,hqi⟩ := G.directed hp hi + exact (a.mem_val_restrict (label c) B G.carrier x).mpr + ⟨i,q,hqi,(hB i q hqi).mpr (sigma_mono M φ _ hqp hf),hq,hix⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaSequenceTrace.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaSequenceTrace.lean new file mode 100644 index 0000000000000000000000000000000000000000..623dc9dfdd899eb302ff8f370b57d3b86ef899cd --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaSequenceTrace.lean @@ -0,0 +1,103 @@ +import OAI.Computability.DegreeRigidity.OrdinalCodes.OmegaPowerDefinability +import OAI.Computability.DegreeRigidity.Syntax.SigmaParameterizedClosure +import OAI.Computability.DegreeRigidity.SetModels.SetModelIteration + +namespace OAI + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel BoundedDefinability SetModelFunctions SetModelIteration RelativeConstructible +universe u + +def SequenceTrace (M : ZFSet.{u}) (S : ZFSet.{u} → ZFSet.{u} → Prop) + (n x y d r f z : ZFSet.{u}) : Prop := + d = insert n n ∧ FunctionGraph d r f ∧ z = ∅ ∧ + ZFSet.pair z x ∈ f ∧ ZFSet.pair n y ∈ f ∧ + ∀ i ∈ n, ∃ j ∈ M, j = insert i i ∧ ∀ v ∈ r, ∀ w ∈ r, + (ZFSet.pair i v ∈ f ∧ ZFSet.pair j w ∈ f) → S v w + +theorem sequenceTrace_sigma (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (S : ZFSet.{u} → ZFSet.{u} → Prop) + (hS : SigmaDefinable M (fun e => S (e 1) (e 0))) : + SigmaDefinable M (fun e => SequenceTrace M S (e 0) (e 1) (e 2) (e 3) (e 4) (e 5) (e 6)) := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + have hcore : Definable M (fun e => e 3 = insert (e 0) (e 0) ∧ FunctionGraph (e 3) (e 4) (e 5) ∧ + e 6 = ∅ ∧ ZFSet.pair (e 6) (e 1) ∈ e 5 ∧ ZFSet.pair (e 0) (e 2) ∈ e 5) := by + refine ⟨.conj (.successor 6 0) (.conj (.functionGraph 10 6 8) + (.conj (.empty 12) (.conj (.pairMem 12 2 10) (.pairMem 0 4 10)))), + fun _ => ZFSet.omega,fun _ => C.omega_mem,?_⟩ + intro e + simp [Formula.Eval,Formula.eval_successor,Formula.eval_functionGraph, + Formula.eval_empty,Formula.eval_pairMem,mix,FunctionGraph] + have hAnte : Definable M (fun e => ZFSet.pair (e 3) (e 1) ∈ e 9 ∧ + ZFSet.pair (e 2) (e 0) ∈ e 9) := by + refine ⟨.conj (.pairMem 6 2 18) (.pairMem 4 0 18), + fun _ => ZFSet.omega,fun _ => C.omega_mem,?_⟩ + intro e; simp [Formula.Eval,Formula.eval_pairMem,mix] + have himp := SigmaDefinable.impBounded C hAnte hS + have hall := (himp.allMem hM hT 7).allMem hM hT 6 + have hsucc : Definable M (fun e => e 0 = insert (e 1) (e 1)) := by + refine ⟨.successor 0 2,fun _ => ZFSet.omega,fun _ => C.omega_mem,?_⟩ + intro e; simp [Formula.eval_successor,mix] + have hstep := (((hsucc.toSigma hM).and hall).existsSet).allMem hM hT 0 + exact ((hcore.toSigma hM).and hstep).congr (fun _ _ => by + simp only [SequenceTrace,cons_zero,cons_succ,and_assoc]) + +theorem SequenceTrace.correct (M : ZFSet.{u}) (S : ZFSet.{u} → ZFSet.{u} → Prop) + (s : ℕ → ZFSet.{u}) (hS : ∀ i w, S (s i) w → w = s (i+1)) + (n : ℕ) {y d r f z : ZFSet.{u}} + (h : SequenceTrace M S (natSet n) (s 0) y d r f z) : y = s n := by + obtain ⟨rfl,hfun,rfl,hzero,hy,hstep⟩ := h + have hd : insert (natSet.{u} n) (natSet n) = natSet (n+1) := rfl + rw [hd] at hfun + have computes (i : ℕ) (hi : i ≤ n) : ZFSet.pair (natSet i) (s i) ∈ f := by + induction i with + | zero => exact hzero + | succ i ih => + have hip := ih (by omega) + have hiv : s i ∈ r := by + obtain ⟨x,_,v,hv,heq⟩ := hfun.1 _ hip + obtain ⟨_,rfl⟩ := ZFSet.pair_inj.mp heq + exact hv + have hjd : natSet.{u} (i+1) ∈ natSet (n+1) := (natSet_mem_natSet _ _).mpr (by omega) + obtain ⟨w,hw,hjw,_⟩ := hfun.2 _ hjd + obtain ⟨j,_,hj,hs⟩ := hstep (natSet i) ((natSet_mem_natSet _ _).mpr (by omega)) + have hj' : j = natSet (i+1) := hj + have hs' := hs (s i) hiv w hw ⟨hip,hj' ▸ hjw⟩ + exact (hS i w hs') ▸ hjw + exact hfun.functional ((natSet_mem_natSet _ _).mpr (Nat.lt_succ_self n)) hy (computes n le_rfl) + +theorem sequenceTrace_exists (M : ZFSet.{u}) (hM : Transitive M) (hT : SourceT M) + (S : ZFSet.{u} → ZFSet.{u} → Prop) (s : ℕ → ZFSet.{u}) + (hs : ∀ i, s i ∈ M) (hstep : ∀ i, S (s i) (s (i+1))) (n : ℕ) : + ∃ z ∈ M, ∃ f ∈ M, ∃ r ∈ M, ∃ d ∈ M, SequenceTrace M S (natSet n) (s 0) (s n) d r f z := by + let C : Context M := ⟨hM,hT.pairing,hT.union,hT.powerSet,hT.separation.finitePrefix.bounded,hT.infinity⟩ + let f := finiteGraph (n+1) s + have hf : f ∈ M := finiteGraph_mem M hM hT.pairing hT.union C.omega_mem _ s (fun i _ => hs i) + let r := iterUnion 2 f + have hr := iterUnion_mem M hM hT.union hf 2 + have hval (i : ℕ) (hi : i < n+1) : s i ∈ r := + second_mem_doubleUnion ((pair_mem_finiteGraph _ _ _ _).mpr ⟨hi,rfl⟩) + have hfun : FunctionGraph (natSet (n+1)) r f := by + constructor + · intro z hz + obtain ⟨i,hi,rfl⟩ := (mem_finiteGraph _ _ _).mp hz + exact ⟨natSet i,(natSet_mem_natSet _ _).mpr hi,s i,hval i hi,rfl⟩ + · intro x hx + obtain ⟨i,hi,rfl⟩ := (mem_natSet (n+1) x).mp hx + refine ⟨s i,hval i hi,(pair_mem_finiteGraph _ _ _ _).mpr ⟨hi,rfl⟩,?_⟩ + intro y _ hy + exact ((pair_mem_finiteGraph _ _ _ _).mp hy).2 + refine ⟨∅,C.nat_mem 0,f,hf,r,hr,natSet (n+1),C.nat_mem _,rfl,hfun,rfl, + (pair_mem_finiteGraph _ _ _ _).mpr ⟨by omega,rfl⟩, + (pair_mem_finiteGraph _ _ _ _).mpr ⟨by omega,rfl⟩,?_⟩ + intro i hi + obtain ⟨i,hi,rfl⟩ := (mem_natSet n i).mp hi + refine ⟨natSet (i+1),C.nat_mem _,rfl,?_⟩ + intro v _ w _ hp + rw [((pair_mem_finiteGraph _ _ _ _).mp hp.1).2, + ((pair_mem_finiteGraph _ _ _ _).mp hp.2).2] + exact hstep i + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaSyntax.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9479d0dd0a7aeb38ff96bb605df203b62142023 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaSyntax.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DegreeRigidity.Syntax.BoundedRelations + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +universe u + +def liftMap (v : ℕ → ℕ) : ℕ → ℕ + | 0 => 0 + | i+1 => v i+1 + +namespace Formula + +def rename (v : ℕ → ℕ) : Formula → Formula + | .equal i j => .equal (v i) (v j) + | .member i j => .member (v i) (v j) + | .conj φ ψ => .conj (rename v φ) (rename v ψ) + | .neg φ => .neg (rename v φ) + | .existsMem i φ => .existsMem (v i) (rename (liftMap v) φ) + +theorem realize_rename (φ : Formula) (M : ZFSet.{u}) (v : ℕ → ℕ) + (e : ℕ → ZFSet.{u}) : (φ.rename v).Realize M e ↔ φ.Realize M (fun i => e (v i)) := by + induction φ generalizing v e with + | equal => rfl + | member => rfl + | conj φ ψ ihφ ihψ => exact and_congr (ihφ v e) (ihψ v e) + | neg φ ih => exact not_congr (ih v e) + | existsMem i φ ih => + simp only [rename,Realize] + apply exists_congr + intro x + apply and_congr_right + intro _ + apply and_congr_right + intro _ + have he : (fun i => cons x e (liftMap v i)) = cons x (fun i => e (v i)) := by + funext i; cases i <;> rfl + exact (ih (liftMap v) (cons x e)).trans (he ▸ Iff.rfl) +end Formula + +namespace SigmaFormula + +def rename (v : ℕ → ℕ) : SigmaFormula → SigmaFormula + | .bounded φ => .bounded (φ.rename v) + | .existsSet φ => .existsSet (rename (liftMap v) φ) + +theorem realize_rename (φ : SigmaFormula) (M : ZFSet.{u}) (v : ℕ → ℕ) + (e : ℕ → ZFSet.{u}) : (φ.rename v).Realize M e ↔ φ.Realize M (fun i => e (v i)) := by + induction φ generalizing v e with + | bounded φ => exact φ.realize_rename M v e + | existsSet φ ih => + simp only [rename,Realize] + apply exists_congr + intro x + apply and_congr_right + intro _ + have he : (fun i => cons x e (liftMap v i)) = cons x (fun i => e (v i)) := by + funext i; cases i <;> rfl + exact (ih (liftMap v) (cons x e)).trans (he ▸ Iff.rfl) + +def andBounded (b : Formula) : SigmaFormula → SigmaFormula + | .bounded φ => .bounded (.conj b φ) + | .existsSet φ => .existsSet (andBounded (b.rename Nat.succ) φ) + +theorem realize_andBounded (b : Formula) (φ : SigmaFormula) (M : ZFSet.{u}) + (e : ℕ → ZFSet.{u}) : + (andBounded b φ).Realize M e ↔ b.Realize M e ∧ φ.Realize M e := by + induction φ generalizing b e with + | bounded => rfl + | existsSet φ ih => + simp only [andBounded,Realize,ih,Formula.realize_rename,cons_succ] + constructor + · rintro ⟨x,hx,hb,hφ⟩; exact ⟨hb,x,hx,hφ⟩ + · rintro ⟨hb,x,hx,hφ⟩; exact ⟨x,hx,hb,hφ⟩ + +def conj : SigmaFormula → SigmaFormula → SigmaFormula + | .bounded b, ψ => andBounded b ψ + | .existsSet φ, ψ => .existsSet (conj φ (ψ.rename Nat.succ)) + +theorem realize_conj (φ ψ : SigmaFormula) (M : ZFSet.{u}) (e : ℕ → ZFSet.{u}) : + (conj φ ψ).Realize M e ↔ φ.Realize M e ∧ ψ.Realize M e := by + induction φ generalizing ψ e with + | bounded b => exact realize_andBounded b ψ M e + | existsSet φ ih => + simp only [conj,Realize,ih,realize_rename,cons_succ] + constructor + · rintro ⟨x,hx,hφ,hψ⟩; exact ⟨⟨x,hx,hφ⟩,hψ⟩ + · rintro ⟨⟨x,hx,hφ⟩,hψ⟩; exact ⟨x,hx,hφ,hψ⟩ +end SigmaFormula + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaTransitiveWitness.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaTransitiveWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c80e5ad3d49e24f34c166e26ce6ec3f39041569 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/SigmaTransitiveWitness.lean @@ -0,0 +1,46 @@ +import OAI.Computability.DegreeRigidity.Syntax.SigmaCollection + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace SigmaFormula + +theorem transitive_upward (φ : SigmaFormula) {d D : ZFSet.{u}} (hd : Transitive d) (hD : Transitive D) + (hsub : d ⊆ D) (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ d) : + φ.Realize d e → φ.Realize D e := by + induction φ generalizing e with + | bounded φ => + intro h + exact (φ.absolute D hD e (fun i => hsub (he i))).mpr ((φ.absolute d hd e he).mp h) + | existsSet φ ih => + rintro ⟨x,hx,hφ⟩ + exact ⟨x,hsub hx,ih (cons x e) (by intro i; cases i <;> simp [cons,he,hx]) hφ⟩ + +theorem internal_transitive_witness (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hS : Separation M) + (hR : SigmaReplacement M) (hI : Infinity M) {t : ZFSet.{u}} (ht : t ∈ M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ t) (φ : SigmaFormula) (hφ : φ.Realize M e) : + ∃ d ∈ M, Transitive d ∧ t ⊆ d ∧ φ.Realize d e := by + obtain ⟨xs,hlen,hxs,hmat⟩ := (φ.realize_iff_prefix M e).mp hφ + have hω := omega_mem M hM hS hI + have h0 := hM _ hω _ ZFSet.omega_zero + let s := t ∪ FiniteTuple.elements xs + have hs : s ∈ M := binary_union_mem M hM hP hU ht (FiniteTuple.elements_mem M hM hP hU h0 xs hxs) + obtain ⟨d,hdM,hd,hsd⟩ := internal_transitive_container M hM hP hU hS hR hI hs + have hsD : s ⊆ d := fun y hy => hd s hsd y hy + have htD : t ⊆ d := fun y hy => hsD (ZFSet.mem_union.mpr (Or.inl hy)) + have hxsD : ∀ y ∈ xs, y ∈ d := fun y hy => + hsD (ZFSet.mem_union.mpr (Or.inr ((FiniteTuple.mem_elements y xs).mpr hy))) + have heM := fun i => hM t ht _ (he i) + have heD := fun i => htD (he i) + refine ⟨d,hdM,hd,htD,(φ.realize_iff_prefix d e).mpr ⟨xs,hlen,hxsD,?_⟩⟩ + exact (φ.matrix.absolute d hd _ (feed_mem xs e d hxsD heD)).mpr + ((φ.matrix.absolute M hM _ (feed_mem xs e M hxs heM)).mp hmat) +end SigmaFormula + +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/TermCertificate.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/TermCertificate.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd034bc1d0890b8c060c47b9e69ebe5916bf8a7f --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/TermCertificate.lean @@ -0,0 +1,77 @@ +import OAI.Computability.DegreeRigidity.Syntax.FiniteTerm + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace FiniteTerm + +theorem Certificate.union {A B L O K D f g : ZFSet.{u}} + (hf : Certificate A B L O K D f) (hg : Certificate A B L O K D g) : + Certificate A B L O K D (f ∪ g) := by + intro z hz + rcases ZFSet.mem_union.mp hz with hz|hz + · obtain ⟨c,hc,v,hv,rfl,hs⟩ := hf z hz + exact ⟨c,hc,v,hv,rfl,hs.mono (fun _ hx => ZFSet.mem_union.mpr (Or.inl hx))⟩ + · obtain ⟨c,hc,v,hv,rfl,hs⟩ := hg z hz + exact ⟨c,hc,v,hv,rfl,hs.mono (fun _ hx => ZFSet.mem_union.mpr (Or.inr hx))⟩ + +theorem Certificate.adjoin {A B L O K D f c v : ZFSet.{u}} + (hf : Certificate A B L O K D f) (hc : c ∈ K) (hv : v ∈ D) + (hs : Step A B L O K D (f ∪ ({ZFSet.pair c v} : ZFSet.{u})) c v) : + Certificate A B L O K D (f ∪ ({ZFSet.pair c v} : ZFSet.{u})) := by + intro z hz + rcases ZFSet.mem_union.mp hz with hz|hz + · obtain ⟨a,ha,x,hx,rfl,hax⟩ := hf z hz + exact ⟨a,ha,x,hx,rfl,hax.mono (fun _ hx => ZFSet.mem_union.mpr (Or.inl hx))⟩ + · obtain rfl := ZFSet.mem_singleton.mp hz + exact ⟨c,hc,v,hv,rfl,hs⟩ + +theorem internal_certificate (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) + {A B L O K D : ZFSet.{u}} (hK : K ∈ M) (hD : D ∈ M) + (hcode : ∀ c v, Eval A B L O D c v → c ∈ K) + {c v : ZFSet.{u}} (h : Eval A B L O D c v) : + ∃ f ∈ M, Certificate A B L O K D f ∧ ZFSet.pair c v ∈ f := by + induction h with + | @leaf a x ha hx hax => + have ev : Eval A B L O D (tag 0 a) x := .leaf ha hx hax + have hc := hcode _ _ ev + let f := ({ZFSet.pair (tag 0 a) x} : ZFSet.{u}) + have hf : f ∈ M := singleton_mem M hM hP + (orderedPair_mem M hM hP (hM K hK _ hc) (hM D hD _ hx)) + refine ⟨f,hf,?_,ZFSet.mem_singleton.mpr rfl⟩ + intro z hz; obtain rfl := ZFSet.mem_singleton.mp hz + exact ⟨_,hc,x,hx,rfl,Or.inl ⟨a,ha,rfl,hax⟩⟩ + | @app o a x y ho ev hy hoy ih => + obtain ⟨f,hf,hfc,hax⟩ := ih + have hc := hcode _ _ (Eval.app ho ev hy hoy) + have hroot : ZFSet.pair (tag 1 (ZFSet.pair o a)) y ∈ M := + orderedPair_mem M hM hP (hM K hK _ hc) (hM D hD _ hy) + refine ⟨f ∪ {ZFSet.pair (tag 1 (ZFSet.pair o a)) y}, + binary_union_mem M hM hP hU hf (singleton_mem M hM hP hroot),?_, + ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_singleton.mpr rfl))⟩ + apply hfc.adjoin hc hy + exact Or.inr (Or.inl ⟨o,ho,a,hcode _ _ ev,x,ev.value_mem,rfl, + ZFSet.mem_union.mpr (Or.inl hax),hoy⟩) + | @pair a b x y eva evb hxy iha ihb => + obtain ⟨f,hf,hfc,hax⟩ := iha + obtain ⟨g,hg,hgc,hby⟩ := ihb + have hc := hcode _ _ (Eval.pair eva evb hxy) + have hroot : ZFSet.pair (tag 2 (ZFSet.pair a b)) (ZFSet.pair x y) ∈ M := + orderedPair_mem M hM hP (hM K hK _ hc) (hM D hD _ hxy) + refine ⟨(f ∪ g) ∪ {ZFSet.pair (tag 2 (ZFSet.pair a b)) (ZFSet.pair x y)}, + binary_union_mem M hM hP hU (binary_union_mem M hM hP hU hf hg) + (singleton_mem M hM hP hroot),?_, + ZFSet.mem_union.mpr (Or.inr (ZFSet.mem_singleton.mpr rfl))⟩ + apply (hfc.union hgc).adjoin hc hxy + exact Or.inr (Or.inr ⟨a,hcode _ _ eva,b,hcode _ _ evb,x,eva.value_mem,y,evb.value_mem,rfl, + ZFSet.mem_union.mpr (Or.inl (ZFSet.mem_union.mpr (Or.inl hax))), + ZFSet.mem_union.mpr (Or.inl (ZFSet.mem_union.mpr (Or.inr hby))),rfl⟩) + +end FiniteTerm +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/TermEvaluationGraph.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/TermEvaluationGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..6269a343e0bb209a198620475983b13377bf2711 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/TermEvaluationGraph.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DegreeRigidity.Syntax.TermFormula + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace FiniteTerm + +def graphFormula : Formula := + .existsMem 6 (.existsMem 8 (.conj (.orderedPair 2 1 0) + (.existsMem 3 (.conj (certificateFormula 5 6 7 8 9 10 0 11 12 13) (.pairMem 2 1 0))))) + +theorem eval_graphFormula (z q A B L O K D : ZFSet.{u}) : + graphFormula.Eval (cons z (cons q (cons A (cons B (cons L (cons O (cons K (cons D + (cons (natSet 0) (cons (natSet 1) (fun _ => natSet 2))))))))))) ↔ + ∃ c ∈ K, ∃ v ∈ D, z = ZFSet.pair c v ∧ ∃ f ∈ q, + Certificate A B L O K D f ∧ ZFSet.pair c v ∈ f := by + simp only [graphFormula,Formula.Eval,Formula.eval_orderedPair,Formula.eval_pairMem, + cons_zero,cons_succ] + apply exists_congr; intro c + apply and_congr_right; intro _ + apply exists_congr; intro v + apply and_congr_right; intro _ + apply and_congr_right; intro _ + apply exists_congr; intro f + apply and_congr_right; intro _ + apply and_congr_left; intro _ + exact eval_certificateFormula 5 6 7 8 9 10 0 11 12 13 + (cons f (cons v (cons c (cons z (cons q (cons A (cons B (cons L (cons O (cons K (cons D + (cons (natSet 0) (cons (natSet 1) (fun _ => natSet 2)))))))))))))) rfl rfl rfl + +theorem internal_evaluation_graph (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) (hS : Separation M) + (hω : ZFSet.omega.{u} ∈ M) {A B L O K D : ZFSet.{u}} + (hA : A ∈ M) (hB : B ∈ M) (hL : L ∈ M) (hO : O ∈ M) (hK : K ∈ M) (hD : D ∈ M) + (hcode : ∀ c v, Eval A B L O D c v → c ∈ K) : + ∃ E ∈ M, E ⊆ ZFSet.prod K D ∧ + ∀ c v, ZFSet.pair c v ∈ E ↔ Eval A B L O D c v := by + have hprod := product_mem M hM hP hU hPow hS hK hD + obtain ⟨q,hq,hqdef⟩ := internal_power M hM hPow hprod + have hn (n : ℕ) : natSet.{u} n ∈ M := hM _ hω _ ((mem_omega _).mpr ⟨n,rfl⟩) + let e := cons q (cons A (cons B (cons L (cons O (cons K (cons D + (cons (natSet 0) (cons (natSet 1) (fun _ => natSet 2))))))))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|i; exact hq + rcases i with _|i; exact hA + rcases i with _|i; exact hB + rcases i with _|i; exact hL + rcases i with _|i; exact hO + rcases i with _|i; exact hK + rcases i with _|i; exact hD + rcases i with _|i; exact hn 0 + rcases i with _|i; exact hn 1 + exact hn 2 + let E := ZFSet.sep (fun z => graphFormula.Eval (cons z e)) (ZFSet.prod K D) + have hE : E ∈ M := sep_mem M hM hS graphFormula e he hprod + refine ⟨E,hE,fun _ hz => (ZFSet.mem_sep.mp hz).1,?_⟩ + intro c v + change ZFSet.pair c v ∈ ZFSet.sep _ _ ↔ _ + rw [ZFSet.mem_sep,eval_graphFormula] + constructor + · rintro ⟨_,c',_,v',_,hp,f,_,hfc,hcv⟩ + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + exact hfc.sound c v hcv + · intro hv + obtain ⟨f,hf,hfc,hcv⟩ := internal_certificate M hM hP hU hK hD hcode hv + have hfq := (hqdef f).mpr ⟨hf,hfc.subset⟩ + exact ⟨ZFSet.mem_prod.mpr ⟨c,hcode c v hv,v,hv.value_mem,rfl⟩, + c,hcode c v hv,v,hv.value_mem,rfl,f,hfq,hfc,hcv⟩ + +theorem uniform_internal_evaluation_graph (M t : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) + (ht : t ∈ M) (htt : Transitive t) (hnt : ∀ n, natSet.{u} n ∈ t) : + ∃ K ∈ M, ∀ A ∈ M, A ⊆ t → ∀ B ∈ M, B ⊆ t → + ∀ L ∈ M, ∀ O ∈ M, ∀ D ∈ M, ∃ E ∈ M, E ⊆ ZFSet.prod K D ∧ + ∀ c v, ZFSet.pair c v ∈ E ↔ Eval A B L O D c v := by + obtain ⟨K,hK,hbound⟩ := FiniteTuple.internal_finite_code_bound M t hM hP hU hPow hS hR hI ht htt + refine ⟨K,hK,?_⟩ + intro A hA hAt B hB hBt L hL O hO D hD + exact internal_evaluation_graph M hM hP hU hPow hS.bounded (omega_mem M hM hS.bounded hI) + hA hB hL hO hK hD (fun c v hv => hbound c (hv.code_finite hAt hBt hnt)) + +end FiniteTerm +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/TermFormula.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/TermFormula.lean new file mode 100644 index 0000000000000000000000000000000000000000..0250335ea0f63085973d039706b5490885f2f6e4 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/TermFormula.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DegreeRigidity.Syntax.TermCertificate + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace Formula + +def rightPair (s a b c : ℕ) : Formula := .existsMem s (.existsMem 0 + (.conj (.orderedPair (s+2) (a+2) 0) (.orderedPair 0 (b+2) (c+2)))) + +def leftPair (s a b c : ℕ) : Formula := .existsMem s (.existsMem 0 + (.conj (.orderedPair (s+2) 0 (c+2)) (.orderedPair 0 (a+2) (b+2)))) + +theorem eval_rightPair (s a b c : ℕ) (e : ℕ → ZFSet.{u}) : + (rightPair s a b c).Eval e ↔ e s = ZFSet.pair (e a) (ZFSet.pair (e b) (e c)) := by + simp only [rightPair,Eval,eval_orderedPair,cons_zero,cons_succ] + constructor + · rintro ⟨p,_,q,_,h,rfl⟩; exact h + · intro h + refine ⟨{e a,ZFSet.pair (e b) (e c)},?_,ZFSet.pair (e b) (e c),?_,h,rfl⟩ + · rw [h]; exact ZFSet.mem_pair.mpr (Or.inr rfl) + · exact ZFSet.mem_pair.mpr (Or.inr rfl) + +theorem eval_leftPair (s a b c : ℕ) (e : ℕ → ZFSet.{u}) : + (leftPair s a b c).Eval e ↔ e s = ZFSet.pair (ZFSet.pair (e a) (e b)) (e c) := by + simp only [leftPair,Eval,eval_orderedPair,cons_zero,cons_succ] + constructor + · rintro ⟨p,_,q,_,h,rfl⟩; exact h + · intro h + refine ⟨{ZFSet.pair (e a) (e b),e c},?_,ZFSet.pair (e a) (e b),?_,h,rfl⟩ + · rw [h]; exact ZFSet.mem_pair.mpr (Or.inr rfl) + · exact ZFSet.mem_pair.mpr (Or.inl rfl) + +def appMem (a b c f : ℕ) : Formula := .existsMem f (leftPair 0 (a+1) (b+1) (c+1)) + +theorem eval_appMem (a b c f : ℕ) (e : ℕ → ZFSet.{u}) : + (appMem a b c f).Eval e ↔ ZFSet.pair (ZFSet.pair (e a) (e b)) (e c) ∈ e f := by + simp only [appMem,Eval,eval_leftPair,cons_zero,cons_succ] + exact ⟨fun ⟨x,hx,he⟩ => he ▸ hx,fun h => ⟨_,h,rfl⟩⟩ +end Formula +namespace FiniteTerm +open Formula + +def stepFormula (c v A B L O K D f z o t : ℕ) : Formula := + .disj (.existsMem A (.conj (.orderedPair (c+1) (z+1) 0) (.pairMem 0 (v+1) (L+1)))) + (.disj + (.existsMem B (.existsMem (K+1) (.existsMem (D+2) + (.conj (.rightPair (c+3) (o+3) 2 1) + (.conj (.pairMem 1 0 (f+3)) (.appMem 2 0 (v+3) (O+3))))))) + (.existsMem K (.existsMem (K+1) (.existsMem (D+2) (.existsMem (D+3) + (.conj (.rightPair (c+4) (t+4) 3 2) + (.conj (.pairMem 3 1 (f+4)) + (.conj (.pairMem 2 0 (f+4)) (.orderedPair (v+4) 1 0))))))))) + +theorem eval_stepFormula (c v A B L O K D f z o t : ℕ) (e : ℕ → ZFSet.{u}) + (hz : e z = natSet 0) (ho : e o = natSet 1) (ht : e t = natSet 2) : + (stepFormula c v A B L O K D f z o t).Eval e ↔ + Step (e A) (e B) (e L) (e O) (e K) (e D) (e f) (e c) (e v) := by + simp only [stepFormula,Formula.Eval,eval_disj,eval_orderedPair,eval_rightPair,eval_pairMem, + eval_appMem,cons_zero,cons_succ,hz,ho,ht,Step,tag] + +def certificateFormula (A B L O K D f z o t : ℕ) : Formula := + .allMem f (.existsMem (K+1) (.existsMem (D+2) (.conj (.orderedPair 2 1 0) + (stepFormula 1 0 (A+3) (B+3) (L+3) (O+3) (K+3) (D+3) (f+3) (z+3) (o+3) (t+3))))) + +theorem eval_certificateFormula (A B L O K D f z o t : ℕ) (e : ℕ → ZFSet.{u}) + (hz : e z = natSet 0) (ho : e o = natSet 1) (ht : e t = natSet 2) : + (certificateFormula A B L O K D f z o t).Eval e ↔ + Certificate (e A) (e B) (e L) (e O) (e K) (e D) (e f) := by + simp only [certificateFormula,eval_allMem,Formula.Eval,eval_orderedPair,cons_zero,cons_succ] + apply forall_congr'; intro w + apply forall_congr'; intro _ + apply exists_congr; intro c + apply and_congr_right; intro _ + apply exists_congr; intro v + apply and_congr_right; intro _ + apply and_congr_right; intro _ + exact eval_stepFormula 1 0 (A+3) (B+3) (L+3) (O+3) (K+3) (D+3) (f+3) + (z+3) (o+3) (t+3) (cons v (cons c (cons w e))) hz ho ht + +end FiniteTerm +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/TermFunctionality.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/TermFunctionality.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8ad9ba93177e16694817d3780f5a00e2a4eb087 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/TermFunctionality.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.Syntax.TermEvaluationGraph + +namespace OAI + + +namespace TuringRigidity.BoundedSetTheory +open TransitiveNameModel +universe u +namespace FiniteTerm + +def Functional (f : ZFSet.{u}) : Prop := + ∀ a x y, ZFSet.pair a x ∈ f → ZFSet.pair a y ∈ f → x = y + +theorem Eval.unfold (A B L O D c v : ZFSet.{u}) : Eval A B L O D c v ↔ + (∃ a ∈ A, v ∈ D ∧ c = tag 0 a ∧ ZFSet.pair a v ∈ L) ∨ + (∃ o ∈ B, ∃ a x, Eval A B L O D a x ∧ v ∈ D ∧ + c = tag 1 (ZFSet.pair o a) ∧ ZFSet.pair (ZFSet.pair o x) v ∈ O) ∨ + (∃ a b x y, Eval A B L O D a x ∧ Eval A B L O D b y ∧ v ∈ D ∧ + c = tag 2 (ZFSet.pair a b) ∧ v = ZFSet.pair x y) := by + constructor + · intro h; cases h with + | @leaf a x ha hx hax => exact Or.inl ⟨a,ha,hx,rfl,hax⟩ + | @app o c x y ho hx hy hox => exact Or.inr (Or.inl ⟨o,ho,c,x,hx,hy,rfl,hox⟩) + | @pair a b x y ha hb hxy => exact Or.inr (Or.inr ⟨a,b,x,y,ha,hb,hxy,rfl,rfl⟩) + · rintro (⟨a,ha,hv,rfl,hav⟩|⟨o,ho,a,x,hax,hv,rfl,hov⟩|⟨a,b,x,y,hax,hby,hv,rfl,rfl⟩) + · exact .leaf ha hv hav + · exact .app ho hax hv hov + · exact .pair hax hby hv + +theorem Eval.functional {A B L O D c x y : ZFSet.{u}} (hL : Functional L) (hO : Functional O) + (hx : Eval A B L O D c x) (hy : Eval A B L O D c y) : x = y := by + induction hx generalizing y with + | @leaf a x ha hx hax => + rcases (Eval.unfold _ _ _ _ _ _ _).mp hy with h|h|h + · obtain ⟨a',_,_,he,hav⟩ := h + obtain ⟨_,rfl⟩ := (tag_inj _ _ _ _).mp he + exact hL _ _ _ hax hav + · obtain ⟨o,_,b,v,_,_,he,_⟩ := h + have hh := ((tag_inj _ _ _ _).mp he).1 + omega + · obtain ⟨b,c,v,w,_,_,_,he,_⟩ := h + have hh := ((tag_inj _ _ _ _).mp he).1 + omega + | @app o a x v ho hax hv hov ih => + rcases (Eval.unfold _ _ _ _ _ _ _).mp hy with h|h|h + · obtain ⟨b,_,_,he,_⟩ := h + have hh := ((tag_inj _ _ _ _).mp he).1 + omega + · obtain ⟨o',_,a',x',hax',_,he,hov'⟩ := h + have hp := ((tag_inj _ _ _ _).mp he).2 + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + obtain rfl := ih hax' + exact hO _ _ _ hov hov' + · obtain ⟨b,c,w,z,_,_,_,he,_⟩ := h + have hh := ((tag_inj _ _ _ _).mp he).1 + omega + | @pair a b x v hax hbv hxv iha ihb => + rcases (Eval.unfold _ _ _ _ _ _ _).mp hy with h|h|h + · obtain ⟨c,_,_,he,_⟩ := h + have hh := ((tag_inj _ _ _ _).mp he).1 + omega + · obtain ⟨o,_,c,w,_,_,he,_⟩ := h + have hh := ((tag_inj _ _ _ _).mp he).1 + omega + · obtain ⟨a',b',x',v',hax',hbv',_,he,rfl⟩ := h + have hp := ((tag_inj _ _ _ _).mp he).2 + obtain ⟨rfl,rfl⟩ := ZFSet.pair_inj.mp hp + obtain rfl := iha hax' + obtain rfl := ihb hbv' + rfl + +theorem evaluation_graph_functional {A B L O D E : ZFSet.{u}} + (hL : Functional L) (hO : Functional O) + (hE : ∀ c v, ZFSet.pair c v ∈ E ↔ Eval A B L O D c v) : Functional E := + fun c x y hx hy => ((hE c x).mp hx).functional hL hO ((hE c y).mp hy) + +end FiniteTerm +end TuringRigidity.BoundedSetTheory + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/VariableCertificateBounds.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/VariableCertificateBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..b887b7262a9076d4f89e4cde03ab63d78a9b3480 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/VariableCertificateBounds.lean @@ -0,0 +1,75 @@ +import OAI.Computability.DegreeRigidity.Constructibility.DefSystemCertificate + +namespace OAI + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions SetModelReals +universe u +variable {M : ZFSet.{u}} + +theorem boundWitness_allBounds (C : Context M) (Q B c b : ℕ) : + Definable M (fun e => BoundWitness (e Q) (e B) (e c) (e b)) := + (((leastFamily_definable C (Q+2) (c+2) 1).and + ((setSupportRecursion_definable C 1 0).and (defPairMem C (c+2) (b+2) 0))).existsMem + (B+1)).existsMem Q + +theorem tupleAdequate_allBounds (C : Context M) (Q B G c t : ℕ) : + Definable M (fun e => TupleAdequate (e Q) (e B) (e G) (e c) (e t)) := + ((((defOrderedPair C (t+3) 2 1).and + ((boundWitness_allBounds C (Q+3) (B+3) (c+3) 0).and + (defSubset C 0 2))).existsParam C.omega_mem).existsMem (G+1)).existsParam C.omega_mem + +theorem setTruthRecursion_allBounds (C : Context M) (Q B a G T f s : ℕ) : + Definable M (fun e => SetTruthRecursion (e Q) (e B) (e G) (e a) (e T) (e f) (e s)) := by + have hn := defAllMem ((((tupleAdequate_allBounds C (Q+3) (B+3) (G+3) 1 0).and + (defOrderedPair C 2 1 0)).existsMem (T+2)).existsMem (f+1)) s + have hr := defAllMem (defAllMem (defImp + (tupleAdequate_allBounds C (Q+2) (B+2) (G+2) 1 0) + (defIff (defPairMem C 1 0 (s+2)) + (setTruthStep_variable C (a+2) (G+2) (T+2) (s+2) 1 0))) (T+1)) f + exact hn.and hr + +theorem truthWitness_allBounds (C : Context M) (Q B a G T c s : ℕ) : + Definable M (fun e => TruthWitness (e Q) (e B) (e G) (e a) (e T) (e c) (e s)) := + ((leastFamily_definable C (Q+1) (c+1) 0).and + (setTruthRecursion_allBounds C (Q+1) (B+1) (a+1) (G+1) (T+1) 0 (s+1))).existsMem Q + +theorem satisfactionWitness_allBounds (C : Context M) (Q B a G H T z : ℕ) : + Definable M (fun e => SatisfactionWitness (e Q) (e B) (e G) (e H) (e a) (e T) (e z)) := + ((((truthWitness_allBounds C (Q+3) (B+3) (a+3) (G+3) (T+3) 2 0).and + ((defPairMem C 2 1 0).and (defOrderedPair C (z+3) 2 1))).existsMem (H+2)).existsMem + (T+1)).existsParam C.omega_mem + +theorem parameterAdequate_allBounds (C : Context M) (Q B G c t : ℕ) : + Definable M (fun e => ParameterAdequate (e Q) (e B) (e G) (e c) (e t)) := + ((((defOrderedPair C (t+3) 2 1).and + ((boundWitness_allBounds C (Q+3) (B+3) (c+3) 0).and + (defAllMem (defOr (member_definable C 0 3) (equal_definable C 0 3)) 0))).existsParam + C.omega_mem).existsMem (G+1)).existsParam C.omega_mem + +theorem definitionWitness_allBounds (C : Context M) (Q B a G T Z S : ℕ) : + Definable M (fun e => DefinitionWitness (e Q) (e B) (e G) (e a) (e T) (e Z) (e S)) := + (((parameterAdequate_allBounds C (Q+2) (B+2) (G+2) 1 0).and + (definesSubset_variable C (a+2) (G+2) (T+2) (Z+2) 1 0 (S+2))).existsMem (T+1)).existsParam C.omega_mem + +theorem satisfactionSystem_allBounds (C : Context M) (Q B a G T H Z : ℕ) : + Definable M (fun e => SatisfactionSystem (e Q) (e B) (e a) (e G) (e T) (e H) (e Z)) := by + have ht := defAllParam (defAllMem (defImp (leastFamily_definable C (Q+2) 1 0) + ((setTruthRecursion_allBounds C (Q+3) (B+3) (a+3) (G+3) (T+3) 1 0).existsMem (H+2))) (Q+1)) C.omega_mem + have hn := defAllMem (satisfactionWitness_allBounds C (Q+1) (B+1) (a+1) (G+1) (H+1) (T+1) 0) Z + have hc := defAllParam (defAllMem (defAllMem + (defImp (truthWitness_allBounds C (Q+3) (B+3) (a+3) (G+3) (T+3) 2 0) + (defImp (defPairMem C 2 1 0) (defPairMem C 2 1 (Z+3)))) (H+2)) (T+1)) C.omega_mem + exact (tupleSystem_definable C a G T).and (ht.and (hn.and hc)) + +theorem defSystem_allBounds (C : Context M) (Q B a G T H Z D : ℕ) : + Definable M (fun e => DefSystem (e Q) (e B) (e a) (e G) (e T) (e H) (e Z) (e D)) := by + have hn := defAllMem (definitionWitness_allBounds C (Q+1) (B+1) (a+1) (G+1) (T+1) (Z+1) 0) D + have hc := defAllParam (defAllMem (defImp (parameterAdequate_allBounds C (Q+2) (B+2) (G+2) 1 0) + ((definesSubset_variable C (a+3) (G+3) (T+3) (Z+3) 2 1 0).existsMem (D+2))) (T+1)) C.omega_mem + exact (satisfactionSystem_allBounds C Q B a G T H Z).and (hn.and hc) + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/VariableTruthSyntax.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/VariableTruthSyntax.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d8d4620a5459d0fe77a151abcca196661c5009d --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/VariableTruthSyntax.lean @@ -0,0 +1,106 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalDefinablePower + +namespace OAI + + +namespace TuringRigidity.RelativeConstructible +open ElementaryModel BoundedSetTheory TransitiveNameModel SentenceCoding +open BoundedDefinability SetModelFunctions SetModelReals +universe u +variable {M : ZFSet.{u}} + +theorem tupleLookup_variable (C : Context M) (G t i x : ℕ) : + Definable M (fun e => TupleLookup (e G) (e t) (e i) (e x)) := + (((defOrderedPair C (t+2) 1 0).and (defPairMem C (i+2) (x+2) 0)).existsMem (G+1)).existsParam C.omega_mem + +theorem tupleAdequate_variable (C : Context M) {Q B : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (G c t : ℕ) : + Definable M (fun e => TupleAdequate Q B (e G) (e c) (e t)) := + ((((defOrderedPair C (t+3) 2 1).and ((boundWitness_definable C hQ hB (c+3) 0).and + (defSubset C 0 2))).existsParam C.omega_mem).existsMem (G+1)).existsParam C.omega_mem + +theorem tuplePrefix_variable (C : Context M) (a G t x s : ℕ) : + Definable M (fun e => TuplePrefix (e a) (e G) (e t) (e x) (e s)) := by + let d := cons ZFSet.omega (fun _ => natSet 0) + let r : ℕ → ℕ := fun i => match i with + | 0 => 2*a | 1 => 1 | 2 => 2*G | 3 => 2*t | 4 => 2*x | 5 => 2*s | _ => 3 + refine ⟨(tuplePrefixFormula 0 1 2 3 4 5 6).rename r,d,?_,?_⟩ + · intro i; cases i + · exact C.omega_mem + · exact C.nat_mem 0 + · intro e + rw [Formula.eval_rename_comp] + have he : mix e d ∘ r = cons (e a) (cons ZFSet.omega (cons (e G) + (cons (e t) (cons (e x) (cons (e s) (fun _ => natSet 0)))))) := by + funext i + rcases i with _|_|_|_|_|_|i <;> simp only [r,d,Function.comp_apply,mix_even,cons_zero,cons_succ] <;> rfl + rw [he] + rfl + +theorem setTruthStep_variable (C : Context M) (a G T S c t : ℕ) : + Definable M (fun e => SetTruthStep (e a) (e G) (e T) (e S) (e c) (e t)) := by + have ha (tag : ℕ) (hr : Definable M (fun e => e 1 = e 0)) := + (((((binaryGraph_definable C _ (atomic_primrec tag) 3 2 (c+4)).and + ((tupleLookup_variable C (G+4) (t+4) 3 1).and + ((tupleLookup_variable C (G+4) (t+4) 2 0).and hr))).existsMem (a+3)).existsMem (a+2)).existsParam + C.omega_mem).existsParam C.omega_mem + have he := ha 0 (equal_definable C 1 0) + have hm := (((((binaryGraph_definable C _ (atomic_primrec 1) 3 2 (c+4)).and + ((tupleLookup_variable C (G+4) (t+4) 3 1).and + ((tupleLookup_variable C (G+4) (t+4) 2 0).and (member_definable C 1 0)))).existsMem (a+3)).existsMem + (a+2)).existsParam C.omega_mem).existsParam C.omega_mem + have hc := (((binaryGraph_definable C _ (binary_primrec 2) 1 0 (c+2)).and + ((defPairMem C 1 (t+2) (S+2)).and (defPairMem C 0 (t+2) (S+2)))).existsParam + C.omega_mem).existsParam C.omega_mem + have hn := ((unaryGraph_definable C _ (unary_primrec 3) 0 (c+1)).and + (defPairMem C 0 (t+1) (S+1)).neg).existsParam C.omega_mem + have hbody := (((tuplePrefix_variable C (a+3) (G+3) (t+3) 1 0).and + (defPairMem C 2 0 (S+3))).existsMem (T+2)).existsMem (a+1) + have hx := ((unaryGraph_definable C _ (unary_primrec 4) 0 (c+1)).and hbody).existsParam C.omega_mem + exact defOr he (defOr hm (defOr hc (defOr hn hx))) + +theorem setTruthRecursion_variable (C : Context M) {Q B : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (a G T f s : ℕ) : + Definable M (fun e => SetTruthRecursion Q B (e G) (e a) (e T) (e f) (e s)) := by + have hn := defAllMem ((((tupleAdequate_variable C hQ hB (G+3) 1 0).and + (defOrderedPair C 2 1 0)).existsMem (T+2)).existsMem (f+1)) s + have hr := defAllMem (defAllMem (defImp (tupleAdequate_variable C hQ hB (G+2) 1 0) + (defIff (defPairMem C 1 0 (s+2)) + (setTruthStep_variable C (a+2) (G+2) (T+2) (s+2) 1 0))) (T+1)) f + exact hn.and hr + +theorem truthWitness_variable (C : Context M) {Q B : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (a G T c s : ℕ) : + Definable M (fun e => TruthWitness Q B (e G) (e a) (e T) (e c) (e s)) := + ((leastFamily_param C hQ (c+1) 0).and + (setTruthRecursion_variable C hQ hB (a+1) (G+1) (T+1) 0 (s+1))).existsParam hQ + +theorem satisfactionWitness_variable (C : Context M) {Q B : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (a G H T z : ℕ) : + Definable M (fun e => SatisfactionWitness Q B (e G) (e H) (e a) (e T) (e z)) := + ((((truthWitness_variable C hQ hB (a+3) (G+3) (T+3) 2 0).and + ((defPairMem C 2 1 0).and (defOrderedPair C (z+3) 2 1))).existsMem (H+2)).existsMem + (T+1)).existsParam C.omega_mem + +theorem parameterAdequate_variable (C : Context M) {Q B : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (G c t : ℕ) : + Definable M (fun e => ParameterAdequate Q B (e G) (e c) (e t)) := + ((((defOrderedPair C (t+3) 2 1).and ((boundWitness_definable C hQ hB (c+3) 0).and + (defAllMem (defOr (member_definable C 0 3) (equal_definable C 0 3)) 0))).existsParam + C.omega_mem).existsMem (G+1)).existsParam C.omega_mem + +theorem definesSubset_variable (C : Context M) (a G T Z c t S : ℕ) : + Definable M (fun e => DefinesSubset (e a) (e G) (e T) (e Z) (e c) (e t) (e S)) := + (defSubset C S a).and (defAllMem (defIff (member_definable C 0 (S+1)) + (((tuplePrefix_variable C (a+2) (G+2) (t+2) 1 0).and + (defPairMem C (c+2) 0 (Z+2))).existsMem (T+1))) a) + +theorem definitionWitness_variable (C : Context M) {Q B : ZFSet.{u}} + (hQ : Q ∈ M) (hB : B ∈ M) (a G T Z S : ℕ) : + Definable M (fun e => DefinitionWitness Q B (e G) (e a) (e T) (e Z) (e S)) := + (((parameterAdequate_variable C hQ hB (G+2) 1 0).and + (definesSubset_variable C (a+2) (G+2) (T+2) (Z+2) 1 0 (S+2))).existsMem (T+1)).existsParam C.omega_mem + +end TuringRigidity.RelativeConstructible + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/WeakCheckedMembership.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/WeakCheckedMembership.lean new file mode 100644 index 0000000000000000000000000000000000000000..651eaf5622372aef4de7001a48e2c08b1e70b3f5 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/WeakCheckedMembership.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DegreeRigidity.Syntax.CheckedMembershipSeparation +import OAI.Computability.DegreeRigidity.Syntax.WeakCheckedValue +import OAI.Computability.DegreeRigidity.CohenForcing.WeakForcingCode + +namespace OAI + +namespace TuringRigidity.FullSetForcing +open RecursiveNames TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +open ElementaryModel SentenceForm +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + +theorem checkedMembership_spec_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) + {o : ZFSet.{u}} (ho : ∀ r s : Conditions c, + ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (t : Name (Conditions c)) (p : Conditions c) (x : ZFSet.{u}) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (h0 : e 0 = x) (h1 : e 1 = c) (h2 : e 2 = o) (h3 : e 3 = label c p) + (h4 : e 4 = t.encode (label c)) (h5 : e 5 = label c ⊤) : + checkedMembershipFormula.Sat (M : Set ZFSet) e ↔ MemForces (Name.check x) t p := by + let v : ℕ → ℕ := fun i => match i with | 0 => 0 | _ => 5 + let k : ℕ → ℕ := fun i => match i with | 0 => 0 | 1 => 1 | _ => 6 + let names : ℕ → Name (Conditions c) := fun i => match i with | 0 => Name.check x | _ => t + have hc : c ∈ M := h1 ▸ he 1 + have hx : x ∈ M := h0 ▸ he 0 + have hcheck : (Name.check x : Name (Conditions c)).encode (label c) ∈ M := + encoded_check_mem M c hM hP hU hPow + hS.bounded hR hI hc hx + have henv (z : ZFSet.{u}) (hz : z ∈ M) : ∀ i, cons z e i ∈ M := by + intro i; cases i; exact hz; exact he _ + have checked (z : ZFSet.{u}) (hz : z ∈ M) : + (checkedValueFormula.rename k).Sat (M : Set ZFSet) (cons z e) ↔ + z = (Name.check x : Name (Conditions c)).encode (label c) := by + rw [sat_rename,checkedValue_spec_without_choice M hM hP hU hPow hS hR hI _ (fun i => henv z hz (k i))] + simp only [k,cons_zero,cons_succ,h0,h5,encode_check] + have forcing (z : ZFSet.{u}) (hz : z ∈ M) + (hzv : z = (Name.check x : Name (Conditions c)).encode (label c)) : + (code (.member 0 1) 2 3 4 v).Sat (M : Set ZFSet) (cons z e) ↔ + MemForces (Name.check x) t p := by + exact realize_code_without_choice M hM hP hU hPow hS hR hI ho (.member 0 1) names p (cons z e) (henv z hz) + 2 3 4 v h1 h2 h3 (by intro i; cases i; exact hzv; exact h4) + change (∃ z ∈ M, (checkedValueFormula.rename k).Sat _ (cons z e) ∧ _) ↔ _ + constructor + · rintro ⟨z,hz,hzv,hf⟩ + exact (forcing z hz ((checked z hz).mp hzv)).mp hf + · intro hf + exact ⟨_,hcheck,(checked _ hcheck).mpr rfl,(forcing _ hcheck rfl).mpr hf⟩ + +theorem internal_forced_members_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) + (hc : c ∈ M) {o a : ZFSet.{u}} + (hoM : o ∈ M) (ha : a ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (t : Name (Conditions c)) (ht : t.encode (label c) ∈ M) (p : Conditions c) : + ∃ b ∈ M, ∀ x, x ∈ b ↔ x ∈ a ∧ MemForces (Name.check x) t p := by + let e := cons c (cons o (cons (label c p) (cons (t.encode (label c)) (fun _ => label c ⊤)))) + have he : ∀ i, e i ∈ M := by + intro i; rcases i with _|_|_|_|i + exact hc + exact hoM + exact hM c hc _ (label_mem c p) + exact ht + exact hM c hc _ (label_mem c ⊤) + obtain ⟨b,hb,hdef⟩ := hS checkedMembershipSigma e he a ha + have spec (x : ZFSet.{u}) (hx : x ∈ M) := checkedMembership_spec_without_choice M hM hP hU hPow hS hR hI ho t p x + (cons x e) (by intro i; cases i; exact hx; exact he _) rfl rfl rfl rfl rfl rfl + refine ⟨b,hb,fun x => ?_⟩ + constructor + · intro hx + have hxM := hM b hb x hx + obtain ⟨hxa,hf⟩ := (hdef x hxM).mp hx + exact ⟨hxa,(spec x hxM).mp ((checkedMembershipSigma_spec M _).mp hf)⟩ + · rintro ⟨hxa,hf⟩ + have hxM := hM a ha x hxa + exact (hdef x hxM).mpr ⟨hxa,(checkedMembershipSigma_spec M _).mpr ((spec x hxM).mpr hf)⟩ + +end TuringRigidity.FullSetForcing + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/WeakCheckedValue.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/WeakCheckedValue.lean new file mode 100644 index 0000000000000000000000000000000000000000..9fa01c3b22f209cbbcaab5a2dc6388158861e269 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/WeakCheckedValue.lean @@ -0,0 +1,45 @@ +import OAI.Computability.DegreeRigidity.SetModels.InternalCheckedValue +import OAI.Computability.DegreeRigidity.Representation.GroundInclusion + +namespace OAI + + +namespace TuringRigidity.ElementaryModel +open BoundedSetTheory TransitiveNameModel SentenceForm +universe u + +theorem checkedValue_complete_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) + (hv : e 0 = checkedCode (e 2) (e 1)) : + checkedValueFormula.Sat (M : Set ZFSet) e := by + obtain ⟨d,hd,hdT,hxd⟩ := internal_transitive_container M hM hP hU hS.bounded hR + hI (he 1) + obtain ⟨q,hq,hqdef⟩ := internal_power M hM hPow hd + obtain ⟨f,hf,hg⟩ := internal_checkGraph M d q (e 2) hM hP hU hPow + hS.bounded hR hd hq (he 2) hdT hqdef (e 1) hxd + have hh := hull_mem M d q hM hS.bounded hd hq (he 1) + have hr := iterUnion_mem M hM hU hf 2 + have hx := self_mem_hull d q hxd + obtain ⟨w,hw,hfw,_⟩ := hg.2.2.1 (e 1) hx + have hwv : w = e 0 := (hg.correct (e 1) hx w hw hfw).trans hv.symm + refine ⟨BoundedSetTheory.hull d q (e 1),hh,iterUnion 2 f,hr,f,hf,?_⟩ + have hi : ∀ i, cons f (cons (iterUnion 2 f) (cons (BoundedSetTheory.hull d q (e 1)) e)) i ∈ M := by + intro i; rcases i with _|_|_|i + exact hf + exact hr + exact hh + exact he i + rw [bounded_sat,Formula.absolute _ M hM _ hi] + simp only [Formula.Eval,CheckFormula.eval_graph,Formula.eval_pairMem,cons_zero,cons_succ] + exact ⟨hg,hx,hwv ▸ hw,hwv ▸ hfw⟩ + +theorem checkedValue_spec_without_choice (M : ZFSet.{u}) (hM : Transitive M) (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) + (e : ℕ → ZFSet.{u}) (he : ∀ i, e i ∈ M) : + checkedValueFormula.Sat (M : Set ZFSet) e ↔ e 0 = checkedCode (e 2) (e 1) := + ⟨checkedValue_sound M hM e he,checkedValue_complete_without_choice M hM hP hU hPow hS hR hI e he⟩ + +end TuringRigidity.ElementaryModel + +end OAI diff --git a/lean/OAI/Computability/DegreeRigidity/Syntax/WeakExtensionContext.lean b/lean/OAI/Computability/DegreeRigidity/Syntax/WeakExtensionContext.lean new file mode 100644 index 0000000000000000000000000000000000000000..af2e1599e6e0b25ebf949ef46caff73942b28555 --- /dev/null +++ b/lean/OAI/Computability/DegreeRigidity/Syntax/WeakExtensionContext.lean @@ -0,0 +1,29 @@ +import OAI.Computability.DegreeRigidity.SetModels.ExtensionSigmaSeparation +import OAI.Computability.DegreeRigidity.SetModels.ExtensionPowerSet +import OAI.Computability.DegreeRigidity.Representation.SourceTheory +import OAI.Computability.DegreeRigidity.SetModels.SetModelFunctionGraphs + +namespace OAI + +namespace TuringRigidity.BoundedForcing +open TransitiveNameModel BoundedSetTheory AtomicForcing CountableForcing +universe u +variable {c : ZFSet.{u}} [Preorder (Conditions c)] [Top (Conditions c)] + +theorem extension_context_without_choice (M : ZFSet.{u}) (hM : Transitive M) + (hP : Pairing M) (hU : BoundedSetTheory.Union M) (hPow : PowerSet M) + (hS : SigmaSeparation M) (hR : SigmaReplacement M) (hI : Infinity M) + (hc : c ∈ M) {o : ZFSet.{u}} (hoM : o ∈ M) + (ho : ∀ r s : Conditions c, ZFSet.pair (label c r) (label c s) ∈ o ↔ r ≤ s) + (G : GenericFilter (Conditions c)) (hG : GroundGeneric M G) (htop : ⊤ ∈ G.carrier) : + SetModelFunctions.Context (genericExtensionSet M c G.carrier) := by + exact ⟨genericExtensionSet_transitive M c hM G.carrier, + extension_pairing M c hM hP hc G.carrier htop, + extension_union M c o hM hP hU hPow hS.bounded hc hoM ho G, + extension_powerSet M hM hP hU hPow hS.bounded hR hI hc hoM ho G hG htop, + (extension_sigmaSeparation M hM hP hU hPow hS hR hI hc hoM ho G hG).bounded, + extension_infinity M c hM hP hU hPow hS.bounded hR hI hc G.carrier htop⟩ + +end TuringRigidity.BoundedForcing + +end OAI diff --git a/lean/OAI/Computability/DepthThree/AlgebraBits.lean b/lean/OAI/Computability/DepthThree/AlgebraBits.lean new file mode 100644 index 0000000000000000000000000000000000000000..896a62e70129566f9ca331658206eb27e5224542 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/AlgebraBits.lean @@ -0,0 +1,83 @@ +import Mathlib.Algebra.Field.ZMod +import Mathlib.Logic.Equiv.Defs + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 + +namespace DepthThreeLowerBound +namespace BinaryAlgebra + +abbrev F2 := ZMod 2 + +def boolEquivF2 : Bool ≃ F2 := finTwoEquiv.symm + +def bitValue (b : Bool) : F2 := boolEquivF2 b + +def fieldBit (a : F2) : Bool := boolEquivF2.symm a + +@[simp] theorem bitValue_false : bitValue false = 0 := rfl + +@[simp] theorem bitValue_true : bitValue true = 1 := rfl + +@[simp] theorem fieldBit_zero : fieldBit 0 = false := rfl + +@[simp] theorem fieldBit_one : fieldBit 1 = true := rfl + +@[simp] theorem fieldBit_bitValue (b : Bool) : fieldBit (bitValue b) = b := + boolEquivF2.symm_apply_apply b + +@[simp] theorem bitValue_fieldBit (a : F2) : bitValue (fieldBit a) = a := + boolEquivF2.apply_symm_apply a + +theorem bitValue_injective : Function.Injective bitValue := + boolEquivF2.injective + +theorem bitValue_surjective : Function.Surjective bitValue := + boolEquivF2.surjective + +theorem bitValue_xor (a b : Bool) : + bitValue (Bool.xor a b) = bitValue a + bitValue b := by + cases a <;> cases b <;> decide + +theorem bitValue_and (a b : Bool) : + bitValue (a && b) = bitValue a * bitValue b := by + cases a <;> cases b <;> decide + +theorem bitValue_not (a : Bool) : bitValue (!a) = 1 + bitValue a := by + cases a <;> decide + +@[simp] theorem bitValue_eq_zero_iff (b : Bool) : bitValue b = 0 ↔ b = false := by + cases b <;> decide + +@[simp] theorem bitValue_eq_one_iff (b : Bool) : bitValue b = 1 ↔ b = true := by + cases b <;> decide + +theorem eq_zero_or_one (a : F2) : a = 0 ∨ a = 1 := by + obtain ⟨b, rfl⟩ := boolEquivF2.surjective a + cases b <;> decide + +@[simp] theorem fieldBit_eq_false_iff (a : F2) : fieldBit a = false ↔ a = 0 := by + obtain ⟨b, rfl⟩ := boolEquivF2.surjective a + cases b <;> decide + +@[simp] theorem fieldBit_eq_true_iff (a : F2) : fieldBit a = true ↔ a = 1 := by + obtain ⟨b, rfl⟩ := boolEquivF2.surjective a + cases b <;> decide + +def bitsEquivF2 (V : Type uDepth1) : (V → Bool) ≃ (V → F2) where + toFun x i := bitValue (x i) + invFun x i := fieldBit (x i) + left_inv x := funext fun i => fieldBit_bitValue (x i) + right_inv x := funext fun i => bitValue_fieldBit (x i) + +@[simp] theorem bitsEquivF2_apply (V : Type uDepth2) (x : V → Bool) (i : V) : + bitsEquivF2 V x i = bitValue (x i) := rfl + +@[simp] theorem bitsEquivF2_symm_apply (V : Type uDepth3) (x : V → F2) (i : V) : + (bitsEquivF2 V).symm x i = fieldBit (x i) := rfl + +end BinaryAlgebra +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/AlgebraFiniteFibers.lean b/lean/OAI/Computability/DepthThree/AlgebraFiniteFibers.lean new file mode 100644 index 0000000000000000000000000000000000000000..d31decf5593ed4ebd32d96b2db9530e270d9141a --- /dev/null +++ b/lean/OAI/Computability/DepthThree/AlgebraFiniteFibers.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DepthThree.FiniteProbability +import Mathlib.Algebra.Group.Hom.Defs +import Mathlib.Data.Fintype.Card + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open scoped BigOperators + +namespace DepthThreeLowerBound.AlgebraFiniteFibers + +variable {A : Type uDepth1} {B : Type uDepth2} [AddCommGroup A] [AddCommGroup B] + +def fiberEquivKernel (L : A →+ B) (hL : Function.Surjective L) (b : B) : + {a : A // L a = b} ≃ {a : A // L a = 0} := by + let x : A := Classical.choose (hL b) + have hx : L x = b := Classical.choose_spec (hL b) + exact { + toFun := fun a => ⟨a.val - x, by rw [map_sub, a.property, hx, sub_self]⟩ + invFun := fun a => ⟨a.val + x, by rw [map_add, a.property, hx, zero_add]⟩ + left_inv := by + intro a + apply Subtype.ext + exact sub_add_cancel a.val x + right_inv := by + intro a + apply Subtype.ext + exact add_sub_cancel_right a.val x + } + +variable [Fintype A] [instFintypeB : Fintype B] [instDecidableEqA : DecidableEq A] [DecidableEq B] + +theorem card_fiber_eq + {A : Type uDepth1} + {B : Type uDepth2} + [AddCommGroup A] + [AddCommGroup B] + [Fintype A] + [Fintype B] + [DecidableEq A] + [DecidableEq B] + (L : A →+ B) (hL : Function.Surjective L) (b : B) : + Fintype.card {a : A // L a = b} = Fintype.card {a : A // L a = 0} := + Fintype.card_congr (fiberEquivKernel L hL b) + +theorem card_filter_fiber_eq (L : A →+ B) (hL : Function.Surjective L) (b : B) : + (Finset.univ.filter (fun a : A => L a = b)).card = + (Finset.univ.filter (fun a : A => L a = 0)).card := by + simpa only [Fintype.card_subtype] using card_fiber_eq L hL b + +theorem card_eq_mul_card_kernel (L : A →+ B) (hL : Function.Surjective L) : + Fintype.card A = Fintype.card B * Fintype.card {a : A // L a = 0} := by + calc + Fintype.card A = ∑ b : B, Fintype.card {a : A // L a = b} := by + simpa using + (Fintype.sum_fiberwise' (fun a : A => L a) (fun _ : B => (1 : ℕ))).symm + _ = ∑ _b : B, Fintype.card {a : A // L a = 0} := by + exact Finset.sum_congr rfl (fun b _ => card_fiber_eq L hL b) + _ = Fintype.card B * Fintype.card {a : A // L a = 0} := by simp + +theorem sum_comp (L : A →+ B) (hL : Function.Surjective L) (f : B → ℝ) : + (∑ a : A, f (L a)) = + (Fintype.card {a : A // L a = 0} : ℝ) * ∑ b : B, f b := by + calc + (∑ a : A, f (L a)) = ∑ b : B, ∑ _a : {a : A // L a = b}, f b := + (Fintype.sum_fiberwise' (fun a : A => L a) f).symm + _ = ∑ b : B, (Fintype.card {a : A // L a = 0} : ℝ) * f b := by + apply Finset.sum_congr rfl + intro b _ + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, + card_fiber_eq L hL b] + _ = (Fintype.card {a : A // L a = 0} : ℝ) * ∑ b : B, f b := + (Finset.mul_sum Finset.univ f _).symm + +theorem finiteAvg_comp (L : A →+ B) (hL : Function.Surjective L) (f : B → ℝ) : + finiteAvg (fun a : A => f (L a)) = finiteAvg f := by + let : Nonempty {a : A // L a = 0} := ⟨⟨0, map_zero L⟩⟩ + have hk : (Fintype.card {a : A // L a = 0} : ℝ) ≠ 0 := by + exact_mod_cast (Fintype.card_ne_zero : Fintype.card {a : A // L a = 0} ≠ 0) + unfold finiteAvg + rw [card_eq_mul_card_kernel L hL, Nat.cast_mul, sum_comp L hL f, mul_inv] + calc + (Fintype.card B : ℝ)⁻¹ * (Fintype.card {a : A // L a = 0} : ℝ)⁻¹ * + ((Fintype.card {a : A // L a = 0} : ℝ) * ∑ b : B, f b) = + (Fintype.card B : ℝ)⁻¹ * + ((Fintype.card {a : A // L a = 0} : ℝ)⁻¹ * + (Fintype.card {a : A // L a = 0} : ℝ)) * ∑ b : B, f b := by ring + _ = (Fintype.card B : ℝ)⁻¹ * ∑ b : B, f b := by + rw [inv_mul_cancel₀ hk, mul_one] + +end DepthThreeLowerBound.AlgebraFiniteFibers + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/AlgebraLanguage.lean b/lean/OAI/Computability/DepthThree/AlgebraLanguage.lean new file mode 100644 index 0000000000000000000000000000000000000000..c046fc5d4c9401a2b9cc8491db1208b7d8c3d9aa --- /dev/null +++ b/lean/OAI/Computability/DepthThree/AlgebraLanguage.lean @@ -0,0 +1,99 @@ +import OAI.Computability.DepthThree.AlgebraQuotient +import OAI.Computability.DepthThree.Language + +namespace OAI + +noncomputable section + +open scoped BigOperators + +namespace DepthThreeLowerBound + +namespace ParsedInput + +abbrev QuotientRing (q : ParsedInput) := AdjoinRoot q.modulus + +instance quotientRingFintype (q : ParsedInput) : Fintype q.QuotientRing := + BinaryAlgebra.inputQuotientFintype + (fun i => BinaryAlgebra.bitValue (q.polynomial i)) + +def quotientHash (q : ParsedInput) : q.QuotientRing := + AdjoinRoot.mk q.modulus q.hashPolynomial + +def quotientCoefficient (q : ParsedInput) (j : Fin q.coefficientCount) : q.QuotientRing := + AdjoinRoot.mk q.modulus (q.coefficientPolynomial j) + +def quotientEvaluation (q : ParsedInput) : q.QuotientRing := + ∑ j : Fin q.coefficientCount, q.quotientCoefficient j * q.quotientHash ^ j.val + +theorem quotientHash_eq_encode (q : ParsedInput) : + q.quotientHash = BinaryAlgebra.encode + (fun i => BinaryAlgebra.bitValue (q.polynomial i)) + (fun i => BinaryAlgebra.bitValue (BinaryHash.hashBool q.hashSeed q.data i)) := rfl + +theorem quotientCoefficient_eq_encode (q : ParsedInput) (j : Fin q.coefficientCount) : + q.quotientCoefficient j = BinaryAlgebra.encode + (fun i => BinaryAlgebra.bitValue (q.polynomial i)) + (fun i => BinaryAlgebra.bitValue (q.coefficients j i)) := rfl + +def coefficientBitsEquiv (q : ParsedInput) : + (Fin q.ringDegree → Bool) ≃ q.QuotientRing := + (BinaryAlgebra.bitsEquivF2 (Fin q.ringDegree)).trans + (BinaryAlgebra.coordinates + (fun i => BinaryAlgebra.bitValue (q.polynomial i))).toEquiv.symm + +@[simp] theorem coefficientBitsEquiv_apply (q : ParsedInput) + (v : Fin q.ringDegree → Bool) : + q.coefficientBitsEquiv v = BinaryAlgebra.encode + (fun i => BinaryAlgebra.bitValue (q.polynomial i)) + (fun i => BinaryAlgebra.bitValue (v i)) := rfl + +@[simp] theorem coefficientBitsEquiv_coefficient (q : ParsedInput) + (j : Fin q.coefficientCount) : + q.coefficientBitsEquiv (q.coefficients j) = q.quotientCoefficient j := rfl + +@[simp] theorem quotientRing_card (q : ParsedInput) : + Fintype.card q.QuotientRing = 2 ^ q.ringDegree := + BinaryAlgebra.bitQuotient_card q.polynomial + +theorem quotientEvaluation_eq_mk (q : ParsedInput) : + q.quotientEvaluation = AdjoinRoot.mk q.modulus q.evaluationPolynomial := by + simp only [quotientEvaluation, evaluationPolynomial, quotientCoefficient, quotientHash, + map_sum, map_mul, map_pow] + +theorem representative_quotientEvaluation (q : ParsedInput) : + BinaryAlgebra.quotientRepresentative q.modulus_monic q.quotientEvaluation = + q.evaluationRemainder := by + rw [quotientEvaluation_eq_mk, BinaryAlgebra.quotientRepresentative_mk] + rfl + +theorem degreeZero_quotientEvaluation (q : ParsedInput) : + BinaryAlgebra.degreeZero q.modulus_monic q.quotientEvaluation = + q.evaluationRemainder.coeff 0 := by + rw [BinaryAlgebra.degreeZero_apply, representative_quotientEvaluation] + +theorem quotient_degreeZero_one (q : ParsedInput) (hr : 0 < q.ringDegree) : + BinaryAlgebra.degreeZero q.modulus_monic (1 : q.QuotientRing) = 1 := by + apply BinaryAlgebra.degreeZero_one + change 0 < (BinaryAlgebra.inputPolynomialBits q.polynomial).natDegree + rw [BinaryAlgebra.inputPolynomialBits_natDegree] + exact hr + +theorem evaluate_eq_true_iff_degreeZero (q : ParsedInput) : + q.evaluate = true ↔ + BinaryAlgebra.degreeZero q.modulus_monic q.quotientEvaluation = 0 := by + rw [evaluate_eq_true_iff, degreeZero_quotientEvaluation] + +end ParsedInput + +theorem language_eq_true_iff_quotient (w : List Bool) : + language w = true ↔ InputFits w ∧ + BinaryAlgebra.degreeZero (decodeInput w).modulus_monic + (decodeInput w).quotientEvaluation = 0 := by + rw [language_eq_true_iff, ParsedInput.degreeZero_quotientEvaluation] + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/AlgebraPolynomial.lean b/lean/OAI/Computability/DepthThree/AlgebraPolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c2653d7f45858793d78ec87825aa426f396877e --- /dev/null +++ b/lean/OAI/Computability/DepthThree/AlgebraPolynomial.lean @@ -0,0 +1,137 @@ +import OAI.Computability.DepthThree.AlgebraBits +import Mathlib.Algebra.Polynomial.Monic +import Mathlib.Algebra.Polynomial.Div + +namespace OAI + +noncomputable section + +open scoped BigOperators +open Polynomial + +namespace DepthThreeLowerBound.BinaryAlgebra + +def pack {r : ℕ} (v : Fin r → ZMod 2) : Polynomial (ZMod 2) := + ∑ i : Fin r, Polynomial.monomial i.val (v i) + +theorem degree_pack_lt {r : ℕ} (v : Fin r → ZMod 2) : + (pack v).degree < (r : WithBot ℕ) := by + simpa only [pack, Polynomial.C_mul_X_pow_eq_monomial] using + (Polynomial.degree_sum_fin_lt v) + +@[simp] theorem coeff_pack {r : ℕ} (v : Fin r → ZMod 2) (i : Fin r) : + (pack v).coeff i.val = v i := by + classical + simp only [pack, Polynomial.finsetSum_coeff, Polynomial.coeff_monomial, + Fin.val_eq_val, Finset.sum_ite_eq', ite_eq_left (Finset.mem_univ i)] + +theorem coeff_pack_of_le {r : ℕ} (v : Fin r → ZMod 2) {j : ℕ} (hj : r ≤ j) : + (pack v).coeff j = 0 := + Polynomial.coeff_eq_zero_of_degree_lt + ((degree_pack_lt v).trans_le (WithBot.coe_le_coe.mpr hj)) + +theorem coeff_pack_nat {r : ℕ} (v : Fin r → ZMod 2) (j : ℕ) : + (pack v).coeff j = if h : j < r then v ⟨j, h⟩ else 0 := by + by_cases hj : j < r + · rw [dite_eq_left hj] + exact coeff_pack v ⟨j, hj⟩ + · rw [dite_eq_right hj] + exact coeff_pack_of_le v (Nat.le_of_not_lt hj) + +theorem pack_injective {r : ℕ} : + Function.Injective (pack : (Fin r → ZMod 2) → Polynomial (ZMod 2)) := by + intro v w h + funext i + simpa only [coeff_pack] using congrArg (fun f : Polynomial (ZMod 2) => f.coeff i.val) h + +@[simp] theorem pack_zero {r : ℕ} : pack (0 : Fin r → ZMod 2) = 0 := by + simp [pack] + +@[simp] theorem pack_add {r : ℕ} (v w : Fin r → ZMod 2) : + pack (v + w) = pack v + pack w := by + simp only [pack, Pi.add_apply, map_add, Finset.sum_add_distrib] + +@[simp] theorem pack_smul {r : ℕ} (c : ZMod 2) (v : Fin r → ZMod 2) : + pack (c • v) = c • pack v := by + simp only [pack, Pi.smul_apply, map_smul, Finset.smul_sum] + +theorem pack_coeff_of_degree_lt {r : ℕ} (f : Polynomial (ZMod 2)) + (hf : f.degree < (r : WithBot ℕ)) : + pack (fun i : Fin r => f.coeff i.val) = f := by + unfold pack + calc + (∑ i : Fin r, Polynomial.monomial i.val (f.coeff i.val)) = + f.sum (fun i c => Polynomial.monomial i c) := + Polynomial.sum_fin (fun i c => Polynomial.monomial i c) + (fun i => Polynomial.monomial_zero_right i) hf + _ = f := Polynomial.sum_monomial_eq f + +def inputPolynomial {r : ℕ} (v : Fin r → ZMod 2) : Polynomial (ZMod 2) := + Polynomial.X ^ r + pack v + +theorem inputPolynomial_monic {r : ℕ} (v : Fin r → ZMod 2) : + (inputPolynomial v).Monic := + Polynomial.monic_X_pow_add (degree_pack_lt v) + +@[simp] theorem inputPolynomial_degree {r : ℕ} (v : Fin r → ZMod 2) : + (inputPolynomial v).degree = (r : WithBot ℕ) := by + have h : (pack v).degree < (Polynomial.X ^ r : Polynomial (ZMod 2)).degree := by + simpa only [Polynomial.degree_X_pow] using degree_pack_lt v + simpa only [inputPolynomial, Polynomial.degree_X_pow] using + Polynomial.degree_add_eq_left_of_degree_lt h + +@[simp] theorem inputPolynomial_natDegree {r : ℕ} (v : Fin r → ZMod 2) : + (inputPolynomial v).natDegree = r := by + have h : (pack v).degree < (Polynomial.X ^ r : Polynomial (ZMod 2)).degree := by + simpa only [Polynomial.degree_X_pow] using degree_pack_lt v + simpa only [inputPolynomial, Polynomial.natDegree_X_pow] using + Polynomial.natDegree_add_eq_left_of_degree_lt h + +theorem inputPolynomial_ne_zero {r : ℕ} (v : Fin r → ZMod 2) : + inputPolynomial v ≠ 0 := + (inputPolynomial_monic v).ne_zero + +@[simp] theorem inputPolynomial_coeff_lt {r : ℕ} (v : Fin r → ZMod 2) (i : Fin r) : + (inputPolynomial v).coeff i.val = v i := by + rw [inputPolynomial, Polynomial.coeff_add, Polynomial.coeff_X_pow, + ite_eq_right (Nat.ne_of_lt i.is_lt), zero_add, coeff_pack] + +@[simp] theorem inputPolynomial_coeff_leading {r : ℕ} (v : Fin r → ZMod 2) : + (inputPolynomial v).coeff r = 1 := by + rw [inputPolynomial, Polynomial.coeff_add, Polynomial.coeff_X_pow_self, + coeff_pack_of_le v (Nat.le_refl r), add_zero] + +theorem inputPolynomial_coeff_of_gt {r : ℕ} (v : Fin r → ZMod 2) + {j : ℕ} (hj : r < j) : (inputPolynomial v).coeff j = 0 := by + apply Polynomial.coeff_eq_zero_of_degree_lt + rw [inputPolynomial_degree] + exact WithBot.coe_lt_coe.mpr hj + +def inputPolynomialBits {r : ℕ} (p : Fin r → Bool) : Polynomial (ZMod 2) := + inputPolynomial (fun i => bitValue (p i)) + +theorem inputPolynomialBits_monic {r : ℕ} (p : Fin r → Bool) : + (inputPolynomialBits p).Monic := + inputPolynomial_monic _ + +@[simp] theorem inputPolynomialBits_degree {r : ℕ} (p : Fin r → Bool) : + (inputPolynomialBits p).degree = (r : WithBot ℕ) := + inputPolynomial_degree _ + +@[simp] theorem inputPolynomialBits_natDegree {r : ℕ} (p : Fin r → Bool) : + (inputPolynomialBits p).natDegree = r := + inputPolynomial_natDegree _ + +@[simp] theorem inputPolynomialBits_coeff_lt {r : ℕ} (p : Fin r → Bool) (i : Fin r) : + (inputPolynomialBits p).coeff i.val = bitValue (p i) := + inputPolynomial_coeff_lt _ _ + +@[simp] theorem inputPolynomialBits_coeff_leading {r : ℕ} (p : Fin r → Bool) : + (inputPolynomialBits p).coeff r = 1 := + inputPolynomial_coeff_leading _ + +end DepthThreeLowerBound.BinaryAlgebra + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/AlgebraQuotient.lean b/lean/OAI/Computability/DepthThree/AlgebraQuotient.lean new file mode 100644 index 0000000000000000000000000000000000000000..9beefb45c24fb5a05a20aec3b9bff1a673168d91 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/AlgebraQuotient.lean @@ -0,0 +1,213 @@ +import OAI.Computability.DepthThree.AlgebraPolynomial +import Mathlib.RingTheory.AdjoinRoot + +namespace OAI + +noncomputable section + +open scoped BigOperators +open Polynomial + +namespace DepthThreeLowerBound.BinaryAlgebra + +def quotientRepresentative {P : Polynomial F2} (hP : P.Monic) : + AdjoinRoot P →ₗ[F2] Polynomial F2 := + AdjoinRoot.modByMonicHom hP + +@[simp] theorem quotientRepresentative_mk {P : Polynomial F2} (hP : P.Monic) + (f : Polynomial F2) : + quotientRepresentative hP (AdjoinRoot.mk P f) = f %ₘ P := + AdjoinRoot.modByMonicHom_mk hP f + +theorem mk_quotientRepresentative {P : Polynomial F2} (hP : P.Monic) + (z : AdjoinRoot P) : + AdjoinRoot.mk P (quotientRepresentative hP z) = z := + AdjoinRoot.mk_leftInverse hP z + +theorem degree_quotientRepresentative_lt {P : Polynomial F2} (hP : P.Monic) + (z : AdjoinRoot P) : + (quotientRepresentative hP z).degree < P.degree := by + refine AdjoinRoot.induction_on P z ?_ + intro f + rw [quotientRepresentative_mk] + exact Polynomial.degree_modByMonic_lt f hP + +theorem quotientRepresentative_one {P : Polynomial F2} (hP : P.Monic) + (hdeg : 0 < P.natDegree) : + quotientRepresentative hP (1 : AdjoinRoot P) = 1 := by + have h : (1 : Polynomial F2).degree < P.degree := by + rw [Polynomial.degree_one, Polynomial.degree_eq_natDegree hP.ne_zero] + exact WithBot.coe_lt_coe.mpr hdeg + calc + quotientRepresentative hP (1 : AdjoinRoot P) = + quotientRepresentative hP (AdjoinRoot.mk P 1) := by rw [(AdjoinRoot.mk P).map_one] + _ = (1 : Polynomial F2) %ₘ P := quotientRepresentative_mk hP 1 + _ = 1 := (Polynomial.modByMonic_eq_self_iff hP).mpr h + +abbrev InputQuotient {r : ℕ} (p : Fin r → F2) := + AdjoinRoot (inputPolynomial p) + +abbrev BitQuotient {r : ℕ} (p : Fin r → Bool) := + InputQuotient (fun i => bitValue (p i)) + +theorem pack_mod_inputPolynomial {r : ℕ} (p a : Fin r → F2) : + pack a %ₘ inputPolynomial p = pack a := by + apply (Polynomial.modByMonic_eq_self_iff (inputPolynomial_monic p)).mpr + rw [inputPolynomial_degree] + exact degree_pack_lt a + +def encode {r : ℕ} (p : Fin r → F2) (a : Fin r → F2) : InputQuotient p := + AdjoinRoot.mk (inputPolynomial p) (pack a) + +def coordinates {r : ℕ} (p : Fin r → F2) : + InputQuotient p ≃ₗ[F2] (Fin r → F2) where + toFun z i := (quotientRepresentative (inputPolynomial_monic p) z).coeff i.val + invFun := encode p + map_add' x y := by + funext i + simp only [map_add, Polynomial.coeff_add, Pi.add_apply] + map_smul' c x := by + funext i + simp only [map_smul, Polynomial.coeff_smul, Pi.smul_apply, RingHom.id_apply] + left_inv z := by + have hd : (quotientRepresentative (inputPolynomial_monic p) z).degree < + (r : WithBot ℕ) := by + simpa only [inputPolynomial_degree] using + degree_quotientRepresentative_lt (inputPolynomial_monic p) z + change AdjoinRoot.mk (inputPolynomial p) + (pack (fun i : Fin r => + (quotientRepresentative (inputPolynomial_monic p) z).coeff i.val)) = z + rw [pack_coeff_of_degree_lt _ hd] + exact mk_quotientRepresentative (inputPolynomial_monic p) z + right_inv a := by + funext i + change (quotientRepresentative (inputPolynomial_monic p) + (AdjoinRoot.mk (inputPolynomial p) (pack a))).coeff i.val = a i + rw [quotientRepresentative_mk, pack_mod_inputPolynomial, coeff_pack] + +@[simp] theorem coordinates_apply {r : ℕ} (p : Fin r → F2) + (z : InputQuotient p) (i : Fin r) : + coordinates p z i = + (quotientRepresentative (inputPolynomial_monic p) z).coeff i.val := rfl + +@[simp] theorem coordinates_symm_apply {r : ℕ} (p a : Fin r → F2) : + (coordinates p).symm a = encode p a := rfl + +@[simp] theorem coordinates_encode {r : ℕ} (p a : Fin r → F2) : + coordinates p (encode p a) = a := + (coordinates p).apply_symm_apply a + +@[simp] theorem encode_coordinates {r : ℕ} (p : Fin r → F2) (z : InputQuotient p) : + encode p (coordinates p z) = z := + (coordinates p).symm_apply_apply z + +theorem encode_injective {r : ℕ} (p : Fin r → F2) : Function.Injective (encode p) := + (coordinates p).symm.injective + +theorem encode_surjective {r : ℕ} (p : Fin r → F2) : Function.Surjective (encode p) := + (coordinates p).symm.surjective + +instance inputQuotientFintype {r : ℕ} (p : Fin r → F2) : Fintype (InputQuotient p) := + Fintype.ofEquiv (Fin r → F2) (coordinates p).toEquiv.symm + +@[simp] theorem inputQuotient_card {r : ℕ} (p : Fin r → F2) : + Fintype.card (InputQuotient p) = 2 ^ r := by + rw [Fintype.card_congr (coordinates p).toEquiv, Fintype.card_fun, + ZMod.card, Fintype.card_fin] + +@[simp] theorem bitQuotient_card {r : ℕ} (p : Fin r → Bool) : + Fintype.card (BitQuotient p) = 2 ^ r := + inputQuotient_card _ + +@[simp] theorem coordinates_mk {r : ℕ} (p : Fin r → F2) + (f : Polynomial F2) (i : Fin r) : + coordinates p (AdjoinRoot.mk (inputPolynomial p) f) i = + (f %ₘ inputPolynomial p).coeff i.val := by + rw [coordinates_apply, quotientRepresentative_mk] + +@[simp] theorem encode_zero {r : ℕ} (p : Fin r → F2) : + encode p (0 : Fin r → F2) = 0 := by + rw [encode, pack_zero, map_zero] + +@[simp] theorem encode_add {r : ℕ} (p a b : Fin r → F2) : + encode p (a + b) = encode p a + encode p b := by + simp only [encode, pack_add, map_add] + +@[simp] theorem encode_smul {r : ℕ} (p : Fin r → F2) (c : F2) (a : Fin r → F2) : + encode p (c • a) = c • encode p a := by + change AdjoinRoot.mk (inputPolynomial p) (pack (c • a)) = + c • AdjoinRoot.mk (inputPolynomial p) (pack a) + rw [pack_smul, AdjoinRoot.smul_mk] + +theorem coordinates_encode_mul {r : ℕ} (p a b : Fin r → F2) (i : Fin r) : + coordinates p (encode p a * encode p b) i = + ((pack a * pack b) %ₘ inputPolynomial p).coeff i.val := by + change coordinates p + (AdjoinRoot.mk (inputPolynomial p) (pack a) * + AdjoinRoot.mk (inputPolynomial p) (pack b)) i = _ + rw [← map_mul, coordinates_mk] + +theorem encode_mul {r : ℕ} (p a b : Fin r → F2) : + encode p (fun i => ((pack a * pack b) %ₘ inputPolynomial p).coeff i.val) = + encode p a * encode p b := by + apply (coordinates p).injective + rw [coordinates_encode] + funext i + exact (coordinates_encode_mul p a b i).symm + +theorem coordinates_mul {r : ℕ} (p : Fin r → F2) (x y : InputQuotient p) (i : Fin r) : + coordinates p (x * y) i = + ((pack (coordinates p x) * pack (coordinates p y)) %ₘ inputPolynomial p).coeff i.val := by + simpa only [encode_coordinates] using + coordinates_encode_mul p (coordinates p x) (coordinates p y) i + +theorem coordinates_one {r : ℕ} (p : Fin r → F2) (hr : 0 < r) (i : Fin r) : + coordinates p (1 : InputQuotient p) i = if i.val = 0 then 1 else 0 := by + rw [coordinates_apply, quotientRepresentative_one (inputPolynomial_monic p) + (by simpa only [inputPolynomial_natDegree] using hr), Polynomial.coeff_one] + +def degreeZero {P : Polynomial F2} (hP : P.Monic) : AdjoinRoot P →ₗ[F2] F2 := + (Polynomial.lcoeff F2 0).comp (quotientRepresentative hP) + +@[simp] theorem degreeZero_apply {P : Polynomial F2} (hP : P.Monic) + (z : AdjoinRoot P) : + degreeZero hP z = (quotientRepresentative hP z).coeff 0 := rfl + +@[simp] theorem degreeZero_mk {P : Polynomial F2} (hP : P.Monic) (f : Polynomial F2) : + degreeZero hP (AdjoinRoot.mk P f) = (f %ₘ P).coeff 0 := by + rw [degreeZero_apply, quotientRepresentative_mk] + +theorem degreeZero_one {P : Polynomial F2} (hP : P.Monic) (hdeg : 0 < P.natDegree) : + degreeZero hP (1 : AdjoinRoot P) = 1 := by + rw [degreeZero_apply, quotientRepresentative_one hP hdeg, Polynomial.coeff_one_zero] + +theorem degreeZero_surjective {P : Polynomial F2} (hP : P.Monic) + (hdeg : 0 < P.natDegree) : Function.Surjective (degreeZero hP) := by + intro c + refine ⟨c • (1 : AdjoinRoot P), ?_⟩ + rw [map_smul, degreeZero_one hP hdeg, smul_eq_mul, mul_one] + +theorem degreeZero_encode {r : ℕ} (p : Fin r → F2) (hr : 0 < r) (a : Fin r → F2) : + degreeZero (inputPolynomial_monic p) (encode p a) = a ⟨0, hr⟩ := by + rw [encode, degreeZero_mk, pack_mod_inputPolynomial] + exact coeff_pack a ⟨0, hr⟩ + +theorem degreeZero_coordinates {r : ℕ} (p : Fin r → F2) (hr : 0 < r) + (z : InputQuotient p) : + degreeZero (inputPolynomial_monic p) z = coordinates p z ⟨0, hr⟩ := rfl + +theorem degreeZero_sum_encode_pow {r t : ℕ} (p a : Fin r → F2) + (beta : Fin t → Fin r → F2) : + degreeZero (inputPolynomial_monic p) + (∑ j : Fin t, encode p (beta j) * (encode p a) ^ j.val) = + ((∑ j : Fin t, pack (beta j) * (pack a) ^ j.val) %ₘ inputPolynomial p).coeff 0 := by + rw [← degreeZero_mk (inputPolynomial_monic p) + (∑ j : Fin t, pack (beta j) * (pack a) ^ j.val)] + congr 1 + simp only [encode, map_sum, map_mul, map_pow] + +end DepthThreeLowerBound.BinaryAlgebra + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/AsymptoticBounds.lean b/lean/OAI/Computability/DepthThree/AsymptoticBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d3c9672a2569b183bcc649f17fbcc6b9c695726 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/AsymptoticBounds.lean @@ -0,0 +1,146 @@ +import Mathlib.Algebra.BigOperators.Intervals +import Mathlib.Analysis.SpecificLimits.Normed +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Analysis.Real.Sqrt +import Mathlib.Topology.Algebra.InfiniteSum.Order +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +namespace OAI + +noncomputable section + +open Filter +open scoped BigOperators Topology + +namespace DepthThreeLowerBound + +theorem exists_factorial_tail_width (Q : ℝ) (hQ : 0 ≤ Q) : + ∃ b : ℕ, 1 ≤ b ∧ ∀ k : ℕ, + (∑ ℓ ∈ Finset.Ico (b + 1) (k + 1), Q ^ ℓ / (ℓ.factorial : ℝ)) ≤ 1 / 2 := by + let a : ℕ → ℝ := fun ℓ => Q ^ ℓ / (ℓ.factorial : ℝ) + have ha : ∀ ℓ, 0 ≤ a ℓ := fun ℓ => + div_nonneg (pow_nonneg hQ ℓ) (Nat.cast_nonneg _) + have hs : Summable a := Real.summable_pow_div_factorial Q + have ht : Tendsto (fun n : ℕ => (∑' ℓ, a ℓ) - ∑ ℓ ∈ Finset.range n, a ℓ) + atTop (𝓝 (0 : ℝ)) := by + have hc : Tendsto (fun _ : ℕ => ∑' ℓ, a ℓ) atTop (𝓝 (∑' ℓ, a ℓ)) := + tendsto_const_nhds + simpa only [sub_self] using hc.sub hs.hasSum.tendsto_sum_nat + have he := ht.eventually_lt_const (by norm_num : (0 : ℝ) < 1 / 2) + obtain ⟨N, hN⟩ := eventually_atTop.mp he + refine ⟨max 1 N, le_max_left _ _, ?_⟩ + intro k + change (∑ ℓ ∈ Finset.Ico (max 1 N + 1) (k + 1), a ℓ) ≤ 1 / 2 + by_cases hk : max 1 N + 1 ≤ k + 1 + · rw [Finset.sum_Ico_eq_sub a hk] + have hupper : (∑ ℓ ∈ Finset.range (k + 1), a ℓ) ≤ ∑' ℓ, a ℓ := + hs.sum_le_tsum _ (fun ℓ _ => ha ℓ) + have htail := hN (max 1 N + 1) + ((le_max_right 1 N).trans (Nat.le_succ _)) + exact (sub_le_sub_right hupper _).trans htail.le + · rw [Finset.Ico_eq_empty_of_le (Nat.le_of_lt (Nat.lt_of_not_ge hk)), Finset.sum_empty] + norm_num + +theorem div_five_ge (D n : ℕ) (h : 5 * D ≤ n) : D ≤ n / 5 := by + omega + +theorem input_div_five_scale (n : ℕ) (hn : 5 ≤ n) : + 0 < n / 5 ∧ n ≤ 9 * (n / 5) := by + omega + +theorem sqrt_input_div_five_le (n : ℕ) (hn : 5 ≤ n) : + Real.sqrt (n : ℝ) ≤ 3 * Real.sqrt ((n / 5 : ℕ) : ℝ) := by + have hscale : (n : ℝ) ≤ 9 * ((n / 5 : ℕ) : ℝ) := by + exact_mod_cast (input_div_five_scale n hn).2 + have hsquare := Real.sq_sqrt (Nat.cast_nonneg (n / 5) : (0 : ℝ) ≤ (n / 5 : ℕ)) + apply Real.sqrt_le_iff.mpr + constructor + · exact mul_nonneg (by norm_num) (Real.sqrt_nonneg _) + · nlinarith + +theorem circuit_size_scale (A : ℝ) (hA : 0 ≤ A) (n : ℕ) (hn : 5 ≤ n) : + (2 : ℝ) ^ (A * Real.sqrt (n : ℝ)) ≤ + (2 : ℝ) ^ ((3 * A) * Real.sqrt ((n / 5 : ℕ) : ℝ)) := by + apply Real.rpow_le_rpow_of_exponent_le (by norm_num) + calc + A * Real.sqrt (n : ℝ) ≤ A * (3 * Real.sqrt ((n / 5 : ℕ) : ℝ)) := + mul_le_mul_of_nonneg_left (sqrt_input_div_five_le n hn) hA + _ = (3 * A) * Real.sqrt ((n / 5 : ℕ) : ℝ) := by ring + +theorem final_error_exponents (s d S : ℝ) (hS0 : 0 ≤ S) + (hS : S ≤ (2 : ℝ) ^ (s * Real.sqrt d)) (k : ℕ) + (hk : 3 * (s + 1) * Real.sqrt d ≤ (k : ℝ)) : + 6 * S * (2 : ℝ) ^ (-(64 * (s + 1) * Real.sqrt d) / 16) + + S ^ 2 * (2 : ℝ) ^ (-(k : ℝ)) ≤ + 6 * (2 : ℝ) ^ (-((3 * s + 4) * Real.sqrt d)) + + (2 : ℝ) ^ (-((s + 3) * Real.sqrt d)) := by + have hfirst : 6 * S * (2 : ℝ) ^ (-(64 * (s + 1) * Real.sqrt d) / 16) ≤ + 6 * (2 : ℝ) ^ (-((3 * s + 4) * Real.sqrt d)) := by + calc + 6 * S * (2 : ℝ) ^ (-(64 * (s + 1) * Real.sqrt d) / 16) ≤ + 6 * (2 : ℝ) ^ (s * Real.sqrt d) * + (2 : ℝ) ^ (-(64 * (s + 1) * Real.sqrt d) / 16) := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hS (by norm_num)) + (Real.rpow_nonneg (by norm_num) _) + _ = 6 * ((2 : ℝ) ^ (s * Real.sqrt d) * + (2 : ℝ) ^ (-(64 * (s + 1) * Real.sqrt d) / 16)) := by ring + _ = 6 * (2 : ℝ) ^ (s * Real.sqrt d - (64 * (s + 1) * Real.sqrt d) / 16) := by + rw [← Real.rpow_add (by norm_num : (0 : ℝ) < 2)] + congr 2 ; ring + _ = 6 * (2 : ℝ) ^ (-((3 * s + 4) * Real.sqrt d)) := by + congr 2 ; ring + have hSsq : S ^ 2 ≤ ((2 : ℝ) ^ (s * Real.sqrt d)) ^ 2 := by + simpa only [pow_two] using + mul_le_mul hS hS hS0 (Real.rpow_nonneg (by norm_num) _) + have hsecond : S ^ 2 * (2 : ℝ) ^ (-(k : ℝ)) ≤ + (2 : ℝ) ^ (-((s + 3) * Real.sqrt d)) := by + calc + S ^ 2 * (2 : ℝ) ^ (-(k : ℝ)) ≤ + ((2 : ℝ) ^ (s * Real.sqrt d)) ^ 2 * (2 : ℝ) ^ (-(k : ℝ)) := + mul_le_mul_of_nonneg_right hSsq (Real.rpow_nonneg (by norm_num) _) + _ = (2 : ℝ) ^ ((s * Real.sqrt d) * 2 + -(k : ℝ)) := by + rw [← Real.rpow_mul_natCast (by norm_num : (0 : ℝ) ≤ 2) (s * Real.sqrt d) 2] + rw [← Real.rpow_add (by norm_num : (0 : ℝ) < 2)] ; norm_num + _ ≤ (2 : ℝ) ^ (-((s + 3) * Real.sqrt d)) := by + apply Real.rpow_le_rpow_of_exponent_le (by norm_num) + nlinarith [hk] + exact add_le_add hfirst hsecond + +theorem final_error_le (s d S : ℝ) (hs : 0 ≤ s) (hd : 4 ≤ d) (hS0 : 0 ≤ S) + (hS : S ≤ (2 : ℝ) ^ (s * Real.sqrt d)) (k : ℕ) + (hk : 3 * (s + 1) * Real.sqrt d ≤ (k : ℝ)) : + 6 * S * (2 : ℝ) ^ (-(64 * (s + 1) * Real.sqrt d) / 16) + + S ^ 2 * (2 : ℝ) ^ (-(k : ℝ)) ≤ 5 / 128 := by + have hroot : (2 : ℝ) ≤ Real.sqrt d := Real.le_sqrt_of_sq_le (by norm_num; exact hd) + have hprod : 0 ≤ s * Real.sqrt d := mul_nonneg hs (Real.sqrt_nonneg d) + have hfirst : (2 : ℝ) ^ (-((3 * s + 4) * Real.sqrt d)) ≤ (2 : ℝ) ^ (-8 : ℝ) := by + apply Real.rpow_le_rpow_of_exponent_le (by norm_num) + nlinarith + have hsecond : (2 : ℝ) ^ (-((s + 3) * Real.sqrt d)) ≤ (2 : ℝ) ^ (-6 : ℝ) := by + apply Real.rpow_le_rpow_of_exponent_le (by norm_num) + nlinarith + calc + _ ≤ 6 * (2 : ℝ) ^ (-((3 * s + 4) * Real.sqrt d)) + + (2 : ℝ) ^ (-((s + 3) * Real.sqrt d)) := final_error_exponents s d S hS0 hS k hk + _ ≤ 6 * (2 : ℝ) ^ (-8 : ℝ) + (2 : ℝ) ^ (-6 : ℝ) := + add_le_add (mul_le_mul_of_nonneg_left hfirst (by norm_num)) hsecond + _ = 5 / 128 := by norm_num + +theorem correlation_error_le (s d : ℝ) (hs : 0 ≤ s) (hd : 1 ≤ d) : + 6 * (2 : ℝ) ^ (-(4 * (s + 1) * Real.sqrt d)) ≤ 3 / 8 := by + have hroot : (1 : ℝ) ≤ Real.sqrt d := Real.one_le_sqrt.mpr hd + have hprod : 0 ≤ s * Real.sqrt d := mul_nonneg hs (Real.sqrt_nonneg d) + have hp : (2 : ℝ) ^ (-(4 * (s + 1) * Real.sqrt d)) ≤ (2 : ℝ) ^ (-4 : ℝ) := by + apply Real.rpow_le_rpow_of_exponent_le (by norm_num) + nlinarith + calc + _ ≤ 6 * (2 : ℝ) ^ (-4 : ℝ) := mul_le_mul_of_nonneg_left hp (by norm_num) + _ = 3 / 8 := by norm_num + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/Circuit.lean b/lean/OAI/Computability/DepthThree/Circuit.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f7dcc47ac3d1da7bae07589c83ae93cdf9f9c98 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/Circuit.lean @@ -0,0 +1,116 @@ +import OAI.Computability.DepthThree.Core + +namespace OAI + +universe uDepth1 uDepth2 + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} {W : Type uDepth2} + +namespace GateInput + +def subst (s : V → Sum W Bool) : GateInput V → GateInput W + | .inl (v, b) => match s v with + | .inl w => .inl (w, b) + | .inr c => .inr (decide (c = b)) + | .inr b => .inr b + +def assignment (s : V → Sum W Bool) (x : Cube W) : Cube V := + fun v => match s v with + | .inl w => x w + | .inr b => b + +@[simp] theorem eval_subst (s : V → Sum W Bool) (l : GateInput V) (x : Cube W) : + (subst s l).eval x = l.eval (assignment s x) := by + cases l with + | inl l => + rcases l with ⟨v, b⟩ + cases h : s v <;> simp [subst, eval, assignment, Literal.eval, h] + | inr b => rfl + +end GateInput + +namespace RawClause + +@[simp] theorem eval_eq_true (C : RawClause V) (x : Cube V) : + C.eval x = true ↔ ∃ l ∈ C, l.eval x = true := by + classical + simp [eval] + +@[simp] theorem eval_map_subst (s : V → Sum W Bool) (C : RawClause V) + (x : Cube W) : RawClause.eval (C.map (GateInput.subst s)) x = + C.eval (GateInput.assignment s x) := by + classical + apply Bool.eq_iff_iff.mpr + rw [eval_eq_true, eval_eq_true] + constructor + · rintro ⟨a, ha, hx⟩ + obtain ⟨l, hl, rfl⟩ := List.mem_map.mp ha + exact ⟨l, hl, by simpa only [GateInput.eval_subst] using hx⟩ + · rintro ⟨l, hl, hx⟩ + refine ⟨GateInput.subst s l, List.mem_map.mpr ⟨l, hl, rfl⟩, ?_⟩ + simpa only [GateInput.eval_subst] using hx + +end RawClause + +namespace Circuit3 + +@[simp] theorem middleEval_eq_true (C : Circuit3 V) (j : Fin C.middleCount) + (x : Cube V) : C.middleEval j x = true ↔ + ∀ i ∈ C.middle j, (C.bottom i).eval x = true := by + classical + simp [middleEval] + +@[simp] theorem eval_eq_true (C : Circuit3 V) (x : Cube V) : + C.eval x = true ↔ ∃ j ∈ C.top, C.middleEval j x = true := by + classical + simp [eval] + +theorem bottomCount_le_gateCount (C : Circuit3 V) : C.bottomCount ≤ C.gateCount := + (Nat.le_add_right C.bottomCount C.middleCount).trans (Nat.le_succ _) + +theorem middleCount_le_gateCount (C : Circuit3 V) : C.middleCount ≤ C.gateCount := + (Nat.le_add_left C.middleCount C.bottomCount).trans (Nat.le_succ _) + +theorem middle_card_le_gateCount (C : Circuit3 V) (j : Fin C.middleCount) : + (C.middle j).card ≤ C.gateCount := by + exact (Finset.card_le_univ _).trans (by simpa using C.bottomCount_le_gateCount) + +theorem top_card_le_gateCount (C : Circuit3 V) : C.top.card ≤ C.gateCount := by + exact (Finset.card_le_univ _).trans (by simpa using C.middleCount_le_gateCount) + +def subst (C : Circuit3 V) (s : V → Sum W Bool) : Circuit3 W where + bottomCount := C.bottomCount + middleCount := C.middleCount + bottom i := (C.bottom i).map (GateInput.subst s) + middle := C.middle + top := C.top + +@[simp] theorem gateCount_subst (C : Circuit3 V) (s : V → Sum W Bool) : + (C.subst s).gateCount = C.gateCount := rfl + +@[simp] theorem middleEval_subst (C : Circuit3 V) (s : V → Sum W Bool) + (j : Fin C.middleCount) (x : Cube W) : + (C.subst s).middleEval j x = C.middleEval j (GateInput.assignment s x) := by + classical + apply Bool.eq_iff_iff.mpr + simp only [middleEval_eq_true, subst, RawClause.eval_map_subst] + +@[simp] theorem eval_subst (C : Circuit3 V) (s : V → Sum W Bool) (x : Cube W) : + (C.subst s).eval x = C.eval (GateInput.assignment s x) := by + classical + apply Bool.eq_iff_iff.mpr + simp only [eval_eq_true, middleEval_eq_true, subst, RawClause.eval_map_subst] + +theorem computes_subst (C : Circuit3 V) {f : Cube V → Bool} (h : C.Computes f) + (s : V → Sum W Bool) : + (C.subst s).Computes (fun x => f (GateInput.assignment s x)) := by + intro x + rw [eval_subst, h] + +end Circuit3 + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/CircuitDeletion.lean b/lean/OAI/Computability/DepthThree/CircuitDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..da82363f4ca34b9e6811ab17ffb52b5851b310f5 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/CircuitDeletion.lean @@ -0,0 +1,156 @@ +import OAI.Computability.DepthThree.CylinderProbability +import OAI.Computability.DepthThree.RestrictionNormalization +import Mathlib.Tactic.Ring + +namespace OAI + +universe uDepth1 + +noncomputable section + +attribute [local instance] Classical.propDecidable + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} + +namespace Clause + +theorem violation_probability [Fintype V] (C : Clause V) (hC : C.Normalized) : + finiteAvg (fun x : Cube V => indicator (C.violation x)) = + ((2 : ℝ) ^ C.width)⁻¹ := by + have hpoint (x : Cube V) : + indicator (C.violation x) = + if ∀ v ∈ C.scope, x v = C.forbiddenValue v then (1 : ℝ) else 0 := by + simp only [← eval_eq_false_iff_forbidden hC x] + cases hx : C.eval x <;> simp [violation, indicator, hx] + calc + _ = finiteAvg (fun x : Cube V => + if ∀ v ∈ C.scope, x v = C.forbiddenValue v then (1 : ℝ) else 0) := + finiteAvg_congr hpoint + _ = ((2 : ℝ) ^ C.width)⁻¹ := by + simpa only [width] using finiteAvg_eq_pattern C.scope C.forbiddenValue + +theorem false_probability [Fintype V] (C : Clause V) (hC : C.Normalized) : + finiteAvg (fun x : Cube V => 1 - indicator (C.eval x)) = + ((2 : ℝ) ^ C.width)⁻¹ := by + refine (finiteAvg_congr fun x => ?_).trans (violation_probability C hC) + cases hx : C.eval x <;> simp [violation, indicator, hx] + +end Clause + +namespace CNF + +def deleteWide (H : CNF V) (k : ℕ) : CNF V := + H.filter fun C => decide (C.width ≤ k) + +@[simp] theorem mem_deleteWide {H : CNF V} {k : ℕ} {C : Clause V} : + C ∈ H.deleteWide k ↔ C ∈ H ∧ C.width ≤ k := by + simp [deleteWide] + +@[simp] theorem deleteWide_nil (k : ℕ) : + CNF.deleteWide ([] : CNF V) k = [] := by + simp [deleteWide] + +@[simp] theorem deleteWide_cons (C : Clause V) (H : CNF V) (k : ℕ) : + CNF.deleteWide (C :: H) k = + if C.width ≤ k then C :: H.deleteWide k else H.deleteWide k := by + by_cases hk : C.width ≤ k <;> simp [deleteWide, hk] + +theorem deleteWide_widthAtMost (H : CNF V) (k : ℕ) : + (H.deleteWide k).WidthAtMost k := by + intro C hC + exact (mem_deleteWide.mp hC).2 + +theorem deleteWide_normalized (H : CNF V) (hH : H.Normalized) (k : ℕ) : + (H.deleteWide k).Normalized := by + intro C hC + exact hH C (mem_deleteWide.mp hC).1 + +theorem deleteWide_length_le (H : CNF V) (k : ℕ) : + (H.deleteWide k).length ≤ H.length := by + induction H with + | nil => simp + | cons C H ih => + rw [deleteWide_cons] + by_cases hk : C.width ≤ k + · simpa only [ite_eq_left hk, List.length_cons] using Nat.succ_le_succ ih + · simpa only [ite_eq_right hk, List.length_cons] using ih.trans (Nat.le_succ H.length) + +theorem eval_deleteWide_of_eval (H : CNF V) (k : ℕ) {x : Cube V} + (hx : H.eval x = true) : (H.deleteWide k).eval x = true := by + apply eval_antitone (J := H) ?_ hx + intro C hC + exact (mem_deleteWide.mp hC).1 + +theorem indicator_eval_le_deleteWide (H : CNF V) (k : ℕ) (x : Cube V) : + indicator (H.eval x) ≤ indicator ((H.deleteWide k).eval x) := by + cases hx : H.eval x + · simpa only [hx, indicator_false] using indicator_nonneg ((H.deleteWide k).eval x) + · have hd := eval_deleteWide_of_eval H k hx + simp [hd] + +theorem deletion_error_cons_le (C : Clause V) (H : CNF V) (k : ℕ) (x : Cube V) : + indicator (CNF.eval (CNF.deleteWide (C :: H) k) x) - indicator (CNF.eval (C :: H) x) ≤ + (indicator ((H.deleteWide k).eval x) - indicator (H.eval x)) + + if C.width ≤ k then 0 else 1 - indicator (C.eval x) := by + have hm := indicator_eval_le_deleteWide H k x + by_cases hk : C.width ≤ k + · cases hc : C.eval x <;> cases hh : H.eval x <;> + cases hd : (H.deleteWide k).eval x <;> + norm_num [deleteWide_cons, hk, eval_cons, hc, hh, hd, indicator] at hm <;> + norm_num [deleteWide_cons, hk, eval_cons, hc, hh, hd, indicator] + · cases hc : C.eval x <;> cases hh : H.eval x <;> + cases hd : (H.deleteWide k).eval x <;> + norm_num [deleteWide_cons, hk, eval_cons, hc, hh, hd, indicator] at hm <;> + norm_num [deleteWide_cons, hk, eval_cons, hc, hh, hd, indicator] + +theorem deletion_error_bound [Fintype V] (H : CNF V) (hH : H.Normalized) (k : ℕ) : + finiteAvg (fun x : Cube V => + indicator ((H.deleteWide k).eval x) - indicator (H.eval x)) ≤ + (H.length : ℝ) * ((2 : ℝ) ^ k)⁻¹ := by + revert hH + induction H with + | nil => + intro _ + simp + | cons C H ih => + intro hH + have hC : C.Normalized := hH C (by simp) + have htail : CNF.Normalized H := fun D hD => hH D (by simp [hD]) + have hclause : finiteAvg (fun x : Cube V => + if C.width ≤ k then 0 else 1 - indicator (C.eval x)) ≤ + ((2 : ℝ) ^ k)⁻¹ := by + by_cases hk : C.width ≤ k + · simp only [ite_eq_left hk, finiteAvg_zero] + exact inv_nonneg.mpr (pow_nonneg (by norm_num) k) + · simp only [ite_eq_right hk] + rw [Clause.false_probability C hC] + have hkw : k ≤ C.width := Nat.le_of_lt (Nat.lt_of_not_ge hk) + have hpow : (2 : ℝ) ^ k ≤ (2 : ℝ) ^ C.width := + pow_le_pow_right₀ (by norm_num) hkw + simpa only [one_div] using + one_div_le_one_div_of_le (pow_pos (by norm_num : (0 : ℝ) < 2) k) hpow + calc + _ ≤ finiteAvg (fun x : Cube V => + (indicator (CNF.eval (CNF.deleteWide H k) x) - indicator (CNF.eval H x)) + + if C.width ≤ k then 0 else 1 - indicator (C.eval x)) := + finiteAvg_mono (deletion_error_cons_le C H k) + _ = finiteAvg (fun x : Cube V => + indicator (CNF.eval (CNF.deleteWide H k) x) - indicator (CNF.eval H x)) + + finiteAvg (fun x : Cube V => + if C.width ≤ k then 0 else 1 - indicator (C.eval x)) := + finiteAvg_add _ _ + _ ≤ (H.length : ℝ) * ((2 : ℝ) ^ k)⁻¹ + ((2 : ℝ) ^ k)⁻¹ := + add_le_add (ih htail) hclause + _ = ((C :: H).length : ℝ) * ((2 : ℝ) ^ k)⁻¹ := by + simp only [List.length_cons, Nat.cast_add, Nat.cast_one] + ring + +end CNF + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/CircuitDensity.lean b/lean/OAI/Computability/DepthThree/CircuitDensity.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6b476ad12384fbe71cb3dfd039f91fd9866fc52 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/CircuitDensity.lean @@ -0,0 +1,44 @@ +import OAI.Computability.DepthThree.FiniteProbability +import Mathlib.Tactic.Linarith + +namespace OAI + +universe uDepth1 + +open scoped Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} [Fintype V] + +theorem sign_eq_two_indicator_sub_one (b : Bool) : + sign b = 2 * indicator b - 1 := by + cases b <;> norm_num [sign, indicator] + +theorem finiteAvg_sign (f : Cube V → Bool) : + finiteAvg (fun x => sign (f x)) = + 2 * finiteAvg (fun x => indicator (f x)) - 1 := by + calc + _ = finiteAvg (fun x => 2 * indicator (f x) - 1) := + finiteAvg_congr (fun x => sign_eq_two_indicator_sub_one (f x)) + _ = _ := by rw [finiteAvg_sub, finiteAvg_const_mul, finiteAvg_const] + +theorem acceptance_density_lower_of_sign_bound (f : Cube V → Bool) (ε : ℝ) + (h : |finiteAvg (fun x => sign (f x))| ≤ ε) : + (1 - ε) / 2 ≤ finiteAvg (fun x => indicator (f x)) := by + have hl := (abs_le.mp h).1 + rw [finiteAvg_sign] at hl + linarith + +theorem acceptance_density_lower_of_width_correlation (f : Cube V → Bool) + (k : ℕ) (ε : ℝ) + (h : ∀ H : CNF V, H.WidthAtMost k → + |finiteAvg (fun x : Cube V => sign (f x) * indicator (H.eval x))| ≤ ε) : + (1 - ε) / 2 ≤ finiteAvg (fun x => indicator (f x)) := by + apply acceptance_density_lower_of_sign_bound + have he := h [] (by intro C hC; simp at hC) + simpa using he + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/CircuitLowerBound.lean b/lean/OAI/Computability/DepthThree/CircuitLowerBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..b548284c57110c2c8f3baaccb2c81796f61f6a8f --- /dev/null +++ b/lean/OAI/Computability/DepthThree/CircuitLowerBound.lean @@ -0,0 +1,112 @@ +import OAI.Computability.DepthThree.CircuitNormalization +import OAI.Computability.DepthThree.CircuitDeletion +import Mathlib.Tactic.Linarith + +namespace OAI + +universe uDepth1 + +noncomputable section +open scoped BigOperators + +open scoped Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} [instFintypeV : Fintype V] + +namespace CNF + +theorem mass_le_of_width_correlation (H : CNF V) (hH : H.Normalized) + (f : Cube V → Bool) (hsupport : ∀ x, H.eval x = true → f x = true) + (k : ℕ) (ε : ℝ) + (hcorr : ∀ J : CNF V, J.WidthAtMost k → + |finiteAvg (fun x : Cube V => sign (f x) * indicator (J.eval x))| ≤ ε) : + finiteAvg (fun x : Cube V => indicator (H.eval x)) ≤ + ε + (H.length : ℝ) * ((2 : ℝ) ^ k)⁻¹ := by + let J := H.deleteWide k + have hpoint (x : Cube V) : indicator (H.eval x) ≤ + sign (f x) * indicator (J.eval x) + + (indicator (J.eval x) - indicator (H.eval x)) := by + have hm := H.indicator_eval_le_deleteWide k x + have hs := hsupport x + change indicator (H.eval x) ≤ indicator (J.eval x) at hm + cases hh : H.eval x <;> cases hj : J.eval x <;> cases hf : f x <;> + simp_all [indicator, sign] + calc + _ ≤ finiteAvg (fun x : Cube V => sign (f x) * indicator (J.eval x) + + (indicator (J.eval x) - indicator (H.eval x))) := finiteAvg_mono hpoint + _ = finiteAvg (fun x : Cube V => sign (f x) * indicator (J.eval x)) + + finiteAvg (fun x : Cube V => indicator (J.eval x) - indicator (H.eval x)) := + finiteAvg_add _ _ + _ ≤ |finiteAvg (fun x : Cube V => sign (f x) * indicator (J.eval x))| + + finiteAvg (fun x : Cube V => indicator (J.eval x) - indicator (H.eval x)) := + add_le_add_left (le_abs_self _) _ + _ ≤ ε + (H.length : ℝ) * ((2 : ℝ) ^ k)⁻¹ := + add_le_add (hcorr J (H.deleteWide_widthAtMost k)) (H.deletion_error_bound hH k) + +end CNF + +namespace Circuit3 + +theorem indicator_output_le_sum_middle + {V : Type uDepth1} + [Fintype V] + (C : Circuit3 V) (x : Cube V) : + indicator (C.eval x) ≤ ∑ j ∈ C.top, indicator ((C.middleCNF j).eval x) := by + classical + cases h : C.eval x with + | false => + simpa using Finset.sum_nonneg (fun j (_ : j ∈ C.top) => + indicator_nonneg ((C.middleCNF j).eval x)) + | true => + obtain ⟨j, hj, hx⟩ := (C.eval_eq_true_iff_middleCNF x).mp h + have hb := Finset.single_le_sum + (fun i (_ : i ∈ C.top) => indicator_nonneg ((C.middleCNF i).eval x)) hj + simpa [hx] using hb + +theorem acceptance_density_le (C : Circuit3 V) (f : Cube V → Bool) + (hC : C.Computes f) (k : ℕ) (ε : ℝ) (hε : 0 ≤ ε) + (hcorr : ∀ H : CNF V, H.WidthAtMost k → + |finiteAvg (fun x : Cube V => sign (f x) * indicator (H.eval x))| ≤ ε) : + finiteAvg (fun x : Cube V => indicator (f x)) ≤ + (C.gateCount : ℝ) * ε + (C.gateCount : ℝ) ^ 2 * ((2 : ℝ) ^ k)⁻¹ := by + classical + let q : ℝ := ((2 : ℝ) ^ k)⁻¹ + have hq : 0 ≤ q := inv_nonneg.mpr (pow_nonneg (by norm_num) _) + have hm (j : Fin C.middleCount) (hj : j ∈ C.top) : + finiteAvg (fun x : Cube V => indicator ((C.middleCNF j).eval x)) ≤ + ε + (C.gateCount : ℝ) * q := by + have hs (x : Cube V) (hx : (C.middleCNF j).eval x = true) : f x = true := by + rw [← hC x] + exact C.middleCNF_implies_output hj hx + have hfirst := (C.middleCNF j).mass_le_of_width_correlation + (C.middleCNF_normalized j) f hs k ε hcorr + refine hfirst.trans (add_le_add_right (mul_le_mul_of_nonneg_right ?_ hq) ε) + exact_mod_cast C.middleCNF_length_le_gateCount j + have hB : 0 ≤ ε + (C.gateCount : ℝ) * q := + add_nonneg hε (mul_nonneg (Nat.cast_nonneg _) hq) + calc + _ = finiteAvg (fun x : Cube V => indicator (C.eval x)) := + finiteAvg_congr (fun x => congrArg indicator (hC x).symm) + _ ≤ finiteAvg (fun x : Cube V => + ∑ j ∈ C.top, indicator ((C.middleCNF j).eval x)) := + finiteAvg_mono (C.indicator_output_le_sum_middle) + _ = ∑ j ∈ C.top, finiteAvg (fun x : Cube V => + indicator ((C.middleCNF j).eval x)) := finiteAvg_sum _ _ + _ ≤ ∑ j ∈ C.top, (ε + (C.gateCount : ℝ) * q) := + Finset.sum_le_sum hm + _ = (C.top.card : ℝ) * (ε + (C.gateCount : ℝ) * q) := by + simp only [Finset.sum_const, nsmul_eq_mul] + _ ≤ (C.gateCount : ℝ) * (ε + (C.gateCount : ℝ) * q) := by + apply mul_le_mul_of_nonneg_right _ hB + exact_mod_cast C.top_card_le_gateCount + _ = _ := by dsimp [q]; ring + +end Circuit3 + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/CircuitNormalization.lean b/lean/OAI/Computability/DepthThree/CircuitNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..d2cf8ed1fe30f70b01b2ce89e9bdcf8dde674197 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/CircuitNormalization.lean @@ -0,0 +1,142 @@ +import OAI.Computability.DepthThree.Circuit +import OAI.Computability.DepthThree.RestrictionNormalization + +namespace OAI + +universe uDepth1 + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} + +namespace RawClause + +def literalPart : GateInput V → Option (Literal V) + | .inl l => some l + | .inr _ => none + +noncomputable def literals (C : RawClause V) : Clause V := by + classical + exact (C.filterMap literalPart).toFinset + +@[simp] theorem mem_literals (C : RawClause V) (l : Literal V) : + l ∈ C.literals ↔ Sum.inl l ∈ C := by + classical + simp only [literals, List.mem_toFinset, List.mem_filterMap] + constructor + · rintro ⟨a, ha, he⟩ + cases a with + | inl k => + have hk : k = l := Option.some.inj he + simpa [hk] using ha + | inr b => simp [literalPart] at he + · intro h + exact ⟨.inl l, h, rfl⟩ + +theorem eval_true_iff (C : RawClause V) (x : Cube V) : + C.eval x = true ↔ Sum.inr true ∈ C ∨ C.literals.eval x = true := by + rw [eval_eq_true, Clause.eval_eq_true] + constructor + · rintro ⟨a, ha, hx⟩ + cases a with + | inl l => exact Or.inr ⟨l, (mem_literals C l).mpr ha, (Literal.eval_eq_true l x).mp hx⟩ + | inr b => + change b = true at hx + exact Or.inl (hx ▸ ha) + · rintro (h | ⟨l, hl, hx⟩) + · exact ⟨.inr true, h, rfl⟩ + · exact ⟨.inl l, (mem_literals C l).mp hl, (Literal.eval_eq_true l x).mpr hx⟩ + +noncomputable def normalize (C : RawClause V) : Option (Clause V) := by + classical + exact if Sum.inr true ∈ C ∨ ¬ C.literals.Normalized then none else some C.literals + +theorem normalized_of_normalize_eq_some {C : RawClause V} {D : Clause V} + (h : C.normalize = some D) : D.Normalized := by + classical + unfold normalize at h + split at h + · contradiction + · rename_i hn + have hCD : C.literals = D := Option.some.inj h + rw [← hCD] + exact Classical.not_not.mp (fun hbad => hn (Or.inr hbad)) + +theorem normalize_eval (C : RawClause V) (x : Cube V) : + ((C.normalize).map (fun D => D.eval x)).getD true = C.eval x := by + classical + unfold normalize + split + · rename_i h + have ht : C.eval x = true := by + apply (eval_true_iff C x).mpr + rcases h with h | h + · exact Or.inl h + · exact Or.inr (Clause.eval_true_of_not_normalized h x) + simp [ht] + · rename_i h + have hc : Sum.inr true ∉ C := fun hc => h (Or.inl hc) + change C.literals.eval x = C.eval x + apply Bool.eq_iff_iff.mpr + rw [eval_true_iff] + simp [hc] + +end RawClause + +namespace Circuit3 + +noncomputable def middleCNF (C : Circuit3 V) (j : Fin C.middleCount) : CNF V := + (C.middle j).toList.filterMap fun i => (C.bottom i).normalize + +theorem mem_middleCNF (C : Circuit3 V) (j : Fin C.middleCount) (D : Clause V) : + D ∈ C.middleCNF j ↔ ∃ i ∈ C.middle j, (C.bottom i).normalize = some D := by + simp [middleCNF, List.mem_filterMap] + +theorem middleCNF_normalized (C : Circuit3 V) (j : Fin C.middleCount) : + (C.middleCNF j).Normalized := by + intro D hD + obtain ⟨i, _, hi⟩ := (mem_middleCNF C j D).mp hD + exact RawClause.normalized_of_normalize_eq_some hi + +theorem middleCNF_length_le_bottomCount (C : Circuit3 V) (j : Fin C.middleCount) : + (C.middleCNF j).length ≤ C.bottomCount := by + calc + (C.middleCNF j).length ≤ (C.middle j).toList.length := List.length_filterMap_le _ _ + _ = (C.middle j).card := Finset.length_toList _ + _ ≤ C.bottomCount := by simpa using Finset.card_le_univ (C.middle j) + +theorem middleCNF_length_le_gateCount (C : Circuit3 V) (j : Fin C.middleCount) : + (C.middleCNF j).length ≤ C.gateCount := + (C.middleCNF_length_le_bottomCount j).trans C.bottomCount_le_gateCount + +@[simp] theorem eval_middleCNF (C : Circuit3 V) (j : Fin C.middleCount) (x : Cube V) : + (C.middleCNF j).eval x = C.middleEval j x := by + classical + apply Bool.eq_iff_iff.mpr + rw [CNF.eval_eq_true, middleEval_eq_true] + constructor + · intro hx i hi + have he := (C.bottom i).normalize_eval x + cases hn : (C.bottom i).normalize with + | none => simpa [hn] using he.symm + | some D => + have hD := hx D ((mem_middleCNF C j D).mpr ⟨i, hi, hn⟩) + simpa [hn, hD] using he.symm + · intro hx D hD + obtain ⟨i, hi, hn⟩ := (mem_middleCNF C j D).mp hD + have he := (C.bottom i).normalize_eval x + simpa [hn, hx i hi] using he + +theorem eval_eq_true_iff_middleCNF (C : Circuit3 V) (x : Cube V) : + C.eval x = true ↔ ∃ j ∈ C.top, (C.middleCNF j).eval x = true := by + simp only [eval_middleCNF, eval_eq_true] + +theorem middleCNF_implies_output (C : Circuit3 V) {j : Fin C.middleCount} + (hj : j ∈ C.top) {x : Cube V} (hx : (C.middleCNF j).eval x = true) : + C.eval x = true := (eval_eq_true_iff_middleCNF C x).mpr ⟨j, hj, hx⟩ + +end Circuit3 + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/CircuitQuantitative.lean b/lean/OAI/Computability/DepthThree/CircuitQuantitative.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c6d94d5c2957595f3def4539fd0bb1e3ec0d78b --- /dev/null +++ b/lean/OAI/Computability/DepthThree/CircuitQuantitative.lean @@ -0,0 +1,57 @@ +import OAI.Computability.DepthThree.CircuitLowerBound +import OAI.Computability.DepthThree.CircuitDensity +import OAI.Computability.DepthThree.AsymptoticBounds +import Mathlib.Tactic.Convert + +namespace OAI + +namespace DepthThreeLowerBound + +theorem circuit_lower_bound_of_small_cnf_correlations + (d k : ℕ) (s : ℝ) (hs : 0 ≤ s) (hd : 4 ≤ d) + (hk : 3 * (s + 1) * Real.sqrt (d : ℝ) ≤ (k : ℝ)) + (f : Cube (Fin d) → Bool) + (hcorr : ∀ H : CNF (Fin d), H.WidthAtMost k → + |finiteAvg (fun x : Cube (Fin d) => sign (f x) * indicator (H.eval x))| ≤ + 6 * (2 : ℝ) ^ (-(64 * (s + 1) * Real.sqrt (d : ℝ)) / 16)) + (C : Circuit3 (Fin d)) (hC : C.Computes f) : + (2 : ℝ) ^ (s * Real.sqrt (d : ℝ)) < (C.gateCount : ℝ) := by + by_contra h + have hsize : (C.gateCount : ℝ) ≤ (2 : ℝ) ^ (s * Real.sqrt (d : ℝ)) := + le_of_not_gt h + let ε : ℝ := 6 * (2 : ℝ) ^ (-(64 * (s + 1) * Real.sqrt (d : ℝ)) / 16) + have hε : 0 ≤ ε := mul_nonneg (by norm_num) (Real.rpow_nonneg (by norm_num) _) + have hdReal : (4 : ℝ) ≤ (d : ℝ) := by exact_mod_cast hd + have hexponent : -(64 * (s + 1) * Real.sqrt (d : ℝ)) / 16 = + -(4 * (s + 1) * Real.sqrt (d : ℝ)) := by ring + have hsmall : ε ≤ 3 / 8 := by + dsimp only [ε] + rw [hexponent] + exact correlation_error_le s (d : ℝ) hs (by linarith) + have hlower : (1 - ε) / 2 ≤ + finiteAvg (fun x : Cube (Fin d) => indicator (f x)) := by + convert acceptance_density_lower_of_width_correlation f k ε + (fun H hH => by convert hcorr H hH) + have hupper : finiteAvg (fun x : Cube (Fin d) => indicator (f x)) ≤ + (C.gateCount : ℝ) * ε + (C.gateCount : ℝ) ^ 2 * ((2 : ℝ) ^ k)⁻¹ := by + convert C.acceptance_density_le f hC k ε hε + (fun H hH => by convert hcorr H hH) + have hinverse : (2 : ℝ) ^ (-(k : ℝ)) = ((2 : ℝ) ^ k)⁻¹ := by + rw [Real.rpow_neg (by norm_num : (0 : ℝ) ≤ 2), Real.rpow_natCast] + have hfinal := final_error_le s (d : ℝ) (C.gateCount : ℝ) hs hdReal + (Nat.cast_nonneg _) hsize k hk + have hupper' : finiteAvg (fun x : Cube (Fin d) => indicator (f x)) ≤ 5 / 128 := by + calc + _ ≤ (C.gateCount : ℝ) * ε + (C.gateCount : ℝ) ^ 2 * ((2 : ℝ) ^ k)⁻¹ := hupper + _ = 6 * (C.gateCount : ℝ) * + (2 : ℝ) ^ (-(64 * (s + 1) * Real.sqrt (d : ℝ)) / 16) + + (C.gateCount : ℝ) ^ 2 * (2 : ℝ) ^ (-(k : ℝ)) := by + rw [hinverse] + dsimp only [ε] + ring + _ ≤ 5 / 128 := hfinal + linarith + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/Core.lean b/lean/OAI/Computability/DepthThree/Core.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce0838d50801849af9fe99da021d486bc404d29a --- /dev/null +++ b/lean/OAI/Computability/DepthThree/Core.lean @@ -0,0 +1,170 @@ +import OAI.Computability.DepthThree.Model + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 + +namespace DepthThreeLowerBound + +abbrev Clause (V : Type uDepth1) := Finset (Literal V) +abbrev CNF (V : Type uDepth2) := List (Clause V) + +variable {V : Type uDepth3} + +namespace Literal + +def compl (l : Literal V) : Literal V := (l.1, !l.2) + +@[simp] theorem eval_eq_true (l : Literal V) (x : Cube V) : + l.eval x = true ↔ x l.1 = l.2 := by simp [eval] + +@[simp] theorem compl_compl (l : Literal V) : l.compl.compl = l := by + cases l with + | mk v b => cases b <;> rfl + +@[simp] theorem eval_compl (l : Literal V) (x : Cube V) : + l.compl.eval x = !(l.eval x) := by + rcases l with ⟨v, b⟩ + cases b <;> cases h : x v <;> simp [compl, eval, h] + +end Literal + +namespace Clause + +noncomputable def eval (C : Clause V) (x : Cube V) : Bool := by + classical + exact decide (∃ l ∈ C, l.eval x = true) + +noncomputable def scope (C : Clause V) : Finset V := by + classical + exact C.image Prod.fst + +noncomputable def width (C : Clause V) : ℕ := C.scope.card + +def Normalized (C : Clause V) : Prop := + ∀ v, (v, false) ∈ C → (v, true) ∈ C → False + +@[simp] theorem eval_eq_true (C : Clause V) (x : Cube V) : + C.eval x = true ↔ ∃ l ∈ C, x l.1 = l.2 := by + classical + simp [eval] + +@[simp] theorem eval_empty (x : Cube V) : (∅ : Clause V).eval x = false := by + simp [eval] + +@[simp] theorem scope_empty : (∅ : Clause V).scope = ∅ := by + classical + simp [scope] + +@[simp] theorem width_empty : (∅ : Clause V).width = 0 := by + simp [width] + +@[simp] theorem eval_singleton (l : Literal V) (x : Cube V) : + ({l} : Clause V).eval x = l.eval x := by + classical + simp [eval, Literal.eval] + +theorem eval_mono {C D : Clause V} (h : C ⊆ D) {x : Cube V} + (hx : C.eval x = true) : D.eval x = true := by + rw [eval_eq_true] at hx ⊢ + obtain ⟨l, hl, hx⟩ := hx + exact ⟨l, h hl, hx⟩ + +theorem Normalized.subset {C D : Clause V} (hD : D.Normalized) (h : C ⊆ D) : + C.Normalized := by + intro v hf ht + exact hD v (h hf) (h ht) + +theorem Normalized.fst_injOn {C : Clause V} (h : C.Normalized) : + Set.InjOn Prod.fst (↑C : Set (Literal V)) := by + rintro ⟨v, b⟩ hb ⟨w, c⟩ hc hv + change v = w at hv + subst w + cases b <;> cases c + · rfl + · exact (h v hb hc).elim + · exact (h v hc hb).elim + · rfl + +theorem Normalized.card_eq_width {C : Clause V} (h : C.Normalized) : + C.card = C.width := by + classical + exact (Finset.card_image_of_injOn h.fst_injOn).symm + +theorem scope_mono {C D : Clause V} (h : C ⊆ D) : C.scope ⊆ D.scope := by + classical + exact Finset.image_subset_image h + +theorem width_mono {C D : Clause V} (h : C ⊆ D) : C.width ≤ D.width := + Finset.card_le_card (scope_mono h) + +end Clause + +namespace CNF + +noncomputable def eval (H : CNF V) (x : Cube V) : Bool := by + classical + exact decide (∀ C ∈ H, C.eval x = true) + +def WidthAtMost (H : CNF V) (b : ℕ) : Prop := ∀ C ∈ H, C.width ≤ b + +def Normalized (H : CNF V) : Prop := ∀ C ∈ H, C.Normalized + +@[simp] theorem eval_eq_true (H : CNF V) (x : Cube V) : + H.eval x = true ↔ ∀ C ∈ H, C.eval x = true := by + classical + simp [eval] + +@[simp] theorem eval_nil (x : Cube V) : CNF.eval ([] : CNF V) x = true := by + simp [eval] + +@[simp] theorem eval_cons (C : Clause V) (H : CNF V) (x : Cube V) : + CNF.eval (C :: H) x = (C.eval x && H.eval x) := by + classical + apply Bool.eq_iff_iff.mpr + rw [eval_eq_true, Bool.and_eq_true, eval_eq_true] + constructor + · intro h + exact ⟨h C (by simp), fun D hD => h D (by simp [hD])⟩ + · rintro ⟨hc, hH⟩ D hD + rcases List.mem_cons.mp hD with hD | hD + · simpa only [hD] using hc + · exact hH D hD + +@[simp] theorem eval_append (H J : CNF V) (x : Cube V) : + (H ++ J).eval x = (H.eval x && J.eval x) := by + induction H with + | nil => simp + | cons C H ih => simp [ih, Bool.and_assoc] + +theorem eval_antitone {H J : CNF V} (h : H ⊆ J) {x : Cube V} + (hx : J.eval x = true) : H.eval x = true := by + rw [eval_eq_true] at hx ⊢ + exact fun C hC => hx C (h hC) + +theorem WidthAtMost.mono {H : CNF V} {b c : ℕ} (h : H.WidthAtMost b) + (hbc : b ≤ c) : H.WidthAtMost c := fun C hC => (h C hC).trans hbc + +end CNF + +def indicator (b : Bool) : ℝ := if b then 1 else 0 +def sign (b : Bool) : ℝ := if b then 1 else -1 + +@[simp] theorem indicator_false : indicator false = 0 := rfl +@[simp] theorem indicator_true : indicator true = 1 := rfl +@[simp] theorem sign_false : sign false = -1 := rfl +@[simp] theorem sign_true : sign true = 1 := rfl + +@[simp] theorem indicator_and (b c : Bool) : + indicator (b && c) = indicator b * indicator c := by + cases b <;> cases c <;> simp [indicator] + +theorem indicator_nonneg (b : Bool) : 0 ≤ indicator b := by + cases b <;> simp [indicator] + +theorem indicator_le_one (b : Bool) : indicator b ≤ 1 := by + cases b <;> simp [indicator] + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/CorrelationTransfer.lean b/lean/OAI/Computability/DepthThree/CorrelationTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ae694c44121c3f0050b10732525199726feb1e9 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/CorrelationTransfer.lean @@ -0,0 +1,119 @@ +import OAI.Computability.DepthThree.RestrictionProbability +import OAI.Computability.DepthThree.RestrictionCorrelation +import Mathlib.Tactic.Linarith + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} [Fintype V] [instDecidableEqV : DecidableEq V] + +theorem restrictionAvg_mask_le + {V : Type uDepth1} + [Fintype V] + [DecidableEq V] + {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) + (W : Restriction V → ℝ) (hW : ∀ σ, 0 ≤ W σ) + (good : Restriction V → Prop) : + restrictionAvg p (fun σ => if good σ then W σ else 0) ≤ restrictionAvg p W := by + apply restrictionAvg_mono hp hp1 + intro σ + split_ifs + · exact le_rfl + · exact hW σ + +theorem restrictionAvg_abs_le_split {p ε δ C : ℝ} + (hp : 0 ≤ p) (hp1 : p ≤ 1) (hε : 0 ≤ ε) + (q W : Restriction V → ℝ) (good : Restriction V → Prop) + (hW : ∀ σ, 0 ≤ W σ) (hmean : restrictionAvg p W ≤ C) + (hgood : ∀ σ, good σ → |q σ| ≤ ε * W σ) + (hunit : ∀ σ, |q σ| ≤ 1) + (hbad : restrictionAvg p (fun σ => if ¬ good σ then 1 else 0) ≤ δ) : + |restrictionAvg p q| ≤ ε * C + δ := by + have hmask : restrictionAvg p (fun σ => if good σ then W σ else 0) ≤ C := + (restrictionAvg_mask_le hp hp1 W hW good).trans hmean + calc + |restrictionAvg p q| ≤ restrictionAvg p (fun σ => |q σ|) := + restrictionAvg_abs_le hp hp1 q + _ ≤ restrictionAvg p (fun σ => + ε * (if good σ then W σ else 0) + (if ¬ good σ then 1 else 0)) := by + apply restrictionAvg_mono hp hp1 + intro σ + by_cases h : good σ + · simpa only [h, ite_true, not_true_eq_false, ite_false, add_zero] + using hgood σ h + · simpa only [h, ite_false, not_false_eq_true, ite_true, mul_zero, zero_add] + using hunit σ + _ = ε * restrictionAvg p (fun σ => if good σ then W σ else 0) + + restrictionAvg p (fun σ => if ¬ good σ then 1 else 0) := by + rw [restrictionAvg_add, restrictionAvg_const_mul] + _ ≤ ε * C + δ := add_le_add (mul_le_mul_of_nonneg_left hmask hε) hbad + +theorem abs_finiteAvg_sign_indicator_le_one {Z : Type uDepth2} [Fintype Z] + (f J : Cube Z → Bool) : + |finiteAvg (fun x => sign (f x) * indicator (J x))| ≤ 1 := by + calc + _ ≤ finiteAvg (fun x => |sign (f x) * indicator (J x)|) := finiteAvg_abs_le _ + _ ≤ finiteAvg (fun _ : Cube Z => (1 : ℝ)) := by + apply finiteAvg_mono + intro x + cases f x <;> cases J x <;> norm_num [sign, indicator] + _ = 1 := finiteAvg_const _ + +theorem restriction_correlation_transfer {p ε δ C : ℝ} + (hp : 0 ≤ p) (hp1 : p ≤ 1) (hε : 0 ≤ ε) + (f : Cube V → Bool) (H : CNF V) (b : ℕ) + (good : Restriction V → Prop) (W : Restriction V → ℝ) + (hW : ∀ σ, 0 ≤ W σ) (hmean : restrictionAvg p W ≤ C) + (hdom : ∀ σ, + |finiteAvg (fun z : Cube (Live σ) => + sign (f (fill σ z)) * indicator (H.eval (fill σ z)))| ≤ + W σ * corr b (fun z => sign (f (fill σ z)))) + (hgood : ∀ σ, good σ → corr b (fun z => sign (f (fill σ z))) ≤ ε) + (hbad : restrictionAvg p (fun σ => if ¬ good σ then 1 else 0) ≤ δ) : + |finiteAvg (fun x => sign (f x) * indicator (H.eval x))| ≤ ε * C + δ := by + rw [← restrictionAvg_fill p (fun x => sign (f x) * indicator (H.eval x))] + apply restrictionAvg_abs_le_split hp hp1 hε _ W good hW hmean + · intro σ hσ + calc + _ ≤ W σ * corr b (fun z => sign (f (fill σ z))) := hdom σ + _ ≤ W σ * ε := mul_le_mul_of_nonneg_left (hgood σ hσ) (hW σ) + _ = ε * W σ := mul_comm _ _ + · intro σ + calc + _ ≤ finiteAvg (fun z : Cube (Live σ) => + |sign (f (fill σ z)) * indicator (H.eval (fill σ z))|) := finiteAvg_abs_le _ + _ ≤ finiteAvg (fun _ : Cube (Live σ) => (1 : ℝ)) := by + apply finiteAvg_mono + intro z + cases f (fill σ z) <;> cases H.eval (fill σ z) <;> norm_num [sign, indicator] + _ = 1 := finiteAvg_const _ + · exact hbad + +theorem restriction_correlation_transfer_six {p ε : ℝ} + (hp : 0 ≤ p) (hp1 : p ≤ 1) (hε : 0 ≤ ε) + (f : Cube V → Bool) (H : CNF V) (b : ℕ) + (good : Restriction V → Prop) (W : Restriction V → ℝ) + (hW : ∀ σ, 0 ≤ W σ) (hmean : restrictionAvg p W ≤ 2) + (hdom : ∀ σ, + |finiteAvg (fun z : Cube (Live σ) => + sign (f (fill σ z)) * indicator (H.eval (fill σ z)))| ≤ + W σ * corr b (fun z => sign (f (fill σ z)))) + (hgood : ∀ σ, good σ → corr b (fun z => sign (f (fill σ z))) ≤ ε) + (hbad : restrictionAvg p (fun σ => if ¬ good σ then 1 else 0) ≤ 4 * ε) : + |finiteAvg (fun x => sign (f x) * indicator (H.eval x))| ≤ 6 * ε := by + have h := restriction_correlation_transfer hp hp1 hε f H b good W hW hmean + hdom hgood hbad + linarith + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/CylinderProbability.lean b/lean/OAI/Computability/DepthThree/CylinderProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ccc4121222a2956cdbb4a9d01959c8db2c5c0b7 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/CylinderProbability.lean @@ -0,0 +1,56 @@ +import OAI.Computability.DepthThree.FiniteProbability +import Mathlib.Algebra.BigOperators.GroupWithZero.Finset +import Mathlib.Tactic.NormNum + +namespace OAI + +universe uDepth1 + +noncomputable section + +open scoped BigOperators +attribute [local instance] Classical.propDecidable + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} [Fintype V] + +theorem finiteAvg_eq_pattern (U : Finset V) (σ : Cube V) : + finiteAvg (fun x : Cube V => + if ∀ v ∈ U, x v = σ v then (1 : ℝ) else 0) = + ((2 : ℝ) ^ U.card)⁻¹ := by + classical + let q : V → Bool → ℝ := fun v b => if v ∈ U → b = σ v then 1 else 0 + have hpoint (x : Cube V) : + (if ∀ v ∈ U, x v = σ v then (1 : ℝ) else 0) = ∏ v, q v (x v) := by + dsimp [q] + rw [Fintype.prod_boole] + have hcoordinate (v : V) : + finiteAvg (q v) = if v ∈ U then (2 : ℝ)⁻¹ else 1 := by + by_cases hv : v ∈ U + · cases hσ : σ v <;> + norm_num [q, hv, hσ, finiteAvg, Fintype.sum_bool] + · simp [q, hv] + calc + _ = finiteAvg (fun x : Cube V => ∏ v, q v (x v)) := finiteAvg_congr hpoint + _ = ∏ v, finiteAvg (q v) := finiteAvg_pi_prod q + _ = ∏ v, if v ∈ U then (2 : ℝ)⁻¹ else 1 := by + exact Finset.prod_congr rfl (fun v _ => hcoordinate v) + _ = ((2 : ℝ) ^ U.card)⁻¹ := by + rw [← Finset.prod_filter] + have hfilter : Finset.univ.filter (fun v => v ∈ U) = U := by + ext v + simp + rw [hfilter, Finset.prod_const, inv_pow] + +theorem finiteAvg_indicator_eq_pattern (U : Finset V) (σ : Cube V) : + finiteAvg (fun x : Cube V => indicator (decide (∀ v ∈ U, x v = σ v))) = + ((2 : ℝ) ^ U.card)⁻¹ := by + refine (finiteAvg_congr fun x => ?_).trans (finiteAvg_eq_pattern U σ) + by_cases hx : ∀ v ∈ U, x v = σ v <;> simp [indicator, hx] + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/Entropy.lean b/lean/OAI/Computability/DepthThree/Entropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..df6fdda6275a1228d24393ebf310a14eaa4301ff --- /dev/null +++ b/lean/OAI/Computability/DepthThree/Entropy.lean @@ -0,0 +1,141 @@ +import OAI.Computability.DepthThree.EntropyBits +import OAI.Computability.DepthThree.EntropyThreshold +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +namespace OAI + +universe uDepth1 + +noncomputable section + +namespace DepthThreeLowerBound + +open scoped BigOperators + +theorem finite_card_le_of_uniform_weight_lower_bound {α : Type uDepth1} [Fintype α] + (A : Finset α) (w : α → ℝ) {δ : ℝ} (hδ : 0 < δ) + (hw : ∀ a, 0 ≤ w a) (hsum : ∑ a, w a ≤ 1) + (hlower : ∀ a ∈ A, δ ≤ w a) : (A.card : ℝ) ≤ 1 / δ := by + classical + have hcard : (A.card : ℝ) * δ ≤ 1 := by + calc + (A.card : ℝ) * δ = ∑ _a ∈ A, δ := by simp + _ ≤ ∑ a ∈ A, w a := Finset.sum_le_sum hlower + _ ≤ ∑ a, w a := Finset.sum_le_sum_of_subset_of_nonneg + (Finset.subset_univ _) (fun a _ _ => hw a) + _ ≤ 1 := hsum + exact (le_div_iff₀ hδ).2 hcard + +def bernoulliStringWeight {N : ℕ} (x : ℝ) (z : Fin N → Bool) : ℝ := + ∏ i, if z i = true then x else 1 - x + +theorem bernoulliStringWeight_pos {N : ℕ} {x : ℝ} (hx : 0 < x) + (hx1 : x < 1) (z : Fin N → Bool) : 0 < bernoulliStringWeight x z := by + apply Finset.prod_pos + intro i _ + split_ifs + · exact hx + · exact sub_pos.mpr hx1 + +theorem sum_bernoulliStringWeight (N : ℕ) (x : ℝ) : + ∑ z : Fin N → Bool, bernoulliStringWeight x z = 1 := by + have hbit : (∑ b : Bool, if b = true then x else 1 - x) = 1 := by + simp [Fintype.univ_bool] + calc + (∑ z : Fin N → Bool, bernoulliStringWeight x z) = + ∏ _i : Fin N, ∑ b : Bool, if b = true then x else 1 - x := + (Fintype.prod_sum (fun (_i : Fin N) (b : Bool) => + if b = true then x else 1 - x)).symm + _ = 1 := by simp only [hbit, Finset.prod_const_one] + +theorem log_bernoulliStringWeight {N : ℕ} {x : ℝ} (hx : 0 < x) + (hx1 : x < 1) (z : Fin N → Bool) : + Real.log (bernoulliStringWeight x z) = + (N : ℝ) * Real.log (1 - x) + + (trueCount z : ℝ) * (Real.log x - Real.log (1 - x)) := by + have hne : ∀ i ∈ (Finset.univ : Finset (Fin N)), + (if z i = true then x else 1 - x) ≠ 0 := by + intro i _ + split_ifs + · exact ne_of_gt hx + · exact ne_of_gt (sub_pos.mpr hx1) + rw [bernoulliStringWeight, Real.log_prod hne] + calc + (∑ i : Fin N, Real.log (if z i = true then x else 1 - x)) = + ∑ i : Fin N, (Real.log (1 - x) + + (if z i = true then (1 : ℝ) else 0) * + (Real.log x - Real.log (1 - x))) := by + apply Finset.sum_congr rfl + intro i _ + split_ifs <;> ring + _ = (N : ℝ) * Real.log (1 - x) + + (trueCount z : ℝ) * (Real.log x - Real.log (1 - x)) := by + rw [Finset.sum_add_distrib, ← Finset.sum_mul, ← trueCount_cast] + simp + +theorem bernoulliStringWeight_lower_bound {N : ℕ} {x : ℝ} + (hx : 0 < x) (hxhalf : x ≤ 1 / 2) (z : Fin N → Bool) + (hz : (trueCount z : ℝ) ≤ (N : ℝ) * x) : + Real.exp (-((N : ℝ) * binaryEntropy x * Real.log 2)) ≤ + bernoulliStringWeight x z := by + have hx1 : x < 1 := by linarith + have hc : Real.log x - Real.log (1 - x) ≤ 0 := by + apply sub_nonpos.mpr + apply Real.log_le_log hx + linarith + have hmul := mul_le_mul_of_nonpos_right hz hc + have hlog : -((N : ℝ) * binaryEntropy x * Real.log 2) ≤ + Real.log (bernoulliStringWeight x z) := by + rw [log_bernoulliStringWeight hx hx1] + calc + -((N : ℝ) * binaryEntropy x * Real.log 2) = + (N : ℝ) * Real.log (1 - x) + + ((N : ℝ) * x) * (Real.log x - Real.log (1 - x)) := by + rw [mul_assoc, binaryEntropy_mul_log_two] + ring + _ ≤ (N : ℝ) * Real.log (1 - x) + + (trueCount z : ℝ) * (Real.log x - Real.log (1 - x)) := + add_le_add_right hmul _ + calc + Real.exp (-((N : ℝ) * binaryEntropy x * Real.log 2)) ≤ + Real.exp (Real.log (bernoulliStringWeight x z)) := + Real.exp_le_exp.mpr hlog + _ = bernoulliStringWeight x z := + Real.exp_log (bernoulliStringWeight_pos hx hx1 z) + +def sparseBinaryStrings (N : ℕ) (x : ℝ) : Finset (Fin N → Bool) := by + classical + exact Finset.univ.filter fun z => (trueCount z : ℝ) ≤ (N : ℝ) * x + +theorem card_sparse_binary_strings_le (N : ℕ) {x : ℝ} + (hx : 0 < x) (hxhalf : x ≤ 1 / 2) : + ((sparseBinaryStrings N x).card : ℝ) ≤ + (2 : ℝ) ^ ((N : ℝ) * binaryEntropy x) := by + classical + have hx1 : x < 1 := by linarith + have h := finite_card_le_of_uniform_weight_lower_bound + (sparseBinaryStrings N x) (bernoulliStringWeight x) + (Real.exp_pos (-((N : ℝ) * binaryEntropy x * Real.log 2))) + (fun z => (bernoulliStringWeight_pos hx hx1 z).le) + (sum_bernoulliStringWeight N x).le + (fun z hz => bernoulliStringWeight_lower_bound hx hxhalf z + (Finset.mem_filter.mp hz).2) + calc + ((sparseBinaryStrings N x).card : ℝ) ≤ + 1 / Real.exp (-((N : ℝ) * binaryEntropy x * Real.log 2)) := h + _ = Real.exp ((N : ℝ) * binaryEntropy x * Real.log 2) := by + rw [one_div, Real.exp_neg, inv_inv] + _ = (2 : ℝ) ^ ((N : ℝ) * binaryEntropy x) := by + rw [Real.rpow_def_of_pos (show (0 : ℝ) < 2 by norm_num)] + congr 1 + ring + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/EntropyBits.lean b/lean/OAI/Computability/DepthThree/EntropyBits.lean new file mode 100644 index 0000000000000000000000000000000000000000..db22488c05b55eaf87506d614066502174aa73ff --- /dev/null +++ b/lean/OAI/Computability/DepthThree/EntropyBits.lean @@ -0,0 +1,25 @@ +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Basic.Real.Basic + +namespace OAI + +namespace DepthThreeLowerBound + +open scoped BigOperators + +def trueCount {N : ℕ} (z : Fin N → Bool) : ℕ := + (Finset.univ.filter fun i => z i = true).card + +theorem trueCount_le {N : ℕ} (z : Fin N → Bool) : trueCount z ≤ N := by + simpa only [trueCount, Finset.card_univ, Fintype.card_fin] using + (Finset.card_filter_le (s := (Finset.univ : Finset (Fin N))) + (p := fun i => z i = true)) + +theorem trueCount_cast {N : ℕ} (z : Fin N → Bool) : + (trueCount z : ℝ) = ∑ i, if z i = true then (1 : ℝ) else 0 := by + exact Finset.natCast_card_filter (fun i => z i = true) Finset.univ + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/EntropyThreshold.lean b/lean/OAI/Computability/DepthThree/EntropyThreshold.lean new file mode 100644 index 0000000000000000000000000000000000000000..374df4bd6392e688b6c812e5ba0d579f54a649b2 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/EntropyThreshold.lean @@ -0,0 +1,56 @@ +import Mathlib.Analysis.SpecialFunctions.Log.NegMulLog +import Mathlib.Analysis.SpecificLimits.Basic + +namespace OAI + +open Filter +open scoped Topology + +namespace DepthThreeLowerBound + +noncomputable def binaryEntropy (x : ℝ) : ℝ := + -(x * Real.log x + (1 - x) * Real.log (1 - x)) / Real.log 2 + +@[simp] theorem binaryEntropy_zero : binaryEntropy 0 = 0 := by + simp [binaryEntropy] + +@[simp] theorem binaryEntropy_one : binaryEntropy 1 = 0 := by + simp [binaryEntropy] + +theorem binaryEntropy_mul_log_two (x : ℝ) : + binaryEntropy x * Real.log 2 = + -(x * Real.log x + (1 - x) * Real.log (1 - x)) := by + exact div_mul_cancel₀ _ (ne_of_gt (Real.log_pos one_lt_two)) + +theorem binaryEntropy_nonneg {x : ℝ} (hx₀ : 0 ≤ x) (hx₁ : x ≤ 1) : + 0 ≤ binaryEntropy x := by + apply div_nonneg + · exact neg_nonneg.mpr (add_nonpos + (Real.mul_log_nonpos hx₀ hx₁) + (Real.mul_log_nonpos (sub_nonneg.mpr hx₁) (sub_le_self _ hx₀))) + · exact (Real.log_pos one_lt_two).le + +theorem continuous_binaryEntropy : Continuous binaryEntropy := by + unfold binaryEntropy + exact ((Real.continuous_mul_log.add + (Real.continuous_mul_log.comp (continuous_const.sub continuous_id))).neg).div_const _ + +theorem tendsto_binaryEntropy_reciprocal : + Tendsto (fun r : ℕ => binaryEntropy (1 / (r : ℝ))) atTop (𝓝 0) := by + simpa only [binaryEntropy_zero, Function.comp_def] using + (continuous_binaryEntropy.tendsto 0).comp tendsto_one_div_atTop_nhds_zero_nat + +theorem exists_integer_entropy_threshold (F : ℕ) {ε : ℝ} (hε : 0 < ε) : + ∃ r : ℕ, 2 ≤ r ∧ (F : ℝ) * binaryEntropy (1 / (r : ℝ)) ≤ ε := by + have hlim : Tendsto (fun r : ℕ => (F : ℝ) * binaryEntropy (1 / (r : ℝ))) + atTop (𝓝 0) := by + simpa only [mul_zero] using + (tendsto_const_nhds.mul tendsto_binaryEntropy_reciprocal : + Tendsto (fun r : ℕ => (F : ℝ) * binaryEntropy (1 / (r : ℝ))) + atTop (𝓝 ((F : ℝ) * 0))) + obtain ⟨N, hN⟩ := eventually_atTop.1 (hlim.eventually (eventually_lt_nhds hε)) + exact ⟨max N 2, le_max_right _ _, (hN _ (le_max_left _ _)).le⟩ + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/FinalParameterBounds.lean b/lean/OAI/Computability/DepthThree/FinalParameterBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..376af944ea65f581ad74ab40789d82479b1662ef --- /dev/null +++ b/lean/OAI/Computability/DepthThree/FinalParameterBounds.lean @@ -0,0 +1,147 @@ +import OAI.Computability.DepthThree.AsymptoticBounds +import OAI.Computability.DepthThree.ReversePathRecurrence +import Mathlib.Algebra.Order.Floor.Semiring +import Mathlib.Data.Nat.Choose.Bounds +import Mathlib.Algebra.Order.Archimedean.Real.Basic +import Mathlib.Tactic.FieldSimp +import Lean.Elab.Tactic.Omega + +namespace OAI + +noncomputable section + +open scoped BigOperators + +namespace DepthThreeLowerBound + +def liveProbability (B : ℝ) (d : ℕ) : ℝ := B / Real.sqrt (d : ℝ) + +def degreeCutoff (s : ℝ) (d : ℕ) : ℕ := + Nat.ceil (3 * (s + 1) * Real.sqrt (d : ℝ)) + +def factorialBase (B s : ℝ) : ℝ := 4 * B * (3 * (s + 1) + 1) + +theorem liveProbability_pos (B : ℝ) (hB : 0 < B) (d : ℕ) (hd : 0 < d) : + 0 < liveProbability B d := + div_pos hB (Real.sqrt_pos.mpr (Nat.cast_pos.mpr hd)) + +theorem liveProbability_mul_dimension (B : ℝ) (d : ℕ) (hd : 0 < d) : + liveProbability B d * (d : ℝ) = B * Real.sqrt (d : ℝ) := by + have hroot : Real.sqrt (d : ℝ) ≠ 0 := + (Real.sqrt_pos.mpr (Nat.cast_pos.mpr hd)).ne' + unfold liveProbability + calc + B / Real.sqrt (d : ℝ) * (d : ℝ) = + B / Real.sqrt (d : ℝ) * (Real.sqrt (d : ℝ) * Real.sqrt (d : ℝ)) := by + rw [Real.mul_self_sqrt (Nat.cast_nonneg d)] + _ = B * Real.sqrt (d : ℝ) := by + rw [← mul_assoc, div_mul_cancel₀ _ hroot] + +theorem degreeCutoff_lower (s : ℝ) (d : ℕ) : + 3 * (s + 1) * Real.sqrt (d : ℝ) ≤ (degreeCutoff s d : ℝ) := + Nat.le_ceil _ + +theorem degreeCutoff_upper (s : ℝ) (hs : 0 ≤ s) (d : ℕ) (hd : 1 ≤ d) : + (degreeCutoff s d : ℝ) ≤ (3 * (s + 1) + 1) * Real.sqrt (d : ℝ) := by + have hroot : (1 : ℝ) ≤ Real.sqrt (d : ℝ) := + Real.one_le_sqrt.mpr (by exact_mod_cast hd) + have hnonneg : 0 ≤ 3 * (s + 1) * Real.sqrt (d : ℝ) := + mul_nonneg (by linarith) (Real.sqrt_nonneg _) + have hceil := Nat.ceil_lt_add_one hnonneg + change (degreeCutoff s d : ℝ) < 3 * (s + 1) * Real.sqrt (d : ℝ) + 1 at hceil + nlinarith + +theorem exists_liveProbability_threshold (B : ℝ) (hB : 0 < B) : + ∃ D : ℕ, 1 ≤ D ∧ ∀ d : ℕ, D ≤ d → + 0 < liveProbability B d ∧ liveProbability B d ≤ 1 / 2 := by + obtain ⟨D, hD⟩ := exists_nat_ge (max (1 : ℝ) ((2 * B) ^ 2)) + have hDone : 1 ≤ D := by + exact_mod_cast (le_max_left (1 : ℝ) ((2 * B) ^ 2)).trans hD + refine ⟨D, hDone, ?_⟩ + intro d hd + have hdone : 1 ≤ d := hDone.trans hd + have hrootpos : 0 < Real.sqrt (d : ℝ) := + Real.sqrt_pos.mpr (Nat.cast_pos.mpr (by omega : 0 < d)) + have hsq : (2 * B) ^ 2 ≤ (d : ℝ) := + ((le_max_right (1 : ℝ) ((2 * B) ^ 2)).trans hD).trans (Nat.cast_le.mpr hd) + have hroot : 2 * B ≤ Real.sqrt (d : ℝ) := Real.le_sqrt_of_sq_le hsq + refine ⟨liveProbability_pos B hB d (by omega), ?_⟩ + change B / Real.sqrt (d : ℝ) ≤ 1 / 2 + apply (div_le_iff₀ hrootpos).mpr + linarith + +theorem scaled_cutoff_le_factorialBase (B s : ℝ) (hB : 0 ≤ B) (hs : 0 ≤ s) + (d : ℕ) (hd : 1 ≤ d) (hp : liveProbability B d ≤ 1 / 2) : + (2 * liveProbability B d / (1 - liveProbability B d)) * + (degreeCutoff s d : ℝ) ≤ factorialBase B s := by + have hrootpos : 0 < Real.sqrt (d : ℝ) := + Real.sqrt_pos.mpr (Nat.cast_pos.mpr (by omega : 0 < d)) + have hp0 : 0 ≤ liveProbability B d := div_nonneg hB (Real.sqrt_nonneg _) + have hα : 2 * liveProbability B d / (1 - liveProbability B d) ≤ + 4 * liveProbability B d := by + calc + 2 * liveProbability B d / (1 - liveProbability B d) ≤ + 2 * liveProbability B d / (1 / 2) := + div_le_div_of_nonneg_left (by linarith) (by norm_num) (by linarith) + _ = 4 * liveProbability B d := by ring + calc + (2 * liveProbability B d / (1 - liveProbability B d)) * + (degreeCutoff s d : ℝ) ≤ + (4 * liveProbability B d) * (degreeCutoff s d : ℝ) := + mul_le_mul_of_nonneg_right hα (Nat.cast_nonneg _) + _ ≤ (4 * liveProbability B d) * + ((3 * (s + 1) + 1) * Real.sqrt (d : ℝ)) := + mul_le_mul_of_nonneg_left (degreeCutoff_upper s hs d hd) (by linarith) + _ = factorialBase B s := by + unfold liveProbability factorialBase + field_simp [hrootpos.ne'] + +theorem reverseTheta_le_factorial_tail (α Q : ℝ) (hα : 0 ≤ α) (b k : ℕ) + (hαk : α * (k : ℝ) ≤ Q) : + reverseTheta α b k ≤ + ∑ ℓ ∈ Finset.Ico (b + 1) (k + 1), Q ^ ℓ / (ℓ.factorial : ℝ) := by + have hset : (Finset.range (k + 1)).filter (fun ℓ => b < ℓ) = + Finset.Ico (b + 1) (k + 1) := by + ext ℓ + simp only [Finset.mem_filter, Finset.mem_range, Finset.mem_Ico] + omega + unfold reverseTheta + rw [← Finset.sum_filter, hset] + apply Finset.sum_le_sum + intro ℓ hℓ + calc + (k.choose ℓ : ℝ) * α ^ ℓ ≤ + ((k : ℝ) ^ ℓ / (ℓ.factorial : ℝ)) * α ^ ℓ := + mul_le_mul_of_nonneg_right (Nat.choose_le_pow_div ℓ k) (pow_nonneg hα _) + _ = (α * (k : ℝ)) ^ ℓ / (ℓ.factorial : ℝ) := by + rw [mul_pow] + ring + _ ≤ Q ^ ℓ / (ℓ.factorial : ℝ) := + div_le_div_of_nonneg_right + (pow_le_pow_left₀ (mul_nonneg hα (Nat.cast_nonneg k)) hαk ℓ) + (Nat.cast_nonneg _) + +theorem exists_final_parameter_width (B s : ℝ) (hB : 0 < B) (hs : 0 ≤ s) : + ∃ b : ℕ, 1 ≤ b ∧ ∃ D : ℕ, 1 ≤ D ∧ ∀ d : ℕ, D ≤ d → + 0 < liveProbability B d ∧ liveProbability B d ≤ 1 / 2 ∧ + reverseTheta (2 * liveProbability B d / (1 - liveProbability B d)) + b (degreeCutoff s d) ≤ 1 / 2 := by + have hQ : 0 ≤ factorialBase B s := + mul_nonneg (mul_nonneg (by norm_num) hB.le) (by linarith) + obtain ⟨b, hb, htail⟩ := exists_factorial_tail_width (factorialBase B s) hQ + obtain ⟨D, hD, hprob⟩ := exists_liveProbability_threshold B hB + refine ⟨b, hb, D, hD, ?_⟩ + intro d hd + obtain ⟨hp0, hphalf⟩ := hprob d hd + refine ⟨hp0, hphalf, ?_⟩ + have hα : 0 ≤ 2 * liveProbability B d / (1 - liveProbability B d) := + div_nonneg (by linarith) (by linarith) + exact (reverseTheta_le_factorial_tail _ _ hα b (degreeCutoff s d) + (scaled_cutoff_le_factorialBase B s hB.le hs d (hD.trans hd) hphalf)).trans + (htail (degreeCutoff s d)) + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/FiniteProbability.lean b/lean/OAI/Computability/DepthThree/FiniteProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..db24f832671463cbebb50dadd1f28a8297cd213b --- /dev/null +++ b/lean/OAI/Computability/DepthThree/FiniteProbability.lean @@ -0,0 +1,211 @@ +import OAI.Computability.DepthThree.Core +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Algebra.Order.BigOperators.Ring.Finset +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Data.Fintype.Option +import Mathlib.Tactic.Ring + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 uDepth7 uDepth8 uDepth9 uDepth10 uDepth11 uDepth12 uDepth13 uDepth14 uDepth15 uDepth16 uDepth17 uDepth18 uDepth19 uDepth20 uDepth21 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +abbrev Restriction (V : Type uDepth1) := V → Option Bool +abbrev Live {V : Type uDepth2} (σ : Restriction V) := {v : V // σ v = none} + +def fill {V : Type uDepth3} (σ : Restriction V) (z : Cube (Live σ)) : Cube V := + fun v => if h : σ v = none then z ⟨v, h⟩ else (σ v).getD false + +@[simp] theorem fill_live {V : Type uDepth4} (σ : Restriction V) (z : Cube (Live σ)) + (v : Live σ) : fill σ z v.val = z v := by + simp [fill, v.property] + +@[simp] theorem fill_fixed {V : Type uDepth5} (σ : Restriction V) (z : Cube (Live σ)) + (v : V) (b : Bool) (h : σ v = some b) : fill σ z v = b := by + simp [fill, h] + +def finiteAvg {Ω : Type uDepth6} [Fintype Ω] (f : Ω → ℝ) : ℝ := + (Fintype.card Ω : ℝ)⁻¹ * ∑ ω, f ω + +section Averages + +variable {Ω : Type uDepth7} {Λ : Type uDepth8} [Fintype Ω] [Fintype Λ] + +theorem finiteAvg_congr {f g : Ω → ℝ} (h : ∀ ω, f ω = g ω) : + finiteAvg f = finiteAvg g := by + unfold finiteAvg + congr 1 + exact Finset.sum_congr rfl (fun ω _ => h ω) + +@[simp] theorem finiteAvg_zero : finiteAvg (fun _ : Ω => (0 : ℝ)) = 0 := by + simp [finiteAvg] + +theorem finiteAvg_add (f g : Ω → ℝ) : + finiteAvg (fun ω => f ω + g ω) = finiteAvg f + finiteAvg g := by + simp [finiteAvg, Finset.sum_add_distrib, mul_add] + +theorem finiteAvg_sub (f g : Ω → ℝ) : + finiteAvg (fun ω => f ω - g ω) = finiteAvg f - finiteAvg g := by + simp [finiteAvg, Finset.sum_sub_distrib, mul_sub] + +theorem finiteAvg_const_mul (c : ℝ) (f : Ω → ℝ) : + finiteAvg (fun ω => c * f ω) = c * finiteAvg f := by + unfold finiteAvg + rw [← Finset.mul_sum] + ring + +theorem finiteAvg_mul_const (f : Ω → ℝ) (c : ℝ) : + finiteAvg (fun ω => f ω * c) = finiteAvg f * c := by + unfold finiteAvg + rw [← Finset.sum_mul] + ring + +theorem finiteAvg_sum {ι : Type uDepth9} (s : Finset ι) (f : ι → Ω → ℝ) : + finiteAvg (fun ω => ∑ i ∈ s, f i ω) = ∑ i ∈ s, finiteAvg (f i) := by + classical + simp only [finiteAvg, Finset.mul_sum] + exact Finset.sum_comm + +theorem finiteAvg_nonneg {f : Ω → ℝ} (h : ∀ ω, 0 ≤ f ω) : + 0 ≤ finiteAvg f := by + exact mul_nonneg (inv_nonneg.mpr (Nat.cast_nonneg _)) + (Finset.sum_nonneg (fun ω _ => h ω)) + +theorem finiteAvg_mono {f g : Ω → ℝ} (h : ∀ ω, f ω ≤ g ω) : + finiteAvg f ≤ finiteAvg g := by + exact mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun ω _ => h ω)) + (inv_nonneg.mpr (Nat.cast_nonneg _)) + +theorem finiteAvg_abs_le (f : Ω → ℝ) : + |finiteAvg f| ≤ finiteAvg (fun ω => |f ω|) := by + unfold finiteAvg + rw [abs_mul, abs_of_nonneg (inv_nonneg.mpr (Nat.cast_nonneg _))] + exact mul_le_mul_of_nonneg_left (Finset.abs_sum_le_sum_abs f Finset.univ) + (inv_nonneg.mpr (Nat.cast_nonneg _)) + +@[simp] theorem finiteAvg_const [Nonempty Ω] (c : ℝ) : + finiteAvg (fun _ : Ω => c) = c := by + have hc : (Fintype.card Ω : ℝ) ≠ 0 := by + exact_mod_cast Fintype.card_ne_zero + simp [finiteAvg, nsmul_eq_mul, hc] + +theorem finiteAvg_equiv (e : Ω ≃ Λ) (f : Λ → ℝ) : + finiteAvg (fun ω => f (e ω)) = finiteAvg f := by + unfold finiteAvg + rw [Fintype.card_congr e, e.sum_comp f] + +theorem finiteAvg_comm (f : Ω → Λ → ℝ) : + finiteAvg (fun ω => finiteAvg (f ω)) = + finiteAvg (fun l => finiteAvg (fun ω => f ω l)) := by + simp only [finiteAvg, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro l hl + apply Finset.sum_congr rfl + intro ω hω + ring + +theorem finiteAvg_product (f : Ω × Λ → ℝ) : + finiteAvg f = finiteAvg (fun ω => finiteAvg (fun l => f (ω, l))) := by + simp only [finiteAvg, Fintype.card_prod, Nat.cast_mul, mul_inv, + Fintype.sum_prod_type, Finset.mul_sum] + apply Finset.sum_congr rfl + intro ω hω + apply Finset.sum_congr rfl + intro l hl + ring + +theorem finiteAvg_pi_prod {ι : Type uDepth10} [Fintype ι] + {κ : ι → Type uDepth21} [∀ i, Fintype (κ i)] (f : ∀ i, κ i → ℝ) : + finiteAvg (fun x : ∀ i, κ i => ∏ i, f i (x i)) = + ∏ i, finiteAvg (f i) := by + classical + unfold finiteAvg + rw [Fintype.card_pi, Nat.cast_prod, ← Fintype.prod_sum] + rw [Finset.prod_mul_distrib, Finset.prod_inv_distrib] + +end Averages + +def restrictionCoordinateWeight (p : ℝ) : Option Bool → ℝ + | none => p + | some _ => (1 - p) / 2 + +def restrictionWeight {V : Type uDepth11} [Fintype V] (p : ℝ) (σ : Restriction V) : ℝ := + ∏ v, restrictionCoordinateWeight p (σ v) + +def restrictionAvg {V : Type uDepth12} [Fintype V] (p : ℝ) + (F : Restriction V → ℝ) : ℝ := + ∑ σ, restrictionWeight p σ * F σ + +@[simp] theorem restrictionCoordinateWeight_sum (p : ℝ) : + (∑ a : Option Bool, restrictionCoordinateWeight p a) = 1 := by + simp [Fintype.sum_option, restrictionCoordinateWeight] + ring + +theorem restrictionCoordinateWeight_nonneg {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) + (a : Option Bool) : 0 ≤ restrictionCoordinateWeight p a := by + cases a with + | none => exact hp + | some b => exact div_nonneg (sub_nonneg.mpr hp1) (by norm_num) + +theorem restrictionWeight_nonneg {V : Type uDepth13} [Fintype V] {p : ℝ} + (hp : 0 ≤ p) (hp1 : p ≤ 1) (σ : Restriction V) : + 0 ≤ restrictionWeight p σ := by + exact Finset.prod_nonneg (fun v _ => restrictionCoordinateWeight_nonneg hp hp1 (σ v)) + +@[simp] theorem restrictionWeight_sum {V : Type uDepth14} [Fintype V] (p : ℝ) : + (∑ σ : Restriction V, restrictionWeight p σ) = 1 := by + classical + unfold restrictionWeight + rw [← Fintype.prod_sum] + simp only [restrictionCoordinateWeight_sum, Finset.prod_const_one] + +@[simp] theorem restrictionAvg_const {V : Type uDepth15} [Fintype V] (p c : ℝ) : + restrictionAvg p (fun _ : Restriction V => c) = c := by + simp [restrictionAvg, ← Finset.sum_mul] + +theorem restrictionAvg_nonneg {V : Type uDepth16} [Fintype V] {p : ℝ} + (hp : 0 ≤ p) (hp1 : p ≤ 1) {F : Restriction V → ℝ} + (hF : ∀ σ, 0 ≤ F σ) : 0 ≤ restrictionAvg p F := by + exact Finset.sum_nonneg (fun σ _ => + mul_nonneg (restrictionWeight_nonneg hp hp1 σ) (hF σ)) + +theorem restrictionAvg_mono {V : Type uDepth17} [Fintype V] {p : ℝ} + (hp : 0 ≤ p) (hp1 : p ≤ 1) {F G : Restriction V → ℝ} + (h : ∀ σ, F σ ≤ G σ) : restrictionAvg p F ≤ restrictionAvg p G := by + exact Finset.sum_le_sum (fun σ _ => + mul_le_mul_of_nonneg_left (h σ) (restrictionWeight_nonneg hp hp1 σ)) + +theorem restrictionAvg_add {V : Type uDepth18} [Fintype V] (p : ℝ) + (F G : Restriction V → ℝ) : + restrictionAvg p (fun σ => F σ + G σ) = restrictionAvg p F + restrictionAvg p G := by + simp [restrictionAvg, mul_add, Finset.sum_add_distrib] + +theorem restrictionAvg_const_mul {V : Type uDepth19} [Fintype V] (p c : ℝ) + (F : Restriction V → ℝ) : + restrictionAvg p (fun σ => c * F σ) = c * restrictionAvg p F := by + simp [restrictionAvg, Finset.mul_sum, mul_left_comm] + +theorem restrictionAvg_abs_le {V : Type uDepth20} [Fintype V] {p : ℝ} + (hp : 0 ≤ p) (hp1 : p ≤ 1) (F : Restriction V → ℝ) : + |restrictionAvg p F| ≤ restrictionAvg p (fun σ => |F σ|) := by + unfold restrictionAvg + calc + _ ≤ ∑ σ, |restrictionWeight p σ * F σ| := + Finset.abs_sum_le_sum_abs _ _ + _ = _ := by + apply Finset.sum_congr rfl + intro σ hσ + rw [abs_mul, abs_of_nonneg (restrictionWeight_nonneg hp hp1 σ)] + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/FiniteProbabilityBounds.lean b/lean/OAI/Computability/DepthThree/FiniteProbabilityBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a7d828e2133e388537bbd39a90fce94473b3281 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/FiniteProbabilityBounds.lean @@ -0,0 +1,113 @@ +import OAI.Computability.DepthThree.FiniteProbability +import Mathlib.Data.Finset.Max +import Mathlib.Tactic.Linarith + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +def finiteProb {Ω : Type uDepth1} [Fintype Ω] (P : Ω → Prop) : ℝ := + finiteAvg (fun ω => if P ω then 1 else 0) + +variable {Ω : Type uDepth2} {Λ : Type uDepth3} [Fintype Ω] [Fintype Λ] + +theorem finiteProb_nonneg (P : Ω → Prop) : 0 ≤ finiteProb P := by + apply finiteAvg_nonneg + intro ω + split_ifs <;> norm_num + +theorem finiteProb_le_one [Nonempty Ω] (P : Ω → Prop) : finiteProb P ≤ 1 := by + have h : finiteProb P ≤ finiteAvg (fun _ : Ω => (1 : ℝ)) := by + apply finiteAvg_mono + intro ω + split_ifs <;> norm_num + simpa using h + +theorem finiteProb_mono {P Q : Ω → Prop} (h : ∀ ω, P ω → Q ω) : + finiteProb P ≤ finiteProb Q := by + apply finiteAvg_mono + intro ω + by_cases hp : P ω + · simp [hp, h ω hp] + · simp only [hp, ite_false] + split_ifs <;> norm_num + +theorem finiteAvg_exists_le [Nonempty Ω] (f : Ω → ℝ) : + ∃ ω, f ω ≤ finiteAvg f := by + obtain ⟨ω, hω, hmin⟩ := Finset.exists_min_image Finset.univ f Finset.univ_nonempty + refine ⟨ω, ?_⟩ + have h := finiteAvg_mono (fun x => hmin x (Finset.mem_univ x)) + simpa using h + +theorem finiteAvg_exists_le_of_le [Nonempty Ω] (f : Ω → ℝ) (c : ℝ) + (h : finiteAvg f ≤ c) : ∃ ω, f ω ≤ c := by + obtain ⟨ω, hω⟩ := finiteAvg_exists_le f + exact ⟨ω, hω.trans h⟩ + +theorem finiteProb_gt_le {f : Ω → ℝ} (hf : ∀ ω, 0 ≤ f ω) + {a : ℝ} (ha : 0 < a) : + finiteProb (fun ω => a < f ω) ≤ finiteAvg f / a := by + have h : finiteAvg (fun ω => a * (if a < f ω then 1 else 0)) ≤ finiteAvg f := by + apply finiteAvg_mono + intro ω + by_cases hω : a < f ω + · simpa [hω] using hω.le + · simpa [hω] using hf ω + rw [finiteAvg_const_mul] at h + apply (le_div_iff₀ ha).mpr + simpa only [finiteProb, mul_comm] using h + +theorem finiteProb_exists_le_sum {ι : Type uDepth4} (s : Finset ι) (P : ι → Ω → Prop) : + finiteProb (fun ω => ∃ i ∈ s, P i ω) ≤ ∑ i ∈ s, finiteProb (P i) := by + have h : finiteProb (fun ω => ∃ i ∈ s, P i ω) ≤ + finiteAvg (fun ω => ∑ i ∈ s, if P i ω then (1 : ℝ) else 0) := by + apply finiteAvg_mono + intro ω + by_cases he : ∃ i ∈ s, P i ω + · obtain ⟨i, hi, hPi⟩ := he + have hs : (if P i ω then (1 : ℝ) else 0) ≤ + ∑ j ∈ s, if P j ω then (1 : ℝ) else 0 := by + apply Finset.single_le_sum _ hi + intro j hj + split_ifs <;> norm_num + simpa [show ∃ i ∈ s, P i ω from ⟨i, hi, hPi⟩, hPi] using hs + · simp only [he, ite_false] + apply Finset.sum_nonneg + intro i hi + split_ifs <;> norm_num + simpa only [finiteAvg_sum, finiteProb] using h + +theorem finiteProb_abs_gt_le_moment (f : Ω → ℝ) (t : ℕ) (ht : 0 < t) + (a C : ℝ) (ha : 0 < a) + (hM : finiteAvg (fun ω => |f ω| ^ t) ≤ C) : + finiteProb (fun ω => a < |f ω|) ≤ C / a ^ t := by + have he : finiteProb (fun ω => a < |f ω|) ≤ + finiteProb (fun ω => a ^ t < |f ω| ^ t) := by + apply finiteProb_mono + intro ω hω + exact pow_lt_pow_left₀ hω ha.le (Nat.ne_of_gt ht) + have hmark := finiteProb_gt_le (fun ω => pow_nonneg (abs_nonneg (f ω)) t) + (pow_pos ha t) + exact he.trans (hmark.trans (div_le_div_of_nonneg_right hM (pow_nonneg ha.le t))) + +theorem finiteAvg_restrictionAvg {V : Type uDepth5} [Fintype V] (p : ℝ) + (F : Ω → Restriction V → ℝ) : + finiteAvg (fun ω => restrictionAvg p (F ω)) = + restrictionAvg p (fun σ => finiteAvg (fun ω => F ω σ)) := by + unfold restrictionAvg + rw [finiteAvg_sum] + apply Finset.sum_congr rfl + intro σ hσ + exact finiteAvg_const_mul _ _ + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/HardSlice.lean b/lean/OAI/Computability/DepthThree/HardSlice.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6476559a1671933bbd20c0cb0257f2236266480 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/HardSlice.lean @@ -0,0 +1,44 @@ +import OAI.Computability.DepthThree.HardSliceEventual +import OAI.Computability.DepthThree.WideCorrelation + +namespace OAI + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +theorem exists_language_slice_small_correlations (s : ℝ) (hs : 0 ≤ s) : + ∃ N : ℕ, 20480 ≤ N ∧ ∀ n : ℕ, N ≤ n → + ∃ α : Fin n → Sum (Fin (dataDimension n)) Bool, + ∀ H : CNF (Fin (dataDimension n)), + H.WidthAtMost (degreeCutoff s (dataDimension n)) → + |finiteAvg (fun x => + sign (language (List.ofFn (GateInput.assignment α x))) * indicator (H.eval x))| ≤ + 6 * (2 : ℝ) ^ (-(64 * (s + 1) * Real.sqrt (dataDimension n : ℝ)) / 16) := by + let B : ℝ := 64 * (s + 1) + have hB : 0 < B := by dsimp [B]; linarith + obtain ⟨b, hb, D, hD, hparams⟩ := exists_final_parameter_width B s hB hs + obtain ⟨Ng, hNg, hgood⟩ := exists_good_language_slice_eventually b hb B hB + refine ⟨max Ng (5 * D), hNg.trans (le_max_left _ _), ?_⟩ + intro n hn + have hng : Ng ≤ n := (le_max_left _ _).trans hn + have hnd : 5 * D ≤ n := (le_max_right _ _).trans hn + have hDd : D ≤ dataDimension n := by unfold dataDimension; omega + obtain ⟨hp0, hphalf, hθ⟩ := hparams (dataDimension n) hDd + have hp1 : liveProbability B (dataDimension n) < 1 := by linarith + have hθ' : restrictionTheta (degreeCutoff s (dataDimension n)) b + (liveProbability B (dataDimension n)) ≤ 1 / 2 := by + simpa only [restrictionTheta_eq_reverseTheta] using hθ + obtain ⟨α, hα⟩ := hgood n hng + refine ⟨α, ?_⟩ + exact wide_correlation_of_good_restrictions hp0 hp1 + (Real.rpow_nonneg (by norm_num) _) b (degreeCutoff s (dataDimension n)) hb hθ' + (fun x => language (List.ofFn (GateInput.assignment α x))) hα + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/HardSliceEventual.lean b/lean/OAI/Computability/DepthThree/HardSliceEventual.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c696fc4ccdecee3767177e665746596fffcfa8b --- /dev/null +++ b/lean/OAI/Computability/DepthThree/HardSliceEventual.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DepthThree.HardSliceExistence +import OAI.Computability.DepthThree.HardSliceParameters +import OAI.Computability.DepthThree.FinalParameterBounds +import OAI.Computability.DepthThree.IrreducibleEncoding +import OAI.Computability.DepthThree.LanguageSlice + +namespace OAI + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +theorem exists_good_language_slice_eventually (b : ℕ) (hb : 1 ≤ b) + (B : ℝ) (hB : 0 < B) : + ∃ N : ℕ, 20480 ≤ N ∧ ∀ n : ℕ, N ≤ n → + ∃ α : Fin n → Sum (Fin (dataDimension n)) Bool, + restrictionAvg (liveProbability B (dataDimension n)) (fun σ => + if ¬ goodRestriction (liveProbability B (dataDimension n)) + ((2 : ℝ) ^ (-(B * Real.sqrt (dataDimension n : ℝ)) / 16)) b + (fun x => language (List.ofFn (GateInput.assignment α x))) σ + then 1 else 0) ≤ + 4 * (2 : ℝ) ^ (-(B * Real.sqrt (dataDimension n : ℝ)) / 16) := by + obtain ⟨De, hDe, herr⟩ := actual_hard_slice_error_bound_eventually b hb B hB + obtain ⟨Dp, hDp, hprob⟩ := exists_liveProbability_threshold B hB + let D := max De Dp + refine ⟨5 * D, ?_, ?_⟩ + · have hbig : 4096 ≤ D := hDe.trans (le_max_left _ _) + omega + intro n hn + let d := dataDimension n + have hDd : D ≤ d := by + dsimp [d, dataDimension] + omega + have hde : De ≤ d := (le_max_left _ _).trans hDd + have hdp : Dp ≤ d := (le_max_right _ _).trans hDd + have hd4096 : 4096 ≤ d := hDe.trans hde + have hdpos : 0 < d := by omega + have hr : 0 < hashDimension d := hashDimension_pos hdpos + have ht2 : 2 ≤ independenceOrder d := (independenceOrder_two_le_iff d).mpr (by omega) + obtain ⟨h, hh⟩ := independenceOrder_even d + have heven : 2 * h = independenceOrder d := by omega + have hhpos : 0 < h := by omega + obtain ⟨hq0, hqhalf⟩ := hprob d hdp + have hq1 : liveProbability B d ≤ 1 := by linarith + obtain ⟨p, hp⟩ := exists_irreducible_inputPolynomialBits (hashDimension d) hr + let : Fact (Irreducible (BinaryAlgebra.inputPolynomialBits p)) := ⟨hp⟩ + have hbound (m : ℕ) + (hmlo : (liveProbability B d * d) / 2 ≤ (m : ℝ)) + (hmhi : (m : ℝ) ≤ 2 * (liveProbability B d * d)) : + (2 : ℝ) ^ m / (2 : ℝ) ^ hashDimension d + + sparseMomentBound m b (hardSliceSparseConstant b hb * m) h + ((2 : ℝ) ^ (-(m : ℝ) / 4)) ≤ + 2 * (2 : ℝ) ^ (-(liveProbability B d * d) / 16) := by + rw [liveProbability_mul_dimension B d hdpos] at hmlo hmhi ⊢ + exact herr d hde m h hmlo hmhi heven + have hex : ∃ (u : Fin (d + hashDimension d - 1) → Bool) + (β : Fin (independenceOrder d) → BinaryAlgebra.BitQuotient p), + restrictionAvg (liveProbability B d) (fun σ => + if ¬ goodRestriction (liveProbability B d) + ((2 : ℝ) ^ (-(B * Real.sqrt (d : ℝ)) / 16)) b + (hashAcceptance p (independenceOrder d) u β) σ then 1 else 0) ≤ + 4 * (2 : ℝ) ^ (-(B * Real.sqrt (d : ℝ)) / 16) := by + rw [← heven] + simpa only [liveProbability_mul_dimension B d hdpos] using + exists_good_hash_coefficients p hr hb hhpos (liveProbability B d) hq0.le hq1 hbound + obtain ⟨u, β, hβ⟩ := hex + let c := coefficientInputBits p β + let α : Fin n → Sum (Fin (dataDimension n)) Bool := canonicalSlice n u p c + have hfit : blockLen d ≤ n := + (blockLen_le_five_mul d hd4096).trans (five_mul_dataDimension_le n) + have heval : (fun x => language (List.ofFn (GateInput.assignment α x))) = + hashAcceptance p (independenceOrder d) u β := by + funext x + rw [language_canonicalSlice_acceptEval n u p c x hdpos ht2 hfit] + change hashAcceptance p (independenceOrder d) u + (fun j => BinaryAlgebra.encode (fun i => BinaryAlgebra.bitValue (p i)) + (fun i => BinaryAlgebra.bitValue (coefficientInputBits p β j i))) x = _ + rw [hashAcceptance_coefficientInputBits] + refine ⟨α, ?_⟩ + rw [heval] + exact hβ + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/HardSliceExistence.lean b/lean/OAI/Computability/DepthThree/HardSliceExistence.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba4c2ad76abfc8e07500226111cb2f2d672382af --- /dev/null +++ b/lean/OAI/Computability/DepthThree/HardSliceExistence.lean @@ -0,0 +1,90 @@ +import OAI.Computability.DepthThree.HardSliceProbability +import OAI.Computability.DepthThree.HardSliceSelection + +namespace OAI + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +theorem actual_hash_coefficient_window_failure_le {d r h b : ℕ} + (p : Fin r → Bool) [Fact (Irreducible (BinaryAlgebra.inputPolynomialBits p))] + (hr : 0 < r) (hb : 1 ≤ b) (hh : 0 < h) (q : ℝ) + (σ : Restriction (Fin d)) (hσ : restrictionWindow q σ) + (hbound : + (2 : ℝ) ^ Fintype.card (Live σ) / (2 : ℝ) ^ r + + sparseMomentBound (Fintype.card (Live σ)) b + (hardSliceSparseConstant b hb * Fintype.card (Live σ)) h + ((2 : ℝ) ^ (-(Fintype.card (Live σ) : ℝ) / 4)) ≤ + 2 * (2 : ℝ) ^ (-(q * d) / 16)) : + finiteProb (fun ω : (Fin (d + r - 1) → Bool) × + (Fin (2 * h) → BinaryAlgebra.BitQuotient p) => + ¬ corr b (fun z => sign (hashAcceptance p (2 * h) ω.1 ω.2 (fill σ z))) ≤ + (2 : ℝ) ^ (-(q * d) / 16)) ≤ + 2 * (2 : ℝ) ^ (-(q * d) / 16) := by + have hlow : (q * d) / 2 ≤ (Fintype.card (Live σ) : ℝ) := by + simpa only [restrictionWindow, Fintype.card_fin] using hσ.1 + have hthreshold : (2 : ℝ) ^ (-(Fintype.card (Live σ) : ℝ) / 8) ≤ + (2 : ℝ) ^ (-(q * d) / 16) := + Real.rpow_le_rpow_of_exponent_le (by norm_num) (by linarith) + apply le_trans _ ((actual_hash_coefficient_failure_le p hr σ b hb h hh).trans hbound) + apply finiteProb_mono + intro ω hω hsmall + exact hω (hsmall.trans hthreshold) + +theorem exists_good_hash_coefficients {d r h b : ℕ} + (p : Fin r → Bool) [Fact (Irreducible (BinaryAlgebra.inputPolynomialBits p))] + (hr : 0 < r) (hb : 1 ≤ b) (hh : 0 < h) (q : ℝ) + (hq : 0 ≤ q) (hq1 : q ≤ 1) + (hbound : ∀ m : ℕ, (q * d) / 2 ≤ (m : ℝ) → (m : ℝ) ≤ 2 * (q * d) → + (2 : ℝ) ^ m / (2 : ℝ) ^ r + + sparseMomentBound m b (hardSliceSparseConstant b hb * m) h + ((2 : ℝ) ^ (-(m : ℝ) / 4)) ≤ 2 * (2 : ℝ) ^ (-(q * d) / 16)) : + ∃ (u : Fin (d + r - 1) → Bool) (β : Fin (2 * h) → BinaryAlgebra.BitQuotient p), + restrictionAvg q (fun σ => if ¬ goodRestriction q + ((2 : ℝ) ^ (-(q * d) / 16)) b (hashAcceptance p (2 * h) u β) σ + then 1 else 0) ≤ 4 * (2 : ℝ) ^ (-(q * d) / 16) := by + have hfixed (σ : Restriction (Fin d)) (hσ : restrictionWindow q σ) : + finiteProb (fun ω : (Fin (d + r - 1) → Bool) × + (Fin (2 * h) → BinaryAlgebra.BitQuotient p) => + ¬ corr b (fun z => sign (hashAcceptance p (2 * h) ω.1 ω.2 (fill σ z))) ≤ + (2 : ℝ) ^ (-(q * d) / 16)) ≤ + 2 * (2 : ℝ) ^ (-(q * d) / 16) := by + apply actual_hash_coefficient_window_failure_le p hr hb hh q σ hσ + apply hbound + · simpa only [restrictionWindow, Fintype.card_fin] using hσ.1 + · simpa only [restrictionWindow, Fintype.card_fin] using hσ.2 + obtain ⟨ω, hω⟩ := exists_good_parameter hq hq1 b + (fun ω : (Fin (d + r - 1) → Bool) × (Fin (2 * h) → BinaryAlgebra.BitQuotient p) => + hashAcceptance p (2 * h) ω.1 ω.2) + (by simpa only [Fintype.card_fin] using hfixed) + exact ⟨ω.1, ω.2, by simpa only [Fintype.card_fin] using hω⟩ + +def coefficientInputBits {r t : ℕ} (p : Fin r → Bool) + (β : Fin t → BinaryAlgebra.BitQuotient p) : Fin t → Fin r → Bool := + fun j i => BinaryAlgebra.fieldBit + (BinaryAlgebra.coordinates (fun i => BinaryAlgebra.bitValue (p i)) (β j) i) + +@[simp] theorem encode_coefficientInputBits {r t : ℕ} (p : Fin r → Bool) + (β : Fin t → BinaryAlgebra.BitQuotient p) (j : Fin t) : + BinaryAlgebra.encode (fun i => BinaryAlgebra.bitValue (p i)) + (fun i => BinaryAlgebra.bitValue (coefficientInputBits p β j i)) = β j := by + simp only [coefficientInputBits, BinaryAlgebra.bitValue_fieldBit] + exact BinaryAlgebra.encode_coordinates _ _ + +theorem hashAcceptance_coefficientInputBits {d r t : ℕ} (p : Fin r → Bool) + [Fact (Irreducible (BinaryAlgebra.inputPolynomialBits p))] + (u : Fin (d + r - 1) → Bool) (β : Fin t → BinaryAlgebra.BitQuotient p) : + hashAcceptance p t u + (fun j => BinaryAlgebra.encode (fun i => BinaryAlgebra.bitValue (p i)) + (fun i => BinaryAlgebra.bitValue (coefficientInputBits p β j i))) = + hashAcceptance p t u β := by + simp only [encode_coefficientInputBits] + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/HardSliceMoment.lean b/lean/OAI/Computability/DepthThree/HardSliceMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..714ae329434f8594426645e68a655771b3e38ba4 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/HardSliceMoment.lean @@ -0,0 +1,115 @@ +import OAI.Computability.DepthThree.MomentBounds +import OAI.Computability.DepthThree.FiniteProbabilityBounds +import OAI.Computability.DepthThree.SparseTestCodes +import OAI.Computability.DepthThree.InterpolationSigns + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 uDepth7 uDepth8 uDepth9 uDepth10 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +theorem finiteProb_abs_avg_gt_le {Ω : Type uDepth1} {Z : Type uDepth2} [Fintype Ω] [Nonempty Ω] + [Fintype Z] [Nonempty Z] [DecidableEq Z] + (h : ℕ) (hh : 0 < h) (bits : Ω → Z → Bool) + (hdist : UniformBitsUpTo (2 * h) bits) (J : Z → Bool) + (δ : ℝ) (hδ : 0 < δ) : + finiteProb (fun ω => δ < |finiteAvg (fun z => sign (bits ω z) * indicator (J z))|) ≤ + (((2 * h : ℕ) : ℝ) ^ (2 * h) * (Fintype.card Z : ℝ) ^ h) / + (δ * (Fintype.card Z : ℝ)) ^ (2 * h) := by + have hN : 0 < (Fintype.card Z : ℝ) := by exact_mod_cast Fintype.card_pos + have hnorm (ω : Ω) : + |finiteAvg (fun z => sign (bits ω z) * indicator (J z))| = + |∑ z, sign (bits ω z) * indicator (J z)| / (Fintype.card Z : ℝ) := by + rw [finiteAvg, abs_mul, abs_inv, abs_of_nonneg hN.le, div_eq_inv_mul] + have hevent : + finiteProb (fun ω => δ < |finiteAvg (fun z => sign (bits ω z) * indicator (J z))|) ≤ + finiteProb (fun ω => δ * (Fintype.card Z : ℝ) < + |∑ z, sign (bits ω z) * indicator (J z)|) := by + apply finiteProb_mono + intro ω hω + rw [hnorm ω] at hω + exact (lt_div_iff₀ hN).mp hω + exact hevent.trans (finiteProb_abs_gt_le_moment + (fun ω => ∑ z, sign (bits ω z) * indicator (J z)) + (2 * h) (Nat.mul_pos (by decide) hh) + (δ * (Fintype.card Z : ℝ)) + (((2 * h : ℕ) : ℝ) ^ (2 * h) * (Fintype.card Z : ℝ) ^ h) + (mul_pos hδ hN) (even_moment_le_manuscript h bits hdist J)) + +def sparseMomentBound (m b L h : ℕ) (δ : ℝ) : ℝ := + ((((2 * m + 1) ^ b + 1) ^ L : ℕ) : ℝ) * + ((((2 * h : ℕ) : ℝ) ^ (2 * h) * ((2 ^ m : ℕ) : ℝ) ^ h) / + (δ * ((2 ^ m : ℕ) : ℝ)) ^ (2 * h)) + +theorem finiteProb_sparse_codes_gt_le {Ω : Type uDepth3} {V : Type uDepth4} [Fintype Ω] [Nonempty Ω] + [Fintype V] (b L h : ℕ) (hh : 0 < h) + (bits : Ω → Cube V → Bool) (hdist : UniformBitsUpTo (2 * h) bits) + (δ : ℝ) (hδ : 0 < δ) : + finiteProb (fun ω => ∃ c : SparseTestCode V b L, + δ < |finiteAvg (fun x => sign (bits ω x) * indicator (c.eval x))|) ≤ + sparseMomentBound (Fintype.card V) b L h δ := by + let P : SparseTestCode V b L → Ω → Prop := fun c ω => + δ < |finiteAvg (fun x => sign (bits ω x) * indicator (c.eval x))| + let B : ℝ := + (((2 * h : ℕ) : ℝ) ^ (2 * h) * (Fintype.card (Cube V) : ℝ) ^ h) / + (δ * (Fintype.card (Cube V) : ℝ)) ^ (2 * h) + have hsingle (c : SparseTestCode V b L) : finiteProb (P c) ≤ B := + finiteProb_abs_avg_gt_le h hh bits hdist c.eval δ hδ + calc + _ ≤ ∑ c : SparseTestCode V b L, finiteProb (P c) := by + simpa only [P, Finset.mem_univ, true_and] using + (finiteProb_exists_le_sum (Finset.univ : Finset (SparseTestCode V b L)) P) + _ ≤ ∑ _c : SparseTestCode V b L, B := + Finset.sum_le_sum (fun c _ => hsingle c) + _ = (Fintype.card (SparseTestCode V b L) : ℝ) * B := by + simp [nsmul_eq_mul] + _ = sparseMomentBound (Fintype.card V) b L h δ := by + simp [B, sparseMomentBound, Cube, + Fintype.card_bool, mul_comm] + +theorem finiteProb_sparse_cnfs_gt_le {Ω : Type uDepth5} {V : Type uDepth6} [Fintype Ω] [Nonempty Ω] + [Fintype V] (b L h : ℕ) (hh : 0 < h) + (bits : Ω → Cube V → Bool) (hdist : UniformBitsUpTo (2 * h) bits) + (δ : ℝ) (hδ : 0 < δ) : + finiteProb (fun ω => ∃ H : CNF V, H.WidthAtMost b ∧ H.length ≤ L ∧ + δ < |finiteAvg (fun x => sign (bits ω x) * indicator (H.eval x))|) ≤ + sparseMomentBound (Fintype.card V) b L h δ := by + apply le_trans _ (finiteProb_sparse_codes_gt_le b L h hh bits hdist δ hδ) + apply finiteProb_mono + rintro ω ⟨H, hw, hlen, hbad⟩ + obtain ⟨c, hc⟩ := SparseTestCode.exists_eval_eq H hw hlen + refine ⟨c, ?_⟩ + simpa only [hc] using hbad + +theorem acceptEval_uniformBitsUpTo {F : Type uDepth7} {Z : Type uDepth8} [Field F] + [Module BinaryAlgebra.F2 F] [Fintype F] [DecidableEq Z] + (ell : F →ₗ[BinaryAlgebra.F2] BinaryAlgebra.F2) (hOne : ell 1 = 1) + (t : ℕ) (a : Z → F) (ha : Function.Injective a) : + UniformBitsUpTo t (Interpolation.acceptEval ell t a) := by + intro s hs Φ + exact Interpolation.finiteAvg_acceptEval_finset ell hOne a s hs + (fun _ _ _ _ hxy => ha hxy) Φ + +theorem coefficient_sparse_cnfs_gt_le {F : Type uDepth9} {V : Type uDepth10} [Field F] + [Module BinaryAlgebra.F2 F] [Fintype F] [Fintype V] + (ell : F →ₗ[BinaryAlgebra.F2] BinaryAlgebra.F2) (hOne : ell 1 = 1) + (a : Cube V → F) (ha : Function.Injective a) + (b L h : ℕ) (hh : 0 < h) (δ : ℝ) (hδ : 0 < δ) : + finiteProb (fun β : Fin (2 * h) → F => + ∃ H : CNF V, H.WidthAtMost b ∧ H.length ≤ L ∧ + δ < |finiteAvg (fun x => + sign (Interpolation.acceptEval ell (2 * h) a β x) * indicator (H.eval x))|) ≤ + sparseMomentBound (Fintype.card V) b L h δ := by + exact finiteProb_sparse_cnfs_gt_le b L h hh _ + (acceptEval_uniformBitsUpTo ell hOne (2 * h) a ha) δ hδ + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/HardSliceParameters.lean b/lean/OAI/Computability/DepthThree/HardSliceParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..47412d053435eda7f48ea8fcf16d2c08d7848c4c --- /dev/null +++ b/lean/OAI/Computability/DepthThree/HardSliceParameters.lean @@ -0,0 +1,144 @@ +import OAI.Computability.DepthThree.LanguageParameterBounds +import OAI.Computability.DepthThree.SparseTailBounds +import OAI.Computability.DepthThree.HardSliceMoment +import OAI.Computability.DepthThree.HardSliceProbability + +namespace OAI + +noncomputable section + +open Filter +open scoped Topology + +namespace DepthThreeLowerBound + +theorem sparseMomentBound_at_quarter (m b L h : ℕ) : + sparseMomentBound m b L h ((2 : ℝ) ^ (-(m : ℝ) / 4)) = + (Fintype.card (SparseTestCode (Fin m) b L) : ℝ) * + ((2 * h : ℕ) : ℝ) ^ (2 * h) * + (2 : ℝ) ^ (-((m : ℝ) * ((2 * h : ℕ) : ℝ)) / 4) := by + have hbase : ((2 ^ m : ℕ) : ℝ) = (2 : ℝ) ^ (m : ℝ) := by simp + have hratio : ((2 ^ m : ℕ) : ℝ) ^ h / + (((2 : ℝ) ^ (-(m : ℝ) / 4)) * ((2 ^ m : ℕ) : ℝ)) ^ (2 * h) = + (2 : ℝ) ^ (-((m : ℝ) * ((2 * h : ℕ) : ℝ)) / 4) := by + rw [hbase, ← Real.rpow_add (by norm_num : (0 : ℝ) < 2), + ← Real.rpow_mul_natCast (by norm_num : (0 : ℝ) ≤ 2), + ← Real.rpow_mul_natCast (by norm_num : (0 : ℝ) ≤ 2), + ← Real.rpow_sub (by norm_num : (0 : ℝ) < 2)] + congr 1 + push_cast + ring + have hcard : (Fintype.card (SparseTestCode (Fin m) b L) : ℝ) = + ((((2 * m + 1) ^ b + 1) ^ L : ℕ) : ℝ) := by + simp only [SparseTestCode.card_eq, Fintype.card_fin] + unfold sparseMomentBound + rw [← hcard, mul_div_assoc, hratio] + ring + +theorem sparseMomentBound_quarter_le (m b M h : ℕ) (hm : 0 < m) (hh : 0 < h) + (hcond : (M : ℝ) * + (1 + (b : ℝ) * (Real.log (2 * (m : ℝ) + 1) / Real.log 2)) / + ((2 * h : ℕ) : ℝ) + (Real.log ((2 * h : ℕ) : ℝ) / Real.log 2) / + (m : ℝ) ≤ 1 / 8) : + sparseMomentBound m b (M * m) h ((2 : ℝ) ^ (-(m : ℝ) / 4)) ≤ + (2 : ℝ) ^ (-((m : ℝ) * ((2 * h : ℕ) : ℝ)) / 8) := by + rw [sparseMomentBound_at_quarter] + simpa only [Fintype.card_fin] using + sparse_moment_union_le (V := Fin m) b M (2 * h) + (by simpa only [Fintype.card_fin] using hm) + (Nat.mul_pos (by decide) hh) + (by simpa only [Fintype.card_fin] using hcond) + +theorem exists_hashDimension_dominates (B : ℝ) : + ∃ D : ℕ, 1 ≤ D ∧ ∀ d : ℕ, D ≤ d → + (33 / 16 : ℝ) * (B * Real.sqrt (d : ℝ)) ≤ (hashDimension d : ℝ) := by + have hg : ∀ᶠ x : ℝ in atTop, (33 / 16 : ℝ) * B ≤ x ^ (1 / 6 : ℝ) := + (tendsto_rpow_atTop (by norm_num : (0 : ℝ) < 1 / 6)).eventually + (eventually_ge_atTop ((33 / 16 : ℝ) * B)) + obtain ⟨R, hR⟩ := eventually_atTop.mp hg + obtain ⟨D, hD⟩ := exists_nat_ge (max 1 R) + have hDone : (1 : ℝ) ≤ (D : ℝ) := (le_max_left 1 R).trans hD + refine ⟨D, by exact_mod_cast hDone, ?_⟩ + intro d hd + have hDd : (D : ℝ) ≤ (d : ℝ) := by exact_mod_cast hd + have hdpos : (0 : ℝ) < d := lt_of_lt_of_le zero_lt_one (hDone.trans hDd) + have hpower := hR (d : ℝ) ((le_max_right 1 R).trans (hD.trans hDd)) + calc + _ = ((33 / 16 : ℝ) * B) * Real.sqrt (d : ℝ) := by ring + _ ≤ (d : ℝ) ^ (1 / 6 : ℝ) * Real.sqrt (d : ℝ) := + mul_le_mul_of_nonneg_right hpower (Real.sqrt_nonneg _) + _ = (d : ℝ) ^ (2 / 3 : ℝ) := by + rw [Real.sqrt_eq_rpow, ← Real.rpow_add hdpos] + norm_num + _ ≤ (hashDimension d : ℝ) := hashDimension_rpow_lower d + +theorem hard_slice_error_bound_eventually (b M : ℕ) (B : ℝ) (hB : 0 < B) : + ∃ D : ℕ, 4096 ≤ D ∧ ∀ d : ℕ, D ≤ d → ∀ m h : ℕ, + B * Real.sqrt (d : ℝ) / 2 ≤ (m : ℝ) → + (m : ℝ) ≤ 2 * (B * Real.sqrt (d : ℝ)) → + 2 * h = independenceOrder d → + (2 : ℝ) ^ ((m : ℝ) - (hashDimension d : ℝ)) + + sparseMomentBound m b (M * m) h ((2 : ℝ) ^ (-(m : ℝ) / 4)) ≤ + 2 * (2 : ℝ) ^ (-(B * Real.sqrt (d : ℝ)) / 16) := by + obtain ⟨Ds, hDs, hSparse⟩ := uniform_sparse_condition (b : ℝ) (M : ℝ) B + (Nat.cast_nonneg _) (Nat.cast_nonneg _) hB + obtain ⟨Dr, hDr, hHash⟩ := exists_hashDimension_dominates B + refine ⟨max 4096 (max Ds Dr), le_max_left _ _, ?_⟩ + intro d hd m h hmlo hmhi heven + have hd4096 : 4096 ≤ d := (le_max_left _ _).trans hd + have hds : Ds ≤ d := (le_max_left Ds Dr).trans ((le_max_right _ _).trans hd) + have hdr : Dr ≤ d := (le_max_right Ds Dr).trans ((le_max_right _ _).trans hd) + have hdpos : (0 : ℝ) < d := by exact_mod_cast (by omega : 0 < d) + have hμ : 0 < B * Real.sqrt (d : ℝ) := mul_pos hB (Real.sqrt_pos.2 hdpos) + have hmpos : 0 < m := by + have hmp : (0 : ℝ) < m := lt_of_lt_of_le (by linarith : 0 < B * Real.sqrt (d : ℝ) / 2) hmlo + exact_mod_cast hmp + have ht2 : 2 ≤ independenceOrder d := (independenceOrder_two_le_iff d).2 (by omega) + have htone : (1 : ℝ) ≤ (independenceOrder d : ℝ) := by + exact_mod_cast (by omega : 1 ≤ independenceOrder d) + have hh : 0 < h := by omega + have hcond := hSparse (d : ℝ) (by exact_mod_cast hds) + (m : ℝ) (independenceOrder d : ℝ) hmlo + (by nlinarith [hmhi]) (half_rpow_le_independenceOrder d hd4096) + (independenceOrder_rpow_le d) htone + have hsparse : sparseMomentBound m b (M * m) h ((2 : ℝ) ^ (-(m : ℝ) / 4)) ≤ + (2 : ℝ) ^ (-((m : ℝ) * (independenceOrder d : ℝ)) / 8) := by + simpa only [heven] using sparseMomentBound_quarter_le m b M h hmpos hh + (by simpa only [heven] using hcond) + have htails := hard_slice_tail_bounds (B * Real.sqrt (d : ℝ)) (m : ℝ) + (hashDimension d : ℝ) (independenceOrder d : ℝ) hμ.le hmlo hmhi (hHash d hdr) htone + calc + _ ≤ (2 : ℝ) ^ ((m : ℝ) - (hashDimension d : ℝ)) + + (2 : ℝ) ^ (-((m : ℝ) * (independenceOrder d : ℝ)) / 8) := + add_le_add_right hsparse _ + _ ≤ (2 : ℝ) ^ (-(B * Real.sqrt (d : ℝ)) / 16) + + (2 : ℝ) ^ (-(B * Real.sqrt (d : ℝ)) / 16) := add_le_add htails.1 htails.2 + _ = _ := by ring + +theorem hash_collision_ratio_eq (m r : ℕ) : + (2 : ℝ) ^ m / (2 : ℝ) ^ r = (2 : ℝ) ^ ((m : ℝ) - (r : ℝ)) := by + simpa only [Real.rpow_natCast] using + (Real.rpow_sub (by norm_num : (0 : ℝ) < 2) (m : ℝ) (r : ℝ)).symm + +theorem actual_hard_slice_error_bound_eventually (b : ℕ) (hb : 1 ≤ b) + (B : ℝ) (hB : 0 < B) : + ∃ D : ℕ, 4096 ≤ D ∧ ∀ d : ℕ, D ≤ d → ∀ m h : ℕ, + B * Real.sqrt (d : ℝ) / 2 ≤ (m : ℝ) → + (m : ℝ) ≤ 2 * (B * Real.sqrt (d : ℝ)) → + 2 * h = independenceOrder d → + (2 : ℝ) ^ m / (2 : ℝ) ^ hashDimension d + + sparseMomentBound m b (hardSliceSparseConstant b hb * m) h + ((2 : ℝ) ^ (-(m : ℝ) / 4)) ≤ + 2 * (2 : ℝ) ^ (-(B * Real.sqrt (d : ℝ)) / 16) := by + obtain ⟨D, hD, hbound⟩ := + hard_slice_error_bound_eventually b (hardSliceSparseConstant b hb) B hB + refine ⟨D, hD, ?_⟩ + intro d hd m h hmlo hmhi heven + rw [hash_collision_ratio_eq] + exact hbound d hd m h hmlo hmhi heven + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/HardSliceProbability.lean b/lean/OAI/Computability/DepthThree/HardSliceProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..9cae4f4ca1f717dd81cc49af581af59aa661cf2c --- /dev/null +++ b/lean/OAI/Computability/DepthThree/HardSliceProbability.lean @@ -0,0 +1,159 @@ +import OAI.Computability.DepthThree.HardSliceMoment +import OAI.Computability.DepthThree.SparseCorrelation +import OAI.Computability.DepthThree.HashProbability +import OAI.Computability.DepthThree.AlgebraQuotient +import Mathlib.Tactic.Positivity + +namespace OAI + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +def hardSliceSparseConstant (b : ℕ) (hb : 1 ≤ b) : ℕ := + Classical.choose (exists_sparse_correlation_constant.{0} b hb) + +theorem hardSliceSparseConstant_pos (b : ℕ) (hb : 1 ≤ b) : + 0 < hardSliceSparseConstant b hb := + (Classical.choose_spec (exists_sparse_correlation_constant.{0} b hb)).1 + +theorem hardSliceSparseConstant_spec (b : ℕ) (hb : 1 ≤ b) + (V : Type) [Fintype V] [DecidableEq V] (G : Cube V → ℝ) + (htests : ∀ H : CNF V, H.Normalized → H.WidthAtMost b → + H.length ≤ hardSliceSparseConstant b hb * Fintype.card V → + |finiteAvg (fun x => G x * indicator (H.eval x))| ≤ + (2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4)) : + corr b G ≤ (2 : ℝ) ^ (-(Fintype.card V : ℝ) / 8) := + (Classical.choose_spec (exists_sparse_correlation_constant.{0} b hb)).2 V G htests + +theorem sparseMomentBound_nonneg (m b L h : ℕ) (δ : ℝ) : + 0 ≤ sparseMomentBound m b L h δ := by + unfold sparseMomentBound + apply mul_nonneg (Nat.cast_nonneg _) + apply div_nonneg + · positivity + · rw [pow_mul] + exact pow_nonneg (sq_nonneg (δ * ((2 ^ m : ℕ) : ℝ))) h + +theorem coefficient_corr_failure_le {F V : Type} [Field F] + [Module BinaryAlgebra.F2 F] [Fintype F] [Fintype V] + (ell : F →ₗ[BinaryAlgebra.F2] BinaryAlgebra.F2) (hOne : ell 1 = 1) + (a : Cube V → F) (ha : Function.Injective a) + (b : ℕ) (hb : 1 ≤ b) (h : ℕ) (hh : 0 < h) : + finiteProb (fun β : Fin (2 * h) → F => + ¬ corr b (fun x => sign (Interpolation.acceptEval ell (2 * h) a β x)) ≤ + (2 : ℝ) ^ (-(Fintype.card V : ℝ) / 8)) ≤ + sparseMomentBound (Fintype.card V) b + (hardSliceSparseConstant b hb * Fintype.card V) h + ((2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4)) := by + apply le_trans _ (coefficient_sparse_cnfs_gt_le ell hOne a ha b + (hardSliceSparseConstant b hb * Fintype.card V) h hh + ((2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4)) (Real.rpow_pos_of_pos (by norm_num) _)) + apply finiteProb_mono + intro β hβ + by_contra hnone + apply hβ + apply hardSliceSparseConstant_spec b hb V + intro H _ hw hlen + by_contra hfail + exact hnone ⟨H, hw, hlen, lt_of_not_ge hfail⟩ + +theorem hash_coefficient_corr_failure_le {F V U : Type} [Field F] + [Module BinaryAlgebra.F2 F] [Fintype F] [Fintype V] + [Fintype U] [Nonempty U] + (ell : F →ₗ[BinaryAlgebra.F2] BinaryAlgebra.F2) (hOne : ell 1 = 1) + (a : U → Cube V → F) (b : ℕ) (hb : 1 ≤ b) (h : ℕ) (hh : 0 < h) : + finiteProb (fun ω : U × (Fin (2 * h) → F) => + ¬ corr b (fun x => sign (Interpolation.acceptEval ell (2 * h) (a ω.1) ω.2 x)) ≤ + (2 : ℝ) ^ (-(Fintype.card V : ℝ) / 8)) ≤ + finiteProb (fun u => ¬ Function.Injective (a u)) + + sparseMomentBound (Fintype.card V) b + (hardSliceSparseConstant b hb * Fintype.card V) h + ((2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4)) := by + let B := sparseMomentBound (Fintype.card V) b + (hardSliceSparseConstant b hb * Fintype.card V) h + ((2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4)) + have hB : 0 ≤ B := sparseMomentBound_nonneg _ _ _ _ _ + change finiteAvg _ ≤ finiteProb _ + B + rw [finiteAvg_product] + calc + _ ≤ finiteAvg (fun u : U => (if ¬ Function.Injective (a u) then 1 else 0) + B) := by + apply finiteAvg_mono + intro u + by_cases hu : Function.Injective (a u) + · simpa only [finiteProb, B, hu, not_true_eq_false, ite_false, zero_add] using + coefficient_corr_failure_le ell hOne (a u) hu b hb h hh + · have hone := finiteProb_le_one (fun β : Fin (2 * h) → F => + ¬ corr b (fun x => sign (Interpolation.acceptEval ell (2 * h) (a u) β x)) ≤ + (2 : ℝ) ^ (-(Fintype.card V : ℝ) / 8)) + simpa only [finiteProb, hu, not_false_eq_true, ite_true] using + hone.trans (le_add_of_nonneg_right hB) + _ = finiteProb (fun u => ¬ Function.Injective (a u)) + B := by + rw [finiteAvg_add, finiteAvg_const] + apply congrArg (fun z : ℝ => z + B) + apply finiteAvg_congr + intro u + exact (ite_eq_ite _ _ _).mpr trivial + +def encodedHash {d r : ℕ} (p : Fin r → Bool) + (u : Fin (d + r - 1) → Bool) (x : Cube (Fin d)) : BinaryAlgebra.BitQuotient p := + BinaryAlgebra.encode (fun i => BinaryAlgebra.bitValue (p i)) + (fun i => BinaryAlgebra.bitValue (BinaryHash.hashBool u x i)) + +theorem encodedHash_fill_injective {d r : ℕ} (p : Fin r → Bool) + (u : Fin (d + r - 1) → Bool) (σ : Restriction (Fin d)) + (hu : Function.Injective (fun z : Cube (Live σ) => BinaryHash.hashBool u (fill σ z))) : + Function.Injective (fun z : Cube (Live σ) => encodedHash p u (fill σ z)) := by + intro x y hxy + apply hu + apply (BinaryAlgebra.bitsEquivF2 (Fin r)).injective + exact BinaryAlgebra.encode_injective _ hxy + +def hashAcceptance {d r : ℕ} (p : Fin r → Bool) + [Fact (Irreducible (BinaryAlgebra.inputPolynomialBits p))] + (t : ℕ) (u : Fin (d + r - 1) → Bool) + (β : Fin t → BinaryAlgebra.BitQuotient p) : Cube (Fin d) → Bool := + Interpolation.acceptEval + (BinaryAlgebra.degreeZero (BinaryAlgebra.inputPolynomialBits_monic p)) t + (encodedHash p u) β + +theorem actual_hash_coefficient_failure_le {d r : ℕ} (p : Fin r → Bool) + [Fact (Irreducible (BinaryAlgebra.inputPolynomialBits p))] + (hr : 0 < r) (σ : Restriction (Fin d)) + (b : ℕ) (hb : 1 ≤ b) (h : ℕ) (hh : 0 < h) : + finiteProb (fun ω : (Fin (d + r - 1) → Bool) × + (Fin (2 * h) → BinaryAlgebra.BitQuotient p) => + ¬ corr b (fun z => sign (hashAcceptance p (2 * h) ω.1 ω.2 (fill σ z))) ≤ + (2 : ℝ) ^ (-(Fintype.card (Live σ) : ℝ) / 8)) ≤ + (2 : ℝ) ^ Fintype.card (Live σ) / (2 : ℝ) ^ r + + sparseMomentBound (Fintype.card (Live σ)) b + (hardSliceSparseConstant b hb * Fintype.card (Live σ)) h + ((2 : ℝ) ^ (-(Fintype.card (Live σ) : ℝ) / 4)) := by + let : Field (BinaryAlgebra.BitQuotient p) := + AdjoinRoot.instField (f := BinaryAlgebra.inputPolynomialBits p) + let : Module BinaryAlgebra.F2 (BinaryAlgebra.BitQuotient p) := + inferInstanceAs (Module BinaryAlgebra.F2 + (AdjoinRoot (BinaryAlgebra.inputPolynomialBits p))) + have hOne : BinaryAlgebra.degreeZero (BinaryAlgebra.inputPolynomialBits_monic p) + (1 : BinaryAlgebra.BitQuotient p) = 1 := + BinaryAlgebra.degreeZero_one _ (by simpa using hr) + have hhash : finiteProb (fun u : Fin (d + r - 1) → Bool => + ¬ Function.Injective (fun z : Cube (Live σ) => encodedHash p u (fill σ z))) ≤ + (2 : ℝ) ^ Fintype.card (Live σ) / (2 : ℝ) ^ r := by + apply le_trans _ (BinaryHash.hashBool_restriction_failure_le_pow (r := r) σ) + apply finiteProb_mono + intro u hu hinj + exact hu (encodedHash_fill_injective p u σ hinj) + exact (hash_coefficient_corr_failure_le (F := BinaryAlgebra.BitQuotient p) + (V := Live σ) (U := Fin (d + r - 1) → Bool) + (BinaryAlgebra.degreeZero (BinaryAlgebra.inputPolynomialBits_monic p)) hOne + (fun u z => encodedHash p u (fill σ z)) b hb h hh).trans + (add_le_add_left hhash _) + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/HardSliceSelection.lean b/lean/OAI/Computability/DepthThree/HardSliceSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b05d1d7cfeee71b8edd868618baf3c7b20453a4 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/HardSliceSelection.lean @@ -0,0 +1,121 @@ +import OAI.Computability.DepthThree.FiniteProbabilityBounds +import OAI.Computability.DepthThree.RestrictionTails +import OAI.Computability.DepthThree.RestrictionCorrelation +import Mathlib.Tactic.Linarith + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} {Ω : Type uDepth2} [Fintype V] [instDecidableEqV : DecidableEq V] + [Fintype Ω] [Nonempty Ω] + +theorem exists_small_restriction_failure + {V : Type uDepth1} + {Ω : Type uDepth2} + [Fintype V] + [DecidableEq V] + [Fintype Ω] + [Nonempty Ω] + {p δ η : ℝ} + (hp : 0 ≤ p) (hp1 : p ≤ 1) (hδ : 0 ≤ δ) + (window : Restriction V → Prop) (good : Ω → Restriction V → Prop) + (hfixed : ∀ σ, window σ → finiteProb (fun ω => ¬ good ω σ) ≤ δ) + (hwindow : restrictionAvg p (fun σ => if ¬ window σ then 1 else 0) ≤ η) : + ∃ ω : Ω, + restrictionAvg p (fun σ => if ¬ (window σ ∧ good ω σ) then 1 else 0) ≤ η + δ := by + have hpoint : ∀ σ : Restriction V, + finiteAvg (fun ω : Ω => if ¬ (window σ ∧ good ω σ) then (1 : ℝ) else 0) ≤ + (if ¬ window σ then 1 else 0) + δ := by + intro σ + by_cases hσ : window σ + · have hfixed' : finiteAvg (fun ω : Ω => if ¬ good ω σ then (1 : ℝ) else 0) ≤ δ := by + calc + _ = finiteProb (fun ω => ¬ good ω σ) := by + apply finiteAvg_congr + intro ω + exact (ite_eq_ite _ _ _).mpr trivial + _ ≤ δ := hfixed σ hσ + simpa only [hσ, true_and, not_true_eq_false, ite_false, zero_add] using hfixed' + · simpa only [hσ, false_and, not_false_eq_true, ite_true, finiteAvg_const] + using (le_add_of_nonneg_right hδ : (1 : ℝ) ≤ 1 + δ) + apply finiteAvg_exists_le_of_le + calc + _ = restrictionAvg p (fun σ => + finiteAvg (fun ω : Ω => if ¬ (window σ ∧ good ω σ) then 1 else 0)) := + finiteAvg_restrictionAvg p _ + _ ≤ restrictionAvg p (fun σ => (if ¬ window σ then 1 else 0) + δ) := + restrictionAvg_mono hp hp1 hpoint + _ = restrictionAvg p (fun σ => if ¬ window σ then 1 else 0) + δ := by + rw [restrictionAvg_add, restrictionAvg_const] + _ ≤ η + δ := add_le_add_left hwindow δ + +def restrictionWindow (p : ℝ) (σ : Restriction V) : Prop := + (p * Fintype.card V) / 2 ≤ (Fintype.card (Live σ) : ℝ) ∧ + (Fintype.card (Live σ) : ℝ) ≤ 2 * (p * Fintype.card V) + +def goodRestriction (p ε : ℝ) (b : ℕ) (f : Cube V → Bool) + (σ : Restriction V) : Prop := + restrictionWindow p σ ∧ corr b (fun z => sign (f (fill σ z))) ≤ ε + +theorem goodRestriction_corr + {V : Type uDepth1} + [Fintype V] + [DecidableEq V] + {p ε : ℝ} {b : ℕ} {f : Cube V → Bool} + {σ : Restriction V} (h : goodRestriction p ε b f σ) : + corr b (fun z => sign (f (fill σ z))) ≤ ε := h.2 + +theorem exists_good_parameter {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) + (b : ℕ) (f : Ω → Cube V → Bool) + (hfixed : ∀ σ : Restriction V, restrictionWindow p σ → + finiteProb (fun ω => + ¬ corr b (fun z => sign (f ω (fill σ z))) ≤ + (2 : ℝ) ^ (-(p * Fintype.card V) / 16)) ≤ + 2 * (2 : ℝ) ^ (-(p * Fintype.card V) / 16)) : + ∃ ω : Ω, + restrictionAvg p (fun σ => if ¬ goodRestriction p + ((2 : ℝ) ^ (-(p * Fintype.card V) / 16)) b (f ω) σ then 1 else 0) ≤ + 4 * (2 : ℝ) ^ (-(p * Fintype.card V) / 16) := by + have hε : 0 ≤ (2 : ℝ) ^ (-(p * Fintype.card V) / 16) := + Real.rpow_nonneg (by norm_num) _ + have hwindow : restrictionAvg p (fun σ : Restriction V => + if ¬ restrictionWindow p σ then 1 else 0) ≤ + 2 * (2 : ℝ) ^ (-(p * Fintype.card V) / 16) := by + calc + _ = restrictionAvg p (fun σ : Restriction V => + if ¬ ((p * Fintype.card V) / 2 ≤ (Fintype.card (Live σ) : ℝ) ∧ + (Fintype.card (Live σ) : ℝ) ≤ 2 * (p * Fintype.card V)) then 1 else 0) := by + apply congrArg (restrictionAvg p) + funext σ + exact (ite_eq_ite _ _ _).mpr trivial + _ ≤ _ := restrictionAvg_outside_window (V := V) p hp hp1 + obtain ⟨ω, hω⟩ := exists_small_restriction_failure hp hp1 + (mul_nonneg (by norm_num : (0 : ℝ) ≤ 2) hε) + (restrictionWindow p) + (fun ω σ => corr b (fun z => sign (f ω (fill σ z))) ≤ + (2 : ℝ) ^ (-(p * Fintype.card V) / 16)) + hfixed hwindow + refine ⟨ω, ?_⟩ + have heq : restrictionAvg p (fun σ => if ¬ goodRestriction p + ((2 : ℝ) ^ (-(p * Fintype.card V) / 16)) b (f ω) σ then 1 else 0) = + restrictionAvg p (fun σ => if ¬ (restrictionWindow p σ ∧ + corr b (fun z => sign (f ω (fill σ z))) ≤ + (2 : ℝ) ^ (-(p * Fintype.card V) / 16)) then 1 else 0) := by + apply congrArg (restrictionAvg p) + funext σ + exact (ite_eq_ite _ _ _).mpr trivial + rw [heq] + linarith + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/Hash.lean b/lean/OAI/Computability/DepthThree/Hash.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc24c2f2166c811e149d9152c1294d14bf9be15b --- /dev/null +++ b/lean/OAI/Computability/DepthThree/Hash.lean @@ -0,0 +1,89 @@ +import OAI.Computability.DepthThree.AlgebraBits +import Mathlib.Algebra.BigOperators.Group.Finset.Basic +import Mathlib.Data.Fintype.BigOperators +import Lean.Elab.Tactic.Omega + +namespace OAI + +namespace DepthThreeLowerBound.BinaryHash + +open scoped BigOperators + +abbrev F2 := BinaryAlgebra.F2 +abbrev Data (d : ℕ) := Fin d → F2 +abbrev Seed (d r : ℕ) := Fin (d + r - 1) → F2 +abbrev Output (r : ℕ) := Fin r → F2 + +def sumIndex {d r : ℕ} (i : Fin r) (s : Fin d) : Fin (d + r - 1) := + ⟨i.val + s.val, by have := i.isLt; have := s.isLt; omega⟩ + +@[simp] theorem sumIndex_val {d r : ℕ} (i : Fin r) (s : Fin d) : + (sumIndex i s).val = i.val + s.val := rfl + +theorem sumIndex_left_injective {d r : ℕ} (s : Fin d) : + Function.Injective (fun i : Fin r => sumIndex i s) := by + intro i j h + apply Fin.ext + have hval := congrArg Fin.val h + simpa only [sumIndex_val, Nat.add_right_cancel_iff] using hval + +def hashF2 {d r : ℕ} (u : Seed d r) (x : Data d) : Output r := + fun i => ∑ s : Fin d, u (sumIndex i s) * x s + +@[simp] theorem hashF2_apply {d r : ℕ} (u : Seed d r) (x : Data d) (i : Fin r) : + hashF2 u x i = ∑ s : Fin d, u (sumIndex i s) * x s := rfl + +@[simp] theorem hashF2_zero_data {d r : ℕ} (u : Seed d r) : + hashF2 u 0 = 0 := by + funext i + simp [hashF2] + +@[simp] theorem hashF2_zero_seed {d r : ℕ} (x : Data d) : + hashF2 (0 : Seed d r) x = 0 := by + funext i + simp [hashF2] + +theorem hashF2_add_data {d r : ℕ} (u : Seed d r) (x y : Data d) : + hashF2 u (x + y) = hashF2 u x + hashF2 u y := by + funext i + simp [hashF2, mul_add, Finset.sum_add_distrib] + +theorem hashF2_sub_data {d r : ℕ} (u : Seed d r) (x y : Data d) : + hashF2 u (x - y) = hashF2 u x - hashF2 u y := by + funext i + simp [hashF2, mul_sub, Finset.sum_sub_distrib] + +theorem hashF2_add_seed {d r : ℕ} (u v : Seed d r) (x : Data d) : + hashF2 (u + v) x = hashF2 u x + hashF2 v x := by + funext i + simp [hashF2, add_mul, Finset.sum_add_distrib] + +theorem hashF2_sub_seed {d r : ℕ} (u v : Seed d r) (x : Data d) : + hashF2 (u - v) x = hashF2 u x - hashF2 v x := by + funext i + simp [hashF2, sub_mul, Finset.sum_sub_distrib] + +def hashBool {d r : ℕ} (u : Fin (d + r - 1) → Bool) (x : Fin d → Bool) : + Fin r → Bool := + fun i => BinaryAlgebra.fieldBit + (hashF2 (fun j => BinaryAlgebra.bitValue (u j)) + (fun s => BinaryAlgebra.bitValue (x s)) i) + +@[simp] theorem bitValue_hashBool {d r : ℕ} + (u : Fin (d + r - 1) → Bool) (x : Fin d → Bool) (i : Fin r) : + BinaryAlgebra.bitValue (hashBool u x i) = + hashF2 (fun j => BinaryAlgebra.bitValue (u j)) + (fun s => BinaryAlgebra.bitValue (x s)) i := by + simp [hashBool] + +theorem bitsEquivF2_hashBool {d r : ℕ} + (u : Fin (d + r - 1) → Bool) (x : Fin d → Bool) : + BinaryAlgebra.bitsEquivF2 (Fin r) (hashBool u x) = + hashF2 (BinaryAlgebra.bitsEquivF2 (Fin (d + r - 1)) u) + (BinaryAlgebra.bitsEquivF2 (Fin d) x) := by + funext i + exact bitValue_hashBool u x i + +end DepthThreeLowerBound.BinaryHash + +end OAI diff --git a/lean/OAI/Computability/DepthThree/HashAffine.lean b/lean/OAI/Computability/DepthThree/HashAffine.lean new file mode 100644 index 0000000000000000000000000000000000000000..198d9f44403f094151cf646a3c7efc2f28e6c979 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/HashAffine.lean @@ -0,0 +1,266 @@ +import OAI.Computability.DepthThree.HashFibers +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Data.Set.Function +import Mathlib.Tactic.Push + +namespace OAI + +noncomputable section + +open scoped BigOperators + +namespace DepthThreeLowerBound.BinaryHash + +open BinaryAlgebra + +variable {d r : ℕ} + +abbrev OutsideData (T : Finset (Fin d)) := {i : Fin d // i ∉ T} → F2 + +def coordinateCube (T : Finset (Fin d)) (rho : OutsideData T) : Set (Data d) := + {x | ∀ i (hi : i ∉ T), x i = rho ⟨i, hi⟩} + +def SupportedOn (T : Finset (Fin d)) (w : Data d) : Prop := + ∀ i, i ∉ T → w i = 0 + +def coordinateCubeExtend (T : Finset (Fin d)) (rho : OutsideData T) + (z : T → F2) : Data d := + fun i => if hi : i ∈ T then z ⟨i, hi⟩ else rho ⟨i, hi⟩ + +theorem coordinateCubeExtend_mem (T : Finset (Fin d)) (rho : OutsideData T) + (z : T → F2) : coordinateCubeExtend T rho z ∈ coordinateCube T rho := by + intro i hi + simp [coordinateCubeExtend, hi] + +def coordinateCubeEquiv (T : Finset (Fin d)) (rho : OutsideData T) : + (coordinateCube T rho) ≃ (T → F2) where + toFun x := fun i => x.val i.val + invFun z := ⟨coordinateCubeExtend T rho z, coordinateCubeExtend_mem T rho z⟩ + left_inv x := by + apply Subtype.ext + funext i + by_cases hi : i ∈ T + · simp [coordinateCubeExtend, hi] + · simpa [coordinateCubeExtend, hi] using (x.property i hi).symm + right_inv z := by + funext i + simp [coordinateCubeExtend, i.property] + +def supportedDataEquiv (T : Finset (Fin d)) : + {w : Data d // SupportedOn T w} ≃ (T → F2) where + toFun w := fun i => w.val i.val + invFun z := ⟨coordinateCubeExtend T 0 z, coordinateCubeExtend_mem T 0 z⟩ + left_inv w := by + apply Subtype.ext + funext i + by_cases hi : i ∈ T + · simp [coordinateCubeExtend, hi] + · simpa [coordinateCubeExtend, hi] using (w.property i hi).symm + right_inv z := by + funext i + simp [coordinateCubeExtend, i.property] + +@[simp] theorem supportedOn_zero (T : Finset (Fin d)) : + SupportedOn T (0 : Data d) := by + intro i hi + rfl + +theorem supportedOn_sub_of_mem {T : Finset (Fin d)} {rho : OutsideData T} + {x y : Data d} (hx : x ∈ coordinateCube T rho) + (hy : y ∈ coordinateCube T rho) : SupportedOn T (x - y) := by + intro i hi + change x i - y i = 0 + rw [hx i hi, hy i hi, sub_self] + +theorem add_mem_coordinateCube {T : Finset (Fin d)} {rho : OutsideData T} + {x w : Data d} (hx : x ∈ coordinateCube T rho) (hw : SupportedOn T w) : + x + w ∈ coordinateCube T rho := by + intro i hi + change x i + w i = rho ⟨i, hi⟩ + rw [hw i hi, add_zero, hx i hi] + +theorem not_injOn_coordinateCube_iff (u : Seed d r) (T : Finset (Fin d)) + (rho : OutsideData T) : + ¬ Set.InjOn (hashF2 u) (coordinateCube T rho) ↔ + ∃ w : Data d, SupportedOn T w ∧ w ≠ 0 ∧ hashF2 u w = 0 := by + classical + constructor + · intro h + simp only [Set.InjOn] at h + push Not at h + obtain ⟨x, hx, y, hy, hxy, hne⟩ := h + refine ⟨x - y, supportedOn_sub_of_mem hx hy, sub_ne_zero.mpr hne, ?_⟩ + rw [hashF2_sub_data, hxy, sub_self] + · rintro ⟨w, hw, hne, hkernel⟩ hinj + let x : Data d := coordinateCubeExtend T rho 0 + have hx : x ∈ coordinateCube T rho := coordinateCubeExtend_mem T rho 0 + have hxw : x + w ∈ coordinateCube T rho := add_mem_coordinateCube hx hw + have hhash : hashF2 u (x + w) = hashF2 u x := by + rw [hashF2_add_data, hkernel, add_zero] + have heq : x + w = x + 0 := by simpa using hinj hxw hx hhash + exact hne (add_left_cancel heq) + +theorem not_injOn_coordinateCube_iff_of_outside (u : Seed d r) + (T : Finset (Fin d)) (rho sigma : OutsideData T) : + (¬ Set.InjOn (hashF2 u) (coordinateCube T rho)) ↔ + ¬ Set.InjOn (hashF2 u) (coordinateCube T sigma) := by + rw [not_injOn_coordinateCube_iff, not_injOn_coordinateCube_iff] + +def supportedVectors (T : Finset (Fin d)) : Finset (Data d) := by + classical + exact Finset.univ.filter (SupportedOn T) + +@[simp] theorem mem_supportedVectors (T : Finset (Fin d)) (w : Data d) : + w ∈ supportedVectors T ↔ SupportedOn T w := by + classical + simp [supportedVectors] + +theorem supportedVectors_card (T : Finset (Fin d)) : + (supportedVectors T).card = 2 ^ T.card := by + classical + calc + (supportedVectors T).card = Fintype.card {w : Data d // SupportedOn T w} := by + simpa [supportedVectors] using (Fintype.card_subtype (SupportedOn T)).symm + _ = Fintype.card (T → F2) := Fintype.card_congr (supportedDataEquiv T) + _ = 2 ^ T.card := by + change Fintype.card (T → ZMod 2) = 2 ^ T.card + rw [Fintype.card_fun, ZMod.card, Fintype.card_coe] + +def nonzeroSupportedVectors (T : Finset (Fin d)) : Finset (Data d) := + (supportedVectors T).erase 0 + +@[simp] theorem mem_nonzeroSupportedVectors (T : Finset (Fin d)) (w : Data d) : + w ∈ nonzeroSupportedVectors T ↔ SupportedOn T w ∧ w ≠ 0 := by + classical + simp [nonzeroSupportedVectors, and_comm] + +theorem nonzeroSupportedVectors_card (T : Finset (Fin d)) : + (nonzeroSupportedVectors T).card = 2 ^ T.card - 1 := by + classical + rw [nonzeroSupportedVectors, Finset.card_erase_of_mem, supportedVectors_card] + exact (mem_supportedVectors T 0).mpr (supportedOn_zero T) + +def kernelSeeds (w : Data d) : Finset (Seed d r) := by + classical + exact Finset.univ.filter (fun u => hashF2 u w = 0) + +@[simp] theorem mem_kernelSeeds (w : Data d) (u : Seed d r) : + u ∈ kernelSeeds w ↔ hashF2 u w = 0 := by + classical + simp [kernelSeeds] + +theorem kernelSeeds_card (w : Data d) (hw : w ≠ 0) : + (kernelSeeds (r := r) w).card = 2 ^ (d - 1) := by + classical + calc + (kernelSeeds (r := r) w).card = + Fintype.card {u : Seed d r // hashF2 u w = 0} := by + simpa [kernelSeeds] using + (Fintype.card_subtype (fun u : Seed d r => hashF2 u w = 0)).symm + _ = 2 ^ (d - 1) := hashF2_fiber_card w hw 0 + +def badSeeds (T : Finset (Fin d)) (rho : OutsideData T) : Finset (Seed d r) := by + classical + exact Finset.univ.filter (fun u => ¬ Set.InjOn (hashF2 u) (coordinateCube T rho)) + +@[simp] theorem mem_badSeeds (T : Finset (Fin d)) (rho : OutsideData T) + (u : Seed d r) : + u ∈ badSeeds T rho ↔ ¬ Set.InjOn (hashF2 u) (coordinateCube T rho) := by + classical + simp [badSeeds] + +theorem badSeeds_eq_biUnion (T : Finset (Fin d)) (rho : OutsideData T) : + badSeeds (r := r) T rho = + (nonzeroSupportedVectors T).biUnion (fun w => kernelSeeds (r := r) w) := by + classical + ext u + simp only [mem_badSeeds, Finset.mem_biUnion, mem_nonzeroSupportedVectors, + mem_kernelSeeds, and_assoc] + exact not_injOn_coordinateCube_iff u T rho + +theorem badSeeds_eq_of_outside (T : Finset (Fin d)) (rho sigma : OutsideData T) : + badSeeds (r := r) T rho = badSeeds T sigma := by + rw [badSeeds_eq_biUnion, badSeeds_eq_biUnion] + +theorem badSeeds_card_le (T : Finset (Fin d)) (rho : OutsideData T) : + (badSeeds (r := r) T rho).card ≤ (2 ^ T.card - 1) * 2 ^ (d - 1) := by + classical + rw [badSeeds_eq_biUnion] + calc + ((nonzeroSupportedVectors T).biUnion (fun w => kernelSeeds (r := r) w)).card ≤ + ∑ w ∈ nonzeroSupportedVectors T, (kernelSeeds (r := r) w).card := + Finset.card_biUnion_le + _ = ∑ _w ∈ nonzeroSupportedVectors T, 2 ^ (d - 1) := by + apply Finset.sum_congr rfl + intro w hw + exact kernelSeeds_card w ((mem_nonzeroSupportedVectors T w).mp hw).2 + _ = (2 ^ T.card - 1) * 2 ^ (d - 1) := by + simp [nonzeroSupportedVectors_card] + +theorem injOn_coordinateCube_empty (u : Seed d r) (rho : OutsideData (∅ : Finset (Fin d))) : + Set.InjOn (hashF2 u) (coordinateCube ∅ rho) := by + intro x hx y hy hxy + funext i + exact (hx i (by simp)).trans (hy i (by simp)).symm + +@[simp] theorem badSeeds_empty (rho : OutsideData (∅ : Finset (Fin d))) : + badSeeds (r := r) ∅ rho = ∅ := by + classical + ext u + simp [injOn_coordinateCube_empty] + +theorem badSeeds_card_eq_zero_of_card_eq_zero (T : Finset (Fin d)) + (rho : OutsideData T) (hT : T.card = 0) : (badSeeds (r := r) T rho).card = 0 := by + have h : T = ∅ := Finset.card_eq_zero.mp hT + subst T + simp + +@[simp] theorem badSeeds_zero_data (T : Finset (Fin 0)) (rho : OutsideData T) : + badSeeds (r := r) T rho = ∅ := by + have hT : T = ∅ := Finset.eq_empty_of_isEmpty T + subst T + exact badSeeds_empty rho + +theorem injOn_coordinateCube_zero_output_iff (u : Seed d 0) + (T : Finset (Fin d)) (rho : OutsideData T) : + Set.InjOn (hashF2 u) (coordinateCube T rho) ↔ T = ∅ := by + classical + constructor + · intro hinj + by_contra hT + obtain ⟨j, hj⟩ := Finset.nonempty_iff_ne_empty.mpr hT + let w : Data d := fun i => if i = j then 1 else 0 + have hsupport : SupportedOn T w := by + intro i hi + have hij : i ≠ j := by + intro h + apply hi + simpa [h] using hj + simp [w, hij] + have hnonzero : w ≠ 0 := by + intro h + have h10 : (1 : F2) = 0 := by simpa [w] using congrFun h j + exact one_ne_zero h10 + have hkernel : hashF2 u w = 0 := by + funext i + exact Fin.elim0 i + exact ((not_injOn_coordinateCube_iff u T rho).mpr + ⟨w, hsupport, hnonzero, hkernel⟩) hinj + · intro hT + subst T + exact injOn_coordinateCube_empty u rho + +theorem badSeeds_zero_output (T : Finset (Fin d)) (rho : OutsideData T) : + badSeeds (r := 0) T rho = if T = ∅ then ∅ else Finset.univ := by + classical + ext u + by_cases hT : T = ∅ + · subst T + simp + · simp [mem_badSeeds, injOn_coordinateCube_zero_output_iff, hT] + +end DepthThreeLowerBound.BinaryHash + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/HashBool.lean b/lean/OAI/Computability/DepthThree/HashBool.lean new file mode 100644 index 0000000000000000000000000000000000000000..64753436c8cf86dd2287cddf5a6a1b99890dff9c --- /dev/null +++ b/lean/OAI/Computability/DepthThree/HashBool.lean @@ -0,0 +1,123 @@ +import OAI.Computability.DepthThree.HashAffine + +namespace OAI + +namespace DepthThreeLowerBound.BinaryHash + +open BinaryAlgebra + +variable {d r : ℕ} + +theorem hashBool_eq_iff (u : Fin (d + r - 1) → Bool) + (x : Fin d → Bool) (a : Fin r → Bool) : + hashBool u x = a ↔ + hashF2 (bitsEquivF2 (Fin (d + r - 1)) u) (bitsEquivF2 (Fin d) x) = + bitsEquivF2 (Fin r) a := by + rw [← bitsEquivF2_hashBool] + exact (bitsEquivF2 (Fin r)).injective.eq_iff.symm + +theorem hashBool_collision_iff (u : Fin (d + r - 1) → Bool) + (x y : Fin d → Bool) : + hashBool u x = hashBool u y ↔ + hashF2 (bitsEquivF2 (Fin (d + r - 1)) u) (bitsEquivF2 (Fin d) x) = + hashF2 (bitsEquivF2 (Fin (d + r - 1)) u) (bitsEquivF2 (Fin d) y) := by + rw [← bitsEquivF2_hashBool, ← bitsEquivF2_hashBool] + exact (bitsEquivF2 (Fin r)).injective.eq_iff.symm + +def hashBool_fiberEquiv (x : Fin d → Bool) (a : Fin r → Bool) : + {u : Fin (d + r - 1) → Bool // hashBool u x = a} ≃ + {u : Seed d r // hashF2 u (bitsEquivF2 (Fin d) x) = + bitsEquivF2 (Fin r) a} := + Equiv.subtypeEquiv (bitsEquivF2 (Fin (d + r - 1))) + (fun u => hashBool_eq_iff u x a) + +theorem hashBool_fiber_card (x : Fin d → Bool) (hx : x ≠ fun _ => false) + (a : Fin r → Bool) : + Fintype.card {u : Fin (d + r - 1) → Bool // hashBool u x = a} = 2 ^ (d - 1) := by + classical + have hnonzero : bitsEquivF2 (Fin d) x ≠ 0 := by + intro h + apply hx + funext i + apply bitValue_injective + simpa using congrFun h i + exact (Fintype.card_congr (hashBool_fiberEquiv x a)).trans + (hashF2_fiber_card (bitsEquivF2 (Fin d) x) hnonzero (bitsEquivF2 (Fin r) a)) + +def hashBool_collisionEquiv (x y : Fin d → Bool) : + {u : Fin (d + r - 1) → Bool // hashBool u x = hashBool u y} ≃ + {u : Seed d r // hashF2 u (bitsEquivF2 (Fin d) x) = + hashF2 u (bitsEquivF2 (Fin d) y)} := + Equiv.subtypeEquiv (bitsEquivF2 (Fin (d + r - 1))) + (fun u => hashBool_collision_iff u x y) + +theorem hashBool_collision_card (x y : Fin d → Bool) (hxy : x ≠ y) : + Fintype.card {u : Fin (d + r - 1) → Bool // hashBool u x = hashBool u y} = + 2 ^ (d - 1) := by + classical + exact (Fintype.card_congr (hashBool_collisionEquiv (r := r) x y)).trans + (hashF2_collision_card (bitsEquivF2 (Fin d) x) (bitsEquivF2 (Fin d) y) + (fun h => hxy ((bitsEquivF2 (Fin d)).injective h))) + +def boolCoordinateCube (T : Finset (Fin d)) (rho : {i : Fin d // i ∉ T} → Bool) : + Set (Fin d → Bool) := + {x | ∀ i (hi : i ∉ T), x i = rho ⟨i, hi⟩} + +theorem mem_boolCoordinateCube_iff (T : Finset (Fin d)) + (rho : {i : Fin d // i ∉ T} → Bool) (x : Fin d → Bool) : + x ∈ boolCoordinateCube T rho ↔ + bitsEquivF2 (Fin d) x ∈ coordinateCube T (fun i => bitValue (rho i)) := by + constructor + · intro hx i hi + change bitValue (x i) = bitValue (rho ⟨i, hi⟩) + exact congrArg bitValue (hx i hi) + · intro hx i hi + exact bitValue_injective (hx i hi) + +theorem injOn_hashBool_iff (u : Fin (d + r - 1) → Bool) + (T : Finset (Fin d)) (rho : {i : Fin d // i ∉ T} → Bool) : + Set.InjOn (hashBool u) (boolCoordinateCube T rho) ↔ + Set.InjOn (hashF2 (bitsEquivF2 (Fin (d + r - 1)) u)) + (coordinateCube T (fun i => bitValue (rho i))) := by + constructor + · intro hinj x hx y hy hxy + obtain ⟨a, rfl⟩ := (bitsEquivF2 (Fin d)).surjective x + obtain ⟨b, rfl⟩ := (bitsEquivF2 (Fin d)).surjective y + have hab := hinj ((mem_boolCoordinateCube_iff T rho a).mpr hx) + ((mem_boolCoordinateCube_iff T rho b).mpr hy) + ((hashBool_collision_iff u a b).mpr hxy) + exact congrArg (bitsEquivF2 (Fin d)) hab + · intro hinj x hx y hy hxy + apply (bitsEquivF2 (Fin d)).injective + exact hinj ((mem_boolCoordinateCube_iff T rho x).mp hx) + ((mem_boolCoordinateCube_iff T rho y).mp hy) + ((hashBool_collision_iff u x y).mp hxy) + +def hashBool_badSeedEquiv (T : Finset (Fin d)) + (rho : {i : Fin d // i ∉ T} → Bool) : + {u : Fin (d + r - 1) → Bool // ¬ Set.InjOn (hashBool u) (boolCoordinateCube T rho)} ≃ + {u : Seed d r // ¬ Set.InjOn (hashF2 u) + (coordinateCube T (fun i => bitValue (rho i)))} := + Equiv.subtypeEquiv (bitsEquivF2 (Fin (d + r - 1))) + (fun u => not_congr (injOn_hashBool_iff u T rho)) + +open scoped Classical in +theorem hashBool_badSeed_card_le (T : Finset (Fin d)) + (rho : {i : Fin d // i ∉ T} → Bool) : + Fintype.card + {u : Fin (d + r - 1) → Bool // ¬ Set.InjOn (hashBool u) (boolCoordinateCube T rho)} ≤ + (2 ^ T.card - 1) * 2 ^ (d - 1) := by + classical + calc + Fintype.card + {u : Fin (d + r - 1) → Bool // ¬ Set.InjOn (hashBool u) (boolCoordinateCube T rho)} = + Fintype.card {u : Seed d r // ¬ Set.InjOn (hashF2 u) + (coordinateCube T (fun i => bitValue (rho i)))} := + Fintype.card_congr (hashBool_badSeedEquiv (r := r) T rho) + _ = (badSeeds (r := r) T (fun i => bitValue (rho i))).card := by + simp only [badSeeds, Fintype.card_subtype] + _ ≤ (2 ^ T.card - 1) * 2 ^ (d - 1) := badSeeds_card_le T _ + +end DepthThreeLowerBound.BinaryHash + +end OAI diff --git a/lean/OAI/Computability/DepthThree/HashFibers.lean b/lean/OAI/Computability/DepthThree/HashFibers.lean new file mode 100644 index 0000000000000000000000000000000000000000..208de793acc10c8cf361c4f0519531544d7986a6 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/HashFibers.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DepthThree.HashTriangular +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Logic.Equiv.Basic + +namespace OAI + +namespace DepthThreeLowerBound +namespace BinaryHash + +noncomputable section + +variable {d r : ℕ} + +def hashF2_fiberEquiv (w : Data d) (hw : w ≠ 0) (a : Output r) : + {u : Seed d r // hashF2 u w = a} ≃ (Nonpivot (r := r) w hw → F2) where + toFun u := (triangularEquiv (r := r) w hw u.1).2 + invFun b := ⟨(triangularEquiv (r := r) w hw).symm (a, b), by + rw [← triangularEquiv_fst w hw] + exact congrArg Prod.fst + ((triangularEquiv (r := r) w hw).apply_symm_apply (a, b))⟩ + left_inv u := by + apply Subtype.ext + apply (triangularEquiv (r := r) w hw).injective + change (triangularEquiv (r := r) w hw) + ((triangularEquiv (r := r) w hw).symm + (a, (triangularEquiv (r := r) w hw u.1).2)) = + triangularEquiv (r := r) w hw u.1 + rw [Equiv.apply_symm_apply] + exact Prod.ext ((triangularEquiv_fst w hw u.1).trans u.2).symm rfl + right_inv b := by + change ((triangularEquiv (r := r) w hw) + ((triangularEquiv (r := r) w hw).symm (a, b))).2 = b + rw [Equiv.apply_symm_apply] + +theorem hashF2_fiber_card (w : Data d) (hw : w ≠ 0) (a : Output r) : + Fintype.card {u : Seed d r // hashF2 u w = a} = 2 ^ (d - 1) := by + classical + calc + Fintype.card {u : Seed d r // hashF2 u w = a} = + Fintype.card (Nonpivot (r := r) w hw → F2) := + Fintype.card_congr (hashF2_fiberEquiv w hw a) + _ = 2 ^ (d - 1) := by + change Fintype.card (Nonpivot (r := r) w hw → ZMod 2) = 2 ^ (d - 1) + rw [Fintype.card_fun, ZMod.card, card_nonpivot (r := r) w hw] + +theorem hashF2_surjective (w : Data d) (hw : w ≠ 0) : + Function.Surjective (fun u : Seed d r => hashF2 u w) := by + intro a + let u : {u : Seed d r // hashF2 u w = a} := + (hashF2_fiberEquiv w hw a).symm (fun _ => 0) + exact ⟨u.1, u.2⟩ + +def hashF2_collisionEquiv (x y : Data d) : + {u : Seed d r // hashF2 u x = hashF2 u y} ≃ + {u : Seed d r // hashF2 u (x - y) = 0} := + Equiv.subtypeEquivRight fun u => by + rw [hashF2_sub_data, sub_eq_zero] + +theorem hashF2_collision_card (x y : Data d) (hxy : x ≠ y) : + Fintype.card {u : Seed d r // hashF2 u x = hashF2 u y} = 2 ^ (d - 1) := by + calc + Fintype.card {u : Seed d r // hashF2 u x = hashF2 u y} = + Fintype.card {u : Seed d r // hashF2 u (x - y) = 0} := + Fintype.card_congr (hashF2_collisionEquiv (r := r) x y) + _ = 2 ^ (d - 1) := + hashF2_fiber_card (x - y) (sub_ne_zero.mpr hxy) 0 + +end + +end BinaryHash +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/HashProbability.lean b/lean/OAI/Computability/DepthThree/HashProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a8e92e96cd9a7010a785b3b63b7c387453b7f6b --- /dev/null +++ b/lean/OAI/Computability/DepthThree/HashProbability.lean @@ -0,0 +1,201 @@ +import OAI.Computability.DepthThree.HashBool +import OAI.Computability.DepthThree.FiniteProbabilityBounds +import OAI.Computability.DepthThree.RestrictionProbability +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +theorem finiteProb_eq_card_div {Ω : Type uDepth1} [Fintype Ω] (P : Ω → Prop) : + finiteProb P = (Fintype.card {ω // P ω} : ℝ) / Fintype.card Ω := by + simp [finiteProb, finiteAvg, Fintype.card_subtype, div_eq_mul_inv, mul_comm] + +private theorem finiteProb_eq_card_div_decidable {Ω : Type uDepth2} [Fintype Ω] + (P : Ω → Prop) [DecidablePred P] : + finiteProb P = (Fintype.card {ω // P ω} : ℝ) / Fintype.card Ω := by + rw [finiteProb_eq_card_div] + exact congrArg (fun k : ℕ => (k : ℝ) / Fintype.card Ω) + (congrArg (@Fintype.card {ω // P ω}) (Subsingleton.elim _ _)) + +namespace BinaryHash + +variable {d r : ℕ} + +private theorem normalize_hash_count (hd : 0 < d) (c : ℝ) : + c * (2 : ℝ) ^ (d - 1) / (2 : ℝ) ^ (d + r - 1) = c / (2 : ℝ) ^ r := by + have he : d + r - 1 = (d - 1) + r := by omega + rw [he, pow_add, mul_comm c] + exact mul_div_mul_left c _ (pow_ne_zero _ (by norm_num)) + +theorem hashBool_fiber_probability (x : Fin d → Bool) + (hx : x ≠ fun _ => false) (a : Fin r → Bool) : + finiteProb (fun u : Fin (d + r - 1) → Bool => hashBool u x = a) = + ((2 : ℝ) ^ r)⁻¹ := by + have hd : 0 < d := by + by_contra h + have hd0 : d = 0 := by omega + subst d + exact hx (Subsingleton.elim _ _) + rw [finiteProb_eq_card_div_decidable + (fun u : Fin (d + r - 1) → Bool => hashBool u x = a), hashBool_fiber_card x hx] + have hc : (Fintype.card (Fin (d + r - 1) → Bool) : ℝ) = + (2 : ℝ) ^ (d + r - 1) := by simp [] + rw [hc] + simp only [Nat.cast_pow, Nat.cast_ofNat] + simpa only [one_mul, one_div] using normalize_hash_count (r := r) hd 1 + +theorem hashBool_collision_probability (x y : Fin d → Bool) (hxy : x ≠ y) : + finiteProb (fun u : Fin (d + r - 1) → Bool => hashBool u x = hashBool u y) = + ((2 : ℝ) ^ r)⁻¹ := by + have hd : 0 < d := by + by_contra h + have hd0 : d = 0 := by omega + subst d + exact hxy (Subsingleton.elim _ _) + rw [finiteProb_eq_card_div_decidable + (fun u : Fin (d + r - 1) → Bool => hashBool u x = hashBool u y), + hashBool_collision_card x y hxy] + have hc : (Fintype.card (Fin (d + r - 1) → Bool) : ℝ) = + (2 : ℝ) ^ (d + r - 1) := by simp [] + rw [hc] + simp only [Nat.cast_pow, Nat.cast_ofNat] + simpa only [one_mul, one_div] using normalize_hash_count (r := r) hd 1 + +theorem hashBool_badSeed_probability_le (T : Finset (Fin d)) + (rho : {i : Fin d // i ∉ T} → Bool) : + finiteProb (fun u : Fin (d + r - 1) → Bool => + ¬ Set.InjOn (hashBool u) (boolCoordinateCube T rho)) ≤ + ((2 : ℝ) ^ T.card - 1) / (2 : ℝ) ^ r := by + by_cases hd0 : d = 0 + · subst d + have hT : T = ∅ := by + ext i + exact Fin.elim0 i + have hinj (u : Fin (0 + r - 1) → Bool) : + Set.InjOn (hashBool u) (boolCoordinateCube T rho) := by + intro x hx y hy hxy + exact Subsingleton.elim _ _ + simp [finiteProb, hinj, hT] + have hd : 0 < d := Nat.pos_of_ne_zero hd0 + have hcount := hashBool_badSeed_card_le (r := r) T rho + have hcast : + (Fintype.card {u : Fin (d + r - 1) → Bool // + ¬ Set.InjOn (hashBool u) (boolCoordinateCube T rho)} : ℝ) ≤ + ((2 : ℕ) ^ T.card - 1 : ℕ) * (2 : ℝ) ^ (d - 1) := by + exact_mod_cast hcount + have hpow : 1 ≤ (2 : ℕ) ^ T.card := by + have hp : 0 < (2 : ℕ) ^ T.card := pow_pos (by decide) _ + omega + have hsub : (((2 : ℕ) ^ T.card - 1 : ℕ) : ℝ) = + (2 : ℝ) ^ T.card - 1 := by + rw [Nat.cast_sub hpow] + simp + have hc : (Fintype.card (Fin (d + r - 1) → Bool) : ℝ) = + (2 : ℝ) ^ (d + r - 1) := by simp [] + rw [hsub] at hcast + rw [finiteProb_eq_card_div_decidable + (fun u : Fin (d + r - 1) → Bool => + ¬ Set.InjOn (hashBool u) (boolCoordinateCube T rho)), hc] + calc + _ ≤ (((2 : ℝ) ^ T.card - 1) * (2 : ℝ) ^ (d - 1)) / + (2 : ℝ) ^ (d + r - 1) := + div_le_div_of_nonneg_right hcast (by positivity) + _ = _ := normalize_hash_count hd _ + +theorem hashBool_badSeed_probability_le_pow (T : Finset (Fin d)) + (rho : {i : Fin d // i ∉ T} → Bool) : + finiteProb (fun u : Fin (d + r - 1) → Bool => + ¬ Set.InjOn (hashBool u) (boolCoordinateCube T rho)) ≤ + (2 : ℝ) ^ T.card / (2 : ℝ) ^ r := by + exact (hashBool_badSeed_probability_le T rho).trans + (div_le_div_of_nonneg_right (by linarith) (by positivity)) + +def restrictionFixed (σ : Restriction (Fin d)) : + {i : Fin d // i ∉ liveSet σ} → Bool := + fun i => (σ i.val).getD false + +theorem fill_mem_boolCoordinateCube (σ : Restriction (Fin d)) (z : Cube (Live σ)) : + fill σ z ∈ boolCoordinateCube (liveSet σ) (restrictionFixed σ) := by + intro i hi + have hn : σ i ≠ none := fun h => hi ((mem_liveSet σ i).mpr h) + simp [fill, hn, restrictionFixed] + +theorem range_fill_eq_boolCoordinateCube (σ : Restriction (Fin d)) : + Set.range (fill σ) = boolCoordinateCube (liveSet σ) (restrictionFixed σ) := by + ext x + constructor + · rintro ⟨z, rfl⟩ + exact fill_mem_boolCoordinateCube σ z + · intro hx + refine ⟨fun v => x v.val, ?_⟩ + funext i + by_cases hi : σ i = none + · simp [fill, hi] + · have hnot : i ∉ liveSet σ := fun h => hi ((mem_liveSet σ i).mp h) + simpa [fill, hi, restrictionFixed] using (hx i hnot).symm + +theorem fill_injective (σ : Restriction (Fin d)) : Function.Injective (fill σ) := by + intro z w h + funext v + simpa only [fill_live] using congrFun h v.val + +theorem hashBool_fill_injective_iff (σ : Restriction (Fin d)) + (u : Fin (d + r - 1) → Bool) : + Function.Injective (fun z : Cube (Live σ) => hashBool u (fill σ z)) ↔ + Set.InjOn (hashBool u) (boolCoordinateCube (liveSet σ) (restrictionFixed σ)) := by + constructor + · intro h x hx y hy hxy + rw [← range_fill_eq_boolCoordinateCube] at hx hy + obtain ⟨z, rfl⟩ := hx + obtain ⟨w, rfl⟩ := hy + exact congrArg (fill σ) (h hxy) + · intro h z w hzw + apply fill_injective σ + exact h (fill_mem_boolCoordinateCube σ z) (fill_mem_boolCoordinateCube σ w) hzw + +theorem card_liveSet (σ : Restriction (Fin d)) : + (liveSet σ).card = Fintype.card (Live σ) := by + let e : Live σ ≃ ↥(liveSet σ) := + Equiv.subtypeEquivRight (fun i => (mem_liveSet σ i).symm) + exact ((Fintype.card_congr e).trans (Fintype.card_coe (liveSet σ))).symm + +theorem hashBool_restriction_failure_le (σ : Restriction (Fin d)) : + finiteProb (fun u : Fin (d + r - 1) → Bool => + ¬ Function.Injective (fun z : Cube (Live σ) => hashBool u (fill σ z))) ≤ + ((2 : ℝ) ^ Fintype.card (Live σ) - 1) / (2 : ℝ) ^ r := by + have he : finiteProb (fun u : Fin (d + r - 1) → Bool => + ¬ Function.Injective (fun z : Cube (Live σ) => hashBool u (fill σ z))) = + finiteProb (fun u : Fin (d + r - 1) → Bool => + ¬ Set.InjOn (hashBool u) (boolCoordinateCube (liveSet σ) (restrictionFixed σ))) := by + apply finiteAvg_congr + intro u + by_cases h : Set.InjOn (hashBool u) (boolCoordinateCube (liveSet σ) (restrictionFixed σ)) + · have h' := (hashBool_fill_injective_iff σ u).mpr h + simp [h, h'] + · have h' := mt (hashBool_fill_injective_iff σ u).mp h + simp [h, h'] + rw [he] + simpa only [card_liveSet] using + hashBool_badSeed_probability_le (r := r) (liveSet σ) (restrictionFixed σ) + +theorem hashBool_restriction_failure_le_pow (σ : Restriction (Fin d)) : + finiteProb (fun u : Fin (d + r - 1) → Bool => + ¬ Function.Injective (fun z : Cube (Live σ) => hashBool u (fill σ z))) ≤ + (2 : ℝ) ^ Fintype.card (Live σ) / (2 : ℝ) ^ r := by + exact (hashBool_restriction_failure_le σ).trans + (div_le_div_of_nonneg_right (by linarith) (by positivity)) + +end BinaryHash +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/HashTriangular.lean b/lean/OAI/Computability/DepthThree/HashTriangular.lean new file mode 100644 index 0000000000000000000000000000000000000000..9145e2f5bc714639b9e95d56bb0d223842d2f988 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/HashTriangular.lean @@ -0,0 +1,144 @@ +import OAI.Computability.DepthThree.Hash +import Mathlib.Data.Finset.Max +import Mathlib.Data.Fintype.EquivFin + +namespace OAI + +namespace DepthThreeLowerBound.BinaryHash + +open scoped BigOperators + +theorem exists_last_nonzero {d : ℕ} (w : Data d) (hw : w ≠ 0) : + ∃ s : Fin d, w s ≠ 0 ∧ ∀ a : Fin d, s.val < a.val → w a = 0 := by + classical + have hex : ∃ a : Fin d, w a ≠ 0 := by + by_contra h + apply hw + funext a + by_contra ha + exact h ⟨a, ha⟩ + obtain ⟨a, ha⟩ := hex + obtain ⟨s, hs, hmax⟩ := Finset.exists_max_image + (Finset.univ.filter fun a : Fin d => w a ≠ 0) Fin.val + ⟨a, by simp [ha]⟩ + refine ⟨s, (Finset.mem_filter.mp hs).2, ?_⟩ + intro b hsb + by_contra hb + have hle := hmax b (by simp [hb]) + omega + +noncomputable def lastIndex {d : ℕ} (w : Data d) (hw : w ≠ 0) : Fin d := + (exists_last_nonzero w hw).choose + +theorem lastIndex_nonzero {d : ℕ} (w : Data d) (hw : w ≠ 0) : + w (lastIndex w hw) ≠ 0 := + (exists_last_nonzero w hw).choose_spec.1 + +theorem zero_after_lastIndex {d : ℕ} (w : Data d) (hw : w ≠ 0) + (a : Fin d) (ha : (lastIndex w hw).val < a.val) : w a = 0 := + (exists_last_nonzero w hw).choose_spec.2 a ha + +theorem data_dim_pos {d : ℕ} (w : Data d) (hw : w ≠ 0) : 0 < d := + Nat.zero_le (lastIndex w hw).val |>.trans_lt (lastIndex w hw).isLt + +def Nonpivot {d r : ℕ} (w : Data d) (hw : w ≠ 0) := + {j : Fin (d + r - 1) // ¬ ∃ i : Fin r, sumIndex i (lastIndex w hw) = j} + +noncomputable instance {d r : ℕ} (w : Data d) (hw : w ≠ 0) : + Fintype (Nonpivot (r := r) w hw) := by + classical + unfold Nonpivot + infer_instance + +theorem card_nonpivot {d r : ℕ} (w : Data d) (hw : w ≠ 0) : + Fintype.card (Nonpivot (r := r) w hw) = d - 1 := by + classical + have hp : Fintype.card + {j : Fin (d + r - 1) // ∃ i : Fin r, sumIndex i (lastIndex w hw) = j} = r := by + let e : Fin r ≃ + {j : Fin (d + r - 1) // ∃ i : Fin r, sumIndex i (lastIndex w hw) = j} := + Equiv.ofInjective (fun i : Fin r => sumIndex i (lastIndex w hw)) + (sumIndex_left_injective (lastIndex w hw)) + simpa only [Fintype.card_fin] using (Fintype.card_congr e).symm + calc + Fintype.card (Nonpivot (r := r) w hw) = Fintype.card + {j : Fin (d + r - 1) // ¬ ∃ i : Fin r, sumIndex i (lastIndex w hw) = j} := + Fintype.card_congr (Equiv.refl _) + _ = (d + r - 1) - r := by + rw [Fintype.card_subtype_compl, hp, Fintype.card_fin] + _ = d - 1 := by + have hd := data_dim_pos w hw + omega + +def triangularMap {d r : ℕ} (w : Data d) (hw : w ≠ 0) (u : Seed d r) : + Output r × (Nonpivot (r := r) w hw → F2) := + (hashF2 u w, fun j => u j.val) + +theorem triangularMap_injective {d r : ℕ} (w : Data d) (hw : w ≠ 0) : + Function.Injective (triangularMap (r := r) w hw) := by + classical + intro u v huv + have hhash : hashF2 u w = hashF2 v w := congrArg Prod.fst huv + have hfree : (fun j : Nonpivot (r := r) w hw => u j.val) = + (fun j : Nonpivot (r := r) w hw => v j.val) := congrArg Prod.snd huv + have heq : ∀ n : ℕ, ∀ j : Fin (d + r - 1), j.val = n → u j = v j := by + intro n + induction n using Nat.strong_induction_on with + | h n ih => + intro j hj + by_cases hp : ∃ i : Fin r, sumIndex i (lastIndex w hw) = j + · obtain ⟨i, rfl⟩ := hp + have hrow : (∑ a : Fin d, + (u (sumIndex i a) - v (sumIndex i a)) * w a) = 0 := by + calc + (∑ a : Fin d, (u (sumIndex i a) - v (sumIndex i a)) * w a) = + hashF2 u w i - hashF2 v w i := by + simp only [hashF2, sub_mul, Finset.sum_sub_distrib] + _ = 0 := sub_eq_zero.mpr (congrFun hhash i) + have hsingle : (∑ a : Fin d, + (u (sumIndex i a) - v (sumIndex i a)) * w a) = + (u (sumIndex i (lastIndex w hw)) - + v (sumIndex i (lastIndex w hw))) * w (lastIndex w hw) := by + apply Finset.sum_eq_single_of_mem (lastIndex w hw) (Finset.mem_univ _) + intro a _ ha + by_cases hlt : a.val < (lastIndex w hw).val + · have hidx : (sumIndex i a).val < n := by + simp only [sumIndex_val] at hj ⊢ + omega + rw [ih (sumIndex i a).val hidx (sumIndex i a) rfl, sub_self, zero_mul] + · have hne : a.val ≠ (lastIndex w hw).val := by + intro he + exact ha (Fin.ext he) + have hgt : (lastIndex w hw).val < a.val := by omega + rw [zero_after_lastIndex w hw a hgt, mul_zero] + rw [hsingle] at hrow + exact sub_eq_zero.mp ((mul_eq_zero.mp hrow).resolve_right (lastIndex_nonzero w hw)) + · exact congrFun hfree ⟨j, hp⟩ + exact funext fun j => heq j.val j rfl + +theorem triangularMap_bijective {d r : ℕ} (w : Data d) (hw : w ≠ 0) : + Function.Bijective (triangularMap (r := r) w hw) := by + classical + apply (Fintype.bijective_iff_injective_and_card _).2 + refine ⟨triangularMap_injective w hw, ?_⟩ + have hd := data_dim_pos w hw + simp only [Seed, Output, Fintype.card_prod, Fintype.card_fun, + F2, BinaryAlgebra.F2, ZMod.card, Fintype.card_fin, card_nonpivot] + rw [← pow_add] + congr 1 + omega + +noncomputable def triangularEquiv {d r : ℕ} (w : Data d) (hw : w ≠ 0) : + Seed d r ≃ Output r × (Nonpivot (r := r) w hw → F2) := + Equiv.ofBijective (triangularMap w hw) (triangularMap_bijective w hw) + +@[simp] theorem triangularEquiv_fst {d r : ℕ} (w : Data d) (hw : w ≠ 0) + (u : Seed d r) : (triangularEquiv w hw u).1 = hashF2 u w := rfl + +@[simp] theorem triangularEquiv_snd {d r : ℕ} (w : Data d) (hw : w ≠ 0) + (u : Seed d r) (j : Nonpivot (r := r) w hw) : + (triangularEquiv w hw u).2 j = u j.val := rfl + +end DepthThreeLowerBound.BinaryHash + +end OAI diff --git a/lean/OAI/Computability/DepthThree/InterpolationEvaluation.lean b/lean/OAI/Computability/DepthThree/InterpolationEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..c65157d317f60e6da07197b4f5a0cb5c0a010d2f --- /dev/null +++ b/lean/OAI/Computability/DepthThree/InterpolationEvaluation.lean @@ -0,0 +1,99 @@ +import Mathlib.LinearAlgebra.Lagrange +import OAI.Computability.DepthThree.AlgebraFiniteFibers + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open scoped BigOperators Polynomial + +namespace DepthThreeLowerBound +namespace Interpolation + +variable {F : Type uDepth1} {ι : Type uDepth2} + +def coeffEval [CommSemiring F] (t : ℕ) (a : ι → F) : + (Fin t → F) →ₗ[F] (ι → F) where + toFun β i := ∑ j : Fin t, β j * a i ^ (j : ℕ) + map_add' β γ := by + funext i + simp only [Pi.add_apply, add_mul, Finset.sum_add_distrib] + map_smul' c β := by + funext i + simp only [Pi.smul_apply, smul_eq_mul, Finset.mul_sum, mul_assoc, + RingHom.id_apply] + +@[simp] theorem coeffEval_apply [CommSemiring F] (t : ℕ) (a : ι → F) + (β : Fin t → F) (i : ι) : + coeffEval t a β i = ∑ j : Fin t, β j * a i ^ (j : ℕ) := rfl + +theorem coeffEval_surjective [Field F] [Fintype ι] {t : ℕ} (a : ι → F) + (hsize : Fintype.card ι ≤ t) (ha : Function.Injective a) : + Function.Surjective (coeffEval t a) := by + classical + intro v + let p : F[X] := Lagrange.interpolate Finset.univ a v + have hinj : Set.InjOn a (↑(Finset.univ : Finset ι) : Set ι) := + fun _ _ _ _ hij => ha hij + have hp : p ∈ Polynomial.degreeLT F (Fintype.card ι) := by + apply Polynomial.mem_degreeLT.mpr + simpa only [Finset.card_univ] using Lagrange.degree_interpolate_lt v hinj + have hpt : p ∈ Polynomial.degreeLT F t := Polynomial.degreeLT_mono hsize hp + refine ⟨Polynomial.degreeLTEquiv F t ⟨p, hpt⟩, ?_⟩ + funext i + change (∑ j : Fin t, + Polynomial.degreeLTEquiv F t ⟨p, hpt⟩ j * a i ^ (j : ℕ)) = v i + rw [← Polynomial.eval_eq_sum_degreeLTEquiv hpt] + exact Lagrange.eval_interpolate_at_node v hinj (Finset.mem_univ i) + +section FiniteField + +variable [Field F] [Fintype F] [DecidableEq F] [Fintype ι] [DecidableEq ι] +variable {t : ℕ} (a : ι → F) +variable (hsize : Fintype.card ι ≤ t) (ha : Function.Injective a) + +include hsize ha + +theorem card_coeffEval_fiber_mul (v : ι → F) : + Fintype.card F ^ Fintype.card ι * + Fintype.card {β : Fin t → F // coeffEval t a β = v} = + Fintype.card F ^ t := by + classical + let L := (coeffEval t a).toAddMonoidHom + have hL : Function.Surjective L := coeffEval_surjective a hsize ha + have hcard := AlgebraFiniteFibers.card_eq_mul_card_kernel L hL + rw [← AlgebraFiniteFibers.card_fiber_eq L hL v] at hcard + simp only [Fintype.card_fun, Fintype.card_fin] at hcard + simp only [Fintype.card_eq_nat_card] at hcard ⊢ + simpa only [L, LinearMap.toAddMonoidHom_coe] using hcard.symm + +theorem card_coeffEval_fiber (v : ι → F) : + Fintype.card {β : Fin t → F // coeffEval t a β = v} = + Fintype.card F ^ (t - Fintype.card ι) := by + apply Nat.eq_of_mul_eq_mul_left + (pow_pos (Fintype.card_pos (α := F)) (Fintype.card ι)) + calc + Fintype.card F ^ Fintype.card ι * + Fintype.card {β : Fin t → F // coeffEval t a β = v} = + Fintype.card F ^ t := card_coeffEval_fiber_mul a hsize ha v + _ = Fintype.card F ^ (Fintype.card ι + (t - Fintype.card ι)) := by + rw [Nat.add_sub_of_le hsize] + _ = Fintype.card F ^ Fintype.card ι * + Fintype.card F ^ (t - Fintype.card ι) := pow_add _ _ _ + +theorem finiteAvg_coeffEval (Φ : (ι → F) → ℝ) : + finiteAvg (fun β : Fin t → F => Φ (coeffEval t a β)) = finiteAvg Φ := by + classical + exact AlgebraFiniteFibers.finiteAvg_comp (coeffEval t a).toAddMonoidHom + (coeffEval_surjective a hsize ha) Φ + +end FiniteField + +end Interpolation +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/InterpolationQuotient.lean b/lean/OAI/Computability/DepthThree/InterpolationQuotient.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d44691c55b74bc4e98797fa917b69a724f2486f --- /dev/null +++ b/lean/OAI/Computability/DepthThree/InterpolationQuotient.lean @@ -0,0 +1,93 @@ +import OAI.Computability.DepthThree.AlgebraQuotient +import OAI.Computability.DepthThree.InterpolationSigns + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +namespace DepthThreeLowerBound +namespace Interpolation + +open BinaryAlgebra + +def coefficientEncoding {r : ℕ} (p : Fin r → F2) (t : ℕ) : + (Fin t → Fin r → Bool) ≃ (Fin t → InputQuotient p) := + Equiv.piCongrRight (fun _ => + (bitsEquivF2 (Fin r)).trans (coordinates p).toEquiv.symm) + +@[simp] theorem coefficientEncoding_apply {r t : ℕ} (p : Fin r → F2) + (β : Fin t → Fin r → Bool) (j : Fin t) : + coefficientEncoding p t β j = encode p (fun i => bitValue (β j i)) := rfl + +theorem finiteAvg_coefficientEncoding {r t : ℕ} (p : Fin r → F2) + (Φ : (Fin t → InputQuotient p) → ℝ) : + finiteAvg (fun β : Fin t → Fin r → Bool => + Φ (fun j => encode p (fun i => bitValue (β j i)))) = finiteAvg Φ := + finiteAvg_equiv (coefficientEncoding p t) Φ + +theorem finiteAvg_degreeZero {r : ℕ} (p : Fin r → F2) (hr : 0 < r) + (Φ : F2 → ℝ) : + finiteAvg (fun z : InputQuotient p => Φ (degreeZero (inputPolynomial_monic p) z)) = + finiteAvg Φ := by + classical + exact AlgebraFiniteFibers.finiteAvg_comp + (degreeZero (inputPolynomial_monic p)).toAddMonoidHom + (degreeZero_surjective (inputPolynomial_monic p) + (by simpa only [inputPolynomial_natDegree] using hr)) Φ + +section Irreducible + +variable {r t : ℕ} (p : Fin r → F2) +variable [Fact (Irreducible (inputPolynomial p))] +variable (hr : 0 < r) +variable {ι : Type uDepth1} [Fintype ι] [DecidableEq ι] +variable (a : ι → InputQuotient p) (hsize : Fintype.card ι ≤ t) +variable (ha : Function.Injective a) + +include hr hsize ha + +theorem finiteAvg_quotient_acceptEval (Φ : (ι → Bool) → ℝ) : + finiteAvg (fun β : Fin t → InputQuotient p => + Φ (acceptEval (degreeZero (inputPolynomial_monic p)) t a β)) = finiteAvg Φ := by + exact finiteAvg_acceptEval (degreeZero (inputPolynomial_monic p)) + (degreeZero_one (inputPolynomial_monic p) + (by simpa only [inputPolynomial_natDegree] using hr)) a hsize ha Φ + +theorem finiteAvg_encoded_acceptEval (Φ : (ι → Bool) → ℝ) : + finiteAvg (fun β : Fin t → Fin r → Bool => + Φ (acceptEval (degreeZero (inputPolynomial_monic p)) t a + (fun j => encode p (fun i => bitValue (β j i))))) = finiteAvg Φ := by + calc + finiteAvg (fun β : Fin t → Fin r → Bool => + Φ (acceptEval (degreeZero (inputPolynomial_monic p)) t a + (fun j => encode p (fun i => bitValue (β j i))))) = + finiteAvg (fun β : Fin t → InputQuotient p => + Φ (acceptEval (degreeZero (inputPolynomial_monic p)) t a β)) := + finiteAvg_coefficientEncoding p + (fun β : Fin t → InputQuotient p => + Φ (acceptEval (degreeZero (inputPolynomial_monic p)) t a β)) + _ = finiteAvg Φ := finiteAvg_quotient_acceptEval p hr a hsize ha Φ + +end Irreducible + +theorem finiteAvg_encoded_acceptEval_finset {r t : ℕ} (p : Fin r → F2) + [Fact (Irreducible (inputPolynomial p))] (hr : 0 < r) {Z : Type uDepth2} [DecidableEq Z] + (a : Z → InputQuotient p) (s : Finset Z) (hsize : s.card ≤ t) + (ha : Set.InjOn a (↑s : Set Z)) (Φ : (s → Bool) → ℝ) : + finiteAvg (fun β : Fin t → Fin r → Bool => + Φ (fun z : s => acceptEval (degreeZero (inputPolynomial_monic p)) t a + (fun j => encode p (fun i => bitValue (β j i))) z)) = finiteAvg Φ := by + classical + apply finiteAvg_encoded_acceptEval p hr (fun z : s => a z) + (by simpa only [Fintype.card_coe] using hsize) + intro x y hxy + exact Subtype.ext (ha x.property y.property hxy) + +end Interpolation +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/InterpolationSigns.lean b/lean/OAI/Computability/DepthThree/InterpolationSigns.lean new file mode 100644 index 0000000000000000000000000000000000000000..71dc9e06c570a78b62e9df86bea41d72e416e9a6 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/InterpolationSigns.lean @@ -0,0 +1,164 @@ +import OAI.Computability.DepthThree.AlgebraBits +import OAI.Computability.DepthThree.InterpolationEvaluation + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 + +noncomputable section + +open scoped BigOperators + +namespace DepthThreeLowerBound +namespace Interpolation + +open BinaryAlgebra + +variable {F : Type uDepth1} {ι : Type uDepth2} +variable [Field F] [Module F2 F] + +def bitEval (ell : F →ₗ[F2] F2) (t : ℕ) (a : ι → F) : + (Fin t → F) →+ (ι → F2) where + toFun β i := ell (coeffEval t a β i) + map_zero' := by + funext i + simp only [map_zero, Pi.zero_apply] + map_add' β γ := by + funext i + simp only [map_add, Pi.add_apply] + +@[simp] theorem bitEval_apply (ell : F →ₗ[F2] F2) (t : ℕ) (a : ι → F) + (β : Fin t → F) (i : ι) : + bitEval ell t a β i = ell (∑ j : Fin t, β j * a i ^ (j : ℕ)) := rfl + +theorem functional_surjective (ell : F →ₗ[F2] F2) (hOne : ell 1 = 1) : + Function.Surjective ell := by + intro b + refine ⟨b • (1 : F), ?_⟩ + simp only [map_smul, hOne, smul_eq_mul, mul_one] + +theorem bitEval_surjective [Fintype ι] (ell : F →ₗ[F2] F2) (hOne : ell 1 = 1) + {t : ℕ} (a : ι → F) (hsize : Fintype.card ι ≤ t) + (ha : Function.Injective a) : Function.Surjective (bitEval ell t a) := by + intro b + obtain ⟨β, hβ⟩ := coeffEval_surjective a hsize ha (fun i => b i • (1 : F)) + refine ⟨β, ?_⟩ + funext i + change ell (coeffEval t a β i) = b i + rw [hβ] + simp only [map_smul, hOne, smul_eq_mul, mul_one] + +def coefficientBits (ell : F →ₗ[F2] F2) (t : ℕ) (a : ι → F) + (β : Fin t → F) : ι → Bool := + fun i => fieldBit (bitEval ell t a β i) + +def acceptEval (ell : F →ₗ[F2] F2) (t : ℕ) (a : ι → F) + (β : Fin t → F) : ι → Bool := + fun i => !(coefficientBits ell t a β i) + +@[simp] theorem acceptEval_eq_true (ell : F →ₗ[F2] F2) (t : ℕ) (a : ι → F) + (β : Fin t → F) (i : ι) : + acceptEval ell t a β i = true ↔ + ell (∑ j : Fin t, β j * a i ^ (j : ℕ)) = 0 := by + simp [acceptEval, coefficientBits] + +def complementEquiv (ι : Type uDepth3) : (ι → Bool) ≃ (ι → Bool) where + toFun b i := !(b i) + invFun b i := !(b i) + left_inv b := by funext i; exact Bool.not_not (b i) + right_inv b := by funext i; exact Bool.not_not (b i) + +section Finite + +variable [Fintype F] [Fintype ι] [DecidableEq ι] +variable (ell : F →ₗ[F2] F2) (hOne : ell 1 = 1) +variable {t : ℕ} (a : ι → F) (hsize : Fintype.card ι ≤ t) +variable (ha : Function.Injective a) + +include hOne hsize ha + +theorem finiteAvg_bitEval (Φ : (ι → F2) → ℝ) : + finiteAvg (fun β : Fin t → F => Φ (bitEval ell t a β)) = finiteAvg Φ := by + classical + exact AlgebraFiniteFibers.finiteAvg_comp (bitEval ell t a) + (bitEval_surjective ell hOne a hsize ha) Φ + +theorem finiteAvg_coefficientBits (Φ : (ι → Bool) → ℝ) : + finiteAvg (fun β : Fin t → F => Φ (coefficientBits ell t a β)) = + finiteAvg Φ := by + calc + finiteAvg (fun β : Fin t → F => Φ (coefficientBits ell t a β)) = + finiteAvg (fun b : ι → F2 => Φ ((bitsEquivF2 ι).symm b)) := + finiteAvg_bitEval ell hOne a hsize ha + (fun b : ι → F2 => Φ ((bitsEquivF2 ι).symm b)) + _ = finiteAvg Φ := finiteAvg_equiv (bitsEquivF2 ι).symm Φ + +theorem finiteAvg_acceptEval (Φ : (ι → Bool) → ℝ) : + finiteAvg (fun β : Fin t → F => Φ (acceptEval ell t a β)) = + finiteAvg Φ := by + calc + finiteAvg (fun β : Fin t → F => Φ (acceptEval ell t a β)) = + finiteAvg (fun b : ι → Bool => Φ (complementEquiv ι b)) := + finiteAvg_coefficientBits ell hOne a hsize ha + (fun b : ι → Bool => Φ (complementEquiv ι b)) + _ = finiteAvg Φ := finiteAvg_equiv (complementEquiv ι) Φ + +end Finite + +section FiberCounts + +variable [Fintype F] [DecidableEq F] [Fintype ι] +variable (ell : F →ₗ[F2] F2) (hOne : ell 1 = 1) +variable {t : ℕ} (a : ι → F) (hsize : Fintype.card ι ≤ t) +variable (ha : Function.Injective a) + +include hOne hsize ha + +theorem card_bitEval_fiber_mul (b : ι → F2) : + 2 ^ Fintype.card ι * + Fintype.card {β : Fin t → F // bitEval ell t a β = b} = + Fintype.card F ^ t := by + classical + have hL := bitEval_surjective ell hOne a hsize ha + have hcard := AlgebraFiniteFibers.card_eq_mul_card_kernel (bitEval ell t a) hL + rw [← AlgebraFiniteFibers.card_fiber_eq (bitEval ell t a) hL b] at hcard + simpa only [Fintype.card_fun, Fintype.card_fin, ZMod.card] using hcard.symm + +theorem card_bitEval_fiber {r : ℕ} (hr : 1 ≤ r) + (hcard : Fintype.card F = 2 ^ r) (b : ι → F2) : + Fintype.card {β : Fin t → F // bitEval ell t a β = b} = + 2 ^ (r * t - Fintype.card ι) := by + have hn : Fintype.card ι ≤ r * t := calc + Fintype.card ι ≤ t := hsize + _ = 1 * t := (one_mul t).symm + _ ≤ r * t := Nat.mul_le_mul_right t hr + apply Nat.eq_of_mul_eq_mul_left (pow_pos (by decide : 0 < (2 : ℕ)) _) + calc + 2 ^ Fintype.card ι * + Fintype.card {β : Fin t → F // bitEval ell t a β = b} = + Fintype.card F ^ t := card_bitEval_fiber_mul ell hOne a hsize ha b + _ = 2 ^ (r * t) := by rw [hcard, pow_mul] + _ = 2 ^ (Fintype.card ι + (r * t - Fintype.card ι)) := by + rw [Nat.add_sub_of_le hn] + _ = 2 ^ Fintype.card ι * 2 ^ (r * t - Fintype.card ι) := pow_add _ _ _ + +end FiberCounts + +theorem finiteAvg_acceptEval_finset [Fintype F] {Z : Type uDepth4} [DecidableEq Z] + (ell : F →ₗ[F2] F2) (hOne : ell 1 = 1) {t : ℕ} (a : Z → F) + (s : Finset Z) (hsize : s.card ≤ t) + (ha : Set.InjOn a (↑s : Set Z)) (Φ : (s → Bool) → ℝ) : + finiteAvg (fun β : Fin t → F => Φ (fun z : s => acceptEval ell t a β z)) = + finiteAvg Φ := by + classical + apply finiteAvg_acceptEval ell hOne (fun z : s => a z) + (by simpa only [Fintype.card_coe] using hsize) + intro x y hxy + exact Subtype.ext (ha x.property y.property hxy) + +end Interpolation +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/IrreducibleEncoding.lean b/lean/OAI/Computability/DepthThree/IrreducibleEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fd958b37966fd0217e0744314ca7a1e09da6896 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/IrreducibleEncoding.lean @@ -0,0 +1,39 @@ +import OAI.Computability.DepthThree.AlgebraPolynomial +import OAI.Computability.DepthThree.IrreduciblePolynomial + +namespace OAI + +namespace DepthThreeLowerBound +namespace BinaryAlgebra + +def polynomialBits (P : Polynomial F2) (r : ℕ) : Fin r → Bool := + fun i => fieldBit (P.coeff i.val) + +theorem inputPolynomialBits_polynomialBits (P : Polynomial F2) (hP : P.Monic) + {r : ℕ} (hdegree : P.natDegree = r) : + inputPolynomialBits (polynomialBits P r) = P := by + ext j + rcases lt_trichotomy j r with hj | rfl | hj + · simpa only [polynomialBits, bitValue_fieldBit] using + inputPolynomialBits_coeff_lt (polynomialBits P r) ⟨j, hj⟩ + · rw [inputPolynomialBits_coeff_leading] + simpa only [hdegree] using hP.coeff_natDegree.symm + · have hleft : (inputPolynomialBits (polynomialBits P r)).coeff j = 0 := + inputPolynomial_coeff_of_gt _ hj + rw [hleft] + symm + apply Polynomial.coeff_eq_zero_of_natDegree_lt + simpa only [hdegree] using hj + +end BinaryAlgebra + +theorem exists_irreducible_inputPolynomialBits (r : ℕ) (hr : 0 < r) : + ∃ p : Fin r → Bool, Irreducible (BinaryAlgebra.inputPolynomialBits p) := by + obtain ⟨P, hP, hI, hdegree⟩ := exists_monic_irreducible_natDegree_two r hr + refine ⟨BinaryAlgebra.polynomialBits P r, ?_⟩ + rw [BinaryAlgebra.inputPolynomialBits_polynomialBits P hP hdegree] + exact hI + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/IrreduciblePolynomial.lean b/lean/OAI/Computability/DepthThree/IrreduciblePolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..ccd254f96451ea8aa8bbaa73a33ab25871984681 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/IrreduciblePolynomial.lean @@ -0,0 +1,29 @@ +import Mathlib.FieldTheory.Finite.GaloisField + +namespace OAI + +namespace DepthThreeLowerBound + +theorem exists_monic_irreducible_natDegree_two (r : ℕ) (hr : 0 < r) : + ∃ P : Polynomial (ZMod 2), + P.Monic ∧ Irreducible P ∧ P.natDegree = r := by + let : Fact (Nat.Prime 2) := ⟨Nat.prime_two⟩ + obtain ⟨α, hα⟩ := Field.exists_primitive_element_of_finite_top + (ZMod 2) (GaloisField 2 r) + have hαint : IsIntegral (ZMod 2) α := IsIntegral.of_finite (ZMod 2) α + refine ⟨minpoly (ZMod 2) α, minpoly.monic hαint, + minpoly.irreducible hαint, ?_⟩ + exact ((Field.primitive_element_iff_minpoly_natDegree_eq + (ZMod 2) α).mp hα).trans + (GaloisField.finrank 2 (Nat.ne_of_gt hr)) + +theorem exists_monic_irreducible_degree_two (r : ℕ) (hr : 0 < r) : + ∃ P : Polynomial (ZMod 2), + P.Monic ∧ Irreducible P ∧ P.degree = (r : WithBot ℕ) := by + obtain ⟨P, hP, hI, hdegree⟩ := exists_monic_irreducible_natDegree_two r hr + refine ⟨P, hP, hI, ?_⟩ + rw [Polynomial.degree_eq_natDegree hP.ne_zero, hdegree] + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/Language.lean b/lean/OAI/Computability/DepthThree/Language.lean new file mode 100644 index 0000000000000000000000000000000000000000..d532f7c7c3e57ae67fc993120e062bca00015d6a --- /dev/null +++ b/lean/OAI/Computability/DepthThree/Language.lean @@ -0,0 +1,81 @@ +import OAI.Computability.DepthThree.LanguageParser +import OAI.Computability.DepthThree.AlgebraPolynomial +import OAI.Computability.DepthThree.Hash +import Mathlib.Algebra.Polynomial.Div + +namespace OAI + +namespace DepthThreeLowerBound + +noncomputable section + +open scoped BigOperators + +namespace ParsedInput + +def hashPolynomial (q : ParsedInput) : Polynomial (ZMod 2) := + BinaryAlgebra.pack fun i => + BinaryAlgebra.bitValue (BinaryHash.hashBool q.hashSeed q.data i) + +def coefficientPolynomial (q : ParsedInput) (j : Fin q.coefficientCount) : + Polynomial (ZMod 2) := + BinaryAlgebra.pack fun i => BinaryAlgebra.bitValue (q.coefficients j i) + +def modulus (q : ParsedInput) : Polynomial (ZMod 2) := + BinaryAlgebra.inputPolynomialBits q.polynomial + +theorem modulus_monic (q : ParsedInput) : q.modulus.Monic := + BinaryAlgebra.inputPolynomialBits_monic q.polynomial + +theorem modulus_degree (q : ParsedInput) : + q.modulus.degree = (q.ringDegree : WithBot ℕ) := + BinaryAlgebra.inputPolynomialBits_degree q.polynomial + +def evaluationPolynomial (q : ParsedInput) : Polynomial (ZMod 2) := + ∑ j : Fin q.coefficientCount, + q.coefficientPolynomial j * q.hashPolynomial ^ j.val + +def evaluationRemainder (q : ParsedInput) : Polynomial (ZMod 2) := + q.evaluationPolynomial %ₘ q.modulus + +theorem evaluationRemainder_degree_lt (q : ParsedInput) : + q.evaluationRemainder.degree < (q.ringDegree : WithBot ℕ) := by + rw [evaluationRemainder, ← q.modulus_degree] + exact Polynomial.degree_modByMonic_lt _ q.modulus_monic + +def evaluate (q : ParsedInput) : Bool := + decide (q.evaluationRemainder.coeff 0 = 0) + +theorem evaluate_eq_true_iff (q : ParsedInput) : + q.evaluate = true ↔ q.evaluationRemainder.coeff 0 = 0 := by + simp only [evaluate, decide_eq_true_eq] + +end ParsedInput + +def language (w : List Bool) : Bool := + match parseInput w with + | none => false + | some q => q.evaluate + +theorem language_of_not_fits {w : List Bool} (h : ¬InputFits w) : + language w = false := by + simp only [language, parseInput_of_not_fits h] + +theorem language_of_fits {w : List Bool} (h : InputFits w) : + language w = (decodeInput w).evaluate := by + simp only [language, parseInput_of_fits h] + +theorem language_eq_true_iff (w : List Bool) : + language w = true ↔ + InputFits w ∧ (decodeInput w).evaluationRemainder.coeff 0 = 0 := by + by_cases h : InputFits w + · rw [language_of_fits h, ParsedInput.evaluate_eq_true_iff] + simp only [h, true_and] + · rw [language_of_not_fits h] + simp only [Bool.false_eq_true, h, false_and] + +end + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageBitArithmetic.lean b/lean/OAI/Computability/DepthThree/LanguageBitArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7c1b3e5cadbb67b1351a3b387fde7143251b90a --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageBitArithmetic.lean @@ -0,0 +1,137 @@ +import OAI.Computability.DepthThree.LanguageBitConvolution +import Mathlib.Algebra.Polynomial.Div +import Lean.Elab.Tactic.Omega + +namespace OAI + +namespace DepthThreeLowerBound + +open BinaryAlgebra +open Polynomial + +def wordFreeze {n : ℕ} (a : BitWord n) : BitWord n := + listWord n (wordList a) + +@[simp] theorem wordFreeze_eq {n : ℕ} (a : BitWord n) : wordFreeze a = a := + listWord_wordList a + +def cancelStep {r m : ℕ} (p : BitWord r) (k : ℕ) (a : BitWord m) : BitWord m := + if h : r ≤ k ∧ k < m then + if a ⟨k, h.2⟩ = true then + wordFreeze (wordXor a (shiftModulus p (k - r))) + else a + else a + +theorem cancelStep_above {r m : ℕ} (p : BitWord r) (k : ℕ) + (a : BitWord m) (i : Fin m) (hi : k < i.val) : + cancelStep p k a i = a i := by + by_cases hk : r ≤ k ∧ k < m + · by_cases ha : a ⟨k, hk.2⟩ = true + · have hs : k - r + r < i.val := by omega + simp [cancelStep, hk, ha, wordXor, shiftModulus_above p (k - r) i hs] + · simp [cancelStep, hk, ha] + · simp [cancelStep, hk] + +theorem cancelStep_at {r m : ℕ} (p : BitWord r) (a : BitWord m) + (i : Fin m) (hi : r ≤ i.val) : cancelStep p i.val a i = false := by + have hk : r ≤ i.val ∧ i.val < m := ⟨hi, i.is_lt⟩ + have hs : i.val - r + r = i.val := by omega + by_cases ha : a i = true + · simp [cancelStep, hk, ha, wordXor, shiftModulus, hs] + · have hf : a i = false := Bool.eq_false_of_not_eq_true ha + simp [cancelStep, hk, ha] + +theorem wordPoly_cancelStep_mod {r m : ℕ} (p : BitWord r) + (k : ℕ) (a : BitWord m) : + wordPoly (cancelStep p k a) %ₘ inputPolynomialBits p = + wordPoly a %ₘ inputPolynomialBits p := by + by_cases hk : r ≤ k ∧ k < m + · by_cases ha : a ⟨k, hk.2⟩ = true + · have hs : k - r + r < m := by omega + simp only [cancelStep, dite_eq_left hk, ite_eq_left ha, wordFreeze_eq, + wordPoly_xor, wordPoly_shiftModulus p (k - r) hs, + Polynomial.add_modByMonic, + Polynomial.mul_self_modByMonic (inputPolynomialBits_monic p), add_zero] + · simp [cancelStep, hk, ha] + · simp [cancelStep, hk] + +def reduceLoop {r m : ℕ} (p : BitWord r) : ℕ → BitWord m → BitWord m + | 0, a => a + | k + 1, a => reduceLoop p k (cancelStep p k a) + +theorem wordPoly_reduceLoop_mod {r m : ℕ} (p : BitWord r) + (k : ℕ) (a : BitWord m) : + wordPoly (reduceLoop p k a) %ₘ inputPolynomialBits p = + wordPoly a %ₘ inputPolynomialBits p := by + induction k generalizing a with + | zero => rfl + | succ k ih => + exact (ih (cancelStep p k a)).trans (wordPoly_cancelStep_mod p k a) + +theorem reduceLoop_tail_false {r m : ℕ} (p : BitWord r) (k : ℕ) + (a : BitWord m) + (ha : ∀ i : Fin m, r ≤ i.val → k ≤ i.val → a i = false) : + ∀ i : Fin m, r ≤ i.val → reduceLoop p k a i = false := by + induction k generalizing a with + | zero => + intro i hi + exact ha i hi (Nat.zero_le _) + | succ k ih => + apply ih (cancelStep p k a) + intro i hri hki + by_cases hlt : k < i.val + · rw [cancelStep_above p k a i hlt] + exact ha i hri (by omega) + · have he : k = i.val := by omega + subst k + exact cancelStep_at p a i hri + +def wordResize {m : ℕ} (r : ℕ) (a : BitWord m) : BitWord r := + fun i => wordGet a i.val + +theorem wordPoly_resize_of_tail_false {r m : ℕ} (a : BitWord m) + (ha : ∀ i : Fin m, r ≤ i.val → a i = false) : + wordPoly (wordResize r a) = wordPoly a := by + ext i + rw [coeff_wordPoly, coeff_wordPoly] + apply congrArg bitValue + by_cases hi : i < r + · simp [wordGet, wordResize, hi] + · rw [wordGet_of_le _ (Nat.le_of_not_lt hi)] + by_cases hm : i < m + · rw [wordGet_of_lt a hm, ha ⟨i, hm⟩ (Nat.le_of_not_lt hi)] + · rw [wordGet_of_le a (Nat.le_of_not_lt hm)] + +def wordReduce {r m : ℕ} (p : BitWord r) (a : BitWord m) : BitWord r := + wordFreeze (wordResize r (reduceLoop p m a)) + +theorem wordPoly_reduce {r m : ℕ} (p : BitWord r) (a : BitWord m) : + wordPoly (wordReduce p a) = wordPoly a %ₘ inputPolynomialBits p := by + have ht : ∀ i : Fin m, r ≤ i.val → reduceLoop p m a i = false := + reduceLoop_tail_false p m a (by + intro i _ hi + exact False.elim (Nat.not_le.mpr i.is_lt hi)) + have hd : (wordPoly (reduceLoop p m a)).degree < + (inputPolynomialBits p).degree := by + rw [inputPolynomialBits_degree] + exact degree_wordPoly_lt_of_tail_false _ ht + have hs := (Polynomial.modByMonic_eq_self_iff + (inputPolynomialBits_monic p)).2 hd + calc + wordPoly (wordReduce p a) = wordPoly (reduceLoop p m a) := by + simp only [wordReduce, wordFreeze_eq] + exact wordPoly_resize_of_tail_false _ ht + _ = wordPoly (reduceLoop p m a) %ₘ inputPolynomialBits p := hs.symm + _ = wordPoly a %ₘ inputPolynomialBits p := wordPoly_reduceLoop_mod p m a + +def wordMulMod {r : ℕ} (p a b : BitWord r) : BitWord r := + wordReduce p (wordConvolve a b) + +theorem wordPoly_mulMod {r : ℕ} (p a b : BitWord r) : + wordPoly (wordMulMod p a b) = + (wordPoly a * wordPoly b) %ₘ inputPolynomialBits p := by + rw [wordMulMod, wordPoly_reduce, wordPoly_convolve] + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageBitConvolution.lean b/lean/OAI/Computability/DepthThree/LanguageBitConvolution.lean new file mode 100644 index 0000000000000000000000000000000000000000..21de83f176b183d3b5bc9dbda05c9f5b5023c6fe --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageBitConvolution.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DepthThree.LanguageBitWord +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Data.List.OfFn + +namespace OAI + +namespace DepthThreeLowerBound + +open scoped BigOperators + +def xorBits (xs : List Bool) : Bool := xs.foldr Bool.xor false + +@[simp] theorem xorBits_nil : xorBits [] = false := rfl + +@[simp] theorem xorBits_cons (x : Bool) (xs : List Bool) : + xorBits (x :: xs) = Bool.xor x (xorBits xs) := rfl + +theorem bitValue_xorBits (xs : List Bool) : + BinaryAlgebra.bitValue (xorBits xs) = (xs.map BinaryAlgebra.bitValue).sum := by + induction xs with + | nil => rfl + | cons x xs ih => + change BinaryAlgebra.bitValue (Bool.xor x (xorBits xs)) = + BinaryAlgebra.bitValue x + (xs.map BinaryAlgebra.bitValue).sum + rw [BinaryAlgebra.bitValue_xor, ih] + +theorem bitValue_xorBits_ofFn {n : ℕ} (f : Fin n → Bool) : + BinaryAlgebra.bitValue (xorBits (List.ofFn f)) = + ∑ i : Fin n, BinaryAlgebra.bitValue (f i) := by + simp only [bitValue_xorBits, List.map_ofFn, List.sum_ofFn, Function.comp_apply] + +def wordConvolve {r s : ℕ} (a : BitWord r) (b : BitWord s) : BitWord (r + s) := + fun k => xorBits (List.ofFn fun i : Fin r => + xorBits (List.ofFn fun j : Fin s => + if i.val + j.val = k.val then a i && b j else false)) + +theorem coeff_wordPoly_mul {r s : ℕ} (a : BitWord r) (b : BitWord s) (k : ℕ) : + (wordPoly a * wordPoly b).coeff k = + ∑ i : Fin r, ∑ j : Fin s, + if i.val + j.val = k then + BinaryAlgebra.bitValue (a i) * BinaryAlgebra.bitValue (b j) + else 0 := by + classical + simp only [wordPoly, BinaryAlgebra.pack, Finset.sum_mul_sum, + Polynomial.monomial_mul_monomial, Polynomial.finsetSum_coeff, + Polynomial.coeff_monomial] + +theorem wordPoly_convolve {r s : ℕ} (a : BitWord r) (b : BitWord s) : + wordPoly (wordConvolve a b) = wordPoly a * wordPoly b := by + ext k + rw [coeff_wordPoly, coeff_wordPoly_mul] + by_cases hk : k < r + s + · rw [wordGet_of_lt _ hk] + simp only [wordConvolve, bitValue_xorBits_ofFn, apply_ite, + BinaryAlgebra.bitValue_and, BinaryAlgebra.bitValue_false] + · rw [wordGet_of_le _ (Nat.le_of_not_lt hk), BinaryAlgebra.bitValue_false] + symm + apply Finset.sum_eq_zero + intro i _ + apply Finset.sum_eq_zero + intro j _ + have hsum : i.val + j.val < r + s := Nat.add_lt_add i.is_lt j.is_lt + have hne : i.val + j.val ≠ k := by omega + simp [hne] + +def wordList {n : ℕ} (a : BitWord n) : List Bool := List.ofFn a + +def listWord (n : ℕ) (xs : List Bool) : BitWord n := + fun i => xs.getD i.val false + +@[simp] theorem wordList_length {n : ℕ} (a : BitWord n) : + (wordList a).length = n := List.length_ofFn + +theorem wordList_getD {n : ℕ} (a : BitWord n) (i : ℕ) : + (wordList a).getD i false = wordGet a i := by + by_cases hi : i < n <;> simp [wordList, wordGet, hi] + +@[simp] theorem listWord_wordList {n : ℕ} (a : BitWord n) : + listWord n (wordList a) = a := by + funext i + change (wordList a).getD i.val false = a i + rw [wordList_getD, wordGet_fin] + +theorem wordList_listWord_length (xs : List Bool) : + wordList (listWord xs.length xs) = xs := by + apply List.ext_getElem + · simp [wordList] + · intro i _ hi + simp [wordList, listWord, List.getElem?_eq_getElem hi] + +theorem wordList_listWord {n : ℕ} (xs : List Bool) (h : xs.length = n) : + wordList (listWord n xs) = xs := by + subst n + exact wordList_listWord_length xs + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageBitConvolutionUpdates.lean b/lean/OAI/Computability/DepthThree/LanguageBitConvolutionUpdates.lean new file mode 100644 index 0000000000000000000000000000000000000000..105dda7cda6e2220fe22e279a96b3c708ab64bbb --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageBitConvolutionUpdates.lean @@ -0,0 +1,158 @@ +import OAI.Computability.DepthThree.LanguageBitLoopInvariants +import Mathlib.Data.List.GetD + +namespace OAI + +namespace DepthThreeLowerBound + +def xorListAt (c : List Bool) (k : ℕ) (v : Bool) : List Bool := + c.set k (Bool.xor (c.getD k false) v) + +@[simp] theorem xorListAt_length (c : List Bool) (k : ℕ) (v : Bool) : + (xorListAt c k v).length = c.length := by + simp [xorListAt] + +theorem xorListAt_getD (c : List Bool) (j : ℕ) (v : Bool) + (hj : j < c.length) (k : ℕ) : + (xorListAt c j v).getD k false = + Bool.xor (c.getD k false) (if j = k then v else false) := by + by_cases h : j = k + · subst k + simp [xorListAt, List.getElem?_set_self hj] + · simp [xorListAt, h, List.getElem?_set_ne h] + +theorem xorListAt_split («prefix» suffix : List Bool) (old v : Bool) : + xorListAt («prefix» ++ old :: suffix) «prefix».length v = + «prefix» ++ Bool.xor old v :: suffix := by + unfold xorListAt + rw [List.getD_append_right «prefix» (old :: suffix) false «prefix».length le_rfl] + simp + +def convolutionUpdateRow (a b : List Bool) (i : ℕ) : + List ℕ → List Bool → List Bool + | [], c => c + | j :: js, c => convolutionUpdateRow a b i js + (xorListAt c (i + j) (a.getD i false && b.getD j false)) + +@[simp] theorem convolutionUpdateRow_nil (a b : List Bool) (i : ℕ) (c : List Bool) : + convolutionUpdateRow a b i [] c = c := rfl + +theorem convolutionUpdateRow_step (a b : List Bool) (i j : ℕ) + (js : List ℕ) (c : List Bool) : + convolutionUpdateRow a b i (j :: js) c = + convolutionUpdateRow a b i js + (xorListAt c (i + j) (a.getD i false && b.getD j false)) := rfl + +@[simp] theorem convolutionUpdateRow_length (a b : List Bool) (i : ℕ) + (js : List ℕ) (c : List Bool) : + (convolutionUpdateRow a b i js c).length = c.length := by + induction js generalizing c with + | nil => rfl + | cons j js ih => + rw [convolutionUpdateRow_step, ih, xorListAt_length] + +theorem convolutionUpdateRow_getD (a b : List Bool) (i : ℕ) + (js : List ℕ) (c : List Bool) (k : ℕ) + (hbound : ∀ j ∈ js, i + j < c.length) : + (convolutionUpdateRow a b i js c).getD k false = + Bool.xor (c.getD k false) + (xorBits (js.map fun j => + if i + j = k then a.getD i false && b.getD j false else false)) := by + induction js generalizing c with + | nil => simp + | cons j js ih => + have hj : i + j < c.length := hbound j (by simp) + have hrest : ∀ j' ∈ js, i + j' < + (xorListAt c (i + j) (a.getD i false && b.getD j false)).length := by + intro j' hj' + rw [xorListAt_length] + exact hbound j' (List.mem_cons_of_mem j hj') + rw [convolutionUpdateRow_step, ih _ hrest, + xorListAt_getD c (i + j) (a.getD i false && b.getD j false) hj k] + simp only [List.map_cons, xorBits_cons, Bool.xor_assoc] + +def convolutionUpdateRows (a b : List Bool) : List ℕ → List Bool → List Bool + | [], c => c + | i :: is, c => convolutionUpdateRows a b is + (convolutionUpdateRow a b i (List.range b.length) c) + +@[simp] theorem convolutionUpdateRows_nil (a b : List Bool) (c : List Bool) : + convolutionUpdateRows a b [] c = c := rfl + +theorem convolutionUpdateRows_step (a b : List Bool) (i : ℕ) + (is : List ℕ) (c : List Bool) : + convolutionUpdateRows a b (i :: is) c = + convolutionUpdateRows a b is + (convolutionUpdateRow a b i (List.range b.length) c) := rfl + +@[simp] theorem convolutionUpdateRows_length (a b : List Bool) + (is : List ℕ) (c : List Bool) : + (convolutionUpdateRows a b is c).length = c.length := by + induction is generalizing c with + | nil => rfl + | cons i is ih => + rw [convolutionUpdateRows_step, ih, convolutionUpdateRow_length] + +theorem convolutionUpdateRows_getD (a b : List Bool) + (is : List ℕ) (c : List Bool) (k : ℕ) + (hbound : ∀ i ∈ is, ∀ j < b.length, i + j < c.length) : + (convolutionUpdateRows a b is c).getD k false = + Bool.xor (c.getD k false) + (xorBits (is.map fun i => xorBits (convolutionRow a b i k))) := by + induction is generalizing c with + | nil => simp + | cons i is ih => + have hcols : ∀ j ∈ List.range b.length, i + j < c.length := by + intro j hj + exact hbound i (by simp) j (List.mem_range.mp hj) + have hrest : ∀ i' ∈ is, ∀ j < b.length, i' + j < + (convolutionUpdateRow a b i (List.range b.length) c).length := by + intro i' hi' j hj + rw [convolutionUpdateRow_length] + exact hbound i' (List.mem_cons_of_mem i hi') j hj + rw [convolutionUpdateRows_step, ih _ hrest, + convolutionUpdateRow_getD a b i (List.range b.length) c k hcols] + simp only [List.map_cons, xorBits_cons, convolutionRow, Bool.xor_assoc] + +def convolveByUpdates (a b : List Bool) : List Bool := + convolutionUpdateRows a b (List.range a.length) + (List.replicate (a.length + b.length) false) + +@[simp] theorem convolveByUpdates_length (a b : List Bool) : + (convolveByUpdates a b).length = a.length + b.length := by + simp [convolveByUpdates] + +theorem convolutionUpdate_index_lt (a b : List Bool) {i j : ℕ} + (hi : i < a.length) (hj : j < b.length) : + i + j < a.length + b.length := + Nat.add_lt_add hi hj + +theorem convolveByUpdates_getD (a b : List Bool) (k : ℕ) : + (convolveByUpdates a b).getD k false = convolutionBit a b k := by + have hbound : ∀ i ∈ List.range a.length, ∀ j < b.length, + i + j < (List.replicate (a.length + b.length) false).length := by + intro i hi j hj + simpa only [List.length_replicate] using + convolutionUpdate_index_lt a b (List.mem_range.mp hi) hj + unfold convolveByUpdates + rw [convolutionUpdateRows_getD a b (List.range a.length) + (List.replicate (a.length + b.length) false) k hbound] + simp [convolutionBit, convolutionRows] + +theorem convolveByUpdates_eq (a b : List Bool) : + convolveByUpdates a b = convolveBitLists a b := by + apply List.ext_getElem + · simp + · intro k hk hl + have hk' : k < a.length + b.length := by + simpa only [convolveBitLists_length] using hl + have hleft := convolveByUpdates_getD a b k + have hright : (convolveBitLists a b).getD k false = convolutionBit a b k := by + simp [convolveBitLists, List.getElem?_range hk'] + rw [List.getD_eq_getElem _ _ hk] at hleft + rw [List.getD_eq_getElem _ _ hl] at hright + exact hleft.trans hright.symm + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageBitEvaluator.lean b/lean/OAI/Computability/DepthThree/LanguageBitEvaluator.lean new file mode 100644 index 0000000000000000000000000000000000000000..25bea5d81ddecd71bc777703ba265c1012b8963b --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageBitEvaluator.lean @@ -0,0 +1,138 @@ +import OAI.Computability.DepthThree.LanguageBitArithmetic +import OAI.Computability.DepthThree.Language +import Mathlib.Tactic.Ring + +namespace OAI + +namespace DepthThreeLowerBound + +open scoped BigOperators +open BinaryAlgebra +open Polynomial + +theorem mul_remainder_modByMonic (a b p : Polynomial (ZMod 2)) (hp : p.Monic) : + (a * (b %ₘ p)) %ₘ p = (a * b) %ₘ p := by + symm + calc + (a * b) %ₘ p = (a * (b %ₘ p + p * (b /ₘ p))) %ₘ p := by + rw [Polynomial.modByMonic_add_div b p] + _ = (a * (b %ₘ p)) %ₘ p := by + rw [mul_add, Polynomial.add_modByMonic] + have hz : (a * (p * (b /ₘ p))) %ₘ p = 0 := by + rw [← mul_assoc, mul_comm a p, mul_assoc, + Polynomial.self_mul_modByMonic hp] + rw [hz, add_zero] + +theorem wordPoly_mod_self {r : ℕ} (p a : BitWord r) : + wordPoly a %ₘ inputPolynomialBits p = wordPoly a := by + apply (Polynomial.modByMonic_eq_self_iff (inputPolynomialBits_monic p)).2 + rw [inputPolynomialBits_degree] + exact degree_wordPoly_lt a + +def wordHorner {r : ℕ} (p h : BitWord r) : + (t : ℕ) → (Fin t → BitWord r) → BitWord r + | 0, _ => fun _ => false + | t + 1, b => wordFreeze (wordXor (b 0) + (wordMulMod p h (wordHorner p h t (fun i => b i.succ)))) + +theorem wordPoly_horner {r : ℕ} (p h : BitWord r) (t : ℕ) + (b : Fin t → BitWord r) : + wordPoly (wordHorner p h t b) = + (∑ j : Fin t, wordPoly (b j) * wordPoly h ^ j.val) %ₘ + inputPolynomialBits p := by + induction t with + | zero => simp [wordHorner] + | succ t ih => + have hsum : + (∑ j : Fin (t + 1), wordPoly (b j) * wordPoly h ^ j.val) = + wordPoly (b 0) + wordPoly h * + ∑ j : Fin t, wordPoly (b j.succ) * wordPoly h ^ j.val := by + rw [Fin.sum_univ_succ] + simp only [Fin.val_zero, pow_zero, mul_one, Fin.val_succ, pow_succ] + rw [Finset.mul_sum] + apply congrArg (fun z : Polynomial (ZMod 2) => wordPoly (b 0) + z) + apply Finset.sum_congr rfl + intro j _ + ring + rw [wordHorner, wordFreeze_eq, wordPoly_xor, wordPoly_mulMod, + ih, mul_remainder_modByMonic _ _ _ (inputPolynomialBits_monic p), + hsum, Polynomial.add_modByMonic, wordPoly_mod_self] + +def wordHash {d r : ℕ} (u : BitWord (d + r - 1)) (x : BitWord d) : BitWord r := + wordFreeze fun i => + xorBits (List.ofFn fun s : Fin d => u (BinaryHash.sumIndex i s) && x s) + +theorem wordHash_eq {d r : ℕ} (u : BitWord (d + r - 1)) (x : BitWord d) : + wordHash u x = BinaryHash.hashBool u x := by + funext i + apply bitValue_injective + simp only [wordHash, wordFreeze_eq, bitValue_xorBits_ofFn, bitValue_and, + BinaryHash.bitValue_hashBool, BinaryHash.hashF2] + +def multiplyBitLists (r : ℕ) (p a b : List Bool) : List Bool := + wordList (wordMulMod (listWord r p) (listWord r a) (listWord r b)) + +@[simp] theorem multiplyBitLists_length (r : ℕ) (p a b : List Bool) : + (multiplyBitLists r p a b).length = r := by + simp [multiplyBitLists] + +theorem multiplyBitLists_correct (r : ℕ) (p a b : List Bool) : + wordPoly (listWord r (multiplyBitLists r p a b)) = + (wordPoly (listWord r a) * wordPoly (listWord r b)) %ₘ + inputPolynomialBits (listWord r p) := by + simp only [multiplyBitLists, listWord_wordList, wordPoly_mulMod] + +def hornerBitLists (r : ℕ) (p h : List Bool) (b : List (List Bool)) : List Bool := + wordList (wordHorner (listWord r p) (listWord r h) b.length + (fun j => listWord r (b.getD j.val []))) + +@[simp] theorem hornerBitLists_length (r : ℕ) (p h : List Bool) + (b : List (List Bool)) : (hornerBitLists r p h b).length = r := by + simp [hornerBitLists] + +theorem hornerBitLists_correct (r : ℕ) (p h : List Bool) (b : List (List Bool)) : + wordPoly (listWord r (hornerBitLists r p h b)) = + (∑ j : Fin b.length, wordPoly (listWord r (b.getD j.val [])) * + wordPoly (listWord r h) ^ j.val) %ₘ inputPolynomialBits (listWord r p) := by + simp only [hornerBitLists, listWord_wordList, wordPoly_horner] + +namespace ParsedInput + +def evaluationBits (q : ParsedInput) : BitWord q.ringDegree := + wordHorner q.polynomial (wordHash q.hashSeed q.data) + q.coefficientCount q.coefficients + +theorem wordPoly_evaluationBits (q : ParsedInput) : + wordPoly q.evaluationBits = q.evaluationRemainder := by + rw [evaluationBits, wordPoly_horner, wordHash_eq] + rfl + +def evaluateBits (q : ParsedInput) : Bool := + !(wordGet q.evaluationBits 0) + +theorem evaluateBits_eq (q : ParsedInput) : q.evaluateBits = q.evaluate := by + have hc : bitValue (wordGet q.evaluationBits 0) = + q.evaluationRemainder.coeff 0 := by + rw [← coeff_wordPoly, wordPoly_evaluationBits] + apply Bool.eq_iff_iff.mpr + rw [evaluate_eq_true_iff] + unfold evaluateBits + rw [← hc, bitValue_eq_zero_iff] + cases wordGet q.evaluationBits 0 <;> decide + +end ParsedInput + +def languageBits (w : List Bool) : Bool := + match parseInput w with + | none => false + | some q => q.evaluateBits + +theorem languageBits_eq_language (w : List Bool) : languageBits w = language w := by + unfold languageBits language + cases parseInput w with + | none => rfl + | some q => exact q.evaluateBits_eq + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageBitHashUpdates.lean b/lean/OAI/Computability/DepthThree/LanguageBitHashUpdates.lean new file mode 100644 index 0000000000000000000000000000000000000000..f247cc5084df620e0370f5a799acdad87b4e18dc --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageBitHashUpdates.lean @@ -0,0 +1,252 @@ +import OAI.Computability.DepthThree.LanguageBitConvolutionUpdates +import Mathlib.Data.List.Range + +namespace OAI + +namespace DepthThreeLowerBound + +def hashUpdateRow (u x : List Bool) (i : ℕ) : List ℕ → List Bool → List Bool + | [], c => c + | j :: js, c => hashUpdateRow u x i js + (xorListAt c i (u.getD (i + j) false && x.getD j false)) + +@[simp] theorem hashUpdateRow_nil (u x : List Bool) (i : ℕ) (c : List Bool) : + hashUpdateRow u x i [] c = c := rfl + +theorem hashUpdateRow_step (u x : List Bool) (i j : ℕ) + (js : List ℕ) (c : List Bool) : + hashUpdateRow u x i (j :: js) c = hashUpdateRow u x i js + (xorListAt c i (u.getD (i + j) false && x.getD j false)) := rfl + +@[simp] theorem hashUpdateRow_length (u x : List Bool) (i : ℕ) + (js : List ℕ) (c : List Bool) : + (hashUpdateRow u x i js c).length = c.length := by + induction js generalizing c with + | nil => rfl + | cons j js ih => rw [hashUpdateRow_step, ih, xorListAt_length] + +theorem hashUpdateRow_append (u x : List Bool) (i : ℕ) + (js ks : List ℕ) (c : List Bool) : + hashUpdateRow u x i (js ++ ks) c = + hashUpdateRow u x i ks (hashUpdateRow u x i js c) := by + induction js generalizing c with + | nil => rfl + | cons j js ih => + simp only [List.cons_append, hashUpdateRow_step, ih] + +theorem hashUpdateRow_getD (u x : List Bool) (i : ℕ) + (js : List ℕ) (c : List Bool) (k : ℕ) (hi : i < c.length) : + (hashUpdateRow u x i js c).getD k false = + Bool.xor (c.getD k false) + (if i = k then xorBits (js.map fun j => + u.getD (i + j) false && x.getD j false) else false) := by + induction js generalizing c with + | nil => simp + | cons j js ih => + have hi' : i < + (xorListAt c i (u.getD (i + j) false && x.getD j false)).length := by + simpa only [xorListAt_length] using hi + rw [hashUpdateRow_step, ih _ hi', + xorListAt_getD c i (u.getD (i + j) false && x.getD j false) hi k] + by_cases hik : i = k <;> + simp [hik, List.map_cons, xorBits_cons] + +theorem hashUpdateRow_getD_self (u x : List Bool) (i : ℕ) + (js : List ℕ) (c : List Bool) (hi : i < c.length) : + (hashUpdateRow u x i js c).getD i false = + Bool.xor (c.getD i false) + (xorBits (js.map fun j => u.getD (i + j) false && x.getD j false)) := by + simpa only [ite_eq_left rfl, ite_true] using hashUpdateRow_getD u x i js c i hi + +theorem hashUpdateRow_getD_ne (u x : List Bool) (i : ℕ) + (js : List ℕ) (c : List Bool) (k : ℕ) (hi : i < c.length) (hik : i ≠ k) : + (hashUpdateRow u x i js c).getD k false = c.getD k false := by + simpa only [ite_eq_right hik, Bool.xor_false] using hashUpdateRow_getD u x i js c k hi + +def hashRowBit (u x : List Bool) (i : ℕ) : Bool := + xorBits ((List.range x.length).map fun j => + u.getD (i + j) false && x.getD j false) + +def hashUpdateRows (u x : List Bool) : List ℕ → List Bool → List Bool + | [], c => c + | i :: is, c => hashUpdateRows u x is + (hashUpdateRow u x i (List.range x.length) c) + +@[simp] theorem hashUpdateRows_nil (u x : List Bool) (c : List Bool) : + hashUpdateRows u x [] c = c := rfl + +theorem hashUpdateRows_step (u x : List Bool) (i : ℕ) + (is : List ℕ) (c : List Bool) : + hashUpdateRows u x (i :: is) c = hashUpdateRows u x is + (hashUpdateRow u x i (List.range x.length) c) := rfl + +@[simp] theorem hashUpdateRows_length (u x : List Bool) + (is : List ℕ) (c : List Bool) : + (hashUpdateRows u x is c).length = c.length := by + induction is generalizing c with + | nil => rfl + | cons i is ih => rw [hashUpdateRows_step, ih, hashUpdateRow_length] + +theorem hashUpdateRows_append (u x : List Bool) + (is ks : List ℕ) (c : List Bool) : + hashUpdateRows u x (is ++ ks) c = + hashUpdateRows u x ks (hashUpdateRows u x is c) := by + induction is generalizing c with + | nil => rfl + | cons i is ih => + simp only [List.cons_append, hashUpdateRows_step, ih] + +theorem hashUpdateRows_getD (u x : List Bool) + (is : List ℕ) (c : List Bool) (k : ℕ) + (hbound : ∀ i ∈ is, i < c.length) : + (hashUpdateRows u x is c).getD k false = + Bool.xor (c.getD k false) + (xorBits (is.map fun i => if i = k then hashRowBit u x i else false)) := by + induction is generalizing c with + | nil => simp + | cons i is ih => + have hi : i < c.length := hbound i (by simp) + have hrest : ∀ i' ∈ is, + i' < (hashUpdateRow u x i (List.range x.length) c).length := by + intro i' hi' + rw [hashUpdateRow_length] + exact hbound i' (List.mem_cons_of_mem i hi') + rw [hashUpdateRows_step, ih _ hrest, + hashUpdateRow_getD u x i (List.range x.length) c k hi] + simp only [hashRowBit, List.map_cons, xorBits_cons, Bool.xor_assoc] + +theorem hashUpdateRow_range'_append (u x : List Bool) (i s m n : ℕ) (c : List Bool) : + hashUpdateRow u x i (List.range' s (m + n)) c = + hashUpdateRow u x i (List.range' (s + m) n) + (hashUpdateRow u x i (List.range' s m) c) := by + rw [← List.range'_append_1, hashUpdateRow_append] + +theorem hashUpdateRow_range'_prefix (u x : List Bool) (i s m n : ℕ) + (c : List Bool) (hm : m ≤ n) : + hashUpdateRow u x i (List.range' (s + m) (n - m)) + (hashUpdateRow u x i (List.range' s m) c) = + hashUpdateRow u x i (List.range' s n) c := by + rw [← hashUpdateRow_range'_append, Nat.add_sub_of_le hm] + +theorem hashUpdateRow_range'_step (u x : List Bool) (i s n : ℕ) (c : List Bool) : + hashUpdateRow u x i (List.range' s (n + 1)) c = + hashUpdateRow u x i (List.range' (s + 1) n) + (xorListAt c i (u.getD (i + s) false && x.getD s false)) := by + rw [List.range'_succ, hashUpdateRow_step] + +theorem hashUpdateRow_range'_snoc (u x : List Bool) (i s n : ℕ) (c : List Bool) : + hashUpdateRow u x i (List.range' s (n + 1)) c = + xorListAt (hashUpdateRow u x i (List.range' s n) c) i + (u.getD (i + (s + n)) false && x.getD (s + n) false) := by + rw [List.range'_concat, hashUpdateRow_append] + simp only [Nat.one_mul, hashUpdateRow_step, hashUpdateRow_nil] + +theorem hashUpdateRows_range'_append (u x : List Bool) (s m n : ℕ) (c : List Bool) : + hashUpdateRows u x (List.range' s (m + n)) c = + hashUpdateRows u x (List.range' (s + m) n) + (hashUpdateRows u x (List.range' s m) c) := by + rw [← List.range'_append_1, hashUpdateRows_append] + +theorem hashUpdateRows_range'_prefix (u x : List Bool) (s m n : ℕ) + (c : List Bool) (hm : m ≤ n) : + hashUpdateRows u x (List.range' (s + m) (n - m)) + (hashUpdateRows u x (List.range' s m) c) = + hashUpdateRows u x (List.range' s n) c := by + rw [← hashUpdateRows_range'_append, Nat.add_sub_of_le hm] + +theorem hashUpdateRows_range'_step (u x : List Bool) (s n : ℕ) (c : List Bool) : + hashUpdateRows u x (List.range' s (n + 1)) c = + hashUpdateRows u x (List.range' (s + 1) n) + (hashUpdateRow u x s (List.range x.length) c) := by + rw [List.range'_succ, hashUpdateRows_step] + +theorem hashUpdateRows_range'_snoc (u x : List Bool) (s n : ℕ) (c : List Bool) : + hashUpdateRows u x (List.range' s (n + 1)) c = + hashUpdateRow u x (s + n) (List.range x.length) + (hashUpdateRows u x (List.range' s n) c) := by + rw [List.range'_concat, hashUpdateRows_append] + simp only [Nat.one_mul, hashUpdateRows_step, hashUpdateRows_nil] + +theorem hashUpdateRow_range_succ (u x : List Bool) (i j : ℕ) (c : List Bool) : + hashUpdateRow u x i (List.range (j + 1)) c = + xorListAt (hashUpdateRow u x i (List.range j) c) i + (u.getD (i + j) false && x.getD j false) := by + simpa only [List.range_eq_range', Nat.zero_add] using + hashUpdateRow_range'_snoc u x i 0 j c + +theorem hashUpdateRows_range_succ (u x : List Bool) (i : ℕ) (c : List Bool) : + hashUpdateRows u x (List.range (i + 1)) c = + hashUpdateRow u x i (List.range x.length) + (hashUpdateRows u x (List.range i) c) := by + simpa only [List.range_eq_range', Nat.zero_add] using + hashUpdateRows_range'_snoc u x 0 i c + +theorem hashReadIndex_lt {d r i j : ℕ} (hi : i < r) (hj : j < d) : + i + j < d + r - 1 := by omega + +private theorem xorBits_map_single_index (is : List ℕ) (hn : is.Nodup) + (k : ℕ) (f : ℕ → Bool) : + xorBits (is.map fun i => if i = k then f i else false) = + if k ∈ is then f k else false := by + induction is with + | nil => simp + | cons i is ih => + have hnodup := List.nodup_cons.mp hn + rw [List.map_cons, xorBits_cons, ih hnodup.2] + by_cases hik : i = k + · subst i + simp [hnodup.1] + · simp [hik, Ne.symm hik] + +theorem hashUpdateRows_getD_nodup (u x : List Bool) + (is : List ℕ) (c : List Bool) (k : ℕ) + (hbound : ∀ i ∈ is, i < c.length) (hn : is.Nodup) : + (hashUpdateRows u x is c).getD k false = + Bool.xor (c.getD k false) (if k ∈ is then hashRowBit u x k else false) := by + rw [hashUpdateRows_getD u x is c k hbound, + xorBits_map_single_index is hn k (hashRowBit u x)] + +def hashByUpdates (r : ℕ) (u x : List Bool) : List Bool := + hashUpdateRows u x (List.range r) (List.replicate r false) + +@[simp] theorem hashByUpdates_length (r : ℕ) (u x : List Bool) : + (hashByUpdates r u x).length = r := by simp [hashByUpdates] + +theorem hashByUpdates_getD (r : ℕ) (u x : List Bool) (k : ℕ) : + (hashByUpdates r u x).getD k false = + if k < r then hashRowBit u x k else false := by + have hbound : ∀ i ∈ List.range r, i < (List.replicate r false).length := by + intro i hi + simpa only [List.length_replicate] using List.mem_range.mp hi + unfold hashByUpdates + rw [hashUpdateRows_getD_nodup u x (List.range r) (List.replicate r false) + k hbound List.nodup_range] + simp + +theorem hashRowBit_ofFn {d r : ℕ} (u : BitWord (d + r - 1)) (x : BitWord d) + (i : Fin r) : + hashRowBit (List.ofFn u) (List.ofFn x) i.val = wordHash u x i := by + unfold hashRowBit + rw [List.length_ofFn, ← ofFn_nat_eq_map_range] + simp only [wordHash, wordFreeze_eq] + apply congrArg xorBits + apply congrArg List.ofFn + funext j + have hu : i.val + j.val < d + r - 1 := (BinaryHash.sumIndex i j).is_lt + change ((wordList u).getD (i.val + j.val) false && (wordList x).getD j.val false) = + (u (BinaryHash.sumIndex i j) && x j) + simp only [wordList_getD, wordGet_of_lt u hu, wordGet_fin, BinaryHash.sumIndex] + +theorem hashByUpdates_ofFn_eq {d r : ℕ} (u : BitWord (d + r - 1)) (x : BitWord d) : + hashByUpdates r (List.ofFn u) (List.ofFn x) = List.ofFn (wordHash u x) := by + apply List.ext_getElem + · simp + · intro k hk hl + have hkr : k < r := by simpa only [List.length_ofFn] using hl + have hleft := hashByUpdates_getD r (List.ofFn u) (List.ofFn x) k + rw [ite_eq_left hkr, List.getD_eq_getElem _ _ hk] at hleft + simpa using hleft.trans (hashRowBit_ofFn u x ⟨k, hkr⟩) + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageBitHornerLoop.lean b/lean/OAI/Computability/DepthThree/LanguageBitHornerLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ef905ba18803dc39e476ac08eb5e94a4e9f7e32 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageBitHornerLoop.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DepthThree.LanguageBitLoopInvariants + +namespace OAI + +universe uDepth1 + +namespace DepthThreeLowerBound + +def hornerStep (r : ℕ) (p h b a : List Bool) : List Bool := + List.zipWith Bool.xor b (multiplyBitLists r p h a) + +theorem hornerStep_length (r : ℕ) (p h b a : List Bool) (hb : b.length = r) : + (hornerStep r p h b a).length = r := by + simp only [hornerStep, List.length_zipWith, multiplyBitLists_length, hb, min_self] + +theorem hornerStep_eq_word (r : ℕ) (p h b a : List Bool) (hb : b.length = r) : + hornerStep r p h b a = + wordList (wordXor (listWord r b) + (wordMulMod (listWord r p) (listWord r h) (listWord r a))) := by + have hx (u v : BitWord r) : + List.zipWith Bool.xor (wordList u) (wordList v) = wordList (wordXor u v) := by + apply List.ext_getElem + · simp only [wordList_length, List.length_zipWith, min_self] + · intro i hi hj + simp only [wordList, wordXor, List.getElem_zipWith, List.getElem_ofFn] + have heq := hx (listWord r b) + (wordMulMod (listWord r p) (listWord r h) (listWord r a)) + simpa only [wordList_listWord b hb, hornerStep, multiplyBitLists] using heq + +def hornerFrom (r : ℕ) (p h : List Bool) (bs : List (List Bool)) + (a : List Bool) : List Bool := + bs.foldr (hornerStep r p h) a + +@[simp] theorem hornerFrom_nil (r : ℕ) (p h a : List Bool) : + hornerFrom r p h [] a = a := rfl + +theorem hornerFrom_cons (r : ℕ) (p h b : List Bool) (bs : List (List Bool)) + (a : List Bool) : + hornerFrom r p h (b :: bs) a = hornerStep r p h b (hornerFrom r p h bs a) := rfl + +theorem hornerFrom_append (r : ℕ) (p h : List Bool) + (bs cs : List (List Bool)) (a : List Bool) : + hornerFrom r p h (bs ++ cs) a = + hornerFrom r p h bs (hornerFrom r p h cs a) := by + simp only [hornerFrom, List.foldr_append] + +theorem hornerFrom_append_singleton (r : ℕ) (p h : List Bool) + (bs : List (List Bool)) (b a : List Bool) : + hornerFrom r p h (bs ++ [b]) a = + hornerFrom r p h bs (hornerStep r p h b a) := by + rw [hornerFrom_append, hornerFrom_cons, hornerFrom_nil] + +theorem hornerFrom_length (r : ℕ) (p h : List Bool) + (bs : List (List Bool)) (a : List Bool) (ha : a.length = r) + (hbs : ∀ b ∈ bs, b.length = r) : + (hornerFrom r p h bs a).length = r := by + cases bs with + | nil => exact ha + | cons b bs => + rw [hornerFrom_cons] + exact hornerStep_length r p h b _ (hbs b (by simp)) + +theorem hornerFrom_zero_eq_hornerBitLists (r : ℕ) (p h : List Bool) + (bs : List (List Bool)) (hbs : ∀ b ∈ bs, b.length = r) : + hornerFrom r p h bs (List.replicate r false) = hornerBitLists r p h bs := by + revert hbs + induction bs with + | nil => + intro hbs + simp only [hornerFrom_nil, hornerBitLists_nil, wordList, List.ofFn_const] + | cons b bs ih => + intro hbs + have hb : b.length = r := hbs b (by simp) + have htail : ∀ c ∈ bs, c.length = r := + fun c hc => hbs c (List.mem_cons_of_mem b hc) + rw [hornerFrom_cons, ih htail, hornerStep_eq_word r p h b _ hb, + hornerBitLists_cons] + +theorem block_flatten_length {α : Type uDepth1} (r : ℕ) (bs : List (List α)) + (hbs : ∀ b ∈ bs, b.length = r) : bs.flatten.length = bs.length * r := by + revert hbs + induction bs with + | nil => intro hbs; simp + | cons b bs ih => + intro hbs + have hb : b.length = r := hbs b (by simp) + have htail : ∀ c ∈ bs, c.length = r := + fun c hc => hbs c (List.mem_cons_of_mem b hc) + simp only [List.flatten_cons, List.length_append, List.length_cons, hb, ih htail] + simp only [Nat.add_mul, Nat.one_mul, Nat.add_comm] + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageBitLoopInvariants.lean b/lean/OAI/Computability/DepthThree/LanguageBitLoopInvariants.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7e4492623dc8ed311f8fa0029fefec424c81d5e --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageBitLoopInvariants.lean @@ -0,0 +1,96 @@ +import OAI.Computability.DepthThree.LanguageBitEvaluator + +namespace OAI + +universe uDepth1 + +namespace DepthThreeLowerBound + +def xorScan : Bool → List Bool → Bool + | acc, [] => acc + | acc, b :: bs => xorScan (Bool.xor acc b) bs + +@[simp] theorem xorScan_nil (acc : Bool) : xorScan acc [] = acc := rfl + +theorem xorScan_step (acc b : Bool) (bs : List Bool) : + xorScan acc (b :: bs) = xorScan (Bool.xor acc b) bs := rfl + +theorem xorScan_eq (acc : Bool) (bs : List Bool) : + xorScan acc bs = Bool.xor acc (xorBits bs) := by + induction bs generalizing acc with + | nil => simp [xorScan] + | cons b bs ih => + simp only [xorScan, xorBits_cons, ih, Bool.xor_assoc] + +theorem xorBits_append (a b : List Bool) : + xorBits (a ++ b) = Bool.xor (xorBits a) (xorBits b) := by + induction a with + | nil => simp + | cons x a ih => + simp only [List.cons_append, xorBits_cons, ih, Bool.xor_assoc] + +theorem xorScan_prefix_invariant (done todo : List Bool) : + xorScan (xorBits done) todo = xorBits (done ++ todo) := by + rw [xorScan_eq, xorBits_append] + +theorem ofFn_nat_eq_map_range {α : Type uDepth1} (n : ℕ) (f : ℕ → α) : + List.ofFn (fun i : Fin n => f i.val) = (List.range n).map f := by + apply List.ext_getElem + · simp + · intro i hi hj + simp + +def convolutionRow (a b : List Bool) (i k : ℕ) : List Bool := + (List.range b.length).map fun j => + if i + j = k then a.getD i false && b.getD j false else false + +def convolutionRows (a b : List Bool) (k : ℕ) : List Bool := + (List.range a.length).map fun i => xorBits (convolutionRow a b i k) + +def convolutionBit (a b : List Bool) (k : ℕ) : Bool := + xorBits (convolutionRows a b k) + +theorem convolutionRow_scan (a b : List Bool) (i k : ℕ) : + xorScan false (convolutionRow a b i k) = xorBits (convolutionRow a b i k) := by + simp [xorScan_eq] + +theorem convolutionRows_scan (a b : List Bool) (k : ℕ) : + xorScan false (convolutionRows a b k) = convolutionBit a b k := by + simp [xorScan_eq, convolutionBit] + +theorem convolutionBit_eq_wordConvolve (a b : List Bool) (k : ℕ) + (hk : k < a.length + b.length) : + convolutionBit a b k = + wordConvolve (listWord a.length a) (listWord b.length b) ⟨k, hk⟩ := by + unfold convolutionBit convolutionRows convolutionRow wordConvolve listWord + simp only [← ofFn_nat_eq_map_range] + +def convolveBitLists (a b : List Bool) : List Bool := + (List.range (a.length + b.length)).map (convolutionBit a b) + +@[simp] theorem convolveBitLists_length (a b : List Bool) : + (convolveBitLists a b).length = a.length + b.length := by + simp [convolveBitLists] + +theorem convolveBitLists_eq (a b : List Bool) : + convolveBitLists a b = + wordList (wordConvolve (listWord a.length a) (listWord b.length b)) := by + unfold convolveBitLists wordList + rw [← ofFn_nat_eq_map_range] + apply congrArg List.ofFn + funext i + exact convolutionBit_eq_wordConvolve a b i.val i.is_lt + +theorem hornerBitLists_nil (r : ℕ) (p h : List Bool) : + hornerBitLists r p h [] = wordList (fun _ : Fin r => false) := rfl + +theorem hornerBitLists_cons (r : ℕ) (p h b : List Bool) (bs : List (List Bool)) : + hornerBitLists r p h (b :: bs) = + wordList (wordXor (listWord r b) + (wordMulMod (listWord r p) (listWord r h) + (listWord r (hornerBitLists r p h bs)))) := by + simp [hornerBitLists, wordHorner] + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageBitReductionLoop.lean b/lean/OAI/Computability/DepthThree/LanguageBitReductionLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..d5b15babb7c6e4f6d84b5e2f1b7a0aa5a6386cfc --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageBitReductionLoop.lean @@ -0,0 +1,241 @@ +import OAI.Computability.DepthThree.LanguageBitConvolutionUpdates + +namespace OAI + +namespace DepthThreeLowerBound + +def modulusUpdateLoop (p : List Bool) (v : Bool) (shift : ℕ) : ℕ → List Bool → List Bool + | 0, c => c + | j + 1, c => xorListAt (modulusUpdateLoop p v shift j c) + (shift + j) (v && p.getD j false) + +@[simp] theorem modulusUpdateLoop_zero (p : List Bool) (v : Bool) + (shift : ℕ) (c : List Bool) : modulusUpdateLoop p v shift 0 c = c := rfl + +theorem modulusUpdateLoop_step (p : List Bool) (v : Bool) (shift j : ℕ) (c : List Bool) : + modulusUpdateLoop p v shift (j + 1) c = + xorListAt (modulusUpdateLoop p v shift j c) (shift + j) (v && p.getD j false) := rfl + +@[simp] theorem modulusUpdateLoop_length (p : List Bool) (v : Bool) + (shift j : ℕ) (c : List Bool) : + (modulusUpdateLoop p v shift j c).length = c.length := by + induction j with + | zero => rfl + | succ j ih => rw [modulusUpdateLoop_step, xorListAt_length, ih] + +theorem modulusUpdateLoop_getD (p : List Bool) (v : Bool) (shift j : ℕ) + (c : List Bool) (hbound : shift + j ≤ c.length) (k : ℕ) : + (modulusUpdateLoop p v shift j c).getD k false = + Bool.xor (c.getD k false) + (if shift ≤ k ∧ k < shift + j then v && p.getD (k - shift) false else false) := by + revert hbound + induction j with + | zero => + intro hbound + have hk : ¬(shift ≤ k ∧ k < shift + 0) := by omega + simp only [modulusUpdateLoop_zero, ite_eq_right hk, Bool.xor_false] + | succ j ih => + intro hbound + have hj : shift + j < (modulusUpdateLoop p v shift j c).length := by + rw [modulusUpdateLoop_length] + omega + rw [modulusUpdateLoop_step, xorListAt_getD _ _ _ hj k, ih (by omega)] + by_cases he : shift + j = k + · have hprev : ¬(shift ≤ k ∧ k < shift + j) := by omega + have hnext : shift ≤ k ∧ k < shift + (j + 1) := by omega + have hsub : k - shift = j := by omega + simp [he, hnext, hsub] + · have hrange : (shift ≤ k ∧ k < shift + (j + 1)) ↔ + (shift ≤ k ∧ k < shift + j) := by omega + simp only [ite_eq_right he, Bool.xor_false, hrange] + +theorem modulusUpdateLoop_above (p : List Bool) (v : Bool) (shift j : ℕ) + (c : List Bool) (hbound : shift + j ≤ c.length) (k : ℕ) (hk : shift + j ≤ k) : + (modulusUpdateLoop p v shift j c).getD k false = c.getD k false := by + rw [modulusUpdateLoop_getD p v shift j c hbound k] + have hnot : ¬(shift ≤ k ∧ k < shift + j) := by omega + simp only [ite_eq_right hnot, Bool.xor_false] + +theorem modulusUpdateLoop_high (p : List Bool) (v : Bool) (shift : ℕ) + (c : List Bool) (hbound : shift + p.length ≤ c.length) : + (modulusUpdateLoop p v shift p.length c).getD (shift + p.length) false = + c.getD (shift + p.length) false := + modulusUpdateLoop_above p v shift p.length c hbound _ le_rfl + +def cancelByUpdates (p c : List Bool) (shift : ℕ) : List Bool := + (modulusUpdateLoop p (c.getD (shift + p.length) false) shift p.length c).set + (shift + p.length) false + +@[simp] theorem cancelByUpdates_length (p c : List Bool) (shift : ℕ) : + (cancelByUpdates p c shift).length = c.length := by + simp [cancelByUpdates] + +theorem cancelByUpdates_getD (p c : List Bool) (shift : ℕ) + (hbound : shift + p.length < c.length) (k : ℕ) : + (cancelByUpdates p c shift).getD k false = + if shift + p.length = k then false else + Bool.xor (c.getD k false) + (if shift ≤ k ∧ k < shift + p.length then + c.getD (shift + p.length) false && p.getD (k - shift) false else false) := by + have ht : shift + p.length < + (modulusUpdateLoop p (c.getD (shift + p.length) false) shift p.length c).length := by + simpa only [modulusUpdateLoop_length] using hbound + by_cases he : shift + p.length = k + · subst k + rw [ite_eq_left rfl] + unfold cancelByUpdates + exact List.getD_eq_getElem?_getD.trans + (congrArg (fun o : Option Bool => o.getD false) + (List.getElem?_set_self (a := false) ht)) + · have hset : (cancelByUpdates p c shift).getD k false = + (modulusUpdateLoop p (c.getD (shift + p.length) false) shift p.length c).getD k false := by + simp only [cancelByUpdates, List.getD_eq_getElem?_getD, List.getElem?_set_ne he] + rw [hset, modulusUpdateLoop_getD _ _ _ _ _ (Nat.le_of_lt hbound) k, ite_eq_right he] + +def reduceByUpdates (p : List Bool) : ℕ → List Bool → List Bool + | 0, c => c + | s + 1, c => reduceByUpdates p s (cancelByUpdates p c s) + +@[simp] theorem reduceByUpdates_zero (p c : List Bool) : reduceByUpdates p 0 c = c := rfl + +theorem reduceByUpdates_step (p c : List Bool) (s : ℕ) : + reduceByUpdates p (s + 1) c = reduceByUpdates p s (cancelByUpdates p c s) := rfl + +@[simp] theorem reduceByUpdates_length (p c : List Bool) (s : ℕ) : + (reduceByUpdates p s c).length = c.length := by + induction s generalizing c with + | zero => rfl + | succ s ih => rw [reduceByUpdates_step, ih, cancelByUpdates_length] + +theorem cancelStep_read {r m : ℕ} (p : BitWord r) (a : BitWord m) + (shift : ℕ) (hbound : shift + r < m) (i : Fin m) : + cancelStep p (shift + r) a i = + if shift + r = i.val then false else + Bool.xor (a i) + (if shift ≤ i.val ∧ i.val < shift + r then + a ⟨shift + r, hbound⟩ && wordGet p (i.val - shift) else false) := by + by_cases he : shift + r = i.val + · rw [ite_eq_left he, he] + exact cancelStep_at p a i (by omega) + · have hk : r ≤ shift + r ∧ shift + r < m := ⟨by omega, hbound⟩ + have hsub : shift + r - r = shift := by omega + by_cases ht : a ⟨shift + r, hbound⟩ = true + · by_cases hw : shift ≤ i.val ∧ i.val < shift + r + · have hj : i.val - shift < r := by omega + simp [cancelStep, hk, ht, wordXor, shiftModulus, hsub, + he, Ne.symm he, hw, wordGet, hj] + · simp [cancelStep, hk, ht, wordXor, shiftModulus, hsub, + he, Ne.symm he, hw] + · have hf : a ⟨shift + r, hbound⟩ = false := Bool.eq_false_of_not_eq_true ht + simp [cancelStep, hk, ht, he] + +theorem cancelByUpdates_eq_cancelStep {r m : ℕ} (p : BitWord r) (a : BitWord m) + (shift : ℕ) (hbound : shift + r < m) : + cancelByUpdates (wordList p) (wordList a) shift = + wordList (cancelStep p (shift + r) a) := by + have hw : listWord m (cancelByUpdates (wordList p) (wordList a) shift) = + cancelStep p (shift + r) a := by + funext i + change (cancelByUpdates (wordList p) (wordList a) shift).getD i.val false = _ + rw [cancelByUpdates_getD _ _ _ (by simpa only [wordList_length] using hbound)] + rw [cancelStep_read p a shift hbound i] + simp only [wordList_length, wordList_getD, wordGet_fin, wordGet_of_lt a hbound] + calc + cancelByUpdates (wordList p) (wordList a) shift = + wordList (listWord m (cancelByUpdates (wordList p) (wordList a) shift)) := + (wordList_listWord _ (by simp)).symm + _ = wordList (cancelStep p (shift + r) a) := congrArg wordList hw + +theorem reduceLoop_below {r m : ℕ} (p : BitWord r) (k : ℕ) (a : BitWord m) + (hk : k ≤ r) : reduceLoop p k a = a := by + revert hk + induction k generalizing a with + | zero => intro hk; rfl + | succ k ih => + intro hk + have hskip : ¬(r ≤ k ∧ k < m) := by omega + simpa only [reduceLoop, cancelStep, dite_eq_right hskip] using ih a (by omega) + +theorem reduceByUpdates_word_eq {r m : ℕ} (p : BitWord r) (s : ℕ) + (a : BitWord m) (hbound : r + s ≤ m) : + reduceByUpdates (wordList p) s (wordList a) = + wordList (reduceLoop p (r + s) a) := by + revert hbound + induction s generalizing a with + | zero => + intro hbound + simp only [reduceByUpdates_zero, Nat.add_zero, reduceLoop_below p r a le_rfl] + | succ s ih => + intro hbound + have hs : s + r < m := by omega + have hs' : r + s ≤ m := by omega + have hnext : r + (s + 1) = (r + s) + 1 := by omega + calc + reduceByUpdates (wordList p) (s + 1) (wordList a) = + reduceByUpdates (wordList p) s (wordList (cancelStep p (s + r) a)) := by + rw [reduceByUpdates_step, cancelByUpdates_eq_cancelStep p a s hs] + _ = wordList (reduceLoop p (r + s) (cancelStep p (s + r) a)) := ih _ hs' + _ = wordList (reduceLoop p (r + (s + 1)) a) := by + rw [hnext, reduceLoop, Nat.add_comm s r] + +theorem reduceByUpdates_eq_reduceLoop (p c : List Bool) (s : ℕ) + (hbound : p.length + s ≤ c.length) : + reduceByUpdates p s c = + wordList (reduceLoop (listWord p.length p) (p.length + s) (listWord c.length c)) := by + simpa only [wordList_listWord_length] using + reduceByUpdates_word_eq (listWord p.length p) s (listWord c.length c) hbound + +theorem reduceByUpdates_tail_false (p c : List Bool) (s : ℕ) + (hfull : p.length + s = c.length) (i : ℕ) (hi : p.length ≤ i) : + (reduceByUpdates p s c).getD i false = false := by + rw [reduceByUpdates_eq_reduceLoop p c s (by omega), hfull, wordList_getD] + by_cases him : i < c.length + · rw [wordGet_of_lt _ him] + exact reduceLoop_tail_false (listWord p.length p) c.length (listWord c.length c) + (by + intro j _ hj + exact False.elim (Nat.not_le.mpr j.is_lt hj)) ⟨i, him⟩ hi + · exact wordGet_of_le _ (Nat.le_of_not_lt him) + +theorem wordList_wordResize_take {r m : ℕ} (a : BitWord m) (hr : r ≤ m) : + wordList (wordResize r a) = (wordList a).take r := by + apply List.ext_getElem + · simp only [wordList_length, List.length_take, Nat.min_eq_left hr] + · intro i hi hj + have hir : i < r := by simpa only [wordList_length] using hi + have hleft : (wordList (wordResize r a)).getD i false = wordGet a i := by + rw [wordList_getD, wordGet_of_lt _ hir] + rfl + have hright : ((wordList a).take r).getD i false = wordGet a i := by + simpa only [List.getD_eq_getElem?_getD, List.getElem?_take_of_lt hir] using + wordList_getD a i + rw [List.getD_eq_getElem _ false hi] at hleft + rw [List.getD_eq_getElem _ false hj] at hright + exact hleft.trans hright.symm + +theorem reduceByUpdates_take_eq_wordReduce (p c : List Bool) + (hwidth : c.length = p.length + p.length) : + (reduceByUpdates p p.length c).take p.length = + wordList (wordReduce (listWord p.length p) (listWord c.length c)) := by + rw [reduceByUpdates_eq_reduceLoop p c p.length (by omega), ← hwidth] + rw [wordReduce, wordFreeze_eq, wordList_wordResize_take _ (by omega)] + +theorem reduceByUpdates_convolve_eq_multiplyBitLists (r : ℕ) (p a b : List Bool) + (hp : p.length = r) (ha : a.length = r) (hb : b.length = r) : + (reduceByUpdates p r (convolveBitLists a b)).take r = multiplyBitLists r p a b := by + have hwidth : (convolveBitLists a b).length = p.length + p.length := by + simp only [convolveBitLists_length, ha, hb, hp] + have h := reduceByUpdates_take_eq_wordReduce p (convolveBitLists a b) hwidth + rw [convolveBitLists_length, hp] at h + rw [convolveBitLists_eq, ha, hb] at h ⊢ + simpa only [listWord_wordList, multiplyBitLists, wordMulMod] using h + +theorem reduceByUpdates_convolveByUpdates_eq_multiplyBitLists (r : ℕ) + (p a b : List Bool) (hp : p.length = r) (ha : a.length = r) (hb : b.length = r) : + (reduceByUpdates p r (convolveByUpdates a b)).take r = multiplyBitLists r p a b := by + rw [convolveByUpdates_eq] + exact reduceByUpdates_convolve_eq_multiplyBitLists r p a b hp ha hb + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageBitWord.lean b/lean/OAI/Computability/DepthThree/LanguageBitWord.lean new file mode 100644 index 0000000000000000000000000000000000000000..9450b4df8cf6f14b5c6bc810deb1940f7f464eec --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageBitWord.lean @@ -0,0 +1,143 @@ +import OAI.Computability.DepthThree.AlgebraPolynomial + +namespace OAI + +namespace DepthThreeLowerBound + +open BinaryAlgebra + +abbrev BitWord (n : ℕ) := Fin n → Bool + +noncomputable def wordPoly {n : ℕ} (a : BitWord n) : Polynomial (ZMod 2) := + BinaryAlgebra.pack (fun i => BinaryAlgebra.bitValue (a i)) + +def wordXor {n : ℕ} (a b : BitWord n) : BitWord n := + fun i => Bool.xor (a i) (b i) + +def wordGet {n : ℕ} (a : BitWord n) (i : ℕ) : Bool := + if h : i < n then a ⟨i, h⟩ else false + +def shiftModulus {r m : ℕ} (p : BitWord r) (s : ℕ) : BitWord m := + fun i => if i.val = s + r then true + else if h : s ≤ i.val ∧ i.val < s + r then + p ⟨i.val - s, by omega⟩ + else false + +@[simp] theorem wordGet_fin {n : ℕ} (a : BitWord n) (i : Fin n) : + wordGet a i.val = a i := by + simp [wordGet, i.is_lt] + +theorem wordGet_of_lt {n : ℕ} (a : BitWord n) {i : ℕ} (hi : i < n) : + wordGet a i = a ⟨i, hi⟩ := by + simp [wordGet, hi] + +theorem wordGet_of_le {n : ℕ} (a : BitWord n) {i : ℕ} (hi : n ≤ i) : + wordGet a i = false := by + simp [wordGet, Nat.not_lt.mpr hi] + +@[simp] theorem wordGet_wordXor {n : ℕ} (a b : BitWord n) (i : ℕ) : + wordGet (wordXor a b) i = Bool.xor (wordGet a i) (wordGet b i) := by + by_cases hi : i < n <;> simp [wordGet, wordXor, hi] + +theorem coeff_wordPoly {n : ℕ} (a : BitWord n) (i : ℕ) : + (wordPoly a).coeff i = BinaryAlgebra.bitValue (wordGet a i) := by + rw [wordPoly, BinaryAlgebra.coeff_pack_nat] + by_cases hi : i < n <;> simp [wordGet, hi] + +@[simp] theorem coeff_wordPoly_fin {n : ℕ} (a : BitWord n) (i : Fin n) : + (wordPoly a).coeff i.val = BinaryAlgebra.bitValue (a i) := by + rw [coeff_wordPoly, wordGet_fin] + +theorem wordPoly_injective {n : ℕ} : + Function.Injective (wordPoly : BitWord n → Polynomial (ZMod 2)) := by + intro a b h + funext i + apply BinaryAlgebra.bitValue_injective + simpa only [coeff_wordPoly_fin] using + congrArg (fun f : Polynomial (ZMod 2) => f.coeff i.val) h + +@[simp] theorem wordPoly_zero (n : ℕ) : + wordPoly (fun _ : Fin n => false) = 0 := by + change BinaryAlgebra.pack (0 : Fin n → ZMod 2) = 0 + exact BinaryAlgebra.pack_zero + +theorem wordPoly_xor {n : ℕ} (a b : BitWord n) : + wordPoly (wordXor a b) = wordPoly a + wordPoly b := by + unfold wordPoly wordXor + simp only [BinaryAlgebra.bitValue_xor] + exact BinaryAlgebra.pack_add + (fun i => BinaryAlgebra.bitValue (a i)) + (fun i => BinaryAlgebra.bitValue (b i)) + +theorem degree_wordPoly_lt {n : ℕ} (a : BitWord n) : + (wordPoly a).degree < (n : WithBot ℕ) := + BinaryAlgebra.degree_pack_lt _ + +theorem degree_wordPoly_lt_of_zero_tail {n r : ℕ} (a : BitWord n) + (h : ∀ i : ℕ, r ≤ i → wordGet a i = false) : + (wordPoly a).degree < (r : WithBot ℕ) := by + apply (Polynomial.degree_lt_iff_coeff_zero (wordPoly a) r).2 + intro i hi + rw [coeff_wordPoly, h i hi, BinaryAlgebra.bitValue_false] + +theorem degree_wordPoly_lt_of_tail_false {n r : ℕ} (a : BitWord n) + (h : ∀ i : Fin n, r ≤ i.val → a i = false) : + (wordPoly a).degree < (r : WithBot ℕ) := by + apply degree_wordPoly_lt_of_zero_tail + intro i hi + by_cases hin : i < n + · rw [wordGet_of_lt a hin] + exact h ⟨i, hin⟩ hi + · exact wordGet_of_le a (Nat.le_of_not_lt hin) + +theorem inputPolynomialBits_eq_wordPoly {r : ℕ} (p : BitWord r) : + BinaryAlgebra.inputPolynomialBits p = Polynomial.X ^ r + wordPoly p := rfl + +@[simp] theorem shiftModulus_top {r m : ℕ} (p : BitWord r) (s : ℕ) + (h : s + r < m) : + shiftModulus (m := m) p s ⟨s + r, h⟩ = true := by + simp [shiftModulus] + +theorem shiftModulus_above {r m : ℕ} (p : BitWord r) (s : ℕ) + (i : Fin m) (h : s + r < i.val) : + shiftModulus p s i = false := by + have he : i.val ≠ s + r := by omega + have hn : ¬ (s ≤ i.val ∧ i.val < s + r) := by omega + simp [shiftModulus, he, hn] + +theorem wordPoly_shiftModulus {r m : ℕ} (p : BitWord r) (s : ℕ) + (hm : s + r < m) : + wordPoly (shiftModulus (m := m) p s) = + Polynomial.X ^ s * BinaryAlgebra.inputPolynomialBits p := by + ext i + rw [coeff_wordPoly, Polynomial.coeff_X_pow_mul'] + by_cases hs : s ≤ i + · rw [ite_eq_left hs] + by_cases he : i = s + r + · subst i + have hsub : s + r - s = r := by omega + rw [hsub, BinaryAlgebra.inputPolynomialBits_coeff_leading] + simp [wordGet, shiftModulus, hm] + · by_cases hl : i < s + r + · have hi : i < m := hl.trans hm + have hsub : i - s < r := by omega + have hc := BinaryAlgebra.inputPolynomialBits_coeff_lt p ⟨i - s, hsub⟩ + change (BinaryAlgebra.inputPolynomialBits p).coeff (i - s) = _ at hc + rw [hc] + simp [wordGet, shiftModulus, hi, he, hs, hl] + · have hsub : r < i - s := by omega + have hz : (BinaryAlgebra.inputPolynomialBits p).coeff (i - s) = 0 := + BinaryAlgebra.inputPolynomial_coeff_of_gt _ hsub + rw [hz] + by_cases hi : i < m + · simp [wordGet, shiftModulus, hi, he, hl] + · simp [wordGet, hi] + · rw [ite_eq_right hs] + have he : i ≠ s + r := by omega + by_cases hi : i < m + · simp [wordGet, shiftModulus, hi, he, hs] + · simp [wordGet, hi] + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageInputBlockLists.lean b/lean/OAI/Computability/DepthThree/LanguageInputBlockLists.lean new file mode 100644 index 0000000000000000000000000000000000000000..f08239fab498ed3e120bd973b543867a58e13bb9 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageInputBlockLists.lean @@ -0,0 +1,153 @@ +import OAI.Computability.DepthThree.LanguageParser +import Mathlib.Data.List.OfFn +import Mathlib.Data.List.GetD +import Mathlib.Tactic.DeriveFintype + +namespace OAI + +namespace DepthThreeLowerBound + +inductive InputBlockKind where + | data + | hash + | polynomial + | coefficients + deriving DecidableEq + +instance : Fintype InputBlockKind where + elems := {.data, .hash, .polynomial, .coefficients} + complete := by + intro kind + cases kind <;> simp + +def inputBlockOffset (n : ℕ) : InputBlockKind → ℕ + | .data => 0 + | .hash => hashOffset (dataDimension n) + | .polynomial => polynomialOffset (dataDimension n) + | .coefficients => coefficientsOffset (dataDimension n) + +def inputBlockLength (n : ℕ) : InputBlockKind → ℕ + | .data => dataDimension n + | .hash => hashBlockLength (dataDimension n) + | .polynomial => hashDimension (dataDimension n) + | .coefficients => independenceOrder (dataDimension n) * hashDimension (dataDimension n) + +def inputBlockData (w : List Bool) (kind : InputBlockKind) : List Bool := + (w.drop (inputBlockOffset w.length kind)).take (inputBlockLength w.length kind) + +theorem inputBlock_end_le {w : List Bool} (h : InputFits w) (kind : InputBlockKind) : + inputBlockOffset w.length kind + inputBlockLength w.length kind ≤ w.length := by + cases kind with + | data => + simpa only [inputBlockOffset, inputBlockLength, Nat.zero_add, dataDimension] using + Nat.div_le_self w.length 5 + | hash => + change polynomialOffset (dataDimension w.length) ≤ w.length + exact (polynomialOffset_le_coefficientsOffset _).trans + ((coefficientsOffset_le_blockLen _).trans h.2.2) + | polynomial => + change coefficientsOffset (dataDimension w.length) ≤ w.length + exact (coefficientsOffset_le_blockLen _).trans h.2.2 + | coefficients => + exact h.2.2 + +theorem inputBlock_offset_le {w : List Bool} (h : InputFits w) (kind : InputBlockKind) : + inputBlockOffset w.length kind ≤ w.length := by + have hb := inputBlock_end_le h kind + omega + +theorem inputBlock_prefix_length {w : List Bool} (h : InputFits w) + (kind : InputBlockKind) : + (w.take (inputBlockOffset w.length kind)).length = inputBlockOffset w.length kind := + List.length_take_of_le (inputBlock_offset_le h kind) + +theorem inputBlockData_length {w : List Bool} (h : InputFits w) (kind : InputBlockKind) : + (inputBlockData w kind).length = inputBlockLength w.length kind := by + unfold inputBlockData + rw [List.length_take, List.length_drop] + apply Nat.min_eq_left + have hb := inputBlock_end_le h kind + omega + +theorem inputBlock_reconstruct (w : List Bool) (kind : InputBlockKind) : + w = w.take (inputBlockOffset w.length kind) ++ inputBlockData w kind ++ + w.drop (inputBlockOffset w.length kind + inputBlockLength w.length kind) := by + calc + w = w.take (inputBlockOffset w.length kind) ++ + w.drop (inputBlockOffset w.length kind) := + (List.take_append_drop _ _).symm + _ = w.take (inputBlockOffset w.length kind) ++ + ((w.drop (inputBlockOffset w.length kind)).take (inputBlockLength w.length kind) ++ + (w.drop (inputBlockOffset w.length kind)).drop (inputBlockLength w.length kind)) := + congrArg (fun tail => w.take (inputBlockOffset w.length kind) ++ tail) + (List.take_append_drop _ _).symm + _ = _ := by simp only [inputBlockData, List.drop_drop, List.append_assoc] + +theorem inputBlockData_getD (w : List Bool) (kind : InputBlockKind) {i : ℕ} + (hi : i < inputBlockLength w.length kind) : + (inputBlockData w kind).getD i false = + w.getD (inputBlockOffset w.length kind + i) false := by + simp only [inputBlockData, List.getD_eq_getElem?_getD, + List.getElem?_take_of_lt hi, List.getElem?_drop] + +theorem inputBlockData_data_nat (w : List Bool) {i : ℕ} + (hi : i < dataDimension w.length) : + (inputBlockData w .data).getD i false = (decodeInput w).data ⟨i, hi⟩ := by + simpa only [inputBlockOffset, Nat.zero_add, decodeInput] using + inputBlockData_getD w .data hi + +theorem inputBlockData_data (w : List Bool) (i : Fin (dataDimension w.length)) : + (inputBlockData w .data).getD i.val false = (decodeInput w).data i := + inputBlockData_data_nat w i.isLt + +theorem inputBlockData_hash_nat (w : List Bool) {i : ℕ} + (hi : i < hashBlockLength (dataDimension w.length)) : + (inputBlockData w .hash).getD i false = (decodeInput w).hashSeed ⟨i, hi⟩ := by + simpa only [inputBlockOffset, decodeInput] using inputBlockData_getD w .hash hi + +theorem inputBlockData_hash (w : List Bool) + (i : Fin (hashBlockLength (dataDimension w.length))) : + (inputBlockData w .hash).getD i.val false = (decodeInput w).hashSeed i := + inputBlockData_hash_nat w i.isLt + +theorem inputBlockData_polynomial_nat (w : List Bool) {i : ℕ} + (hi : i < hashDimension (dataDimension w.length)) : + (inputBlockData w .polynomial).getD i false = (decodeInput w).polynomial ⟨i, hi⟩ := by + simpa only [inputBlockOffset, decodeInput] using inputBlockData_getD w .polynomial hi + +theorem inputBlockData_polynomial (w : List Bool) + (i : Fin (hashDimension (dataDimension w.length))) : + (inputBlockData w .polynomial).getD i.val false = (decodeInput w).polynomial i := + inputBlockData_polynomial_nat w i.isLt + +theorem inputBlock_coefficient_index_lt {n j i : ℕ} + (hj : j < independenceOrder (dataDimension n)) + (hi : i < hashDimension (dataDimension n)) : + j * hashDimension (dataDimension n) + i < inputBlockLength n .coefficients := by + have hmul := Nat.mul_le_mul_right (hashDimension (dataDimension n)) + (Nat.succ_le_of_lt hj) + simp only [Nat.succ_mul] at hmul + change j * hashDimension (dataDimension n) + i < + independenceOrder (dataDimension n) * hashDimension (dataDimension n) + omega + +theorem inputBlockData_coefficients_nat (w : List Bool) {j i : ℕ} + (hj : j < independenceOrder (dataDimension w.length)) + (hi : i < hashDimension (dataDimension w.length)) : + (inputBlockData w .coefficients).getD + (j * hashDimension (dataDimension w.length) + i) false = + (decodeInput w).coefficients ⟨j, hj⟩ ⟨i, hi⟩ := by + simpa only [inputBlockOffset, decodeInput, coefficientOffset, Nat.add_assoc] using + inputBlockData_getD w .coefficients (inputBlock_coefficient_index_lt hj hi) + +theorem inputBlockData_coefficients (w : List Bool) + (j : Fin (independenceOrder (dataDimension w.length))) + (i : Fin (hashDimension (dataDimension w.length))) : + (inputBlockData w .coefficients).getD + (j.val * hashDimension (dataDimension w.length) + i.val) false = + (decodeInput w).coefficients j i := + inputBlockData_coefficients_nat w j.isLt i.isLt + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageInputBlockWords.lean b/lean/OAI/Computability/DepthThree/LanguageInputBlockWords.lean new file mode 100644 index 0000000000000000000000000000000000000000..7be896fe52772814eb606e0bdef7f0a0eca710e5 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageInputBlockWords.lean @@ -0,0 +1,152 @@ +import OAI.Computability.DepthThree.LanguageInputBlockLists +import OAI.Computability.DepthThree.LanguageBitHashUpdates +import OAI.Computability.DepthThree.LanguageBitHornerLoop + +namespace OAI + +namespace DepthThreeLowerBound + +private theorem list_eq_ofFn_of_getD {n : ℕ} (xs : List Bool) (f : Fin n → Bool) + (hlen : xs.length = n) (hread : ∀ i, xs.getD i.val false = f i) : + xs = List.ofFn f := by + have heq : listWord n xs = f := by + funext i + exact hread i + exact (wordList_listWord xs hlen).symm.trans (congrArg wordList heq) + +theorem inputBlockData_data_length {w : List Bool} (hfit : InputFits w) : + (inputBlockData w .data).length = (decodeInput w).dataSize := + inputBlockData_length hfit .data + +theorem inputBlockData_hash_length {w : List Bool} (hfit : InputFits w) : + (inputBlockData w .hash).length = + (decodeInput w).dataSize + (decodeInput w).ringDegree - 1 := + inputBlockData_length hfit .hash + +theorem inputBlockData_polynomial_length {w : List Bool} (hfit : InputFits w) : + (inputBlockData w .polynomial).length = (decodeInput w).ringDegree := + inputBlockData_length hfit .polynomial + +theorem inputBlockData_coefficients_length {w : List Bool} (hfit : InputFits w) : + (inputBlockData w .coefficients).length = + (decodeInput w).coefficientCount * (decodeInput w).ringDegree := + inputBlockData_length hfit .coefficients + +theorem decoded_ringDegree_ne_zero {w : List Bool} (hfit : InputFits w) : + (decodeInput w).ringDegree ≠ 0 := + Nat.ne_of_gt (decoded_ringDegree_pos hfit) + +theorem inputBlockData_data_eq_ofFn {w : List Bool} (hfit : InputFits w) : + inputBlockData w .data = List.ofFn (decodeInput w).data := + list_eq_ofFn_of_getD _ _ (inputBlockData_data_length hfit) + (inputBlockData_data w) + +theorem inputBlockData_hash_eq_ofFn {w : List Bool} (hfit : InputFits w) : + inputBlockData w .hash = List.ofFn (decodeInput w).hashSeed := + list_eq_ofFn_of_getD _ _ (inputBlockData_hash_length hfit) + (inputBlockData_hash w) + +theorem inputBlockData_polynomial_eq_ofFn {w : List Bool} (hfit : InputFits w) : + inputBlockData w .polynomial = List.ofFn (decodeInput w).polynomial := + list_eq_ofFn_of_getD _ _ (inputBlockData_polynomial_length hfit) + (inputBlockData_polynomial w) + +def decodedCoefficientBlocks (w : List Bool) : List (List Bool) := + List.ofFn fun j => List.ofFn ((decodeInput w).coefficients j) + +@[simp] theorem decodedCoefficientBlocks_length (w : List Bool) : + (decodedCoefficientBlocks w).length = (decodeInput w).coefficientCount := by + simp only [decodedCoefficientBlocks, List.length_ofFn] + +theorem decodedCoefficientBlocks_row_length (w : List Bool) : + ∀ b ∈ decodedCoefficientBlocks w, b.length = (decodeInput w).ringDegree := by + intro b hb + obtain ⟨j, rfl⟩ := List.mem_ofFn.mp hb + exact List.length_ofFn + +@[simp] theorem decodedCoefficientBlocks_flatten_length (w : List Bool) : + (decodedCoefficientBlocks w).flatten.length = + (decodeInput w).coefficientCount * (decodeInput w).ringDegree := by + rw [block_flatten_length _ _ (decodedCoefficientBlocks_row_length w), + decodedCoefficientBlocks_length] + +theorem inputBlockData_coefficients_eq_flatten {w : List Bool} (hfit : InputFits w) : + inputBlockData w .coefficients = (decodedCoefficientBlocks w).flatten := by + have heq : inputBlockData w .coefficients = List.ofFn + (fun i : Fin ((decodeInput w).coefficientCount * (decodeInput w).ringDegree) => + (inputBlockData w .coefficients).getD i.val false) := + list_eq_ofFn_of_getD _ _ (inputBlockData_coefficients_length hfit) (fun _ => rfl) + rw [heq, List.ofFn_mul] + apply congrArg List.flatten + apply congrArg List.ofFn + funext j + apply congrArg List.ofFn + funext i + exact inputBlockData_coefficients w j i + +theorem hornerBitLists_ofFn {r t : ℕ} (p h : BitWord r) (b : Fin t → BitWord r) : + hornerBitLists r (List.ofFn p) (List.ofFn h) (List.ofFn fun j => List.ofFn (b j)) = + List.ofFn (wordHorner p h t b) := by + have hp : listWord r (List.ofFn p) = p := listWord_wordList p + have hh : listWord r (List.ofFn h) = h := listWord_wordList h + have hb : (fun j : Fin t => listWord r + ((List.ofFn fun j => List.ofFn (b j)).getD j.val [])) = b := by + funext j + simp only [List.getD_eq_getElem?_getD, List.getElem?_ofFn, dite_eq_left j.isLt, + Option.getD_some] + exact listWord_wordList (b j) + unfold hornerBitLists + rw [List.length_ofFn] + simp only [hp, hh, hb] + rfl + +theorem hashByUpdates_inputBlocks {w : List Bool} (hfit : InputFits w) : + hashByUpdates (decodeInput w).ringDegree + (inputBlockData w .hash) (inputBlockData w .data) = + List.ofFn (wordHash (decodeInput w).hashSeed (decodeInput w).data) := by + rw [inputBlockData_hash_eq_ofFn hfit, inputBlockData_data_eq_ofFn hfit] + exact hashByUpdates_ofFn_eq _ _ + +theorem hornerBitLists_inputBlocks {w : List Bool} (hfit : InputFits w) : + hornerBitLists (decodeInput w).ringDegree (inputBlockData w .polynomial) + (hashByUpdates (decodeInput w).ringDegree + (inputBlockData w .hash) (inputBlockData w .data)) + (decodedCoefficientBlocks w) = + List.ofFn (decodeInput w).evaluationBits := by + rw [inputBlockData_polynomial_eq_ofFn hfit, hashByUpdates_inputBlocks hfit] + exact hornerBitLists_ofFn _ _ _ + +theorem hornerFrom_inputBlocks {w : List Bool} (hfit : InputFits w) : + hornerFrom (decodeInput w).ringDegree (inputBlockData w .polynomial) + (hashByUpdates (decodeInput w).ringDegree + (inputBlockData w .hash) (inputBlockData w .data)) + (decodedCoefficientBlocks w) + (List.replicate (decodeInput w).ringDegree false) = + List.ofFn (decodeInput w).evaluationBits := by + rw [hornerFrom_zero_eq_hornerBitLists _ _ _ _ (decodedCoefficientBlocks_row_length w)] + exact hornerBitLists_inputBlocks hfit + +theorem evaluateBits_eq_final_bit {w : List Bool} (hfit : InputFits w) : + (decodeInput w).evaluateBits = + !((hornerBitLists (decodeInput w).ringDegree (inputBlockData w .polynomial) + (hashByUpdates (decodeInput w).ringDegree + (inputBlockData w .hash) (inputBlockData w .data)) + (decodedCoefficientBlocks w)).getD 0 false) := by + rw [hornerBitLists_inputBlocks hfit] + change Bool.not (wordGet (decodeInput w).evaluationBits 0) = + Bool.not ((wordList (decodeInput w).evaluationBits).getD 0 false) + rw [wordList_getD] + +theorem language_eq_final_bit {w : List Bool} (hfit : InputFits w) : + language w = + !((hornerBitLists (decodeInput w).ringDegree (inputBlockData w .polynomial) + (hashByUpdates (decodeInput w).ringDegree + (inputBlockData w .hash) (inputBlockData w .data)) + (decodedCoefficientBlocks w)).getD 0 false) := by + simpa only [language, parseInput_of_fits hfit] using + ((ParsedInput.evaluateBits_eq (decodeInput w)).symm.trans + (evaluateBits_eq_final_bit hfit)) + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageLowerBound.lean b/lean/OAI/Computability/DepthThree/LanguageLowerBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e21e9dabe0188f78d60685e7fbc9053ea91171b --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageLowerBound.lean @@ -0,0 +1,33 @@ +import OAI.Computability.DepthThree.HardSlice +import OAI.Computability.DepthThree.CircuitQuantitative + +namespace OAI + +namespace DepthThreeLowerBound + +theorem language_depth_three_gate_lower_bound (A : ℝ) (hA : 0 < A) : + ∃ N : ℕ, ∀ n : ℕ, N ≤ n → ∀ C : Circuit3 (Fin n), + C.Computes (fun x => language (List.ofFn x)) → + (2 : ℝ) ^ (A * Real.sqrt (n : ℝ)) < (C.gateCount : ℝ) := by + have hs : 0 ≤ 3 * A := mul_nonneg (by norm_num) hA.le + obtain ⟨N, hN, hslice⟩ := exists_language_slice_small_correlations (3 * A) hs + refine ⟨N, ?_⟩ + intro n hn C hC + have hnlarge : 20480 ≤ n := hN.trans hn + have hd : 4 ≤ dataDimension n := by + unfold dataDimension + omega + obtain ⟨α, hα⟩ := hslice n hn + have hrestricted := circuit_lower_bound_of_small_cnf_correlations + (dataDimension n) (degreeCutoff (3 * A) (dataDimension n)) + (3 * A) hs hd (degreeCutoff_lower (3 * A) (dataDimension n)) + (fun x => language (List.ofFn (GateInput.assignment α x))) hα + (C.subst α) (C.computes_subst hC α) + have hdata : (2 : ℝ) ^ ((3 * A) * Real.sqrt (dataDimension n : ℝ)) < + (C.gateCount : ℝ) := by + simpa only [Circuit3.gateCount_subst] using hrestricted + exact (circuit_size_scale A hA.le n (by omega)).trans_lt hdata + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageParameterBounds.lean b/lean/OAI/Computability/DepthThree/LanguageParameterBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..68a7e5fa5ec1293c2b3b6a10fa7016267ec60297 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageParameterBounds.lean @@ -0,0 +1,136 @@ +import OAI.Computability.DepthThree.LanguageParameters +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +namespace OAI + +noncomputable section + +namespace DepthThreeLowerBound + +private theorem rpow_two_thirds_cube (d : ℕ) : + ((d : ℝ) ^ (2 / 3 : ℝ)) ^ 3 = (d : ℝ) ^ 2 := by + rw [← Real.rpow_mul_natCast (Nat.cast_nonneg d) (2 / 3 : ℝ) 3] + norm_num + +private theorem rpow_one_sixth_sixth (d : ℕ) : + ((d : ℝ) ^ (1 / 6 : ℝ)) ^ 6 = (d : ℝ) := by + rw [← Real.rpow_mul_natCast (Nat.cast_nonneg d) (1 / 6 : ℝ) 6] + norm_num + +theorem hashDimension_rpow_lower (d : ℕ) : + (d : ℝ) ^ (2 / 3 : ℝ) ≤ (hashDimension d : ℝ) := by + apply le_of_pow_le_pow_left₀ (by decide : (3 : ℕ) ≠ 0) + (Nat.cast_nonneg (hashDimension d)) + rw [rpow_two_thirds_cube] + exact_mod_cast hashDimension_cube_bound d + +theorem hashDimension_rpow_lt_add_one (d : ℕ) (hd : 0 < d) : + (hashDimension d : ℝ) < (d : ℝ) ^ (2 / 3 : ℝ) + 1 := by + have hr := hashDimension_pos hd + by_cases hrone : hashDimension d = 1 + · have hpos := Real.rpow_pos_of_pos (Nat.cast_pos.mpr hd) (2 / 3 : ℝ) + rw [hrone] + norm_num only [Nat.cast_one] + linarith + · have hpredpos : 0 < hashDimension d - 1 := by omega + have hpred : (hashDimension d - 1) ^ 3 < d ^ 2 := by + by_contra h + have hle := hashDimension_minimal hd hpredpos (Nat.le_of_not_gt h) + omega + have hpredreal : ((hashDimension d - 1 : ℕ) : ℝ) < + (d : ℝ) ^ (2 / 3 : ℝ) := by + apply lt_of_pow_lt_pow_left₀ 3 (Real.rpow_nonneg (Nat.cast_nonneg d) _) + rw [rpow_two_thirds_cube] + exact_mod_cast hpred + have hcast : ((hashDimension d - 1 : ℕ) : ℝ) = + (hashDimension d : ℝ) - 1 := by + rw [Nat.cast_sub (by omega : 1 ≤ hashDimension d)] ; norm_num + rw [hcast] at hpredreal + linarith + +theorem hashDimension_rpow_upper (d : ℕ) (hd : 1 ≤ d) : + (hashDimension d : ℝ) ≤ 2 * (d : ℝ) ^ (2 / 3 : ℝ) := by + have hround := hashDimension_rpow_lt_add_one d (by omega) + have hone : (1 : ℝ) ≤ (d : ℝ) ^ (2 / 3 : ℝ) := + Real.one_le_rpow (by exact_mod_cast hd) (by norm_num) + linarith + +theorem independenceOrder_rpow_le (d : ℕ) : + (independenceOrder d : ℝ) ≤ (d : ℝ) ^ (1 / 6 : ℝ) := by + apply le_of_pow_le_pow_left₀ (by decide : (6 : ℕ) ≠ 0) + (Real.rpow_nonneg (Nat.cast_nonneg d) _) + rw [rpow_one_sixth_sixth] + exact_mod_cast independenceOrder_pow_le d + +theorem rpow_lt_independenceOrder_add_two (d : ℕ) : + (d : ℝ) ^ (1 / 6 : ℝ) < (independenceOrder d : ℝ) + 2 := by + apply lt_of_pow_lt_pow_left₀ 6 + (by linarith [(Nat.cast_nonneg (independenceOrder d) : + (0 : ℝ) ≤ (independenceOrder d : ℝ))] : + (0 : ℝ) ≤ (independenceOrder d : ℝ) + 2) + rw [rpow_one_sixth_sixth] + exact_mod_cast independenceOrder_next_pow_gt d + +theorem four_le_rpow_one_sixth (d : ℕ) (hd : 4096 ≤ d) : + (4 : ℝ) ≤ (d : ℝ) ^ (1 / 6 : ℝ) := by + apply le_of_pow_le_pow_left₀ (by decide : (6 : ℕ) ≠ 0) + (Real.rpow_nonneg (Nat.cast_nonneg d) _) + rw [rpow_one_sixth_sixth] + norm_num only [show (4 : ℝ) ^ 6 = 4096 by norm_num] + exact_mod_cast hd + +theorem half_rpow_le_independenceOrder (d : ℕ) (hd : 4096 ≤ d) : + (d : ℝ) ^ (1 / 6 : ℝ) / 2 ≤ (independenceOrder d : ℝ) := by + have hfour := four_le_rpow_one_sixth d hd + have hnext := rpow_lt_independenceOrder_add_two d + linarith + +theorem independenceOrder_add_two_mul_hashDimension_le (d : ℕ) (hd : 4096 ≤ d) : + (independenceOrder d + 2) * hashDimension d ≤ 3 * d := by + have hdreal : (1 : ℝ) ≤ (d : ℝ) := by exact_mod_cast (by omega : 1 ≤ d) + have hdpos : (0 : ℝ) < (d : ℝ) := lt_of_lt_of_le zero_lt_one hdreal + have ht := independenceOrder_rpow_le d + have hr := hashDimension_rpow_upper d (by omega) + have hfour := four_le_rpow_one_sixth d hd + have hy : 0 ≤ (d : ℝ) ^ (2 / 3 : ℝ) := + Real.rpow_nonneg (Nat.cast_nonneg d) _ + have hproduct : ((independenceOrder d : ℝ) + 2) * (hashDimension d : ℝ) ≤ + ((d : ℝ) ^ (1 / 6 : ℝ) + 2) * (2 * (d : ℝ) ^ (2 / 3 : ℝ)) := + mul_le_mul (by linarith) hr + (Nat.cast_nonneg (hashDimension d)) (by linarith) + have hslack : 0 ≤ ((d : ℝ) ^ (1 / 6 : ℝ) - 4) * + ((d : ℝ) ^ (2 / 3 : ℝ)) := + mul_nonneg (by linarith) hy + have hsum : (d : ℝ) ^ (1 / 6 : ℝ) * (d : ℝ) ^ (2 / 3 : ℝ) = + (d : ℝ) ^ (5 / 6 : ℝ) := by + rw [← Real.rpow_add hdpos] + norm_num + have hlast : (d : ℝ) ^ (5 / 6 : ℝ) ≤ (d : ℝ) := by + simpa only [Real.rpow_one] using + (Real.rpow_le_rpow_of_exponent_le hdreal (by norm_num : (5 / 6 : ℝ) ≤ 1)) + have hreal : ((independenceOrder d : ℝ) + 2) * (hashDimension d : ℝ) ≤ + 3 * (d : ℝ) := by + nlinarith [hproduct, hslack, hsum, hlast] + exact_mod_cast hreal + +theorem blockLen_le_five_mul (d : ℕ) (hd : 4096 ≤ d) : + blockLen d ≤ 5 * d := by + have hprod := independenceOrder_add_two_mul_hashDimension_le d hd + rw [blockLen_eq (by omega : 0 < d)] + omega + +theorem blockLen_dataDimension_le (n : ℕ) (hn : 20480 ≤ n) : + blockLen (dataDimension n) ≤ n := by + have hd : 4096 ≤ dataDimension n := by + unfold dataDimension + omega + exact (blockLen_le_five_mul (dataDimension n) hd).trans (five_mul_dataDimension_le n) + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageParameters.lean b/lean/OAI/Computability/DepthThree/LanguageParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..df7250a9d2f33c2fe053522f4a399cb170953e96 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageParameters.lean @@ -0,0 +1,247 @@ +import Mathlib.Data.Nat.Find +import Mathlib.Algebra.Group.Nat.Even +import Lean.Elab.Tactic.Omega + +namespace OAI + +namespace DepthThreeLowerBound + +def dataDimension (n : ℕ) : ℕ := n / 5 + +theorem five_mul_dataDimension_le (n : ℕ) : 5 * dataDimension n ≤ n := by + unfold dataDimension + omega + +theorem lt_five_mul_dataDimension_add_five (n : ℕ) : + n < 5 * dataDimension n + 5 := by + unfold dataDimension + omega + +theorem dataDimension_eq_zero_iff (n : ℕ) : dataDimension n = 0 ↔ n < 5 := by + unfold dataDimension + omega + +theorem hashDimension_exists (d : ℕ) (hd : 0 < d) : + ∃ r : ℕ, 0 < r ∧ d ^ 2 ≤ r ^ 3 := + ⟨d, hd, Nat.pow_le_pow_right hd (by decide)⟩ + +def hashDimension (d : ℕ) : ℕ := + if hd : d = 0 then 0 + else Nat.find (hashDimension_exists d (Nat.pos_of_ne_zero hd)) + +@[simp] theorem hashDimension_zero : hashDimension 0 = 0 := by + simp [hashDimension] + +theorem hashDimension_spec {d : ℕ} (hd : 0 < d) : + 0 < hashDimension d ∧ d ^ 2 ≤ hashDimension d ^ 3 := by + rw [hashDimension, dite_eq_right (Nat.ne_of_gt hd)] + exact Nat.find_spec (hashDimension_exists d hd) + +theorem hashDimension_pos {d : ℕ} (hd : 0 < d) : 0 < hashDimension d := + (hashDimension_spec hd).1 + +theorem hashDimension_cube_bound (d : ℕ) : d ^ 2 ≤ hashDimension d ^ 3 := by + by_cases hd : d = 0 + · subst d + simp + · exact (hashDimension_spec (Nat.pos_of_ne_zero hd)).2 + +theorem hashDimension_minimal {d r : ℕ} (hd : 0 < d) + (hr : 0 < r) (hcube : d ^ 2 ≤ r ^ 3) : hashDimension d ≤ r := by + rw [hashDimension, dite_eq_right (Nat.ne_of_gt hd)] + exact Nat.find_min' _ ⟨hr, hcube⟩ + +theorem hashDimension_le (d : ℕ) : hashDimension d ≤ d := by + by_cases hd : d = 0 + · subst d + simp + · have hd' := Nat.pos_of_ne_zero hd + exact hashDimension_minimal hd' hd' (Nat.pow_le_pow_right hd' (by decide)) + +theorem hashDimension_le_iff {d r : ℕ} (hd : 0 < d) : + hashDimension d ≤ r ↔ 0 < r ∧ d ^ 2 ≤ r ^ 3 := by + constructor + · intro hr + exact ⟨lt_of_lt_of_le (hashDimension_pos hd) hr, + Nat.le_trans (hashDimension_cube_bound d) (Nat.pow_le_pow_left hr 3)⟩ + · rintro ⟨hr, hcube⟩ + exact hashDimension_minimal hd hr hcube + +theorem nat_le_sixth_power (j : ℕ) : j ≤ j ^ 6 := by + by_cases hj : j = 0 + · subst j + simp + · simpa only [Nat.pow_one] using + (Nat.pow_le_pow_right (Nat.pos_of_ne_zero hj) (show 1 ≤ 6 by decide)) + +theorem sixth_power_le_implies_le {j d : ℕ} (hj : j ^ 6 ≤ d) : j ≤ d := + Nat.le_trans (nat_le_sixth_power j) hj + +def independenceOrder (d : ℕ) : ℕ := + Nat.findGreatest (fun t => Even t ∧ t ^ 6 ≤ d) d + +@[simp] theorem independenceOrder_zero : independenceOrder 0 = 0 := rfl + +theorem independenceOrder_spec (d : ℕ) : + Even (independenceOrder d) ∧ independenceOrder d ^ 6 ≤ d := by + exact Nat.findGreatest_spec (P := fun t => Even t ∧ t ^ 6 ≤ d) + (Nat.zero_le d) ⟨⟨0, rfl⟩, by simp⟩ + +theorem independenceOrder_even (d : ℕ) : Even (independenceOrder d) := + (independenceOrder_spec d).1 + +theorem independenceOrder_pow_le (d : ℕ) : independenceOrder d ^ 6 ≤ d := + (independenceOrder_spec d).2 + +theorem independenceOrder_le (d : ℕ) : independenceOrder d ≤ d := + Nat.findGreatest_le d + +theorem independenceOrder_greatest {d j : ℕ} (hj : Even j) (hpow : j ^ 6 ≤ d) : + j ≤ independenceOrder d := + Nat.le_findGreatest (sixth_power_le_implies_le hpow) ⟨hj, hpow⟩ + +theorem independenceOrder_two_le_iff (d : ℕ) : + 2 ≤ independenceOrder d ↔ 64 ≤ d := by + constructor + · intro ht + calc + 64 = (2 : ℕ) ^ 6 := rfl + _ ≤ independenceOrder d ^ 6 := Nat.pow_le_pow_left ht 6 + _ ≤ d := independenceOrder_pow_le d + · intro hd + exact independenceOrder_greatest ⟨1, rfl⟩ (show (2 : ℕ) ^ 6 ≤ d from hd) + +theorem independenceOrder_eq_zero_iff (d : ℕ) : + independenceOrder d = 0 ↔ d < 64 := by + have ht := independenceOrder_two_le_iff d + obtain ⟨k, hk⟩ := independenceOrder_even d + constructor <;> intro h <;> omega + +theorem independenceOrder_next_pow_gt (d : ℕ) : + d < (independenceOrder d + 2) ^ 6 := by + by_contra h + have hpow : (independenceOrder d + 2) ^ 6 ≤ d := Nat.le_of_not_gt h + have heven : Even (independenceOrder d + 2) := by + obtain ⟨k, hk⟩ := independenceOrder_even d + exact ⟨k + 1, by omega⟩ + have hle := independenceOrder_greatest heven hpow + omega + +theorem independenceOrder_eq_iff (d j : ℕ) : + independenceOrder d = j ↔ + Even j ∧ j ^ 6 ≤ d ∧ ∀ k : ℕ, Even k → k ^ 6 ≤ d → k ≤ j := by + constructor + · intro h + subst j + exact ⟨independenceOrder_even d, independenceOrder_pow_le d, + fun _ hk hp => independenceOrder_greatest hk hp⟩ + · rintro ⟨hj, hp, hmax⟩ + exact le_antisymm (hmax _ (independenceOrder_even d) (independenceOrder_pow_le d)) + (independenceOrder_greatest hj hp) + +theorem independenceOrder_dataDimension_two_le_iff (n : ℕ) : + 2 ≤ independenceOrder (dataDimension n) ↔ 320 ≤ n := by + rw [independenceOrder_two_le_iff] + unfold dataDimension + omega + +def hashBlockLength (d : ℕ) : ℕ := d + hashDimension d - 1 + +def hashOffset (d : ℕ) : ℕ := d + +def polynomialOffset (d : ℕ) : ℕ := hashOffset d + hashBlockLength d + +def coefficientsOffset (d : ℕ) : ℕ := polynomialOffset d + hashDimension d + +def coefficientOffset (d j : ℕ) : ℕ := coefficientsOffset d + j * hashDimension d + +def blockLen (d : ℕ) : ℕ := + coefficientsOffset d + independenceOrder d * hashDimension d + +theorem polynomialOffset_eq (d : ℕ) : + polynomialOffset d = d + (d + hashDimension d - 1) := rfl + +theorem coefficientsOffset_eq (d : ℕ) : + coefficientsOffset d = d + (d + hashDimension d - 1) + hashDimension d := rfl + +theorem blockLen_eq_sum (d : ℕ) : + blockLen d = d + (d + hashDimension d - 1) + hashDimension d + + independenceOrder d * hashDimension d := rfl + +theorem blockLen_eq {d : ℕ} (hd : 0 < d) : + blockLen d = 2 * d + (independenceOrder d + 2) * hashDimension d - 1 := by + rw [blockLen_eq_sum] + simp only [Nat.add_mul] + omega + +theorem hashBlockLength_pos {d : ℕ} (hd : 0 < d) : 0 < hashBlockLength d := by + have hr := hashDimension_pos hd + unfold hashBlockLength + omega + +theorem hashOffset_le_polynomialOffset (d : ℕ) : hashOffset d ≤ polynomialOffset d := by + unfold polynomialOffset + omega + +theorem polynomialOffset_le_coefficientsOffset (d : ℕ) : + polynomialOffset d ≤ coefficientsOffset d := by + unfold coefficientsOffset + omega + +theorem coefficientsOffset_le_blockLen (d : ℕ) : coefficientsOffset d ≤ blockLen d := by + unfold blockLen + omega + +@[simp] theorem coefficientOffset_zero (d : ℕ) : + coefficientOffset d 0 = coefficientsOffset d := by + simp [coefficientOffset] + +theorem coefficientOffset_succ (d j : ℕ) : + coefficientOffset d (j + 1) = coefficientOffset d j + hashDimension d := by + simp only [coefficientOffset, Nat.add_mul, Nat.one_mul, Nat.add_assoc] + +theorem coefficientOffset_last (d : ℕ) : + coefficientOffset d (independenceOrder d) = blockLen d := rfl + +theorem coefficientOffset_mono (d : ℕ) {j k : ℕ} (hjk : j ≤ k) : + coefficientOffset d j ≤ coefficientOffset d k := + Nat.add_le_add_left (Nat.mul_le_mul_right (hashDimension d) hjk) _ + +theorem hash_index_lt {d i s : ℕ} (hi : i < hashDimension d) (hs : s < d) : + i + s < hashBlockLength d := by + unfold hashBlockLength + omega + +theorem hash_absolute_index_lt {d i s : ℕ} + (hi : i < hashDimension d) (hs : s < d) : + hashOffset d + (i + s) < polynomialOffset d := + Nat.add_lt_add_left (hash_index_lt hi hs) _ + +theorem polynomial_index_lt {d i : ℕ} (hi : i < hashDimension d) : + polynomialOffset d + i < coefficientsOffset d := + Nat.add_lt_add_left hi _ + +theorem coefficient_index_lt {d j i : ℕ} + (hj : j < independenceOrder d) (hi : i < hashDimension d) : + coefficientOffset d j + i < blockLen d := by + have hmul := Nat.mul_le_mul_right (hashDimension d) (Nat.succ_le_of_lt hj) + simp only [Nat.succ_mul] at hmul + unfold coefficientOffset blockLen + omega + +theorem blockLen_le_quad (d : ℕ) : blockLen d ≤ d * d + 4 * d := by + have hr := hashDimension_le d + have hmul := Nat.mul_le_mul (independenceOrder_le d) hr + rw [blockLen_eq_sum] + omega + +theorem blockLen_le_four_mul_sub_one {d : ℕ} (hd : 0 < d) (hlt : d < 64) : + blockLen d ≤ 4 * d - 1 := by + rw [blockLen_eq hd, (independenceOrder_eq_zero_iff d).mpr hlt] + have hr := hashDimension_le d + simp only [Nat.zero_add] + omega + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageParser.lean b/lean/OAI/Computability/DepthThree/LanguageParser.lean new file mode 100644 index 0000000000000000000000000000000000000000..7268587dacef6e5d6992801efa7d3c5d7bd6b72f --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageParser.lean @@ -0,0 +1,103 @@ +import OAI.Computability.DepthThree.LanguageParameters +import Mathlib.Data.List.GetD + +namespace OAI + +namespace DepthThreeLowerBound + +structure ParsedInput where + dataSize : ℕ + ringDegree : ℕ + coefficientCount : ℕ + data : Fin dataSize → Bool + hashSeed : Fin (dataSize + ringDegree - 1) → Bool + polynomial : Fin ringDegree → Bool + coefficients : Fin coefficientCount → Fin ringDegree → Bool + +def decodeInput (w : List Bool) : ParsedInput where + dataSize := dataDimension w.length + ringDegree := hashDimension (dataDimension w.length) + coefficientCount := independenceOrder (dataDimension w.length) + data i := w.getD i.val false + hashSeed i := w.getD (hashOffset (dataDimension w.length) + i.val) false + polynomial i := w.getD (polynomialOffset (dataDimension w.length) + i.val) false + coefficients j i := + w.getD (coefficientOffset (dataDimension w.length) j.val + i.val) false + +def InputFits (w : List Bool) : Prop := + 0 < dataDimension w.length ∧ + 2 ≤ independenceOrder (dataDimension w.length) ∧ + blockLen (dataDimension w.length) ≤ w.length + +instance (w : List Bool) : Decidable (InputFits w) := by + unfold InputFits + infer_instance + +def parseInput (w : List Bool) : Option ParsedInput := + if InputFits w then some (decodeInput w) else none + +theorem parseInput_of_fits {w : List Bool} (h : InputFits w) : + parseInput w = some (decodeInput w) := by + simp only [parseInput, ite_eq_left h] + +theorem parseInput_of_not_fits {w : List Bool} (h : ¬InputFits w) : + parseInput w = none := by + simp only [parseInput, ite_eq_right h] + +theorem parseInput_eq_some_iff (w : List Bool) (q : ParsedInput) : + parseInput w = some q ↔ InputFits w ∧ decodeInput w = q := by + by_cases h : InputFits w + · simp [parseInput, h] + · simp [parseInput, h] + +theorem parseInput_eq_none_iff (w : List Bool) : + parseInput w = none ↔ ¬InputFits w := by + by_cases h : InputFits w + · simp [parseInput, h] + · simp [parseInput, h] + +theorem decodeInput_dataSize (w : List Bool) : + (decodeInput w).dataSize = dataDimension w.length := rfl + +theorem decodeInput_ringDegree (w : List Bool) : + (decodeInput w).ringDegree = hashDimension (dataDimension w.length) := rfl + +theorem decodeInput_coefficientCount (w : List Bool) : + (decodeInput w).coefficientCount = independenceOrder (dataDimension w.length) := rfl + +theorem data_read_lt (w : List Bool) (i : Fin (dataDimension w.length)) : + i.val < w.length := + Nat.lt_of_lt_of_le i.isLt (Nat.div_le_self w.length 5) + +theorem hash_read_lt {w : List Bool} (h : InputFits w) + (i : Fin (dataDimension w.length + hashDimension (dataDimension w.length) - 1)) : + hashOffset (dataDimension w.length) + i.val < w.length := by + have hi : hashOffset (dataDimension w.length) + i.val < + polynomialOffset (dataDimension w.length) := + Nat.add_lt_add_left i.isLt _ + exact Nat.lt_of_lt_of_le hi (Nat.le_trans (polynomialOffset_le_coefficientsOffset _) + (Nat.le_trans (coefficientsOffset_le_blockLen _) h.2.2)) + +theorem polynomial_read_lt {w : List Bool} (h : InputFits w) + (i : Fin (hashDimension (dataDimension w.length))) : + polynomialOffset (dataDimension w.length) + i.val < w.length := + Nat.lt_of_lt_of_le (polynomial_index_lt i.isLt) + (Nat.le_trans (coefficientsOffset_le_blockLen _) h.2.2) + +theorem coefficient_read_lt {w : List Bool} (h : InputFits w) + (j : Fin (independenceOrder (dataDimension w.length))) + (i : Fin (hashDimension (dataDimension w.length))) : + coefficientOffset (dataDimension w.length) j.val + i.val < w.length := + Nat.lt_of_lt_of_le (coefficient_index_lt j.isLt i.isLt) h.2.2 + +theorem decoded_ringDegree_pos {w : List Bool} (h : InputFits w) : + 0 < (decodeInput w).ringDegree := + hashDimension_pos h.1 + +theorem decoded_coefficientCount_two_le {w : List Bool} (h : InputFits w) : + 2 ≤ (decodeInput w).coefficientCount := + h.2.1 + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageSearchTests.lean b/lean/OAI/Computability/DepthThree/LanguageSearchTests.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f701cd5ee1bfabf8249f494625d20d9354c5de6 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageSearchTests.lean @@ -0,0 +1,57 @@ +import OAI.Computability.DepthThree.LanguageParameters + +namespace OAI + +namespace DepthThreeLowerBound + +theorem cube_lt_iff_lt_hashDimension (d r : ℕ) : + r ^ 3 < d ^ 2 ↔ r < hashDimension d := by + by_cases hd : d = 0 + · subst d + simp + · have hdpos : 0 < d := Nat.pos_of_ne_zero hd + constructor + · intro h + by_contra hn + have hle : hashDimension d ≤ r := Nat.le_of_not_gt hn + have hc := Nat.le_trans (hashDimension_cube_bound d) + (Nat.pow_le_pow_left hle 3) + omega + · intro h + by_contra hn + have hc : d ^ 2 ≤ r ^ 3 := Nat.le_of_not_gt hn + have hr : 0 < r := by + by_contra hz + have he : r = 0 := by omega + have hp : 0 < d ^ 2 := Nat.pow_pos hdpos + simp only [he, Nat.zero_pow (by decide : 0 < 3)] at hc + omega + have hm := hashDimension_minimal hdpos hr hc + omega + +theorem next_sixth_le_iff_lt_independenceOrder (d k : ℕ) (hk : Even k) : + (k + 2) ^ 6 ≤ d ↔ k < independenceOrder d := by + have hnext : Even (k + 2) := by + obtain ⟨a, ha⟩ := hk + exact ⟨a + 1, by omega⟩ + constructor + · intro hp + have hm := independenceOrder_greatest hnext hp + omega + · intro hlt + have ht := independenceOrder_even d + have hle : k + 2 ≤ independenceOrder d := by + obtain ⟨a, ha⟩ := hk + obtain ⟨b, hb⟩ := ht + omega + exact Nat.le_trans (Nat.pow_le_pow_left hle 6) (independenceOrder_pow_le d) + +theorem cube_search_candidate_le_data {d r : ℕ} (h : r ≤ hashDimension d) : r ≤ d := + Nat.le_trans h (hashDimension_le d) + +theorem sixth_search_candidate_le_data {d k : ℕ} (h : k ≤ independenceOrder d) : k ≤ d := + Nat.le_trans h (independenceOrder_le d) + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/LanguageSlice.lean b/lean/OAI/Computability/DepthThree/LanguageSlice.lean new file mode 100644 index 0000000000000000000000000000000000000000..826840e4175a743417ebb05c339e1bd98ea94dc5 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/LanguageSlice.lean @@ -0,0 +1,262 @@ +import OAI.Computability.DepthThree.AlgebraLanguage +import OAI.Computability.DepthThree.Circuit +import OAI.Computability.DepthThree.InterpolationQuotient +import Mathlib.Data.List.OfFn +import Lean.Elab.Tactic.Omega + +namespace OAI + +namespace DepthThreeLowerBound + +def parameterSlice {n d r t : ℕ} + (u : Fin (d + r - 1) → Bool) (p : Fin r → Bool) + (b : Fin t → Fin r → Bool) : Fin n → Sum (Fin d) Bool := + fun i => + if hd : i.val < d then .inl ⟨i.val, hd⟩ + else if hu : i.val - d < d + r - 1 then .inr (u ⟨i.val - d, hu⟩) + else if hp : i.val - (d + (d + r - 1)) < r then + .inr (p ⟨i.val - (d + (d + r - 1)), hp⟩) + else if hb : (i.val - (d + (d + r - 1) + r)) / r < t then + if hi : (i.val - (d + (d + r - 1) + r)) % r < r then + .inr (b ⟨(i.val - (d + (d + r - 1) + r)) / r, hb⟩ + ⟨(i.val - (d + (d + r - 1) + r)) % r, hi⟩) + else .inr false + else .inr false + +theorem parameterSlice_data {n d r t : ℕ} + (u : Fin (d + r - 1) → Bool) (p : Fin r → Bool) + (b : Fin t → Fin r → Bool) (i : Fin d) (hn : i.val < n) : + parameterSlice u p b ⟨i.val, hn⟩ = Sum.inl i := by + simp [parameterSlice, i.is_lt] + +theorem parameterSlice_hash {n d r t : ℕ} + (u : Fin (d + r - 1) → Bool) (p : Fin r → Bool) + (b : Fin t → Fin r → Bool) (i : Fin (d + r - 1)) + (hn : d + i.val < n) : + parameterSlice u p b ⟨d + i.val, hn⟩ = Sum.inr (u i) := by + have hd : ¬d + i.val < d := by omega + simp [parameterSlice, hd, i.is_lt] + +theorem parameterSlice_polynomial {n d r t : ℕ} + (u : Fin (d + r - 1) → Bool) (p : Fin r → Bool) + (b : Fin t → Fin r → Bool) (i : Fin r) + (hn : d + (d + r - 1) + i.val < n) : + parameterSlice u p b ⟨d + (d + r - 1) + i.val, hn⟩ = Sum.inr (p i) := by + have hd : ¬d + (d + r - 1) + i.val < d := by omega + have hu : ¬d + (d + r - 1) + i.val - d < d + r - 1 := by omega + simp [parameterSlice, hd, hu, i.is_lt] + +theorem parameterSlice_coefficient {n d r t : ℕ} + (u : Fin (d + r - 1) → Bool) (p : Fin r → Bool) + (b : Fin t → Fin r → Bool) (j : Fin t) (i : Fin r) + (hn : d + (d + r - 1) + r + j.val * r + i.val < n) : + parameterSlice u p b + ⟨d + (d + r - 1) + r + j.val * r + i.val, hn⟩ = + Sum.inr (b j i) := by + have hr : 0 < r := Nat.zero_lt_of_lt i.is_lt + have hd : ¬d + (d + r - 1) + r + j.val * r + i.val < d := by omega + have hu : ¬d + (d + r - 1) + r + j.val * r + i.val - d < d + r - 1 := by + omega + have hp : ¬d + (d + r - 1) + r + j.val * r + i.val - + (d + (d + r - 1)) < r := by omega + have hs : d + (d + r - 1) + r + j.val * r + i.val - + (d + (d + r - 1) + r) = j.val * r + i.val := by omega + have hdiv : (j.val * r + i.val) / r = j.val := by + rw [Nat.add_comm, Nat.add_mul_div_right _ _ hr, Nat.div_eq_of_lt i.is_lt, + Nat.zero_add] + have hmod : (j.val * r + i.val) % r = i.val := by + rw [Nat.mul_add_mod_self_right, Nat.mod_eq_of_lt i.is_lt] + simp [parameterSlice, hd, hu, hp, hs, hdiv, hmod, j.is_lt, i.is_lt] + +theorem parameterSlice_suffix {n d r t : ℕ} + (u : Fin (d + r - 1) → Bool) (p : Fin r → Bool) + (b : Fin t → Fin r → Bool) (i : Fin n) + (hi : d + (d + r - 1) + r + t * r ≤ i.val) : + parameterSlice u p b i = Sum.inr false := by + have hd : ¬i.val < d := by omega + have hu : ¬i.val - d < d + r - 1 := by omega + have hp : ¬i.val - (d + (d + r - 1)) < r := by omega + by_cases hr : r = 0 + · simp only [parameterSlice, dite_eq_right hd, dite_eq_right hu, dite_eq_right hp] + simp [hr] + · have hr' : 0 < r := Nat.pos_of_ne_zero hr + have hmul : t * r ≤ i.val - (d + (d + r - 1) + r) := by omega + have hdiv : t ≤ (i.val - (d + (d + r - 1) + r)) / r := + (Nat.le_div_iff_mul_le hr').2 hmul + simp [parameterSlice, hd, hu, hp, Nat.not_lt.mpr hdiv] + +def sliceParsedInput (n : ℕ) + (u : Fin (dataDimension n + hashDimension (dataDimension n) - 1) → Bool) + (p : Fin (hashDimension (dataDimension n)) → Bool) + (b : Fin (independenceOrder (dataDimension n)) → + Fin (hashDimension (dataDimension n)) → Bool) + (x : Fin (dataDimension n) → Bool) : ParsedInput where + dataSize := dataDimension n + ringDegree := hashDimension (dataDimension n) + coefficientCount := independenceOrder (dataDimension n) + data := x + hashSeed := u + polynomial := p + coefficients := b + +def canonicalSlice (n : ℕ) + (u : Fin (dataDimension n + hashDimension (dataDimension n) - 1) → Bool) + (p : Fin (hashDimension (dataDimension n)) → Bool) + (b : Fin (independenceOrder (dataDimension n)) → + Fin (hashDimension (dataDimension n)) → Bool) : + Fin n → Sum (Fin (dataDimension n)) Bool := parameterSlice u p b + +def canonicalSliceWord (n : ℕ) + (u : Fin (dataDimension n + hashDimension (dataDimension n) - 1) → Bool) + (p : Fin (hashDimension (dataDimension n)) → Bool) + (b : Fin (independenceOrder (dataDimension n)) → + Fin (hashDimension (dataDimension n)) → Bool) + (x : Fin (dataDimension n) → Bool) : List Bool := + List.ofFn (GateInput.assignment (canonicalSlice n u p b) x) + +@[simp] theorem canonicalSliceWord_length (n : ℕ) (u p b x) : + (canonicalSliceWord n u p b x).length = n := List.length_ofFn + +theorem canonicalSlice_first (n : ℕ) (u p b) (i : Fin (dataDimension n)) : + canonicalSlice n u p b + ⟨i.val, i.is_lt.trans_le (Nat.div_le_self n 5)⟩ = Sum.inl i := + parameterSlice_data u p b i _ + +theorem canonicalSlice_unused (n : ℕ) (u p b) (i : Fin n) + (hi : blockLen (dataDimension n) ≤ i.val) : + canonicalSlice n u p b i = Sum.inr false := by + apply parameterSlice_suffix + simpa only [blockLen_eq_sum] using hi + +private theorem getD_ofFn_at {n : ℕ} (f : Fin n → Bool) (i : ℕ) (hi : i < n) : + (List.ofFn f).getD i false = f ⟨i, hi⟩ := by + simp [List.getD_eq_getElem?_getD, List.length_ofFn, hi] + +theorem canonicalSliceWord_fits (n : ℕ) (u p b x) + (hd : 0 < dataDimension n) + (ht : 2 ≤ independenceOrder (dataDimension n)) + (hlen : blockLen (dataDimension n) ≤ n) : + InputFits (canonicalSliceWord n u p b x) := by + simpa only [InputFits, canonicalSliceWord_length] using And.intro hd (And.intro ht hlen) + +theorem decodeInput_canonicalSliceWord (n : ℕ) (u p b x) + (_hd : 0 < dataDimension n) + (_ht : 2 ≤ independenceOrder (dataDimension n)) + (hlen : blockLen (dataDimension n) ≤ n) : + decodeInput (canonicalSliceWord n u p b x) = sliceParsedInput n u p b x := by + let readAtLength (m : ℕ) : ParsedInput := + { dataSize := dataDimension m + ringDegree := hashDimension (dataDimension m) + coefficientCount := independenceOrder (dataDimension m) + data := fun i => (canonicalSliceWord n u p b x).getD i.val false + hashSeed := fun i => (canonicalSliceWord n u p b x).getD + (hashOffset (dataDimension m) + i.val) false + polynomial := fun i => (canonicalSliceWord n u p b x).getD + (polynomialOffset (dataDimension m) + i.val) false + coefficients := fun j i => (canonicalSliceWord n u p b x).getD + (coefficientOffset (dataDimension m) j.val + i.val) false } + change readAtLength (canonicalSliceWord n u p b x).length = _ + rw [canonicalSliceWord_length] + dsimp only [readAtLength, sliceParsedInput] + congr 1 + · funext i + have hi : i.val < n := i.is_lt.trans_le (Nat.div_le_self n 5) + rw [canonicalSliceWord, getD_ofFn_at _ _ hi] + simp [GateInput.assignment, canonicalSlice_first] + · funext i + have hi : hashOffset (dataDimension n) + i.val < n := by + exact (Nat.add_lt_add_left i.is_lt _).trans_le + ((polynomialOffset_le_coefficientsOffset _).trans + ((coefficientsOffset_le_blockLen _).trans hlen)) + rw [canonicalSliceWord, getD_ofFn_at _ _ hi] + have hi' : dataDimension n + i.val < n := by + simpa only [hashOffset] using hi + change GateInput.assignment (parameterSlice u p b) x + ⟨dataDimension n + i.val, hi'⟩ = u i + rw [GateInput.assignment, parameterSlice_hash] + · funext i + have hi : polynomialOffset (dataDimension n) + i.val < n := by + exact (polynomial_index_lt i.is_lt).trans_le + ((coefficientsOffset_le_blockLen _).trans hlen) + rw [canonicalSliceWord, getD_ofFn_at _ _ hi] + have hi' : dataDimension n + + (dataDimension n + hashDimension (dataDimension n) - 1) + i.val < n := by + simpa only [polynomialOffset_eq] using hi + change GateInput.assignment (parameterSlice u p b) x + ⟨dataDimension n + (dataDimension n + hashDimension (dataDimension n) - 1) + + i.val, hi'⟩ = p i + rw [GateInput.assignment, parameterSlice_polynomial] + · funext j i + have hi : coefficientOffset (dataDimension n) j.val + i.val < n := by + exact (coefficient_index_lt j.is_lt i.is_lt).trans_le hlen + rw [canonicalSliceWord, getD_ofFn_at _ _ hi] + have hi' : dataDimension n + + (dataDimension n + hashDimension (dataDimension n) - 1) + + hashDimension (dataDimension n) + j.val * hashDimension (dataDimension n) + + i.val < n := by + simpa only [coefficientOffset, coefficientsOffset_eq] using hi + change GateInput.assignment (parameterSlice u p b) x + ⟨dataDimension n + (dataDimension n + hashDimension (dataDimension n) - 1) + + hashDimension (dataDimension n) + j.val * hashDimension (dataDimension n) + + i.val, hi'⟩ = b j i + rw [GateInput.assignment, parameterSlice_coefficient] + +theorem language_canonicalSliceWord (n : ℕ) (u p b x) + (hd : 0 < dataDimension n) + (ht : 2 ≤ independenceOrder (dataDimension n)) + (hlen : blockLen (dataDimension n) ≤ n) : + language (canonicalSliceWord n u p b x) = (sliceParsedInput n u p b x).evaluate := by + rw [language_of_fits (canonicalSliceWord_fits n u p b x hd ht hlen), + decodeInput_canonicalSliceWord n u p b x hd ht hlen] + +theorem language_ofFn_canonicalSlice (n : ℕ) (u p b x) + (hd : 0 < dataDimension n) + (ht : 2 ≤ independenceOrder (dataDimension n)) + (hlen : blockLen (dataDimension n) ≤ n) : + language (List.ofFn (GateInput.assignment (canonicalSlice n u p b) x)) = + (sliceParsedInput n u p b x).evaluate := + language_canonicalSliceWord n u p b x hd ht hlen + +theorem language_canonicalSlice_quotient (n : ℕ) (u p b x) + (hd : 0 < dataDimension n) + (ht : 2 ≤ independenceOrder (dataDimension n)) + (hlen : blockLen (dataDimension n) ≤ n) : + language (List.ofFn (GateInput.assignment (canonicalSlice n u p b) x)) = true ↔ + BinaryAlgebra.degreeZero (sliceParsedInput n u p b x).modulus_monic + (sliceParsedInput n u p b x).quotientEvaluation = 0 := by + rw [language_ofFn_canonicalSlice n u p b x hd ht hlen, + ParsedInput.evaluate_eq_true_iff_degreeZero] + +theorem language_canonicalSlice_acceptEval (n : ℕ) + (u : Fin (dataDimension n + hashDimension (dataDimension n) - 1) → Bool) + (p : Fin (hashDimension (dataDimension n)) → Bool) + (b : Fin (independenceOrder (dataDimension n)) → + Fin (hashDimension (dataDimension n)) → Bool) + (x : Fin (dataDimension n) → Bool) + [Fact (Irreducible (BinaryAlgebra.inputPolynomialBits p))] + (hd : 0 < dataDimension n) + (ht : 2 ≤ independenceOrder (dataDimension n)) + (hlen : blockLen (dataDimension n) ≤ n) : + language (List.ofFn (GateInput.assignment (canonicalSlice n u p b) x)) = + Interpolation.acceptEval + (BinaryAlgebra.degreeZero (BinaryAlgebra.inputPolynomialBits_monic p)) + (independenceOrder (dataDimension n)) + (fun y : Fin (dataDimension n) → Bool => + BinaryAlgebra.encode (fun i => BinaryAlgebra.bitValue (p i)) + (fun i => BinaryAlgebra.bitValue (BinaryHash.hashBool u y i))) + (fun j => BinaryAlgebra.encode (fun i => BinaryAlgebra.bitValue (p i)) + (fun i => BinaryAlgebra.bitValue (b j i))) x := by + apply Bool.eq_iff_iff.mpr + exact (language_canonicalSlice_quotient n u p b x hd ht hlen).trans + (Interpolation.acceptEval_eq_true + (BinaryAlgebra.degreeZero (BinaryAlgebra.inputPolynomialBits_monic p)) + (independenceOrder (dataDimension n)) + (fun y : Fin (dataDimension n) → Bool => + BinaryAlgebra.encode (fun i => BinaryAlgebra.bitValue (p i)) + (fun i => BinaryAlgebra.bitValue (BinaryHash.hashBool u y i))) + (fun j => BinaryAlgebra.encode (fun i => BinaryAlgebra.bitValue (p i)) + (fun i => BinaryAlgebra.bitValue (b j i))) x).symm + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/MachineBasic.lean b/lean/OAI/Computability/DepthThree/MachineBasic.lean new file mode 100644 index 0000000000000000000000000000000000000000..1eab48e585f1a87cca95197ef383c6a4bb5b9df6 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/MachineBasic.lean @@ -0,0 +1,98 @@ +import OAI.Computability.DepthThree.Model + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 uDepth7 uDepth8 uDepth9 uDepth10 uDepth11 uDepth12 + +namespace DepthThreeLowerBound + +@[simp] theorem runSteps_zero {S : Type uDepth1} (step : S → Option S) (c : Option S) : + runSteps step 0 c = c := rfl + +theorem runSteps_succ {S : Type uDepth2} (step : S → Option S) (n : ℕ) (c : Option S) : + runSteps step (n + 1) c = (runSteps step n c).bind step := by + exact Function.iterate_succ_apply' _ _ _ + +theorem runSteps_succ_left {S : Type uDepth3} (step : S → Option S) (n : ℕ) + (c : Option S) : + runSteps step (n + 1) c = runSteps step n (c.bind step) := by + exact Function.iterate_succ_apply _ _ _ + +@[simp] theorem runSteps_none {S : Type uDepth4} (step : S → Option S) (n : ℕ) : + runSteps step n none = none := by + induction n with + | zero => rfl + | succ n ih => rw [runSteps_succ, ih]; rfl + +theorem runSteps_add {S : Type uDepth5} (step : S → Option S) (m n : ℕ) (c : Option S) : + runSteps step (m + n) c = runSteps step m (runSteps step n c) := by + exact Function.iterate_add_apply _ _ _ _ + +theorem runSteps_succ_eq_of_step_eq {S : Type uDepth6} {step : S → Option S} + {a b : S} (h : step a = step b) (n : ℕ) : + runSteps step (n + 1) (some a) = runSteps step (n + 1) (some b) := by + rw [runSteps_succ_left, runSteps_succ_left] + exact congrArg (runSteps step n) h + +theorem runSteps_eq_of_step_eq {S : Type uDepth7} {step : S → Option S} + {a b : S} (h : step a = step b) {n : ℕ} (hn : 0 < n) : + runSteps step n (some a) = runSteps step n (some b) := by + cases n with + | zero => exact False.elim ((Nat.not_lt_zero 0) hn) + | succ n => exact runSteps_succ_eq_of_step_eq h n + +def RunsIn {S : Type uDepth8} (step : S → Option S) (a b : S) (bound : ℕ) : Prop := + ∃ n ≤ bound, runSteps step n (some a) = some b + +theorem RunsIn.refl {S : Type uDepth9} (step : S → Option S) (a : S) : + RunsIn step a a 0 := + ⟨0, le_refl 0, rfl⟩ + +theorem RunsIn.single {S : Type uDepth10} {step : S → Option S} {a b : S} + (h : step a = some b) : RunsIn step a b 1 := + ⟨1, le_refl 1, h⟩ + +theorem RunsIn.mono {S : Type uDepth11} {step : S → Option S} {a b : S} {m n : ℕ} + (h : RunsIn step a b m) (hmn : m ≤ n) : RunsIn step a b n := by + obtain ⟨k, hk, he⟩ := h + exact ⟨k, hk.trans hmn, he⟩ + +theorem RunsIn.trans {S : Type uDepth12} {step : S → Option S} {a b c : S} {m n : ℕ} + (h₁ : RunsIn step a b m) (h₂ : RunsIn step b c n) : + RunsIn step a c (m + n) := by + obtain ⟨k₁, hk₁, he₁⟩ := h₁ + obtain ⟨k₂, hk₂, he₂⟩ := h₂ + refine ⟨k₂ + k₁, ?_, ?_⟩ + · simpa only [Nat.add_comm] using Nat.add_le_add hk₂ hk₁ + · rw [runSteps_add, he₁] + exact he₂ + +structure FiniteMachine where + Γ : Type + [alphabetInhabited : Inhabited Γ] + [alphabetFinite : Fintype Γ] + Λ : Type + [stateInhabited : Inhabited Λ] + [stateFinite : Fintype Λ] + inputSymbol : Bool → Γ + input_injective : Function.Injective inputSymbol + input_ne_blank : ∀ b, inputSymbol b ≠ default + code : Turing.TM0.Machine Γ Λ + accept : Λ → Bool + +attribute [instance] FiniteMachine.alphabetInhabited FiniteMachine.alphabetFinite + FiniteMachine.stateInhabited FiniteMachine.stateFinite + +def HaltsIn (M : FiniteMachine) (input : List Bool) (output : Bool) (time : ℕ) : Prop := + ∃ k ≤ time, ∃ c : Turing.TM0.Cfg M.Γ M.Λ, + runSteps (Turing.TM0.step M.code) k + (some (Turing.TM0.init (input.map M.inputSymbol))) = some c ∧ + Turing.TM0.step M.code c = none ∧ M.accept c.q = output + +def PolynomialTimeDecider (f : List Bool → Bool) : Prop := + ∃ M : FiniteMachine, ∃ C a : ℕ, 0 < C ∧ 0 < a ∧ + ∀ w, HaltsIn M w (f w) (C * (w.length + 1) ^ a) + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/MachineCompilation.lean b/lean/OAI/Computability/DepthThree/MachineCompilation.lean new file mode 100644 index 0000000000000000000000000000000000000000..acbe6b1fdc9c8ec2941ac49fa238c18d4f361c10 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/MachineCompilation.lean @@ -0,0 +1,248 @@ +import OAI.Computability.DepthThree.MachineBasic +import OAI.Computability.DepthThree.MachineFiniteRestriction +import Mathlib.Data.Finset.Lattice.Fold + +namespace OAI + +namespace DepthThreeLowerBound +namespace MachineCompilation + +open Turing + +variable {Γ Λ σ : Type} + +def stmtCost : TM1.Stmt Γ Λ σ → ℕ + | .move _ q => stmtCost q + 1 + | .write _ q => stmtCost q + 1 + | .load _ q => stmtCost q + | .branch _ q₁ q₂ => max (stmtCost q₁) (stmtCost q₂) + | .goto _ => 1 + | .halt => 1 + +theorem stmtCost_pos (q : TM1.Stmt Γ Λ σ) : 0 < stmtCost q := by + induction q with + | move _ q ih => exact Nat.zero_lt_succ _ + | write _ q ih => exact Nat.zero_lt_succ _ + | load _ q ih => exact ih + | branch _ q₁ q₂ ih₁ ih₂ => exact ih₁.trans_le (le_max_left _ _) + | goto _ => exact Nat.zero_lt_one + | halt => exact Nat.zero_lt_one + +variable [instInhabitedΓ : Inhabited Γ] [instInhabitedΛ : Inhabited Λ] [instInhabitedσ : Inhabited σ] +variable (M : Λ → TM1.Stmt Γ Λ σ) + +def subCfg (q : TM1.Stmt Γ Λ σ) (v : σ) (tape : Tape Γ) : + TM0.Cfg Γ (TM1to0.Λ' M) := + ⟨(some q, v), tape⟩ + +theorem stepAux_counted (q : TM1.Stmt Γ Λ σ) (v : σ) (tape : Tape Γ) : + ∃ k, 0 < k ∧ k ≤ stmtCost q ∧ + runSteps (TM0.step (TM1to0.tr M)) k (some (subCfg M q v tape)) = + some (TM1to0.trCfg M (TM1.stepAux q v tape)) := by + induction q generalizing v tape with + | move d q ih => + obtain ⟨k, hk, hcost, hrun⟩ := ih v (tape.move d) + refine ⟨k + 1, Nat.succ_pos k, Nat.add_le_add_right hcost 1, ?_⟩ + rw [runSteps_succ_left] + exact hrun + | write a q ih => + obtain ⟨k, hk, hcost, hrun⟩ := ih v (tape.write (a tape.1 v)) + refine ⟨k + 1, Nat.succ_pos k, Nat.add_le_add_right hcost 1, ?_⟩ + rw [runSteps_succ_left] + exact hrun + | load a q ih => + obtain ⟨k, hk, hcost, hrun⟩ := ih (a tape.1 v) tape + refine ⟨k, hk, hcost, ?_⟩ + have hstep : + TM0.step (TM1to0.tr M) (subCfg M (.load a q) v tape) = + TM0.step (TM1to0.tr M) (subCfg M q (a tape.1 v) tape) := rfl + exact (runSteps_eq_of_step_eq hstep hk).trans hrun + | branch p q₁ q₂ ih₁ ih₂ => + cases hp : p tape.1 v with + | false => + obtain ⟨k, hk, hcost, hrun⟩ := ih₂ v tape + refine ⟨k, hk, hcost.trans (le_max_right _ _), ?_⟩ + have hstep : + TM0.step (TM1to0.tr M) (subCfg M (.branch p q₁ q₂) v tape) = + TM0.step (TM1to0.tr M) (subCfg M q₂ v tape) := by + simp only [subCfg, TM0.step, TM1to0.tr, TM1to0.trAux, hp, Bool.cond_false] + have hout : TM1.stepAux (.branch p q₁ q₂) v tape = + TM1.stepAux q₂ v tape := by + simp only [TM1.stepAux, hp, Bool.cond_false] + rw [hout] + exact (runSteps_eq_of_step_eq hstep hk).trans hrun + | true => + obtain ⟨k, hk, hcost, hrun⟩ := ih₁ v tape + refine ⟨k, hk, hcost.trans (le_max_left _ _), ?_⟩ + have hstep : + TM0.step (TM1to0.tr M) (subCfg M (.branch p q₁ q₂) v tape) = + TM0.step (TM1to0.tr M) (subCfg M q₁ v tape) := by + simp only [subCfg, TM0.step, TM1to0.tr, TM1to0.trAux, hp, Bool.cond_true] + have hout : TM1.stepAux (.branch p q₁ q₂) v tape = + TM1.stepAux q₁ v tape := by + simp only [TM1.stepAux, hp, Bool.cond_true] + rw [hout] + exact (runSteps_eq_of_step_eq hstep hk).trans hrun + | goto l => + refine ⟨1, Nat.zero_lt_one, le_refl 1, ?_⟩ + change some (TM0.Cfg.mk _ (tape.write tape.1)) = some (TM0.Cfg.mk _ tape) + rw [Tape.write_self] + rfl + | halt => + refine ⟨1, Nat.zero_lt_one, le_refl 1, ?_⟩ + change some (TM0.Cfg.mk _ (tape.write tape.1)) = some (TM0.Cfg.mk _ tape) + rw [Tape.write_self] + rfl + +variable [instFintypeΛ : Fintype Λ] + +def programCost : ℕ := + Finset.univ.sup (fun l => stmtCost (M l)) + +theorem stmtCost_le_programCost + {Γ : Type} + {Λ : Type} + {σ : Type} + [Inhabited Γ] + [Inhabited Λ] + [Inhabited σ] + (M : Λ → Turing.TM1.Stmt Γ Λ σ) + [instFintypeΛ : Fintype Λ] + (l : Λ) : stmtCost (M l) ≤ programCost M := + Finset.le_sup (f := fun l => stmtCost (M l)) (Finset.mem_univ l) + +theorem programCost_pos : 0 < programCost M := + (stmtCost_pos (M default)).trans_le (stmtCost_le_programCost M default) + +theorem step_counted {c c' : TM1.Cfg Γ Λ σ} (h : TM1.step M c = some c') : + RunsIn (TM0.step (TM1to0.tr M)) (TM1to0.trCfg M c) (TM1to0.trCfg M c') + (programCost M) := by + rcases c with ⟨l, v, tape⟩ + cases l with + | none => cases h + | some l => + have hc : TM1.stepAux (M l) v tape = c' := Option.some.inj h + subst c' + obtain ⟨k, hk, hcost, hrun⟩ := stepAux_counted M (M l) v tape + exact ⟨k, hcost.trans (stmtCost_le_programCost M l), hrun⟩ + +theorem run_counted (n : ℕ) {c c' : TM1.Cfg Γ Λ σ} + (h : runSteps (TM1.step M) n (some c) = some c') : + RunsIn (TM0.step (TM1to0.tr M)) (TM1to0.trCfg M c) (TM1to0.trCfg M c') + (programCost M * n) := by + induction n generalizing c with + | zero => + have hc : c = c' := Option.some.inj h + subst c' + simpa only [Nat.mul_zero] using RunsIn.refl (TM0.step (TM1to0.tr M)) + (TM1to0.trCfg M c) + | succ n ih => + rw [runSteps_succ_left] at h + cases hstep : TM1.step M c with + | none => + rw [Option.bind_some, hstep, runSteps_none] at h + cases h + | some d => + have hrest : runSteps (TM1.step M) n (some d) = some c' := by + simpa only [Option.bind_some, hstep] using h + simpa only [Nat.mul_succ, Nat.add_comm] using + (step_counted M hstep).trans (ih hrest) + +theorem runsIn_counted {c c' : TM1.Cfg Γ Λ σ} {bound : ℕ} + (h : RunsIn (TM1.step M) c c' bound) : + RunsIn (TM0.step (TM1to0.tr M)) (TM1to0.trCfg M c) (TM1to0.trCfg M c') + (programCost M * bound) := by + obtain ⟨n, hn, hrun⟩ := h + exact (run_counted M n hrun).mono (Nat.mul_le_mul_left _ hn) + +theorem compiled_halt + {Γ : Type} + {Λ : Type} + {σ : Type} + [instInhabitedΓ : Inhabited Γ] + [instInhabitedΛ : Inhabited Λ] + [instInhabitedσ : Inhabited σ] + (M : Λ → Turing.TM1.Stmt Γ Λ σ) + [Fintype Λ] + {c : TM1.Cfg Γ Λ σ} (h : TM1.step M c = none) : + TM0.step (TM1to0.tr M) (TM1to0.trCfg M c) = none := by + rcases c with ⟨l, v, tape⟩ + cases l with + | none => rfl + | some l => cases h + +theorem compiled_init + {Γ : Type} + {Λ : Type} + {σ : Type} + [instInhabitedΓ : Inhabited Γ] + [instInhabitedΛ : Inhabited Λ] + [instInhabitedσ : Inhabited σ] + (M : Λ → Turing.TM1.Stmt Γ Λ σ) + [Fintype Λ] + (input : List Γ) : + TM1to0.trCfg M (TM1.init input) = TM0.init input := rfl + +theorem source_supports + {Γ : Type} + {Λ : Type} + {σ : Type} + [Inhabited Γ] + [instInhabitedΛ : Inhabited Λ] + [Inhabited σ] + (M : Λ → Turing.TM1.Stmt Γ Λ σ) + [instFintypeΛ : Fintype Λ] : TM1.Supports M Finset.univ := by + classical + refine ⟨Finset.mem_univ _, ?_⟩ + intro l hl + induction M l with + | move _ _ ih => exact ih + | write _ _ ih => exact ih + | load _ _ ih => exact ih + | branch _ _ _ ih₁ ih₂ => exact ⟨ih₁, ih₂⟩ + | goto _ => exact fun _ _ => Finset.mem_univ _ + | halt => trivial + +variable [Fintype Γ] [Fintype σ] +variable (inputSymbol : Bool → Γ) (hinj : Function.Injective inputSymbol) +variable (hblank : ∀ b, inputSymbol b ≠ default) (accept : σ → Bool) + +noncomputable def compileFinite : FiniteMachine := + MachineFiniteRestriction.toFiniteMachine (TM1to0.tr M) + (TM1to0.trStmts M Finset.univ) (TM1to0.tr_supports M (source_supports M)) + inputSymbol hinj hblank (fun q => accept q.2) + +theorem compileFinite_haltsIn (w : List Bool) (output : Bool) (time : ℕ) + (c : TM1.Cfg Γ Λ σ) + (hrun : RunsIn (TM1.step M) (TM1.init (w.map inputSymbol)) c time) + (hhalt : TM1.step M c = none) (haccept : accept c.var = output) : + HaltsIn (compileFinite M inputSymbol hinj hblank accept) w output + (programCost M * time) := by + apply (MachineFiniteRestriction.toFiniteMachine_haltsIn_iff (TM1to0.tr M) + (TM1to0.trStmts M Finset.univ) (TM1to0.tr_supports M (source_supports M)) + inputSymbol hinj hblank (fun q => accept q.2) w output (programCost M * time)).2 + obtain ⟨k, hk, hcompiled⟩ := runsIn_counted M hrun + refine ⟨k, hk, TM1to0.trCfg M c, ?_, compiled_halt M hhalt, haccept⟩ + simpa only [compiled_init] using hcompiled + +include hinj hblank in + +theorem polynomialTimeDecider_of_counted_TM1 (f : List Bool → Bool) + (C a : ℕ) (hC : 0 < C) (ha : 0 < a) + (hprogram : ∀ w, ∃ c : TM1.Cfg Γ Λ σ, + RunsIn (TM1.step M) (TM1.init (w.map inputSymbol)) c + (C * (w.length + 1) ^ a) ∧ + TM1.step M c = none ∧ accept c.var = f w) : + PolynomialTimeDecider f := by + refine ⟨compileFinite M inputSymbol hinj hblank accept, + programCost M * C, a, Nat.mul_pos (programCost_pos M) hC, ha, ?_⟩ + intro w + obtain ⟨c, hrun, hhalt, haccept⟩ := hprogram w + simpa only [Nat.mul_assoc] using + compileFinite_haltsIn M inputSymbol hinj hblank accept w (f w) + (C * (w.length + 1) ^ a) c hrun hhalt haccept + +end MachineCompilation +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/MachineFiniteRestriction.lean b/lean/OAI/Computability/DepthThree/MachineFiniteRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..e950f59c8f530e93d3a56d10700c4495c8d27c32 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/MachineFiniteRestriction.lean @@ -0,0 +1,265 @@ +import OAI.Computability.DepthThree.MachineBasic +import Mathlib.Data.Fintype.Sets + +namespace OAI + +namespace DepthThreeLowerBound +namespace MachineFiniteRestriction + +open Turing + +variable {Γ Λ : Type} [instInhabitedΓ : Inhabited Γ] [Inhabited Λ] + +def Label (M : TM0.Machine Γ Λ) (S : Finset Λ) + (_hs : TM0.Supports M (S : Set Λ)) := + {q : Λ // q ∈ S} + +variable (M : TM0.Machine Γ Λ) (S : Finset Λ) +variable (hs : TM0.Supports M (S : Set Λ)) + +instance labelInhabited : Inhabited (Label M S hs) := + ⟨⟨default, hs.1⟩⟩ + +instance labelFintype : Fintype (Label M S hs) := + inferInstanceAs (Fintype {q : Λ // q ∈ S}) + +noncomputable def retract (q : Λ) : Label M S hs := by + classical + exact if hq : q ∈ S then ⟨q, hq⟩ else default + +theorem retract_val + {Γ : Type} + {Λ : Type} + [Inhabited Γ] + [Inhabited Λ] + (M : Turing.TM0.Machine Γ Λ) + (S : Finset Λ) + (hs : Turing.TM0.Supports M ↑S) + (q : Λ) (hq : q ∈ S) : + (retract M S hs q).val = q := by + classical + have hr : retract M S hs q = (⟨q, hq⟩ : Label M S hs) := by + unfold retract + exact dite_eq_left hq + exact congrArg Subtype.val hr + +@[simp] theorem retract_default : + retract M S hs default = (default : Label M S hs) := by + apply Subtype.ext + exact retract_val M S hs default hs.1 + +private def idAlphabet : PointedMap Γ Γ := ⟨id, rfl⟩ + +private theorem listBlank_map_id (l : ListBlank Γ) : + l.map (idAlphabet (Γ := Γ)) = l := by + apply ListBlank.ext + intro n + rw [ListBlank.nth_map] + rfl + +private theorem tape_map_id (t : Tape Γ) : + t.map (idAlphabet (Γ := Γ)) = t := by + cases t with + | mk a l r => + change Tape.mk a (l.map (idAlphabet (Γ := Γ))) (r.map (idAlphabet (Γ := Γ))) = + Tape.mk a l r + rw [listBlank_map_id, listBlank_map_id] + +noncomputable def restrict : TM0.Machine Γ (Label M S hs) := + M.map idAlphabet idAlphabet (retract M S hs) Subtype.val + +noncomputable def restrictCfg (c : TM0.Cfg Γ Λ) : TM0.Cfg Γ (Label M S hs) := + ⟨retract M S hs c.q, c.Tape⟩ + +def includeCfg (c : TM0.Cfg Γ (Label M S hs)) : TM0.Cfg Γ Λ := + ⟨c.q.val, c.Tape⟩ + +theorem include_restrict (c : TM0.Cfg Γ Λ) (hc : c.q ∈ S) : + includeCfg M S hs (restrictCfg M S hs c) = c := by + cases c with + | mk q t => + exact congrArg (fun q => TM0.Cfg.mk q t) (retract_val M S hs q hc) + +@[simp] theorem restrict_include (c : TM0.Cfg Γ (Label M S hs)) : + restrictCfg M S hs (includeCfg M S hs c) = c := by + cases c with + | mk q t => + have hq : retract M S hs q.val = q := + Subtype.ext (retract_val M S hs q.val q.property) + exact congrArg (fun q => TM0.Cfg.mk q t) hq + +theorem includeCfg_injective : Function.Injective (includeCfg M S hs) := by + intro a b h + have h' := congrArg (restrictCfg M S hs) h + simpa only [restrict_include] using h' + +private theorem cfg_map_eq (c : TM0.Cfg Γ Λ) : + TM0.Cfg.map idAlphabet (retract M S hs) c = restrictCfg M S hs c := by + cases c with + | mk q t => + change TM0.Cfg.mk (retract M S hs q) (t.map idAlphabet) = + TM0.Cfg.mk (retract M S hs q) t + rw [tape_map_id] + +theorem restrict_step (c : TM0.Cfg Γ Λ) (hc : c.q ∈ S) : + (TM0.step M c).map (restrictCfg M S hs) = + TM0.step (restrict M S hs) (restrictCfg M S hs c) := by + have h := M.map_step idAlphabet idAlphabet (retract M S hs) Subtype.val + (S := (S : Set Λ)) (by intro a; rfl) + (fun q hq => retract_val M S hs q hq) c hc + have hm : TM0.Cfg.map idAlphabet (retract M S hs) = restrictCfg M S hs := + funext (cfg_map_eq M S hs) + rw [hm] at h + exact h + +theorem include_step (c : TM0.Cfg Γ (Label M S hs)) : + (TM0.step (restrict M S hs) c).map (includeCfg M S hs) = + TM0.step M (includeCfg M S hs c) := by + have h := restrict_step M S hs (includeCfg M S hs c) c.q.property + rw [restrict_include] at h + rw [← h] + cases he : TM0.step M (includeCfg M S hs c) with + | none => rfl + | some d => + have hd : d.q ∈ S := TM0.step_supports M hs he c.q.property + exact congrArg some (include_restrict M S hs d hd) + +@[simp] theorem restrict_init (l : List Γ) : + restrictCfg M S hs (TM0.init l) = TM0.init l := by + exact congrArg (fun q => TM0.Cfg.mk q (Tape.mk₁ l)) (retract_default M S hs) + +@[simp] theorem include_init (l : List Γ) : + includeCfg M S hs (TM0.init l) = TM0.init l := rfl + +theorem include_runSteps (n : ℕ) (c : Option (TM0.Cfg Γ (Label M S hs))) : + (runSteps (TM0.step (restrict M S hs)) n c).map (includeCfg M S hs) = + runSteps (TM0.step M) n (c.map (includeCfg M S hs)) := by + induction n with + | zero => rfl + | succ n ih => + rw [runSteps_succ, runSteps_succ, ← ih] + cases runSteps (TM0.step (restrict M S hs)) n c with + | none => rfl + | some d => exact include_step M S hs d + +theorem restrict_runSteps (n : ℕ) (c : TM0.Cfg Γ Λ) (hc : c.q ∈ S) : + (runSteps (TM0.step M) n (some c)).map (restrictCfg M S hs) = + runSteps (TM0.step (restrict M S hs)) n (some (restrictCfg M S hs c)) := by + induction n generalizing c with + | zero => rfl + | succ n ih => + rw [runSteps_succ_left, runSteps_succ_left] + change (runSteps (TM0.step M) n (TM0.step M c)).map (restrictCfg M S hs) = + runSteps (TM0.step (restrict M S hs)) n + (TM0.step (restrict M S hs) (restrictCfg M S hs c)) + rw [← restrict_step M S hs c hc] + cases he : TM0.step M c with + | none => simp only [Option.map_none, runSteps_none] + | some d => exact ih d (TM0.step_supports M hs he hc) + +include hs in + +theorem runSteps_supports (n : ℕ) (c : TM0.Cfg Γ Λ) (hc : c.q ∈ S) + {d : TM0.Cfg Γ Λ} (hrun : runSteps (TM0.step M) n (some c) = some d) : + d.q ∈ S := by + induction n generalizing c with + | zero => + have hcd : c = d := Option.some.inj hrun + cases hcd + exact hc + | succ n ih => + rw [runSteps_succ_left] at hrun + change runSteps (TM0.step M) n (TM0.step M c) = some d at hrun + cases he : TM0.step M c with + | none => + rw [he, runSteps_none] at hrun + cases hrun + | some e => + rw [he] at hrun + exact ih e (TM0.step_supports M hs he hc) hrun + +theorem restrict_runsIn {a b : TM0.Cfg Γ Λ} {bound : ℕ} (ha : a.q ∈ S) + (h : RunsIn (TM0.step M) a b bound) : + RunsIn (TM0.step (restrict M S hs)) + (restrictCfg M S hs a) (restrictCfg M S hs b) bound := by + obtain ⟨n, hn, he⟩ := h + refine ⟨n, hn, ?_⟩ + rw [← restrict_runSteps M S hs n a ha, he] + rfl + +theorem include_runsIn_iff (a b : TM0.Cfg Γ (Label M S hs)) (bound : ℕ) : + RunsIn (TM0.step M) (includeCfg M S hs a) (includeCfg M S hs b) bound ↔ + RunsIn (TM0.step (restrict M S hs)) a b bound := by + constructor + · rintro ⟨n, hn, he⟩ + refine ⟨n, hn, ?_⟩ + apply Option.map_injective (includeCfg_injective M S hs) + rw [include_runSteps] + exact he + · rintro ⟨n, hn, he⟩ + refine ⟨n, hn, ?_⟩ + have h := congrArg (Option.map (includeCfg M S hs)) he + rw [include_runSteps] at h + exact h + +theorem restrict_halt_iff (c : TM0.Cfg Γ Λ) (hc : c.q ∈ S) : + TM0.step (restrict M S hs) (restrictCfg M S hs c) = none ↔ + TM0.step M c = none := by + rw [← restrict_step M S hs c hc] + cases TM0.step M c <;> simp + +theorem include_halt_iff (c : TM0.Cfg Γ (Label M S hs)) : + TM0.step M (includeCfg M S hs c) = none ↔ + TM0.step (restrict M S hs) c = none := by + rw [← include_step M S hs c] + cases TM0.step (restrict M S hs) c <;> simp + +variable [Fintype Γ] +variable (inputSymbol : Bool → Γ) (hinj : Function.Injective inputSymbol) +variable (hblank : ∀ b, inputSymbol b ≠ default) (accept : Λ → Bool) + +noncomputable def toFiniteMachine : FiniteMachine where + Γ := Γ + alphabetInhabited := inferInstance + alphabetFinite := inferInstance + Λ := Label M S hs + stateInhabited := labelInhabited M S hs + stateFinite := labelFintype M S hs + inputSymbol := inputSymbol + input_injective := hinj + input_ne_blank := hblank + code := restrict M S hs + accept := fun q => accept q.val + +theorem toFiniteMachine_haltsIn_iff (w : List Bool) (output : Bool) (time : ℕ) : + HaltsIn (toFiniteMachine M S hs inputSymbol hinj hblank accept) w output time ↔ + ∃ k ≤ time, ∃ c : TM0.Cfg Γ Λ, + runSteps (TM0.step M) k (some (TM0.init (w.map inputSymbol))) = some c ∧ + TM0.step M c = none ∧ accept c.q = output := by + dsimp only [HaltsIn, toFiniteMachine] + constructor + · rintro ⟨k, hk, c, hrun, hhalt, haccept⟩ + refine ⟨k, hk, includeCfg M S hs c, ?_, ?_, haccept⟩ + · have h := congrArg (Option.map (includeCfg M S hs)) hrun + change (runSteps (TM0.step (restrict M S hs)) k + (some (TM0.init (w.map inputSymbol)))).map (includeCfg M S hs) = + some (includeCfg M S hs c) at h + rw [include_runSteps] at h + simpa only [Option.map_some, include_init] using h + · exact (include_halt_iff M S hs c).2 hhalt + · rintro ⟨k, hk, c, hrun, hhalt, haccept⟩ + have hc : c.q ∈ S := + runSteps_supports M S hs k (TM0.init (w.map inputSymbol)) hs.1 hrun + refine ⟨k, hk, restrictCfg M S hs c, ?_, ?_, ?_⟩ + · have h := restrict_runSteps M S hs k (TM0.init (w.map inputSymbol)) hs.1 + rw [hrun, Option.map_some, restrict_init] at h + exact h.symm + · exact (restrict_halt_iff M S hs c hc).2 hhalt + · change accept (retract M S hs c.q).val = output + rw [retract_val M S hs c.q hc] + exact haccept + +end MachineFiniteRestriction +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/MachineLanguage.lean b/lean/OAI/Computability/DepthThree/MachineLanguage.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b2ff508213eb9e41650fc39ed788a98ca000344 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/MachineLanguage.lean @@ -0,0 +1,131 @@ +import OAI.Computability.DepthThree.TapeDecodeParsed +import OAI.Computability.DepthThree.TapeEvaluation +import OAI.Computability.DepthThree.TapeBranch + +namespace OAI + +namespace DepthThreeLowerBound +namespace MachineLanguage + +open TapeMultiProgram TapeRouting TapeRegister + +theorem decoded_prepared (w : List Bool) : + TapeEvaluation.Prepared (TapeDecodeParsed.outputStore w) w := by + constructor + · constructor + · exact TapeDecodeParsed.outputStore_hash w + all_goals apply TapeDecodeParsed.outputStore_empty <;> decide + · constructor + all_goals apply TapeDecodeParsed.outputStore_empty <;> decide + · exact TapeDecodeParsed.outputStore_data w + · exact TapeDecodeParsed.outputStore_order w + · exact TapeDecodeParsed.outputStore_block w .data + · exact TapeDecodeParsed.outputStore_block w .hash + · exact TapeDecodeParsed.outputStore_block w .polynomial + · exact TapeDecodeParsed.outputStore_block w .coefficients + · apply TapeDecodeParsed.outputStore_empty <;> decide + +abbrev BodyState := TapeDecodeBlocks.State ⊕ TapeEvaluation.State + +def bodyProgram : TapeMultiProgram BodyState := + joinCode TapeDecodeBlocks.program TapeEvaluation.program (fun _ => TapeEvaluation.start) + +def bodyStart : BodyState := .inl TapeDecodeBlocks.start +def bodyDone (answer : Bool) : BodyState := .inr (TapeEvaluation.done answer) + +@[simp] theorem bodyProgram_done (answer : Bool) (h : TapeHeads) : + bodyProgram (bodyDone answer) h = none := rfl + +theorem runs_body (w : List Bool) (hfit : InputFits w) : + RunsIn bodyProgram.step (cfg bodyStart (storeTapes (TapeParse.outputStore w))) + (cfg (bodyDone (language w)) (storeTapes + (TapeEvaluation.outputStore (TapeDecodeParsed.outputStore w) w))) + (21000 * (w.length + 1) ^ 4) := by + have hd := TapeDecodeParsed.runs_decode w hfit + have he := TapeEvaluation.runs_evaluate w (TapeDecodeParsed.outputStore w) + hfit (decoded_prepared w) + have hall := join_runs TapeDecodeBlocks.program TapeEvaluation.program + (fun _ => TapeEvaluation.start) hd (by simp) he + apply hall.mono + have h24 : (w.length + 1) ^ 2 ≤ (w.length + 1) ^ 4 := + Nat.pow_le_pow_right (Nat.succ_pos _) (by decide) + have hpos : 1 ≤ (w.length + 1) ^ 4 := Nat.pow_pos (Nat.succ_pos _) + omega + +abbrev State := TapeBranch.State TapeParse.State BodyState + +def program : TapeMultiProgram State := + TapeBranch.program TapeParse.program bodyProgram bodyStart TapeParse.acceptFlag + +def start : State := TapeBranch.test TapeParse.start + +def acceptFlag : State → Bool + | .inr (.inl (.inr q)) => TapeEvaluation.acceptFlag q + | _ => false + +private instance stateFintype : Fintype State := by + letI : Fintype TapeParse.State := inferInstance + letI : Fintype TapeDecodeBlocks.State := inferInstance + letI : Fintype TapeHornerMultiply.WorkState := inferInstance + letI : Fintype TapeHorner.State := inferInstance + infer_instance + +def machine : FiniteMultiTapeMachine := TapeMultiProgram.machine program start acceptFlag + +@[simp] theorem machine_init (w : List Bool) : + machine.init w = cfg start (rawInputTapes w) := rfl + +theorem halts (w : List Bool) : + MultiTapeHaltsIn machine w (language w) (24000 * (w.length + 3) ^ 8) := by + apply (multiTapeHaltsIn_iff_runsIn machine w (language w) _).2 + have hp := TapeParse.runs_parse w + have hpos : 1 ≤ (w.length + 3) ^ 8 := Nat.pow_pos (by omega) + by_cases hfit : InputFits w + · have hflag : decide (InputFits w) = true := by simp [hfit] + rw [hflag] at hp + have hb := runs_body w hfit + have hall := TapeBranch.runs_accept TapeParse.program bodyProgram bodyStart + TapeParse.acceptFlag hp (by simp) (by simp) hb + refine ⟨cfg (TapeBranch.body (bodyDone (language w))) + (storeTapes (TapeEvaluation.outputStore (TapeDecodeParsed.outputStore w) w)), + hall.mono ?_, ?_, ?_⟩ + · have h48 : (w.length + 1) ^ 4 ≤ (w.length + 3) ^ 8 := + Nat.le_trans (Nat.pow_le_pow_left (by omega : w.length + 1 ≤ w.length + 3) 4) + (Nat.pow_le_pow_right (by omega : 0 < w.length + 3) (by decide : 4 ≤ 8)) + omega + · apply (multiTapeStep_eq_none_iff program _).2 + exact TapeBranch.body_halts _ _ _ _ _ _ (by simp) + · change acceptFlag (TapeBranch.body (bodyDone (language w))) = language w + simp [acceptFlag, TapeBranch.body, bodyDone] + · have hflag : decide (InputFits w) = false := by simp [hfit] + rw [hflag] at hp + have hall := TapeBranch.runs_reject TapeParse.program bodyProgram bodyStart + TapeParse.acceptFlag hp (by simp) (by simp) + refine ⟨cfg TapeBranch.rejected (storeTapes (TapeParse.outputStore w)), + hall.mono ?_, ?_, ?_⟩ + · omega + · apply (multiTapeStep_eq_none_iff program _).2 + exact TapeBranch.rejected_halts _ _ _ _ _ + · change false = language w + exact (language_of_not_fits hfit).symm + +theorem cost_le_standard (n : ℕ) : + 24000 * (n + 3) ^ 8 ≤ (24000 * 3 ^ 8) * (n + 1) ^ 8 := by + calc + 24000 * (n + 3) ^ 8 ≤ 24000 * (3 * (n + 1)) ^ 8 := + Nat.mul_le_mul_left _ (Nat.pow_le_pow_left (by omega) 8) + _ = _ := by rw [mul_pow]; ring + +theorem polynomial_time : MultiTapePolynomialTimeDecider language := by + refine ⟨machine, 24000 * 3 ^ 8, 8, by decide, by decide, ?_⟩ + intro w + exact (halts w).mono (cost_le_standard w.length) + +end MachineLanguage + +theorem language_polynomial_time : MultiTapePolynomialTimeDecider language := + MachineLanguage.polynomial_time + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/Main.lean b/lean/OAI/Computability/DepthThree/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..6878be2842d3013ef26cac2936143972782aa6dc --- /dev/null +++ b/lean/OAI/Computability/DepthThree/Main.lean @@ -0,0 +1,20 @@ +import OAI.Computability.DepthThree.MachineLanguage +import OAI.Computability.DepthThree.LanguageLowerBound + +namespace OAI + +namespace DepthThreeLowerBound + +theorem exists_polynomial_time_language_depth_three_lower_bound : + ∃ (L : List Bool → Bool) (M : FiniteMultiTapeMachine) (C a : ℕ), + 0 < C ∧ 0 < a ∧ + (∀ w : List Bool, MultiTapeHaltsIn M w (L w) (C * (w.length + 1) ^ a)) ∧ + ∀ A : ℝ, 0 < A → ∃ N : ℕ, ∀ n : ℕ, N ≤ n → + ∀ D : Circuit3 (Fin n), D.Computes (fun x => L (List.ofFn x)) → + (2 : ℝ) ^ (A * Real.sqrt (n : ℝ)) < (D.gateCount : ℝ) := by + obtain ⟨M, C, a, hC, ha, hM⟩ := language_polynomial_time + exact ⟨language, M, C, a, hC, ha, hM, language_depth_three_gate_lower_bound⟩ + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/MarkerMixture.lean b/lean/OAI/Computability/DepthThree/MarkerMixture.lean new file mode 100644 index 0000000000000000000000000000000000000000..bfacbb8be45657529c6c1db74115637e77d4d496 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/MarkerMixture.lean @@ -0,0 +1,167 @@ +import OAI.Computability.DepthThree.MarkerPermutation +import OAI.Computability.DepthThree.FiniteProbability +import OAI.Computability.DepthThree.Core +import Mathlib.Data.Fintype.Sum +import Mathlib.Data.Bool.Basic +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Convert + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open scoped BigOperators + +namespace DepthThreeLowerBound + +universe u v + +variable {I : Type u} [Fintype I] [instDecidableEqI : DecidableEq I] {A : Type v} + +def markerSelected (c : ℕ) (π : Equiv.Perm (I ⊕ Fin c)) : Finset I := + Finset.univ.filter fun i => + ∀ m : Fin c, permutationRank π (Sum.inl i) < permutationRank π (Sum.inr m) + +@[simp] theorem mem_markerSelected + {I : Type u} + [Fintype I] + [DecidableEq I] + (c : ℕ) (π : Equiv.Perm (I ⊕ Fin c)) (i : I) : + i ∈ markerSelected c π ↔ + ∀ m : Fin c, permutationRank π (Sum.inl i) < permutationRank π (Sum.inr m) := by + simp [markerSelected] + +def markerSample (C : I → A → Bool) (c : ℕ) (π : Equiv.Perm (I ⊕ Fin c)) + (x : A) : Bool := + decide (∀ i ∈ markerSelected c π, C i x = true) + +@[simp] theorem markerSample_eq_true (C : I → A → Bool) (c : ℕ) + (π : Equiv.Perm (I ⊕ Fin c)) (x : A) : + markerSample C c π x = true ↔ ∀ i ∈ markerSelected c π, C i x = true := by + simp [markerSample] + +def markerBad (C : I → A → Bool) (x : A) : Finset I := + Finset.univ.filter fun i => C i x = false + +def markerActive (C : I → A → Bool) (x : A) (c : ℕ) : Finset (I ⊕ Fin c) := + (markerBad C x).disjSum Finset.univ + +def markerObjects (c : ℕ) : Finset (I ⊕ Fin c) := + (∅ : Finset I).disjSum Finset.univ + +theorem markerActive_nonempty + {I : Type u} + [Fintype I] + [DecidableEq I] + {A : Type v} + (C : I → A → Bool) (x : A) {c : ℕ} (hc : 0 < c) : + (markerActive C x c).Nonempty := by + refine ⟨Sum.inr ⟨0, hc⟩, ?_⟩ + simp [markerActive] + +theorem markerObjects_subset + {I : Type u} + [Fintype I] + [DecidableEq I] + {A : Type v} + (C : I → A → Bool) (x : A) (c : ℕ) : + markerObjects (I := I) c ⊆ markerActive C x c := by + intro s hs + cases s with + | inl i => simp [markerObjects] at hs + | inr m => simp [markerActive] + +theorem markerSample_iff_first_marker (C : I → A → Bool) (x : A) + {c : ℕ} (hc : 0 < c) (π : Equiv.Perm (I ⊕ Fin c)) : + markerSample C c π x = true ↔ + ∃ s ∈ markerObjects (I := I) c, IsFirst (markerActive C x c) π s := by + constructor + · intro hsample + have hgood := (markerSample_eq_true C c π x).mp hsample + obtain ⟨s, hs⟩ := exists_isFirst (markerActive C x c) + (markerActive_nonempty C x hc) π + cases s with + | inr m => exact ⟨Sum.inr m, by simp [markerObjects], hs⟩ + | inl i => + have hbad : C i x = false := by simpa [markerActive, markerBad] using hs.1 + have hselected : i ∈ markerSelected c π := by + apply (mem_markerSelected c π i).mpr + intro m + have hle := hs.2 (Sum.inr m) (by simp [markerActive]) + apply lt_of_le_of_ne hle + intro heq + have hlabels := permutationRank_injective π heq + cases hlabels + have htrue := hgood i hselected + rw [hbad] at htrue + cases htrue + · rintro ⟨s, hs, hfirst⟩ + apply (markerSample_eq_true C c π x).mpr + cases s with + | inl i => simp [markerObjects] at hs + | inr m => + intro i hi + by_contra hnot + have hbad : C i x = false := Bool.eq_false_of_not_eq_true hnot + have hactive : Sum.inl i ∈ markerActive C x c := by + simp [markerActive, markerBad, hbad] + have hle := hfirst.2 (Sum.inl i) hactive + have hlt := (mem_markerSelected c π i).mp hi m + exact (not_lt_of_ge hle) hlt + +theorem marker_mixture_ratio (C : I → A → Bool) (x : A) {c : ℕ} (hc : 0 < c) : + finiteAvg (fun π : Equiv.Perm (I ⊕ Fin c) => + indicator (markerSample C c π x)) = + (c : ℝ) / ((c : ℝ) + ((markerBad C x).card : ℝ)) := by + classical + calc + finiteAvg (fun π : Equiv.Perm (I ⊕ Fin c) => + indicator (markerSample C c π x)) = + (∑ π : Equiv.Perm (I ⊕ Fin c), + if ∃ s ∈ markerObjects (I := I) c, IsFirst (markerActive C x c) π s + then (1 : ℝ) else 0) / (Fintype.card (Equiv.Perm (I ⊕ Fin c)) : ℝ) := by + unfold finiteAvg indicator + simp_rw [markerSample_iff_first_marker C x hc] + rw [div_eq_mul_inv, mul_comm] + _ = ((markerObjects (I := I) c).card : ℝ) / + ((markerActive C x c).card : ℝ) := + permutation_first_ratio (markerActive C x c) (markerObjects c) + (markerActive_nonempty C x hc) (markerObjects_subset C x c) + _ = (c : ℝ) / ((c : ℝ) + ((markerBad C x).card : ℝ)) := by + simp [markerObjects, markerActive, Finset.card_disjSum, Nat.cast_add, add_comm] + +theorem markerSample_of_all_true (C : I → A → Bool) (x : A) (c : ℕ) + (π : Equiv.Perm (I ⊕ Fin c)) (hC : ∀ i, C i x = true) : + markerSample C c π x = true := by + apply (markerSample_eq_true C c π x).mpr + exact fun i _ => hC i + +theorem markerSample_of_isEmpty [IsEmpty I] (C : I → A → Bool) (x : A) (c : ℕ) + (π : Equiv.Perm (I ⊕ Fin c)) : markerSample C c π x = true := by + apply markerSample_of_all_true + intro i + exact isEmptyElim i + +theorem marker_product_mixture_ratio {H : Type uDepth1} [Fintype H] [DecidableEq H] + {J : H → Type uDepth2} [∀ h, Fintype (J h)] [∀ h, DecidableEq (J h)] + (C : ∀ h, J h → A → Bool) (c : H → ℕ) (hc : ∀ h, 0 < c h) (x : A) : + finiteAvg (fun π : ∀ h, Equiv.Perm (J h ⊕ Fin (c h)) => + ∏ h, indicator (markerSample (C h) (c h) (π h) x)) = + ∏ h, (c h : ℝ) / ((c h : ℝ) + ((markerBad (C h) x).card : ℝ)) := by + calc + _ = ∏ h, finiteAvg (fun π : Equiv.Perm (J h ⊕ Fin (c h)) => + indicator (markerSample (C h) (c h) π x)) := by + convert finiteAvg_pi_prod (fun h (π : Equiv.Perm (J h ⊕ Fin (c h))) => + indicator (markerSample (C h) (c h) π x)) + _ = _ := by + apply Finset.prod_congr rfl + intro h _ + exact marker_mixture_ratio (C h) x (hc h) + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/MarkerPermutation.lean b/lean/OAI/Computability/DepthThree/MarkerPermutation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f67548ac3c876d17c9206b735af9b855c15d7a44 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/MarkerPermutation.lean @@ -0,0 +1,158 @@ +import Mathlib.Data.Fintype.Perm +import Mathlib.Data.Finset.Max +import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise +import Mathlib.Algebra.BigOperators.Group.Finset.Sigma +import Mathlib.Basic.Real.Basic +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +namespace OAI + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +universe u + +variable {L : Type u} [instFintypeL : Fintype L] [instDecidableEqL : DecidableEq L] + +def permutationRank (π : Equiv.Perm L) (l : L) : Fin (Fintype.card L) := + Fintype.equivFin L (π l) + +def IsFirst (S : Finset L) (π : Equiv.Perm L) (s : L) : Prop := + s ∈ S ∧ ∀ t ∈ S, permutationRank π s ≤ permutationRank π t + +theorem permutationRank_injective + {L : Type u} + [instFintypeL : Fintype L] + [DecidableEq L] + (π : Equiv.Perm L) : + Function.Injective (permutationRank π) := + (Fintype.equivFin L).injective.comp π.injective + +theorem exists_isFirst + {L : Type u} + [instFintypeL : Fintype L] + [DecidableEq L] + (S : Finset L) (hS : S.Nonempty) (π : Equiv.Perm L) : + ∃ s, IsFirst S π s := by + obtain ⟨s, hs, hmin⟩ := S.exists_min_image (permutationRank π) hS + exact ⟨s, hs, hmin⟩ + +theorem isFirst_unique {S : Finset L} {π : Equiv.Perm L} {s t : L} + (hs : IsFirst S π s) (ht : IsFirst S π t) : s = t := by + apply permutationRank_injective π + exact le_antisymm (hs.2 t ht.1) (ht.2 s hs.1) + +private theorem swap_mem_active + {L : Type u} + [Fintype L] + [instDecidableEqL : DecidableEq L] + {S : Finset L} {s t x : L} + (hs : s ∈ S) (ht : t ∈ S) (hx : x ∈ S) : Equiv.swap s t x ∈ S := by + by_cases hxs : x = s + · subst x + simpa only [Equiv.swap_apply_left] using ht + by_cases hxt : x = t + · subst x + simpa only [Equiv.swap_apply_right] using hs + rw [Equiv.swap_apply_of_ne_of_ne hxs hxt] + exact hx + +private def permutationInputSwap (s t : L) : Equiv.Perm (Equiv.Perm L) where + toFun π := (Equiv.swap s t).trans π + invFun π := (Equiv.swap s t).trans π + left_inv π := by + apply Equiv.ext + intro x + simp only [Equiv.trans_apply, Equiv.swap_apply_self] + right_inv π := by + apply Equiv.ext + intro x + simp only [Equiv.trans_apply, Equiv.swap_apply_self] + +private theorem isFirst_inputSwap_iff (S : Finset L) (s t : L) + (hs : s ∈ S) (ht : t ∈ S) (π : Equiv.Perm L) : + IsFirst S ((Equiv.swap s t).trans π) t ↔ IsFirst S π s := by + constructor + · intro h + refine ⟨hs, ?_⟩ + intro x hx + have hmin := h.2 (Equiv.swap s t x) (swap_mem_active hs ht hx) + simpa only [permutationRank, Equiv.trans_apply, Equiv.swap_apply_right, + Equiv.swap_apply_self] using hmin + · intro h + refine ⟨ht, ?_⟩ + intro x hx + have hmin := h.2 (Equiv.swap s t x) (swap_mem_active hs ht hx) + simpa only [permutationRank, Equiv.trans_apply, Equiv.swap_apply_right] using hmin + +private theorem first_fiber_sum_eq (S : Finset L) {s t : L} + (hs : s ∈ S) (ht : t ∈ S) : + (∑ π : Equiv.Perm L, if IsFirst S π s then (1 : ℝ) else 0) = + ∑ π : Equiv.Perm L, if IsFirst S π t then (1 : ℝ) else 0 := by + refine Fintype.sum_equiv (permutationInputSwap s t) _ _ ?_ + intro π + change (if IsFirst S π s then (1 : ℝ) else 0) = + if IsFirst S ((Equiv.swap s t).trans π) t then (1 : ℝ) else 0 + rw [isFirst_inputSwap_iff S s t hs ht π] + +private theorem sum_isFirst_indicator (S M : Finset L) (π : Equiv.Perm L) : + (∑ s ∈ M, if IsFirst S π s then (1 : ℝ) else 0) = + if ∃ s ∈ M, IsFirst S π s then (1 : ℝ) else 0 := by + exact Finset.sum_ite_zero M (IsFirst S π) + (fun s _ t _ hs ht => isFirst_unique hs ht) (1 : ℝ) + +theorem permutation_first_ratio (S M : Finset L) (hS : S.Nonempty) (hMS : M ⊆ S) : + ((∑ π : Equiv.Perm L, if ∃ s ∈ M, IsFirst S π s then (1 : ℝ) else 0) / + (Fintype.card (Equiv.Perm L) : ℝ)) = (M.card : ℝ) / (S.card : ℝ) := by + obtain ⟨s, hs⟩ := hS + let q : ℝ := ∑ π : Equiv.Perm L, if IsFirst S π s then (1 : ℝ) else 0 + have hfiber (t : L) (ht : t ∈ S) : + (∑ π : Equiv.Perm L, if IsFirst S π t then (1 : ℝ) else 0) = q := + first_fiber_sum_eq S ht hs + have hsum (A : Finset L) (hAS : A ⊆ S) : + (∑ π : Equiv.Perm L, if ∃ t ∈ A, IsFirst S π t then (1 : ℝ) else 0) = + (A.card : ℝ) * q := by + calc + (∑ π : Equiv.Perm L, if ∃ t ∈ A, IsFirst S π t then (1 : ℝ) else 0) = + ∑ π : Equiv.Perm L, ∑ t ∈ A, if IsFirst S π t then (1 : ℝ) else 0 := by + apply Finset.sum_congr rfl + intro π _ + exact (sum_isFirst_indicator S A π).symm + _ = ∑ t ∈ A, ∑ π : Equiv.Perm L, if IsFirst S π t then (1 : ℝ) else 0 := + Finset.sum_comm + _ = ∑ _t ∈ A, q := by + apply Finset.sum_congr rfl + intro t ht + exact hfiber t (hAS ht) + _ = (A.card : ℝ) * q := by simp [nsmul_eq_mul] + have hone : + (∑ π : Equiv.Perm L, if ∃ t ∈ S, IsFirst S π t then (1 : ℝ) else 0) = + (Fintype.card (Equiv.Perm L) : ℝ) := by + calc + (∑ π : Equiv.Perm L, if ∃ t ∈ S, IsFirst S π t then (1 : ℝ) else 0) = + ∑ _π : Equiv.Perm L, (1 : ℝ) := by + apply Finset.sum_congr rfl + intro π _ + obtain ⟨t, ht⟩ := exists_isFirst S ⟨s, hs⟩ π + exact ite_eq_left ⟨t, ht.1, ht⟩ + _ = (Fintype.card (Equiv.Perm L) : ℝ) := by simp + have hmass : (S.card : ℝ) * q = (Fintype.card (Equiv.Perm L) : ℝ) := + (hsum S (fun _ hx => hx)).symm.trans hone + have hS0 : (S.card : ℝ) ≠ 0 := by + exact_mod_cast (Finset.card_pos.mpr (show S.Nonempty from ⟨s, hs⟩)).ne' + have hΩ0 : (Fintype.card (Equiv.Perm L) : ℝ) ≠ 0 := by + exact_mod_cast (Fintype.card_ne_zero : Fintype.card (Equiv.Perm L) ≠ 0) + rw [hsum M hMS] + apply (div_eq_div_iff hΩ0 hS0).2 + rw [← hmass] + ring + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/Model.lean b/lean/OAI/Computability/DepthThree/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..90f7f43c78f06010520ce157375a5d4ff560da3e --- /dev/null +++ b/lean/OAI/Computability/DepthThree/Model.lean @@ -0,0 +1,135 @@ +import Mathlib + +namespace OAI + +namespace DepthThreeLowerBound + +universe uV uS uK uGamma uQ + +abbrev Cube (V : Type uV) := V → Bool +abbrev Literal (V : Type uV) := V × Bool + +variable {V : Type uV} + +namespace Literal + +def eval (l : Literal V) (x : Cube V) : Bool := decide (x l.1 = l.2) + +end Literal + +abbrev GateInput (V : Type uV) := Sum (Literal V) Bool +abbrev RawClause (V : Type uV) := List (GateInput V) + +namespace GateInput + +def eval : GateInput V → Cube V → Bool + | .inl l, x => l.eval x + | .inr b, _ => b + +end GateInput + +namespace RawClause + +noncomputable def eval (C : RawClause V) (x : Cube V) : Bool := by + classical + exact decide (∃ l ∈ C, l.eval x = true) + +end RawClause + +structure Circuit3 (V : Type uV) where + bottomCount : ℕ + middleCount : ℕ + bottom : Fin bottomCount → RawClause V + middle : Fin middleCount → Finset (Fin bottomCount) + top : Finset (Fin middleCount) + +namespace Circuit3 + +def gateCount (C : Circuit3 V) : ℕ := C.bottomCount + C.middleCount + 1 + +noncomputable def middleEval (C : Circuit3 V) (j : Fin C.middleCount) + (x : Cube V) : Bool := by + classical + exact decide (∀ i ∈ C.middle j, (C.bottom i).eval x = true) + +noncomputable def eval (C : Circuit3 V) (x : Cube V) : Bool := by + classical + exact decide (∃ j ∈ C.top, C.middleEval j x = true) + +def Computes (C : Circuit3 V) (f : Cube V → Bool) : Prop := ∀ x, C.eval x = f x + +end Circuit3 + +def runSteps {S : Type uS} (step : S → Option S) (n : ℕ) (c : Option S) : Option S := + (fun oc => oc.bind step)^[n] c + +inductive HeadMove + | left + | stay + | right + +def HeadMove.apply {Γ : Type uGamma} [Inhabited Γ] : HeadMove → Turing.Tape Γ → Turing.Tape Γ + | .left, t => t.move Turing.Dir.left + | .stay, t => t + | .right, t => t.move Turing.Dir.right + +structure MultiTapeCfg (K : Type uK) (Γ : Type uGamma) (Q : Type uQ) [Inhabited Γ] where + q : Q + tapes : K → Turing.Tape Γ + +abbrev MultiTapeCode (K : Type uK) (Γ : Type uGamma) (Q : Type uQ) := + Q → (K → Γ) → Option (Q × (K → Γ) × (K → HeadMove)) + +def multiTapeUpdate {K : Type uK} {Γ : Type uGamma} {Q : Type uQ} [Inhabited Γ] (c : MultiTapeCfg K Γ Q) + (q : Q) (writes : K → Γ) (moves : K → HeadMove) : MultiTapeCfg K Γ Q := + ⟨q, fun k => (moves k).apply ((c.tapes k).write (writes k))⟩ + +def multiTapeStep {K : Type uK} {Γ : Type uGamma} {Q : Type uQ} [Inhabited Γ] (code : MultiTapeCode K Γ Q) + (c : MultiTapeCfg K Γ Q) : Option (MultiTapeCfg K Γ Q) := + (code c.q (fun k => (c.tapes k).head)).map fun out => + multiTapeUpdate c out.1 out.2.1 out.2.2 + +structure FiniteMultiTapeMachine where + K : Type + [tapeFinite : Fintype K] + [tapeDecidableEq : DecidableEq K] + inputTape : K + Γ : Type + [alphabetInhabited : Inhabited Γ] + [alphabetFinite : Fintype Γ] + Q : Type + [stateFinite : Fintype Q] + initialState : Q + inputSymbol : Bool → Γ + input_injective : Function.Injective inputSymbol + input_ne_blank : ∀ b, inputSymbol b ≠ default + code : MultiTapeCode K Γ Q + accept : Q → Bool + +attribute [instance] FiniteMultiTapeMachine.tapeFinite + FiniteMultiTapeMachine.tapeDecidableEq FiniteMultiTapeMachine.alphabetInhabited + FiniteMultiTapeMachine.alphabetFinite FiniteMultiTapeMachine.stateFinite + +namespace FiniteMultiTapeMachine + +abbrev Cfg (M : FiniteMultiTapeMachine) := MultiTapeCfg M.K M.Γ M.Q + +abbrev step (M : FiniteMultiTapeMachine) : M.Cfg → Option M.Cfg := + multiTapeStep M.code + +def init (M : FiniteMultiTapeMachine) (input : List Bool) : M.Cfg := + ⟨M.initialState, fun k => + if k = M.inputTape then Turing.Tape.mk₁ (input.map M.inputSymbol) + else Turing.Tape.mk₁ []⟩ + +end FiniteMultiTapeMachine + +def MultiTapeHaltsIn (M : FiniteMultiTapeMachine) (input : List Bool) + (output : Bool) (time : ℕ) : Prop := + ∃ k ≤ time, ∃ c : M.Cfg, + runSteps M.step k (some (M.init input)) = some c ∧ + M.step c = none ∧ M.accept c.q = output + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/MomentBounds.lean b/lean/OAI/Computability/DepthThree/MomentBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a2574a90d871737c970def70fc7ed7835d55a21 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/MomentBounds.lean @@ -0,0 +1,163 @@ +import OAI.Computability.DepthThree.FiniteProbability +import OAI.Computability.DepthThree.TupleCounting +import Mathlib.Algebra.Order.BigOperators.Ring.Finset +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 uDepth7 uDepth8 uDepth9 uDepth10 uDepth11 uDepth12 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +def UniformBitsUpTo {Ω : Type uDepth1} {Z : Type uDepth2} [Fintype Ω] [DecidableEq Z] + (t : ℕ) (bits : Ω → Z → Bool) : Prop := + ∀ s : Finset Z, s.card ≤ t → ∀ F : (↥s → Bool) → ℝ, + finiteAvg (fun ω => F (fun z => bits ω z.val)) = finiteAvg F + +@[simp] theorem sign_not (b : Bool) : sign (!b) = -sign b := by + cases b <;> norm_num [sign] + +theorem abs_sign_mul_indicator_le_one (b c : Bool) : + |sign b * indicator c| ≤ 1 := by + cases b <;> cases c <;> norm_num [sign, indicator] + +def flipCoordinate {A : Type uDepth3} [DecidableEq A] (a₀ : A) : + (A → Bool) ≃ (A → Bool) where + toFun x a := if a = a₀ then !(x a) else x a + invFun x a := if a = a₀ then !(x a) else x a + left_inv x := by + funext a + by_cases h : a = a₀ <;> simp [h] + right_inv x := by + funext a + by_cases h : a = a₀ <;> simp [h] + +theorem uniform_product_zero_of_singleton {A : Type uDepth4} {I : Type uDepth5} + [Fintype A] [DecidableEq A] [Fintype I] [DecidableEq I] + (a : I → A) (w : I → ℝ) (i₀ : I) + (hunique : ∀ i, a i = a i₀ → i = i₀) : + finiteAvg (fun x : A → Bool => ∏ i, sign (x (a i)) * w i) = 0 := by + let F : (A → Bool) → ℝ := fun x => ∏ i, sign (x (a i)) * w i + let e := flipCoordinate (a i₀) + have hflip (x : A → Bool) : F (e x) = -F x := by + have hother : (∏ i ∈ Finset.univ.erase i₀, sign ((e x) (a i)) * w i) = + ∏ i ∈ Finset.univ.erase i₀, sign (x (a i)) * w i := by + apply Finset.prod_congr rfl + intro i hi + have hne : a i ≠ a i₀ := fun h => (Finset.mem_erase.mp hi).1 (hunique i h) + simp [e, flipCoordinate, hne] + have hat : sign ((e x) (a i₀)) * w i₀ = -(sign (x (a i₀)) * w i₀) := by + simp [e, flipCoordinate] + change (∏ i, sign ((e x) (a i)) * w i) = -(∏ i, sign (x (a i)) * w i) + rw [← Finset.mul_prod_erase Finset.univ + (fun i => sign ((e x) (a i)) * w i) (Finset.mem_univ i₀), + ← Finset.mul_prod_erase Finset.univ + (fun i => sign (x (a i)) * w i) (Finset.mem_univ i₀), hat, hother] + ring + have havg : finiteAvg F = -finiteAvg F := by + calc + finiteAvg F = finiteAvg (fun x => F (e x)) := (finiteAvg_equiv e F).symm + _ = finiteAvg (fun x => (-1) * F x) := by + apply finiteAvg_congr + intro x + rw [hflip] + ring + _ = -finiteAvg F := by rw [finiteAvg_const_mul]; ring + change finiteAvg F = 0 + linarith + +theorem tuple_product_avg_zero {Ω : Type uDepth6} {Z : Type uDepth7} [Fintype Ω] [DecidableEq Z] + {t : ℕ} (bits : Ω → Z → Bool) (hdist : UniformBitsUpTo t bits) + (a : Fin t → Z) (w : Fin t → ℝ) (hns : ¬ TupleNoSingleton a) : + finiteAvg (fun ω => ∏ i, sign (bits ω (a i)) * w i) = 0 := by + classical + obtain ⟨i₀, hi₀⟩ := tuple_singleton_of_not a hns + let s : Finset Z := Finset.univ.image a + let a' : Fin t → ↥s := fun i => + ⟨a i, Finset.mem_image_of_mem a (Finset.mem_univ i)⟩ + have hs : s.card ≤ t := by + simpa [s] using (Finset.card_image_le (s := (Finset.univ : Finset (Fin t))) (f := a)) + have huniq : ∀ i, a' i = a' i₀ → i = i₀ := by + intro i hi + exact hi₀ i (congrArg Subtype.val hi) + calc + finiteAvg (fun ω => ∏ i, sign (bits ω (a i)) * w i) = + finiteAvg (fun x : ↥s → Bool => ∏ i, sign (x (a' i)) * w i) := + hdist s hs (fun x => ∏ i, sign (x (a' i)) * w i) + _ = 0 := uniform_product_zero_of_singleton a' w i₀ huniq + +theorem sign_indicator_product_le_one {I : Type uDepth8} [Fintype I] + (b c : I → Bool) : (∏ i, sign (b i) * indicator (c i)) ≤ 1 := by + calc + _ ≤ |∏ i, sign (b i) * indicator (c i)| := le_abs_self _ + _ = ∏ i, |sign (b i) * indicator (c i)| := Finset.abs_prod _ _ + _ ≤ 1 := Finset.prod_le_one₀ + (fun _ _ => abs_nonneg _) (fun i _ => abs_sign_mul_indicator_le_one (b i) (c i)) + +theorem even_moment_le {Ω : Type uDepth9} {Z : Type uDepth10} [Fintype Ω] [Nonempty Ω] + [Fintype Z] [Nonempty Z] [DecidableEq Z] (h : ℕ) + (bits : Ω → Z → Bool) (hdist : UniformBitsUpTo (2 * h) bits) + (J : Z → Bool) : + finiteAvg (fun ω => |∑ z, sign (bits ω z) * indicator (J z)| ^ (2 * h)) ≤ + (Fintype.card Z : ℝ) ^ h * (h : ℝ) ^ (2 * h) := by + classical + have hexpand : finiteAvg + (fun ω => |∑ z, sign (bits ω z) * indicator (J z)| ^ (2 * h)) = + ∑ a : Fin (2 * h) → Z, + finiteAvg (fun ω => ∏ i, sign (bits ω (a i)) * indicator (J (a i))) := by + calc + _ = finiteAvg (fun ω => ∑ a : Fin (2 * h) → Z, + ∏ i, sign (bits ω (a i)) * indicator (J (a i))) := by + apply finiteAvg_congr + intro ω + rw [show |∑ z, sign (bits ω z) * indicator (J z)| ^ (2 * h) = + (∑ z, sign (bits ω z) * indicator (J z)) ^ (2 * h) by + simp only [pow_mul, sq_abs]] + exact Fintype.sum_pow _ _ + _ = _ := finiteAvg_sum Finset.univ _ + have hterm (a : Fin (2 * h) → Z) : + finiteAvg (fun ω => ∏ i, sign (bits ω (a i)) * indicator (J (a i))) ≤ + if TupleNoSingleton a then (1 : ℝ) else 0 := by + by_cases ha : TupleNoSingleton a + · simp only [ite_eq_left ha] + calc + _ ≤ finiteAvg (fun _ : Ω => (1 : ℝ)) := + finiteAvg_mono (fun ω => sign_indicator_product_le_one + (fun i => bits ω (a i)) (fun i => J (a i))) + _ = 1 := finiteAvg_const 1 + · rw [ite_eq_right ha, tuple_product_avg_zero bits hdist a (fun i => indicator (J (a i))) ha] + calc + _ = _ := hexpand + _ ≤ ∑ a : Fin (2 * h) → Z, if TupleNoSingleton a then (1 : ℝ) else 0 := + Finset.sum_le_sum (fun a _ => hterm a) + _ = ((Finset.univ.filter (fun a : Fin (2 * h) → Z => TupleNoSingleton a)).card : ℝ) := + Finset.sum_boole _ _ + _ ≤ ((Fintype.card Z) ^ h * h ^ (2 * h) : ℕ) := by + exact_mod_cast (card_noSingleton_tuples_le (Z := Z) h) + _ = (Fintype.card Z : ℝ) ^ h * (h : ℝ) ^ (2 * h) := by push_cast; rfl + +theorem even_moment_le_manuscript {Ω : Type uDepth11} {Z : Type uDepth12} [Fintype Ω] [Nonempty Ω] + [Fintype Z] [Nonempty Z] [DecidableEq Z] (h : ℕ) + (bits : Ω → Z → Bool) (hdist : UniformBitsUpTo (2 * h) bits) + (J : Z → Bool) : + finiteAvg (fun ω => |∑ z, sign (bits ω z) * indicator (J z)| ^ (2 * h)) ≤ + ((2 * h : ℕ) : ℝ) ^ (2 * h) * (Fintype.card Z : ℝ) ^ h := by + have hh : (h : ℝ) ≤ ((2 * h : ℕ) : ℝ) := by exact_mod_cast (show h ≤ 2 * h by omega) + calc + _ ≤ (Fintype.card Z : ℝ) ^ h * (h : ℝ) ^ (2 * h) := + even_moment_le h bits hdist J + _ ≤ (Fintype.card Z : ℝ) ^ h * ((2 * h : ℕ) : ℝ) ^ (2 * h) := + mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (Nat.cast_nonneg h) hh _) (by positivity) + _ = _ := mul_comm _ _ + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/MultiTapeMachine.lean b/lean/OAI/Computability/DepthThree/MultiTapeMachine.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8f0cab694777c642d6ddb8bde0710889fad8283 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/MultiTapeMachine.lean @@ -0,0 +1,79 @@ +import OAI.Computability.DepthThree.MachineBasic +import Mathlib.Tactic.DeriveFintype + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 uDepth7 uDepth8 uDepth9 + +namespace DepthThreeLowerBound + +deriving instance DecidableEq, Inhabited for HeadMove + +instance : Fintype HeadMove where + elems := { .left, .stay, .right } + complete := by + intro m + cases m <;> simp + +@[simp] theorem HeadMove.apply_left {Γ : Type uDepth1} [Inhabited Γ] (t : Turing.Tape Γ) : + HeadMove.left.apply t = t.move Turing.Dir.left := rfl + +@[simp] theorem HeadMove.apply_stay {Γ : Type uDepth2} [Inhabited Γ] (t : Turing.Tape Γ) : + HeadMove.stay.apply t = t := rfl + +@[simp] theorem HeadMove.apply_right {Γ : Type uDepth3} [Inhabited Γ] (t : Turing.Tape Γ) : + HeadMove.right.apply t = t.move Turing.Dir.right := rfl + +theorem multiTapeStep_eq_some {K : Type uDepth4} {Γ : Type uDepth5} {Q : Type uDepth6} [Inhabited Γ] + {code : MultiTapeCode K Γ Q} {c : MultiTapeCfg K Γ Q} + {q : Q} {writes : K → Γ} {moves : K → HeadMove} + (h : code c.q (fun k => (c.tapes k).head) = some (q, writes, moves)) : + multiTapeStep code c = some (multiTapeUpdate c q writes moves) := by + simp only [multiTapeStep, h, Option.map_some] + +@[simp] theorem multiTapeStep_eq_none_iff {K : Type uDepth7} {Γ : Type uDepth8} {Q : Type uDepth9} [Inhabited Γ] + (code : MultiTapeCode K Γ Q) (c : MultiTapeCfg K Γ Q) : + multiTapeStep code c = none ↔ code c.q (fun k => (c.tapes k).head) = none := by + unfold multiTapeStep + cases h : code c.q (fun k => (c.tapes k).head) <;> simp + +namespace FiniteMultiTapeMachine + +@[simp] theorem init_q (M : FiniteMultiTapeMachine) (input : List Bool) : + (M.init input).q = M.initialState := rfl + +@[simp] theorem init_inputTape (M : FiniteMultiTapeMachine) (input : List Bool) : + (M.init input).tapes M.inputTape = Turing.Tape.mk₁ (input.map M.inputSymbol) := by + simp [init] + +theorem init_otherTape (M : FiniteMultiTapeMachine) (input : List Bool) + (k : M.K) (hk : k ≠ M.inputTape) : + (M.init input).tapes k = Turing.Tape.mk₁ [] := by + simp [init, hk] + +end FiniteMultiTapeMachine + +theorem multiTapeHaltsIn_iff_runsIn (M : FiniteMultiTapeMachine) (input : List Bool) + (output : Bool) (time : ℕ) : + MultiTapeHaltsIn M input output time ↔ + ∃ c : M.Cfg, RunsIn M.step (M.init input) c time ∧ + M.step c = none ∧ M.accept c.q = output := by + constructor + · rintro ⟨k, hk, c, hrun, hhalt, hout⟩ + exact ⟨c, ⟨k, hk, hrun⟩, hhalt, hout⟩ + · rintro ⟨c, ⟨k, hk, hrun⟩, hhalt, hout⟩ + exact ⟨k, hk, c, hrun, hhalt, hout⟩ + +theorem MultiTapeHaltsIn.mono {M : FiniteMultiTapeMachine} {input : List Bool} + {output : Bool} {m n : ℕ} (h : MultiTapeHaltsIn M input output m) (hmn : m ≤ n) : + MultiTapeHaltsIn M input output n := by + obtain ⟨k, hk, c, hrun, hhalt, hout⟩ := h + exact ⟨k, hk.trans hmn, c, hrun, hhalt, hout⟩ + +def MultiTapePolynomialTimeDecider (f : List Bool → Bool) : Prop := + ∃ M : FiniteMultiTapeMachine, ∃ C a : ℕ, 0 < C ∧ 0 < a ∧ + ∀ w, MultiTapeHaltsIn M w (f w) (C * (w.length + 1) ^ a) + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/Restriction.lean b/lean/OAI/Computability/DepthThree/Restriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf2bb0018c45f93f5ff3ce7322fc675670e2b7af --- /dev/null +++ b/lean/OAI/Computability/DepthThree/Restriction.lean @@ -0,0 +1,85 @@ +import OAI.Computability.DepthThree.RestrictionCostCorrelation +import OAI.Computability.DepthThree.RestrictionExpectedCost +import Mathlib.Tactic.Linarith + +namespace OAI + +universe uDepth1 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} [Fintype V] + +def restrictionTheta (k b : ℕ) (p : ℝ) : ℝ := + ∑ l ∈ Finset.Icc (b + 1) k, (k.choose l : ℝ) * (2 * p / (1 - p)) ^ l + +theorem restrictionTheta_eq_reverseTheta (k b : ℕ) (p : ℝ) : + restrictionTheta k b p = reverseTheta (2 * p / (1 - p)) b k := by + have hs : (Finset.range (k + 1)).filter (fun l => b < l) = Finset.Icc (b + 1) k := by + ext l + simp only [Finset.mem_filter, Finset.mem_range, Finset.mem_Icc] + omega + unfold reverseTheta + rw [← Finset.sum_filter, hs] + rfl + +def cnfRestrictionCost (H : CNF V) (b : ℕ) (σ : Restriction V) : ℝ := + restrictionCost (cnfIndexFamily H.normalize) b σ + +theorem cnfRestrictionCost_nonneg (H : CNF V) (b : ℕ) (σ : Restriction V) : + 0 ≤ cnfRestrictionCost H b σ := + restrictionCost_nonneg (cnfIndexFamily H.normalize) b σ + +theorem cnf_restricted_correlation_le_cost (H : CNF V) (b : ℕ) (hb : 1 ≤ b) + (σ : Restriction V) (G : Cube (Live σ) → ℝ) : + |finiteAvg (fun x => G x * indicator (H.eval (fill σ x)))| ≤ + cnfRestrictionCost H b σ * corr b G := by + have hn : ∀ i, (cnfIndexFamily H.normalize i).Normalized := + cnfIndexFamily_normalized (CNF.normalize_normalized H) + simpa only [cnfRestrictionCost, indexedCNF_cnfIndexFamily_eval, CNF.eval_normalize] using + restricted_correlation_le_cost (cnfIndexFamily H.normalize) b hb hn σ G + +theorem restrictionAvg_cnfRestrictionCost_le (H : CNF V) (b k : ℕ) + (hH : H.WidthAtMost k) (p : ℝ) (hp0 : 0 < p) (hp1 : p < 1) + (hθ : restrictionTheta k b p < 1) : + restrictionAvg p (cnfRestrictionCost H b) ≤ 1 / (1 - restrictionTheta k b p) := by + have hn : ∀ i, (cnfIndexFamily H.normalize i).Normalized := + cnfIndexFamily_normalized (CNF.normalize_normalized H) + have hw : ∀ i, (cnfIndexFamily H.normalize i).scope.card ≤ k := + cnfIndexFamily_width (CNF.normalize_widthAtMost hH) + have ht : reverseTheta (2 * p / (1 - p)) b k < 1 := by + simpa only [restrictionTheta_eq_reverseTheta] using hθ + simpa +unfoldPartialApp only [cnfRestrictionCost, restrictionTheta_eq_reverseTheta, one_div] using + restrictionAvg_restrictionCost_le (cnfIndexFamily H.normalize) p hp0 hp1 b k hn hw ht + +theorem cnf_restriction_bound (H : CNF V) (b k : ℕ) (hb : 1 ≤ b) + (hH : H.WidthAtMost k) (p : ℝ) (hp0 : 0 < p) (hp1 : p < 1) + (hθ : restrictionTheta k b p < 1) : + ∃ W : Restriction V → ℝ, + (∀ σ, 0 ≤ W σ) ∧ + restrictionAvg p W ≤ 1 / (1 - restrictionTheta k b p) ∧ + ∀ (σ : Restriction V) (G : Cube (Live σ) → ℝ), + |finiteAvg (fun x => G x * indicator (H.eval (fill σ x)))| ≤ W σ * corr b G := by + refine ⟨cnfRestrictionCost H b, cnfRestrictionCost_nonneg H b, ?_, ?_⟩ + · exact restrictionAvg_cnfRestrictionCost_le H b k hH p hp0 hp1 hθ + · exact cnf_restricted_correlation_le_cost H b hb + +theorem restrictionAvg_cnfRestrictionCost_le_two (H : CNF V) (b k : ℕ) + (hH : H.WidthAtMost k) (p : ℝ) (hp0 : 0 < p) (hp1 : p < 1) + (hθ : restrictionTheta k b p ≤ 1 / 2) : + restrictionAvg p (cnfRestrictionCost H b) ≤ 2 := by + have ht : restrictionTheta k b p < 1 := by linarith + have hd : 0 < 1 - restrictionTheta k b p := sub_pos.mpr ht + refine (restrictionAvg_cnfRestrictionCost_le H b k hH p hp0 hp1 ht).trans ?_ + apply (div_le_iff₀ hd).mpr + linarith + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionClause.lean b/lean/OAI/Computability/DepthThree/RestrictionClause.lean new file mode 100644 index 0000000000000000000000000000000000000000..8116f23751b6618dc0f8e6376bf7bcedd9cff57e --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionClause.lean @@ -0,0 +1,174 @@ +import OAI.Computability.DepthThree.FiniteProbability +import OAI.Computability.DepthThree.RestrictionNormalization +import Mathlib.Data.List.Basic + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 uDepth7 uDepth8 uDepth9 + +noncomputable section + +open scoped Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} [Fintype V] + +def liveClause (σ : Restriction V) (C : Clause V) : Clause (Live σ) := by + classical + exact Finset.univ.filter fun l => ((l.1 : V), l.2) ∈ C + +@[simp] theorem mem_liveClause (σ : Restriction V) (C : Clause V) + (l : Literal (Live σ)) : l ∈ liveClause σ C ↔ ((l.1 : V), l.2) ∈ C := by + classical + simp [liveClause] + +theorem liveClause_scope_image_subset (σ : Restriction V) (C : Clause V) : + (liveClause σ C).scope.image Subtype.val ⊆ C.scope := by + classical + let : DecidableEq (Live σ) := Classical.decEq _ + intro v hv + obtain ⟨w, hw, rfl⟩ := Finset.mem_image.mp hv + obtain ⟨l, hl, hlw⟩ := Finset.mem_image.mp hw + have hc : ((l.1 : V), l.2) ∈ C := (mem_liveClause σ C l).mp hl + have hv : (l.1 : V) ∈ C.scope := Finset.mem_image_of_mem Prod.fst hc + simpa only [hlw] using hv + +theorem liveClause_width_le (σ : Restriction V) (C : Clause V) : + (liveClause σ C).width ≤ C.width := by + classical + calc + (liveClause σ C).width = + ((liveClause σ C).scope.image Subtype.val).card := + (Finset.card_image_of_injective _ Subtype.val_injective).symm + _ ≤ C.scope.card := Finset.card_le_card (liveClause_scope_image_subset σ C) + _ = C.width := rfl + +theorem liveClause_normalized (σ : Restriction V) {C : Clause V} + (hC : C.Normalized) : (liveClause σ C).Normalized := by + intro v hf ht + exact hC v.val ((mem_liveClause σ C (v, false)).mp hf) + ((mem_liveClause σ C (v, true)).mp ht) + +def restrictClause (σ : Restriction V) (C : Clause V) : Option (Clause (Live σ)) := by + classical + exact if ∃ l ∈ C, σ l.1 = some l.2 then none else some (liveClause σ C) + +def residualClauseEval {W : Type uDepth2} (C : Option (Clause W)) (x : Cube W) : Bool := + match C with + | none => true + | some C => C.eval x + +@[simp] theorem residualClauseEval_none {W : Type uDepth3} (x : Cube W) : + residualClauseEval (none : Option (Clause W)) x = true := rfl + +@[simp] theorem residualClauseEval_some {W : Type uDepth4} (C : Clause W) (x : Cube W) : + residualClauseEval (some C) x = C.eval x := rfl + +theorem restrictClause_eval (σ : Restriction V) (C : Clause V) + (z : Cube (Live σ)) : + residualClauseEval (restrictClause σ C) z = C.eval (fill σ z) := by + classical + by_cases hs : ∃ l ∈ C, σ l.1 = some l.2 + · simp only [restrictClause, ite_eq_left hs, residualClauseEval_none] + symm + obtain ⟨l, hl, hlσ⟩ := hs + exact (Clause.eval_eq_true C (fill σ z)).mpr ⟨l, hl, fill_fixed σ z l.1 l.2 hlσ⟩ + · simp only [restrictClause, ite_eq_right hs, residualClauseEval_some] + apply Bool.eq_iff_iff.mpr + rw [Clause.eval_eq_true, Clause.eval_eq_true] + constructor + · rintro ⟨⟨v, b⟩, hl, hz⟩ + refine ⟨(v.val, b), (mem_liveClause σ C (v, b)).mp hl, ?_⟩ + exact (fill_live σ z v).trans hz + · rintro ⟨⟨v, b⟩, hl, hz⟩ + have hv : σ v = none := by + cases hσ : σ v with + | none => rfl + | some c => + have hcb : c = b := (fill_fixed σ z v c hσ).symm.trans hz + have hf : ∃ l ∈ C, σ l.1 = some l.2 := + ⟨(v, b), hl, hσ.trans (congrArg some hcb)⟩ + exact (hs hf).elim + refine ⟨(⟨v, hv⟩, b), (mem_liveClause σ C (⟨v, hv⟩, b)).mpr hl, ?_⟩ + exact (fill_live σ z ⟨v, hv⟩).symm.trans hz + +theorem restrictClause_some_eq {σ : Restriction V} {C : Clause V} + {D : Clause (Live σ)} (h : restrictClause σ C = some D) : + D = liveClause σ C := by + classical + unfold restrictClause at h + split at h + · cases h + · exact (Option.some.inj h).symm + +theorem restrictClause_width_le {σ : Restriction V} {C : Clause V} + {D : Clause (Live σ)} (h : restrictClause σ C = some D) : D.width ≤ C.width := by + rw [restrictClause_some_eq h] + exact liveClause_width_le σ C + +theorem restrictClause_normalized {σ : Restriction V} {C : Clause V} + {D : Clause (Live σ)} (hC : C.Normalized) + (h : restrictClause σ C = some D) : D.Normalized := by + rw [restrictClause_some_eq h] + exact liveClause_normalized σ hC + +@[simp] theorem restrictClause_empty (σ : Restriction V) : + restrictClause σ (∅ : Clause V) = some ∅ := by + classical + simp [restrictClause, liveClause] + +def residualCNF {W : Type uDepth5} (H : List (Option (Clause W))) : CNF W := + H.filterMap id + +@[simp] theorem residualCNF_nil {W : Type uDepth6} : + residualCNF ([] : List (Option (Clause W))) = [] := rfl + +@[simp] theorem residualCNF_cons_none {W : Type uDepth7} (H : List (Option (Clause W))) : + residualCNF (none :: H) = residualCNF H := rfl + +@[simp] theorem residualCNF_cons_some {W : Type uDepth8} (C : Clause W) + (H : List (Option (Clause W))) : + residualCNF (some C :: H) = C :: residualCNF H := rfl + +theorem residualCNF_eval_cons {W : Type uDepth9} (C : Option (Clause W)) + (H : List (Option (Clause W))) (x : Cube W) : + (residualCNF (C :: H)).eval x = + (residualClauseEval C x && (residualCNF H).eval x) := by + cases C <;> simp + +def restrictCNF (σ : Restriction V) (H : CNF V) : CNF (Live σ) := + H.filterMap (restrictClause σ) + +@[simp] theorem restrictCNF_eval (σ : Restriction V) (H : CNF V) + (z : Cube (Live σ)) : (restrictCNF σ H).eval z = H.eval (fill σ z) := by + induction H with + | nil => simp [restrictCNF] + | cons C H ih => + have he := restrictClause_eval σ C z + unfold restrictCNF at ih + cases hr : restrictClause σ C with + | none => + simp only [hr, residualClauseEval_none] at he + simp [restrictCNF, hr, ← he, ih] + | some D => + simp only [hr, residualClauseEval_some] at he + simp [restrictCNF, hr, ← he, ih] + +theorem restrictCNF_widthAtMost (σ : Restriction V) {H : CNF V} {b : ℕ} + (hH : H.WidthAtMost b) : (restrictCNF σ H).WidthAtMost b := by + intro D hD + obtain ⟨C, hC, hCD⟩ := List.mem_filterMap.mp hD + exact (restrictClause_width_le hCD).trans (hH C hC) + +theorem restrictCNF_normalized (σ : Restriction V) {H : CNF V} + (hH : H.Normalized) : (restrictCNF σ H).Normalized := by + intro D hD + obtain ⟨C, hC, hCD⟩ := List.mem_filterMap.mp hD + exact restrictClause_normalized (hH C hC) hCD + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionCorrelation.lean b/lean/OAI/Computability/DepthThree/RestrictionCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..194f9e995fdd624cca6292187c92a93b1f918cbd --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionCorrelation.lean @@ -0,0 +1,168 @@ +import OAI.Computability.DepthThree.Core +import OAI.Computability.DepthThree.FiniteProbability +import Mathlib.Data.Finset.Lattice.Fold +import Mathlib.Algebra.Order.BigOperators.Group.Finset + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} [Fintype V] + +def narrowTests (b : ℕ) : Finset (Cube V → Bool) := by + classical + exact Finset.univ.filter fun J => ∃ H : CNF V, H.WidthAtMost b ∧ H.eval = J + +@[simp] theorem mem_narrowTests_iff (b : ℕ) (J : Cube V → Bool) : + J ∈ narrowTests b ↔ ∃ H : CNF V, H.WidthAtMost b ∧ H.eval = J := by + classical + simp [narrowTests] + +theorem eval_mem_narrowTests (b : ℕ) (H : CNF V) (hH : H.WidthAtMost b) : + H.eval ∈ narrowTests b := + (mem_narrowTests_iff b H.eval).mpr ⟨H, hH, rfl⟩ + +theorem narrowTests_true_mem (b : ℕ) : + (fun _ : Cube V => true) ∈ narrowTests b := by + apply (mem_narrowTests_iff b _).mpr + refine ⟨[], ?_, ?_⟩ + · simp [CNF.WidthAtMost] + · funext x + exact CNF.eval_nil x + +theorem narrowTests_false_mem (b : ℕ) : + (fun _ : Cube V => false) ∈ narrowTests b := by + apply (mem_narrowTests_iff b _).mpr + refine ⟨[∅], ?_, ?_⟩ + · simp [CNF.WidthAtMost] + · funext x + simp + +theorem narrowTests_nonempty (b : ℕ) : (narrowTests (V := V) b).Nonempty := + ⟨_, narrowTests_true_mem b⟩ + +def corr (b : ℕ) (G : Cube V → ℝ) : ℝ := + (narrowTests b).sup' (narrowTests_nonempty b) + (fun J => |finiteAvg (fun x => G x * indicator (J x))|) + +theorem abs_table_corr_le (b : ℕ) (G : Cube V → ℝ) + (J : Cube V → Bool) (hJ : J ∈ narrowTests b) : + |finiteAvg (fun x => G x * indicator (J x))| ≤ corr b G := + Finset.le_sup' (fun J : Cube V → Bool => |finiteAvg (fun x => G x * indicator (J x))|) hJ + +theorem abs_corr_le (b : ℕ) (G : Cube V → ℝ) (H : CNF V) + (hH : H.WidthAtMost b) : + |finiteAvg (fun x => G x * indicator (H.eval x))| ≤ corr b G := + abs_table_corr_le b G H.eval (eval_mem_narrowTests b H hH) + +theorem abs_mean_le_corr (b : ℕ) (G : Cube V → ℝ) : + |finiteAvg G| ≤ corr b G := by + simpa using abs_table_corr_le b G (fun _ => true) (narrowTests_true_mem b) + +theorem corr_nonneg (b : ℕ) (G : Cube V → ℝ) : 0 ≤ corr b G := + (abs_nonneg (finiteAvg G)).trans (abs_mean_le_corr b G) + +theorem corr_le_of_forall (b : ℕ) (G : Cube V → ℝ) (c : ℝ) + (h : ∀ H : CNF V, H.WidthAtMost b → + |finiteAvg (fun x => G x * indicator (H.eval x))| ≤ c) : + corr b G ≤ c := by + apply Finset.sup'_le + intro J hJ + obtain ⟨H, hH, rfl⟩ := (mem_narrowTests_iff b J).mp hJ + exact h H hH + +theorem corr_attained (b : ℕ) (G : Cube V → ℝ) : + ∃ H : CNF V, H.WidthAtMost b ∧ + corr b G = |finiteAvg (fun x => G x * indicator (H.eval x))| := by + obtain ⟨J, hJ, heq⟩ := Finset.exists_mem_eq_sup' (narrowTests_nonempty (V := V) b) + (fun J => |finiteAvg (fun x => G x * indicator (J x))|) + obtain ⟨H, hH, rfl⟩ := (mem_narrowTests_iff b J).mp hJ + exact ⟨H, hH, heq⟩ + +theorem corr_le_abs_mean (b : ℕ) (G : Cube V → ℝ) : + corr b G ≤ finiteAvg (fun x => |G x|) := by + apply corr_le_of_forall + intro H _ + apply (finiteAvg_abs_le _).trans + apply finiteAvg_mono + intro x + rw [abs_mul, abs_of_nonneg (indicator_nonneg (H.eval x))] + exact mul_le_of_le_one_right (abs_nonneg _) (indicator_le_one _) + +theorem corr_linearCombination_identity {ι : Type uDepth2} (s : Finset ι) + (c : ι → ℝ) (H : ι → CNF V) (G : Cube V → ℝ) : + finiteAvg (fun x => G x * ∑ i ∈ s, c i * indicator ((H i).eval x)) = + ∑ i ∈ s, c i * finiteAvg (fun x => G x * indicator ((H i).eval x)) := by + calc + _ = finiteAvg (fun x => ∑ i ∈ s, c i * (G x * indicator ((H i).eval x))) := by + apply finiteAvg_congr + intro x + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + exact mul_left_comm _ _ _ + _ = ∑ i ∈ s, finiteAvg (fun x => c i * (G x * indicator ((H i).eval x))) := + finiteAvg_sum s _ + _ = _ := Finset.sum_congr rfl (fun i _ => finiteAvg_const_mul _ _) + +theorem abs_corr_linearCombination_le {ι : Type uDepth3} (s : Finset ι) + (c : ι → ℝ) (H : ι → CNF V) (b : ℕ) (G : Cube V → ℝ) + (hH : ∀ i ∈ s, (H i).WidthAtMost b) : + |finiteAvg (fun x => G x * ∑ i ∈ s, c i * indicator ((H i).eval x))| ≤ + (∑ i ∈ s, |c i|) * corr b G := by + rw [corr_linearCombination_identity] + calc + _ ≤ ∑ i ∈ s, |c i * finiteAvg (fun x => G x * indicator ((H i).eval x))| := + Finset.abs_sum_le_sum_abs _ _ + _ = ∑ i ∈ s, |c i| * |finiteAvg (fun x => G x * indicator ((H i).eval x))| := by + simp only [abs_mul] + _ ≤ ∑ i ∈ s, |c i| * corr b G := by + apply Finset.sum_le_sum + intro i hi + exact mul_le_mul_of_nonneg_left (abs_corr_le b G (H i) (hH i hi)) (abs_nonneg _) + _ = (∑ i ∈ s, |c i|) * corr b G := (Finset.sum_mul _ _ _).symm + +theorem abs_corr_convex_mixture_le {ι : Type uDepth4} (s : Finset ι) + (w : ι → ℝ) (H : ι → CNF V) (b : ℕ) (G : Cube V → ℝ) + (hw : ∀ i ∈ s, 0 ≤ w i) (hsum : ∑ i ∈ s, w i = 1) + (hH : ∀ i ∈ s, (H i).WidthAtMost b) : + |finiteAvg (fun x => G x * ∑ i ∈ s, w i * indicator ((H i).eval x))| ≤ + corr b G := by + have hwabs : (∑ i ∈ s, |w i|) = 1 := by + calc + _ = ∑ i ∈ s, w i := + Finset.sum_congr rfl (fun i hi => abs_of_nonneg (hw i hi)) + _ = 1 := hsum + simpa only [hwabs, one_mul] using abs_corr_linearCombination_le s w H b G hH + +theorem abs_corr_uniform_mixture_le {ι : Type uDepth5} [Fintype ι] [Nonempty ι] + (H : ι → CNF V) (b : ℕ) (G : Cube V → ℝ) + (hH : ∀ i, (H i).WidthAtMost b) : + |finiteAvg (fun x => G x * finiteAvg (fun i => indicator ((H i).eval x)))| ≤ + corr b G := by + have hlin : + finiteAvg (fun x => G x * finiteAvg (fun i => indicator ((H i).eval x))) = + finiteAvg (fun i => finiteAvg (fun x => G x * indicator ((H i).eval x))) := by + calc + _ = finiteAvg (fun x => finiteAvg (fun i => G x * indicator ((H i).eval x))) := + finiteAvg_congr (fun x => (finiteAvg_const_mul (G x) _).symm) + _ = _ := finiteAvg_comm _ + rw [hlin] + calc + _ ≤ finiteAvg (fun i => |finiteAvg (fun x => G x * indicator ((H i).eval x))|) := + finiteAvg_abs_le _ + _ ≤ finiteAvg (fun _ : ι => corr b G) := + finiteAvg_mono (fun i => abs_corr_le b G (H i) (hH i)) + _ = corr b G := finiteAvg_const _ + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionCostCorrelation.lean b/lean/OAI/Computability/DepthThree/RestrictionCostCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..72e2ed70e758b2e518f2d45563c1f44a0279d087 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionCostCorrelation.lean @@ -0,0 +1,216 @@ +import OAI.Computability.DepthThree.RestrictionPathProducts +import OAI.Computability.DepthThree.RestrictionPathMixture +import OAI.Computability.DepthThree.RestrictionEasyBase +import OAI.Computability.DepthThree.RestrictionCorrelation + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} {I : Type uDepth2} [Fintype V] [Fintype I] + +theorem pathMixture_eq_pathTerm (C : I → Clause V) (b : ℕ) (σ : Restriction V) + {n : ℕ} {P : List I} + (hP : P ∈ paths (fun i => (C i).scope) (liveSet σ) b n) + (hn : ∀ i ∈ P, (C i).Normalized) (hc : pathCompatible C σ P) + (K : CNF (Live σ)) (x : Cube (Live σ)) : + pathWeight C σ P * + finiteAvg (fun π : PathMarkerSample C b σ P => + indicator ((pathMixtureCNF C b σ P K π).eval x)) = + indicator (K.eval x) * pathTerm (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) P := by + rw [pathTerm_eq_support_prod_inv] + exact pathMixture_scaled_average C b σ hP hn hc K x + +theorem pathTerm_zero_of_incompatible (C : I → Clause V) (b : ℕ) + (σ : Restriction V) (P : List I) (hc : ¬ pathCompatible C σ P) + (x : Cube (Live σ)) : + pathTerm (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) P = 0 := by + have hs : ¬ ∀ i ∈ P, (C i).violation (fill σ x) = true := + fun hx => hc ⟨x, hx⟩ + rw [pathTerm_eq_support_prod_inv, ite_eq_right hs] + +theorem abs_corr_pathTerm_le (C : I → Clause V) (b : ℕ) (σ : Restriction V) + {n : ℕ} {P : List I} + (hP : P ∈ paths (fun i => (C i).scope) (liveSet σ) b n) + (hn : ∀ i ∈ P, (C i).Normalized) (hb : 1 ≤ b) + (K : CNF (Live σ)) (hK : K.WidthAtMost b) (G : Cube (Live σ) → ℝ) : + |finiteAvg (fun x => G x * (indicator (K.eval x) * + pathTerm (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) P))| ≤ + (if pathCompatible C σ P then pathWeight C σ P else 0) * corr b G := by + by_cases hc : pathCompatible C σ P + · rw [ite_eq_left hc] + have hlin : + finiteAvg (fun x => G x * (indicator (K.eval x) * + pathTerm (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) P)) = + pathWeight C σ P * finiteAvg (fun x => G x * + finiteAvg (fun π : PathMarkerSample C b σ P => + indicator ((pathMixtureCNF C b σ P K π).eval x))) := by + calc + _ = finiteAvg (fun x => pathWeight C σ P * (G x * + finiteAvg (fun π : PathMarkerSample C b σ P => + indicator ((pathMixtureCNF C b σ P K π).eval x)))) := by + apply finiteAvg_congr + intro x + rw [← pathMixture_eq_pathTerm C b σ hP hn hc K x] + ring + _ = _ := finiteAvg_const_mul _ _ + rw [hlin, abs_mul, abs_of_nonneg (pathWeight_nonneg C σ P)] + apply mul_le_mul_of_nonneg_left _ (pathWeight_nonneg C σ P) + have htransport (inst₁ inst₂ : Fintype (Cube (Live σ))) + (f : Cube (Live σ) → ℝ) (c : ℝ) + (h : |@finiteAvg _ inst₁ f| ≤ c) : |@finiteAvg _ inst₂ f| ≤ c := by + have hi : inst₁ = inst₂ := Subsingleton.elim _ _ + cases hi + exact h + exact htransport _ _ _ _ + (abs_corr_uniform_mixture_le (pathMixtureCNF C b σ P K) b G + (pathMixtureCNF_widthAtMost C b σ P K hb hK)) + · have hz : ∀ x : Cube (Live σ), pathTerm (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) P = 0 := + pathTerm_zero_of_incompatible C b σ P hc + simp [hc, hz] + +def pathLayer (C : I → Clause V) (b : ℕ) (σ : Restriction V) + (K : CNF (Live σ)) (n : ℕ) (x : Cube (Live σ)) : ℝ := + indicator (K.eval x) * + ∑ P ∈ paths (fun i => (C i).scope) (liveSet σ) b n, + pathTerm (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) P + +theorem abs_corr_pathLayer_le (C : I → Clause V) (hn : ∀ i, (C i).Normalized) + (b : ℕ) (hb : 1 ≤ b) (σ : Restriction V) (K : CNF (Live σ)) + (hK : K.WidthAtMost b) (n : ℕ) (G : Cube (Live σ) → ℝ) : + |finiteAvg (fun x => G x * pathLayer C b σ K n x)| ≤ + pathCost C b σ n * corr b G := by + have hlin : finiteAvg (fun x => G x * pathLayer C b σ K n x) = + ∑ P ∈ paths (fun i => (C i).scope) (liveSet σ) b n, + finiteAvg (fun x => G x * (indicator (K.eval x) * + pathTerm (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) P)) := by + calc + _ = finiteAvg (fun x => + ∑ P ∈ paths (fun i => (C i).scope) (liveSet σ) b n, + G x * (indicator (K.eval x) * + pathTerm (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) P)) := by + apply finiteAvg_congr + intro x + simp only [pathLayer, Finset.mul_sum] + _ = _ := finiteAvg_sum _ _ + rw [hlin] + calc + _ ≤ ∑ P ∈ paths (fun i => (C i).scope) (liveSet σ) b n, + |finiteAvg (fun x => G x * (indicator (K.eval x) * + pathTerm (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) P))| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ P ∈ paths (fun i => (C i).scope) (liveSet σ) b n, + (if pathCompatible C σ P then pathWeight C σ P else 0) * corr b G := by + apply Finset.sum_le_sum + intro P hP + exact abs_corr_pathTerm_le C b σ hP (fun i _ => hn i) hb K hK G + _ = _ := by rw [← Finset.sum_mul]; rfl + +theorem indexedCNF_restriction_expansion (C : I → Clause V) (b : ℕ) + (σ : Restriction V) (x : Cube (Live σ)) : + indicator ((indexedCNF C).eval (fill σ x)) = + indicator ((easyBaseCNF C b σ).eval x) + + ∑ j ∈ Finset.range ((liveSet σ).card / (b + 1)), + (-1 : ℝ) ^ (j + 1) * pathLayer C b σ (easyBaseCNF C b σ) (j + 1) x := by + have h := finite_violation_expansion (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) + rw [← indexedCNF_eval_indicator C (fill σ x), + ← easyBaseCNF_eval_indicator C b σ x] at h + rw [h, mul_add, mul_one, Finset.mul_sum] + congr 1 + apply Finset.sum_congr rfl + intro j hj + simp only [pathLayer] + ring + +theorem initial_and_live_path_cost_le (C : I → Clause V) (b : ℕ) + (σ : Restriction V) : + 1 + (∑ j ∈ Finset.range ((liveSet σ).card / (b + 1)), pathCost C b σ (j + 1)) ≤ + restrictionCost C b σ := by + have hc : (liveSet σ).card / (b + 1) + 1 ≤ Fintype.card V / (b + 1) + 1 := + Nat.add_le_add_right (Nat.div_le_div_right (Finset.card_le_univ (liveSet σ))) 1 + calc + _ = ∑ j ∈ Finset.range ((liveSet σ).card / (b + 1) + 1), pathCost C b σ j := by + rw [Finset.sum_range_succ'] + simp only [pathCost_zero] + ring + _ ≤ _ := Finset.sum_le_sum_of_subset_of_nonneg (Finset.range_mono hc) + (fun j _ _ => pathCost_nonneg C b σ j) + +theorem restricted_correlation_le_cost (C : I → Clause V) + (b : ℕ) (hb : 1 ≤ b) (hn : ∀ i, (C i).Normalized) + (σ : Restriction V) (G : Cube (Live σ) → ℝ) : + |finiteAvg (fun x => G x * indicator ((indexedCNF C).eval (fill σ x)))| ≤ + restrictionCost C b σ * corr b G := by + let K := easyBaseCNF C b σ + let L := (liveSet σ).card / (b + 1) + have hlin : finiteAvg (fun x => G x * indicator ((indexedCNF C).eval (fill σ x))) = + finiteAvg (fun x => G x * indicator (K.eval x)) + + ∑ j ∈ Finset.range L, (-1 : ℝ) ^ (j + 1) * + finiteAvg (fun x => G x * pathLayer C b σ K (j + 1) x) := by + calc + _ = finiteAvg (fun x => G x * indicator (K.eval x) + + ∑ j ∈ Finset.range L, (-1 : ℝ) ^ (j + 1) * + (G x * pathLayer C b σ K (j + 1) x)) := by + apply finiteAvg_congr + intro x + rw [indexedCNF_restriction_expansion, mul_add, Finset.mul_sum] + congr 1 + apply Finset.sum_congr rfl + intro j hj + ring + _ = _ := by + rw [finiteAvg_add, finiteAvg_sum] + congr 1 + apply Finset.sum_congr rfl + intro j hj + exact finiteAvg_const_mul _ _ + rw [hlin] + calc + _ ≤ |finiteAvg (fun x => G x * indicator (K.eval x))| + + |∑ j ∈ Finset.range L, (-1 : ℝ) ^ (j + 1) * + finiteAvg (fun x => G x * pathLayer C b σ K (j + 1) x)| := abs_add_le _ _ + _ ≤ corr b G + ∑ j ∈ Finset.range L, + |(-1 : ℝ) ^ (j + 1) * + finiteAvg (fun x => G x * pathLayer C b σ K (j + 1) x)| := by + have htransport (inst₁ inst₂ : Fintype (Cube (Live σ))) + (f : Cube (Live σ) → ℝ) (c : ℝ) + (h : |@finiteAvg _ inst₁ f| ≤ c) : |@finiteAvg _ inst₂ f| ≤ c := by + have hi : inst₁ = inst₂ := Subsingleton.elim _ _ + cases hi + exact h + apply add_le_add + · exact htransport _ _ _ _ (abs_corr_le b G K (easyBaseCNF_widthAtMost C b σ)) + · exact Finset.abs_sum_le_sum_abs _ _ + _ ≤ corr b G + ∑ j ∈ Finset.range L, pathCost C b σ (j + 1) * corr b G := by + apply add_le_add_right + apply Finset.sum_le_sum + intro j hj + simpa only [abs_mul, abs_pow, abs_neg, abs_one, one_pow, one_mul] using + abs_corr_pathLayer_le C hn b hb σ K (easyBaseCNF_widthAtMost C b σ) (j + 1) G + _ = (1 + ∑ j ∈ Finset.range L, pathCost C b σ (j + 1)) * corr b G := by + rw [← Finset.sum_mul] + ring + _ ≤ restrictionCost C b σ * corr b G := + mul_le_mul_of_nonneg_right (initial_and_live_path_cost_le C b σ) (corr_nonneg b G) + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionCountSplit.lean b/lean/OAI/Computability/DepthThree/RestrictionCountSplit.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3cd7de59b3ba27e4c6c69d444b092deb8826af8 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionCountSplit.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DepthThree.RestrictionExpansion + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open scoped Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} {I : Type uDepth2} [instFintypeI : Fintype I] + +def intermediateIndices (scope : I → Finset V) (T : Finset V) (b : ℕ) + (U : Finset V) : Finset I := + Finset.univ.filter fun i => + 0 < (residual scope T U i).card ∧ (residual scope T U i).card ≤ b + +@[simp] theorem mem_intermediateIndices (scope : I → Finset V) (T : Finset V) + (b : ℕ) (U : Finset V) (i : I) : + i ∈ intermediateIndices scope T b U ↔ + 0 < (residual scope T U i).card ∧ (residual scope T U i).card ≤ b := by + simp [intermediateIndices] + +def intermediateCount (scope : I → Finset V) (T : Finset V) (b : ℕ) + (violation : I → Bool) (U : Finset V) : ℕ := + ((intermediateIndices scope T b U).filter fun i => violation i = true).card + +theorem easyCount_eq_covered_add_intermediate (scope : I → Finset V) + (T : Finset V) (b : ℕ) (violation : I → Bool) (U : Finset V) : + easyCount scope T b violation U = coveredCount scope T violation U + + intermediateCount scope T b violation U := by + let covered : Finset I := Finset.univ.filter fun i => + residual scope T U i = ∅ ∧ violation i = true + let middle := (intermediateIndices scope T b U).filter fun i => violation i = true + have hd : Disjoint covered middle := by + apply Finset.disjoint_left.mpr + intro i hi hj + have he : residual scope T U i = ∅ := (Finset.mem_filter.mp hi).2.1 + have hp : 0 < (residual scope T U i).card := + ((mem_intermediateIndices scope T b U i).mp (Finset.mem_filter.mp hj).1).1 + rw [he, Finset.card_empty] at hp + exact Nat.not_lt_zero _ hp + have hu : (Finset.univ.filter fun i => + (residual scope T U i).card ≤ b ∧ violation i = true) = covered ∪ middle := by + ext i + simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_union, + covered, middle, mem_intermediateIndices] + constructor + · rintro ⟨hle, hv⟩ + by_cases he : residual scope T U i = ∅ + · exact Or.inl ⟨he, hv⟩ + · have hp : 0 < (residual scope T U i).card := + Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr he) + exact Or.inr ⟨⟨hp, hle⟩, hv⟩ + · rintro (⟨he, hv⟩ | ⟨⟨hp, hle⟩, hv⟩) + · exact ⟨by rw [he]; simp, hv⟩ + · exact ⟨hle, hv⟩ + change (Finset.univ.filter fun i => + (residual scope T U i).card ≤ b ∧ violation i = true).card = + covered.card + middle.card + rw [hu, Finset.card_union_of_disjoint hd] + +theorem subtype_filter_card + {I : Type uDepth2} + [Fintype I] + (s : Finset I) (p : I → Prop) [DecidablePred p] : + ((Finset.univ : Finset s).filter fun i => p i.val).card = (s.filter p).card := by + let a := (Finset.univ : Finset s).filter fun i => p i.val + have ha : a.image Subtype.val = s.filter p := by + ext i + constructor + · intro hi + obtain ⟨j, hj, rfl⟩ := Finset.mem_image.mp hi + exact Finset.mem_filter.mpr ⟨j.property, (Finset.mem_filter.mp hj).2⟩ + · intro hi + obtain ⟨his, hip⟩ := Finset.mem_filter.mp hi + exact Finset.mem_image.mpr ⟨⟨i, his⟩, by simp [a, hip], rfl⟩ + rw [← ha] + exact (Finset.card_image_of_injective a Subtype.val_injective).symm + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionCylinders.lean b/lean/OAI/Computability/DepthThree/RestrictionCylinders.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d7ea5315ed9b0173c0d3b052b78f7db9255446e --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionCylinders.lean @@ -0,0 +1,179 @@ +import OAI.Computability.DepthThree.RestrictionClause +import OAI.Computability.DepthThree.RestrictionExpansion + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} {I : Type uDepth2} [instDecidableEqV : DecidableEq V] [instDecidableEqI : DecidableEq I] [instFintypeI : Fintype I] + +theorem Clause.eval_eq_of_scope_agree + {V : Type uDepth1} + [DecidableEq V] + (C : Clause V) (x y : Cube V) + (h : ∀ v ∈ C.scope, x v = y v) : C.eval x = C.eval y := by + classical + let : DecidableEq V := Classical.decEq _ + apply Bool.eq_iff_iff.mpr + rw [Clause.eval_eq_true, Clause.eval_eq_true] + constructor + · rintro ⟨l, hl, hx⟩ + exact ⟨l, hl, (h l.1 (Finset.mem_image_of_mem Prod.fst hl)).symm.trans hx⟩ + · rintro ⟨l, hl, hy⟩ + exact ⟨l, hl, (h l.1 (Finset.mem_image_of_mem Prod.fst hl)).trans hy⟩ + +theorem Clause.violation_eq_of_scope_agree (C : Clause V) (x y : Cube V) + (h : ∀ v ∈ C.scope, x v = y v) : C.violation x = C.violation y := by + unfold Clause.violation + rw [Clause.eval_eq_of_scope_agree C x y h] + +theorem simultaneous_violation_iff_cylinder + {V : Type uDepth1} + {I : Type uDepth2} + [instDecidableEqV : DecidableEq V] + [instDecidableEqI : DecidableEq I] + [Fintype I] + (C : I → Clause V) (T : Finset V) (P : List I) (x y : Cube V) + (hn : ∀ i ∈ P, (C i).Normalized) + (hy : ∀ i ∈ P, (C i).violation y = true) + (hout : ∀ v ∉ T, x v = y v) : + (∀ i ∈ P, (C i).violation x = true) ↔ + ∀ v ∈ revealed (fun i => (C i).scope) T P, x v = y v := by + constructor + · intro hx v hv + obtain ⟨i, hi, hvi, hvt⟩ := (mem_revealed (fun i => (C i).scope) T P v).mp hv + have hxv := (Clause.violation_eq_true_iff_forbidden (hn i hi) x).mp + (hx i hi) v hvi + have hyv := (Clause.violation_eq_true_iff_forbidden (hn i hi) y).mp + (hy i hi) v hvi + exact hxv.trans hyv.symm + · intro hxy i hi + apply (Clause.violation_eq_true_iff_forbidden (hn i hi) x).mpr + intro v hv + have hsame : x v = y v := by + by_cases ht : v ∈ T + · exact hxy v ((mem_revealed (fun i => (C i).scope) T P v).mpr + ⟨i, hi, hv, ht⟩) + · exact hout v ht + exact hsame.trans ((Clause.violation_eq_true_iff_forbidden (hn i hi) y).mp + (hy i hi) v hv) + +theorem violation_eq_of_covered + {V : Type uDepth1} + {I : Type uDepth2} + [instDecidableEqV : DecidableEq V] + [DecidableEq I] + [Fintype I] + (C : I → Clause V) (T U : Finset V) (x y : Cube V) (i : I) + (hc : residual (fun i => (C i).scope) T U i = ∅) + (hU : ∀ v ∈ U, x v = y v) (hout : ∀ v ∉ T, x v = y v) : + (C i).violation x = (C i).violation y := by + apply Clause.violation_eq_of_scope_agree + intro v hv + by_cases ht : v ∈ T + · have hu : v ∈ U := by + by_contra hu + have hm : v ∈ residual (fun i => (C i).scope) T U i := by + simp [residual, hv, ht, hu] + rw [hc] at hm + exact Finset.notMem_empty v hm + exact hU v hu + · exact hout v ht + +theorem coveredCount_eq_of_agree + (C : I → Clause V) (T U : Finset V) (x y : Cube V) + (hU : ∀ v ∈ U, x v = y v) (hout : ∀ v ∉ T, x v = y v) : + coveredCount (fun i => (C i).scope) T (fun i => (C i).violation x) U = + coveredCount (fun i => (C i).scope) T (fun i => (C i).violation y) U := by + unfold coveredCount + congr 1 + ext i + simp only [Finset.mem_filter, Finset.mem_univ, true_and] + constructor + · rintro ⟨hc, hv⟩ + exact ⟨hc, (violation_eq_of_covered C T U x y i hc hU hout).symm.trans hv⟩ + · rintro ⟨hc, hv⟩ + exact ⟨hc, (violation_eq_of_covered C T U x y i hc hU hout).trans hv⟩ + +theorem coveredCount_eq_on_larger_cylinder + (C : I → Clause V) (T U Z : Finset V) (x y : Cube V) (hUZ : U ⊆ Z) + (hZ : ∀ v ∈ Z, x v = y v) (hout : ∀ v ∉ T, x v = y v) : + coveredCount (fun i => (C i).scope) T (fun i => (C i).violation x) U = + coveredCount (fun i => (C i).scope) T (fun i => (C i).violation y) U := + coveredCount_eq_of_agree C T U x y (fun v hv => hZ v (hUZ hv)) hout + +def cylinderCNF (U : Finset V) (pattern : Cube V) : CNF V := + U.toList.map fun v => ({(v, pattern v)} : Clause V) + +@[simp] theorem cylinderCNF_eval_eq_true + {V : Type uDepth1} + [DecidableEq V] + (U : Finset V) (pattern x : Cube V) : + (cylinderCNF U pattern).eval x = true ↔ ∀ v ∈ U, x v = pattern v := by + classical + simp [cylinderCNF, CNF.eval_eq_true] + +theorem cylinderCNF_eval (U : Finset V) (pattern x : Cube V) : + (cylinderCNF U pattern).eval x = decide (∀ v ∈ U, x v = pattern v) := by + classical + apply Bool.eq_iff_iff.mpr + simp only [cylinderCNF_eval_eq_true, decide_eq_true_eq] + +theorem cylinderCNF_widthAtMost + {V : Type uDepth1} + [DecidableEq V] + (U : Finset V) (pattern : Cube V) + {b : ℕ} (hb : 1 ≤ b) : (cylinderCNF U pattern).WidthAtMost b := by + intro C hC + obtain ⟨v, hv, rfl⟩ := List.mem_map.mp hC + simpa [Clause.width, Clause.scope] using hb + +theorem cylinderCNF_normalized + {V : Type uDepth1} + [DecidableEq V] + (U : Finset V) (pattern : Cube V) : + (cylinderCNF U pattern).Normalized := by + intro C hC + obtain ⟨v, hv, rfl⟩ := List.mem_map.mp hC + intro w hf ht + have hf' : (w, false) = (v, pattern v) := Finset.mem_singleton.mp hf + have ht' : (w, true) = (v, pattern v) := Finset.mem_singleton.mp ht + have : (false : Bool) = true := congrArg Prod.snd (hf'.trans ht'.symm) + cases this + +section ActualRestriction + +variable [instFintypeV : Fintype V] + +theorem fill_agree_outside_live + {V : Type uDepth1} + [DecidableEq V] + [Fintype V] + (σ : Restriction V) (x y : Cube (Live σ)) + (v : V) (hv : σ v ≠ none) : fill σ x v = fill σ y v := by + simp [fill, hv] + +theorem simultaneous_restricted_violation_iff + (C : I → Clause V) (σ : Restriction V) (T : Finset V) + (hT : ∀ v, v ∈ T ↔ σ v = none) (P : List I) + (x y : Cube (Live σ)) (hn : ∀ i ∈ P, (C i).Normalized) + (hy : ∀ i ∈ P, (C i).violation (fill σ y) = true) : + (∀ i ∈ P, (C i).violation (fill σ x) = true) ↔ + ∀ v ∈ revealed (fun i => (C i).scope) T P, fill σ x v = fill σ y v := by + apply simultaneous_violation_iff_cylinder C T P (fill σ x) (fill σ y) hn hy + intro v hv + apply fill_agree_outside_live + intro he + exact hv ((hT v).mpr he) + +end ActualRestriction + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionEasyBase.lean b/lean/OAI/Computability/DepthThree/RestrictionEasyBase.lean new file mode 100644 index 0000000000000000000000000000000000000000..3dcd7110856a94fc7080359a3604b667f8e999d9 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionEasyBase.lean @@ -0,0 +1,158 @@ +import OAI.Computability.DepthThree.RestrictionPathData +import OAI.Computability.DepthThree.RestrictionMarkerCNF + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} {I : Type uDepth2} [instFintypeV : Fintype V] [instFintypeI : Fintype I] + +def indexedCNF (C : I → Clause V) : CNF V := + (Finset.univ : Finset I).toList.map C + +@[simp] theorem indexedCNF_eval_eq_true + {V : Type uDepth1} + {I : Type uDepth2} + [Fintype V] + [instFintypeI : Fintype I] + (C : I → Clause V) (x : Cube V) : + (indexedCNF C).eval x = true ↔ ∀ i, (C i).eval x = true := by + simp [indexedCNF, CNF.eval_eq_true] + +theorem clauseViolationCount_zero_iff + {V : Type uDepth1} + {I : Type uDepth2} + [Fintype V] + [Fintype I] + (C : I → Clause V) (x : Cube V) (S : Finset I) : + (S.filter (fun i => (C i).violation x = true)).card = 0 ↔ + ∀ i ∈ S, (C i).eval x = true := by + rw [Finset.card_eq_zero, Finset.filter_eq_empty_iff] + constructor + · intro h i hi + have hn := h hi + cases he : (C i).eval x + · exact (hn ((Clause.violation_eq_true (C i) x).mpr he)).elim + · rfl + · intro h i hi hv + have ht := h i hi + have hf := (Clause.violation_eq_true (C i) x).mp hv + rw [ht] at hf + cases hf + +theorem indexedCNF_eval_indicator (C : I → Clause V) (x : Cube V) : + indicator ((indexedCNF C).eval x) = + if totalCount (fun i => (C i).violation x) = 0 then (1 : ℝ) else 0 := by + have he : (indexedCNF C).eval x = true ↔ totalCount (fun i => (C i).violation x) = 0 := by + rw [indexedCNF_eval_eq_true] + simp [totalCount] + unfold indicator + congr 1 + exact propext he + +def easyBaseIndices (C : I → Clause V) (b : ℕ) (σ : Restriction V) : Finset I := + Finset.univ.filter fun i => ((C i).scope ∩ liveSet σ).card ≤ b + +def easyBaseClause (C : I → Clause V) (σ : Restriction V) (i : I) : + Option (Clause (Live σ)) := + keptRestrictedClause σ (liveSet σ) (fill σ (fun _ => false)) (C i) + +theorem easyBaseClause_eval + {V : Type uDepth1} + {I : Type uDepth2} + [instFintypeV : Fintype V] + [Fintype I] + (C : I → Clause V) (σ : Restriction V) (i : I) + (x : Cube (Live σ)) : + residualClauseEval (easyBaseClause C σ i) x = (C i).eval (fill σ x) := by + apply keptRestrictedClause_eval + intro v hv + apply fill_agree_outside_live + intro hσ + exact hv (by simp [liveSet, hσ]) + +def easyBaseCNF (C : I → Clause V) (b : ℕ) (σ : Restriction V) : CNF (Live σ) := + residualCNF ((easyBaseIndices C b σ).toList.map (easyBaseClause C σ)) + +theorem easyBaseCNF_widthAtMost (C : I → Clause V) (b : ℕ) (σ : Restriction V) : + (easyBaseCNF C b σ).WidthAtMost b := by + apply residualCNF_widthAtMost + intro D hD + obtain ⟨i, hi, hiD⟩ := List.mem_map.mp hD + have hi' : i ∈ easyBaseIndices C b σ := by simpa using hi + have hb : ((C i).scope ∩ liveSet σ).card ≤ b := (Finset.mem_filter.mp hi').2 + exact (keptRestrictedClause_width_le hiD).trans hb + +theorem easyBaseCNF_eval_iff_all (C : I → Clause V) (b : ℕ) (σ : Restriction V) + (x : Cube (Live σ)) : + (easyBaseCNF C b σ).eval x = true ↔ + ∀ i ∈ easyBaseIndices C b σ, (C i).eval (fill σ x) = true := by + change (residualCNF ((easyBaseIndices C b σ).toList.map (easyBaseClause C σ))).eval x = true ↔ _ + rw [residualCNF_eval_eq_true] + constructor + · intro h i hi + have hm : easyBaseClause C σ i ∈ + (easyBaseIndices C b σ).toList.map (easyBaseClause C σ) := + List.mem_map.mpr ⟨i, by simpa using hi, rfl⟩ + have hx := h _ hm + rwa [easyBaseClause_eval] at hx + · intro h D hD + obtain ⟨i, hi, rfl⟩ := List.mem_map.mp hD + rw [easyBaseClause_eval] + exact h i (by simpa using hi) + +theorem easyBaseCNF_eval_eq_true (C : I → Clause V) (b : ℕ) (σ : Restriction V) + (x : Cube (Live σ)) : + (easyBaseCNF C b σ).eval x = true ↔ + easyCount (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) ∅ = 0 := by + rw [easyBaseCNF_eval_iff_all] + simp [easyCount, easyBaseIndices, residual] + +theorem easyBaseCNF_eval_indicator (C : I → Clause V) (b : ℕ) (σ : Restriction V) + (x : Cube (Live σ)) : + indicator ((easyBaseCNF C b σ).eval x) = + if easyCount (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) ∅ = 0 then (1 : ℝ) else 0 := by + unfold indicator + congr 1 + exact propext (easyBaseCNF_eval_eq_true C b σ x) + +def cnfIndexFamily (H : CNF V) (i : Fin H.length) : Clause V := H.get i + +theorem cnfIndexFamily_normalized + {V : Type uDepth1} + [Fintype V] + {H : CNF V} (hH : H.Normalized) + (i : Fin H.length) : (cnfIndexFamily H i).Normalized := + hH _ (List.get_mem H i) + +theorem cnfIndexFamily_width + {V : Type uDepth1} + [Fintype V] + {H : CNF V} {k : ℕ} (hH : H.WidthAtMost k) + (i : Fin H.length) : (cnfIndexFamily H i).width ≤ k := + hH _ (List.get_mem H i) + +@[simp] theorem indexedCNF_cnfIndexFamily_eval (H : CNF V) (x : Cube V) : + (indexedCNF (cnfIndexFamily H)).eval x = H.eval x := by + apply Bool.eq_iff_iff.mpr + rw [indexedCNF_eval_eq_true, CNF.eval_eq_true] + constructor + · intro h C hC + obtain ⟨i, rfl⟩ := List.mem_iff_get.mp hC + exact h i + · intro h i + exact h _ (List.get_mem H i) + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionExpansion.lean b/lean/OAI/Computability/DepthThree/RestrictionExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..fad0b1ca473abc4b0003ce060b14a62c2d04e572 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionExpansion.lean @@ -0,0 +1,336 @@ +import OAI.Computability.DepthThree.RestrictionPaths +import Mathlib.Data.List.Induction +import Mathlib.Basic.Real.Basic +import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise +import Mathlib.Algebra.BigOperators.Field +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Ring +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Linarith + +namespace OAI + +noncomputable section + +open Finset +open scoped BigOperators + +namespace DepthThreeLowerBound + +universe u v + +variable {V : Type u} {I : Type v} [DecidableEq V] [instDecidableEqI : DecidableEq I] [instFintypeI : Fintype I] + +def violationValue (violation : I → Bool) (i : I) : ℝ := + if violation i = true then 1 else 0 + +def totalCount (violation : I → Bool) : ℕ := + (univ.filter fun i => violation i = true).card + +def easyCount (scope : I → Finset V) (T : Finset V) (b : ℕ) + (violation : I → Bool) (U : Finset V) : ℕ := + (univ.filter fun i => (residual scope T U i).card ≤ b ∧ violation i = true).card + +def coveredCount (scope : I → Finset V) (T : Finset V) + (violation : I → Bool) (U : Finset V) : ℕ := + (univ.filter fun i => residual scope T U i = ∅ ∧ violation i = true).card + +def pathNumerator (violation : I → Bool) (P : List I) : ℝ := + (P.map (violationValue violation)).prod + +def pathDenominator (scope : I → Finset V) (T : Finset V) (b : ℕ) + (violation : I → Bool) (P : List I) : ℝ := + P.reverseRecOn 1 fun Q i d => d * (easyCount scope T b violation + (revealed scope T (Q ++ [i])) : ℝ) + +def pathTerm (scope : I → Finset V) (T : Finset V) (b : ℕ) + (violation : I → Bool) (P : List I) : ℝ := + pathNumerator violation P / pathDenominator scope T b violation P + +def pathResidual (scope : I → Finset V) (T : Finset V) (b : ℕ) + (violation : I → Bool) (P : List I) : ℝ := + P.reverseRecOn 0 fun Q i _ => pathNumerator violation (Q ++ [i]) / + ((totalCount violation : ℝ) * pathDenominator scope T b violation Q) + +@[simp] theorem pathNumerator_nil + {I : Type v} + [DecidableEq I] + [Fintype I] + (violation : I → Bool) : + pathNumerator violation [] = 1 := by simp [pathNumerator] + +@[simp] theorem pathNumerator_snoc + {I : Type v} + [DecidableEq I] + [Fintype I] + (violation : I → Bool) (P : List I) (i : I) : + pathNumerator violation (P ++ [i]) = + pathNumerator violation P * violationValue violation i := by + simp [pathNumerator] + +@[simp] theorem pathDenominator_nil (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) : pathDenominator scope T b violation [] = 1 := by + simp [pathDenominator] + +@[simp] theorem pathDenominator_snoc (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) (P : List I) (i : I) : + pathDenominator scope T b violation (P ++ [i]) = + pathDenominator scope T b violation P * + (easyCount scope T b violation (revealed scope T (P ++ [i])) : ℝ) := by + simp [pathDenominator] + +@[simp] theorem pathResidual_snoc (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) (P : List I) (i : I) : + pathResidual scope T b violation (P ++ [i]) = + pathNumerator violation (P ++ [i]) / + ((totalCount violation : ℝ) * pathDenominator scope T b violation P) := by + simp [pathResidual] + +theorem pathNumerator_ne_zero_iff + {I : Type v} + [DecidableEq I] + [Fintype I] + (violation : I → Bool) (P : List I) : + pathNumerator violation P ≠ 0 ↔ ∀ i ∈ P, violation i = true := by + induction P with + | nil => simp [pathNumerator] + | cons i P ih => + have hi : violationValue violation i ≠ 0 ↔ violation i = true := by + cases h : violation i <;> simp [violationValue, h] + simpa only [pathNumerator, List.map_cons, List.prod_cons, mul_ne_zero_iff, + List.forall_mem_cons] using and_congr hi ih + +theorem coveredCount_le_easyCount + {V : Type u} + {I : Type v} + [DecidableEq V] + [DecidableEq I] + [instFintypeI : Fintype I] + (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) (U : Finset V) : + coveredCount scope T violation U ≤ easyCount scope T b violation U := by + apply Finset.card_le_card + intro i hi + simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hi ⊢ + exact ⟨by rw [hi.1]; simp, hi.2⟩ + +theorem easyCount_le_totalCount + {V : Type u} + {I : Type v} + [DecidableEq V] + [DecidableEq I] + [instFintypeI : Fintype I] + (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) (U : Finset V) : + easyCount scope T b violation U ≤ totalCount violation := by + apply Finset.card_le_card + intro i hi + simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hi ⊢ + exact hi.2 + +theorem length_le_coveredCount_of_support (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) {n : ℕ} {P : List I} + (hP : P ∈ paths scope T b n) (hs : pathNumerator violation P ≠ 0) : + P.length ≤ coveredCount scope T violation (revealed scope T P) := by + have hnd := nodup_of_mem_paths hP + rw [← List.toFinset_card_of_nodup hnd] + apply Finset.card_le_card + intro i hi + have him : i ∈ P := List.mem_toFinset.mp hi + simp only [Finset.mem_filter, Finset.mem_univ, true_and] + exact ⟨residual_eq_empty_of_mem him, (pathNumerator_ne_zero_iff violation P).mp hs i him⟩ + +theorem easyCount_pos_of_support (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) {n : ℕ} {P : List I} + (hP : P ∈ paths scope T b (n + 1)) (hs : pathNumerator violation P ≠ 0) : + 0 < easyCount scope T b violation (revealed scope T P) := by + have h := (length_le_coveredCount_of_support scope T b violation hP hs).trans + (coveredCount_le_easyCount scope T b violation _) + rw [length_of_mem_paths hP] at h + exact (Nat.succ_pos n).trans_le h + +theorem pathDenominator_pos_of_support (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) {n : ℕ} {P : List I} + (hP : P ∈ paths scope T b n) (hs : pathNumerator violation P ≠ 0) : + 0 < pathDenominator scope T b violation P := by + induction n generalizing P with + | zero => + have he : P = [] := List.length_eq_zero_iff.mp (length_of_mem_paths hP) + subst P + simp + | succ n ih => + obtain ⟨Q, hQ, i, hi, rfl⟩ := mem_paths_succ.mp hP + have hQs : pathNumerator violation Q ≠ 0 := by + exact (mul_ne_zero_iff.mp (by simpa only [pathNumerator_snoc] using hs)).1 + rw [pathDenominator_snoc] + exact mul_pos (ih hQ hQs) + (Nat.cast_pos.mpr (easyCount_pos_of_support scope T b violation hP hs)) + +private theorem cast_count + {I : Type v} + [DecidableEq I] + [Fintype I] + (violation : I → Bool) (s : Finset I) : + ((s.filter fun i => violation i = true).card : ℝ) = + ∑ i ∈ s, violationValue violation i := by + simp [violationValue] + +theorem totalCount_eq_easy_add_hard (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) (U : Finset V) : + (totalCount violation : ℝ) = (easyCount scope T b violation U : ℝ) + + ∑ i ∈ hardIndices scope T b U, violationValue violation i := by + have h := Finset.sum_filter_add_sum_filter_not (s := (univ : Finset I)) + (p := fun i => (residual scope T U i).card ≤ b) (violationValue violation) + have heasy : (easyCount scope T b violation U : ℝ) = + ∑ i ∈ univ.filter (fun i => (residual scope T U i).card ≤ b), + violationValue violation i := by + rw [← cast_count] + simp [easyCount, Finset.filter_filter] + rw [heasy] + simpa only [totalCount, cast_count, hardIndices, not_le] using h.symm + +theorem path_residual_identity (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) {n : ℕ} {P : List I} + (hP : P ∈ paths scope T b (n + 1)) (hq : totalCount violation ≠ 0) : + pathResidual scope T b violation P = pathTerm scope T b violation P - + ∑ i ∈ hardIndices scope T b (revealed scope T P), + pathResidual scope T b violation (P ++ [i]) := by + by_cases hs : pathNumerator violation P = 0 + · obtain ⟨Q, hQ, i, hi, rfl⟩ := mem_paths_succ.mp hP + simp only [pathResidual_snoc, pathTerm, hs, zero_div, pathNumerator_snoc, + zero_mul, Finset.sum_const_zero, sub_zero] + · have hd := ne_of_gt (pathDenominator_pos_of_support scope T b violation hP hs) + have ha := ne_of_gt (Nat.cast_pos.mpr + (easyCount_pos_of_support scope T b violation hP hs) : + (0 : ℝ) < easyCount scope T b violation (revealed scope T P)) + have hqr : (totalCount violation : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr hq + have hext : (∑ i ∈ hardIndices scope T b (revealed scope T P), + pathResidual scope T b violation (P ++ [i])) = + pathNumerator violation P / + ((totalCount violation : ℝ) * pathDenominator scope T b violation P) * + ∑ i ∈ hardIndices scope T b (revealed scope T P), violationValue violation i := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + rw [pathResidual_snoc, pathNumerator_snoc] + ring + rw [hext] + have hcounts := totalCount_eq_easy_add_hard scope T b violation (revealed scope T P) + have hsum : (∑ i ∈ hardIndices scope T b (revealed scope T P), + violationValue violation i) = (totalCount violation : ℝ) - + (easyCount scope T b violation (revealed scope T P) : ℝ) := by + linarith + rw [hsum] + obtain ⟨Q, hQ, i, hi, rfl⟩ := mem_paths_succ.mp hP + have hQnum : pathNumerator violation Q ≠ 0 := + (mul_ne_zero_iff.mp (by simpa only [pathNumerator_snoc] using hs)).1 + have hQden := ne_of_gt (pathDenominator_pos_of_support scope T b violation hQ hQnum) + simp only [pathResidual_snoc, pathTerm, pathDenominator_snoc] + have halg (z q d a : ℝ) (hq' : q ≠ 0) (hd' : d ≠ 0) (ha' : a ≠ 0) : + z / (q * d) = z / (d * a) - z / (q * (d * a)) * (q - a) := by + field_simp [hq', hd', ha'] + ; ring + exact halg _ _ _ _ hqr hQden ha + +theorem sum_path_residual_identity (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) (n : ℕ) (hq : totalCount violation ≠ 0) : + (∑ P ∈ paths scope T b (n + 1), pathResidual scope T b violation P) = + (∑ P ∈ paths scope T b (n + 1), pathTerm scope T b violation P) - + ∑ P ∈ paths scope T b (n + 2), pathResidual scope T b violation P := by + calc + _ = ∑ P ∈ paths scope T b (n + 1), + (pathTerm scope T b violation P - + ∑ i ∈ hardIndices scope T b (revealed scope T P), + pathResidual scope T b violation (P ++ [i])) := by + apply Finset.sum_congr rfl + intro P hP + exact path_residual_identity scope T b violation hP hq + _ = _ := by + rw [Finset.sum_sub_distrib, + sum_paths_succ scope T b (n + 1) (pathResidual scope T b violation)] + +theorem sum_initial_residual (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) + (he : easyCount scope T b violation ∅ = 0) (hq : totalCount violation ≠ 0) : + (∑ P ∈ paths scope T b 1, pathResidual scope T b violation P) = 1 := by + have hs (i : I) : pathResidual scope T b violation [i] = + violationValue violation i / (totalCount violation : ℝ) := by + change pathResidual scope T b violation ([] ++ [i]) = _ + rw [pathResidual_snoc, pathNumerator_snoc] + simp + have hcounts := totalCount_eq_easy_add_hard scope T b violation ∅ + have hsum : (∑ i ∈ hardIndices scope T b ∅, violationValue violation i) = + (totalCount violation : ℝ) := by simpa [he] using hcounts.symm + rw [show (1 : ℕ) = 0 + 1 by rfl, sum_paths_succ] + simp only [paths, Finset.sum_singleton, revealed, List.toFinset_nil, + Finset.biUnion_empty, List.nil_append, hs] + rw [← Finset.sum_div, hsum, div_self (Nat.cast_ne_zero.mpr hq)] + +theorem finite_alternating_telescoping (t r : ℕ → ℝ) + (h : ∀ n, r (n + 1) = t (n + 1) - r (n + 2)) (N : ℕ) : + (∑ j ∈ Finset.range N, (-1 : ℝ) ^ (j + 1) * t (j + 1)) = + -r 1 + (-1 : ℝ) ^ N * r (N + 1) := by + induction N with + | zero => simp + | succ N ih => + rw [Finset.sum_range_succ, ih, h N] + simp only [pow_succ] + ring + +theorem pathTerm_zero_of_totalCount_zero (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) {n : ℕ} {P : List I} + (hP : P ∈ paths scope T b (n + 1)) (hq : totalCount violation = 0) : + pathTerm scope T b violation P = 0 := by + have hz : pathNumerator violation P = 0 := by + by_contra hs + have h := (length_le_coveredCount_of_support scope T b violation hP hs).trans + ((coveredCount_le_easyCount scope T b violation _).trans + (easyCount_le_totalCount scope T b violation _)) + rw [length_of_mem_paths hP, hq] at h + omega + simp [pathTerm, hz] + +theorem finite_violation_expansion (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) : + (if totalCount violation = 0 then (1 : ℝ) else 0) = + (if easyCount scope T b violation ∅ = 0 then (1 : ℝ) else 0) * + (1 + ∑ j ∈ Finset.range (T.card / (b + 1)), + (-1 : ℝ) ^ (j + 1) * + ∑ P ∈ paths scope T b (j + 1), pathTerm scope T b violation P) := by + by_cases he : easyCount scope T b violation ∅ = 0 + · by_cases hq : totalCount violation = 0 + · have hz (j : ℕ) : + (∑ P ∈ paths scope T b (j + 1), pathTerm scope T b violation P) = 0 := by + apply Finset.sum_eq_zero + intro P hP + exact pathTerm_zero_of_totalCount_zero scope T b violation hP hq + simp [he, hq, hz] + · let t : ℕ → ℝ := fun j => + ∑ P ∈ paths scope T b j, pathTerm scope T b violation P + let r : ℕ → ℝ := fun j => + ∑ P ∈ paths scope T b j, pathResidual scope T b violation P + have hr : ∀ n, r (n + 1) = t (n + 1) - r (n + 2) := + fun n => sum_path_residual_identity scope T b violation n hq + have hfirst : r 1 = 1 := sum_initial_residual scope T b violation he hq + have hlast : r (T.card / (b + 1) + 1) = 0 := by + dsimp [r] + rw [paths_horizon_eq_empty] + simp + have htel := finite_alternating_telescoping t r hr (T.card / (b + 1)) + rw [hfirst, hlast, mul_zero, add_zero] at htel + simp only [he, hq, ite_eq_left, ite_false, one_mul] + change 0 = 1 + ∑ j ∈ Finset.range (T.card / (b + 1)), + (-1 : ℝ) ^ (j + 1) * t (j + 1) + rw [htel] + norm_num + · have hq : totalCount violation ≠ 0 := by + intro hq + apply he + exact Nat.eq_zero_of_le_zero (hq ▸ easyCount_le_totalCount scope T b violation ∅) + simp [he, hq] + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionExpectedCost.lean b/lean/OAI/Computability/DepthThree/RestrictionExpectedCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..1cb7eac86c1b2f6de574aaf5ff8a6b2b409cc56d --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionExpectedCost.lean @@ -0,0 +1,181 @@ +import OAI.Computability.DepthThree.RestrictionPathData +import OAI.Computability.DepthThree.ReversePathEncoding +import Mathlib.Algebra.Order.Field.GeomSum + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} {I : Type uDepth2} [Fintype V] [Fintype I] + +theorem pathCoveredCount_eq_of_support (C : I → Clause V) (σ : Restriction V) + (P : List I) (x : Cube (Live σ)) + (hn : ∀ i ∈ P, (C i).Normalized) + (hx : ∀ i ∈ P, (C i).violation (fill σ x) = true) + (h : Fin P.length) : + pathCoveredCount C σ P h = + coveredCount (fun i => (C i).scope) (liveSet σ) + (fun i => (C i).violation (fill σ x)) (pathPrefixSet C σ P h) := by + have hc : pathCompatible C σ P := ⟨x, hx⟩ + have hZ : ∀ v ∈ pathFinalSet C σ P, + fill σ (pathCenter C σ P) v = fill σ x v := by + exact (simultaneous_restricted_violation_iff C σ (liveSet σ) + (fun v => mem_liveSet σ v) P (pathCenter C σ P) x hn hx).mp + (pathCenter_support C σ P hc) + unfold pathCoveredCount + apply coveredCount_eq_on_larger_cylinder C (liveSet σ) + (pathPrefixSet C σ P h) (pathFinalSet C σ P) + (fill σ (pathCenter C σ P)) (fill σ x) + (pathPrefixSet_subset_final C σ P h) hZ + intro v hv + exact fill_agree_outside_live σ (pathCenter C σ P) x v + (by simpa only [mem_liveSet] using hv) + +theorem pathWeight_eq_coveredPathWeight_of_support (C : I → Clause V) + (σ : Restriction V) (P : List I) (x : Cube (Live σ)) + (hn : ∀ i ∈ P, (C i).Normalized) + (hx : ∀ i ∈ P, (C i).violation (fill σ x) = true) : + pathWeight C σ P = coveredPathWeight (fun i => (C i).scope) (liveSet σ) + (fun i => (C i).violation (fill σ x)) P := by + unfold pathWeight coveredPathWeight + apply Finset.prod_congr rfl + intro h hh + exact congrArg (fun n : ℕ => (n : ℝ)⁻¹) + (pathCoveredCount_eq_of_support C σ P x hn hx h) + +theorem pathWeight_eq_finiteAvg_supported (C : I → Clause V) + (σ : Restriction V) (P : List I) (hn : ∀ i ∈ P, (C i).Normalized) : + (if pathCompatible C σ P then pathWeight C σ P else 0) = + finiteAvg (fun x : Cube (Live σ) => + if ∀ i ∈ P, (C i).violation (fill σ x) = true then + (2 : ℝ) ^ (pathFinalSet C σ P).card * + coveredPathWeight (fun i => (C i).scope) (liveSet σ) + (fun i => (C i).violation (fill σ x)) P + else 0) := by + by_cases hc : pathCompatible C σ P + · rw [ite_eq_left hc] + symm + calc + _ = finiteAvg (fun x : Cube (Live σ) => + ((2 : ℝ) ^ (pathFinalSet C σ P).card * pathWeight C σ P) * + indicator (decide (∀ i ∈ P, (C i).violation (fill σ x) = true))) := by + apply finiteAvg_congr + intro x + by_cases hx : ∀ i ∈ P, (C i).violation (fill σ x) = true + · rw [ite_eq_left hx, ← pathWeight_eq_coveredPathWeight_of_support C σ P x hn hx] + rw [decide_eq_true hx, indicator_true, mul_one] + · rw [ite_eq_right hx, decide_eq_false hx, indicator_false, mul_zero] + _ = ((2 : ℝ) ^ (pathFinalSet C σ P).card * pathWeight C σ P) * + ((2 : ℝ) ^ (pathFinalSet C σ P).card)⁻¹ := by + rw [finiteAvg_const_mul, path_cylinder_probability C σ P hn hc] + _ = pathWeight C σ P := by + have htwo : (2 : ℝ) ^ (pathFinalSet C σ P).card ≠ 0 := + pow_ne_zero _ (by norm_num) + calc + _ = pathWeight C σ P * + ((2 : ℝ) ^ (pathFinalSet C σ P).card * + ((2 : ℝ) ^ (pathFinalSet C σ P).card)⁻¹) := by ring + _ = _ := by rw [mul_inv_cancel₀ htwo, mul_one] + · rw [ite_eq_right hc] + symm + calc + _ = finiteAvg (fun _ : Cube (Live σ) => (0 : ℝ)) := by + apply finiteAvg_congr + intro x + have hx : ¬ ∀ i ∈ P, (C i).violation (fill σ x) = true := + fun hx => hc ⟨x, hx⟩ + simp only [ite_eq_right hx] + _ = 0 := finiteAvg_zero + +def fullAssignmentPathCost (C : I → Clause V) (b : ℕ) (σ : Restriction V) + (j : ℕ) (y : Cube V) : ℝ := + ∑ P ∈ paths (fun i => (C i).scope) (liveSet σ) b j, + if ∀ i ∈ P, (C i).violation y = true then + (2 : ℝ) ^ (pathFinalSet C σ P).card * + coveredPathWeight (fun i => (C i).scope) (liveSet σ) + (fun i => (C i).violation y) P + else 0 + +theorem pathCost_eq_finiteAvg_supported (C : I → Clause V) (b : ℕ) + (σ : Restriction V) (j : ℕ) (hn : ∀ i, (C i).Normalized) : + pathCost C b σ j = finiteAvg (fun x : Cube (Live σ) => + fullAssignmentPathCost C b σ j (fill σ x)) := by + unfold pathCost fullAssignmentPathCost + rw [finiteAvg_sum] + apply Finset.sum_congr rfl + intro P hP + exact pathWeight_eq_finiteAvg_supported C σ P (fun i _ => hn i) + +theorem restrictionAvg_pathCost_reweight (C : I → Clause V) (p : ℝ) + (b j : ℕ) (hn : ∀ i, (C i).Normalized) : + restrictionAvg p (fun σ => pathCost C b σ j) = + finiteAvg (fun y : Cube V => + ∑ T : Finset V, bernoulliWeight p T * + fullAssignmentPathCost C b (maskRestriction T y) j y) := by + calc + _ = restrictionAvg p (fun σ => finiteAvg (fun x : Cube (Live σ) => + fullAssignmentPathCost C b σ j (fill σ x))) := by + unfold restrictionAvg + apply Finset.sum_congr rfl + intro σ hσ + exact congrArg (fun t : ℝ => restrictionWeight p σ * t) + (pathCost_eq_finiteAvg_supported C b σ j hn) + _ = _ := restrictionAvg_fill_reweight p + (fun σ y => fullAssignmentPathCost C b σ j y) + +theorem restrictionAvg_pathCost_le (C : I → Clause V) (p : ℝ) + (hp0 : 0 < p) (hp1 : p < 1) (b k j : ℕ) + (hn : ∀ i, (C i).Normalized) (hwidth : ∀ i, (C i).scope.card ≤ k) : + restrictionAvg p (fun σ => pathCost C b σ j) ≤ + (reverseTheta (2 * p / (1 - p)) b k) ^ j := by + rw [restrictionAvg_pathCost_reweight C p b j hn] + calc + _ ≤ finiteAvg (fun _ : Cube V => (reverseTheta (2 * p / (1 - p)) b k) ^ j) := by + apply finiteAvg_mono + intro y + simpa only [fullAssignmentPathCost, pathFinalSet, liveSet_maskRestriction] + using weighted_supported_paths_le p hp0 hp1 b k (fun i => (C i).scope) + hwidth (fun i => (C i).violation y) j + _ = _ := finiteAvg_const _ + +theorem restrictionAvg_restrictionCost_le_sum (C : I → Clause V) (p : ℝ) + (hp0 : 0 < p) (hp1 : p < 1) (b k : ℕ) + (hn : ∀ i, (C i).Normalized) (hwidth : ∀ i, (C i).scope.card ≤ k) : + restrictionAvg p (fun σ => restrictionCost C b σ) ≤ + ∑ j ∈ Finset.range (Fintype.card V / (b + 1) + 1), + (reverseTheta (2 * p / (1 - p)) b k) ^ j := by + have hsum : restrictionAvg p (fun σ => restrictionCost C b σ) = + ∑ j ∈ Finset.range (Fintype.card V / (b + 1) + 1), + restrictionAvg p (fun σ => pathCost C b σ j) := by + unfold restrictionAvg restrictionCost + simp_rw [Finset.mul_sum] + exact Finset.sum_comm + rw [hsum] + exact Finset.sum_le_sum fun j hj => + restrictionAvg_pathCost_le C p hp0 hp1 b k j hn hwidth + +theorem restrictionAvg_restrictionCost_le (C : I → Clause V) (p : ℝ) + (hp0 : 0 < p) (hp1 : p < 1) (b k : ℕ) + (hn : ∀ i, (C i).Normalized) (hwidth : ∀ i, (C i).scope.card ≤ k) + (hθ : reverseTheta (2 * p / (1 - p)) b k < 1) : + restrictionAvg p (fun σ => restrictionCost C b σ) ≤ + (1 - reverseTheta (2 * p / (1 - p)) b k)⁻¹ := by + have hα : 0 ≤ 2 * p / (1 - p) := + div_nonneg (mul_nonneg (by norm_num) hp0.le) (sub_nonneg.mpr hp1.le) + have hθ0 := reverseTheta_nonneg hα b k + refine (restrictionAvg_restrictionCost_le_sum C p hp0 hp1 b k hn hwidth).trans ?_ + simpa only [Nat.Ico_zero_eq_range, pow_zero, one_div] using + (geom_sum_Ico_le_of_lt_one hθ0 hθ + (m := 0) (n := Fintype.card V / (b + 1) + 1)) + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionKeepClause.lean b/lean/OAI/Computability/DepthThree/RestrictionKeepClause.lean new file mode 100644 index 0000000000000000000000000000000000000000..13876456bfa33639c6099220366bf7a8962a8272 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionKeepClause.lean @@ -0,0 +1,122 @@ +import OAI.Computability.DepthThree.RestrictionClause + +namespace OAI + +universe uDepth1 + +noncomputable section + +open scoped Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} + +def keptLiterals (R : Finset V) (C : Clause V) : Clause V := + C.filter fun l => l.1 ∈ R + +@[simp] theorem mem_keptLiterals (R : Finset V) (C : Clause V) (l : Literal V) : + l ∈ keptLiterals R C ↔ l ∈ C ∧ l.1 ∈ R := by + simp [keptLiterals] + +theorem keptLiterals_scope (R : Finset V) (C : Clause V) : + (keptLiterals R C).scope = C.scope ∩ R := by + ext v + simp only [Clause.scope, Finset.mem_image, Finset.mem_inter, mem_keptLiterals] + constructor + · rintro ⟨l, ⟨hl, hR⟩, hv⟩ + exact ⟨⟨l, hl, hv⟩, hv ▸ hR⟩ + · rintro ⟨⟨l, hl, hv⟩, hR⟩ + exact ⟨l, ⟨hl, hv.symm ▸ hR⟩, hv⟩ + +theorem keptLiterals_width (R : Finset V) (C : Clause V) : + (keptLiterals R C).width = (C.scope ∩ R).card := by + rw [Clause.width, keptLiterals_scope] + +def keepClause (R : Finset V) (pattern : Cube V) (C : Clause V) : + Option (Clause V) := + if ∃ l ∈ C, l.1 ∉ R ∧ pattern l.1 = l.2 then none else some (keptLiterals R C) + +theorem keepClause_eval (R : Finset V) (pattern x : Cube V) (C : Clause V) + (hagree : ∀ v ∉ R, x v = pattern v) : + residualClauseEval (keepClause R pattern C) x = C.eval x := by + by_cases hs : ∃ l ∈ C, l.1 ∉ R ∧ pattern l.1 = l.2 + · simp only [keepClause, ite_eq_left hs, residualClauseEval_none] + symm + obtain ⟨l, hl, hout, hp⟩ := hs + exact (Clause.eval_eq_true C x).mpr ⟨l, hl, (hagree l.1 hout).trans hp⟩ + · simp only [keepClause, ite_eq_right hs, residualClauseEval_some] + apply Bool.eq_iff_iff.mpr + rw [Clause.eval_eq_true, Clause.eval_eq_true] + constructor + · rintro ⟨l, hl, hx⟩ + exact ⟨l, ((mem_keptLiterals R C l).mp hl).1, hx⟩ + · rintro ⟨l, hl, hx⟩ + have hR : l.1 ∈ R := by + by_cases hr : l.1 ∈ R + · exact hr + · exact (hs ⟨l, hl, hr, (hagree l.1 hr).symm.trans hx⟩).elim + exact ⟨l, (mem_keptLiterals R C l).mpr ⟨hl, hR⟩, hx⟩ + +theorem keepClause_some_eq {R : Finset V} {pattern : Cube V} + {C D : Clause V} (h : keepClause R pattern C = some D) : + D = keptLiterals R C := by + unfold keepClause at h + split at h + · cases h + · exact (Option.some.inj h).symm + +theorem keepClause_width {R : Finset V} {pattern : Cube V} + {C D : Clause V} (h : keepClause R pattern C = some D) : + D.width = (C.scope ∩ R).card := by + rw [keepClause_some_eq h, keptLiterals_width] + +theorem keepClause_normalized {R : Finset V} {pattern : Cube V} + {C D : Clause V} (hC : C.Normalized) (h : keepClause R pattern C = some D) : + D.Normalized := by + rw [keepClause_some_eq h] + exact hC.subset (Finset.filter_subset _ _) + +section Restrict + +variable [Fintype V] + +def keptRestrictedClause (σ : Restriction V) (R : Finset V) + (pattern : Cube V) (C : Clause V) : Option (Clause (Live σ)) := + (keepClause R pattern C).bind (restrictClause σ) + +theorem residualClauseEval_bind_restrict (σ : Restriction V) + (C : Option (Clause V)) (x : Cube (Live σ)) : + residualClauseEval (C.bind (restrictClause σ)) x = + residualClauseEval C (fill σ x) := by + cases C with + | none => rfl + | some C => exact restrictClause_eval σ C x + +theorem keptRestrictedClause_eval (σ : Restriction V) (R : Finset V) + (pattern : Cube V) (C : Clause V) (x : Cube (Live σ)) + (hagree : ∀ v ∉ R, fill σ x v = pattern v) : + residualClauseEval (keptRestrictedClause σ R pattern C) x = + C.eval (fill σ x) := by + rw [keptRestrictedClause, residualClauseEval_bind_restrict] + exact keepClause_eval R pattern (fill σ x) C hagree + +theorem keptRestrictedClause_width_le {σ : Restriction V} {R : Finset V} + {pattern : Cube V} {C : Clause V} {D : Clause (Live σ)} + (h : keptRestrictedClause σ R pattern C = some D) : + D.width ≤ (C.scope ∩ R).card := by + unfold keptRestrictedClause at h + cases he : keepClause R pattern C with + | none => simp [he] at h + | some E => + have hr : restrictClause σ E = some D := by simpa [he] using h + rw [← keepClause_width he] + exact restrictClause_width_le hr + +end Restrict + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionMarkerCNF.lean b/lean/OAI/Computability/DepthThree/RestrictionMarkerCNF.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc0eca5e97f793b40c9d73ba013e3e6835929874 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionMarkerCNF.lean @@ -0,0 +1,197 @@ +import OAI.Computability.DepthThree.RestrictionCylinders +import OAI.Computability.DepthThree.MarkerMixture +import Mathlib.Algebra.BigOperators.GroupWithZero.Finset +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Ring + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 + +noncomputable section + +open scoped BigOperators + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} {I : Type uDepth2} [Fintype I] [instDecidableEqI : DecidableEq I] + +theorem residualCNF_eval_eq_true (L : List (Option (Clause V))) (x : Cube V) : + (residualCNF L).eval x = true ↔ ∀ C ∈ L, residualClauseEval C x = true := by + induction L with + | nil => simp + | cons C L ih => + cases C <;> simp [ih, CNF.eval_cons] + +theorem residualCNF_widthAtMost (L : List (Option (Clause V))) {b : ℕ} + (h : ∀ C, some C ∈ L → C.width ≤ b) : (residualCNF L).WidthAtMost b := by + intro C hC + obtain ⟨D, hD, hDC⟩ := List.mem_filterMap.mp hC + change D = some C at hDC + subst D + exact h C hD + +def markerCNF (C : I → Option (Clause V)) (c : ℕ) + (π : Equiv.Perm (I ⊕ Fin c)) : CNF V := + residualCNF ((markerSelected c π).toList.map C) + +@[simp] theorem markerCNF_eval (C : I → Option (Clause V)) (c : ℕ) + (π : Equiv.Perm (I ⊕ Fin c)) (x : Cube V) : + (markerCNF C c π).eval x = + markerSample (fun i x => residualClauseEval (C i) x) c π x := by + apply Bool.eq_iff_iff.mpr + rw [markerSample_eq_true] + simp only [markerCNF, residualCNF_eval_eq_true, List.forall_mem_map, + Finset.mem_toList] + +theorem markerCNF_widthAtMost + {V : Type uDepth1} + {I : Type uDepth2} + [Fintype I] + [DecidableEq I] + (C : I → Option (Clause V)) (c : ℕ) + (π : Equiv.Perm (I ⊕ Fin c)) {b : ℕ} + (h : ∀ i D, C i = some D → D.width ≤ b) : + (markerCNF C c π).WidthAtMost b := by + apply residualCNF_widthAtMost + intro D hD + obtain ⟨i, hi, hiD⟩ := List.mem_map.mp hD + exact h i D hiD + +theorem markerCNF_avg (C : I → Option (Clause V)) {c : ℕ} (hc : 0 < c) + (x : Cube V) : + finiteAvg (fun π : Equiv.Perm (I ⊕ Fin c) => indicator ((markerCNF C c π).eval x)) = + (c : ℝ) / ((c : ℝ) + + ((markerBad (fun i x => residualClauseEval (C i) x) x).card : ℝ)) := by + simp_rw [markerCNF_eval] + exact marker_mixture_ratio _ x hc + +section Product + +variable {H : Type uDepth3} [Fintype H] [instDecidableEqH : DecidableEq H] + {J : H → Type uDepth4} [∀ h, Fintype (J h)] [insthDecidableEqJh : ∀ h, DecidableEq (J h)] + +def markerProductCNF (C : ∀ h, J h → Option (Clause V)) (c : H → ℕ) + (π : ∀ h, Equiv.Perm (J h ⊕ Fin (c h))) : CNF V := + (Finset.univ : Finset H).toList.flatMap fun h => markerCNF (C h) (c h) (π h) + +theorem markerProductCNF_eval_eq_true + {V : Type uDepth1} + {H : Type uDepth3} + [Fintype H] + [DecidableEq H] + {J : H → Type uDepth4} + [(h : H) → Fintype (J h)] + [(h : H) → DecidableEq (J h)] + (C : ∀ h, J h → Option (Clause V)) + (c : H → ℕ) (π : ∀ h, Equiv.Perm (J h ⊕ Fin (c h))) (x : Cube V) : + (markerProductCNF C c π).eval x = true ↔ + ∀ h, (markerCNF (C h) (c h) (π h)).eval x = true := by + simp only [markerProductCNF, CNF.eval_eq_true, List.forall_mem_flatMap, + Finset.mem_toList, Finset.mem_univ, forall_const] + +theorem markerProductCNF_indicator (C : ∀ h, J h → Option (Clause V)) + (c : H → ℕ) (π : ∀ h, Equiv.Perm (J h ⊕ Fin (c h))) (x : Cube V) : + indicator ((markerProductCNF C c π).eval x) = + ∏ h, indicator ((markerCNF (C h) (c h) (π h)).eval x) := by + unfold indicator + rw [Fintype.prod_boole] + congr 1 + exact propext (markerProductCNF_eval_eq_true C c π x) + +theorem markerProductCNF_widthAtMost + {V : Type uDepth1} + {H : Type uDepth3} + [Fintype H] + [DecidableEq H] + {J : H → Type uDepth4} + [(h : H) → Fintype (J h)] + [insthDecidableEqJh : (h : H) → DecidableEq (J h)] + (C : ∀ h, J h → Option (Clause V)) + (c : H → ℕ) (π : ∀ h, Equiv.Perm (J h ⊕ Fin (c h))) {b : ℕ} + (hC : ∀ h i D, C h i = some D → D.width ≤ b) : + (markerProductCNF C c π).WidthAtMost b := by + intro D hD + obtain ⟨h, hh, hD⟩ := List.mem_flatMap.mp hD + exact markerCNF_widthAtMost (C h) (c h) (π h) (hC h) D hD + +theorem markerProductCNF_avg (C : ∀ h, J h → Option (Clause V)) + (c : H → ℕ) (hc : ∀ h, 0 < c h) (x : Cube V) : + finiteAvg (fun π : ∀ h, Equiv.Perm (J h ⊕ Fin (c h)) => + indicator ((markerProductCNF C c π).eval x)) = + ∏ h, (c h : ℝ) / ((c h : ℝ) + + ((markerBad (fun i x => residualClauseEval (C h i) x) x).card : ℝ)) := by + simp_rw [markerProductCNF_indicator, markerCNF_eval] + exact marker_product_mixture_ratio (fun h i x => residualClauseEval (C h i) x) c hc x + +variable [instDecidableEqV : DecidableEq V] + +def markerCylinderCNF (K : CNF V) (U : Finset V) (pattern : Cube V) + (C : ∀ h, J h → Option (Clause V)) (c : H → ℕ) + (π : ∀ h, Equiv.Perm (J h ⊕ Fin (c h))) : CNF V := + (K ++ cylinderCNF U pattern) ++ markerProductCNF C c π + +theorem markerCylinderCNF_widthAtMost (K : CNF V) (U : Finset V) (pattern : Cube V) + (C : ∀ h, J h → Option (Clause V)) (c : H → ℕ) + (π : ∀ h, Equiv.Perm (J h ⊕ Fin (c h))) {b : ℕ} (hb : 1 ≤ b) + (hK : K.WidthAtMost b) (hC : ∀ h i D, C h i = some D → D.width ≤ b) : + (markerCylinderCNF K U pattern C c π).WidthAtMost b := by + intro D hD + rcases List.mem_append.mp hD with hD | hD + · rcases List.mem_append.mp hD with hD | hD + · exact hK D hD + · exact cylinderCNF_widthAtMost U pattern hb D hD + · exact markerProductCNF_widthAtMost C c π hC D hD + +theorem markerCylinderCNF_avg + {V : Type uDepth1} + {H : Type uDepth3} + [Fintype H] + [instDecidableEqH : DecidableEq H] + {J : H → Type uDepth4} + [(h : H) → Fintype (J h)] + [insthDecidableEqJh : (h : H) → DecidableEq (J h)] + [DecidableEq V] + (K : CNF V) (U : Finset V) (pattern x : Cube V) + (C : ∀ h, J h → Option (Clause V)) (c : H → ℕ) (hc : ∀ h, 0 < c h) : + finiteAvg (fun π : ∀ h, Equiv.Perm (J h ⊕ Fin (c h)) => + indicator ((markerCylinderCNF K U pattern C c π).eval x)) = + indicator (K.eval x) * indicator ((cylinderCNF U pattern).eval x) * + ∏ h, (c h : ℝ) / ((c h : ℝ) + + ((markerBad (fun i x => residualClauseEval (C h i) x) x).card : ℝ)) := by + simp only [markerCylinderCNF, CNF.eval_append, indicator_and] + rw [finiteAvg_const_mul, markerProductCNF_avg C c hc x] + +theorem markerCylinderCNF_scaled_avg (K : CNF V) (U : Finset V) (pattern x : Cube V) + (C : ∀ h, J h → Option (Clause V)) (c : H → ℕ) (hc : ∀ h, 0 < c h) : + (∏ h, (c h : ℝ)⁻¹) * + finiteAvg (fun π : ∀ h, Equiv.Perm (J h ⊕ Fin (c h)) => + indicator ((markerCylinderCNF K U pattern C c π).eval x)) = + indicator (K.eval x) * indicator ((cylinderCNF U pattern).eval x) * + ∏ h, ((c h : ℝ) + + ((markerBad (fun i x => residualClauseEval (C h i) x) x).card : ℝ))⁻¹ := by + rw [markerCylinderCNF_avg K U pattern x C c hc] + have hprod : (∏ h, (c h : ℝ)⁻¹) * + (∏ h, (c h : ℝ) / ((c h : ℝ) + + ((markerBad (fun i x => residualClauseEval (C h i) x) x).card : ℝ))) = + ∏ h, ((c h : ℝ) + + ((markerBad (fun i x => residualClauseEval (C h i) x) x).card : ℝ))⁻¹ := by + rw [← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro h hh + have hcn : (c h : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt (hc h)) + rw [div_eq_mul_inv, ← mul_assoc, inv_mul_cancel₀ hcn, one_mul] + calc + _ = (indicator (K.eval x) * indicator ((cylinderCNF U pattern).eval x)) * + ((∏ h, (c h : ℝ)⁻¹) * + ∏ h, (c h : ℝ) / ((c h : ℝ) + + ((markerBad (fun i x => residualClauseEval (C h i) x) x).card : ℝ))) := by ring + _ = _ := by rw [hprod] + +end Product + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionNormalization.lean b/lean/OAI/Computability/DepthThree/RestrictionNormalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..03475bedd1b705c2e180d49b07bb5198c712e920 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionNormalization.lean @@ -0,0 +1,120 @@ +import OAI.Computability.DepthThree.Core +import Mathlib.Data.List.Basic + +namespace OAI + +universe uDepth1 + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} + +namespace Clause + +theorem eval_true_of_not_normalized {C : Clause V} (h : ¬ C.Normalized) + (x : Cube V) : C.eval x = true := by + classical + apply (eval_eq_true C x).mpr + by_contra hx + apply h + intro v hf ht + cases hv : x v + · exact hx ⟨(v, false), hf, hv⟩ + · exact hx ⟨(v, true), ht, hv⟩ + +noncomputable def forbiddenValue (C : Clause V) (v : V) : Bool := by + classical + exact decide ((v, false) ∈ C) + +theorem forbiddenValue_ne_literal {C : Clause V} (hC : C.Normalized) + {l : Literal V} (hl : l ∈ C) : C.forbiddenValue l.1 ≠ l.2 := by + classical + rcases l with ⟨v, b⟩ + cases b + · simp [forbiddenValue, hl] + · have hf : (v, false) ∉ C := fun hf => hC v hf hl + simp [forbiddenValue, hf] + +theorem eval_eq_false_iff (C : Clause V) (x : Cube V) : + C.eval x = false ↔ ∀ l ∈ C, x l.1 ≠ l.2 := by + classical + constructor + · intro hx l hl he + have ht := (eval_eq_true C x).mpr ⟨l, hl, he⟩ + simp [hx] at ht + · intro hx + cases he : C.eval x + · rfl + · obtain ⟨l, hl, hxl⟩ := (eval_eq_true C x).mp he + exact (hx l hl hxl).elim + +theorem eval_eq_false_iff_forbidden {C : Clause V} (hC : C.Normalized) + (x : Cube V) : + C.eval x = false ↔ ∀ v ∈ C.scope, x v = C.forbiddenValue v := by + classical + rw [eval_eq_false_iff] + constructor + · intro hx v hv + obtain ⟨⟨w, b⟩, hl, hval⟩ := Finset.mem_image.mp hv + change w = v at hval + subst v + have hxb := hx (w, b) hl + have hfb := forbiddenValue_ne_literal hC hl + cases hxx : x w <;> cases hff : C.forbiddenValue w <;> cases b <;> + simp_all + · intro hx l hl + have hv : l.1 ∈ C.scope := Finset.mem_image_of_mem Prod.fst hl + rw [hx l.1 hv] + exact forbiddenValue_ne_literal hC hl + +noncomputable def violation (C : Clause V) (x : Cube V) : Bool := !(C.eval x) + +@[simp] theorem violation_eq_true (C : Clause V) (x : Cube V) : + C.violation x = true ↔ C.eval x = false := by + cases h : C.eval x <;> simp [violation, h] + +theorem violation_eq_true_iff_forbidden {C : Clause V} (hC : C.Normalized) + (x : Cube V) : + C.violation x = true ↔ ∀ v ∈ C.scope, x v = C.forbiddenValue v := by + rw [violation_eq_true, eval_eq_false_iff_forbidden hC] + +end Clause + +namespace CNF + +noncomputable def normalize (H : CNF V) : CNF V := by + classical + exact H.filter fun C => decide C.Normalized + +@[simp] theorem mem_normalize {H : CNF V} {C : Clause V} : + C ∈ H.normalize ↔ C ∈ H ∧ C.Normalized := by + classical + simp [normalize] + +theorem normalize_normalized (H : CNF V) : H.normalize.Normalized := by + intro C hC + exact (mem_normalize.mp hC).2 + +theorem normalize_widthAtMost {H : CNF V} {b : ℕ} (hH : H.WidthAtMost b) : + H.normalize.WidthAtMost b := by + intro C hC + exact hH C (mem_normalize.mp hC).1 + +@[simp] theorem eval_normalize (H : CNF V) (x : Cube V) : + H.normalize.eval x = H.eval x := by + classical + apply Bool.eq_iff_iff.mpr + rw [eval_eq_true, eval_eq_true] + constructor + · intro hx C hC + by_cases hn : C.Normalized + · exact hx C (mem_normalize.mpr ⟨hC, hn⟩) + · exact Clause.eval_true_of_not_normalized hn x + · intro hx C hC + exact hx C (mem_normalize.mp hC).1 + +end CNF + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionPathData.lean b/lean/OAI/Computability/DepthThree/RestrictionPathData.lean new file mode 100644 index 0000000000000000000000000000000000000000..89fe9822886d36aa2319d08625bb84e60cfcde62 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionPathData.lean @@ -0,0 +1,192 @@ +import OAI.Computability.DepthThree.RestrictionCylinders +import OAI.Computability.DepthThree.RestrictionKeepClause +import OAI.Computability.DepthThree.RestrictionProbability +import OAI.Computability.DepthThree.CylinderProbability + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} {I : Type uDepth2} [instFintypeV : Fintype V] [instFintypeI : Fintype I] + +def pathCompatible (C : I → Clause V) (σ : Restriction V) (P : List I) : Prop := + ∃ z : Cube (Live σ), ∀ i ∈ P, (C i).violation (fill σ z) = true + +def pathCenter (C : I → Clause V) (σ : Restriction V) (P : List I) : Cube (Live σ) := + if h : pathCompatible C σ P then Classical.choose h else fun _ => false + +theorem pathCenter_support + {V : Type uDepth1} + {I : Type uDepth2} + [Fintype V] + [Fintype I] + (C : I → Clause V) (σ : Restriction V) (P : List I) + (h : pathCompatible C σ P) : + ∀ i ∈ P, (C i).violation (fill σ (pathCenter C σ P)) = true := by + unfold pathCenter + rw [dite_eq_left h] + exact Classical.choose_spec h + +@[simp] theorem pathCompatible_nil + {V : Type uDepth1} + {I : Type uDepth2} + [Fintype V] + [Fintype I] + (C : I → Clause V) (σ : Restriction V) : + pathCompatible C σ [] := by + exact ⟨fun _ => false, by simp⟩ + +def pathPrefixSet (C : I → Clause V) (σ : Restriction V) (P : List I) + (h : Fin P.length) : Finset V := + revealed (fun i => (C i).scope) (liveSet σ) (P.take (h.val + 1)) + +def pathFinalSet (C : I → Clause V) (σ : Restriction V) (P : List I) : Finset V := + revealed (fun i => (C i).scope) (liveSet σ) P + +def pathLiveSet (C : I → Clause V) (σ : Restriction V) (P : List I) : + Finset (Live σ) := + Finset.univ.filter fun v => v.val ∈ pathFinalSet C σ P + +def pathCoveredCount (C : I → Clause V) (σ : Restriction V) (P : List I) + (h : Fin P.length) : ℕ := + coveredCount (fun i => (C i).scope) (liveSet σ) + (fun i => (C i).violation (fill σ (pathCenter C σ P))) (pathPrefixSet C σ P h) + +def pathWeight (C : I → Clause V) (σ : Restriction V) (P : List I) : ℝ := + ∏ h : Fin P.length, (pathCoveredCount C σ P h : ℝ)⁻¹ + +def pathCost (C : I → Clause V) (b : ℕ) (σ : Restriction V) (j : ℕ) : ℝ := + ∑ P ∈ paths (fun i => (C i).scope) (liveSet σ) b j, + if pathCompatible C σ P then pathWeight C σ P else 0 + +def restrictionCost (C : I → Clause V) (b : ℕ) (σ : Restriction V) : ℝ := + ∑ j ∈ Finset.range (Fintype.card V / (b + 1) + 1), pathCost C b σ j + +theorem pathWeight_nonneg (C : I → Clause V) (σ : Restriction V) (P : List I) : + 0 ≤ pathWeight C σ P := by + exact Finset.prod_nonneg fun h _ => inv_nonneg.mpr (Nat.cast_nonneg _) + +theorem pathCost_nonneg (C : I → Clause V) (b : ℕ) (σ : Restriction V) (j : ℕ) : + 0 ≤ pathCost C b σ j := by + apply Finset.sum_nonneg + intro P hP + split + · exact pathWeight_nonneg C σ P + · exact le_rfl + +theorem restrictionCost_nonneg (C : I → Clause V) (b : ℕ) (σ : Restriction V) : + 0 ≤ restrictionCost C b σ := + Finset.sum_nonneg fun j _ => pathCost_nonneg C b σ j + +@[simp] theorem pathWeight_nil (C : I → Clause V) (σ : Restriction V) : + pathWeight C σ [] = 1 := by simp [pathWeight] + +@[simp] theorem pathCost_zero (C : I → Clause V) (b : ℕ) (σ : Restriction V) : + pathCost C b σ 0 = 1 := by + simp [pathCost, paths_zero] + +theorem pathPrefixSet_subset_final + {V : Type uDepth1} + {I : Type uDepth2} + [instFintypeV : Fintype V] + [Fintype I] + (C : I → Clause V) (σ : Restriction V) + (P : List I) (h : Fin P.length) : + pathPrefixSet C σ P h ⊆ pathFinalSet C σ P := + revealed_mono (fun i => (C i).scope) (liveSet σ) (List.take_subset _ _) + +theorem pathCoveredCount_pos (C : I → Clause V) (b : ℕ) (σ : Restriction V) + {n : ℕ} {P : List I} + (hP : P ∈ paths (fun i => (C i).scope) (liveSet σ) b n) + (hc : pathCompatible C σ P) (h : Fin P.length) : + 0 < pathCoveredCount C σ P h := by + have hk : h.val + 1 ≤ n := by + rw [← length_of_mem_paths hP] + exact Nat.succ_le_of_lt h.isLt + have hpref := take_mem_paths (fun i => (C i).scope) (liveSet σ) b hP hk + have hs : pathNumerator + (fun i => (C i).violation (fill σ (pathCenter C σ P))) + (P.take (h.val + 1)) ≠ 0 := by + apply (pathNumerator_ne_zero_iff _ _).mpr + intro i hi + exact pathCenter_support C σ P hc i ((List.take_subset _ _) hi) + have hle := length_le_coveredCount_of_support (fun i => (C i).scope) + (liveSet σ) b (fun i => (C i).violation (fill σ (pathCenter C σ P))) hpref hs + rw [length_of_mem_paths hpref] at hle + exact (Nat.succ_pos h.val).trans_le hle + +theorem pathLiveSet_image + {V : Type uDepth1} + {I : Type uDepth2} + [instFintypeV : Fintype V] + [Fintype I] + (C : I → Clause V) (σ : Restriction V) (P : List I) : + (pathLiveSet C σ P).image Subtype.val = pathFinalSet C σ P := by + ext v + constructor + · intro hv + obtain ⟨w, hw, rfl⟩ := Finset.mem_image.mp hv + exact (Finset.mem_filter.mp hw).2 + · intro hv + have ht : v ∈ liveSet σ := revealed_subset (fun i => (C i).scope) (liveSet σ) P hv + have hσ : σ v = none := by simpa [liveSet] using ht + exact Finset.mem_image.mpr ⟨⟨v, hσ⟩, by simp [pathLiveSet, hv], rfl⟩ + +theorem pathLiveSet_card (C : I → Clause V) (σ : Restriction V) (P : List I) : + (pathLiveSet C σ P).card = (pathFinalSet C σ P).card := by + rw [← pathLiveSet_image C σ P] + exact (Finset.card_image_of_injective _ Subtype.val_injective).symm + +theorem path_support_iff_live_cylinder (C : I → Clause V) (σ : Restriction V) + (P : List I) (hn : ∀ i ∈ P, (C i).Normalized) (hc : pathCompatible C σ P) + (x : Cube (Live σ)) : + (∀ i ∈ P, (C i).violation (fill σ x) = true) ↔ + ∀ v ∈ pathLiveSet C σ P, x v = pathCenter C σ P v := by + rw [simultaneous_restricted_violation_iff C σ (liveSet σ) + (by intro v; simp [liveSet]) P x (pathCenter C σ P) hn + (pathCenter_support C σ P hc)] + constructor + · intro h v hv + have hval : v.val ∈ pathFinalSet C σ P := (Finset.mem_filter.mp hv).2 + simpa using h v.val hval + · intro h v hv + have ht : v ∈ liveSet σ := revealed_subset (fun i => (C i).scope) (liveSet σ) P hv + have hσ : σ v = none := by simpa [liveSet] using ht + have hv' : (⟨v, hσ⟩ : Live σ) ∈ pathLiveSet C σ P := by + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hv⟩ + simpa [fill, hσ] using h ⟨v, hσ⟩ hv' + +theorem path_cylinder_probability (C : I → Clause V) (σ : Restriction V) + (P : List I) (hn : ∀ i ∈ P, (C i).Normalized) (hc : pathCompatible C σ P) : + finiteAvg (fun x : Cube (Live σ) => + indicator (decide (∀ i ∈ P, (C i).violation (fill σ x) = true))) = + ((2 : ℝ) ^ (pathFinalSet C σ P).card)⁻¹ := by + simp_rw [path_support_iff_live_cylinder C σ P hn hc] + calc + _ = ((2 : ℝ) ^ (pathLiveSet C σ P).card)⁻¹ := by + have havg (inst₁ inst₂ : Fintype (Cube (Live σ))) + (f g : Cube (Live σ) → ℝ) (hfg : ∀ x, f x = g x) : + @finiteAvg _ inst₁ f = @finiteAvg _ inst₂ g := by + have hi : inst₁ = inst₂ := Subsingleton.elim _ _ + cases hi + exact @finiteAvg_congr _ inst₁ f g hfg + refine Eq.trans ?_ + (finiteAvg_indicator_eq_pattern (pathLiveSet C σ P) (pathCenter C σ P)) + apply havg + intro x + apply congrArg indicator + apply Bool.eq_iff_iff.mpr + simp only [decide_eq_true_eq] + _ = _ := by rw [pathLiveSet_card] + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionPathMixture.lean b/lean/OAI/Computability/DepthThree/RestrictionPathMixture.lean new file mode 100644 index 0000000000000000000000000000000000000000..5835d6bc3824a4ece4aea0ba6531a547e35c448c --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionPathMixture.lean @@ -0,0 +1,178 @@ +import OAI.Computability.DepthThree.RestrictionPathData +import OAI.Computability.DepthThree.RestrictionCountSplit +import OAI.Computability.DepthThree.RestrictionMarkerCNF + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} {I : Type uDepth2} [Fintype V] [Fintype I] + +def pathIntermediateIndices (C : I → Clause V) (b : ℕ) (σ : Restriction V) + (P : List I) (h : Fin P.length) : Finset I := + intermediateIndices (fun i => (C i).scope) (liveSet σ) b (pathPrefixSet C σ P h) + +abbrev PathIntermediateIndex (C : I → Clause V) (b : ℕ) (σ : Restriction V) + (P : List I) (h : Fin P.length) := ↥(pathIntermediateIndices C b σ P h) + +def pathReducedClause (C : I → Clause V) (b : ℕ) (σ : Restriction V) + (P : List I) (h : Fin P.length) (i : PathIntermediateIndex C b σ P h) : + Option (Clause (Live σ)) := + keptRestrictedClause σ (liveSet σ \ pathFinalSet C σ P) + (fill σ (pathCenter C σ P)) (C i.val) + +theorem pathReducedClause_widthAtMost (C : I → Clause V) (b : ℕ) + (σ : Restriction V) (P : List I) (h : Fin P.length) + (i : PathIntermediateIndex C b σ P h) (D : Clause (Live σ)) + (hD : pathReducedClause C b σ P h i = some D) : D.width ≤ b := by + have hd := keptRestrictedClause_width_le hD + have hs : (C i.val).scope ∩ (liveSet σ \ pathFinalSet C σ P) ⊆ + residual (fun i => (C i).scope) (liveSet σ) (pathPrefixSet C σ P h) i.val := by + intro v hv + refine Finset.mem_inter.mpr ⟨(Finset.mem_inter.mp hv).1, ?_⟩ + obtain ⟨ht, hn⟩ := Finset.mem_sdiff.mp (Finset.mem_inter.mp hv).2 + exact Finset.mem_sdiff.mpr ⟨ht, + fun hp => hn (pathPrefixSet_subset_final C σ P h hp)⟩ + have hi := (mem_intermediateIndices (fun i => (C i).scope) (liveSet σ) b + (pathPrefixSet C σ P h) i.val).mp i.property + exact hd.trans ((Finset.card_le_card hs).trans hi.2) + +theorem path_fill_agree_outside_remainder (C : I → Clause V) (σ : Restriction V) + (P : List I) (hn : ∀ i ∈ P, (C i).Normalized) (hc : pathCompatible C σ P) + (x : Cube (Live σ)) (hx : ∀ i ∈ P, (C i).violation (fill σ x) = true) : + ∀ v ∉ liveSet σ \ pathFinalSet C σ P, + fill σ x v = fill σ (pathCenter C σ P) v := by + have hZ := (simultaneous_restricted_violation_iff C σ (liveSet σ) + (by intro v; simp [liveSet]) P x (pathCenter C σ P) hn + (pathCenter_support C σ P hc)).mp hx + intro v hv + by_cases ht : v ∈ liveSet σ + · have hz : v ∈ pathFinalSet C σ P := by + by_contra hz + exact hv (Finset.mem_sdiff.mpr ⟨ht, hz⟩) + exact hZ v hz + · apply fill_agree_outside_live + intro hσ + exact ht (by simp [liveSet, hσ]) + +theorem pathReducedClause_eval_on_support (C : I → Clause V) (b : ℕ) + (σ : Restriction V) (P : List I) (hn : ∀ i ∈ P, (C i).Normalized) + (hc : pathCompatible C σ P) (x : Cube (Live σ)) + (hx : ∀ i ∈ P, (C i).violation (fill σ x) = true) + (h : Fin P.length) (i : PathIntermediateIndex C b σ P h) : + residualClauseEval (pathReducedClause C b σ P h i) x = (C i.val).eval (fill σ x) := + keptRestrictedClause_eval σ _ _ _ x + (path_fill_agree_outside_remainder C σ P hn hc x hx) + +theorem pathCoveredCount_eq_on_support (C : I → Clause V) (σ : Restriction V) + (P : List I) (hn : ∀ i ∈ P, (C i).Normalized) (hc : pathCompatible C σ P) + (x : Cube (Live σ)) (hx : ∀ i ∈ P, (C i).violation (fill σ x) = true) + (h : Fin P.length) : + coveredCount (fun i => (C i).scope) (liveSet σ) + (fun i => (C i).violation (fill σ x)) (pathPrefixSet C σ P h) = + pathCoveredCount C σ P h := by + have hZ := (simultaneous_restricted_violation_iff C σ (liveSet σ) + (by intro v; simp [liveSet]) P x (pathCenter C σ P) hn + (pathCenter_support C σ P hc)).mp hx + apply coveredCount_eq_on_larger_cylinder C (liveSet σ) (pathPrefixSet C σ P h) + (pathFinalSet C σ P) (fill σ x) (fill σ (pathCenter C σ P)) + (pathPrefixSet_subset_final C σ P h) hZ + intro v hv + apply fill_agree_outside_live + intro hσ + exact hv (by simp [liveSet, hσ]) + +theorem pathMarkerBad_card (C : I → Clause V) (b : ℕ) (σ : Restriction V) + (P : List I) (hn : ∀ i ∈ P, (C i).Normalized) (hc : pathCompatible C σ P) + (x : Cube (Live σ)) (hx : ∀ i ∈ P, (C i).violation (fill σ x) = true) + (h : Fin P.length) : + (markerBad (fun i z => residualClauseEval (pathReducedClause C b σ P h i) z) x).card = + intermediateCount (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) (pathPrefixSet C σ P h) := by + have he : markerBad + (fun i z => residualClauseEval (pathReducedClause C b σ P h i) z) x = + (Finset.univ : Finset (PathIntermediateIndex C b σ P h)).filter + (fun i => (C i.val).violation (fill σ x) = true) := by + ext i + simp only [markerBad, Finset.mem_filter, Finset.mem_univ, true_and] + rw [pathReducedClause_eval_on_support C b σ P hn hc x hx h i, + Clause.violation_eq_true] + rw [he] + exact subtype_filter_card (pathIntermediateIndices C b σ P h) + (fun i => (C i).violation (fill σ x) = true) + +theorem path_easyCount_eq_marker_count (C : I → Clause V) (b : ℕ) + (σ : Restriction V) (P : List I) (hn : ∀ i ∈ P, (C i).Normalized) + (hc : pathCompatible C σ P) (x : Cube (Live σ)) + (hx : ∀ i ∈ P, (C i).violation (fill σ x) = true) (h : Fin P.length) : + easyCount (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) (pathPrefixSet C σ P h) = + pathCoveredCount C σ P h + + (markerBad (fun i z => residualClauseEval (pathReducedClause C b σ P h i) z) x).card := by + rw [easyCount_eq_covered_add_intermediate, + pathCoveredCount_eq_on_support C σ P hn hc x hx h, + pathMarkerBad_card C b σ P hn hc x hx h] + +abbrev PathMarkerSample (C : I → Clause V) (b : ℕ) (σ : Restriction V) + (P : List I) := + ∀ h : Fin P.length, Equiv.Perm + (PathIntermediateIndex C b σ P h ⊕ Fin (pathCoveredCount C σ P h)) + +def pathMixtureCNF (C : I → Clause V) (b : ℕ) (σ : Restriction V) (P : List I) + (K : CNF (Live σ)) (π : PathMarkerSample C b σ P) : CNF (Live σ) := + markerCylinderCNF K (pathLiveSet C σ P) (pathCenter C σ P) + (pathReducedClause C b σ P) (pathCoveredCount C σ P) π + +theorem pathMixtureCNF_widthAtMost (C : I → Clause V) (b : ℕ) + (σ : Restriction V) (P : List I) (K : CNF (Live σ)) (hb : 1 ≤ b) + (hK : K.WidthAtMost b) (π : PathMarkerSample C b σ P) : + (pathMixtureCNF C b σ P K π).WidthAtMost b := + markerCylinderCNF_widthAtMost K _ _ _ _ π hb hK + (pathReducedClause_widthAtMost C b σ P) + +theorem pathMixture_scaled_average (C : I → Clause V) (b : ℕ) + (σ : Restriction V) {n : ℕ} {P : List I} + (hP : P ∈ paths (fun i => (C i).scope) (liveSet σ) b n) + (hn : ∀ i ∈ P, (C i).Normalized) (hc : pathCompatible C σ P) + (K : CNF (Live σ)) (x : Cube (Live σ)) : + pathWeight C σ P * + finiteAvg (fun π : PathMarkerSample C b σ P => + indicator ((pathMixtureCNF C b σ P K π).eval x)) = + indicator (K.eval x) * + (if ∀ i ∈ P, (C i).violation (fill σ x) = true then + ∏ h : Fin P.length, + (easyCount (fun i => (C i).scope) (liveSet σ) b + (fun i => (C i).violation (fill σ x)) (pathPrefixSet C σ P h) : ℝ)⁻¹ + else 0) := by + simp only [pathWeight, pathMixtureCNF] + rw [markerCylinderCNF_scaled_avg K (pathLiveSet C σ P) (pathCenter C σ P) x + (pathReducedClause C b σ P) (pathCoveredCount C σ P) + (pathCoveredCount_pos C b σ hP hc)] + by_cases hx : ∀ i ∈ P, (C i).violation (fill σ x) = true + · have hZ := (path_support_iff_live_cylinder C σ P hn hc x).mp hx + have hev : (cylinderCNF (pathLiveSet C σ P) (pathCenter C σ P)).eval x = true := + (cylinderCNF_eval_eq_true _ _ _).mpr hZ + simp only [ite_eq_left hx, hev, indicator_true, mul_one] + congr 1 + apply Finset.prod_congr rfl + intro h hh + rw [path_easyCount_eq_marker_count C b σ P hn hc x hx h, Nat.cast_add] + · have hZ : ¬ ∀ v ∈ pathLiveSet C σ P, x v = pathCenter C σ P v := + fun hz => hx ((path_support_iff_live_cylinder C σ P hn hc x).mpr hz) + have hev : (cylinderCNF (pathLiveSet C σ P) (pathCenter C σ P)).eval x = false := by + cases he : (cylinderCNF (pathLiveSet C σ P) (pathCenter C σ P)).eval x + · rfl + · exact (hZ ((cylinderCNF_eval_eq_true _ _ _).mp he)).elim + simp only [ite_eq_right hx, hev, indicator_false, mul_zero, zero_mul] + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionPathProducts.lean b/lean/OAI/Computability/DepthThree/RestrictionPathProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..0759c08f37ecf10d5c70e396c718c2f3b0546a4d --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionPathProducts.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DepthThree.RestrictionExpansion +import Mathlib.Algebra.BigOperators.Fin + +namespace OAI + +noncomputable section + +open scoped BigOperators + +namespace DepthThreeLowerBound + +universe u v + +variable {V : Type u} {I : Type v} [DecidableEq V] [DecidableEq I] [Fintype I] + +theorem pathDenominator_eq_prod_prefix (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) (P : List I) : + pathDenominator scope T b violation P = + ∏ h : Fin P.length, + (easyCount scope T b violation (revealed scope T (P.take (h.val + 1))) : ℝ) := by + induction P using List.reverseRecOn with + | nil => simp + | append_singleton P i ih => + rw [pathDenominator_snoc, ih] + rw [Fin.prod_univ_eq_prod_range + (fun h : ℕ => (easyCount scope T b violation + (revealed scope T (P.take (h + 1))) : ℝ)) P.length, + Fin.prod_univ_eq_prod_range + (fun h : ℕ => (easyCount scope T b violation + (revealed scope T ((P ++ [i]).take (h + 1))) : ℝ)) (P ++ [i]).length] + simp only [List.length_append, List.length_singleton, Finset.prod_range_succ] + have hlast : (P ++ [i]).take (P.length + 1) = P ++ [i] := + List.take_of_length_le (by simp) + rw [hlast] + congr 1 + apply Finset.prod_congr rfl + intro h hh + rw [List.take_append_of_le_length + (Nat.succ_le_of_lt (Finset.mem_range.mp hh))] + +theorem pathNumerator_eq_indicator_support (violation : I → Bool) (P : List I) : + pathNumerator violation P = if ∀ i ∈ P, violation i = true then 1 else 0 := by + classical + by_cases hs : ∀ i ∈ P, violation i = true + · rw [ite_eq_left hs] + unfold pathNumerator + apply List.prod_eq_one + intro r hr + obtain ⟨i, hi, rfl⟩ := List.mem_map.mp hr + simp [violationValue, hs i hi] + · rw [ite_eq_right hs] + by_contra hne + exact hs ((pathNumerator_ne_zero_iff violation P).mp hne) + +theorem pathTerm_eq_support_prod_inv (scope : I → Finset V) (T : Finset V) + (b : ℕ) (violation : I → Bool) (P : List I) : + pathTerm scope T b violation P = + if ∀ i ∈ P, violation i = true then + ∏ h : Fin P.length, + (easyCount scope T b violation + (revealed scope T (P.take (h.val + 1))) : ℝ)⁻¹ + else 0 := by + classical + by_cases hs : ∀ i ∈ P, violation i = true + · simp only [pathTerm, pathNumerator_eq_indicator_support, ite_eq_left hs, + pathDenominator_eq_prod_prefix, one_div, Finset.prod_inv_distrib] + · simp only [pathTerm, pathNumerator_eq_indicator_support, ite_eq_right hs, zero_div] + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionPaths.lean b/lean/OAI/Computability/DepthThree/RestrictionPaths.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d73cfdad84855a9d42e6be22a4508c315b47929 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionPaths.lean @@ -0,0 +1,250 @@ +import Mathlib.Data.Finset.Card +import Mathlib.Data.Finset.Union +import Mathlib.Data.Finset.Lattice.Lemmas +import Mathlib.Data.Fintype.Basic +import Mathlib.Data.List.Nodup +import Mathlib.Algebra.BigOperators.Group.Finset.Basic + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 + +namespace DepthThreeLowerBound + +open scoped BigOperators + +variable {V : Type uDepth1} {I : Type uDepth2} [DecidableEq V] [instDecidableEqI : DecidableEq I] + +def revealed (scope : I → Finset V) (T : Finset V) (P : List I) : Finset V := + P.toFinset.biUnion fun i => scope i ∩ T + +def residual (scope : I → Finset V) (T U : Finset V) (i : I) : Finset V := + scope i ∩ (T \ U) + +@[simp] theorem revealed_nil (scope : I → Finset V) (T : Finset V) : + revealed scope T [] = ∅ := by simp [revealed] + +theorem mem_revealed (scope : I → Finset V) (T : Finset V) (P : List I) (v : V) : + v ∈ revealed scope T P ↔ ∃ i ∈ P, v ∈ scope i ∧ v ∈ T := by + simp [revealed] + +theorem revealed_subset (scope : I → Finset V) (T : Finset V) (P : List I) : + revealed scope T P ⊆ T := by + intro v hv + obtain ⟨i, hi, hv, ht⟩ := (mem_revealed scope T P v).mp hv + exact ht + +theorem revealed_mono (scope : I → Finset V) (T : Finset V) {P Q : List I} + (h : P ⊆ Q) : revealed scope T P ⊆ revealed scope T Q := by + intro v hv + obtain ⟨i, hi, hv, ht⟩ := (mem_revealed scope T P v).mp hv + exact (mem_revealed scope T Q v).mpr ⟨i, h hi, hv, ht⟩ + +@[simp] theorem revealed_snoc (scope : I → Finset V) (T : Finset V) + (P : List I) (i : I) : + revealed scope T (P ++ [i]) = revealed scope T P ∪ (scope i ∩ T) := by + ext v + simp only [mem_revealed, List.mem_append, List.mem_singleton, + Finset.mem_union, Finset.mem_inter] + constructor + · rintro ⟨j, hj, hv⟩ + rcases hj with hj | rfl + · exact Or.inl ⟨j, hj, hv⟩ + · exact Or.inr hv + · rintro (⟨j, hj, hv⟩ | hv) + · exact ⟨j, Or.inl hj, hv⟩ + · exact ⟨i, Or.inr rfl, hv⟩ + +theorem residual_eq_sdiff + {V : Type uDepth1} + {I : Type uDepth2} + [DecidableEq V] + [DecidableEq I] + (scope : I → Finset V) (T U : Finset V) (i : I) : + residual scope T U i = (scope i ∩ T) \ U := by + ext v + simp [residual, and_assoc] + +theorem residual_eq_empty_of_mem {scope : I → Finset V} {T : Finset V} + {P : List I} {i : I} (hi : i ∈ P) : + residual scope T (revealed scope T P) i = ∅ := by + apply Finset.eq_empty_iff_forall_notMem.mpr + intro v hv + simp only [residual, Finset.mem_inter, Finset.mem_sdiff] at hv + exact hv.2.2 ((mem_revealed scope T P v).mpr ⟨i, hi, hv.1, hv.2.1⟩) + +theorem card_revealed_snoc (scope : I → Finset V) (T : Finset V) + (P : List I) (i : I) : + (revealed scope T (P ++ [i])).card = + (revealed scope T P).card + (residual scope T (revealed scope T P) i).card := by + rw [revealed_snoc, residual_eq_sdiff, Finset.union_comm] + exact (Finset.card_sdiff_add_card (scope i ∩ T) (revealed scope T P)).symm.trans + (Nat.add_comm _ _) + +variable [Fintype I] + +def hardIndices (scope : I → Finset V) (T : Finset V) (b : ℕ) (U : Finset V) : + Finset I := Finset.univ.filter fun i => b < (residual scope T U i).card + +@[simp] theorem mem_hardIndices + {V : Type uDepth1} + {I : Type uDepth2} + [DecidableEq V] + [DecidableEq I] + [Fintype I] + (scope : I → Finset V) (T : Finset V) + (b : ℕ) (U : Finset V) (i : I) : + i ∈ hardIndices scope T b U ↔ b < (residual scope T U i).card := by + simp [hardIndices] + +def paths (scope : I → Finset V) (T : Finset V) (b : ℕ) : ℕ → Finset (List I) + | 0 => {[]} + | n + 1 => (paths scope T b n).biUnion fun P => + (hardIndices scope T b (revealed scope T P)).image fun i => P ++ [i] + +@[simp] theorem paths_zero (scope : I → Finset V) (T : Finset V) (b : ℕ) : + paths scope T b 0 = {[]} := rfl + +theorem paths_succ (scope : I → Finset V) (T : Finset V) (b n : ℕ) : + paths scope T b (n + 1) = (paths scope T b n).biUnion fun P => + (hardIndices scope T b (revealed scope T P)).image fun i => P ++ [i] := rfl + +@[simp] theorem mem_paths_zero (scope : I → Finset V) (T : Finset V) + (b : ℕ) (P : List I) : P ∈ paths scope T b 0 ↔ P = [] := by + simp [paths] + +theorem mem_paths_succ {scope : I → Finset V} {T : Finset V} + {b n : ℕ} {P : List I} : + P ∈ paths scope T b (n + 1) ↔ + ∃ Q ∈ paths scope T b n, ∃ i ∈ hardIndices scope T b (revealed scope T Q), + Q ++ [i] = P := by + simp only [paths_succ, Finset.mem_biUnion, Finset.mem_image] + +theorem snoc_mem_paths (scope : I → Finset V) (T : Finset V) + (b : ℕ) {n : ℕ} {P : List I} {i : I} + (hP : P ∈ paths scope T b n) + (hi : i ∈ hardIndices scope T b (revealed scope T P)) : + P ++ [i] ∈ paths scope T b (n + 1) := + mem_paths_succ.mpr ⟨P, hP, i, hi, rfl⟩ + +theorem mem_paths_snoc_iff (scope : I → Finset V) (T : Finset V) + (b n : ℕ) (P : List I) (i : I) : + P ++ [i] ∈ paths scope T b (n + 1) ↔ + P ∈ paths scope T b n ∧ i ∈ hardIndices scope T b (revealed scope T P) := by + constructor + · intro h + obtain ⟨Q, hQ, j, hj, heq⟩ := mem_paths_succ.mp h + obtain ⟨hQP, hji⟩ := List.append_inj' heq rfl + have hji' : j = i := by simpa using hji + subst Q + subst j + exact ⟨hQ, hj⟩ + · rintro ⟨hP, hi⟩ + exact snoc_mem_paths scope T b hP hi + +theorem length_of_mem_paths {scope : I → Finset V} {T : Finset V} + {b : ℕ} {n : ℕ} {P : List I} (hP : P ∈ paths scope T b n) : + P.length = n := by + induction n generalizing P with + | zero => + have h := (mem_paths_zero scope T b P).mp hP + subst P + rfl + | succ n ih => + obtain ⟨Q, hQ, i, hi, rfl⟩ := mem_paths_succ.mp hP + simp [ih hQ] + +theorem take_mem_paths (scope : I → Finset V) (T : Finset V) + (b : ℕ) {n : ℕ} {P : List I} (hP : P ∈ paths scope T b n) + {k : ℕ} (hk : k ≤ n) : P.take k ∈ paths scope T b k := by + induction n generalizing P k with + | zero => + have hk0 : k = 0 := Nat.eq_zero_of_le_zero hk + subst k + simp + | succ n ih => + obtain ⟨Q, hQ, i, hi, rfl⟩ := mem_paths_succ.mp hP + by_cases hkn : k ≤ n + · rw [List.take_append_of_le_length (by simpa [length_of_mem_paths hQ] + using hkn)] + exact ih hQ hkn + · have hk' : k = n + 1 := by omega + subst k + rw [List.take_of_length_le (by simp [length_of_mem_paths hQ])] + exact snoc_mem_paths scope T b hQ hi + +theorem not_mem_of_hard (scope : I → Finset V) (T : Finset V) + (b : ℕ) {P : List I} {i : I} + (hi : i ∈ hardIndices scope T b (revealed scope T P)) : i ∉ P := by + intro hmem + have hh := (mem_hardIndices scope T b (revealed scope T P) i).mp hi + rw [residual_eq_empty_of_mem hmem, Finset.card_empty] at hh + exact Nat.not_lt_zero _ hh + +theorem nodup_of_mem_paths {scope : I → Finset V} {T : Finset V} + {b : ℕ} {n : ℕ} {P : List I} (hP : P ∈ paths scope T b n) : P.Nodup := by + induction n generalizing P with + | zero => + have h := (mem_paths_zero scope T b P).mp hP + subst P + simp + | succ n ih => + obtain ⟨Q, hQ, i, hi, rfl⟩ := mem_paths_succ.mp hP + exact (ih hQ).append (List.nodup_singleton i) + (List.disjoint_singleton.mpr (not_mem_of_hard scope T b hi)) + +theorem mul_le_revealed_card (scope : I → Finset V) (T : Finset V) + (b : ℕ) {n : ℕ} {P : List I} (hP : P ∈ paths scope T b n) : + n * (b + 1) ≤ (revealed scope T P).card := by + induction n generalizing P with + | zero => simp + | succ n ih => + obtain ⟨Q, hQ, i, hi, rfl⟩ := mem_paths_succ.mp hP + rw [Nat.succ_mul, card_revealed_snoc] + exact Nat.add_le_add (ih hQ) + (Nat.succ_le_of_lt ((mem_hardIndices scope T b (revealed scope T Q) i).mp hi)) + +theorem length_mul_le_revealed_card (scope : I → Finset V) (T : Finset V) + (b : ℕ) {n : ℕ} {P : List I} (hP : P ∈ paths scope T b n) : + P.length * (b + 1) ≤ (revealed scope T P).card := by + rw [length_of_mem_paths hP] + exact mul_le_revealed_card scope T b hP + +theorem paths_eq_empty_of_card_lt (scope : I → Finset V) (T : Finset V) + (b n : ℕ) (hn : T.card < n * (b + 1)) : paths scope T b n = ∅ := by + apply Finset.eq_empty_iff_forall_notMem.mpr + intro P hP + have hle := (mul_le_revealed_card scope T b hP).trans + (Finset.card_le_card (revealed_subset scope T P)) + exact (Nat.not_lt_of_ge hle) hn + +theorem paths_horizon_eq_empty (scope : I → Finset V) (T : Finset V) (b : ℕ) : + paths scope T b (T.card / (b + 1) + 1) = ∅ := by + apply paths_eq_empty_of_card_lt + exact (Nat.div_lt_iff_lt_mul (Nat.succ_pos b)).mp (Nat.lt_succ_self _) + +theorem sum_paths_succ (scope : I → Finset V) (T : Finset V) (b n : ℕ) + {M : Type uDepth3} [AddCommMonoid M] (f : List I → M) : + ∑ P ∈ paths scope T b (n + 1), f P = + ∑ P ∈ paths scope T b n, + ∑ i ∈ hardIndices scope T b (revealed scope T P), f (P ++ [i]) := by + have hd : Set.PairwiseDisjoint (↑(paths scope T b n) : Set (List I)) + (fun P => (hardIndices scope T b (revealed scope T P)).image + (fun i => P ++ [i])) := by + intro P hP Q hQ hne + apply Finset.disjoint_left.mpr + intro R hR₁ hR₂ + obtain ⟨i, hi, hiR⟩ := Finset.mem_image.mp hR₁ + obtain ⟨j, hj, hjR⟩ := Finset.mem_image.mp hR₂ + exact hne (List.append_inj_left' (hiR.trans hjR.symm) rfl) + rw [paths_succ, Finset.sum_biUnion hd] + apply Finset.sum_congr rfl + intro P hP + apply Finset.sum_image + intro i hi j hj hij + have h := List.append_inj_right' hij rfl + simpa using h + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionProbability.lean b/lean/OAI/Computability/DepthThree/RestrictionProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..26c54b6069956e285bc713161aec274040d0d3b7 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionProbability.lean @@ -0,0 +1,237 @@ +import OAI.Computability.DepthThree.FiniteProbability +import OAI.Computability.DepthThree.ReversePathWeights + +namespace OAI + +universe uDepth1 + +noncomputable section + +open scoped BigOperators + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} [instFintypeV : Fintype V] [instDecidableEqV : DecidableEq V] + +def liveSet (σ : Restriction V) : Finset V := + Finset.univ.filter (fun v => σ v = none) + +@[simp] theorem mem_liveSet + {V : Type uDepth1} + [instFintypeV : Fintype V] + [DecidableEq V] + (σ : Restriction V) (v : V) : + v ∈ liveSet σ ↔ σ v = none := by + simp [liveSet] + +def maskRestriction (T : Finset V) (y : Cube V) : Restriction V := + fun v => if v ∈ T then none else some (y v) + +@[simp] theorem maskRestriction_live + {V : Type uDepth1} + [Fintype V] + [instDecidableEqV : DecidableEq V] + (T : Finset V) (y : Cube V) (v : V) + (hv : v ∈ T) : maskRestriction T y v = none := by + simp [maskRestriction, hv] + +@[simp] theorem maskRestriction_fixed + {V : Type uDepth1} + [Fintype V] + [instDecidableEqV : DecidableEq V] + (T : Finset V) (y : Cube V) (v : V) + (hv : v ∉ T) : maskRestriction T y v = some (y v) := by + simp [maskRestriction, hv] + +@[simp] theorem liveSet_maskRestriction (T : Finset V) (y : Cube V) : + liveSet (maskRestriction T y) = T := by + ext v + by_cases hv : v ∈ T <;> simp [liveSet, maskRestriction, hv] + +@[simp] theorem fill_maskRestriction (T : Finset V) (y : Cube V) : + fill (maskRestriction T y) (fun v => y v.val) = y := by + funext v + by_cases hv : v ∈ T + · exact fill_live (maskRestriction T y) (fun w => y w.val) + ⟨v, maskRestriction_live T y v hv⟩ + · exact fill_fixed (maskRestriction T y) (fun w => y w.val) v (y v) + (maskRestriction_fixed T y v hv) + +@[simp] theorem maskRestriction_fill (σ : Restriction V) (z : Cube (Live σ)) : + maskRestriction (liveSet σ) (fill σ z) = σ := by + funext v + cases hv : σ v with + | none => simp [maskRestriction, hv] + | some b => simp [maskRestriction, hv] + +def restrictionCoordinates (s : Σ σ : Restriction V, Cube (Live σ)) : + Finset V × Cube V := + (liveSet s.1, fill s.1 s.2) + +theorem restrictionCoordinates_injective : + Function.Injective (restrictionCoordinates (V := V)) := by + rintro ⟨σ, z⟩ ⟨τ, w⟩ h + have hsets : liveSet σ = liveSet τ := congrArg Prod.fst h + have hfills : fill σ z = fill τ w := congrArg Prod.snd h + have hστ : σ = τ := by + calc + σ = maskRestriction (liveSet σ) (fill σ z) := (maskRestriction_fill σ z).symm + _ = maskRestriction (liveSet τ) (fill τ w) := by rw [hsets, hfills] + _ = τ := maskRestriction_fill τ w + subst τ + have hzw : z = w := by + funext v + simpa only [fill_live] using congrFun hfills v.val + cases hzw + rfl + +theorem restrictionCoordinates_surjective : + Function.Surjective (restrictionCoordinates (V := V)) := by + rintro ⟨T, y⟩ + refine ⟨⟨maskRestriction T y, fun v => y v.val⟩, ?_⟩ + exact Prod.ext (liveSet_maskRestriction T y) (fill_maskRestriction T y) + +def restrictionCoordinatesEquiv : + (Σ σ : Restriction V, Cube (Live σ)) ≃ (Finset V × Cube V) := + Equiv.ofBijective restrictionCoordinates + ⟨restrictionCoordinates_injective, restrictionCoordinates_surjective⟩ + +@[simp] theorem restrictionCoordinatesEquiv_apply + (s : Σ σ : Restriction V, Cube (Live σ)) : + restrictionCoordinatesEquiv s = (liveSet s.1, fill s.1 s.2) := rfl + +@[simp] theorem card_live_maskRestriction (T : Finset V) (y : Cube V) : + Fintype.card (Live (maskRestriction T y)) = T.card := by + let e : Live (maskRestriction T y) ≃ ↥T := + Equiv.subtypeEquivRight (fun v => by + by_cases hv : v ∈ T <;> simp [maskRestriction, hv]) + exact (Fintype.card_congr e).trans (Fintype.card_coe T) + +theorem restrictionWeight_maskRestriction (p : ℝ) (T : Finset V) (y : Cube V) : + restrictionWeight p (maskRestriction T y) = + p ^ T.card * ((1 - p) / 2) ^ (Fintype.card V - T.card) := by + classical + have hprodLive : + (∏ v ∈ T, restrictionCoordinateWeight p (maskRestriction T y v)) = + p ^ T.card := by + calc + _ = ∏ _v ∈ T, p := by + apply Finset.prod_congr rfl + intro v hv + simp [maskRestriction, hv, restrictionCoordinateWeight] + _ = _ := by simp + have hprodFixed : + (∏ v ∈ Tᶜ, restrictionCoordinateWeight p (maskRestriction T y v)) = + ((1 - p) / 2) ^ (Fintype.card V - T.card) := by + calc + _ = ∏ _v ∈ Tᶜ, ((1 - p) / 2) := by + apply Finset.prod_congr rfl + intro v hv + have hv' : v ∉ T := Finset.mem_compl.mp hv + simp [maskRestriction, hv', restrictionCoordinateWeight] + _ = _ := by simp only [Finset.prod_const, Finset.card_compl] + unfold restrictionWeight + rw [← Finset.prod_mul_prod_compl T + (fun v => restrictionCoordinateWeight p (maskRestriction T y v))] + rw [hprodLive, hprodFixed] + +theorem restriction_mask_joint_weight (p : ℝ) (T : Finset V) (y : Cube V) : + restrictionWeight p (maskRestriction T y) * + (Fintype.card (Cube (Live (maskRestriction T y))) : ℝ)⁻¹ = + bernoulliWeight p T * (Fintype.card (Cube V) : ℝ)⁻¹ := by + have hcLive : (Fintype.card (Cube (Live (maskRestriction T y))) : ℝ) = + (2 : ℝ) ^ T.card := by + simp [Cube] + have hcV : (Fintype.card (Cube V) : ℝ) = + (2 : ℝ) ^ Fintype.card V := by + simp [Cube] + rw [restrictionWeight_maskRestriction, hcLive, hcV] + unfold bernoulliWeight + calc + _ = (p ^ T.card * (1 - p) ^ (Fintype.card V - T.card)) * + (((2 : ℝ) ^ (Fintype.card V - T.card))⁻¹ * + ((2 : ℝ) ^ T.card)⁻¹) := by + rw [div_pow, div_eq_mul_inv] + ring + _ = _ := by + rw [← mul_inv, ← pow_add, Nat.sub_add_cancel T.card_le_univ] + +theorem restriction_fill_joint_weight (p : ℝ) (σ : Restriction V) + (z : Cube (Live σ)) : + restrictionWeight p σ * (Fintype.card (Cube (Live σ)) : ℝ)⁻¹ = + bernoulliWeight p (liveSet σ) * (Fintype.card (Cube V) : ℝ)⁻¹ := by + have h := restriction_mask_joint_weight p (liveSet σ) (fill σ z) + simpa only [maskRestriction_fill] using h + +theorem restrictionAvg_fill_coupling (p : ℝ) + (F : Restriction V → Cube V → ℝ) : + restrictionAvg p (fun σ => finiteAvg (fun z : Cube (Live σ) => F σ (fill σ z))) = + ∑ T : Finset V, bernoulliWeight p T * + finiteAvg (fun y : Cube V => F (maskRestriction T y) y) := by + classical + unfold restrictionAvg finiteAvg + calc + _ = ∑ σ : Restriction V, ∑ z : Cube (Live σ), + (restrictionWeight p σ * (Fintype.card (Cube (Live σ)) : ℝ)⁻¹) * + F σ (fill σ z) := by + refine Finset.sum_congr ?_ ?_ + · ext σ + simp only [Finset.mem_univ] + · intro σ hσ + dsimp only + rw [← mul_assoc, Finset.mul_sum] + _ = ∑ s : (Σ σ : Restriction V, Cube (Live σ)), + (restrictionWeight p s.1 * (Fintype.card (Cube (Live s.1)) : ℝ)⁻¹) * + F s.1 (fill s.1 s.2) := by + exact (Fintype.sum_sigma' + (fun (σ : Restriction V) (z : Cube (Live σ)) => + (restrictionWeight p σ * (Fintype.card (Cube (Live σ)) : ℝ)⁻¹) * + F σ (fill σ z))).symm + _ = ∑ Ty : Finset V × Cube V, + (bernoulliWeight p Ty.1 * (Fintype.card (Cube V) : ℝ)⁻¹) * + F (maskRestriction Ty.1 Ty.2) Ty.2 := by + apply Fintype.sum_equiv (restrictionCoordinatesEquiv (V := V)) + rintro ⟨σ, z⟩ + change (restrictionWeight p σ * (Fintype.card (Cube (Live σ)) : ℝ)⁻¹) * + F σ (fill σ z) = + (bernoulliWeight p (liveSet σ) * (Fintype.card (Cube V) : ℝ)⁻¹) * + F (maskRestriction (liveSet σ) (fill σ z)) (fill σ z) + rw [restriction_fill_joint_weight p σ z, maskRestriction_fill] + _ = _ := by + rw [Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro T hT + dsimp only + rw [← Finset.mul_sum] + ring + +theorem restrictionAvg_fill_reweight (p : ℝ) + (F : Restriction V → Cube V → ℝ) : + restrictionAvg p (fun σ => finiteAvg (fun z : Cube (Live σ) => F σ (fill σ z))) = + finiteAvg (fun y : Cube V => + ∑ T : Finset V, bernoulliWeight p T * F (maskRestriction T y) y) := by + rw [restrictionAvg_fill_coupling, finiteAvg_sum] + apply Finset.sum_congr rfl + intro T hT + exact (finiteAvg_const_mul (bernoulliWeight p T) + (fun y : Cube V => F (maskRestriction T y) y)).symm + +theorem restrictionAvg_fill (p : ℝ) (F : Cube V → ℝ) : + restrictionAvg p (fun σ => finiteAvg (fun z : Cube (Live σ) => F (fill σ z))) = + finiteAvg F := by + calc + _ = ∑ T : Finset V, bernoulliWeight p T * finiteAvg F := + restrictionAvg_fill_coupling p (fun _ y => F y) + _ = _ := by rw [← Finset.sum_mul, sum_bernoulliWeight, one_mul] + +theorem restrictionAvg_mask_sampler (p : ℝ) (F : Restriction V → ℝ) : + restrictionAvg p F = ∑ T : Finset V, bernoulliWeight p T * + finiteAvg (fun y : Cube V => F (maskRestriction T y)) := by + simpa only [finiteAvg_const] using + restrictionAvg_fill_coupling p (fun σ _ => F σ) + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/RestrictionTails.lean b/lean/OAI/Computability/DepthThree/RestrictionTails.lean new file mode 100644 index 0000000000000000000000000000000000000000..d61a66605f395122013871322ddb017112632daf --- /dev/null +++ b/lean/OAI/Computability/DepthThree/RestrictionTails.lean @@ -0,0 +1,176 @@ +import OAI.Computability.DepthThree.RestrictionProbability +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import Mathlib.Analysis.Complex.ExponentialBounds +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Ring + +namespace OAI + +universe uDepth1 + +noncomputable section + +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} [Fintype V] [DecidableEq V] + +theorem restrictionAvg_pow_card_live (p a : ℝ) : + restrictionAvg p (fun σ : Restriction V => a ^ Fintype.card (Live σ)) = + (1 - p + p * a) ^ Fintype.card V := by + rw [restrictionAvg_mask_sampler] + calc + _ = ∑ T : Finset V, (p * a) ^ T.card * + (1 - p) ^ (Fintype.card V - T.card) := by + apply Finset.sum_congr rfl + intro T hT + simp only [card_live_maskRestriction, finiteAvg_const, bernoulliWeight, mul_pow] + ring + _ = (p * a + (1 - p)) ^ Fintype.card V := by + simpa only [Finset.prod_const, Finset.card_compl, Finset.card_univ] using + (Fintype.prod_add (fun _ : V => p * a) (fun _ : V => 1 - p)).symm + _ = _ := by congr 1 ; ring + +theorem restrictionAvg_two_pow_live (p : ℝ) : + restrictionAvg p (fun σ : Restriction V => + (2 : ℝ) ^ (Fintype.card (Live σ) : ℝ)) = (1 + p) ^ Fintype.card V := by + calc + _ = (1 - p + p * 2) ^ Fintype.card V := by + simpa only [Real.rpow_natCast] using restrictionAvg_pow_card_live (V := V) p 2 + _ = _ := by congr 1 ; ring + +theorem restrictionAvg_two_neg_pow_live (p : ℝ) : + restrictionAvg p (fun σ : Restriction V => + (2 : ℝ) ^ (-(Fintype.card (Live σ) : ℝ))) = (1 - p / 2) ^ Fintype.card V := by + simp_rw [Real.rpow_neg (by norm_num : (0 : ℝ) ≤ 2), Real.rpow_natCast, ← inv_pow] + rw [restrictionAvg_pow_card_live] + congr 1 ; ring + +theorem one_add_pow_le_exp (p : ℝ) (hp : 0 ≤ p) (n : ℕ) : + (1 + p) ^ n ≤ Real.exp (p * n) := by + calc + _ ≤ (Real.exp p) ^ n := pow_le_pow_left₀ (by linarith) + (by linarith [Real.add_one_le_exp p]) n + _ = Real.exp (p * n) := by rw [← Real.exp_nat_mul]; congr 1 ; ring + +theorem one_sub_half_pow_le_exp (p : ℝ) (hp1 : p ≤ 1) (n : ℕ) : + (1 - p / 2) ^ n ≤ Real.exp (-(p * n) / 2) := by + calc + _ ≤ (Real.exp (-(p / 2))) ^ n := pow_le_pow_left₀ (by linarith) + (Real.one_sub_le_exp_neg (p / 2)) n + _ = Real.exp (-(p * n) / 2) := by + rw [← Real.exp_nat_mul] + congr 1 ; ring + +private theorem lower_tail_exponent (μ : ℝ) (hμ : 0 ≤ μ) : + (2 : ℝ) ^ (μ / 2) * Real.exp (-μ / 2) ≤ (2 : ℝ) ^ (-μ / 16) := by + simp only [Real.rpow_def_of_pos (by norm_num : (0 : ℝ) < 2)] + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + have hlog : Real.log 2 ≤ (3 / 4 : ℝ) := by linarith [Real.log_two_lt_d9] + have hmul := mul_le_mul_of_nonneg_left hlog hμ + nlinarith + +private theorem upper_tail_exponent (μ : ℝ) (hμ : 0 ≤ μ) : + (2 : ℝ) ^ (-(2 * μ)) * Real.exp μ ≤ (2 : ℝ) ^ (-μ / 16) := by + simp only [Real.rpow_def_of_pos (by norm_num : (0 : ℝ) < 2)] + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + have hlog : (2 / 3 : ℝ) ≤ Real.log 2 := by linarith [Real.log_two_gt_d9] + have hmul := mul_le_mul_of_nonneg_left hlog hμ + nlinarith + +theorem restrictionAvg_lower_tail (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) : + restrictionAvg p (fun σ : Restriction V => + if (Fintype.card (Live σ) : ℝ) < (p * Fintype.card V) / 2 then 1 else 0) ≤ + (2 : ℝ) ^ (-(p * Fintype.card V) / 16) := by + let μ : ℝ := p * Fintype.card V + have hμ : 0 ≤ μ := mul_nonneg hp (Nat.cast_nonneg _) + have hmajor : ∀ σ : Restriction V, + (if (Fintype.card (Live σ) : ℝ) < μ / 2 then (1 : ℝ) else 0) ≤ + (2 : ℝ) ^ (μ / 2) * (2 : ℝ) ^ (-(Fintype.card (Live σ) : ℝ)) := by + intro σ + by_cases hσ : (Fintype.card (Live σ) : ℝ) < μ / 2 + · rw [ite_eq_left hσ, ← Real.rpow_add (by norm_num : (0 : ℝ) < 2)] + exact Real.one_le_rpow (by norm_num) (by linarith) + · rw [ite_eq_right hσ] + exact mul_nonneg (Real.rpow_nonneg (by norm_num) _) + (Real.rpow_nonneg (by norm_num) _) + calc + _ ≤ restrictionAvg p (fun σ : Restriction V => + (2 : ℝ) ^ (μ / 2) * (2 : ℝ) ^ (-(Fintype.card (Live σ) : ℝ))) := + restrictionAvg_mono hp hp1 hmajor + _ = (2 : ℝ) ^ (μ / 2) * (1 - p / 2) ^ Fintype.card V := by + rw [restrictionAvg_const_mul, restrictionAvg_two_neg_pow_live] + _ ≤ (2 : ℝ) ^ (μ / 2) * Real.exp (-μ / 2) := + mul_le_mul_of_nonneg_left (one_sub_half_pow_le_exp p hp1 _) + (Real.rpow_nonneg (by norm_num) _) + _ ≤ _ := lower_tail_exponent μ hμ + +theorem restrictionAvg_upper_tail (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) : + restrictionAvg p (fun σ : Restriction V => + if 2 * (p * Fintype.card V) < (Fintype.card (Live σ) : ℝ) then 1 else 0) ≤ + (2 : ℝ) ^ (-(p * Fintype.card V) / 16) := by + let μ : ℝ := p * Fintype.card V + have hμ : 0 ≤ μ := mul_nonneg hp (Nat.cast_nonneg _) + have hmajor : ∀ σ : Restriction V, + (if 2 * μ < (Fintype.card (Live σ) : ℝ) then (1 : ℝ) else 0) ≤ + (2 : ℝ) ^ (-(2 * μ)) * (2 : ℝ) ^ (Fintype.card (Live σ) : ℝ) := by + intro σ + by_cases hσ : 2 * μ < (Fintype.card (Live σ) : ℝ) + · rw [ite_eq_left hσ, ← Real.rpow_add (by norm_num : (0 : ℝ) < 2)] + exact Real.one_le_rpow (by norm_num) (by linarith) + · rw [ite_eq_right hσ] + exact mul_nonneg (Real.rpow_nonneg (by norm_num) _) + (Real.rpow_nonneg (by norm_num) _) + calc + _ ≤ restrictionAvg p (fun σ : Restriction V => + (2 : ℝ) ^ (-(2 * μ)) * (2 : ℝ) ^ (Fintype.card (Live σ) : ℝ)) := + restrictionAvg_mono hp hp1 hmajor + _ = (2 : ℝ) ^ (-(2 * μ)) * (1 + p) ^ Fintype.card V := by + rw [restrictionAvg_const_mul, restrictionAvg_two_pow_live] + _ ≤ (2 : ℝ) ^ (-(2 * μ)) * Real.exp μ := + mul_le_mul_of_nonneg_left (one_add_pow_le_exp p hp _) + (Real.rpow_nonneg (by norm_num) _) + _ ≤ _ := upper_tail_exponent μ hμ + +theorem restrictionAvg_outside_window (p : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) : + restrictionAvg p (fun σ : Restriction V => + if ¬((p * Fintype.card V) / 2 ≤ (Fintype.card (Live σ) : ℝ) ∧ + (Fintype.card (Live σ) : ℝ) ≤ 2 * (p * Fintype.card V)) then 1 else 0) ≤ + 2 * (2 : ℝ) ^ (-(p * Fintype.card V) / 16) := by + let μ : ℝ := p * Fintype.card V + have hsplit : ∀ σ : Restriction V, + (if ¬(μ / 2 ≤ (Fintype.card (Live σ) : ℝ) ∧ + (Fintype.card (Live σ) : ℝ) ≤ 2 * μ) then (1 : ℝ) else 0) ≤ + (if (Fintype.card (Live σ) : ℝ) < μ / 2 then (1 : ℝ) else 0) + + (if 2 * μ < (Fintype.card (Live σ) : ℝ) then (1 : ℝ) else 0) := by + intro σ + by_cases hlo : (Fintype.card (Live σ) : ℝ) < μ / 2 + · by_cases hhi : 2 * μ < (Fintype.card (Live σ) : ℝ) <;> + simp [hlo, hhi, not_le.mpr hlo] + · have hlo' := le_of_not_gt hlo + by_cases hhi : 2 * μ < (Fintype.card (Live σ) : ℝ) + · simp [hlo, hhi, not_le.mpr hhi] + · simp [hlo, hhi, hlo', le_of_not_gt hhi] + calc + _ ≤ restrictionAvg p (fun σ : Restriction V => + (if (Fintype.card (Live σ) : ℝ) < μ / 2 then (1 : ℝ) else 0) + + (if 2 * μ < (Fintype.card (Live σ) : ℝ) then (1 : ℝ) else 0)) := + restrictionAvg_mono hp hp1 hsplit + _ = restrictionAvg p (fun σ : Restriction V => + if (Fintype.card (Live σ) : ℝ) < μ / 2 then 1 else 0) + + restrictionAvg p (fun σ : Restriction V => + if 2 * μ < (Fintype.card (Live σ) : ℝ) then 1 else 0) := + restrictionAvg_add p _ _ + _ ≤ (2 : ℝ) ^ (-μ / 16) + (2 : ℝ) ^ (-μ / 16) := + add_le_add (restrictionAvg_lower_tail p hp hp1) (restrictionAvg_upper_tail p hp hp1) + _ = _ := by ring + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/ReversePathEncoding.lean b/lean/OAI/Computability/DepthThree/ReversePathEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..66f2ba2f629274e43ead80403d94d3f76ff1cb2a --- /dev/null +++ b/lean/OAI/Computability/DepthThree/ReversePathEncoding.lean @@ -0,0 +1,424 @@ +import OAI.Computability.DepthThree.RestrictionExpansion +import OAI.Computability.DepthThree.ReversePathRecurrence +import OAI.Computability.DepthThree.ReversePathWeights +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Algebra.BigOperators.Group.Finset.Sigma +import Mathlib.Algebra.Order.BigOperators.Ring.Finset +import Mathlib.Tactic.Tauto + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open Finset +open scoped BigOperators Classical + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} {I : Type uDepth2} [DecidableEq V] [instDecidableEqI : DecidableEq I] [instFintypeI : Fintype I] + +def pathRemainder (scope : I → Finset V) (T : Finset V) (P : List I) : Finset V := + T \ revealed scope T P + +@[simp] theorem pathRemainder_nil + {V : Type uDepth1} + {I : Type uDepth2} + [DecidableEq V] + [instDecidableEqI : DecidableEq I] + [Fintype I] + (scope : I → Finset V) (T : Finset V) : + pathRemainder scope T [] = T := by simp [pathRemainder] + +theorem coveredCount_eq_reverseEligible + {V : Type uDepth1} + {I : Type uDepth2} + [DecidableEq V] + [DecidableEq I] + [instFintypeI : Fintype I] + (scope : I → Finset V) (T U : Finset V) + (violation : I → Bool) : + coveredCount scope T violation U = (reverseEligible scope violation (T \ U)).card := by + unfold coveredCount reverseEligible + congr 1 + ext i + simp only [mem_filter, mem_univ, true_and, residual, + Finset.disjoint_iff_inter_eq_empty] + simp only [Finset.mem_filter_univ, and_comm] + +def coveredPathWeight (scope : I → Finset V) (T : Finset V) + (violation : I → Bool) (P : List I) : ℝ := + ∏ h : Fin P.length, + (coveredCount scope T violation (revealed scope T (P.take (h.val + 1))) : ℝ)⁻¹ + +@[simp] theorem coveredPathWeight_nil (scope : I → Finset V) (T : Finset V) + (violation : I → Bool) : coveredPathWeight scope T violation [] = 1 := by + simp [coveredPathWeight] + +theorem coveredPathWeight_nonneg (scope : I → Finset V) (T : Finset V) + (violation : I → Bool) (P : List I) : 0 ≤ coveredPathWeight scope T violation P := + prod_nonneg fun _ _ => inv_nonneg.mpr (Nat.cast_nonneg _) + +theorem coveredPathWeight_snoc (scope : I → Finset V) (T : Finset V) + (violation : I → Bool) (P : List I) (i : I) : + coveredPathWeight scope T violation (P ++ [i]) = + coveredPathWeight scope T violation P * + (coveredCount scope T violation (revealed scope T (P ++ [i])) : ℝ)⁻¹ := by + unfold coveredPathWeight + rw [Fin.prod_univ_eq_prod_range + (fun h : ℕ => (coveredCount scope T violation + (revealed scope T ((P ++ [i]).take (h + 1))) : ℝ)⁻¹) (P ++ [i]).length, + Fin.prod_univ_eq_prod_range + (fun h : ℕ => (coveredCount scope T violation + (revealed scope T (P.take (h + 1))) : ℝ)⁻¹) P.length] + rw [List.length_append, List.length_singleton, Finset.prod_range_succ] + congr 1 + · apply prod_congr rfl + intro h hh + rw [List.take_append_of_le_length (Nat.succ_le_of_lt (Finset.mem_range.mp hh))] + · rw [List.take_of_length_le (by simp)] + +theorem remainder_snoc_union_block + {V : Type uDepth1} + {I : Type uDepth2} + [DecidableEq V] + [instDecidableEqI : DecidableEq I] + [Fintype I] + (scope : I → Finset V) (T : Finset V) + (P : List I) (i : I) : + pathRemainder scope T (P ++ [i]) ∪ residual scope T (revealed scope T P) i = + pathRemainder scope T P := by + ext v + simp only [pathRemainder, revealed_snoc, residual, + mem_union, mem_sdiff, mem_inter] + tauto + +theorem remainder_snoc_disjoint_block + {V : Type uDepth1} + {I : Type uDepth2} + [DecidableEq V] + [instDecidableEqI : DecidableEq I] + [Fintype I] + (scope : I → Finset V) (T : Finset V) + (P : List I) (i : I) : + Disjoint (pathRemainder scope T (P ++ [i])) + (residual scope T (revealed scope T P) i) := by + apply disjoint_left.mpr + intro v hR hD + simp only [pathRemainder, revealed_snoc, mem_sdiff, mem_union, mem_inter] at hR + simp only [residual, mem_inter, mem_sdiff] at hD + exact hR.2 (Or.inr ⟨hD.1, hD.2.1⟩) + +theorem scope_disjoint_remainder_snoc + {V : Type uDepth1} + {I : Type uDepth2} + [DecidableEq V] + [instDecidableEqI : DecidableEq I] + [Fintype I] + (scope : I → Finset V) (T : Finset V) + (P : List I) (i : I) : Disjoint (scope i) (pathRemainder scope T (P ++ [i])) := by + apply disjoint_left.mpr + intro v hi hR + simp only [pathRemainder, revealed_snoc, mem_sdiff, mem_union, mem_inter] at hR + exact hR.2 (Or.inr ⟨hi, hR.1⟩) + +def reverseEncode (scope : I → Finset V) (T : Finset V) (P : List I) : + List (I × Finset V) := + P.reverseRecOn [] fun Q i rec => + (i, residual scope T (revealed scope T Q) i) :: rec + +@[simp] theorem reverseEncode_nil + {V : Type uDepth1} + {I : Type uDepth2} + [DecidableEq V] + [instDecidableEqI : DecidableEq I] + [Fintype I] + (scope : I → Finset V) (T : Finset V) : + reverseEncode scope T [] = [] := by simp [reverseEncode] + +@[simp] theorem reverseEncode_snoc + {V : Type uDepth1} + {I : Type uDepth2} + [DecidableEq V] + [instDecidableEqI : DecidableEq I] + [Fintype I] + (scope : I → Finset V) (T : Finset V) + (P : List I) (i : I) : + reverseEncode scope T (P ++ [i]) = + (i, residual scope T (revealed scope T P) i) :: reverseEncode scope T P := by + simp [reverseEncode] + +def reverseStart (R : Finset V) (L : List (I × Finset V)) : Finset V := + L.foldl (fun S q => S ∪ q.2) R + +@[simp] theorem reverseStart_nil + {V : Type uDepth1} + {I : Type uDepth2} + [DecidableEq V] + [DecidableEq I] + [Fintype I] + (R : Finset V) : reverseStart R ([] : List (I × Finset V)) = R := rfl + +@[simp] theorem reverseStart_cons + {V : Type uDepth1} + {I : Type uDepth2} + [DecidableEq V] + [DecidableEq I] + [Fintype I] + (R : Finset V) (i : I) (D : Finset V) + (L : List (I × Finset V)) : + reverseStart R ((i,D) :: L) = reverseStart (R ∪ D) L := rfl + +theorem reverseStart_encode (scope : I → Finset V) (T : Finset V) (P : List I) : + reverseStart (pathRemainder scope T P) (reverseEncode scope T P) = T := by + induction P using List.reverseRecOn with + | nil => simp + | append_singleton P i ih => + rw [reverseEncode_snoc, reverseStart_cons, remainder_snoc_union_block] + exact ih + +theorem reverseEncode_indices (scope : I → Finset V) (T : Finset V) (P : List I) : + (reverseEncode scope T P).map Prod.fst = P.reverse := by + induction P using List.reverseRecOn with + | nil => simp + | append_singleton P i ih => simp [ih] + +def encodePathPair (scope : I → Finset V) (x : Σ _T : Finset V, List I) : + Σ _R : Finset V, List (I × Finset V) := + ⟨pathRemainder scope x.1 x.2, reverseEncode scope x.1 x.2⟩ + +theorem encodePathPair_injective (scope : I → Finset V) : + Function.Injective (encodePathPair scope) := by + rintro ⟨T,P⟩ ⟨S,Q⟩ h + have hT := congrArg (fun x : Σ _R : Finset V, List (I × Finset V) => + reverseStart x.1 x.2) h + have hP := congrArg (fun x : Σ _R : Finset V, List (I × Finset V) => + (x.2.map Prod.fst).reverse) h + simp only [encodePathPair, reverseStart_encode] at hT + simp only [encodePathPair, reverseEncode_indices, List.reverse_reverse] at hP + subst S + subst Q + rfl + +def reverseTraces (scope : I → Finset V) (violation : I → Bool) (b : ℕ) : + ℕ → Finset V → Finset (List (I × Finset V)) + | 0, _ => {[]} + | s + 1, R => (reverseEligible scope violation R).biUnion fun i => + (reverseBlocks b (scope i)).biUnion fun D => + (reverseTraces scope violation b s (R ∪ D)).image fun L => (i,D) :: L + +@[simp] theorem mem_reverseTraces_zero (scope : I → Finset V) (violation : I → Bool) + (b : ℕ) (R : Finset V) (L : List (I × Finset V)) : + L ∈ reverseTraces scope violation b 0 R ↔ L = [] := by + simp [reverseTraces] + +theorem mem_reverseTraces_succ (scope : I → Finset V) (violation : I → Bool) + (b s : ℕ) (R : Finset V) (L : List (I × Finset V)) : + L ∈ reverseTraces scope violation b (s+1) R ↔ + ∃ i ∈ reverseEligible scope violation R, + ∃ D ∈ reverseBlocks b (scope i), + ∃ M ∈ reverseTraces scope violation b s (R ∪ D), (i,D)::M = L := by + simp only [reverseTraces, mem_biUnion, mem_image] + +theorem reverseEncode_mem (scope : I → Finset V) (violation : I → Bool) + (b : ℕ) (T : Finset V) {j : ℕ} {P : List I} + (hP : P ∈ paths scope T b j) (hs : ∀ i ∈ P, violation i = true) : + reverseEncode scope T P ∈ reverseTraces scope violation b j (pathRemainder scope T P) := by + induction j generalizing P with + | zero => + have h := (mem_paths_zero scope T b P).mp hP + subst P + simp + | succ j ih => + obtain ⟨Q,hQ,i,hi,rfl⟩ := mem_paths_succ.mp hP + have hsQ : ∀ a ∈ Q, violation a = true := fun a ha => hs a (List.mem_append_left _ ha) + have hsi : violation i = true := hs i (by simp) + rw [reverseEncode_snoc] + apply (mem_reverseTraces_succ scope violation b j _ _).mpr + refine ⟨i, ?_, residual scope T (revealed scope T Q) i, ?_, reverseEncode scope T Q, ?_, rfl⟩ + · exact (mem_reverseEligible scope violation _ i).mpr + ⟨hsi, scope_disjoint_remainder_snoc scope T Q i⟩ + · exact (mem_reverseBlocks b _ _).mpr + ⟨Finset.inter_subset_left, (mem_hardIndices scope T b _ i).mp hi⟩ + · rw [remainder_snoc_union_block] + exact ih hQ hsQ + +def reverseTraceWeight (α : ℝ) (scope : I → Finset V) (violation : I → Bool) : + Finset V → List (I × Finset V) → ℝ + | _, [] => 1 + | R, (_,D)::L => reverseChoiceWeight α scope violation R D * + reverseTraceWeight α scope violation (R ∪ D) L + +theorem reverseTraceWeight_nonneg {α : ℝ} (hα : 0 ≤ α) + (scope : I → Finset V) (violation : I → Bool) (R : Finset V) + (L : List (I × Finset V)) : 0 ≤ reverseTraceWeight α scope violation R L := by + induction L generalizing R with + | nil => simp [reverseTraceWeight] + | cons q L ih => + rcases q with ⟨i,D⟩ + exact mul_nonneg (reverseChoiceWeight_nonneg hα scope violation R D) (ih (R ∪ D)) + +theorem sum_reverseTraces_succ (scope : I → Finset V) (violation : I → Bool) + (b s : ℕ) (R : Finset V) (f : List (I × Finset V) → ℝ) : + (∑ L ∈ reverseTraces scope violation b (s+1) R, f L) = + ∑ i ∈ reverseEligible scope violation R, ∑ D ∈ reverseBlocks b (scope i), + ∑ L ∈ reverseTraces scope violation b s (R ∪ D), f ((i,D)::L) := by + have hi : Set.PairwiseDisjoint (↑(reverseEligible scope violation R) : Set I) + (fun i => (reverseBlocks b (scope i)).biUnion fun D => + (reverseTraces scope violation b s (R ∪ D)).image fun L => (i,D)::L) := by + intro i hi k hk hik + apply disjoint_left.mpr + intro L hL hM + obtain ⟨D,hD,hL⟩ := mem_biUnion.mp hL + obtain ⟨E,hE,hM⟩ := mem_biUnion.mp hM + obtain ⟨L',hL',heq⟩ := mem_image.mp hL + obtain ⟨M',hM',heq'⟩ := mem_image.mp hM + have hh := List.cons.inj (heq.trans heq'.symm) + exact hik (congrArg Prod.fst hh.1) + rw [reverseTraces, sum_biUnion hi] + apply sum_congr rfl + intro i hi + have hD : Set.PairwiseDisjoint (↑(reverseBlocks b (scope i)) : Set (Finset V)) + (fun D => (reverseTraces scope violation b s (R ∪ D)).image fun L => (i,D)::L) := by + intro D hD E hE hDE + apply disjoint_left.mpr + intro L hL hM + obtain ⟨L',hL',heq⟩ := mem_image.mp hL + obtain ⟨M',hM',heq'⟩ := mem_image.mp hM + have hh := List.cons.inj (heq.trans heq'.symm) + exact hDE (congrArg Prod.snd hh.1) + rw [sum_biUnion hD] + apply sum_congr rfl + intro D hD + exact sum_image fun L hL M hM h => (List.cons.inj h).2 + +theorem sum_reverseTraceWeight (α : ℝ) (scope : I → Finset V) + (violation : I → Bool) (b j : ℕ) (R : Finset V) : + (∑ L ∈ reverseTraces scope violation b j R, reverseTraceWeight α scope violation R L) = + reverseTotal α b scope violation j R := by + induction j generalizing R with + | zero => simp [reverseTraces, reverseTraceWeight] + | succ j ih => + rw [sum_reverseTraces_succ] + simp_rw [reverseTraceWeight, ← Finset.mul_sum, ih] + by_cases h : (reverseEligible scope violation R).Nonempty + · rw [reverseTotal_succ_of_nonempty α b scope violation j R h, + Finset.sum_div] + apply sum_congr rfl + intro i hi + rw [Finset.sum_div] + apply sum_congr rfl + intro D hD + unfold reverseChoiceWeight + ring + · have he := Finset.not_nonempty_iff_eq_empty.mp h + rw [reverseTotal_succ_of_empty α b scope violation j R he, he] + simp + +variable [Fintype V] + +theorem reverseEncode_weight (p : ℝ) (hp0 : 0 < p) (hp1 : p < 1) + (scope : I → Finset V) (violation : I → Bool) (T : Finset V) (P : List I) : + bernoulliWeight p T * (2 : ℝ) ^ (revealed scope T P).card * + coveredPathWeight scope T violation P = + bernoulliWeight p (pathRemainder scope T P) * + reverseTraceWeight (2*p/(1-p)) scope violation + (pathRemainder scope T P) (reverseEncode scope T P) := by + induction P using List.reverseRecOn with + | nil => simp [reverseTraceWeight] + | append_singleton P i ih => + let D := residual scope T (revealed scope T P) i + let R := pathRemainder scope T (P ++ [i]) + have hR : R ∪ D = pathRemainder scope T P := remainder_snoc_union_block scope T P i + have hdis : Disjoint R D := remainder_snoc_disjoint_block scope T P i + have hbal := bernoulliWeight_disjoint_union hp0 hp1 R D hdis + rw [hR] at hbal + rw [coveredPathWeight_snoc, card_revealed_snoc, pow_add, + coveredCount_eq_reverseEligible, reverseEncode_snoc] + change bernoulliWeight p T * + ((2 : ℝ) ^ (revealed scope T P).card * (2 : ℝ) ^ D.card) * + (coveredPathWeight scope T violation P * + ((reverseEligible scope violation R).card : ℝ)⁻¹) = + bernoulliWeight p R * + (reverseChoiceWeight (2*p/(1-p)) scope violation R D * + reverseTraceWeight (2*p/(1-p)) scope violation (R ∪ D) (reverseEncode scope T P)) + rw [hR] + calc + _ = (bernoulliWeight p T * (2 : ℝ) ^ (revealed scope T P).card * + coveredPathWeight scope T violation P) * (2 : ℝ)^D.card * + ((reverseEligible scope violation R).card : ℝ)⁻¹ := by ring + _ = (bernoulliWeight p (pathRemainder scope T P) * (2 : ℝ)^D.card) * + reverseTraceWeight (2*p/(1-p)) scope violation (pathRemainder scope T P) + (reverseEncode scope T P) * ((reverseEligible scope violation R).card : ℝ)⁻¹ := by + rw [ih] + ring + _ = _ := by rw [hbal]; unfold reverseChoiceWeight; ring + +def supportedForwardPairs (scope : I → Finset V) (violation : I → Bool) (b j : ℕ) : + Finset (Σ _T : Finset V, List I) := + univ.sigma fun T => (paths scope T b j).filter fun P => ∀ i ∈ P, violation i = true + +def indexedReverseTraces (scope : I → Finset V) (violation : I → Bool) (b j : ℕ) : + Finset (Σ _R : Finset V, List (I × Finset V)) := + univ.sigma fun R => reverseTraces scope violation b j R + +theorem encode_supported_mem (scope : I → Finset V) (violation : I → Bool) (b j : ℕ) + {x : Σ _T : Finset V, List I} (hx : x ∈ supportedForwardPairs scope violation b j) : + encodePathPair scope x ∈ indexedReverseTraces scope violation b j := by + rcases x with ⟨T,P⟩ + have hh := mem_filter.mp (mem_sigma.mp hx).2 + exact mem_sigma.mpr ⟨mem_univ _, reverseEncode_mem scope violation b T hh.1 hh.2⟩ + +theorem weighted_supported_paths_le (p : ℝ) (hp0 : 0 < p) (hp1 : p < 1) + (b k : ℕ) (scope : I → Finset V) (hscope : ∀ i, (scope i).card ≤ k) + (violation : I → Bool) (j : ℕ) : + (∑ T : Finset V, bernoulliWeight p T * + ∑ P ∈ paths scope T b j, if ∀ i ∈ P, violation i = true then + (2 : ℝ) ^ (revealed scope T P).card * coveredPathWeight scope T violation P else 0) ≤ + (reverseTheta (2*p/(1-p)) b k) ^ j := by + let α : ℝ := 2*p/(1-p) + have hα : 0 ≤ α := div_nonneg (mul_nonneg (by norm_num) hp0.le) (sub_pos.mpr hp1).le + let w : (Σ _R : Finset V, List (I × Finset V)) → ℝ := fun x => + bernoulliWeight p x.1 * reverseTraceWeight α scope violation x.1 x.2 + have hw : ∀ x, 0 ≤ w x := fun x => mul_nonneg + (bernoulliWeight_nonneg hp0.le hp1.le x.1) (reverseTraceWeight_nonneg hα scope violation x.1 x.2) + have hs : (supportedForwardPairs scope violation b j).image (encodePathPair scope) ⊆ + indexedReverseTraces scope violation b j := by + intro x hx + obtain ⟨y,hy,rfl⟩ := mem_image.mp hx + exact encode_supported_mem scope violation b j hy + calc + _ = ∑ x ∈ supportedForwardPairs scope violation b j, w (encodePathPair scope x) := by + rw [supportedForwardPairs, Finset.sum_sigma] + apply sum_congr rfl + intro T hT + rw [← Finset.sum_filter, Finset.mul_sum] + apply sum_congr rfl + intro P hP + exact (mul_assoc _ _ _).symm.trans (reverseEncode_weight p hp0 hp1 scope violation T P) + _ = ∑ x ∈ (supportedForwardPairs scope violation b j).image (encodePathPair scope), w x := by + symm + exact sum_image fun x hx y hy h => encodePathPair_injective scope h + _ ≤ ∑ x ∈ indexedReverseTraces scope violation b j, w x := + sum_le_sum_of_subset_of_nonneg hs (fun x hx hn => hw x) + _ = ∑ R : Finset V, bernoulliWeight p R * reverseTotal α b scope violation j R := by + rw [indexedReverseTraces, Finset.sum_sigma] + apply sum_congr rfl + intro R hR + change (∑ L ∈ reverseTraces scope violation b j R, + bernoulliWeight p R * reverseTraceWeight α scope violation R L) = _ + rw [← Finset.mul_sum, sum_reverseTraceWeight] + _ ≤ ∑ R : Finset V, bernoulliWeight p R * (reverseTheta α b k)^j := by + apply sum_le_sum + intro R hR + exact mul_le_mul_of_nonneg_left + (reverseTotal_le_theta_pow hα b k scope hscope violation j R) + (bernoulliWeight_nonneg hp0.le hp1.le R) + _ = _ := by rw [← Finset.sum_mul, sum_bernoulliWeight, one_mul] + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/ReversePathRecurrence.lean b/lean/OAI/Computability/DepthThree/ReversePathRecurrence.lean new file mode 100644 index 0000000000000000000000000000000000000000..bbd46193f2f9e2b879a4cff61b228e9c63571e52 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/ReversePathRecurrence.lean @@ -0,0 +1,291 @@ +import Mathlib.Algebra.BigOperators.Group.Finset.Powerset +import Mathlib.Algebra.BigOperators.Field +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Basic.Real.Basic +import Mathlib.Tactic.Ring +import Mathlib.Tactic.SplitIfs + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +open Finset +open scoped BigOperators + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} {I : Type uDepth2} [instDecidableEqV : DecidableEq V] [instDecidableEqI : DecidableEq I] [Fintype I] + +def reverseEligible (scope : I → Finset V) (violation : I → Bool) + (R : Finset V) : Finset I := + univ.filter fun i => violation i = true ∧ Disjoint (scope i) R + +@[simp] theorem mem_reverseEligible + {V : Type uDepth1} + {I : Type uDepth2} + [instDecidableEqV : DecidableEq V] + [DecidableEq I] + [Fintype I] + (scope : I → Finset V) (violation : I → Bool) + (R : Finset V) (i : I) : + i ∈ reverseEligible scope violation R ↔ + violation i = true ∧ Disjoint (scope i) R := by + simp [reverseEligible] + +def reverseBlocks (b : ℕ) (E : Finset V) : Finset (Finset V) := + E.powerset.filter fun D => b < D.card + +@[simp] theorem mem_reverseBlocks + {V : Type uDepth1} + [DecidableEq V] + (b : ℕ) (E D : Finset V) : + D ∈ reverseBlocks b E ↔ D ⊆ E ∧ b < D.card := by + simp [reverseBlocks] + +def ReverseChoice (b : ℕ) (scope : I → Finset V) (violation : I → Bool) + (R : Finset V) (i : I) (D : Finset V) : Prop := + i ∈ reverseEligible scope violation R ∧ D ∈ reverseBlocks b (scope i) + +theorem ReverseChoice.disjoint {b : ℕ} {scope : I → Finset V} + {violation : I → Bool} {R : Finset V} {i : I} {D : Finset V} + (h : ReverseChoice b scope violation R i D) : Disjoint R D := by + have hi := (mem_reverseEligible scope violation R i).mp h.1 + have hD := (mem_reverseBlocks b (scope i) D).mp h.2 + exact hi.2.symm.mono_right hD.1 + +theorem ReverseChoice.eligible_card_pos + {V : Type uDepth1} + {I : Type uDepth2} + [instDecidableEqV : DecidableEq V] + [DecidableEq I] + [Fintype I] + {b : ℕ} {scope : I → Finset V} + {violation : I → Bool} {R : Finset V} {i : I} {D : Finset V} + (h : ReverseChoice b scope violation R i D) : + 0 < (reverseEligible scope violation R).card := + Finset.card_pos.mpr ⟨i, h.1⟩ + +def reverseChoiceWeight (α : ℝ) (scope : I → Finset V) (violation : I → Bool) + (R D : Finset V) : ℝ := + α ^ D.card / ((reverseEligible scope violation R).card : ℝ) + +theorem reverseChoiceWeight_nonneg + {V : Type uDepth1} + {I : Type uDepth2} + [instDecidableEqV : DecidableEq V] + [DecidableEq I] + [Fintype I] + {α : ℝ} (hα : 0 ≤ α) + (scope : I → Finset V) (violation : I → Bool) (R D : Finset V) : + 0 ≤ reverseChoiceWeight α scope violation R D := + div_nonneg (pow_nonneg hα _) (Nat.cast_nonneg _) + +def reverseTheta (α : ℝ) (b k : ℕ) : ℝ := + ∑ l ∈ range (k + 1), if b < l then (k.choose l : ℝ) * α ^ l else 0 + +theorem reverseTheta_nonneg {α : ℝ} (hα : 0 ≤ α) (b k : ℕ) : + 0 ≤ reverseTheta α b k := by + apply sum_nonneg + intro l hl + split_ifs + · exact mul_nonneg (Nat.cast_nonneg _) (pow_nonneg hα _) + · exact le_rfl + +def reverseBlockMass (α : ℝ) (b : ℕ) (E : Finset V) : ℝ := + ∑ D ∈ reverseBlocks b E, α ^ D.card + +theorem reverseBlockMass_nonneg + {V : Type uDepth1} + [DecidableEq V] + {α : ℝ} (hα : 0 ≤ α) (b : ℕ) (E : Finset V) : + 0 ≤ reverseBlockMass α b E := + sum_nonneg fun _ _ => pow_nonneg hα _ + +theorem reverseBlockMass_eq_theta + {V : Type uDepth1} + [DecidableEq V] + (α : ℝ) (b : ℕ) (E : Finset V) : + reverseBlockMass α b E = reverseTheta α b E.card := by + unfold reverseBlockMass reverseBlocks + rw [Finset.sum_filter, Finset.sum_powerset] + unfold reverseTheta + apply sum_congr rfl + intro l hl + rw [Finset.sum_powersetCard l E (fun n => if b < n then α ^ n else 0)] + by_cases h : b < l <;> simp [h, nsmul_eq_mul] + +theorem reverseTheta_mono_width {α : ℝ} (hα : 0 ≤ α) (b : ℕ) + {e k : ℕ} (hek : e ≤ k) : reverseTheta α b e ≤ reverseTheta α b k := by + unfold reverseTheta + calc + (∑ l ∈ range (e + 1), if b < l then (e.choose l : ℝ) * α ^ l else 0) ≤ + ∑ l ∈ range (e + 1), if b < l then (k.choose l : ℝ) * α ^ l else 0 := by + apply sum_le_sum + intro l hl + by_cases h : b < l + · simp only [h, ite_true] + apply mul_le_mul_of_nonneg_right _ (pow_nonneg hα _) + exact Nat.cast_le.mpr (Nat.choose_le_choose l hek) + · simp only [h, ite_false, le_refl] + _ ≤ ∑ l ∈ range (k + 1), if b < l then (k.choose l : ℝ) * α ^ l else 0 := by + apply sum_le_sum_of_subset_of_nonneg (range_mono (Nat.add_le_add_right hek 1)) + intro l hl hle + split_ifs + · exact mul_nonneg (Nat.cast_nonneg _) (pow_nonneg hα _) + · exact le_rfl + +theorem reverseBlockMass_le_theta {α : ℝ} (hα : 0 ≤ α) (b : ℕ) + (E : Finset V) {k : ℕ} (hE : E.card ≤ k) : + reverseBlockMass α b E ≤ reverseTheta α b k := by + rw [reverseBlockMass_eq_theta] + exact reverseTheta_mono_width hα b hE + +def reverseOneStep (α : ℝ) (b : ℕ) (scope : I → Finset V) + (violation : I → Bool) (R : Finset V) : ℝ := + (∑ i ∈ reverseEligible scope violation R, reverseBlockMass α b (scope i)) / + ((reverseEligible scope violation R).card : ℝ) + +theorem sum_reverseBlockMass_le + {V : Type uDepth1} + {I : Type uDepth2} + [instDecidableEqV : DecidableEq V] + [DecidableEq I] + [Fintype I] + {α : ℝ} (hα : 0 ≤ α) (b k : ℕ) + (scope : I → Finset V) (hscope : ∀ i, (scope i).card ≤ k) + (violation : I → Bool) (R : Finset V) : + (∑ i ∈ reverseEligible scope violation R, reverseBlockMass α b (scope i)) ≤ + ((reverseEligible scope violation R).card : ℝ) * reverseTheta α b k := by + calc + _ ≤ ∑ i ∈ reverseEligible scope violation R, reverseTheta α b k := + sum_le_sum fun i hi => reverseBlockMass_le_theta hα b (scope i) (hscope i) + _ = _ := by simp [nsmul_eq_mul] + +theorem reverseOneStep_le_theta {α : ℝ} (hα : 0 ≤ α) (b k : ℕ) + (scope : I → Finset V) (hscope : ∀ i, (scope i).card ≤ k) + (violation : I → Bool) (R : Finset V) : + reverseOneStep α b scope violation R ≤ reverseTheta α b k := by + by_cases h : (reverseEligible scope violation R).Nonempty + · have hc : (0 : ℝ) < (reverseEligible scope violation R).card := by + exact Nat.cast_pos.mpr (Finset.card_pos.mpr h) + apply (div_le_iff₀ hc).mpr + simpa only [mul_comm] using sum_reverseBlockMass_le hα b k scope hscope violation R + · have he : reverseEligible scope violation R = ∅ := Finset.not_nonempty_iff_eq_empty.mp h + simpa [reverseOneStep, he] using reverseTheta_nonneg hα b k + +def reverseTotal (α : ℝ) (b : ℕ) (scope : I → Finset V) + (violation : I → Bool) : ℕ → Finset V → ℝ + | 0, _ => 1 + | s + 1, R => + if (reverseEligible scope violation R).Nonempty then + (∑ i ∈ reverseEligible scope violation R, + ∑ D ∈ reverseBlocks b (scope i), + α ^ D.card * reverseTotal α b scope violation s (R ∪ D)) / + ((reverseEligible scope violation R).card : ℝ) + else 0 + +@[simp] theorem reverseTotal_zero + {V : Type uDepth1} + {I : Type uDepth2} + [instDecidableEqV : DecidableEq V] + [DecidableEq I] + [Fintype I] + (α : ℝ) (b : ℕ) (scope : I → Finset V) + (violation : I → Bool) (R : Finset V) : + reverseTotal α b scope violation 0 R = 1 := rfl + +theorem reverseTotal_succ_of_nonempty + {V : Type uDepth1} + {I : Type uDepth2} + [instDecidableEqV : DecidableEq V] + [DecidableEq I] + [Fintype I] + (α : ℝ) (b : ℕ) (scope : I → Finset V) + (violation : I → Bool) (s : ℕ) (R : Finset V) + (h : (reverseEligible scope violation R).Nonempty) : + reverseTotal α b scope violation (s + 1) R = + (∑ i ∈ reverseEligible scope violation R, + ∑ D ∈ reverseBlocks b (scope i), + α ^ D.card * reverseTotal α b scope violation s (R ∪ D)) / + ((reverseEligible scope violation R).card : ℝ) := by + simp only [reverseTotal, h, ite_true] + +theorem reverseTotal_succ_of_empty + {V : Type uDepth1} + {I : Type uDepth2} + [instDecidableEqV : DecidableEq V] + [DecidableEq I] + [Fintype I] + (α : ℝ) (b : ℕ) (scope : I → Finset V) + (violation : I → Bool) (s : ℕ) (R : Finset V) + (h : reverseEligible scope violation R = ∅) : + reverseTotal α b scope violation (s + 1) R = 0 := by + simp [reverseTotal, h] + +theorem reverseTotal_nonneg + {V : Type uDepth1} + {I : Type uDepth2} + [instDecidableEqV : DecidableEq V] + [DecidableEq I] + [Fintype I] + {α : ℝ} (hα : 0 ≤ α) (b : ℕ) + (scope : I → Finset V) (violation : I → Bool) (s : ℕ) (R : Finset V) : + 0 ≤ reverseTotal α b scope violation s R := by + induction s generalizing R with + | zero => simp + | succ s ih => + simp only [reverseTotal] + split_ifs + · apply div_nonneg _ (Nat.cast_nonneg _) + apply sum_nonneg + intro i hi + exact sum_nonneg fun D hD => mul_nonneg (pow_nonneg hα _) (ih (R ∪ D)) + · exact le_rfl + +theorem reverseTotal_le_theta_pow {α : ℝ} (hα : 0 ≤ α) (b k : ℕ) + (scope : I → Finset V) (hscope : ∀ i, (scope i).card ≤ k) + (violation : I → Bool) (s : ℕ) (R : Finset V) : + reverseTotal α b scope violation s R ≤ (reverseTheta α b k) ^ s := by + have hθ : 0 ≤ reverseTheta α b k := reverseTheta_nonneg hα b k + induction s generalizing R with + | zero => simp + | succ s ih => + by_cases h : (reverseEligible scope violation R).Nonempty + · rw [reverseTotal_succ_of_nonempty α b scope violation s R h] + have hc : (0 : ℝ) < (reverseEligible scope violation R).card := by + exact Nat.cast_pos.mpr (Finset.card_pos.mpr h) + apply (div_le_iff₀ hc).mpr + calc + (∑ i ∈ reverseEligible scope violation R, + ∑ D ∈ reverseBlocks b (scope i), + α ^ D.card * reverseTotal α b scope violation s (R ∪ D)) ≤ + ∑ i ∈ reverseEligible scope violation R, + ∑ D ∈ reverseBlocks b (scope i), α ^ D.card * (reverseTheta α b k) ^ s := by + apply sum_le_sum + intro i hi + exact sum_le_sum fun D hD => + mul_le_mul_of_nonneg_left (ih (R ∪ D)) (pow_nonneg hα _) + _ = ∑ i ∈ reverseEligible scope violation R, + reverseBlockMass α b (scope i) * (reverseTheta α b k) ^ s := by + simp only [reverseBlockMass, Finset.sum_mul] + _ ≤ ∑ i ∈ reverseEligible scope violation R, + reverseTheta α b k * (reverseTheta α b k) ^ s := by + apply sum_le_sum + intro i hi + exact mul_le_mul_of_nonneg_right + (reverseBlockMass_le_theta hα b (scope i) (hscope i)) (pow_nonneg hθ _) + _ = (reverseTheta α b k) ^ (s + 1) * + ((reverseEligible scope violation R).card : ℝ) := by + simp only [Finset.sum_const, nsmul_eq_mul, pow_succ] + ring + · have he : reverseEligible scope violation R = ∅ := Finset.not_nonempty_iff_eq_empty.mp h + rw [reverseTotal_succ_of_empty α b scope violation s R he] + exact pow_nonneg hθ _ + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/ReversePathWeights.lean b/lean/OAI/Computability/DepthThree/ReversePathWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..1af5ace115b61a344a3f4c7edad6071db252cb8d --- /dev/null +++ b/lean/OAI/Computability/DepthThree/ReversePathWeights.lean @@ -0,0 +1,69 @@ +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Basic.Real.Basic +import Mathlib.Tactic.Ring + +namespace OAI + +universe uDepth1 + +namespace DepthThreeLowerBound + +open scoped BigOperators + +variable {V : Type uDepth1} [Fintype V] + +def bernoulliWeight (p : ℝ) (R : Finset V) : ℝ := + p ^ R.card * (1 - p) ^ (Fintype.card V - R.card) + +theorem bernoulliWeight_nonneg {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) + (R : Finset V) : 0 ≤ bernoulliWeight p R := by + exact mul_nonneg (pow_nonneg hp0 _) (pow_nonneg (sub_nonneg.mpr hp1) _) + +theorem bernoulliWeight_pos {p : ℝ} (hp0 : 0 < p) (hp1 : p < 1) + (R : Finset V) : 0 < bernoulliWeight p R := by + exact mul_pos (pow_pos hp0 _) (pow_pos (sub_pos.mpr hp1) _) + +theorem sum_bernoulliWeight (p : ℝ) : + ∑ R : Finset V, bernoulliWeight p R = 1 := by + classical + have hp : p + (1 - p) = 1 := by ring + simpa only [bernoulliWeight, hp, Finset.prod_const, Finset.card_compl, one_pow] + using (Fintype.prod_add (fun _ : V => p) (fun _ : V => 1 - p)).symm + +variable [DecidableEq V] + +theorem bernoulliWeight_disjoint_balance (p : ℝ) (R D : Finset V) + (hRD : Disjoint R D) : + bernoulliWeight p (R ∪ D) * (1 - p) ^ D.card = + bernoulliWeight p R * p ^ D.card := by + have hcard : R.card + D.card ≤ Fintype.card V := by + rw [← Finset.card_union_of_disjoint hRD] + exact (R ∪ D).card_le_univ + have hD : D.card ≤ Fintype.card V - R.card := + Nat.le_sub_of_add_le (by simpa only [Nat.add_comm] using hcard) + have hsplit : Fintype.card V - R.card = + (Fintype.card V - (R.card + D.card)) + D.card := by + rw [← Nat.sub_sub, Nat.sub_add_cancel hD] + unfold bernoulliWeight + rw [Finset.card_union_of_disjoint hRD, hsplit, pow_add, pow_add] + ring + +theorem bernoulliWeight_disjoint_union {p : ℝ} (_hp0 : 0 < p) (hp1 : p < 1) + (R D : Finset V) (hRD : Disjoint R D) : + bernoulliWeight p (R ∪ D) * (2 : ℝ) ^ D.card = + bernoulliWeight p R * (2 * p / (1 - p)) ^ D.card := by + have hq : (1 - p) ^ D.card ≠ 0 := + pow_ne_zero _ (ne_of_gt (sub_pos.mpr hp1)) + rw [div_pow, mul_pow, ← mul_div_assoc] + apply (eq_div_iff hq).2 + calc + (bernoulliWeight p (R ∪ D) * (2 : ℝ) ^ D.card) * (1 - p) ^ D.card = + (bernoulliWeight p (R ∪ D) * (1 - p) ^ D.card) * (2 : ℝ) ^ D.card := by + ring + _ = (bernoulliWeight p R * p ^ D.card) * (2 : ℝ) ^ D.card := by + rw [bernoulliWeight_disjoint_balance p R D hRD] + _ = bernoulliWeight p R * ((2 : ℝ) ^ D.card * p ^ D.card) := by ring + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparseBranch.lean b/lean/OAI/Computability/DepthThree/SparseBranch.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2f2fe97b5d746df27123e43ad9a49fa07af0fc2 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparseBranch.lean @@ -0,0 +1,489 @@ +import OAI.Computability.DepthThree.SparseCounting +import OAI.Computability.DepthThree.Sunflower + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} [instDecidableEqV : DecidableEq V] + +def sparseBatchUpdate (A B : Finset (Clause V)) : Finset (Clause V) := by + classical + exact B ∪ A.filter (fun C => ¬ ∃ D ∈ B, D ⊆ C) + +@[simp] theorem mem_sparseBatchUpdate {A B : Finset (Clause V)} {C : Clause V} : + C ∈ sparseBatchUpdate A B ↔ C ∈ B ∨ (C ∈ A ∧ ¬ ∃ D ∈ B, D ⊆ C) := by + classical + simp only [sparseBatchUpdate, Finset.mem_union, Finset.mem_filter] + +theorem batch_subset_sparseBatchUpdate (A B : Finset (Clause V)) : + B ⊆ sparseBatchUpdate A B := fun _ h => mem_sparseBatchUpdate.mpr (Or.inl h) + +theorem sparseBatchUpdate_subset_union (A B : Finset (Clause V)) : + sparseBatchUpdate A B ⊆ B ∪ A := by + classical + intro C hC + rcases mem_sparseBatchUpdate.mp hC with hB | ⟨hA, _⟩ + · exact Finset.mem_union.mpr (Or.inl hB) + · exact Finset.mem_union.mpr (Or.inr hA) + +theorem sparseBatchUpdate_mono_left {A A' B : Finset (Clause V)} (h : A ⊆ A') : + sparseBatchUpdate A B ⊆ sparseBatchUpdate A' B := by + intro C hC + rcases mem_sparseBatchUpdate.mp hC with hB | ⟨hA, hn⟩ + · exact mem_sparseBatchUpdate.mpr (Or.inl hB) + · exact mem_sparseBatchUpdate.mpr (Or.inr ⟨h hA, hn⟩) + +theorem sparseBatchUpdate_dominates (A B : Finset (Clause V)) {C : Clause V} + (hC : C ∈ A) : ∃ D ∈ sparseBatchUpdate A B, D ⊆ C := by + classical + by_cases h : ∃ D ∈ B, D ⊆ C + · obtain ⟨D, hD, hDC⟩ := h + exact ⟨D, batch_subset_sparseBatchUpdate A B hD, hDC⟩ + · exact ⟨C, mem_sparseBatchUpdate.mpr (Or.inr ⟨hC, h⟩), Finset.Subset.refl _⟩ + +theorem sparseBatchUpdate_satisfies (A B : Finset (Clause V)) (x : Cube V) : + (∀ C ∈ sparseBatchUpdate A B, C.eval x = true) ↔ + (∀ C ∈ A, C.eval x = true) ∧ (∀ D ∈ B, D.eval x = true) := by + classical + constructor + · intro h + refine ⟨?_, fun D hD => h D (batch_subset_sparseBatchUpdate A B hD)⟩ + intro C hC + obtain ⟨D, hD, hDC⟩ := sparseBatchUpdate_dominates A B hC + exact Clause.eval_mono hDC (h D hD) + · rintro ⟨hA, hB⟩ C hC + rcases mem_sparseBatchUpdate.mp hC with hC | ⟨hC, _⟩ + · exact hB C hC + · exact hA C hC + +private theorem bool_eq_of_true_iff {a b : Bool} (h : a = true ↔ b = true) : a = b := by + cases a <;> cases b <;> simp_all + +structure SparseState (V : Type uDepth2) where + active : Finset (Clause V) + side : Finset (Literal V) + added : Finset (Clause V) + +namespace SparseState + +def toCNF (s : SparseState V) : CNF V := + s.active.toList ++ s.side.toList.map (fun l => {l}) + +def eval (s : SparseState V) (x : Cube V) : Bool := s.toCNF.eval x + +structure Valid (s : SparseState V) (b : ℕ) : Prop where + normalized : ∀ C ∈ s.active, C.Normalized + nonempty : ∀ C ∈ s.active, C.Nonempty + antichain : ∀ C ∈ s.active, ∀ D ∈ s.active, C ⊆ D → C = D + width_le : ∀ C ∈ s.active, C.width ≤ b + added_subset : s.added ⊆ s.active + +@[simp] theorem eval_eq_true + {V : Type uDepth1} + [DecidableEq V] + (s : SparseState V) (x : Cube V) : + s.eval x = true ↔ + (∀ C ∈ s.active, C.eval x = true) ∧ (∀ l ∈ s.side, l.eval x = true) := by + classical + change CNF.eval (s.active.toList ++ s.side.toList.map (fun l => ({l} : Clause V))) x = true ↔ _ + rw [CNF.eval_eq_true] + constructor + · intro h + refine ⟨?_, ?_⟩ + · intro C hC + exact h C (List.mem_append.mpr (Or.inl (Finset.mem_toList.mpr hC))) + · intro l hl + have hunit := h {l} (List.mem_append.mpr (Or.inr + (List.mem_map.mpr ⟨l, Finset.mem_toList.mpr hl, rfl⟩))) + simpa only [Clause.eval_singleton] using hunit + · rintro ⟨hA, hS⟩ C hC + rcases List.mem_append.mp hC with hC | hC + · exact hA C (Finset.mem_toList.mp hC) + · obtain ⟨l, hl, rfl⟩ := List.mem_map.mp hC + simpa only [Clause.eval_singleton] using hS l (Finset.mem_toList.mp hl) + +def batchUpdate (s : SparseState V) (B : Finset (Clause V)) : SparseState V where + active := sparseBatchUpdate s.active B + side := s.side + added := sparseBatchUpdate s.added B + +@[simp] theorem batchUpdate_active (s : SparseState V) (B : Finset (Clause V)) : + (s.batchUpdate B).active = sparseBatchUpdate s.active B := rfl + +@[simp] theorem batchUpdate_side (s : SparseState V) (B : Finset (Clause V)) : + (s.batchUpdate B).side = s.side := rfl + +@[simp] theorem batchUpdate_added (s : SparseState V) (B : Finset (Clause V)) : + (s.batchUpdate B).added = sparseBatchUpdate s.added B := rfl + +theorem eval_batchUpdate_eq_true (s : SparseState V) (B : Finset (Clause V)) + (x : Cube V) : + (s.batchUpdate B).eval x = true ↔ s.eval x = true ∧ ∀ C ∈ B, C.eval x = true := by + rw [eval_eq_true, eval_eq_true] + change ((∀ C ∈ sparseBatchUpdate s.active B, C.eval x = true) ∧ + (∀ l ∈ s.side, l.eval x = true)) ↔ _ + rw [sparseBatchUpdate_satisfies] + constructor + · rintro ⟨⟨hA, hB⟩, hS⟩ + exact ⟨⟨hA, hS⟩, hB⟩ + · rintro ⟨⟨hA, hS⟩, hB⟩ + exact ⟨⟨hA, hB⟩, hS⟩ + +end SparseState + +structure InsertionBatch (s : SparseState V) (i : ℕ) where + clauses : Finset (Clause V) + size : ℕ + nonempty : clauses.Nonempty + size_pos : 0 < size + size_lt : size < i + uniform : ∀ D ∈ clauses, D.card = size + subclause : ∀ D ∈ clauses, ∃ A ∈ s.active, D ⊂ A + pairwise_disjoint : ∀ D ∈ clauses, ∀ E ∈ clauses, D ≠ E → Disjoint D E + +namespace InsertionBatch + +variable {s : SparseState V} {i b : ℕ} + +theorem clause_nonempty + {V : Type uDepth1} + [DecidableEq V] + {s : DepthThreeLowerBound.SparseState V} + {i : ℕ} + (B : InsertionBatch s i) (D : Clause V) + (hD : D ∈ B.clauses) : D.Nonempty := + Finset.card_pos.mp (by rw [B.uniform D hD]; exact B.size_pos) + +theorem antichain (B : InsertionBatch s i) : + ∀ D ∈ B.clauses, ∀ E ∈ B.clauses, D ⊆ E → D = E := by + classical + intro D hD E hE hDE + by_contra hne + obtain ⟨l, hl⟩ := B.clause_nonempty D hD + exact Finset.disjoint_left.mp (B.pairwise_disjoint D hD E hE hne) hl (hDE hl) + +theorem fresh + {V : Type uDepth1} + [DecidableEq V] + {s : DepthThreeLowerBound.SparseState V} + {i : ℕ} + {b : ℕ} + (B : InsertionBatch s i) (hs : s.Valid b) : + ∀ D ∈ B.clauses, ∀ A ∈ s.active, ¬ A ⊆ D := by + intro D hD A hA hAD + obtain ⟨E, hE, hDE⟩ := B.subclause D hD + have hAE : A = E := hs.antichain A hA E hE (hAD.trans hDE.1) + apply hDE.2 + simpa only [hAE] using hAD + +theorem not_mem_active (B : InsertionBatch s i) (hs : s.Valid b) + {D : Clause V} (hD : D ∈ B.clauses) : D ∉ s.active := + fun hA => B.fresh hs D hD D hA (Finset.Subset.refl _) + +theorem disjoint_active (B : InsertionBatch s i) (hs : s.Valid b) : + Disjoint s.active B.clauses := by + classical + exact Finset.disjoint_left.mpr (fun D hA hB => B.not_mem_active hs hB hA) + +theorem disjoint_added (B : InsertionBatch s i) (hs : s.Valid b) : + Disjoint s.added B.clauses := by + classical + exact Finset.disjoint_left.mpr + (fun D hA hB => B.not_mem_active hs hB (hs.added_subset hA)) + +theorem removed_strict (B : InsertionBatch s i) (hs : s.Valid b) + {C : Clause V} (hC : C ∈ s.active) + (hnot : C ∉ sparseBatchUpdate s.active B.clauses) : + ∃ D ∈ B.clauses, D ⊂ C := by + classical + have hex : ∃ D ∈ B.clauses, D ⊆ C := by + by_contra hnone + exact hnot (mem_sparseBatchUpdate.mpr (Or.inr ⟨hC, hnone⟩)) + obtain ⟨D, hD, hDC⟩ := hex + exact ⟨D, hD, hDC, B.fresh hs D hD C hC⟩ + +theorem normalized + {V : Type uDepth1} + [DecidableEq V] + {s : DepthThreeLowerBound.SparseState V} + {i : ℕ} + {b : ℕ} + (B : InsertionBatch s i) (hs : s.Valid b) + {D : Clause V} (hD : D ∈ B.clauses) : D.Normalized := by + obtain ⟨A, hA, hDA⟩ := B.subclause D hD + exact (hs.normalized A hA).subset hDA.1 + +theorem width_le + {V : Type uDepth1} + [DecidableEq V] + {s : DepthThreeLowerBound.SparseState V} + {i : ℕ} + {b : ℕ} + (B : InsertionBatch s i) (hs : s.Valid b) + {D : Clause V} (hD : D ∈ B.clauses) : D.width ≤ b := by + obtain ⟨A, hA, hDA⟩ := B.subclause D hD + exact (Clause.width_mono hDA.1).trans (hs.width_le A hA) + +theorem valid_batchUpdate (B : InsertionBatch s i) (hs : s.Valid b) : + (s.batchUpdate B.clauses).Valid b := by + classical + refine ⟨?_, ?_, ?_, ?_, sparseBatchUpdate_mono_left hs.added_subset⟩ + · intro C hC + rcases mem_sparseBatchUpdate.mp hC with hB | ⟨hA, _⟩ + · exact B.normalized hs hB + · exact hs.normalized C hA + · intro C hC + rcases mem_sparseBatchUpdate.mp hC with hB | ⟨hA, _⟩ + · exact B.clause_nonempty C hB + · exact hs.nonempty C hA + · intro C hC D hD hCD + rcases mem_sparseBatchUpdate.mp hC with hCB | ⟨hCA, hCnot⟩ + · rcases mem_sparseBatchUpdate.mp hD with hDB | ⟨hDA, hDnot⟩ + · exact B.antichain C hCB D hDB hCD + · exact (hDnot ⟨C, hCB, hCD⟩).elim + · rcases mem_sparseBatchUpdate.mp hD with hDB | ⟨hDA, hDnot⟩ + · exact (B.fresh hs D hDB C hCA hCD).elim + · exact hs.antichain C hCA D hDA hCD + · intro C hC + rcases mem_sparseBatchUpdate.mp hC with hB | ⟨hA, _⟩ + · exact B.width_le hs hB + · exact hs.width_le C hA + +theorem literal_occurrences_le_one (B : InsertionBatch s i) (u : ℕ) + (l : Literal V) : literalOccurrences B.clauses u l ≤ 1 := by + classical + apply Finset.card_le_one.mpr + intro D hD E hE + obtain ⟨hDsize, hlD⟩ := Finset.mem_filter.mp hD + obtain ⟨hEsize, hlE⟩ := Finset.mem_filter.mp hE + have hDB := (mem_clausesOfSize.mp hDsize).1 + have hEB := (mem_clausesOfSize.mp hEsize).1 + by_contra hne + exact Finset.disjoint_left.mp (B.pairwise_disjoint D hDB E hEB hne) hlD hlE + +@[simp] theorem added_eq (B : InsertionBatch s i) : + (s.batchUpdate B.clauses).added = sparseBatchUpdate s.added B.clauses := rfl + +end InsertionBatch + +section SignedSunflower + +structure SignedSunflower (s : SparseState V) (i r : ℕ) where + family : Finset (Clause V) + core : Clause V + subset_active : family ⊆ s.active + card_family : family.card = r + two_le : 2 ≤ r + uniform : ∀ A ∈ family, A.card = i + core_nonempty : core.Nonempty + sunflower : Sunflower family core + +namespace SignedSunflower + +variable {s : SparseState V} {i r b : ℕ} + +theorem card_family_ge_two (f : SignedSunflower s i r) : 2 ≤ f.family.card := by + rw [f.card_family] + exact f.two_le + +theorem family_nonempty (f : SignedSunflower s i r) : f.family.Nonempty := + Finset.card_pos.mp (by have := f.card_family_ge_two; omega) + +theorem size_ge_two (f : SignedSunflower s i r) : 2 ≤ i := by + have hc := Finset.card_pos.mpr f.core_nonempty + have hi := f.sunflower.core_card_lt f.card_family_ge_two f.uniform + omega + +theorem size_le (f : SignedSunflower s i r) (hs : s.Valid b) : i ≤ b := by + obtain ⟨A, hA⟩ := f.family_nonempty + rw [← f.uniform A hA, (hs.normalized A (f.subset_active hA)).card_eq_width] + exact hs.width_le A (f.subset_active hA) + +def petals (f : SignedSunflower s i r) : Finset (Clause V) := + f.family.image (fun A => A \ f.core) + +@[simp] theorem mem_petals (f : SignedSunflower s i r) (D : Clause V) : + D ∈ f.petals ↔ ∃ A ∈ f.family, A \ f.core = D := Finset.mem_image + +def coreBatch (f : SignedSunflower s i r) : InsertionBatch s i where + clauses := {f.core} + size := f.core.card + nonempty := Finset.singleton_nonempty _ + size_pos := Finset.card_pos.mpr f.core_nonempty + size_lt := f.sunflower.core_card_lt f.card_family_ge_two f.uniform + uniform := by intro D hD; simp only [Finset.mem_singleton.mp hD] + subclause := by + intro D hD + have hDcore : D = f.core := Finset.mem_singleton.mp hD + subst D + obtain ⟨A, hA⟩ := f.family_nonempty + refine ⟨A, f.subset_active hA, f.sunflower.core_subset f.card_family_ge_two hA, ?_⟩ + intro hAC + have hle := Finset.card_le_card hAC + have hlt := f.sunflower.core_card_lt f.card_family_ge_two f.uniform + rw [f.uniform A hA] at hle + omega + pairwise_disjoint := by + intro D hD E hE hne + exact (hne ((Finset.mem_singleton.mp hD).trans (Finset.mem_singleton.mp hE).symm)).elim + +def petalBatch (f : SignedSunflower s i r) : InsertionBatch s i where + clauses := f.petals + size := i - f.core.card + nonempty := by + obtain ⟨A, hA⟩ := f.family_nonempty + exact ⟨A \ f.core, Finset.mem_image.mpr ⟨A, hA, rfl⟩⟩ + size_pos := Nat.sub_pos_of_lt (f.sunflower.core_card_lt f.card_family_ge_two f.uniform) + size_lt := by + have hc := Finset.card_pos.mpr f.core_nonempty + have hi := f.sunflower.core_card_lt f.card_family_ge_two f.uniform + omega + uniform := by + intro D hD + obtain ⟨A, hA, rfl⟩ := Finset.mem_image.mp hD + exact f.sunflower.petal_card f.card_family_ge_two f.uniform hA + subclause := by + intro D hD + obtain ⟨A, hA, rfl⟩ := Finset.mem_image.mp hD + refine ⟨A, f.subset_active hA, Finset.sdiff_subset, ?_⟩ + intro hAsub + have hle := Finset.card_le_card hAsub + have hlt := f.sunflower.petal_card_lt f.card_family_ge_two f.uniform f.core_nonempty hA + rw [f.uniform A hA] at hle + omega + pairwise_disjoint := by + intro D hD E hE hne + obtain ⟨A, hA, rfl⟩ := Finset.mem_image.mp hD + obtain ⟨B, hB, rfl⟩ := Finset.mem_image.mp hE + apply f.sunflower.petals_disjoint hA hB + intro hAB + exact hne (congrArg (fun C => C \ f.core) hAB) + +def batch (f : SignedSunflower s i r) (choice : Bool) : InsertionBatch s i := + if choice then f.petalBatch else f.coreBatch + +def coreBranch (f : SignedSunflower s i r) : SparseState V := + s.batchUpdate f.coreBatch.clauses + +def petalBranch (f : SignedSunflower s i r) : SparseState V := + { s.batchUpdate f.petalBatch.clauses with side := s.side ∪ f.core.image Literal.compl } + +def branch (f : SignedSunflower s i r) (choice : Bool) : SparseState V := + if choice then f.petalBranch else f.coreBranch + +@[simp] theorem branch_active (f : SignedSunflower s i r) (choice : Bool) : + (f.branch choice).active = sparseBatchUpdate s.active (f.batch choice).clauses := by + cases choice <;> rfl + +@[simp] theorem branch_added (f : SignedSunflower s i r) (choice : Bool) : + (f.branch choice).added = sparseBatchUpdate s.added (f.batch choice).clauses := by + cases choice <;> rfl + +theorem batch_card (f : SignedSunflower s i r) (choice : Bool) : + (f.batch choice).clauses.card = if choice then r else 1 := by + cases choice + · exact Finset.card_singleton _ + · exact (f.sunflower.card_petals f.card_family_ge_two).trans f.card_family + +theorem coreBranch_valid (f : SignedSunflower s i r) (hs : s.Valid b) : + f.coreBranch.Valid b := f.coreBatch.valid_batchUpdate hs + +theorem petalBranch_valid (f : SignedSunflower s i r) (hs : s.Valid b) : + f.petalBranch.Valid b := by + have h := f.petalBatch.valid_batchUpdate hs + exact ⟨h.normalized, h.nonempty, h.antichain, h.width_le, h.added_subset⟩ + +theorem branch_valid (f : SignedSunflower s i r) (choice : Bool) (hs : s.Valid b) : + (f.branch choice).Valid b := by + cases choice + · exact f.coreBranch_valid hs + · exact f.petalBranch_valid hs + +theorem core_false_iff_complement_units (C : Clause V) (x : Cube V) : + C.eval x = false ↔ ∀ l ∈ C.image Literal.compl, l.eval x = true := by + constructor + · intro hC l hl + obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hl + have haf : a.eval x = false := by + cases hax : a.eval x + · rfl + · have hCt : C.eval x = true := + (Clause.eval_eq_true C x).mpr ⟨a, ha, (Literal.eval_eq_true a x).mp hax⟩ + exact (Bool.false_ne_true (hC.symm.trans hCt)).elim + simp only [Literal.eval_compl, haf, Bool.not_false] + · intro h + cases hC : C.eval x + · rfl + · obtain ⟨a, ha, hax⟩ := (Clause.eval_eq_true C x).mp hC + have hat : a.eval x = true := (Literal.eval_eq_true a x).mpr hax + have hbad := h a.compl (Finset.mem_image.mpr ⟨a, ha, rfl⟩) + simp only [Literal.eval_compl, hat, Bool.not_true] at hbad + exact (Bool.false_ne_true hbad).elim + +theorem petals_true_of_core_false (f : SignedSunflower s i r) (x : Cube V) + (hA : ∀ C ∈ s.active, C.eval x = true) (hC : f.core.eval x = false) : + ∀ P ∈ f.petals, P.eval x = true := by + intro P hP + obtain ⟨A, hAfamily, rfl⟩ := Finset.mem_image.mp hP + obtain ⟨l, hlA, hlx⟩ := (Clause.eval_eq_true A x).mp (hA A (f.subset_active hAfamily)) + have hlnot : l ∉ f.core := by + intro hlcore + have htrue := (Clause.eval_eq_true f.core x).mpr ⟨l, hlcore, hlx⟩ + exact Bool.false_ne_true (hC.symm.trans htrue) + exact (Clause.eval_eq_true (A \ f.core) x).mpr + ⟨l, Finset.mem_sdiff.mpr ⟨hlA, hlnot⟩, hlx⟩ + +theorem eval_coreBranch (f : SignedSunflower s i r) (x : Cube V) : + f.coreBranch.eval x = (s.eval x && f.core.eval x) := by + apply bool_eq_of_true_iff + change (s.batchUpdate {f.core}).eval x = true ↔ _ + rw [SparseState.eval_batchUpdate_eq_true, Bool.and_eq_true] + simp only [Finset.mem_singleton, forall_eq] + +theorem eval_petalBranch (f : SignedSunflower s i r) (x : Cube V) : + f.petalBranch.eval x = (s.eval x && !(f.core.eval x)) := by + apply bool_eq_of_true_iff + rw [SparseState.eval_eq_true, Bool.and_eq_true, SparseState.eval_eq_true] + change ((∀ C ∈ sparseBatchUpdate s.active f.petals, C.eval x = true) ∧ + (∀ l ∈ s.side ∪ f.core.image Literal.compl, l.eval x = true)) ↔ _ + rw [sparseBatchUpdate_satisfies] + constructor + · rintro ⟨⟨hA, _hP⟩, hS⟩ + have hc : f.core.eval x = false := + (core_false_iff_complement_units f.core x).mpr + (fun l hl => hS l (Finset.mem_union.mpr (Or.inr hl))) + refine ⟨⟨hA, fun l hl => hS l (Finset.mem_union.mpr (Or.inl hl))⟩, ?_⟩ + simp only [hc, Bool.not_false] + · rintro ⟨⟨hA, hS⟩, hnot⟩ + have hc : f.core.eval x = false := by + cases he : f.core.eval x <;> simp_all + refine ⟨⟨hA, f.petals_true_of_core_false x hA hc⟩, ?_⟩ + intro l hl + rcases Finset.mem_union.mp hl with hl | hl + · exact hS l hl + · exact (core_false_iff_complement_units f.core x).mp hc l hl + +theorem branch_indicator (f : SignedSunflower s i r) (x : Cube V) : + indicator (s.eval x) = indicator (f.coreBranch.eval x) + + indicator (f.petalBranch.eval x) := by + rw [f.eval_coreBranch, f.eval_petalBranch] + cases s.eval x <;> cases f.core.eval x <;> simp + +theorem branch_disjoint (f : SignedSunflower s i r) (x : Cube V) : + ¬ (f.coreBranch.eval x = true ∧ f.petalBranch.eval x = true) := by + rw [f.eval_coreBranch, f.eval_petalBranch] + cases s.eval x <;> cases f.core.eval x <;> simp + +end SignedSunflower +end SignedSunflower + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparseCorrelation.lean b/lean/OAI/Computability/DepthThree/SparseCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..cac1aa9ddd76169b13f54acc4cce01849f53ca58 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparseCorrelation.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DepthThree.SparsePartition +import OAI.Computability.DepthThree.RestrictionCorrelation + +namespace OAI + +noncomputable section + +namespace DepthThreeLowerBound + +open scoped BigOperators Classical + +universe u + +namespace SparsePartition + +variable {V : Type u} [Fintype V] + +theorem correlation_eq_sum {H : CNF V} {b M : ℕ} {η : ℝ} + (P : SparsePartition H b M η) (G : Cube V → ℝ) : + finiteAvg (fun x => G x * indicator (H.eval x)) = + ∑ i, finiteAvg (fun x => G x * indicator ((P.piece i).eval x)) := by + calc + finiteAvg (fun x => G x * indicator (H.eval x)) = + finiteAvg (fun x => ∑ i, G x * indicator ((P.piece i).eval x)) := by + apply finiteAvg_congr + intro x + rw [P.indicator_eq_sum x, Finset.mul_sum] + _ = _ := finiteAvg_sum Finset.univ + (fun i x => G x * indicator ((P.piece i).eval x)) + +theorem abs_correlation_le {H : CNF V} {b M : ℕ} {η δ : ℝ} + (P : SparsePartition H b M η) (G : Cube V → ℝ) (hδ : 0 ≤ δ) + (hpiece : ∀ i, |finiteAvg (fun x => G x * indicator ((P.piece i).eval x))| ≤ δ) : + |finiteAvg (fun x => G x * indicator (H.eval x))| ≤ + (2 : ℝ) ^ (η * (Fintype.card V : ℝ)) * δ := by + rw [P.correlation_eq_sum G] + calc + |∑ i, finiteAvg (fun x => G x * indicator ((P.piece i).eval x))| ≤ + ∑ i, |finiteAvg (fun x => G x * indicator ((P.piece i).eval x))| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ _i : Fin P.count, δ := Finset.sum_le_sum (fun i _ => hpiece i) + _ = (P.count : ℝ) * δ := by simp + _ ≤ _ := mul_le_mul_of_nonneg_right P.count_le hδ + +end SparsePartition + +theorem exists_sparse_correlation_transfer (b : ℕ) (η : ℝ) + (hb : 1 ≤ b) (hη : 0 < η) : + ∃ M : ℕ, 0 < M ∧ + ∀ (V : Type u) [Fintype V] [DecidableEq V] (G : Cube V → ℝ) (δ : ℝ), + 0 ≤ δ → + (∀ H : CNF V, H.Normalized → H.WidthAtMost b → + H.length ≤ M * Fintype.card V → + |finiteAvg (fun x => G x * indicator (H.eval x))| ≤ δ) → + corr b G ≤ (2 : ℝ) ^ (η * (Fintype.card V : ℝ)) * δ := by + obtain ⟨M, hM, hpartition⟩ := exists_sparse_partition_constant b η hb hη + refine ⟨M, hM, ?_⟩ + intro V _ _ G δ hδ htests + apply corr_le_of_forall + intro H hH + obtain ⟨P⟩ := hpartition V H hH + apply P.abs_correlation_le G hδ + intro i + exact Eq.mp + (congrArg (fun inst : Fintype (Cube V) => + |@finiteAvg (Cube V) inst (fun x => G x * indicator ((P.piece i).eval x))| ≤ δ) + (Subsingleton.elim _ _)) + (htests (P.piece i) (P.normalized i) (P.width_le i) (P.clauses_le i)) + +theorem exists_sparse_correlation_constant (b : ℕ) (hb : 1 ≤ b) : + ∃ M : ℕ, 0 < M ∧ + ∀ (V : Type u) [Fintype V] [DecidableEq V] (G : Cube V → ℝ), + (∀ H : CNF V, H.Normalized → H.WidthAtMost b → + H.length ≤ M * Fintype.card V → + |finiteAvg (fun x => G x * indicator (H.eval x))| ≤ + (2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4)) → + corr b G ≤ (2 : ℝ) ^ (-(Fintype.card V : ℝ) / 8) := by + obtain ⟨M, hM, htransfer⟩ := exists_sparse_correlation_transfer b (1 / 8) hb (by norm_num) + refine ⟨M, hM, ?_⟩ + intro V _ _ G htests + have h := htransfer V G ((2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4)) + (Real.rpow_nonneg (by norm_num) _) htests + calc + corr b G ≤ (2 : ℝ) ^ ((1 / 8) * (Fintype.card V : ℝ)) * + (2 : ℝ) ^ (-(Fintype.card V : ℝ) / 4) := h + _ = (2 : ℝ) ^ (-(Fintype.card V : ℝ) / 8) := by + rw [← Real.rpow_add (by norm_num : (0 : ℝ) < 2)] + congr 1 + ring + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparseCounting.lean b/lean/OAI/Computability/DepthThree/SparseCounting.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ce405cc37cab8f14295939fd964af0271e36e7f --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparseCounting.lean @@ -0,0 +1,222 @@ +import OAI.Computability.DepthThree.Core +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Data.Fintype.Prod + +namespace OAI + +universe uDepth1 + +noncomputable section + +open scoped BigOperators + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} +variable [instDecidableEqV : DecidableEq V] + +def clausesOfSize (A : Finset (Clause V)) (u : ℕ) : Finset (Clause V) := + A.filter (fun C => C.card = u) + +def literalOccurrences (A : Finset (Clause V)) (u : ℕ) (l : Literal V) : ℕ := by + classical + exact ((clausesOfSize A u).filter (fun C => l ∈ C)).card + +@[simp] theorem mem_clausesOfSize + {V : Type uDepth1} + [DecidableEq V] + {A : Finset (Clause V)} {u : ℕ} {C : Clause V} : + C ∈ clausesOfSize A u ↔ C ∈ A ∧ C.card = u := by + simp [clausesOfSize] + +theorem clausesOfSize_subset + {V : Type uDepth1} + [DecidableEq V] + (A : Finset (Clause V)) (u : ℕ) : + clausesOfSize A u ⊆ A := Finset.filter_subset _ _ + +theorem clausesOfSize_mono + {V : Type uDepth1} + [DecidableEq V] + {A B : Finset (Clause V)} (h : A ⊆ B) (u : ℕ) : + clausesOfSize A u ⊆ clausesOfSize B u := + Finset.filter_subset_filter _ h + +theorem clausesOfSize_eq_self + {V : Type uDepth1} + [DecidableEq V] + (A : Finset (Clause V)) (u : ℕ) + (h : ∀ C ∈ A, C.card = u) : clausesOfSize A u = A := + Finset.filter_eq_self.mpr h + +theorem clausesOfSize_eq_empty + {V : Type uDepth1} + [DecidableEq V] + (A : Finset (Clause V)) (u : ℕ) + (h : ∀ C ∈ A, C.card ≠ u) : clausesOfSize A u = ∅ := by + exact Finset.filter_eq_empty_iff.mpr (fun C hC => h C hC) + +theorem literalOccurrences_mono {A B : Finset (Clause V)} (h : A ⊆ B) + (u : ℕ) (l : Literal V) : literalOccurrences A u l ≤ literalOccurrences B u l := by + classical + exact Finset.card_le_card (Finset.filter_subset_filter _ (clausesOfSize_mono h u)) + +theorem literalOccurrences_le_card (A : Finset (Clause V)) (u : ℕ) (l : Literal V) : + literalOccurrences A u l ≤ (clausesOfSize A u).card := by + classical + exact Finset.card_filter_le _ _ + +theorem literalOccurrences_one_le (A : Finset (Clause V)) (l : Literal V) : + literalOccurrences A 1 l ≤ 1 := by + classical + unfold literalOccurrences + apply Finset.card_le_one.mpr + intro C hC D hD + obtain ⟨hCA, hlC⟩ := Finset.mem_filter.mp hC + obtain ⟨hDA, hlD⟩ := Finset.mem_filter.mp hD + obtain ⟨c, hc⟩ := Finset.card_eq_one.mp (mem_clausesOfSize.mp hCA).2 + obtain ⟨d, hd⟩ := Finset.card_eq_one.mp (mem_clausesOfSize.mp hDA).2 + rw [hc] at hlC + rw [hd] at hlD + have hcd : c = d := (Finset.mem_singleton.mp hlC).symm.trans + (Finset.mem_singleton.mp hlD) + rw [hc, hd, hcd] + +theorem clausesOfSize_union (A B : Finset (Clause V)) (u : ℕ) : + clausesOfSize (A ∪ B) u = clausesOfSize A u ∪ clausesOfSize B u := by + classical + exact Finset.filter_union _ _ _ + +theorem literalOccurrences_union_le (A B : Finset (Clause V)) (u : ℕ) (l : Literal V) : + literalOccurrences (A ∪ B) u l ≤ + literalOccurrences A u l + literalOccurrences B u l := by + classical + unfold literalOccurrences + rw [clausesOfSize_union, Finset.filter_union] + exact Finset.card_union_le _ _ + +theorem clausesOfSize_card_le [Fintype V] (A : Finset (Clause V)) (u n : ℕ) + (hne : ∀ C ∈ clausesOfSize A u, C.Nonempty) + (hocc : ∀ l, literalOccurrences A u l ≤ n) : + (clausesOfSize A u).card ≤ (2 * Fintype.card V) * n := by + classical + calc + (clausesOfSize A u).card = ∑ _C ∈ clausesOfSize A u, 1 := + Finset.card_eq_sum_ones _ + _ ≤ ∑ C ∈ clausesOfSize A u, C.card := + Finset.sum_le_sum (fun C hC => (hne C hC).card_pos) + _ ≤ Fintype.card (Literal V) * n := Finset.sum_card_le hocc + _ = (2 * Fintype.card V) * n := by + simp only [Literal, Fintype.card_prod, Fintype.card_bool, Nat.mul_comm] + +theorem subsumed_by_clause_card_le (A : Finset (Clause V)) (u n : ℕ) + (hocc : ∀ l, literalOccurrences A u l ≤ n) + (D : Clause V) (hD : D.Nonempty) : + ((clausesOfSize A u).filter (fun C => D ⊆ C)).card ≤ n := by + classical + obtain ⟨l, hl⟩ := hD + have hsub : (clausesOfSize A u).filter (fun C => D ⊆ C) ⊆ + (clausesOfSize A u).filter (fun C => l ∈ C) := by + intro C hC + obtain ⟨hCA, hDC⟩ := Finset.mem_filter.mp hC + exact Finset.mem_filter.mpr ⟨hCA, hDC hl⟩ + exact (Finset.card_le_card hsub).trans (hocc l) + +theorem deleted_clausesOfSize_card_le (A B R : Finset (Clause V)) (u n : ℕ) + (hne : ∀ D ∈ B, D.Nonempty) + (hocc : ∀ l, literalOccurrences A u l ≤ n) + (hsub : R ⊆ clausesOfSize A u) + (hcover : ∀ C ∈ R, ∃ D ∈ B, D ⊆ C) : + R.card ≤ B.card * n := by + classical + let receiver := fun D : Clause V => (clausesOfSize A u).filter (fun C => D ⊆ C) + have hR : R ⊆ B.biUnion receiver := by + intro C hC + obtain ⟨D, hDB, hDC⟩ := hcover C hC + exact Finset.mem_biUnion.mpr + ⟨D, hDB, Finset.mem_filter.mpr ⟨hsub hC, hDC⟩⟩ + exact (Finset.card_le_card hR).trans + (Finset.card_biUnion_le_card_mul B receiver n + (fun D hD => subsumed_by_clause_card_le A u n hocc D (hne D hD))) + +def subsumedOfSize (A B : Finset (Clause V)) (u : ℕ) : Finset (Clause V) := by + classical + exact (clausesOfSize A u).filter (fun C => ∃ D ∈ B, D ⊆ C) + +theorem subsumedOfSize_card_le (A B : Finset (Clause V)) (u n : ℕ) + (hne : ∀ D ∈ B, D.Nonempty) + (hocc : ∀ l, literalOccurrences A u l ≤ n) : + (subsumedOfSize A B u).card ≤ B.card * n := by + classical + apply deleted_clausesOfSize_card_le A B (subsumedOfSize A B u) u n hne hocc + · exact Finset.filter_subset _ _ + · intro C hC + exact (Finset.mem_filter.mp hC).2 + +theorem clausesOfSize_update_balance + (A B : Finset (Clause V)) (u : ℕ) (hfresh : Disjoint A B) : + (clausesOfSize (B ∪ A.filter (fun C => ¬ ∃ D ∈ B, D ⊆ C)) u).card + + (subsumedOfSize A B u).card = + (clausesOfSize A u).card + (clausesOfSize B u).card := by + classical + let P := fun C : Clause V => ∃ D ∈ B, D ⊆ C + let S := (clausesOfSize A u).filter (fun C => ¬ P C) + have hdecomp : clausesOfSize (B ∪ A.filter (fun C => ¬ P C)) u = + clausesOfSize B u ∪ S := by + ext C + simp only [clausesOfSize, Finset.mem_filter, Finset.mem_union, S] + constructor + · rintro ⟨hC, hsize⟩ + rcases hC with hCB | ⟨hCA, hP⟩ + · exact Or.inl ⟨hCB, hsize⟩ + · exact Or.inr ⟨⟨hCA, hsize⟩, hP⟩ + · rintro (⟨hCB, hsize⟩ | ⟨⟨hCA, hsize⟩, hP⟩) + · exact ⟨Or.inl hCB, hsize⟩ + · exact ⟨Or.inr ⟨hCA, hP⟩, hsize⟩ + have hdisj : Disjoint (clausesOfSize B u) S := by + apply Finset.disjoint_left.mpr + intro C hCB hCS + exact Finset.disjoint_left.mp hfresh + (Finset.mem_filter.mp (Finset.mem_filter.mp hCS).1).1 + (Finset.mem_filter.mp hCB).1 + have hpartition : (subsumedOfSize A B u).card + S.card = + (clausesOfSize A u).card := by + change ((clausesOfSize A u).filter P).card + + ((clausesOfSize A u).filter (fun C => ¬ P C)).card = _ + have hfilters : Disjoint ((clausesOfSize A u).filter P) + ((clausesOfSize A u).filter (fun C => ¬ P C)) := by + apply Finset.disjoint_left.mpr + intro C hC hC' + exact (Finset.mem_filter.mp hC').2 (Finset.mem_filter.mp hC).2 + rw [← Finset.card_union_of_disjoint hfilters] + apply congrArg Finset.card + ext C + simp only [Finset.mem_union, Finset.mem_filter] + by_cases hPC : P C <;> simp [hPC] + change (clausesOfSize (B ∪ A.filter (fun C => ¬ P C)) u).card + + (subsumedOfSize A B u).card = _ + rw [hdecomp, Finset.card_union_of_disjoint hdisj] + calc + (clausesOfSize B u).card + S.card + (subsumedOfSize A B u).card = + ((subsumedOfSize A B u).card + S.card) + (clausesOfSize B u).card := by + simp only [Nat.add_comm, Nat.add_left_comm] + _ = _ := by rw [hpartition] + +theorem literalOccurrences_update_le (A B : Finset (Clause V)) + (u : ℕ) (l : Literal V) : + literalOccurrences (B ∪ A.filter (fun C => ¬ ∃ D ∈ B, D ⊆ C)) u l ≤ + literalOccurrences A u l + literalOccurrences B u l := by + classical + have hsub : B ∪ A.filter (fun C => ¬ ∃ D ∈ B, D ⊆ C) ⊆ A ∪ B := by + intro C hC + rcases Finset.mem_union.mp hC with hCB | hCA + · exact Finset.mem_union.mpr (Or.inr hCB) + · exact Finset.mem_union.mpr (Or.inl (Finset.mem_filter.mp hCA).1) + exact (literalOccurrences_mono hsub u l).trans + (literalOccurrences_union_le A B u l) + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparseFiniteFamily.lean b/lean/OAI/Computability/DepthThree/SparseFiniteFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..95c4e2e4ab59b301263a2d2cf158cff9a057a548 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparseFiniteFamily.lean @@ -0,0 +1,69 @@ +import Mathlib.Data.Finset.Max +import Mathlib.Data.Finset.Card + +namespace OAI + +universe uDepth1 + +namespace DepthThreeLowerBound + +variable {α : Type uDepth1} + +noncomputable def sparseMinimalFamily (A : Finset (Finset α)) : Finset (Finset α) := by + classical + exact A.filter (fun C => ∀ D ∈ A, D ⊆ C → C ⊆ D) + +theorem mem_sparseMinimalFamily {A : Finset (Finset α)} {C : Finset α} : + C ∈ sparseMinimalFamily A ↔ C ∈ A ∧ ∀ D ∈ A, D ⊆ C → C ⊆ D := by + classical + simp only [sparseMinimalFamily, Finset.mem_filter] + +theorem sparseMinimalFamily_subset (A : Finset (Finset α)) : + sparseMinimalFamily A ⊆ A := by + intro C hC + exact (mem_sparseMinimalFamily.mp hC).1 + +theorem sparseMinimalFamily_antichain (A : Finset (Finset α)) : + ∀ C ∈ sparseMinimalFamily A, ∀ D ∈ sparseMinimalFamily A, C ⊆ D → C = D := by + intro C hC D hD hCD + apply Finset.Subset.antisymm hCD + exact (mem_sparseMinimalFamily.mp hD).2 C + (sparseMinimalFamily_subset A hC) hCD + +theorem exists_mem_sparseMinimalFamily_subset {A : Finset (Finset α)} + {C : Finset α} (hC : C ∈ A) : + ∃ D ∈ sparseMinimalFamily A, D ⊆ C := by + classical + let candidates := A.filter (fun D => D ⊆ C) + have hne : candidates.Nonempty := by + refine ⟨C, ?_⟩ + exact Finset.mem_filter.mpr ⟨hC, Finset.Subset.refl _⟩ + obtain ⟨D, hD, hmin⟩ := candidates.exists_min_image Finset.card hne + have hDA : D ∈ A := (Finset.mem_filter.mp hD).1 + have hDC : D ⊆ C := (Finset.mem_filter.mp hD).2 + refine ⟨D, mem_sparseMinimalFamily.mpr ⟨hDA, ?_⟩, hDC⟩ + intro E hEA hED + have hEc : E ∈ candidates := + Finset.mem_filter.mpr ⟨hEA, Finset.Subset.trans hED hDC⟩ + have hEq : E = D := Finset.eq_of_subset_of_card_le hED (hmin E hEc) + exact Finset.subset_of_eq hEq.symm + +theorem forall_sparseMinimalFamily_iff (A : Finset (Finset α)) + (P : Finset α → Prop) + (hP : ∀ {C D}, C ⊆ D → P C → P D) : + (∀ C ∈ sparseMinimalFamily A, P C) ↔ ∀ C ∈ A, P C := by + constructor + · intro h C hC + obtain ⟨D, hD, hDC⟩ := exists_mem_sparseMinimalFamily_subset hC + exact hP hDC (h D hD) + · intro h C hC + exact h C (sparseMinimalFamily_subset A hC) + +theorem sparseMinimalFamily_empty : + sparseMinimalFamily (∅ : Finset (Finset α)) = ∅ := by + classical + simp [sparseMinimalFamily] + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparseLeafCNF.lean b/lean/OAI/Computability/DepthThree/SparseLeafCNF.lean new file mode 100644 index 0000000000000000000000000000000000000000..0cec83d5cc335b279a6e59f966de98158564e0ac --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparseLeafCNF.lean @@ -0,0 +1,135 @@ +import OAI.Computability.DepthThree.SparseNormalize +import OAI.Computability.DepthThree.SparsePrefix + +namespace OAI + +universe uDepth1 + +noncomputable section + +namespace DepthThreeLowerBound + +open scoped BigOperators + +variable {V : Type uDepth1} [instDecidableEqV : DecidableEq V] + +namespace SparseNormalization + +def toState {H : CNF V} {b : ℕ} (N : SparseNormalization H b) : SparseState V where + active := N.active + side := ∅ + added := ∅ + +theorem toState_valid + {V : Type uDepth1} + [DecidableEq V] + {H : CNF V} {b : ℕ} (N : SparseNormalization H b) : + N.toState.Valid b where + normalized := N.normalized + nonempty := N.nonempty + antichain := N.antichain + width_le := N.width_le + added_subset := Finset.empty_subset _ + +@[simp] theorem toState_added + {V : Type uDepth1} + [DecidableEq V] + {H : CNF V} {b : ℕ} (N : SparseNormalization H b) : + N.toState.added = ∅ := rfl + +theorem toState_eval + {V : Type uDepth1} + [DecidableEq V] + {H : CNF V} {b : ℕ} (N : SparseNormalization H b) + (x : Cube V) : N.toState.eval x = H.eval x := by + simpa only [SparseState.eval, SparseState.toCNF, toState, Finset.toList_empty, + List.map_nil, List.append_nil] using N.eval_eq x + +end SparseNormalization + +namespace SparseState + +theorem toCNF_normalized + {V : Type uDepth1} + [DecidableEq V] + (s : SparseState V) {b : ℕ} + (hs : s.Valid b) : s.toCNF.Normalized := by + intro C hC + rcases List.mem_append.mp hC with hactive | hside + · exact hs.normalized C (Finset.mem_toList.mp hactive) + · obtain ⟨l, _, rfl⟩ := List.mem_map.mp hside + intro v hf ht + have heq := (Finset.mem_singleton.mp hf).trans (Finset.mem_singleton.mp ht).symm + have hfalse : (false : Bool) = true := congrArg Prod.snd heq + cases hfalse + +theorem toCNF_widthAtMost + {V : Type uDepth1} + [DecidableEq V] + (s : SparseState V) {b : ℕ} + (hs : s.Valid b) (hb : 1 ≤ b) : s.toCNF.WidthAtMost b := by + intro C hC + rcases List.mem_append.mp hC with hactive | hside + · exact hs.width_le C (Finset.mem_toList.mp hactive) + · obtain ⟨l, _, rfl⟩ := List.mem_map.mp hside + simpa [Clause.width, Clause.scope] using hb + +@[simp] theorem toCNF_length + {V : Type uDepth1} + [DecidableEq V] + (s : SparseState V) : + s.toCNF.length = s.active.card + s.side.card := by + simp [toCNF] + +theorem active_card_eq_sum_sizes + {V : Type uDepth1} + [DecidableEq V] + (s : SparseState V) {b : ℕ} (hs : s.Valid b) : + s.active.card = ∑ u ∈ Finset.Icc 1 b, (clausesOfSize s.active u).card := by + apply Finset.card_eq_sum_card_fiberwise + intro C hC + apply Finset.mem_Icc.mpr + constructor + · exact (hs.nonempty C hC).card_pos + · rw [(hs.normalized C hC).card_eq_width] + exact hs.width_le C hC + +theorem active_card_le_of_terminal [Fintype V] (s : SparseState V) + {r e D : ℕ → ℕ} {b : ℕ} (hs : s.Valid b) + (hnum : SparseNumerics r e D b) + (hterminal : ∀ i, ¬ Nonempty (SignedSunflower s i (r i))) : + s.active.card ≤ (2 * Fintype.card V) * ∑ u ∈ Finset.Icc 1 b, e u := by + rw [s.active_card_eq_sum_sizes hs, Finset.mul_sum] + apply Finset.sum_le_sum + intro u hu + obtain ⟨hu1, hub⟩ := Finset.mem_Icc.mp hu + apply clausesOfSize_card_le + · intro C hC + exact hs.nonempty C (mem_clausesOfSize.mp hC).1 + · intro l + exact sparse_occurrence_le_of_no_sunflower hnum s u hu1 hub (hterminal u) l + +theorem toCNF_length_le_of_terminal [Fintype V] (s : SparseState V) + {r e D : ℕ → ℕ} {b : ℕ} (hs : s.Valid b) + (hnum : SparseNumerics r e D b) + (hterminal : ∀ i, ¬ Nonempty (SignedSunflower s i (r i))) : + s.toCNF.length ≤ + (2 + 2 * ∑ u ∈ Finset.Icc 1 b, e u) * Fintype.card V := by + have hside : s.side.card ≤ 2 * Fintype.card V := by + have h := Finset.card_le_univ s.side + simpa only [Literal, Fintype.card_prod, Fintype.card_bool, Nat.mul_comm] using h + rw [s.toCNF_length] + calc + s.active.card + s.side.card ≤ + (2 * Fintype.card V) * (∑ u ∈ Finset.Icc 1 b, e u) + + 2 * Fintype.card V := + Nat.add_le_add (s.active_card_le_of_terminal hs hnum hterminal) hside + _ = _ := by ring + +end SparseState + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparseLeafCount.lean b/lean/OAI/Computability/DepthThree/SparseLeafCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f1d654932acbe7ed1f586efb8140028a0a3d947 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparseLeafCount.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DepthThree.SparseStreams +import OAI.Computability.DepthThree.Entropy +import Mathlib.Algebra.Order.BigOperators.Ring.Finset + +namespace OAI + +universe uDepth1 + +namespace DepthThreeLowerBound + +open scoped BigOperators + +namespace SparseDecisionTree + +variable {Label : Type uDepth1} [DecidableEq Label] [Fintype Label] + +theorem card_le_entropy_sum (t : SparseDecisionTree Label) (N r : Label → ℕ) + (hr : ∀ i, 2 ≤ r i) + (hN : ∀ (p : t.Leaf) i, (t.stream p i).length ≤ N i) + (hones : ∀ (p : t.Leaf) i, r i * (t.stream p i).count true ≤ N i) : + (Fintype.card t.Leaf : ℝ) ≤ + (2 : ℝ) ^ (∑ i, (N i : ℝ) * binaryEntropy (1 / (r i : ℝ))) := by + classical + let admitted (i : Label) := sparseBinaryStrings (N i) (1 / (r i : ℝ)) + have hrpos (i : Label) : (0 : ℝ) < r i := by + have htwo : (2 : ℝ) ≤ r i := by exact_mod_cast hr i + linarith + have hhalf (i : Label) : (1 : ℝ) / r i ≤ 1 / 2 := by + apply (div_le_div_iff₀ (hrpos i) (by norm_num : (0 : ℝ) < 2)).mpr + simpa only [one_mul] using (show (2 : ℝ) ≤ r i by exact_mod_cast hr i) + have hmem : ∀ (p : t.Leaf) i, t.padded N p i ∈ admitted i := by + intro p i + have hcast : (r i : ℝ) * ((t.stream p i).count true : ℝ) ≤ N i := by + exact_mod_cast hones p i + have hbound : ((t.stream p i).count true : ℝ) ≤ + (N i : ℝ) * (1 / (r i : ℝ)) := by + rw [mul_one_div] + apply (le_div_iff₀ (hrpos i)).mpr + simpa only [mul_comm] using hcast + simp only [admitted, sparseBinaryStrings, Finset.mem_filter, Finset.mem_univ, + true_and, t.padded_trueCount N p i (hN p i)] + exact hbound + have hnat := t.card_le_prod_admitted N hN admitted hmem + have hreal : (Fintype.card t.Leaf : ℝ) ≤ ∏ i, ((admitted i).card : ℝ) := by + exact_mod_cast hnat + calc + (Fintype.card t.Leaf : ℝ) ≤ ∏ i, ((admitted i).card : ℝ) := hreal + _ ≤ ∏ i, (2 : ℝ) ^ ((N i : ℝ) * binaryEntropy (1 / (r i : ℝ))) := by + apply Finset.prod_le_prod₀ + · intro i _ + exact Nat.cast_nonneg _ + · intro i _ + exact card_sparse_binary_strings_le (N i) (one_div_pos.mpr (hrpos i)) (hhalf i) + _ = _ := (Real.rpow_sum_of_pos (by norm_num : (0 : ℝ) < 2) + (fun i => (N i : ℝ) * binaryEntropy (1 / (r i : ℝ))) Finset.univ).symm + +theorem card_le_of_entropy_budget (t : SparseDecisionTree Label) (N r : Label → ℕ) + (hr : ∀ i, 2 ≤ r i) + (hN : ∀ (p : t.Leaf) i, (t.stream p i).length ≤ N i) + (hones : ∀ (p : t.Leaf) i, r i * (t.stream p i).count true ≤ N i) + {B : ℝ} (hbudget : (∑ i, (N i : ℝ) * binaryEntropy (1 / (r i : ℝ))) ≤ B) : + (Fintype.card t.Leaf : ℝ) ≤ (2 : ℝ) ^ B := + (t.card_le_entropy_sum N r hr hN hones).trans + (Real.rpow_le_rpow_of_exponent_le (by norm_num) hbudget) + +end SparseDecisionTree + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparseNormalize.lean b/lean/OAI/Computability/DepthThree/SparseNormalize.lean new file mode 100644 index 0000000000000000000000000000000000000000..08e7d80bd5b191aa11df602d28644eca3e501e74 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparseNormalize.lean @@ -0,0 +1,107 @@ +import OAI.Computability.DepthThree.Core +import OAI.Computability.DepthThree.SparseFiniteFamily + +namespace OAI + +universe uDepth1 + +namespace DepthThreeLowerBound + +variable {V : Type uDepth1} + +theorem Clause.eval_of_not_normalized {C : Clause V} (hC : ¬ C.Normalized) + (x : Cube V) : C.eval x = true := by + classical + by_contra hx + apply hC + intro v hf ht + cases hv : x v with + | false => exact hx (Clause.eval_eq_true C x |>.mpr ⟨(v, false), hf, hv⟩) + | true => exact hx (Clause.eval_eq_true C x |>.mpr ⟨(v, true), ht, hv⟩) + +theorem CNF.eval_of_empty_mem {H : CNF V} (hH : ∅ ∈ H) (x : Cube V) : + H.eval x = false := by + cases hx : H.eval x with + | false => rfl + | true => + have he := (CNF.eval_eq_true H x).mp hx ∅ hH + simp only [Clause.eval_empty, Bool.false_eq_true] at he + +noncomputable def sparseNormalizedFamily (H : CNF V) : Finset (Clause V) := by + classical + exact H.toFinset.filter Clause.Normalized + +theorem mem_sparseNormalizedFamily {H : CNF V} {C : Clause V} : + C ∈ sparseNormalizedFamily H ↔ C ∈ H ∧ C.Normalized := by + classical + simp [sparseNormalizedFamily] + +private theorem bool_eq_of_true_iff {a b : Bool} (h : a = true ↔ b = true) : a = b := by + cases a <;> cases b <;> simp_all + +theorem sparseNormalizedFamily_eval (H : CNF V) (x : Cube V) : + CNF.eval (sparseNormalizedFamily H).toList x = H.eval x := by + classical + apply bool_eq_of_true_iff + simp only [CNF.eval_eq_true, Finset.mem_toList] + constructor + · intro h C hC + by_cases hn : C.Normalized + · exact h C (mem_sparseNormalizedFamily.mpr ⟨hC, hn⟩) + · exact Clause.eval_of_not_normalized hn x + · intro h C hC + exact h C (mem_sparseNormalizedFamily.mp hC).1 + +theorem sparseMinimalFamily_eval (A : Finset (Clause V)) (x : Cube V) : + CNF.eval (sparseMinimalFamily A).toList x = CNF.eval A.toList x := by + classical + apply bool_eq_of_true_iff + simp only [CNF.eval_eq_true, Finset.mem_toList] + exact forall_sparseMinimalFamily_iff A (fun C => Clause.eval C x = true) + (fun hCD hx => Clause.eval_mono hCD hx) + +structure SparseNormalization (H : CNF V) (b : ℕ) where + active : Finset (Clause V) + normalized : ∀ C ∈ active, C.Normalized + nonempty : ∀ C ∈ active, C.Nonempty + antichain : ∀ C ∈ active, ∀ D ∈ active, C ⊆ D → C = D + width_le : ∀ C ∈ active, C.width ≤ b + eval_eq : ∀ x, CNF.eval active.toList x = H.eval x + +noncomputable def sparseNormalizeOfNoEmpty (H : CNF V) {b : ℕ} + (hwidth : H.WidthAtMost b) (hempty : (∅ : Clause V) ∉ H) : + SparseNormalization H b where + active := sparseMinimalFamily (sparseNormalizedFamily H) + normalized := by + intro C hC + exact (mem_sparseNormalizedFamily.mp + (sparseMinimalFamily_subset _ hC)).2 + nonempty := by + intro C hC + apply Finset.nonempty_iff_ne_empty.mpr + intro hzero + apply hempty + have hCH := (mem_sparseNormalizedFamily.mp + (sparseMinimalFamily_subset _ hC)).1 + simpa only [hzero] using hCH + antichain := sparseMinimalFamily_antichain _ + width_le := by + intro C hC + exact hwidth C ((mem_sparseNormalizedFamily.mp + (sparseMinimalFamily_subset _ hC)).1) + eval_eq := by + intro x + exact (sparseMinimalFamily_eval (sparseNormalizedFamily H) x).trans + (sparseNormalizedFamily_eval H x) + +theorem exists_sparseNormalization_or_false (H : CNF V) {b : ℕ} + (hwidth : H.WidthAtMost b) : + (∀ x, H.eval x = false) ∨ Nonempty (SparseNormalization H b) := by + classical + by_cases hempty : (∅ : Clause V) ∈ H + · exact Or.inl (CNF.eval_of_empty_mem hempty) + · exact Or.inr ⟨sparseNormalizeOfNoEmpty H hwidth hempty⟩ + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparsePartition.lean b/lean/OAI/Computability/DepthThree/SparsePartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b3b3e9cfcc65e6ada63e2a68a06add26510c152 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparsePartition.lean @@ -0,0 +1,141 @@ +import OAI.Computability.DepthThree.SparseThresholds +import OAI.Computability.DepthThree.SparseTree +import OAI.Computability.DepthThree.SparseLeafCount +import OAI.Computability.DepthThree.SparseLeafCNF +import Mathlib.Data.Fintype.EquivFin +import Mathlib.Tactic.FieldSimp + +namespace OAI + +noncomputable section + +namespace DepthThreeLowerBound + +open scoped BigOperators + +universe u + +theorem sparse_entropy_sum_budget (b m : ℕ) (η : ℝ) (hb : 1 ≤ b) (hη : 0 < η) + (r F : ℕ → ℕ) (hF0 : F 0 = 0) (hF1 : F 1 = 0) + (hbound : ∀ i, 2 ≤ i → i ≤ b → + (F i : ℝ) * binaryEntropy (1 / (r i : ℝ)) ≤ η / (b : ℝ)) : + (∑ i : Fin (b + 1), ((F i.val * m : ℕ) : ℝ) * + binaryEntropy (1 / (r i.val : ℝ))) ≤ η * (m : ℝ) := by + have hbpos : (0 : ℝ) < b := by exact_mod_cast (show 0 < b by omega) + have hδ : 0 ≤ η / (b : ℝ) := (div_pos hη hbpos).le + rw [Fin.sum_univ_succ] + simp only [Fin.val_zero, hF0, Nat.cast_zero, zero_mul, zero_add, + Fin.val_succ] + calc + (∑ i : Fin b, ((F (i.val + 1) * m : ℕ) : ℝ) * + binaryEntropy (1 / (r (i.val + 1) : ℝ))) ≤ + ∑ _i : Fin b, (m : ℝ) * (η / (b : ℝ)) := by + apply Finset.sum_le_sum + intro i _ + have hi : (F (i.val + 1) : ℝ) * + binaryEntropy (1 / (r (i.val + 1) : ℝ)) ≤ η / (b : ℝ) := by + by_cases hi1 : i.val + 1 = 1 + · simpa only [hi1, hF1, Nat.cast_zero, zero_mul] using hδ + · exact hbound _ (by omega) (Nat.succ_le_of_lt i.isLt) + simpa only [Nat.cast_mul, mul_assoc, mul_comm, mul_left_comm] using + mul_le_mul_of_nonneg_left hi (Nat.cast_nonneg m) + _ = η * (m : ℝ) := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + field_simp [ne_of_gt hbpos] + +structure SparsePartition {V : Type u} [Fintype V] + (H : CNF V) (b M : ℕ) (η : ℝ) where + count : ℕ + piece : Fin count → CNF V + normalized : ∀ i, (piece i).Normalized + width_le : ∀ i, (piece i).WidthAtMost b + clauses_le : ∀ i, (piece i).length ≤ M * Fintype.card V + disjoint : ∀ i j, i ≠ j → ∀ x, + ¬ ((piece i).eval x = true ∧ (piece j).eval x = true) + indicator_eq_sum : ∀ x, indicator (H.eval x) = + ∑ i, indicator ((piece i).eval x) + count_le : (count : ℝ) ≤ (2 : ℝ) ^ (η * (Fintype.card V : ℝ)) + +theorem exists_sparse_partition_constant (b : ℕ) (η : ℝ) + (hb : 1 ≤ b) (hη : 0 < η) : + ∃ M : ℕ, 0 < M ∧ + ∀ (V : Type u) [Fintype V] [DecidableEq V] (H : CNF V), + H.WidthAtMost b → Nonempty (SparsePartition H b M η) := by + classical + obtain ⟨r, e, D, F, M, hnum, hr, hF0, hF1, hFsum, hentropy, hM, hMpos⟩ := + exists_sparse_numerics b η hb hη + refine ⟨M, hMpos, ?_⟩ + intro V _ _ H hwidth + rcases exists_sparseNormalization_or_false H hwidth with hfalse | hA + · refine ⟨{ + count := 0 + piece := fun i => Fin.elim0 i + normalized := fun i => Fin.elim0 i + width_le := fun i => Fin.elim0 i + clauses_le := fun i => Fin.elim0 i + disjoint := fun i => Fin.elim0 i + indicator_eq_sum := ?_ + count_le := ?_ + }⟩ + · intro x + simp [hfalse x] + · simpa only [Nat.cast_zero] using + (Real.rpow_nonneg (by norm_num : (0 : ℝ) ≤ 2) (η * (Fintype.card V : ℝ))) + · let A : SparseNormalization H b := Classical.choice hA + let s := A.toState + have hs : s.Valid b := A.toState_valid + have hadded : s.added = ∅ := rfl + let T := sparseTree r D b s hs + let eqv := Fintype.equivFin T.tree.Leaf + have hcount : (Fintype.card T.tree.Leaf : ℝ) ≤ + (2 : ℝ) ^ (η * (Fintype.card V : ℝ)) := by + apply T.tree.card_le_of_entropy_budget + (fun i => F i.val * Fintype.card V) (fun i => r i.val) + · intro i + exact hr i.val + · intro p i + rw [hFsum] + exact sparseTree_stream_length hnum s hs hadded p i + · intro p i + rw [hFsum] + exact sparseTree_stream_ones hnum s hs hadded p i + · exact sparse_entropy_sum_budget b (Fintype.card V) η hb hη r F hF0 hF1 hentropy + refine ⟨{ + count := Fintype.card T.tree.Leaf + piece := fun i => (T.finish (eqv.symm i)).toCNF + normalized := ?_ + width_le := ?_ + clauses_le := ?_ + disjoint := ?_ + indicator_eq_sum := ?_ + count_le := hcount + }⟩ + · intro i + exact (T.finish (eqv.symm i)).toCNF_normalized ((T.path (eqv.symm i)).valid hs) + · intro i + exact (T.finish (eqv.symm i)).toCNF_widthAtMost + ((T.path (eqv.symm i)).valid hs) hb + · intro i + rw [hM] + exact (T.finish (eqv.symm i)).toCNF_length_le_of_terminal + ((T.path (eqv.symm i)).valid hs) hnum + (sparseTree_terminal hnum s hs hadded (eqv.symm i)) + · intro i j hij x + exact T.disjoint (eqv.symm i) (eqv.symm j) + (fun h => hij (eqv.symm.injective h)) x + · intro x + change indicator (H.eval x) = + ∑ i, indicator ((T.finish (eqv.symm i)).eval x) + calc + indicator (H.eval x) = indicator (s.eval x) := + congrArg indicator (A.toState_eval x).symm + _ = ∑ p, indicator ((T.finish p).eval x) := T.indicator_eq_sum x + _ = ∑ i, indicator ((T.finish (eqv.symm i)).eval x) := by + simpa only [Equiv.symm_apply_apply] using + eqv.sum_comp (fun i => indicator ((T.finish (eqv.symm i)).eval x)) + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparsePrefix.lean b/lean/OAI/Computability/DepthThree/SparsePrefix.lean new file mode 100644 index 0000000000000000000000000000000000000000..34460ceb20c89ba9da944164f6cf36d5616c8397 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparsePrefix.lean @@ -0,0 +1,385 @@ +import OAI.Computability.DepthThree.SparseBranch +import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise +import Mathlib.Algebra.BigOperators.Ring.Finset +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Order.Interval.Finset.Nat +import Mathlib.Tactic.Linarith + +namespace OAI + +universe uDepth1 + +namespace DepthThreeLowerBound + +open scoped BigOperators + +variable {V : Type uDepth1} [DecidableEq V] + +structure SparseNumerics (r e D : ℕ → ℕ) (b : ℕ) : Prop where + r_ge_two : ∀ i, 2 ≤ i → i ≤ b → 2 ≤ r i + e_one : e 1 = 1 + e_succ : ∀ i, 1 ≤ i → i + 1 ≤ b → + e (i + 1) = i.factorial * (r (i + 1) - 1) ^ i + D_eq : ∀ i, 1 ≤ i → i ≤ b → + D i = (e i + 1) * (2 + ∑ v ∈ Finset.Ico 1 i, D v) + +theorem sparse_occurrence_le_of_no_sunflower + {r e D : ℕ → ℕ} {b : ℕ} (hnum : SparseNumerics r e D b) + (s : SparseState V) (u : ℕ) (hu : 1 ≤ u) (hub : u ≤ b) + (hno : ¬ Nonempty (SignedSunflower s u (r u))) (l : Literal V) : + literalOccurrences s.active u l ≤ e u := by + classical + cases u with + | zero => omega + | succ i => + by_cases hi : i = 0 + · subst i + simpa only [hnum.e_one] using literalOccurrences_one_le s.active l + · have hi1 : 1 ≤ i := by omega + have hr : 2 ≤ r (i + 1) := hnum.r_ge_two _ (by omega) hub + rw [hnum.e_succ i hi1 hub] + apply no_nonempty_core_sunflower_occurrence_le + (clausesOfSize s.active (i + 1)) i (r (i + 1)) hr + (fun C hC => (mem_clausesOfSize.mp hC).2) + intro sub hsub hcard core hcore hflower + apply hno + exact ⟨{ + family := sub + core := core + subset_active := hsub.trans (clausesOfSize_subset s.active (i + 1)) + card_family := hcard + two_le := hr + uniform := fun C hC => (mem_clausesOfSize.mp (hsub hC)).2 + core_nonempty := hcore + sunflower := hflower + }⟩ + +structure SparseStep (r : ℕ → ℕ) (s t : SparseState V) where + size : ℕ + selected : SignedSunflower s size (r size) + minimal : ∀ j, 2 ≤ j → j < size → + ¬ Nonempty (SignedSunflower s j (r j)) + choice : Bool + target : t = selected.branch choice + +namespace SparseStep + +noncomputable def batch {r : ℕ → ℕ} {s t : SparseState V} + (step : SparseStep r s t) : InsertionBatch s step.size := + step.selected.batch step.choice + +theorem target_active {r : ℕ → ℕ} {s t : SparseState V} + (step : SparseStep r s t) : + t.active = sparseBatchUpdate s.active step.batch.clauses := by + exact (congrArg (fun q : SparseState V => q.active) step.target).trans + (step.selected.branch_active step.choice) + +theorem target_added {r : ℕ → ℕ} {s t : SparseState V} + (step : SparseStep r s t) : + t.added = sparseBatchUpdate s.added step.batch.clauses := by + exact (congrArg (fun q : SparseState V => q.added) step.target).trans + (step.selected.branch_added step.choice) + +theorem valid {r : ℕ → ℕ} {s t : SparseState V} {b : ℕ} + (step : SparseStep r s t) (hs : s.Valid b) : t.Valid b := by + rw [step.target] + exact step.selected.branch_valid step.choice hs + +theorem fresh_added {r : ℕ → ℕ} {s t : SparseState V} {b : ℕ} + (step : SparseStep r s t) (hs : s.Valid b) : + Disjoint s.added step.batch.clauses := by + classical + apply Finset.disjoint_left.mpr + intro C hCa hCB + exact step.batch.fresh hs C hCB C (hs.added_subset hCa) (Finset.Subset.refl C) + +theorem batch_size_count {r : ℕ → ℕ} {s t : SparseState V} + (step : SparseStep r s t) (u : ℕ) : + (clausesOfSize step.batch.clauses u).card = + if step.batch.size = u then step.batch.clauses.card else 0 := by + classical + by_cases h : step.batch.size = u + · have hself : clausesOfSize step.batch.clauses u = step.batch.clauses := + clausesOfSize_eq_self _ _ (fun C hC => (step.batch.uniform C hC).trans h) + rw [ite_eq_left h, hself] + · have hempty : clausesOfSize step.batch.clauses u = ∅ := by + apply clausesOfSize_eq_empty + intro C hC + rw [step.batch.uniform C hC] + exact h + rw [ite_eq_right h, hempty, Finset.card_empty] + +theorem removed_eq_empty_of_le {r : ℕ → ℕ} {s t : SparseState V} {b : ℕ} + (step : SparseStep r s t) (hs : s.Valid b) (u : ℕ) + (hu : u ≤ step.batch.size) : subsumedOfSize s.added step.batch.clauses u = ∅ := by + classical + apply Finset.eq_empty_iff_forall_notMem.mpr + intro C hC + obtain ⟨hC, D, hDB, hDC⟩ := Finset.mem_filter.mp hC + obtain ⟨hCa, hCu⟩ := mem_clausesOfSize.mp hC + have hsize : C.card ≤ D.card := by rw [hCu, step.batch.uniform D hDB]; exact hu + have heq : D = C := Finset.eq_of_subset_of_card_le hDC hsize + subst D + exact step.batch.fresh hs C hDB C (hs.added_subset hCa) (Finset.Subset.refl C) + +theorem update_balance {r : ℕ → ℕ} {s t : SparseState V} {b : ℕ} + (step : SparseStep r s t) (hs : s.Valid b) (u : ℕ) : + (clausesOfSize t.added u).card + (subsumedOfSize s.added step.batch.clauses u).card = + (clausesOfSize s.added u).card + + if step.batch.size = u then step.batch.clauses.card else 0 := by + rw [step.target_added, ← step.batch_size_count u] + exact clausesOfSize_update_balance s.added step.batch.clauses u (step.fresh_added hs) + +end SparseStep + +inductive SparsePath (r : ℕ → ℕ) (start : SparseState V) : SparseState V → Type _ + | nil : SparsePath r start start + | snoc {s t : SparseState V} (path : SparsePath r start s) + (step : SparseStep r s t) : SparsePath r start t + +namespace SparsePath + +variable {r e D : ℕ → ℕ} {b : ℕ} {start finish : SparseState V} + +def length : {finish : SparseState V} → SparsePath r start finish → ℕ + | _, .nil => 0 + | _, .snoc path _ => length path + 1 + +noncomputable def insertions : + {finish : SparseState V} → SparsePath r start finish → ℕ → ℕ + | _, .nil, _ => 0 + | _, .snoc path step, u => + insertions path u + if step.batch.size = u then step.batch.clauses.card else 0 + +def processed : {finish : SparseState V} → SparsePath r start finish → ℕ → ℕ + | _, .nil, _ => 0 + | _, .snoc path step, i => processed path i + if step.size = i then 1 else 0 + +def petalSteps : {finish : SparseState V} → SparsePath r start finish → ℕ → ℕ + | _, .nil, _ => 0 + | _, .snoc path step, i => + petalSteps path i + if step.size = i ∧ step.choice = true then 1 else 0 + +theorem valid (path : SparsePath r start finish) (hstart : start.Valid b) : + finish.Valid b := by + induction path with + | nil => exact hstart + | snoc path step ih => exact step.valid ih + +@[simp] theorem insertions_nil (u : ℕ) : + (SparsePath.nil : SparsePath r start start).insertions u = 0 := rfl + +@[simp] theorem insertions_snoc {s t : SparseState V} + (path : SparsePath r start s) (step : SparseStep r s t) (u : ℕ) : + (path.snoc step).insertions u = + path.insertions u + if step.batch.size = u then step.batch.clauses.card else 0 := rfl + +theorem insertions_sum_snoc {s t : SparseState V} + (path : SparsePath r start s) (step : SparseStep r s t) (u : ℕ) : + (∑ v ∈ Finset.Ico 1 u, (path.snoc step).insertions v) = + (∑ v ∈ Finset.Ico 1 u, path.insertions v) + + if step.batch.size < u then step.batch.clauses.card else 0 := by + classical + simp only [insertions_snoc, Finset.sum_add_distrib, Finset.sum_ite_eq] + simp only [Finset.mem_Ico, Nat.succ_le_iff.mpr step.batch.size_pos, true_and] + +theorem added_occurrence_bound (path : SparsePath r start finish) + (hnum : SparseNumerics r e D b) (hstart : start.Valid b) + (hadded : start.added = ∅) : + ∀ u, 1 ≤ u → u ≤ b → ∀ l, + literalOccurrences finish.added u l ≤ e u + 1 := by + classical + induction path with + | nil => + intro u hu hub l + simp [hadded, literalOccurrences, clausesOfSize] + | @snoc s t path step ih => + intro u hu hub l + have hs := path.valid hstart + have hupdate := literalOccurrences_update_le s.added step.batch.clauses u l + change literalOccurrences (sparseBatchUpdate s.added step.batch.clauses) u l ≤ _ at hupdate + rw [← step.target_added] at hupdate + by_cases hsize : step.batch.size = u + · have hlt : u < step.size := hsize ▸ step.batch.size_lt + have hpre := sparse_occurrence_le_of_no_sunflower hnum s u hu hub + (fun hflower => step.minimal u (by + have hflower_size : 2 ≤ u := (Classical.choice hflower).size_ge_two + exact hflower_size) hlt hflower) l + have hadd := literalOccurrences_mono hs.added_subset u l + have hbatch := step.batch.literal_occurrences_le_one u l + omega + · have hempty : clausesOfSize step.batch.clauses u = ∅ := by + apply clausesOfSize_eq_empty + intro C hC + rw [step.batch.uniform C hC] + exact hsize + have hzero : literalOccurrences step.batch.clauses u l = 0 := by + simp [literalOccurrences, hempty] + have hprev := ih u hu hub l + omega + +theorem online_insertion_bound (path : SparsePath r start finish) + (hnum : SparseNumerics r e D b) (hstart : start.Valid b) + (hadded : start.added = ∅) : + ∀ u, 1 ≤ u → u ≤ b → + path.insertions u ≤ (clausesOfSize finish.added u).card + + (e u + 1) * ∑ v ∈ Finset.Ico 1 u, path.insertions v := by + classical + induction path with + | nil => + intro u hu hub + simp [hadded, clausesOfSize] + | @snoc s t path step ih => + intro u hu hub + have hs := path.valid hstart + have hbalance := step.update_balance hs u + have hprev := ih u hu hub + have hocc := path.added_occurrence_bound hnum hstart hadded u hu hub + have hremoved := subsumedOfSize_card_le s.added step.batch.clauses u (e u + 1) + (fun C hC => step.batch.clause_nonempty C hC) hocc + rw [insertions_snoc, insertions_sum_snoc] + by_cases hlt : step.batch.size < u + · have hne : step.batch.size ≠ u := Nat.ne_of_lt hlt + simp only [ite_eq_right hne, ite_eq_left hlt, Nat.add_zero] at hbalance ⊢ + nlinarith + · have hremoved_zero := step.removed_eq_empty_of_le hs u (Nat.le_of_not_gt hlt) + rw [hremoved_zero, Finset.card_empty, Nat.add_zero] at hbalance + simp only [ite_eq_right hlt, Nat.add_zero] + omega + +theorem insertion_recurrence [Fintype V] (path : SparsePath r start finish) + (hnum : SparseNumerics r e D b) (hstart : start.Valid b) + (hadded : start.added = ∅) (u : ℕ) (hu : 1 ≤ u) (hub : u ≤ b) : + path.insertions u ≤ (e u + 1) * + (2 * Fintype.card V + ∑ v ∈ Finset.Ico 1 u, path.insertions v) := by + have hv := path.valid hstart + have hsurvive := clausesOfSize_card_le finish.added u (e u + 1) + (fun C hC => hv.nonempty C (hv.added_subset (mem_clausesOfSize.mp hC).1)) + (path.added_occurrence_bound hnum hstart hadded u hu hub) + have honline := path.online_insertion_bound hnum hstart hadded u hu hub + nlinarith + +theorem length_le_insertions (path : SparsePath r start finish) + (hstart : start.Valid b) : + path.length ≤ ∑ u ∈ Finset.Ico 1 b, path.insertions u := by + induction path with + | nil => simp [length] + | @snoc s t path step ih => + have hbatch : 0 < step.batch.clauses.card := step.batch.nonempty.card_pos + have hsize : step.batch.size < b := + step.batch.size_lt.trans_le (step.selected.size_le (path.valid hstart)) + change path.length + 1 ≤ _ + rw [insertions_sum_snoc, ite_eq_left hsize] + omega + +theorem processed_le_insertions (path : SparsePath r start finish) (i : ℕ) : + path.processed i ≤ ∑ u ∈ Finset.Ico 1 i, path.insertions u := by + induction path with + | nil => simp [processed] + | @snoc s t path step ih => + have hbatch : 0 < step.batch.clauses.card := step.batch.nonempty.card_pos + change path.processed i + (if step.size = i then 1 else 0) ≤ _ + rw [insertions_sum_snoc] + by_cases hi : step.size = i + · have hsize : step.batch.size < i := hi ▸ step.batch.size_lt + simp only [ite_eq_left hi, ite_eq_left hsize] + omega + · simp only [ite_eq_right hi, Nat.add_zero] + split <;> omega + +theorem petalSteps_mul_le_insertions (path : SparsePath r start finish) (i : ℕ) : + r i * path.petalSteps i ≤ ∑ u ∈ Finset.Ico 1 i, path.insertions u := by + induction path with + | nil => simp [petalSteps] + | @snoc s t path step ih => + change r i * (path.petalSteps i + + if step.size = i ∧ step.choice = true then 1 else 0) ≤ _ + rw [insertions_sum_snoc] + by_cases hi : step.size = i ∧ step.choice = true + · have hsize : step.batch.size < i := hi.1 ▸ step.batch.size_lt + have hcard : step.batch.clauses.card = r i := by + simp only [SparseStep.batch, step.selected.batch_card, hi.2, ↓reduceIte, hi.1] + simp only [ite_eq_left hi, ite_eq_left hsize, Nat.mul_add, Nat.mul_one, hcard] + omega + · simp only [ite_eq_right hi, Nat.add_zero] + split <;> omega + +end SparsePath + +theorem sparse_insertion_budget_of_recurrence + (r e D N : ℕ → ℕ) (b m : ℕ) (hnum : SparseNumerics r e D b) + (hN : ∀ u, 1 ≤ u → u ≤ b → + N u ≤ (e u + 1) * (2 * m + ∑ v ∈ Finset.Ico 1 u, N v)) : + ∀ u, 1 ≤ u → u ≤ b → N u ≤ D u * m := by + intro u + induction u using Nat.strong_induction_on with + | h u ih => + intro hu hub + have hsum : (∑ v ∈ Finset.Ico 1 u, N v) ≤ + (∑ v ∈ Finset.Ico 1 u, D v) * m := by + calc + (∑ v ∈ Finset.Ico 1 u, N v) ≤ + ∑ v ∈ Finset.Ico 1 u, D v * m := by + apply Finset.sum_le_sum + intro v hv + have hv' := Finset.mem_Ico.mp hv + exact ih v hv'.2 hv'.1 (le_trans (Nat.le_of_lt hv'.2) hub) + _ = _ := (Finset.sum_mul _ _ _).symm + calc + N u ≤ (e u + 1) * (2 * m + ∑ v ∈ Finset.Ico 1 u, N v) := hN u hu hub + _ ≤ (e u + 1) * (2 * m + (∑ v ∈ Finset.Ico 1 u, D v) * m) := + Nat.mul_le_mul_left _ (Nat.add_le_add_left hsum _) + _ = D u * m := by + rw [hnum.D_eq u hu hub, ← Nat.add_mul, Nat.mul_assoc] + +namespace SparsePath + +variable {r e D : ℕ → ℕ} {b : ℕ} {start finish : SparseState V} + +theorem insertion_budget [Fintype V] (path : SparsePath r start finish) + (hnum : SparseNumerics r e D b) (hstart : start.Valid b) + (hadded : start.added = ∅) (u : ℕ) (hu : 1 ≤ u) (hub : u ≤ b) : + path.insertions u ≤ D u * Fintype.card V := + sparse_insertion_budget_of_recurrence r e D path.insertions b (Fintype.card V) hnum + (path.insertion_recurrence hnum hstart hadded) u hu hub + +theorem insertion_sum_budget [Fintype V] (path : SparsePath r start finish) + (hnum : SparseNumerics r e D b) (hstart : start.Valid b) + (hadded : start.added = ∅) (i : ℕ) (hi : i ≤ b + 1) : + (∑ u ∈ Finset.Ico 1 i, path.insertions u) ≤ + (∑ u ∈ Finset.Ico 1 i, D u) * Fintype.card V := by + calc + (∑ u ∈ Finset.Ico 1 i, path.insertions u) ≤ + ∑ u ∈ Finset.Ico 1 i, D u * Fintype.card V := by + apply Finset.sum_le_sum + intro u hu + have hu' := Finset.mem_Ico.mp hu + exact path.insertion_budget hnum hstart hadded u hu'.1 (by omega) + _ = _ := (Finset.sum_mul _ _ _).symm + +theorem length_budget [Fintype V] (path : SparsePath r start finish) + (hnum : SparseNumerics r e D b) (hstart : start.Valid b) + (hadded : start.added = ∅) : + path.length ≤ (∑ u ∈ Finset.Ico 1 b, D u) * Fintype.card V := + (path.length_le_insertions hstart).trans + (path.insertion_sum_budget hnum hstart hadded b (by omega)) + +theorem processed_budget [Fintype V] (path : SparsePath r start finish) + (hnum : SparseNumerics r e D b) (hstart : start.Valid b) + (hadded : start.added = ∅) (i : ℕ) (hi : i ≤ b) : + path.processed i ≤ (∑ u ∈ Finset.Ico 1 i, D u) * Fintype.card V := + (path.processed_le_insertions i).trans + (path.insertion_sum_budget hnum hstart hadded i (by omega)) + +theorem petalSteps_budget [Fintype V] (path : SparsePath r start finish) + (hnum : SparseNumerics r e D b) (hstart : start.Valid b) + (hadded : start.added = ∅) (i : ℕ) (hi : i ≤ b) : + r i * path.petalSteps i ≤ (∑ u ∈ Finset.Ico 1 i, D u) * Fintype.card V := + (path.petalSteps_mul_le_insertions i).trans + (path.insertion_sum_budget hnum hstart hadded i (by omega)) + +end SparsePath + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparseStreams.lean b/lean/OAI/Computability/DepthThree/SparseStreams.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6afa7f71e7e21955ba691c76cd915e4bfa84032 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparseStreams.lean @@ -0,0 +1,176 @@ +import OAI.Computability.DepthThree.EntropyBits +import Mathlib.Data.List.GetD +import Mathlib.Data.List.Count +import Mathlib.Data.Fintype.Sum +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Algebra.BigOperators.Fin + +namespace OAI + +universe uDepth1 uDepth2 + +open scoped BigOperators + +namespace DepthThreeLowerBound + +inductive SparseDecisionTree (Label : Type uDepth1) where + | leaf : SparseDecisionTree Label + | node : Label → SparseDecisionTree Label → SparseDecisionTree Label → + SparseDecisionTree Label + +namespace SparseDecisionTree + +variable {Label : Type uDepth2} + +def Leaf : SparseDecisionTree Label → Type + | .leaf => Unit + | .node _ l r => Leaf l ⊕ Leaf r + +@[instance_reducible] +private def leafFintype : (t : SparseDecisionTree Label) → Fintype t.Leaf + | .leaf => inferInstanceAs (Fintype Unit) + | .node _ l r => by + change Fintype (Leaf l ⊕ Leaf r) + letI := leafFintype l + letI := leafFintype r + infer_instance + +instance (t : SparseDecisionTree Label) : Fintype t.Leaf := leafFintype t + +def stream [DecidableEq Label] : (t : SparseDecisionTree Label) → + t.Leaf → Label → List Bool + | .leaf, _, _ => [] + | .node a l _, .inl p, i => + if i = a then false :: stream l p i else stream l p i + | .node a _ r, .inr p, i => + if i = a then true :: stream r p i else stream r p i + +def streamBit [DecidableEq Label] (t : SparseDecisionTree Label) + (p : t.Leaf) (i : Label) (k : ℕ) : Bool := + (t.stream p i).getD k false + +def padded [DecidableEq Label] (t : SparseDecisionTree Label) (N : Label → ℕ) + (p : t.Leaf) (i : Label) (k : Fin (N i)) : Bool := + t.streamBit p i k + +theorem streamBit_injective [DecidableEq Label] (t : SparseDecisionTree Label) : + Function.Injective t.streamBit := by + induction t with + | leaf => + intro p q _ + exact Subsingleton.elim (α := Unit) p q + | node a l r ihl ihr => + intro p q h + cases p with + | inl p => + cases q with + | inl q => + have hpq : p = q := ihl (by + funext i k + by_cases hi : i = a + · subst i + simpa only [streamBit, stream, ite_eq_left rfl, ite_true, List.getD_cons_succ] using + congrFun (congrFun h a) (k + 1) + · simpa only [streamBit, stream, ite_eq_right hi] using + congrFun (congrFun h i) k) + exact congrArg Sum.inl hpq + | inr q => + have hfalse : False := by + simpa only [streamBit, stream, ite_eq_left rfl, ite_true, List.getD_cons_zero, + Bool.false_eq_true] using congrFun (congrFun h a) 0 + exact hfalse.elim + | inr p => + cases q with + | inl q => + have hfalse : False := by + simpa only [streamBit, stream, ite_eq_left rfl, ite_true, List.getD_cons_zero, + Bool.true_eq_false] using congrFun (congrFun h a) 0 + exact hfalse.elim + | inr q => + have hpq : p = q := ihr (by + funext i k + by_cases hi : i = a + · subst i + simpa only [streamBit, stream, ite_eq_left rfl, ite_true, List.getD_cons_succ] using + congrFun (congrFun h a) (k + 1) + · simpa only [streamBit, stream, ite_eq_right hi] using + congrFun (congrFun h i) k) + exact congrArg Sum.inr hpq + +theorem padded_injective [DecidableEq Label] (t : SparseDecisionTree Label) + (N : Label → ℕ) (hN : ∀ (p : t.Leaf) i, (t.stream p i).length ≤ N i) : + Function.Injective (t.padded N) := by + intro p q h + apply t.streamBit_injective + funext i k + by_cases hk : k < N i + · exact congrFun (congrFun h i) ⟨k, hk⟩ + · have hNk : N i ≤ k := Nat.le_of_not_gt hk + change (t.stream p i).getD k false = (t.stream q i).getD k false + rw [List.getD_eq_default _ _ ((hN p i).trans hNk), + List.getD_eq_default _ _ ((hN q i).trans hNk)] + +private theorem sum_getD_false (N : ℕ) (xs : List Bool) (h : xs.length ≤ N) : + (∑ j : Fin N, if xs.getD j.val false = true then (1 : ℕ) else 0) = + xs.count true := by + induction N generalizing xs with + | zero => cases xs <;> simp_all + | succ N ih => + cases xs with + | nil => simp + | cons b xs => + have hx : xs.length ≤ N := Nat.le_of_succ_le_succ h + rw [Fin.sum_univ_succ] + simp only [Fin.val_zero, Fin.val_succ, List.getD_cons_zero, List.getD_cons_succ] + rw [ih xs hx] + cases b <;> simp [Nat.add_comm] + +theorem trueCount_getD (xs : List Bool) (N : ℕ) (h : xs.length ≤ N) : + trueCount (fun j : Fin N => xs.getD j.val false) = xs.count true := by + unfold trueCount + exact (Finset.natCast_card_filter (R := ℕ) + (fun j : Fin N => xs.getD j.val false = true) Finset.univ).trans + (sum_getD_false N xs h) + +theorem padded_trueCount [DecidableEq Label] (t : SparseDecisionTree Label) + (N : Label → ℕ) (p : t.Leaf) (i : Label) + (h : (t.stream p i).length ≤ N i) : + trueCount (t.padded N p i) = (t.stream p i).count true := + trueCount_getD (t.stream p i) (N i) h + +theorem card_le_prod_admitted [DecidableEq Label] [Fintype Label] + (t : SparseDecisionTree Label) (N : Label → ℕ) + (hN : ∀ (p : t.Leaf) i, (t.stream p i).length ≤ N i) + (admitted : (i : Label) → Finset (Fin (N i) → Bool)) + (hmem : ∀ (p : t.Leaf) i, t.padded N p i ∈ admitted i) : + Fintype.card t.Leaf ≤ ∏ i, (admitted i).card := by + classical + let enc : t.Leaf → ((i : Label) → {w // w ∈ admitted i}) := + fun p i => ⟨t.padded N p i, hmem p i⟩ + have henc : Function.Injective enc := by + intro p q h + apply t.padded_injective N hN + funext i + exact congrArg Subtype.val (congrFun h i) + simpa only [Fintype.card_pi, Fintype.card_coe] using + (Fintype.card_le_of_injective enc henc) + +theorem card_le_prod_lowWeight [DecidableEq Label] [Fintype Label] + (t : SparseDecisionTree Label) (N r : Label → ℕ) + (hN : ∀ (p : t.Leaf) i, (t.stream p i).length ≤ N i) + (hones : ∀ (p : t.Leaf) i, r i * (t.stream p i).count true ≤ N i) : + Fintype.card t.Leaf ≤ + ∏ i, (Finset.univ.filter (fun w : Fin (N i) → Bool => + r i * trueCount w ≤ N i)).card := by + classical + apply t.card_le_prod_admitted N hN + intro p i + simp only [Finset.mem_filter, Finset.mem_univ, true_and] + rw [t.padded_trueCount N p i (hN p i)] + exact hones p i + +end SparseDecisionTree + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparseTailBounds.lean b/lean/OAI/Computability/DepthThree/SparseTailBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..07ea03ba3589f3509b7fb2af4b60c705908934ab --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparseTailBounds.lean @@ -0,0 +1,112 @@ +import OAI.Computability.DepthThree.SparseTestCodes +import OAI.Computability.DepthThree.UniformSparseBounds +import Mathlib.Tactic.FieldSimp +import Mathlib.Tactic.Positivity + +namespace OAI + +universe uDepth1 uDepth2 + +noncomputable section + +namespace DepthThreeLowerBound + +private theorem two_rpow_log_div (x : ℝ) (hx : 0 < x) : + (2 : ℝ) ^ (Real.log x / Real.log 2) = x := by + have htwo : Real.log 2 ≠ 0 := (Real.log_pos (by norm_num : (1 : ℝ) < 2)).ne' + rw [Real.rpow_def_of_pos (by norm_num : (0 : ℝ) < 2)] + have he : Real.log 2 * (Real.log x / Real.log 2) = Real.log x := by + field_simp [htwo] + rw [he, Real.exp_log hx] + +theorem nat_pow_eq_two_rpow (x : ℝ) (hx : 0 < x) (n : ℕ) : + x ^ n = (2 : ℝ) ^ ((n : ℝ) * (Real.log x / Real.log 2)) := by + calc + x ^ n = ((2 : ℝ) ^ (Real.log x / Real.log 2)) ^ n := by + rw [two_rpow_log_div x hx] + _ = (2 : ℝ) ^ ((Real.log x / Real.log 2) * (n : ℝ)) := + (Real.rpow_mul_natCast (by norm_num) _ n).symm + _ = _ := by congr 1 ; ring + +theorem sparse_count_le_two_rpow (m b L : ℕ) : + ((2 * (m : ℝ) + 1) ^ b + 1) ^ L ≤ + (2 : ℝ) ^ ((L : ℝ) * + (1 + (b : ℝ) * (Real.log (2 * (m : ℝ) + 1) / Real.log 2))) := by + have hx : 0 < 2 * (m : ℝ) + 1 := by positivity + have hxone : 1 ≤ 2 * (m : ℝ) + 1 := by + have hm : (0 : ℝ) ≤ m := Nat.cast_nonneg m + linarith + have hpow : 1 ≤ (2 * (m : ℝ) + 1) ^ b := one_le_pow₀ hxone + calc + _ ≤ (2 * (2 * (m : ℝ) + 1) ^ b) ^ L := + pow_le_pow_left₀ (by positivity) (by linarith) L + _ = ((2 : ℝ) ^ (1 + (b : ℝ) * + (Real.log (2 * (m : ℝ) + 1) / Real.log 2))) ^ L := by + congr 1 + rw [Real.rpow_add (by norm_num : (0 : ℝ) < 2), Real.rpow_one, + ← nat_pow_eq_two_rpow _ hx b] + _ = _ := by + rw [← Real.rpow_mul_natCast (by norm_num : (0 : ℝ) ≤ 2)] + congr 1 ; ring + +theorem sparseTestCode_card_le_two_rpow {V : Type uDepth1} [Fintype V] (b L : ℕ) : + (Fintype.card (SparseTestCode V b L) : ℝ) ≤ + (2 : ℝ) ^ ((L : ℝ) * + (1 + (b : ℝ) * (Real.log (2 * (Fintype.card V : ℝ) + 1) / Real.log 2))) := by + rw [SparseTestCode.card_eq] + push_cast + exact sparse_count_le_two_rpow (Fintype.card V) b L + +theorem sparse_moment_union_le {V : Type uDepth2} [Fintype V] (b M t : ℕ) + (hm : 0 < Fintype.card V) (ht : 0 < t) + (hcond : (M : ℝ) * + (1 + (b : ℝ) * (Real.log (2 * (Fintype.card V : ℝ) + 1) / Real.log 2)) / + (t : ℝ) + (Real.log (t : ℝ) / Real.log 2) / (Fintype.card V : ℝ) ≤ 1 / 8) : + (Fintype.card (SparseTestCode V b (M * Fintype.card V)) : ℝ) * (t : ℝ) ^ t * + (2 : ℝ) ^ (-((Fintype.card V : ℝ) * (t : ℝ)) / 4) ≤ + (2 : ℝ) ^ (-((Fintype.card V : ℝ) * (t : ℝ)) / 8) := by + let m : ℝ := Fintype.card V + have hmpos : 0 < m := by + change (0 : ℝ) < (Fintype.card V : ℝ) + exact_mod_cast hm + have htpos : (0 : ℝ) < t := by exact_mod_cast ht + have hmult := mul_le_mul_of_nonneg_right hcond (mul_nonneg hmpos.le htpos.le) + have hclear : ((M : ℝ) * + (1 + (b : ℝ) * (Real.log (2 * m + 1) / Real.log 2)) / (t : ℝ) + + (Real.log (t : ℝ) / Real.log 2) / m) * (m * (t : ℝ)) = + (M : ℝ) * m * (1 + (b : ℝ) * (Real.log (2 * m + 1) / Real.log 2)) + + (t : ℝ) * (Real.log (t : ℝ) / Real.log 2) := by + field_simp [hmpos.ne', htpos.ne'] + change ((M : ℝ) * + (1 + (b : ℝ) * (Real.log (2 * m + 1) / Real.log 2)) / (t : ℝ) + + (Real.log (t : ℝ) / Real.log 2) / m) * (m * (t : ℝ)) ≤ + (1 / 8 : ℝ) * (m * (t : ℝ)) at hmult + rw [hclear] at hmult + have hcount := sparseTestCode_card_le_two_rpow (V := V) b (M * Fintype.card V) + calc + _ ≤ (2 : ℝ) ^ (((M * Fintype.card V : ℕ) : ℝ) * + (1 + (b : ℝ) * (Real.log (2 * m + 1) / Real.log 2))) * (t : ℝ) ^ t * + (2 : ℝ) ^ (-(m * (t : ℝ)) / 4) := + mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right hcount (pow_nonneg (Nat.cast_nonneg t) t)) + (Real.rpow_nonneg (by norm_num) _) + _ = (2 : ℝ) ^ (((M * Fintype.card V : ℕ) : ℝ) * + (1 + (b : ℝ) * (Real.log (2 * m + 1) / Real.log 2)) + + (t : ℝ) * (Real.log (t : ℝ) / Real.log 2) + -(m * (t : ℝ)) / 4) := by + rw [nat_pow_eq_two_rpow (t : ℝ) htpos t, + ← Real.rpow_add (by norm_num : (0 : ℝ) < 2), + ← Real.rpow_add (by norm_num : (0 : ℝ) < 2)] + _ ≤ _ := by + apply Real.rpow_le_rpow_of_exponent_le (by norm_num) + push_cast + change (M : ℝ) * m * + (1 + (b : ℝ) * (Real.log (2 * m + 1) / Real.log 2)) + + (t : ℝ) * (Real.log (t : ℝ) / Real.log 2) + -(m * (t : ℝ)) / 4 ≤ + -(m * (t : ℝ)) / 8 + linarith + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparseTestCodes.lean b/lean/OAI/Computability/DepthThree/SparseTestCodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..b13ddb187a45d9e3a1c26576df635220c8a57970 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparseTestCodes.lean @@ -0,0 +1,152 @@ +import OAI.Computability.DepthThree.RestrictionNormalization +import Mathlib.Data.Fintype.BigOperators +import Mathlib.Data.Fintype.EquivFin +import Mathlib.Data.Fintype.Option +import Mathlib.Data.Fin.Tuple.Basic +import Mathlib.Logic.Function.Basic +import Mathlib.Tactic.SplitIfs + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 uDepth7 uDepth8 uDepth9 uDepth10 uDepth11 uDepth12 uDepth13 uDepth14 uDepth15 uDepth16 uDepth17 uDepth18 + +noncomputable section + +open scoped Classical + +namespace DepthThreeLowerBound + +abbrev SparseClauseCode (V : Type uDepth1) (b : ℕ) := Fin b → Option (Literal V) +abbrev SparseTestCode (V : Type uDepth2) (b L : ℕ) := Fin L → Option (SparseClauseCode V b) + +namespace SparseClauseCode + +def decode {V : Type uDepth3} [Fintype V] {b : ℕ} (c : SparseClauseCode V b) : Clause V := + Finset.univ.filter (fun l => ∃ i, c i = some l) + +@[simp] theorem mem_decode {V : Type uDepth4} [Fintype V] {b : ℕ} + (c : SparseClauseCode V b) (l : Literal V) : + l ∈ c.decode ↔ ∃ i, c i = some l := by + simp [decode] + +@[simp] theorem decode_none {V : Type uDepth5} [Fintype V] (b : ℕ) : + decode (fun _ : Fin b => (none : Option (Literal V))) = ∅ := by + ext l + simp + +theorem exists_decode_of_card_le {V : Type uDepth6} [Fintype V] + (C : Clause V) {b : ℕ} (hC : C.card ≤ b) : + ∃ c : SparseClauseCode V b, c.decode = C := by + have hsize : Fintype.card ↥C ≤ Fintype.card (Fin b) := by simpa using hC + obtain ⟨e⟩ := Function.Embedding.nonempty_of_card_le hsize + let c : SparseClauseCode V b := + Function.extend e (fun l : ↥C => some l.val) (fun _ => none) + refine ⟨c, ?_⟩ + ext l + rw [mem_decode] + constructor + · rintro ⟨i, hi⟩ + change Function.extend e (fun l : ↥C => some l.val) (fun _ => none) i = some l at hi + rw [Function.extend_def] at hi + split_ifs at hi with hex + · have heq : (Classical.choose hex).val = l := Option.some.inj hi + exact heq ▸ (Classical.choose hex).property + · intro hl + refine ⟨e ⟨l, hl⟩, ?_⟩ + exact e.injective.extend_apply (fun l : ↥C => some l.val) (fun _ => none) ⟨l, hl⟩ + +theorem exists_decode_of_normalized {V : Type uDepth7} [Fintype V] + (C : Clause V) {b : ℕ} (hn : C.Normalized) (hw : C.width ≤ b) : + ∃ c : SparseClauseCode V b, c.decode = C := + exists_decode_of_card_le C (hn.card_eq_width.trans_le hw) + +theorem card_eq {V : Type uDepth8} [Fintype V] (b : ℕ) : + Fintype.card (SparseClauseCode V b) = (2 * Fintype.card V + 1) ^ b := by + simp [SparseClauseCode, Literal, Nat.mul_comm] + +end SparseClauseCode + +namespace SparseTestCode + +def decode {V : Type uDepth9} [Fintype V] {b : ℕ} : + {L : ℕ} → SparseTestCode V b L → CNF V + | 0, _ => [] + | _ + 1, c => + match c 0 with + | none => decode (fun i => c i.succ) + | some d => d.decode :: decode (fun i => c i.succ) + +def eval {V : Type uDepth10} [Fintype V] {b L : ℕ} + (c : SparseTestCode V b L) (x : Cube V) : Bool := c.decode.eval x + +@[simp] theorem decode_cons_none {V : Type uDepth11} [Fintype V] {b L : ℕ} + (c : SparseTestCode V b L) : decode (Fin.cons none c) = c.decode := by + simp [decode] + +@[simp] theorem decode_cons_some {V : Type uDepth12} [Fintype V] {b L : ℕ} + (d : SparseClauseCode V b) (c : SparseTestCode V b L) : + decode (Fin.cons (some d) c) = d.decode :: c.decode := by + simp [decode] + +@[simp] theorem decode_none {V : Type uDepth13} [Fintype V] (b L : ℕ) : + decode (fun _ : Fin L => (none : Option (SparseClauseCode V b))) = [] := by + induction L with + | zero => rfl + | succ L ih => simpa [decode] using ih + +@[simp] theorem eval_none {V : Type uDepth14} [Fintype V] (b L : ℕ) (x : Cube V) : + eval (fun _ : Fin L => (none : Option (SparseClauseCode V b))) x = true := by + simp [eval] + +theorem eval_cons_empty {V : Type uDepth15} [Fintype V] {b L : ℕ} + (c : SparseTestCode V b L) (x : Cube V) : + eval (Fin.cons (some (fun _ : Fin b => (none : Option (Literal V)))) c) x = false := by + simp [eval] + +theorem exists_decode_of_normalized {V : Type uDepth16} [Fintype V] + (H : CNF V) (b : ℕ) : + ∀ L, H.Normalized → H.WidthAtMost b → H.length ≤ L → + ∃ c : SparseTestCode V b L, c.decode = H := by + induction H with + | nil => + intro L _ _ _ + exact ⟨fun _ => none, decode_none b L⟩ + | cons C H ih => + intro L hn hw hlen + cases L with + | zero => simp at hlen + | succ L => + have hnC : C.Normalized := hn C (by simp) + have hwC : C.width ≤ b := hw C (by simp) + obtain ⟨d, hd⟩ := SparseClauseCode.exists_decode_of_normalized C hnC hwC + have hnH : CNF.Normalized H := fun D hD => hn D (by simp [hD]) + have hwH : CNF.WidthAtMost H b := fun D hD => hw D (by simp [hD]) + have hlenH : H.length ≤ L := Nat.le_of_succ_le_succ hlen + obtain ⟨c, hc⟩ := ih L hnH hwH hlenH + refine ⟨Fin.cons (some d) c, ?_⟩ + rw [decode_cons_some, hd, hc] + +theorem exists_eval_eq {V : Type uDepth17} [Fintype V] + (H : CNF V) {b L : ℕ} (hw : H.WidthAtMost b) (hlen : H.length ≤ L) : + ∃ c : SparseTestCode V b L, ∀ x, c.eval x = H.eval x := by + have hnormlen : H.normalize.length ≤ H.length := by + unfold CNF.normalize + exact List.length_filter_le _ _ + obtain ⟨c, hc⟩ := exists_decode_of_normalized H.normalize b L + (CNF.normalize_normalized H) (CNF.normalize_widthAtMost hw) (hnormlen.trans hlen) + refine ⟨c, fun x => ?_⟩ + change c.decode.eval x = H.eval x + rw [hc, CNF.eval_normalize] + +theorem card_eq {V : Type uDepth18} [Fintype V] (b L : ℕ) : + Fintype.card (SparseTestCode V b L) = ((2 * Fintype.card V + 1) ^ b + 1) ^ L := by + simp only [SparseTestCode, SparseClauseCode, Fintype.card_fun, Fintype.card_fin, + Fintype.card_option, Literal, Fintype.card_prod, Fintype.card_bool, Nat.mul_comm] + +end SparseTestCode + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparseThresholds.lean b/lean/OAI/Computability/DepthThree/SparseThresholds.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e1f0d8cfcfa0075569f23783f4acca6e9b7dd57 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparseThresholds.lean @@ -0,0 +1,169 @@ +import OAI.Computability.DepthThree.EntropyThreshold +import OAI.Computability.DepthThree.SparsePrefix +import Mathlib.Algebra.BigOperators.Intervals + +namespace OAI + +noncomputable section + +namespace DepthThreeLowerBound + +open scoped BigOperators + +structure SparseLevel where + r : ℕ + e : ℕ + D : ℕ + F : ℕ + +private def nextSparseLevel (ε : ℝ) (hε : 0 < ε) (i : ℕ) + (previous : SparseLevel) : SparseLevel := + let F := previous.F + previous.D + let r := Classical.choose (exists_integer_entropy_threshold F hε) + let e := i.factorial * (r - 1) ^ i + ⟨r, e, (e + 1) * (2 + F), F⟩ + +def sparseLevel (ε : ℝ) (hε : 0 < ε) : ℕ → SparseLevel + | 0 => ⟨2, 0, 0, 0⟩ + | 1 => ⟨2, 1, 4, 0⟩ + | n + 2 => nextSparseLevel ε hε (n + 1) (sparseLevel ε hε (n + 1)) + +def sparseR (ε : ℝ) (hε : 0 < ε) (i : ℕ) : ℕ := (sparseLevel ε hε i).r +def sparseE (ε : ℝ) (hε : 0 < ε) (i : ℕ) : ℕ := (sparseLevel ε hε i).e +def sparseD (ε : ℝ) (hε : 0 < ε) (i : ℕ) : ℕ := (sparseLevel ε hε i).D +def sparseF (ε : ℝ) (hε : 0 < ε) (i : ℕ) : ℕ := (sparseLevel ε hε i).F + +variable (ε : ℝ) (hε : 0 < ε) + +@[simp] theorem sparseE_zero : sparseE ε hε 0 = 0 := rfl +@[simp] theorem sparseD_zero : sparseD ε hε 0 = 0 := rfl +@[simp] theorem sparseF_zero : sparseF ε hε 0 = 0 := rfl +@[simp] theorem sparseE_one : sparseE ε hε 1 = 1 := rfl +@[simp] theorem sparseD_one : sparseD ε hε 1 = 4 := rfl +@[simp] theorem sparseF_one : sparseF ε hε 1 = 0 := rfl + +theorem sparseR_succ_succ (n : ℕ) : + sparseR ε hε (n + 2) = Classical.choose + (exists_integer_entropy_threshold (sparseF ε hε (n + 1) + sparseD ε hε (n + 1)) hε) := + rfl + +theorem sparseF_succ_succ (n : ℕ) : + sparseF ε hε (n + 2) = sparseF ε hε (n + 1) + sparseD ε hε (n + 1) := rfl + +theorem sparseE_succ_succ (n : ℕ) : + sparseE ε hε (n + 2) = (n + 1).factorial * (sparseR ε hε (n + 2) - 1) ^ (n + 1) := + rfl + +theorem sparseD_succ_succ (n : ℕ) : + sparseD ε hε (n + 2) = + (sparseE ε hε (n + 2) + 1) * (2 + sparseF ε hε (n + 2)) := rfl + +theorem sparseR_ge_two (i : ℕ) : 2 ≤ sparseR ε hε i := by + cases i with + | zero => exact le_rfl + | succ i => + cases i with + | zero => exact le_rfl + | succ n => + rw [sparseR_succ_succ] + exact (Classical.choose_spec + (exists_integer_entropy_threshold + (sparseF ε hε (n + 1) + sparseD ε hε (n + 1)) hε)).1 + +theorem sparseF_eq_sum_Ico (i : ℕ) : + sparseF ε hε i = ∑ v ∈ Finset.Ico 1 i, sparseD ε hε v := by + induction i with + | zero => simp + | succ i ih => + cases i with + | zero => simp + | succ n => + rw [sparseF_succ_succ, ih] + exact (Finset.sum_Ico_succ_top (by omega : 1 ≤ n + 1) (sparseD ε hε)).symm + +theorem sparseE_succ (i : ℕ) (hi : 1 ≤ i) : + sparseE ε hε (i + 1) = i.factorial * (sparseR ε hε (i + 1) - 1) ^ i := by + cases i with + | zero => omega + | succ n => exact sparseE_succ_succ ε hε n + +theorem sparseD_eq (i : ℕ) (hi : 1 ≤ i) : + sparseD ε hε i = + (sparseE ε hε i + 1) * (2 + ∑ v ∈ Finset.Ico 1 i, sparseD ε hε v) := by + cases i with + | zero => omega + | succ i => + cases i with + | zero => simp + | succ n => rw [sparseD_succ_succ, sparseF_eq_sum_Ico] + +theorem sparseE_pos (i : ℕ) (hi : 1 ≤ i) : 0 < sparseE ε hε i := by + cases i with + | zero => omega + | succ i => + cases i with + | zero => simp + | succ n => + rw [sparseE_succ_succ] + have hr := sparseR_ge_two ε hε (n + 2) + exact Nat.mul_pos (Nat.factorial_pos _) (pow_pos (by omega) _) + +theorem sparseD_pos (i : ℕ) (hi : 1 ≤ i) : 0 < sparseD ε hε i := by + rw [sparseD_eq ε hε i hi] + exact Nat.mul_pos (by omega) (by omega) + +theorem sparse_entropy_bound (i : ℕ) (hi : 2 ≤ i) : + (sparseF ε hε i : ℝ) * binaryEntropy (1 / (sparseR ε hε i : ℝ)) ≤ ε := by + cases i with + | zero => omega + | succ i => + cases i with + | zero => omega + | succ n => + rw [sparseF_succ_succ, sparseR_succ_succ] + exact (Classical.choose_spec + (exists_integer_entropy_threshold + (sparseF ε hε (n + 1) + sparseD ε hε (n + 1)) hε)).2 + +theorem sparseNumerics (b : ℕ) : + SparseNumerics (sparseR ε hε) (sparseE ε hε) (sparseD ε hε) b where + r_ge_two i _ _ := sparseR_ge_two ε hε i + e_one := sparseE_one ε hε + e_succ i hi _ := sparseE_succ ε hε i hi + D_eq i hi _ := sparseD_eq ε hε i hi + +def sparseM (b : ℕ) : ℕ := 2 + 2 * ∑ i ∈ Finset.Icc 1 b, sparseE ε hε i + +theorem sparseM_eq (b : ℕ) : + sparseM ε hε b = 2 + 2 * ∑ i ∈ Finset.Icc 1 b, sparseE ε hε i := rfl + +theorem sparseM_pos (b : ℕ) : 0 < sparseM ε hε b := by + unfold sparseM + omega + +theorem sparse_tolerance_pos {b : ℕ} {η : ℝ} (hb : 1 ≤ b) (hη : 0 < η) : + 0 < η / (b : ℝ) := by + apply div_pos hη + exact_mod_cast (show 0 < b by omega) + +theorem exists_sparse_numerics (b : ℕ) (η : ℝ) (hb : 1 ≤ b) (hη : 0 < η) : + ∃ (r e D F : ℕ → ℕ) (M : ℕ), + SparseNumerics r e D b ∧ + (∀ i, 2 ≤ r i) ∧ F 0 = 0 ∧ F 1 = 0 ∧ + (∀ i, F i = ∑ v ∈ Finset.Ico 1 i, D v) ∧ + (∀ i, 2 ≤ i → i ≤ b → + (F i : ℝ) * binaryEntropy (1 / (r i : ℝ)) ≤ η / (b : ℝ)) ∧ + M = 2 + 2 * ∑ i ∈ Finset.Icc 1 b, e i ∧ 0 < M := by + let δ := η / (b : ℝ) + have hδ : 0 < δ := sparse_tolerance_pos hb hη + exact ⟨sparseR δ hδ, sparseE δ hδ, sparseD δ hδ, sparseF δ hδ, + sparseM δ hδ b, sparseNumerics δ hδ b, sparseR_ge_two δ hδ, + sparseF_zero δ hδ, sparseF_one δ hδ, sparseF_eq_sum_Ico δ hδ, + fun i hi _ => sparse_entropy_bound δ hδ i hi, sparseM_eq δ hδ b, + sparseM_pos δ hδ b⟩ + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/SparseTree.lean b/lean/OAI/Computability/DepthThree/SparseTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..8526301f73c4d99e41e8a3cbea039db45d66bd44 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/SparseTree.lean @@ -0,0 +1,303 @@ +import OAI.Computability.DepthThree.SparsePrefix +import OAI.Computability.DepthThree.SparseStreams +import Mathlib.Data.Nat.Find + +namespace OAI + +universe uDepth1 + +noncomputable section + +namespace DepthThreeLowerBound + +open scoped BigOperators + +variable {V : Type uDepth1} [DecidableEq V] + +def SparseEligible (r : ℕ → ℕ) (s : SparseState V) : Prop := + ∃ i, Nonempty (SignedSunflower s i (r i)) + +def SparseTerminal (r : ℕ → ℕ) (s : SparseState V) : Prop := + ∀ i, ¬ Nonempty (SignedSunflower s i (r i)) + +theorem sparseTerminal_of_not_eligible {r : ℕ → ℕ} {s : SparseState V} + (h : ¬ SparseEligible r s) : SparseTerminal r s := + fun i hi => h ⟨i, hi⟩ + +structure SparseSelection (r : ℕ → ℕ) (s : SparseState V) where + size : ℕ + selected : SignedSunflower s size (r size) + minimal : ∀ j, 2 ≤ j → j < size → + ¬ Nonempty (SignedSunflower s j (r j)) + +def sparseSelect (r : ℕ → ℕ) (s : SparseState V) (h : SparseEligible r s) : + SparseSelection r s := by + classical + exact { + size := Nat.find h + selected := Classical.choice (Nat.find_spec h) + minimal := fun _ _ hj => Nat.find_min h hj } + +namespace SparseSelection + +variable {r : ℕ → ℕ} {s : SparseState V} {b : ℕ} + +def branch (c : SparseSelection r s) (choice : Bool) : SparseState V := + c.selected.branch choice + +def step (c : SparseSelection r s) (choice : Bool) : + SparseStep r s (c.branch choice) where + size := c.size + selected := c.selected + minimal := c.minimal + choice := choice + target := rfl + +def label (c : SparseSelection r s) (hs : s.Valid b) : Fin (b + 1) := + ⟨c.size, Nat.lt_succ_of_le (c.selected.size_le hs)⟩ + +theorem branch_valid (c : SparseSelection r s) (hs : s.Valid b) (choice : Bool) : + (c.branch choice).Valid b := c.selected.branch_valid choice hs + +theorem branch_eval_imp (c : SparseSelection r s) (choice : Bool) (x : Cube V) + (h : (c.branch choice).eval x = true) : s.eval x = true := by + cases choice + · change c.selected.coreBranch.eval x = true at h + rw [c.selected.eval_coreBranch, Bool.and_eq_true] at h + exact h.1 + · change c.selected.petalBranch.eval x = true at h + rw [c.selected.eval_petalBranch, Bool.and_eq_true] at h + exact h.1 + +end SparseSelection + +namespace SparsePath + +variable {r : ℕ → ℕ} {start middle finish : SparseState V} + +def prepend (step : SparseStep r start middle) : + {finish : SparseState V} → SparsePath r middle finish → SparsePath r start finish + | _, .nil => .snoc .nil step + | _, .snoc path next => .snoc (path.prepend step) next + +theorem length_prepend (step : SparseStep r start middle) + (path : SparsePath r middle finish) : + (path.prepend step).length = 1 + path.length := by + induction path with + | nil => rfl + | snoc path next ih => simp only [prepend, length, ih, Nat.add_assoc] + +theorem processed_prepend (step : SparseStep r start middle) + (path : SparsePath r middle finish) (i : ℕ) : + (path.prepend step).processed i = + (if step.size = i then 1 else 0) + path.processed i := by + induction path with + | nil => simp only [prepend, processed, Nat.zero_add, Nat.add_zero] + | snoc path next ih => simp only [prepend, processed, ih, Nat.add_assoc] + +theorem petalSteps_prepend (step : SparseStep r start middle) + (path : SparsePath r middle finish) (i : ℕ) : + (path.prepend step).petalSteps i = + (if step.size = i ∧ step.choice = true then 1 else 0) + path.petalSteps i := by + induction path with + | nil => simp only [prepend, petalSteps, Nat.zero_add, Nat.add_zero] + | snoc path next ih => simp only [prepend, petalSteps, ih, Nat.add_assoc] + +end SparsePath + +structure SparseTreeResult (r : ℕ → ℕ) (b : ℕ) (start : SparseState V) (fuel : ℕ) where + tree : SparseDecisionTree (Fin (b + 1)) + finish : tree.Leaf → SparseState V + path : (p : tree.Leaf) → SparsePath r start (finish p) + terminal_or_exhausted : ∀ p, SparseTerminal r (finish p) ∨ (path p).length = fuel + stream_length : ∀ p i, (tree.stream p i).length = (path p).processed i.val + stream_ones : ∀ p i, (tree.stream p i).count true = (path p).petalSteps i.val + leaf_eval_imp : ∀ p x, (finish p).eval x = true → start.eval x = true + indicator_eq_sum : ∀ x, indicator (start.eval x) = ∑ p, indicator ((finish p).eval x) + disjoint : ∀ p q, p ≠ q → ∀ x, + ¬ ((finish p).eval x = true ∧ (finish q).eval x = true) + +namespace SparseTreeResult + +variable {r : ℕ → ℕ} {b fuel : ℕ} {s : SparseState V} + +private def stop (r : ℕ → ℕ) (b : ℕ) (s : SparseState V) (fuel : ℕ) + (h : SparseTerminal r s ∨ fuel = 0) : SparseTreeResult r b s fuel where + tree := .leaf + finish := fun _ => s + path := fun _ => .nil + terminal_or_exhausted := by + intro _ + rcases h with h | h + · exact Or.inl h + · exact Or.inr (by simp only [SparsePath.length, h]) + stream_length := by intros; rfl + stream_ones := by intros; rfl + leaf_eval_imp := by intros _ _ h; exact h + indicator_eq_sum := by + intro x + change indicator (s.eval x) = ∑ _ : Unit, indicator (s.eval x) + exact (Fintype.sum_unique (fun _ : Unit => indicator (s.eval x))).symm + disjoint := by intro p q hpq; exact (hpq (Subsingleton.elim (α := Unit) p q)).elim + +private def join (c : SparseSelection r s) (hs : s.Valid b) + (left : SparseTreeResult r b (c.branch false) fuel) + (right : SparseTreeResult r b (c.branch true) fuel) : + SparseTreeResult r b s (fuel + 1) where + tree := .node (c.label hs) left.tree right.tree + finish := Sum.elim left.finish right.finish + path := fun p => match p with + | .inl p => (left.path p).prepend (c.step false) + | .inr p => (right.path p).prepend (c.step true) + terminal_or_exhausted := by + intro p + cases p with + | inl p => + rcases left.terminal_or_exhausted p with h | h + · exact Or.inl h + · exact Or.inr (by + change ((left.path p).prepend (c.step false)).length = fuel + 1 + rw [SparsePath.length_prepend, h, Nat.add_comm]) + | inr p => + rcases right.terminal_or_exhausted p with h | h + · exact Or.inl h + · exact Or.inr (by + change ((right.path p).prepend (c.step true)).length = fuel + 1 + rw [SparsePath.length_prepend, h, Nat.add_comm]) + stream_length := by + intro p i + cases p with + | inl p => + by_cases hi : i = c.label hs + · subst i + simp [SparseDecisionTree.stream, SparsePath.processed_prepend, + SparseSelection.step, SparseSelection.label, left.stream_length, Nat.add_comm] + · have hiv : c.size ≠ i.val := by + intro he + exact hi (Fin.ext he.symm) + simp [SparseDecisionTree.stream, hi, SparsePath.processed_prepend, + SparseSelection.step, hiv, left.stream_length] + | inr p => + by_cases hi : i = c.label hs + · subst i + simp [SparseDecisionTree.stream, SparsePath.processed_prepend, + SparseSelection.step, SparseSelection.label, right.stream_length, Nat.add_comm] + · have hiv : c.size ≠ i.val := by + intro he + exact hi (Fin.ext he.symm) + simp [SparseDecisionTree.stream, hi, SparsePath.processed_prepend, + SparseSelection.step, hiv, right.stream_length] + stream_ones := by + intro p i + cases p with + | inl p => + by_cases hi : i = c.label hs + · subst i + simp [SparseDecisionTree.stream, SparsePath.petalSteps_prepend, + SparseSelection.step, SparseSelection.label, left.stream_ones] + · have hiv : c.size ≠ i.val := by + intro he + exact hi (Fin.ext he.symm) + simp [SparseDecisionTree.stream, hi, SparsePath.petalSteps_prepend, + SparseSelection.step, hiv, left.stream_ones] + | inr p => + by_cases hi : i = c.label hs + · subst i + simp [SparseDecisionTree.stream, SparsePath.petalSteps_prepend, + SparseSelection.step, SparseSelection.label, right.stream_ones, Nat.add_comm] + · have hiv : c.size ≠ i.val := by + intro he + exact hi (Fin.ext he.symm) + simp [SparseDecisionTree.stream, hi, SparsePath.petalSteps_prepend, + SparseSelection.step, hiv, right.stream_ones] + leaf_eval_imp := by + intro p x hp + cases p with + | inl p => exact c.branch_eval_imp false x (left.leaf_eval_imp p x hp) + | inr p => exact c.branch_eval_imp true x (right.leaf_eval_imp p x hp) + indicator_eq_sum := by + intro x + change indicator (s.eval x) = + ∑ p : left.tree.Leaf ⊕ right.tree.Leaf, + indicator ((Sum.elim left.finish right.finish p).eval x) + rw [Fintype.sum_sum_type] + simp only [Sum.elim_inl, Sum.elim_inr] + rw [← left.indicator_eq_sum x, ← right.indicator_eq_sum x] + exact c.selected.branch_indicator x + disjoint := by + intro p q hpq x hpqx + cases p with + | inl p => + cases q with + | inl q => + exact left.disjoint p q (fun h => hpq (congrArg Sum.inl h)) x hpqx + | inr q => + exact c.selected.branch_disjoint x + ⟨left.leaf_eval_imp p x hpqx.1, right.leaf_eval_imp q x hpqx.2⟩ + | inr p => + cases q with + | inl q => + exact c.selected.branch_disjoint x + ⟨left.leaf_eval_imp q x hpqx.2, right.leaf_eval_imp p x hpqx.1⟩ + | inr q => + exact right.disjoint p q (fun h => hpq (congrArg Sum.inr h)) x hpqx + +def build (r : ℕ → ℕ) (b : ℕ) : + (fuel : ℕ) → (s : SparseState V) → s.Valid b → SparseTreeResult r b s fuel + | 0, s, _ => stop r b s 0 (Or.inr rfl) + | fuel + 1, s, hs => by + classical + exact if h : SparseEligible r s then + let c := sparseSelect r s h + join c hs + (build r b fuel (c.branch false) (c.branch_valid hs false)) + (build r b fuel (c.branch true) (c.branch_valid hs true)) + else stop r b s (fuel + 1) (Or.inl (sparseTerminal_of_not_eligible h)) + +end SparseTreeResult + +def sparseTreeFuel [Fintype V] (D : ℕ → ℕ) (b : ℕ) : ℕ := + (∑ u ∈ Finset.Ico 1 b, D u) * Fintype.card V + +def sparseTree [Fintype V] (r D : ℕ → ℕ) (b : ℕ) (s : SparseState V) + (hs : s.Valid b) : SparseTreeResult r b s (sparseTreeFuel (V := V) D b) := + SparseTreeResult.build r b (sparseTreeFuel (V := V) D b) s hs + +theorem sparseTree_terminal [Fintype V] {r e D : ℕ → ℕ} {b : ℕ} + (hnum : SparseNumerics r e D b) (s : SparseState V) (hs : s.Valid b) + (hadded : s.added = ∅) (p : (sparseTree r D b s hs).tree.Leaf) : + SparseTerminal r ((sparseTree r D b s hs).finish p) := by + classical + let T := sparseTree r D b s hs + rcases T.terminal_or_exhausted p with ht | hlen + · exact ht + · intro i hi + let c := sparseSelect r (T.finish p) ⟨i, hi⟩ + have hbound := ((T.path p).snoc (c.step false)).length_budget hnum hs hadded + change (T.path p).length + 1 ≤ sparseTreeFuel (V := V) D b at hbound + rw [hlen] at hbound + exact Nat.not_succ_le_self _ hbound + +theorem sparseTree_stream_length [Fintype V] {r e D : ℕ → ℕ} {b : ℕ} + (hnum : SparseNumerics r e D b) (s : SparseState V) (hs : s.Valid b) + (hadded : s.added = ∅) (p : (sparseTree r D b s hs).tree.Leaf) (i : Fin (b + 1)) : + ((sparseTree r D b s hs).tree.stream p i).length ≤ + (∑ u ∈ Finset.Ico 1 i.val, D u) * Fintype.card V := by + rw [(sparseTree r D b s hs).stream_length] + exact ((sparseTree r D b s hs).path p).processed_budget hnum hs hadded i.val + (Nat.le_of_lt_succ i.isLt) + +theorem sparseTree_stream_ones [Fintype V] {r e D : ℕ → ℕ} {b : ℕ} + (hnum : SparseNumerics r e D b) (s : SparseState V) (hs : s.Valid b) + (hadded : s.added = ∅) (p : (sparseTree r D b s hs).tree.Leaf) (i : Fin (b + 1)) : + r i.val * ((sparseTree r D b s hs).tree.stream p i).count true ≤ + (∑ u ∈ Finset.Ico 1 i.val, D u) * Fintype.card V := by + rw [(sparseTree r D b s hs).stream_ones] + exact ((sparseTree r D b s hs).path p).petalSteps_budget hnum hs hadded i.val + (Nat.le_of_lt_succ i.isLt) + +end DepthThreeLowerBound + +end + +end OAI diff --git a/lean/OAI/Computability/DepthThree/Sunflower.lean b/lean/OAI/Computability/DepthThree/Sunflower.lean new file mode 100644 index 0000000000000000000000000000000000000000..df7aa979c443355d99247059877d22e645078b28 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/Sunflower.lean @@ -0,0 +1,272 @@ +import Mathlib.Combinatorics.Pigeonhole +import Mathlib.Data.Finset.Max +import Mathlib.Data.Finset.Powerset +import Mathlib.Data.Nat.Factorial.Basic +import Mathlib.Tactic.Ring +import Lean.Elab.Tactic.Omega + +namespace OAI + +universe uDepth1 + +namespace DepthThreeLowerBound + +open scoped BigOperators + +variable {α : Type uDepth1} [DecidableEq α] + +def Sunflower (family : Finset (Finset α)) (core : Finset α) : Prop := + ∀ A ∈ family, ∀ B ∈ family, A ≠ B → A ∩ B = core + +namespace Sunflower + +variable {family : Finset (Finset α)} {core A B : Finset α} {i : ℕ} + +theorem mono (h : Sunflower family core) {sub : Finset (Finset α)} + (hsub : sub ⊆ family) : Sunflower sub core := by + intro A hA B hB hne + exact h A (hsub hA) B (hsub hB) hne + +theorem core_subset (h : Sunflower family core) (hcard : 2 ≤ family.card) + (hA : A ∈ family) : core ⊆ A := by + obtain ⟨B, hB, hBA⟩ : ∃ B ∈ family, B ≠ A := by + obtain ⟨B, hB, C, hC, hBC⟩ := Finset.one_lt_card.mp (by omega : 1 < family.card) + by_cases hBA : B = A + · exact ⟨C, hC, fun hCA => hBC (hBA.trans hCA.symm)⟩ + · exact ⟨B, hB, hBA⟩ + rw [← h A hA B hB hBA.symm] + exact Finset.inter_subset_left + +theorem core_card_lt (h : Sunflower family core) (hcard : 2 ≤ family.card) + (uniform : ∀ A ∈ family, A.card = i) : core.card < i := by + obtain ⟨A, hA, B, hB, hAB⟩ := Finset.one_lt_card.mp (by omega : 1 < family.card) + by_contra hn + have hCA : core = A := Finset.eq_of_subset_of_card_le (h.core_subset hcard hA) + (by rw [uniform A hA]; omega) + have hCB : core = B := Finset.eq_of_subset_of_card_le (h.core_subset hcard hB) + (by rw [uniform B hB]; omega) + exact hAB (hCA.symm.trans hCB) + +theorem petal_card (h : Sunflower family core) (hcard : 2 ≤ family.card) + (uniform : ∀ A ∈ family, A.card = i) (hA : A ∈ family) : + (A \ core).card = i - core.card := by + have hcore_inter : core ∩ A = core := by + ext x + exact ⟨fun hx => (Finset.mem_inter.mp hx).1, + fun hx => Finset.mem_inter.mpr ⟨hx, h.core_subset hcard hA hx⟩⟩ + rw [Finset.card_sdiff, hcore_inter, uniform A hA] + +theorem petal_nonempty (h : Sunflower family core) (hcard : 2 ≤ family.card) + (uniform : ∀ A ∈ family, A.card = i) (hA : A ∈ family) : + (A \ core).Nonempty := by + apply Finset.card_pos.mp + rw [h.petal_card hcard uniform hA] + exact Nat.sub_pos_of_lt (h.core_card_lt hcard uniform) + +theorem petal_card_lt (h : Sunflower family core) (hcard : 2 ≤ family.card) + (uniform : ∀ A ∈ family, A.card = i) (hc : core.Nonempty) + (hA : A ∈ family) : (A \ core).card < i := by + rw [h.petal_card hcard uniform hA] + have hcpos := Finset.card_pos.mpr hc + have hclt := h.core_card_lt hcard uniform + omega + +theorem petals_disjoint (h : Sunflower family core) (hA : A ∈ family) + (hB : B ∈ family) (hne : A ≠ B) : Disjoint (A \ core) (B \ core) := by + apply Finset.disjoint_left.mpr + intro x hxA hxB + obtain ⟨hxA, hxc⟩ := Finset.mem_sdiff.mp hxA + obtain ⟨hxB, _⟩ := Finset.mem_sdiff.mp hxB + apply hxc + rw [← h A hA B hB hne] + exact Finset.mem_inter.mpr ⟨hxA, hxB⟩ + +theorem petal_injective (h : Sunflower family core) (hcard : 2 ≤ family.card) : + Set.InjOn (fun A => A \ core) (↑family : Set (Finset α)) := by + intro A hA B hB heq + calc + A = (A \ core) ∪ core := (Finset.sdiff_union_of_subset (h.core_subset hcard hA)).symm + _ = (B \ core) ∪ core := congrArg (fun D => D ∪ core) heq + _ = B := Finset.sdiff_union_of_subset (h.core_subset hcard hB) + +theorem card_petals (h : Sunflower family core) (hcard : 2 ≤ family.card) : + (family.image (fun A => A \ core)).card = family.card := + Finset.card_image_of_injOn (h.petal_injective hcard) + +end Sunflower + +private def eraseContaining (family : Finset (Finset α)) (x : α) : + Finset (Finset α) := + (family.filter (fun A => x ∈ A)).image (fun A => A.erase x) + +private theorem eraseContaining_card (family : Finset (Finset α)) (x : α) : + (eraseContaining family x).card = (family.filter (fun A => x ∈ A)).card := by + apply Finset.card_image_of_injOn + intro A hA B hB heq + have hxA := (Finset.mem_filter.mp hA).2 + have hxB := (Finset.mem_filter.mp hB).2 + calc + A = insert x (A.erase x) := (Finset.insert_erase hxA).symm + _ = insert x (B.erase x) := congrArg (insert x) heq + _ = B := Finset.insert_erase hxB + +private theorem eraseContaining_uniform (family : Finset (Finset α)) (x : α) + (i : ℕ) (uniform : ∀ A ∈ family, A.card = i + 1) : + ∀ B ∈ eraseContaining family x, B.card = i := by + intro B hB + obtain ⟨A, hA, rfl⟩ := Finset.mem_image.mp hB + obtain ⟨hA, hxA⟩ := Finset.mem_filter.mp hA + rw [Finset.card_erase_of_mem hxA, uniform A hA] + omega + +private theorem lift_erased_sunflower (family : Finset (Finset α)) (x : α) + {sub : Finset (Finset α)} {core : Finset α} + (hsub : sub ⊆ eraseContaining family x) (hs : Sunflower sub core) : + ∃ lifted ⊆ family, lifted.card = sub.card ∧ Sunflower lifted (insert x core) := by + have hrestore : ∀ B ∈ sub, insert x B ∈ family ∧ x ∉ B := by + intro B hB + obtain ⟨A, hA, rfl⟩ := Finset.mem_image.mp (hsub hB) + obtain ⟨hA, hxA⟩ := Finset.mem_filter.mp hA + exact ⟨by simpa only [Finset.insert_erase hxA] using hA, by simp⟩ + refine ⟨sub.image (insert x), ?_, ?_, ?_⟩ + · intro A hA + obtain ⟨B, hB, rfl⟩ := Finset.mem_image.mp hA + exact (hrestore B hB).1 + · apply Finset.card_image_of_injOn + intro A hA B hB heq + have he := congrArg (fun D : Finset α => D.erase x) heq + simpa only [Finset.erase_insert (hrestore A hA).2, + Finset.erase_insert (hrestore B hB).2] using he + · intro A hA B hB hne + obtain ⟨A₁, hA₁, rfl⟩ := Finset.mem_image.mp hA + obtain ⟨B₁, hB₁, rfl⟩ := Finset.mem_image.mp hB + have hAB : A₁ ≠ B₁ := fun heq => hne (congrArg (insert x) heq) + rw [← Finset.insert_inter_distrib, hs A₁ hA₁ B₁ hB₁ hAB] + +theorem finite_uniform_sunflower (family : Finset (Finset α)) (s r : ℕ) + (hr : 2 ≤ r) (uniform : ∀ A ∈ family, A.card = s) + (large : s.factorial * (r - 1) ^ s < family.card) : + ∃ sub ⊆ family, sub.card = r ∧ ∃ core, Sunflower sub core := by + classical + induction s generalizing family with + | zero => + have hsub : family ⊆ {∅} := by + intro A hA + have hzero : A = ∅ := Finset.card_eq_zero.mp (uniform A hA) + simp only [Finset.mem_singleton, hzero] + have hsmall : family.card ≤ 1 := by simpa using Finset.card_le_card hsub + simp only [Nat.factorial_zero, pow_zero, mul_one] at large + omega + | succ s ih => + let candidates := family.powerset.filter (fun M => Sunflower M (∅ : Finset α)) + have hcandidates : candidates.Nonempty := by + refine ⟨∅, Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr (Finset.empty_subset _), ?_⟩⟩ + intro A hA + simp at hA + obtain ⟨M, hM, hmax⟩ := Finset.exists_max_image candidates Finset.card hcandidates + obtain ⟨hMpow, hMs⟩ := Finset.mem_filter.mp hM + have hMsub : M ⊆ family := Finset.mem_powerset.mp hMpow + by_cases hrM : r ≤ M.card + · obtain ⟨sub, hsub, hcard⟩ := Finset.exists_subset_card_eq hrM + exact ⟨sub, hsub.trans hMsub, hcard, ∅, hMs.mono hsub⟩ + · have hMcard : M.card ≤ r - 1 := by omega + let U : Finset α := M.biUnion id + have hUcard : U.card ≤ (s + 1) * (r - 1) := by + calc + U.card ≤ ∑ A ∈ M, A.card := Finset.card_biUnion_le + _ = ∑ _A ∈ M, (s + 1) := by + apply Finset.sum_congr rfl + intro A hA + exact uniform A (hMsub hA) + _ = M.card * (s + 1) := by simp + _ ≤ (r - 1) * (s + 1) := Nat.mul_le_mul_right _ hMcard + _ = (s + 1) * (r - 1) := Nat.mul_comm _ _ + have hmeet : ∀ A ∈ family, ∃ x, x ∈ A ∧ x ∈ U := by + intro A hA + by_contra hnone + have hAM : A ∉ M := by + intro hAM + have hpos : 0 < A.card := by rw [uniform A hA]; omega + obtain ⟨x, hx⟩ := Finset.card_pos.mp hpos + exact hnone ⟨x, hx, Finset.mem_biUnion.mpr ⟨A, hAM, hx⟩⟩ + have hinter : ∀ B ∈ M, A ∩ B = ∅ := by + intro B hB + ext x + constructor + · intro hx + obtain ⟨hxA, hxB⟩ := Finset.mem_inter.mp hx + exact (hnone ⟨x, hxA, Finset.mem_biUnion.mpr ⟨B, hB, hxB⟩⟩).elim + · simp + have hinsert : Sunflower (insert A M) (∅ : Finset α) := by + intro B hB C hC hBC + rcases Finset.mem_insert.mp hB with rfl | hBM + · rcases Finset.mem_insert.mp hC with rfl | hCM + · exact (hBC rfl).elim + · exact hinter C hCM + · rcases Finset.mem_insert.mp hC with rfl | hCM + · simpa only [Finset.inter_comm] using hinter B hBM + · exact hMs B hBM C hCM hBC + have hinsertmem : insert A M ∈ candidates := by + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_powerset.mpr ?_, hinsert⟩ + intro B hB + rcases Finset.mem_insert.mp hB with rfl | hB + · exact hA + · exact hMsub hB + have hbad := hmax (insert A M) hinsertmem + simp [hAM] at hbad + obtain ⟨A₀, hA₀⟩ := Finset.card_pos.mp (lt_of_le_of_lt (Nat.zero_le _) large) + have hA₀pos : 0 < A₀.card := by rw [uniform A₀ hA₀]; omega + obtain ⟨x₀, _hx₀⟩ := Finset.card_pos.mp hA₀pos + let f : Finset α → α := fun A => + if h : ∃ x, x ∈ A ∧ x ∈ U then h.choose else x₀ + have hf : ∀ A ∈ family, f A ∈ A ∧ f A ∈ U := by + intro A hA + dsimp only [f] + rw [dite_eq_left (hmeet A hA)] + exact (hmeet A hA).choose_spec + have hprod : U.card * (s.factorial * (r - 1) ^ s) < family.card := by + calc + U.card * (s.factorial * (r - 1) ^ s) ≤ + ((s + 1) * (r - 1)) * (s.factorial * (r - 1) ^ s) := + Nat.mul_le_mul_right _ hUcard + _ = (s + 1).factorial * (r - 1) ^ (s + 1) := by + rw [Nat.factorial_succ, pow_succ] + ring + _ < family.card := large + obtain ⟨x, _hxU, hxmany⟩ := + Finset.exists_lt_card_fiber_of_mul_lt_card_of_maps_to + (fun A hA => (hf A hA).2) hprod + have hfiber : (family.filter (fun A => f A = x)) ⊆ + family.filter (fun A => x ∈ A) := by + intro A hA + obtain ⟨hA, hfx⟩ := Finset.mem_filter.mp hA + exact Finset.mem_filter.mpr ⟨hA, hfx ▸ (hf A hA).1⟩ + have herasedlarge : s.factorial * (r - 1) ^ s < (eraseContaining family x).card := by + rw [eraseContaining_card] + exact hxmany.trans_le (Finset.card_le_card hfiber) + obtain ⟨sub, hsub, hsubcard, core, hs⟩ := + ih (eraseContaining family x) (eraseContaining_uniform family x s uniform) herasedlarge + obtain ⟨lifted, hlifted, hcard, hlifts⟩ := lift_erased_sunflower family x hsub hs + exact ⟨lifted, hlifted, hcard.trans hsubcard, insert x core, hlifts⟩ + +theorem no_nonempty_core_sunflower_occurrence_le (family : Finset (Finset α)) + (i r : ℕ) (hr : 2 ≤ r) (uniform : ∀ A ∈ family, A.card = i + 1) + (hno : ∀ sub ⊆ family, sub.card = r → + ∀ core, core.Nonempty → ¬ Sunflower sub core) (x : α) : + (family.filter (fun A => x ∈ A)).card ≤ i.factorial * (r - 1) ^ i := by + classical + by_contra hn + have hlarge : i.factorial * (r - 1) ^ i < (eraseContaining family x).card := by + rw [eraseContaining_card] + omega + obtain ⟨sub, hsub, hcard, core, hs⟩ := + finite_uniform_sunflower (eraseContaining family x) i r hr + (eraseContaining_uniform family x i uniform) hlarge + obtain ⟨lifted, hlifted, hliftedcard, hlifts⟩ := lift_erased_sunflower family x hsub hs + exact hno lifted hlifted (hliftedcard.trans hcard) (insert x core) + (Finset.insert_nonempty x core) hlifts + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeArithmetic.lean b/lean/OAI/Computability/DepthThree/TapeArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a56b1aaa57e46c11d76f138130b49c73b7423aa --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeArithmetic.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DepthThree.TapeRouting +import OAI.Computability.DepthThree.TapeUnary +import OAI.Computability.DepthThree.TapeCopy +import Lean.Elab.Tactic.Omega + +namespace OAI + +universe uDepth1 uDepth2 + +namespace DepthThreeLowerBound +namespace TapeArithmetic + +open TapeMultiProgram TapeRouting TapeUnary TapeCopy + +theorem update_onPair_src {α : Type uDepth1} (src dst : TapeRegister) + (T : TapeRegister → α) (s d s' : α) : + Function.update (onPair src dst T s d) src s' = onPair src dst T s' d := by + funext r + by_cases h : r = src + · subst r + simp + · simp [Function.update, onPair, h] + +theorem update_onPair_dst {α : Type uDepth2} {src dst : TapeRegister} (hne : src ≠ dst) + (T : TapeRegister → α) (s d d' : α) : + Function.update (onPair src dst T s d) dst d' = onPair src dst T s d' := by + funext r + by_cases hs : r = src + · subst r + simp [Function.update, onPair, hne] + · by_cases hd : r = dst + · subst r + simp [Function.update, onPair, Ne.symm hne] + · simp [Function.update, onPair, hs, hd] + +def decPositive : DecState → Bool + | .done b => b + | _ => false + +abbrev AddState := LoopState DecState IncState + +def addProgram (counter destination : TapeRegister) : TapeMultiProgram AddState := + loopCode (decProgram counter) (incProgram destination) + DecState.start IncState.start decPositive + +def addStart : AddState := loopTest DecState.start +def addDone : AddState := loopDone + +theorem runs_add {counter destination : TapeRegister} (hne : counter ≠ destination) + (T : TapeTapes) (n m : ℕ) : + RunsIn (addProgram counter destination).step + (cfg addStart (onPair counter destination T (counterTape n) (counterTape m))) + (cfg addDone (onPair counter destination T (counterTape 0) (counterTape (m + n)))) + (8 * n + 3) := by + induction n generalizing m with + | zero => + have hdec := decrement_empty counter + (onPair counter destination T (counterTape 0) (counterTape m)) (by + simp [counterTape]) + have he := loop_exit (decProgram counter) (incProgram destination) + DecState.start IncState.start decPositive hdec rfl rfl + simpa only [addProgram, addStart, addDone, Nat.mul_zero, Nat.zero_add, + Nat.add_zero] using he + | succ n ih => + have hdec := decrement_cons counter + (onPair counter destination T (counterTape (n + 1)) (counterTape m)) + (List.replicate n true) true (by simp [counterTape, List.replicate_succ]) + simp only [update_onPair_src] at hdec + have hinc := increment destination + (onPair counter destination T (counterTape n) (counterTape m)) m (by + simp [hne]) + simp only [update_onPair_dst hne] at hinc + have hit := loop_iter (decProgram counter) (incProgram destination) + DecState.start IncState.start decPositive hdec rfl rfl hinc rfl + have hrest := ih (m + 1) + have hall := hit.trans hrest + have hacc : m + 1 + n = m + (n + 1) := by omega + have htime : 4 + 1 + 2 + 1 + (8 * n + 3) = 8 * (n + 1) + 3 := by omega + simpa only [addProgram, addStart, addDone, hacc, htime] using hall + +@[simp] theorem add_done (counter destination : TapeRegister) (h : TapeHeads) : + addProgram counter destination addDone h = none := rfl + +end TapeArithmetic +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeArray.lean b/lean/OAI/Computability/DepthThree/TapeArray.lean new file mode 100644 index 0000000000000000000000000000000000000000..53ede1d94e40a4cff0765f5b601aeb1c86ed5811 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeArray.lean @@ -0,0 +1,205 @@ +import OAI.Computability.DepthThree.TapeCopy + +namespace OAI + +universe uDepth1 + +namespace DepthThreeLowerBound +namespace TapeArray + +open Turing TapeMultiProgram TapeCopy + +inductive State where + | start + | scan + | rewind (read : Bool) + | done (read : Bool) + deriving DecidableEq, Fintype, Inhabited + +def code (index array : TapeRegister) (f : Bool → Bool) : TapeMultiProgram State + | .start, h => emit index array .scan h (h index) (h array) .right + | .scan, h => + match (h index).1 with + | .bit true => emit index array .scan h (h index) (h array) .right + | .endMark => + match (h array).1 with + | .bit b => emit index array (.rewind b) h (h index) (rawInputSymbol (f b)) .stay + | _ => none + | _ => none + | .rewind b, h => + if (h index).1 = .home then emit index array (.done b) h (h index) (h array) .stay + else emit index array (.rewind b) h (h index) (h array) .left + | .done _, _ => none + +private theorem replicate_append_cons {α : Type uDepth1} (n : ℕ) (a : α) (L : List α) : + List.replicate n a ++ a :: L = a :: (List.replicate n a ++ L) := by + induction n with + | zero => rfl + | succ n ih => simpa only [List.replicate_succ, List.cons_append] using congrArg (List.cons a) ih + +theorem step_start {index array : TapeRegister} (hne : index ≠ array) + (f : Bool → Bool) (T : TapeTapes) (I A : Tape TapeSymbol) : + (code index array f).step (cfg .start (onPair index array T I A)) = + some (cfg .scan (onPair index array T (I.move .right) (A.move .right))) := by + have h := step_emit (code index array f) hne T I A .start .scan I.head A.head .right + (by simp [code, heads, hne]) + simpa only [Tape.write_self, HeadMove.apply_right] using h + +theorem step_scan_bit {index array : TapeRegister} (hne : index ≠ array) + (f : Bool → Bool) (T : TapeTapes) (I A : Tape TapeSymbol) + (hI : I.head = rawInputSymbol true) : + (code index array f).step (cfg .scan (onPair index array T I A)) = + some (cfg .scan (onPair index array T (I.move .right) (A.move .right))) := by + have h := step_emit (code index array f) hne T I A .scan .scan I.head A.head .right + (by simp [code, heads, hne, hI, rawInputSymbol, cleanAtom]) + simpa only [Tape.write_self, HeadMove.apply_right] using h + +theorem step_scan_end {index array : TapeRegister} (hne : index ≠ array) + (f : Bool → Bool) (T : TapeTapes) (I A : Tape TapeSymbol) (b : Bool) + (hI : I.head = cleanAtom .endMark) (hA : A.head = rawInputSymbol b) : + (code index array f).step (cfg .scan (onPair index array T I A)) = + some (cfg (.rewind b) (onPair index array T I (A.write (rawInputSymbol (f b))))) := by + have h := step_emit (code index array f) hne T I A .scan (.rewind b) + I.head (rawInputSymbol (f b)) .stay + (by simp [code, heads, hne, hI, hA, rawInputSymbol, cleanAtom]) + simpa only [Tape.write_self, HeadMove.apply_stay] using h + +theorem step_rewind_move {index array : TapeRegister} (hne : index ≠ array) + (f : Bool → Bool) (T : TapeTapes) (I A : Tape TapeSymbol) (b : Bool) + (hI : I.head.1 ≠ .home) : + (code index array f).step (cfg (.rewind b) (onPair index array T I A)) = + some (cfg (.rewind b) (onPair index array T (I.move .left) (A.move .left))) := by + have h := step_emit (code index array f) hne T I A (.rewind b) (.rewind b) + I.head A.head .left (by simp [code, heads, hne, hI]) + simpa only [Tape.write_self, HeadMove.apply_left] using h + +theorem step_rewind_home {index array : TapeRegister} (hne : index ≠ array) + (f : Bool → Bool) (T : TapeTapes) (I A : Tape TapeSymbol) (b : Bool) + (hI : I.head.1 = .home) : + (code index array f).step (cfg (.rewind b) (onPair index array T I A)) = + some (cfg (.done b) (onPair index array T I A)) := by + have h := step_emit (code index array f) hne T I A (.rewind b) (.done b) + I.head A.head .stay (by simp [code, heads, hne, hI]) + simpa only [Tape.write_self, HeadMove.apply_stay] using h + +theorem runs_scan {index array : TapeRegister} (hne : index ≠ array) + (f : Bool → Bool) (T : TapeTapes) («prefix» : List Bool) + (LI LA R : List TapeSymbol) : + RunsIn (code index array f).step + (cfg .scan (onPair index array T + (Tape.mk₂ LI (List.replicate «prefix».length (rawInputSymbol true) ++ [cleanAtom .endMark])) + (Tape.mk₂ LA (encodeInput «prefix» ++ R)))) + (cfg .scan (onPair index array T + (Tape.mk₂ (List.replicate «prefix».length (rawInputSymbol true) ++ LI) [cleanAtom .endMark]) + (Tape.mk₂ ((encodeInput «prefix»).reverse ++ LA) R))) + «prefix».length := by + induction «prefix» generalizing LI LA with + | nil => + simpa only [List.length_nil, List.replicate_zero, List.nil_append, + encodeInput, List.map_nil, List.reverse_nil] using + RunsIn.refl (code index array f).step + (cfg .scan (onPair index array T (Tape.mk₂ LI [cleanAtom .endMark]) (Tape.mk₂ LA R))) + | cons a «prefix» ih => + have hfirst := RunsIn.single (step_scan_bit hne f T + (Tape.mk₂ LI (rawInputSymbol true :: + (List.replicate «prefix».length (rawInputSymbol true) ++ [cleanAtom .endMark]))) + (Tape.mk₂ LA (rawInputSymbol a :: (encodeInput «prefix» ++ R))) rfl) + simp only [TapeWord.move_right_mk₂_cons] at hfirst + have hrest := ih (rawInputSymbol true :: LI) (rawInputSymbol a :: LA) + simpa only [List.length_cons, List.replicate_succ, encodeInput, List.map_cons, + List.cons_append, List.reverse_cons, List.append_assoc, List.nil_append, + replicate_append_cons, Nat.add_comm] using hfirst.trans hrest + +theorem runs_rewind {index array : TapeRegister} (hne : index ≠ array) + (f : Bool → Bool) (T : TapeTapes) (left : List Bool) (b : Bool) + (i : TapeSymbol) (RI RA : List TapeSymbol) (hi : i.1 ≠ .home) : + RunsIn (code index array f).step + (cfg (.rewind b) (onPair index array T + (Tape.mk₂ (List.replicate left.length (rawInputSymbol true) ++ [cleanAtom .home]) (i :: RI)) + (Tape.mk₂ (encodeInput left ++ [cleanAtom .home]) RA))) + (cfg (.done b) (onPair index array T + (Tape.mk₂ [] (cleanAtom .home :: + (List.replicate left.length (rawInputSymbol true) ++ i :: RI))) + (Tape.mk₂ [] (cleanAtom .home :: ((encodeInput left).reverse ++ RA))))) + (left.length + 2) := by + induction left generalizing i RI RA with + | nil => + have hfirst := RunsIn.single (step_rewind_move hne f T + (Tape.mk₂ [cleanAtom .home] (i :: RI)) (Tape.mk₂ [cleanAtom .home] RA) b hi) + simp only [TapeWord.move_left_mk₂_cons] at hfirst + have hlast := RunsIn.single (step_rewind_home hne f T + (Tape.mk₂ [] (cleanAtom .home :: i :: RI)) + (Tape.mk₂ [] (cleanAtom .home :: RA)) b rfl) + simpa only [List.length_nil, List.replicate_zero, List.nil_append, + encodeInput, List.map_nil, List.reverse_nil, Nat.zero_add] using hfirst.trans hlast + | cons a left ih => + have hfirst := RunsIn.single (step_rewind_move hne f T + (Tape.mk₂ (rawInputSymbol true :: + (List.replicate left.length (rawInputSymbol true) ++ [cleanAtom .home])) (i :: RI)) + (Tape.mk₂ (rawInputSymbol a :: (encodeInput left ++ [cleanAtom .home])) RA) b hi) + simp only [TapeWord.move_left_mk₂_cons] at hfirst + have hrest := ih (rawInputSymbol true) (i :: RI) (rawInputSymbol a :: RA) + (by simp [rawInputSymbol, cleanAtom]) + simpa only [List.length_cons, List.replicate_succ, encodeInput, List.map_cons, + List.cons_append, List.reverse_cons, List.append_assoc, List.nil_append, + replicate_append_cons, Nat.add_comm, Nat.add_left_comm, Nat.add_assoc] + using hfirst.trans hrest + +theorem runs_modify {index array : TapeRegister} (hne : index ≠ array) + (f : Bool → Bool) (T : TapeTapes) («prefix» suffix : List Bool) (b : Bool) : + RunsIn (code index array f).step + (cfg .start (onPair index array T + (wordTape (List.replicate «prefix».length true)) (wordTape («prefix» ++ b :: suffix)))) + (cfg (.done b) (onPair index array T + (wordTape (List.replicate «prefix».length true)) (wordTape («prefix» ++ f b :: suffix)))) + (2 * «prefix».length + 4) := by + have hstart := RunsIn.single (step_start hne f T + (wordTape (List.replicate «prefix».length true)) (wordTape («prefix» ++ b :: suffix))) + have hscan := runs_scan hne f T «prefix» [cleanAtom .home] [cleanAtom .home] + (rawInputSymbol b :: (encodeInput suffix ++ [cleanAtom .endMark])) + have hwrite := RunsIn.single (step_scan_end hne f T + (Tape.mk₂ (List.replicate «prefix».length (rawInputSymbol true) ++ [cleanAtom .home]) + [cleanAtom .endMark]) + (Tape.mk₂ ((encodeInput «prefix»).reverse ++ [cleanAtom .home]) + (rawInputSymbol b :: (encodeInput suffix ++ [cleanAtom .endMark]))) b rfl rfl) + simp only [TapeWord.write_mk₂_cons] at hwrite + have hback := runs_rewind hne f T «prefix».reverse b (cleanAtom .endMark) [] + (rawInputSymbol (f b) :: (encodeInput suffix ++ [cleanAtom .endMark])) + (by simp [cleanAtom]) + have hreverse : encodeInput «prefix».reverse = (encodeInput «prefix»).reverse := by + simp [encodeInput] + simp only [hreverse, List.reverse_reverse, List.length_reverse] at hback + have hstart' : RunsIn (code index array f).step + (cfg .start (onPair index array T + (wordTape (List.replicate «prefix».length true)) (wordTape («prefix» ++ b :: suffix)))) + (cfg .scan (onPair index array T + (Tape.mk₂ [cleanAtom .home] + (List.replicate «prefix».length (rawInputSymbol true) ++ [cleanAtom .endMark])) + (Tape.mk₂ [cleanAtom .home] + (encodeInput «prefix» ++ rawInputSymbol b :: (encodeInput suffix ++ [cleanAtom .endMark]))))) 1 := by + simpa only [wordTape_right, cursorTape, encodeInput, List.map_append, + List.map_replicate, List.map_cons, List.map_nil, List.reverse_nil, + List.nil_append, List.append_assoc, List.cons_append] using hstart + have hboth := ((hstart'.trans hscan).trans hwrite).trans hback + simpa only [wordTape, Tape.mk₁, encodeInput, List.map_replicate, List.map_append, + List.map_cons, List.append_assoc, List.cons_append, List.append_nil, + Nat.two_mul, Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using hboth + +theorem runs_read {index array : TapeRegister} (hne : index ≠ array) + (T : TapeTapes) («prefix» suffix : List Bool) (b : Bool) : + RunsIn (code index array id).step + (cfg .start (onPair index array T + (wordTape (List.replicate «prefix».length true)) (wordTape («prefix» ++ b :: suffix)))) + (cfg (.done b) (onPair index array T + (wordTape (List.replicate «prefix».length true)) (wordTape («prefix» ++ b :: suffix)))) + (2 * «prefix».length + 4) := + runs_modify hne id T «prefix» suffix b + +@[simp] theorem step_done (index array : TapeRegister) (f : Bool → Bool) + (T : TapeTapes) (b : Bool) : + (code index array f).step (cfg (.done b) T) = none := rfl + +end TapeArray +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeBranch.lean b/lean/OAI/Computability/DepthThree/TapeBranch.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0fa2c21bc065accc1ba10a94d3d7d48c0e64589 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeBranch.lean @@ -0,0 +1,73 @@ +import OAI.Computability.DepthThree.TapeRouting + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 uDepth7 uDepth8 uDepth9 uDepth10 uDepth11 uDepth12 uDepth13 uDepth14 uDepth15 uDepth16 uDepth17 uDepth18 uDepth19 uDepth20 + +namespace DepthThreeLowerBound +namespace TapeBranch + +open TapeMultiProgram + +abbrev State (Q : Type uDepth1) (R : Type uDepth2) := Q ⊕ (R ⊕ Unit) + +def test {Q : Type uDepth3} {R : Type uDepth4} (q : Q) : State Q R := .inl q +def body {Q : Type uDepth5} {R : Type uDepth6} (r : R) : State Q R := .inr (.inl r) +def rejected {Q : Type uDepth7} {R : Type uDepth8} : State Q R := .inr (.inr ()) + +def program {Q : Type uDepth9} {R : Type uDepth10} (P : TapeMultiProgram Q) (B : TapeMultiProgram R) + (entry : R) (accept : Q → Bool) : TapeMultiProgram (State Q R) + | .inl q, h => + match P q h with + | none => jump (if accept q then body entry else rejected) h + | some (q', writes, moves) => some (test q', writes, moves) + | .inr (.inl r), h => (B r h).map fun out => (body out.1, out.2) + | .inr (.inr _), _ => none + +@[simp] theorem rejected_halts {Q : Type uDepth11} {R : Type uDepth12} (P : TapeMultiProgram Q) + (B : TapeMultiProgram R) (entry : R) (accept : Q → Bool) (h : TapeHeads) : + program P B entry accept rejected h = none := rfl + +theorem body_halts {Q : Type uDepth13} {R : Type uDepth14} (P : TapeMultiProgram Q) + (B : TapeMultiProgram R) (entry : R) (accept : Q → Bool) + (r : R) (h : TapeHeads) (hr : B r h = none) : + program P B entry accept (body r) h = none := by + simp only [program, body, hr, Option.map_none] + +theorem runs_test {Q : Type uDepth15} {R : Type uDepth16} (P : TapeMultiProgram Q) (B : TapeMultiProgram R) + (entry : R) (accept : Q → Bool) {q q' : Q} {T U : TapeTapes} {m : ℕ} + (h : RunsIn P.step (cfg q T) (cfg q' U) m) : + RunsIn (program P B entry accept).step (cfg (test q) T) (cfg (test q') U) m := + runs_map P _ test (by + intro a heads a' writes moves he + simp only [program, test, he]) h + +theorem runs_reject {Q : Type uDepth17} {R : Type uDepth18} (P : TapeMultiProgram Q) (B : TapeMultiProgram R) + (entry : R) (accept : Q → Bool) {q q' : Q} {T U : TapeTapes} {m : ℕ} + (h : RunsIn P.step (cfg q T) (cfg q' U) m) + (hhalt : P q' (heads U) = none) (hno : accept q' = false) : + RunsIn (program P B entry accept).step (cfg (test q) T) (cfg rejected U) (m + 1) := by + have ht := runs_test P B entry accept h + have he := RunsIn.single (step_jump (program P B entry accept) (test q') rejected U + (by simp [program, test, hhalt, hno])) + exact ht.trans he + +theorem runs_accept {Q : Type uDepth19} {R : Type uDepth20} (P : TapeMultiProgram Q) (B : TapeMultiProgram R) + (entry : R) (accept : Q → Bool) {q q' : Q} {r : R} {T U V : TapeTapes} {m n : ℕ} + (hP : RunsIn P.step (cfg q T) (cfg q' U) m) + (hhalt : P q' (heads U) = none) (hyes : accept q' = true) + (hB : RunsIn B.step (cfg entry U) (cfg r V) n) : + RunsIn (program P B entry accept).step (cfg (test q) T) (cfg (body r) V) + (m + 1 + n) := by + have ht := runs_test P B entry accept hP + have he := RunsIn.single (step_jump (program P B entry accept) (test q') (body entry) U + (by simp [program, test, hhalt, hyes])) + have hb := runs_map B (program P B entry accept) body (by + intro a heads a' writes moves hcode + simp only [program, body, hcode, Option.map_some]) hB + exact (ht.trans he).trans hb + +end TapeBranch +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeCancel.lean b/lean/OAI/Computability/DepthThree/TapeCancel.lean new file mode 100644 index 0000000000000000000000000000000000000000..10c148fa6521beee9fd5e144f3754ca2261b5166 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeCancel.lean @@ -0,0 +1,132 @@ +import OAI.Computability.DepthThree.TapeCancelRow + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeCancel + +open TapeMultiProgram TapeRouting TapeUnary TapeProductTerm TapeRegister + +abbrev ReadState := TapeArray.State ⊕ (Bool × TapeCancelRow.State) +abbrev ClearState := ReadState ⊕ TapeArray.State +abbrev State := ClearState ⊕ Unit + +def readProgram : TapeMultiProgram ReadState := + joinCode (TapeArray.code indexB productBits id) + (carryCode TapeCancelRow.program) (fun q => (readFlag q, TapeCancelRow.start)) + +def clearProgram : TapeMultiProgram ClearState := + joinCode readProgram (TapeArray.code indexC productBits (fun _ => false)) + (fun _ => TapeArray.State.start) + +def haltProgram : TapeMultiProgram Unit := fun _ _ => none + +def program : TapeMultiProgram State := + joinCode clearProgram haltProgram (fun _ => ()) + +def start : State := .inl (.inl (.inl TapeArray.State.start)) +def done : State := .inr () + +def resultStore (σ : TapeStore) (r s : ℕ) (out : List Bool) : TapeStore := + TapeCancelRow.frame σ 0 r s out + +def cost (s r : ℕ) : ℕ := r * (2 * s + 4 * r + 21) + 4 * (s + r) + 14 + +theorem set_eq_split (xs : List Bool) (i : ℕ) (hi : i < xs.length) (b : Bool) : + xs.set i b = xs.take i ++ b :: xs.drop (i + 1) := by + calc + xs.set i b = (xs.take i ++ xs.getD i false :: xs.drop (i + 1)).set + (xs.take i).length b := by + rw [TapeNaturalAccess.take_length xs i hi, ← TapeNaturalAccess.split xs i hi] + _ = _ := by simp + +theorem clear_at (σ : TapeStore) (i : ℕ) + (hi : σ indexC = List.replicate i true) (hib : i < (σ productBits).length) : + RunsIn (TapeArray.code indexC productBits (fun _ => false)).step + (cfg TapeArray.State.start (storeTapes σ)) + (cfg (TapeArray.State.done ((σ productBits).getD i false)) + (storeTapes (Function.update σ productBits ((σ productBits).set i false)))) + (2 * i + 4) := by + have h := modify_at (by decide : indexC ≠ productBits) (fun _ => false) (storeTapes σ) + ((σ productBits).take i) ((σ productBits).drop (i + 1)) ((σ productBits).getD i false) + (by simp only [storeTapes_apply, hi, counterTape, TapeNaturalAccess.take_length _ _ hib]) + (congrArg wordTape (TapeNaturalAccess.split _ _ hib)) + simpa only [TapeNaturalAccess.take_length _ _ hib, storeTapes_update, + set_eq_split _ _ hib] using h + +theorem update_output (σ : TapeStore) (r s : ℕ) (out out' : List Bool) : + Function.update (resultStore σ r s out) productBits out' = resultStore σ r s out' := by + funext q + by_cases hq : q = productBits + · subst q + simp [resultStore] + · simp [resultStore, TapeCancelRow.frame, Function.update, hq] + +theorem runs_cancel (σ : TapeStore) (p c : List Bool) (s : ℕ) + (hP : σ polyBits = p) (hOut : σ productBits = c) + (hLoop : σ loop1 = List.replicate p.length true) (hA : σ indexA = []) + (hB : σ indexB = List.replicate (s + p.length) true) + (hC : σ indexC = List.replicate s true) (hbound : s + p.length < c.length) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (resultStore σ p.length s (cancelByUpdates p c s)))) + (cost s p.length) := by + let v := c.getD (s + p.length) false + let out := modulusUpdateLoop p v s p.length c + let ρ := resultStore σ p.length s out + have hr := TapeNaturalAccess.read indexB productBits (by decide) σ (s + p.length) hB + (by simpa only [hOut] using hbound) + have hrow := TapeCancelRow.runs_row v σ p c s 0 p.length hP (by omega) hbound.le + have hentry : TapeCancelRow.frame σ p.length 0 s c = σ := by + funext q + by_cases hl : q = loop1 + · subst q + simp [hLoop] + · by_cases ha : q = indexA + · subst q + simp [hA] + · by_cases hc : q = indexC + · subst q + simp [hC] + · by_cases ho : q = productBits + · subst q + simp [hOut] + · simp [TapeCancelRow.frame, hl, ha, hc, ho] + have hrow' : RunsIn (TapeCancelRow.program v).step + (cfg TapeCancelRow.start (storeTapes σ)) + (cfg TapeCancelRow.done (storeTapes ρ)) + (p.length * (2 * s + 4 * p.length + 21) + 3) := by + simpa only [modulusUpdateLoop_zero, Nat.zero_add, hentry, ρ, resultStore, out] using hrow + have hcarr := carry_runs TapeCancelRow.program v hrow' + have hread := join_runs (TapeArray.code indexB productBits id) + (carryCode TapeCancelRow.program) (fun q => (readFlag q, TapeCancelRow.start)) + (q' := TapeArray.State.done v) + (by simpa only [hOut] using hr) rfl hcarr + have hclear := clear_at ρ (s + p.length) (by simp [ρ, resultStore]) (by + simp only [ρ, resultStore, TapeCancelRow.frame_output, out, modulusUpdateLoop_length] + exact hbound) + have hclear' : RunsIn (TapeArray.code indexC productBits (fun _ => false)).step + (cfg TapeArray.State.start (storeTapes ρ)) + (cfg (TapeArray.State.done (out.getD (s + p.length) false)) + (storeTapes (resultStore σ p.length s (cancelByUpdates p c s)))) + (2 * (s + p.length) + 4) := by + have hρout : ρ productBits = out := by simp [ρ, resultStore] + simpa only [hρout, ρ, update_output, cancelByUpdates, out, v] using hclear + have hboth := join_runs readProgram (TapeArray.code indexC productBits (fun _ => false)) + (fun _ => TapeArray.State.start) hread rfl hclear' + have hhalt : RunsIn haltProgram.step + (cfg () (storeTapes (resultStore σ p.length s (cancelByUpdates p c s)))) + (cfg () (storeTapes (resultStore σ p.length s (cancelByUpdates p c s)))) 0 := RunsIn.refl _ _ + have hall := join_runs clearProgram haltProgram (fun _ => ()) hboth rfl hhalt + have htime : ((2 * (s + p.length) + 4 + 1 + + (p.length * (2 * s + 4 * p.length + 21) + 3)) + 1 + + (2 * (s + p.length) + 4)) + 1 + 0 = cost s p.length := by + unfold cost + omega + simpa only [State, program, start, done, htime, Nat.add_zero] using hall + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeCancel +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeCancelRow.lean b/lean/OAI/Computability/DepthThree/TapeCancelRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..e909017691cc0b30c74bb9f148ee7bed828ecd8a --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeCancelRow.lean @@ -0,0 +1,112 @@ +import OAI.Computability.DepthThree.TapeCancelStep +import OAI.Computability.DepthThree.LanguageBitReductionLoop + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeCancelRow + +open TapeMultiProgram TapeRouting TapeUnary TapeArithmetic TapeRegister + +abbrev State := LoopState DecState TapeCancelStep.State + +def program (v : Bool) : TapeMultiProgram State := + loopCode (decProgram loop1) (TapeCancelStep.program v) + DecState.start TapeCancelStep.start decPositive + +def start : State := loopTest DecState.start +def done : State := loopDone + +def frame (σ : TapeStore) (n j shift : ℕ) (out : List Bool) : TapeStore := + fun r => if r = loop1 then List.replicate n true + else if r = indexA then List.replicate j true + else if r = indexC then List.replicate (shift + j) true + else if r = productBits then out else σ r + +@[simp] theorem frame_counter (σ : TapeStore) (n j s : ℕ) (out : List Bool) : + frame σ n j s out loop1 = List.replicate n true := by simp [frame] +@[simp] theorem frame_indexA (σ : TapeStore) (n j s : ℕ) (out : List Bool) : + frame σ n j s out indexA = List.replicate j true := by simp [frame, loop1, indexA] +@[simp] theorem frame_indexC (σ : TapeStore) (n j s : ℕ) (out : List Bool) : + frame σ n j s out indexC = List.replicate (s + j) true := by + simp [frame, loop1, indexA, indexC] +@[simp] theorem frame_output (σ : TapeStore) (n j s : ℕ) (out : List Bool) : + frame σ n j s out productBits = out := by + simp [frame, loop1, indexA, indexC, productBits] + +theorem update_counter (σ : TapeStore) (n n' j s : ℕ) (out : List Bool) : + Function.update (frame σ n j s out) loop1 (List.replicate n' true) = + frame σ n' j s out := by + funext r + by_cases hr : r = loop1 + · subst r + simp + · simp [frame, Function.update, hr] + +theorem resultStore_frame (σ : TapeStore) (n j s : ℕ) (out out' : List Bool) : + TapeCancelStep.resultStore (frame σ n j s out) j (s + j) out' = + frame σ n (j + 1) s out' := by + funext r + by_cases hc : r = indexC + · subst r + simp [TapeCancelStep.resultStore, Nat.add_assoc] + · by_cases ha : r = indexA + · subst r + simp [TapeCancelStep.resultStore, indexA, indexC] + · by_cases hp : r = productBits + · subst r + simp [TapeCancelStep.resultStore, indexA, indexC, productBits] + · simp [TapeCancelStep.resultStore, Function.update, frame, hc, ha, hp] + +theorem runs_row (v : Bool) (σ : TapeStore) (p c : List Bool) (s j n : ℕ) + (hP : σ polyBits = p) (hj : j + n ≤ p.length) (hsize : s + p.length ≤ c.length) : + RunsIn (program v).step + (cfg start (storeTapes (frame σ n j s (modulusUpdateLoop p v s j c)))) + (cfg done (storeTapes (frame σ 0 (j + n) s (modulusUpdateLoop p v s (j + n) c)))) + (n * (2 * s + 4 * p.length + 21) + 3) := by + induction n generalizing j with + | zero => + have hd := decrement_empty loop1 + (storeTapes (frame σ 0 j s (modulusUpdateLoop p v s j c))) (by simp []) + have he := loop_exit (decProgram loop1) (TapeCancelStep.program v) + DecState.start TapeCancelStep.start decPositive hd rfl rfl + simpa only [program, start, done, Nat.add_zero, Nat.zero_mul, Nat.zero_add] using he + | succ n ih => + let out := modulusUpdateLoop p v s j c + let out' := modulusUpdateLoop p v s (j + 1) c + have hd := decrement_cons loop1 (storeTapes (frame σ (n + 1) j s out)) + (List.replicate n true) true (by simp [List.replicate_succ]) + have hd' : RunsIn (decProgram loop1).step + (cfg DecState.start (storeTapes (frame σ (n + 1) j s out))) + (cfg (DecState.done true) (storeTapes (frame σ n j s out))) 4 := by + simpa only [← storeTapes_update, update_counter] using hd + have hPf : frame σ n j s out polyBits = p := by + simp [frame, hP, polyBits, loop1, indexA, indexC, productBits] + have ht := TapeCancelStep.runs_step v (frame σ n j s out) j (s + j) + (by simp) (by simp) (by rw [hPf]; omega) + (by simp only [frame_output, out, modulusUpdateLoop_length]; omega) + have ht' : RunsIn (TapeCancelStep.program v).step + (cfg TapeCancelStep.start (storeTapes (frame σ n j s out))) + (cfg TapeCancelStep.done (storeTapes (frame σ n (j + 1) s out'))) + (2 * j + 2 * (s + j) + 15) := by + simpa only [frame_output, hPf, resultStore_frame, out', modulusUpdateLoop_step, out] using ht + have hit := loop_iter (decProgram loop1) (TapeCancelStep.program v) + DecState.start TapeCancelStep.start decPositive hd' rfl rfl ht' rfl + have hit' := hit.mono (show 4 + 1 + (2 * j + 2 * (s + j) + 15) + 1 ≤ + 2 * s + 4 * p.length + 21 by omega) + have hrest := ih (j + 1) (by omega) + have hall := hit'.trans hrest + have htime : (2 * s + 4 * p.length + 21) + + (n * (2 * s + 4 * p.length + 21) + 3) = + (n + 1) * (2 * s + 4 * p.length + 21) + 3 := by + rw [Nat.add_mul, Nat.one_mul] + omega + have hindex : j + 1 + n = j + (n + 1) := by omega + simpa only [program, start, done, htime, hindex, out, out'] using hall + +@[simp] theorem program_done (v : Bool) (h : TapeHeads) : program v done h = none := rfl + +end TapeCancelRow +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeCancelStep.lean b/lean/OAI/Computability/DepthThree/TapeCancelStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..a022ee314eef6b040f68a8551c7f4550fdb3a2ee --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeCancelStep.lean @@ -0,0 +1,77 @@ +import OAI.Computability.DepthThree.TapeNaturalAccess + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeCancelStep + +open TapeMultiProgram TapeRouting TapeUnary TapeProductTerm TapeRegister + +abbrev ReadState := TapeArray.State ⊕ (Bool × TapeArray.State) +abbrev FirstState := ReadState ⊕ IncState +abbrev State := FirstState ⊕ IncState + +def readProgram (v : Bool) : TapeMultiProgram ReadState := + joinCode (TapeArray.code indexA polyBits id) + (carryCode fun b : Bool => TapeArray.code indexC productBits + (fun old => Bool.xor old (v && b))) + (fun q => (readFlag q, TapeArray.State.start)) + +def firstProgram (v : Bool) : TapeMultiProgram FirstState := + joinCode (readProgram v) (incProgram indexA) (fun _ => IncState.start) + +def program (v : Bool) : TapeMultiProgram State := + joinCode (firstProgram v) (incProgram indexC) (fun _ => IncState.start) + +def start : State := .inl (.inl (.inl TapeArray.State.start)) +def done : State := .inr IncState.done + +def resultStore (σ : TapeStore) (j k : ℕ) (out : List Bool) : TapeStore := + Function.update (Function.update (Function.update σ productBits out) + indexA (List.replicate (j + 1) true)) indexC (List.replicate (k + 1) true) + +theorem runs_step (v : Bool) (σ : TapeStore) (j k : ℕ) + (hA : σ indexA = List.replicate j true) + (hC : σ indexC = List.replicate k true) + (hj : j < (σ polyBits).length) (hk : k < (σ productBits).length) : + RunsIn (program v).step (cfg start (storeTapes σ)) + (cfg done (storeTapes (resultStore σ j k + (xorListAt (σ productBits) k (v && (σ polyBits).getD j false))))) + (2 * j + 2 * k + 15) := by + let b := (σ polyBits).getD j false + let out := xorListAt (σ productBits) k (v && b) + let σ₁ := Function.update σ productBits out + let σ₂ := Function.update σ₁ indexA (List.replicate (j + 1) true) + have hr := TapeNaturalAccess.read indexA polyBits (by decide) σ j hA hj + have hx := TapeNaturalAccess.xorAt indexC productBits (by decide) σ k (v && b) hC hk + have hxc := carry_runs + (fun b : Bool => TapeArray.code indexC productBits (fun old => Bool.xor old (v && b))) b hx + have hread := join_runs (TapeArray.code indexA polyBits id) + (carryCode fun b : Bool => TapeArray.code indexC productBits + (fun old => Bool.xor old (v && b))) + (fun q => (readFlag q, TapeArray.State.start)) hr rfl hxc + have ha := increment indexA (storeTapes σ₁) j (by + simp [σ₁, counterTape, hA, indexA, productBits]) + have ha' : RunsIn (incProgram indexA).step + (cfg IncState.start (storeTapes σ₁)) (cfg IncState.done (storeTapes σ₂)) 2 := by + simpa only [σ₂, storeTapes_update, counterTape] using ha + have hfirst := join_runs (readProgram v) (incProgram indexA) + (fun _ => IncState.start) hread rfl ha' + have hc := increment indexC (storeTapes σ₂) k (by + simp [σ₂, σ₁, counterTape, hC, indexC, indexA, productBits]) + have hc' : RunsIn (incProgram indexC).step + (cfg IncState.start (storeTapes σ₂)) + (cfg IncState.done (storeTapes (resultStore σ j k out))) 2 := by + simpa only [resultStore, σ₂, σ₁, storeTapes_update, counterTape] using hc + have hall := join_runs (firstProgram v) (incProgram indexC) + (fun _ => IncState.start) hfirst rfl hc' + have ht : (2 * j + 4 + 1 + (2 * k + 4)) + 1 + 2 + 1 + 2 = + 2 * j + 2 * k + 15 := by omega + simpa only [program, start, done, out, b, ht] using hall + +@[simp] theorem program_done (v : Bool) (h : TapeHeads) : program v done h = none := rfl + +end TapeCancelStep +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeConvolutionPrepare.lean b/lean/OAI/Computability/DepthThree/TapeConvolutionPrepare.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f5e961ff594362a4ce9dc167e95c4200e39c2da --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeConvolutionPrepare.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DepthThree.TapeConvolutionRows + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeConvolutionPrepare + +open TapeMultiProgram TapeRouting TapeUnary TapeArithmetic TapeRegister + +abbrev CopyState := TapeCopy.State ⊕ TapeCopy.State +abbrev AddState := CopyState ⊕ TapeArithmetic.AddState +abbrev FillState := AddState ⊕ TapeFill.FillState +abbrev State := FillState ⊕ TapeCopy.State + +def copies : TapeMultiProgram CopyState := + joinCode (TapeCopy.code ringDegree loop0) (TapeCopy.code ringDegree loop1) + (fun _ => TapeCopy.State.start) + +def addition : TapeMultiProgram AddState := + joinCode copies (addProgram loop1 loop0) (fun _ => addStart) + +def filling : TapeMultiProgram FillState := + joinCode addition (TapeFill.fillProgram loop0 productBits false) (fun _ => TapeFill.fillStart) + +def program : TapeMultiProgram State := + joinCode filling (TapeCopy.code ringDegree loop0) (fun _ => TapeCopy.State.start) + +def start : State := .inl (.inl (.inl (.inl TapeCopy.State.start))) +def done : State := .inr TapeCopy.State.done + +theorem runs_prepare (σ : TapeStore) (r : ℕ) + (hr : σ ringDegree = List.replicate r true) + (hL0 : σ loop0 = []) (hL1 : σ loop1 = []) + (hI : σ indexA = []) (hOut : σ productBits = []) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (TapeConvolutionRows.frame σ r 0 (List.replicate (r + r) false)))) + (30 * r + 22) := by + let σ₁ := Function.update σ loop0 (σ ringDegree) + let σ₂ := Function.update σ₁ loop1 (σ₁ ringDegree) + let σ₃ := Function.update (Function.update σ₂ loop1 []) loop0 (List.replicate (r + r) true) + let σ₄ := Function.update (Function.update σ₃ loop0 []) productBits (List.replicate (r + r) false) + let σ₅ := Function.update σ₄ loop0 (σ₄ ringDegree) + have hcopy0 := TapeStoreRuns.copy (by decide : ringDegree ≠ loop0) σ hL0 + have hcopy1 := TapeStoreRuns.copy (by decide : ringDegree ≠ loop1) σ₁ (by + simp [σ₁, hL1, loop0, loop1]) + have hc := join_runs (TapeCopy.code ringDegree loop0) (TapeCopy.code ringDegree loop1) + (fun _ => TapeCopy.State.start) hcopy0 rfl hcopy1 + have hadd := TapeStoreRuns.add (by decide : loop1 ≠ loop0) σ₂ r r + (by simp [σ₂, σ₁, hr, ringDegree, loop0]) + (by simp [σ₂, σ₁, hr, loop0, loop1]) + have ha := join_runs copies (addProgram loop1 loop0) (fun _ => addStart) hc rfl hadd + have hfill := TapeStoreRuns.fill (by decide : loop0 ≠ productBits) false σ₃ (r + r) (by + simp [σ₃]) + have hfill' : RunsIn (TapeFill.fillProgram loop0 productBits false).step + (cfg TapeFill.fillStart (storeTapes σ₃)) (cfg TapeFill.fillDone (storeTapes σ₄)) + (8 * (r + r) + 3) := by + simpa only [σ₄, show σ₃ productBits = [] by + simp [σ₃, σ₂, σ₁, hOut, loop0, loop1, productBits], List.append_nil] using hfill + have hf := join_runs addition (TapeFill.fillProgram loop0 productBits false) + (fun _ => TapeFill.fillStart) ha rfl hfill' + have hlast := TapeStoreRuns.copy (by decide : ringDegree ≠ loop0) σ₄ (by + simp [σ₄, loop0, productBits]) + have hall := join_runs filling (TapeCopy.code ringDegree loop0) + (fun _ => TapeCopy.State.start) hf rfl hlast + have hstore : σ₅ = TapeConvolutionRows.frame σ r 0 (List.replicate (r + r) false) := by + funext k + by_cases h0 : k = loop0 + · subst k + simp [σ₅, σ₄, σ₃, σ₂, σ₁, hr, ringDegree, loop0, loop1, productBits] + · by_cases hp : k = productBits + · subst k + simp [σ₅, σ₄, TapeConvolutionRows.frame, loop0, indexA, productBits] + · by_cases h1 : k = loop1 + · subst k + simp [σ₅, σ₄, σ₃, TapeConvolutionRows.frame, hL1, loop0, loop1, indexA, productBits] + · by_cases hi : k = indexA + · subst k + simp [σ₅, σ₄, σ₃, σ₂, σ₁, TapeConvolutionRows.frame, hI, + loop0, loop1, indexA, productBits] + · simp [σ₅, σ₄, σ₃, σ₂, σ₁, TapeConvolutionRows.frame, h0, hp, h1, hi] + have hl0 : (σ ringDegree).length = r := by simp [hr] + have hl1 : (σ₁ ringDegree).length = r := by simp [σ₁, hr, ringDegree, loop0] + have hlf : (σ₄ ringDegree).length = r := by + simp [σ₄, σ₃, σ₂, σ₁, hr, ringDegree, loop0, loop1, productBits] + have htime : ((2 * r + 4 + 1 + (2 * r + 4)) + 1 + (8 * r + 3)) + + 1 + (8 * (r + r) + 3) + 1 + (2 * r + 4) = 30 * r + 22 := by omega + dsimp only [σ₅] at hstore + simpa only [program, start, done, hstore, hl0, hl1, hlf, htime] using hall + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeConvolutionPrepare +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeConvolutionRow.lean b/lean/OAI/Computability/DepthThree/TapeConvolutionRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc0cf14628a526ab3bf0f124396a63b696c201f3 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeConvolutionRow.lean @@ -0,0 +1,144 @@ +import OAI.Computability.DepthThree.TapeConvolutionStep +import OAI.Computability.DepthThree.TapeNaturalAccess + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeConvolutionRow + +open TapeMultiProgram TapeRouting TapeUnary TapeArithmetic TapeRegister + +abbrev State := LoopState DecState TapeConvolutionStep.State + +def program : TapeMultiProgram State := + loopCode (decProgram loop1) TapeConvolutionStep.program + DecState.start TapeConvolutionStep.start decPositive + +def start : State := loopTest DecState.start +def done : State := loopDone + +def frame (σ : TapeStore) (remaining column : ℕ) (out : List Bool) : TapeStore := + fun r => if r = loop1 then List.replicate remaining true + else if r = indexB then List.replicate column true + else if r = productBits then out else σ r + +@[simp] theorem frame_counter (σ : TapeStore) (n j : ℕ) (out : List Bool) : + frame σ n j out loop1 = List.replicate n true := by simp [frame] + +@[simp] theorem frame_index (σ : TapeStore) (n j : ℕ) (out : List Bool) : + frame σ n j out indexB = List.replicate j true := by simp [frame, loop1, indexB] + +@[simp] theorem frame_output (σ : TapeStore) (n j : ℕ) (out : List Bool) : + frame σ n j out productBits = out := by simp [frame, loop1, indexB, productBits] + +theorem update_counter (σ : TapeStore) (n n' j : ℕ) (out : List Bool) : + Function.update (frame σ n j out) loop1 (List.replicate n' true) = frame σ n' j out := by + funext r + by_cases hr : r = loop1 + · subst r + simp + · simp [frame, Function.update, hr] + +theorem resultStore_frame (σ : TapeStore) (n j : ℕ) (out out' : List Bool) : + TapeConvolutionStep.resultStore (frame σ n j out) j out' = frame σ n (j + 1) out' := by + funext r + by_cases hr : r = indexB + · subst r + simp [TapeConvolutionStep.resultStore] + · by_cases hp : r = productBits + · subst r + simp [TapeConvolutionStep.resultStore, indexB, productBits] + · simp [TapeConvolutionStep.resultStore, Function.update, frame, hr, hp] + +theorem runs_step (σ : TapeStore) (i j : ℕ) + (hi : σ indexA = List.replicate i true) (hj : σ indexB = List.replicate j true) + (hk : σ indexC = []) (hs : σ scratchA = []) + (ha : i < (σ hashBits).length) (hb : j < (σ accumBits).length) + (hc : i + j < (σ productBits).length) : + RunsIn TapeConvolutionStep.program.step + (cfg TapeConvolutionStep.start (storeTapes σ)) + (cfg TapeConvolutionStep.done (storeTapes + (TapeConvolutionStep.resultStore σ j + (xorListAt (σ productBits) (i + j) + ((σ hashBits).getD i false && (σ accumBits).getD j false))))) + (8 * i + 16 * j + 37) := by + have h := TapeConvolutionStep.runs_step σ + ((σ hashBits).take i) ((σ hashBits).drop (i + 1)) + ((σ accumBits).take j) ((σ accumBits).drop (j + 1)) + ((σ productBits).take (i + j)) ((σ productBits).drop (i + j + 1)) + ((σ hashBits).getD i false) ((σ accumBits).getD j false) + ((σ productBits).getD (i + j) false) + (by simpa only [TapeNaturalAccess.take_length _ _ ha] using hi) + (by simpa only [TapeNaturalAccess.take_length _ _ hb] using hj) hk hs + (TapeNaturalAccess.split _ _ ha) (TapeNaturalAccess.split _ _ hb) + (TapeNaturalAccess.split _ _ hc) + (by simp only [TapeNaturalAccess.take_length _ _ ha, + TapeNaturalAccess.take_length _ _ hb, TapeNaturalAccess.take_length _ _ hc]) + simpa only [TapeNaturalAccess.take_length _ _ ha, TapeNaturalAccess.take_length _ _ hb, + TapeNaturalAccess.xorListAt_eq_split _ _ hc] using h + +theorem runs_row (σ : TapeStore) (a b : List Bool) (i j n : ℕ) (out : List Bool) + (hA : σ hashBits = a) (hB : σ accumBits = b) + (hI : σ indexA = List.replicate i true) + (hK : σ indexC = []) (hS : σ scratchA = []) + (hi : i < a.length) (hj : j + n ≤ b.length) + (hsize : a.length + b.length ≤ out.length) : + RunsIn program.step (cfg start (storeTapes (frame σ n j out))) + (cfg done (storeTapes (frame σ 0 (j + n) + (convolutionUpdateRow a b i (List.range' j n) out)))) + (n * (8 * a.length + 16 * b.length + 43) + 3) := by + induction n generalizing j out with + | zero => + have hd := decrement_empty loop1 (storeTapes (frame σ 0 j out)) (by + simp []) + have he := loop_exit (decProgram loop1) TapeConvolutionStep.program + DecState.start TapeConvolutionStep.start decPositive hd rfl rfl + simpa only [program, start, done, List.range'_zero, convolutionUpdateRow_nil, + Nat.add_zero, Nat.zero_mul, Nat.zero_add] using he + | succ n ih => + have hj' : j < b.length := by omega + have hij : i + j < out.length := by omega + let out' := xorListAt out (i + j) (a.getD i false && b.getD j false) + have hd := decrement_cons loop1 (storeTapes (frame σ (n + 1) j out)) + (List.replicate n true) true (by simp [List.replicate_succ]) + have hd' : RunsIn (decProgram loop1).step + (cfg DecState.start (storeTapes (frame σ (n + 1) j out))) + (cfg (DecState.done true) (storeTapes (frame σ n j out))) 4 := by + simpa only [← storeTapes_update, update_counter] using hd + have hAf : frame σ n j out hashBits = a := by + simp [frame, hA, hashBits, loop1, indexB, productBits] + have hBf : frame σ n j out accumBits = b := by + simp [frame, hB, accumBits, loop1, indexB, productBits] + have ht := runs_step (frame σ n j out) i j + (by simp [frame, hI, indexA, loop1, indexB, productBits]) + (by simp) (by simp [frame, hK, indexC, loop1, indexB, productBits]) + (by simp [frame, hS, scratchA, loop1, indexB, productBits]) + (by simpa [frame, hA, hashBits, loop1, indexB, productBits] using hi) + (by simpa [frame, hB, accumBits, loop1, indexB, productBits] using hj') + (by simpa using hij) + have ht' : RunsIn TapeConvolutionStep.program.step + (cfg TapeConvolutionStep.start (storeTapes (frame σ n j out))) + (cfg TapeConvolutionStep.done (storeTapes (frame σ n (j + 1) out'))) + (8 * i + 16 * j + 37) := by + simpa only [frame_output, hAf, hBf, resultStore_frame, out'] using ht + have hit := loop_iter (decProgram loop1) TapeConvolutionStep.program + DecState.start TapeConvolutionStep.start decPositive hd' rfl rfl ht' rfl + have hit' := hit.mono (show 4 + 1 + (8 * i + 16 * j + 37) + 1 ≤ + 8 * a.length + 16 * b.length + 43 by omega) + have hrest := ih (j + 1) out' (by omega) (by simpa [out'] using hsize) + have hall := hit'.trans hrest + have htime : (8 * a.length + 16 * b.length + 43) + + (n * (8 * a.length + 16 * b.length + 43) + 3) = + (n + 1) * (8 * a.length + 16 * b.length + 43) + 3 := by + rw [Nat.add_mul, Nat.one_mul] + omega + have hindex : j + 1 + n = j + (n + 1) := by omega + simpa only [program, start, done, List.range'_succ, convolutionUpdateRow_step, + htime, hindex, out'] using hall + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeConvolutionRow +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeConvolutionRows.lean b/lean/OAI/Computability/DepthThree/TapeConvolutionRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d85c750d82a05d9a2a33afd3419c5c92cb46b60 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeConvolutionRows.lean @@ -0,0 +1,197 @@ +import OAI.Computability.DepthThree.TapeConvolutionRow + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeConvolutionRows + +open TapeMultiProgram TapeRouting TapeUnary TapeArithmetic TapeRegister + +abbrev ReadState := TapeCopy.State ⊕ TapeConvolutionRow.State +abbrev ClearState := ReadState ⊕ TapeErase.State +abbrev BodyState := ClearState ⊕ IncState + +def readProgram : TapeMultiProgram ReadState := + joinCode (TapeCopy.code ringDegree loop1) TapeConvolutionRow.program + (fun _ => TapeConvolutionRow.start) + +def clearProgram : TapeMultiProgram ClearState := + joinCode readProgram (TapeErase.code indexB) (fun _ => TapeErase.State.start) + +def bodyProgram : TapeMultiProgram BodyState := + joinCode clearProgram (incProgram indexA) (fun _ => IncState.start) + +def bodyStart : BodyState := .inl (.inl (.inl TapeCopy.State.start)) +def bodyDone : BodyState := .inr IncState.done + +def bodyResult (σ : TapeStore) (i : ℕ) (out : List Bool) : TapeStore := + Function.update (Function.update σ productBits out) indexA (List.replicate (i + 1) true) + +theorem runs_body (σ : TapeStore) (a b out : List Bool) (i : ℕ) + (hA : σ hashBits = a) (hB : σ accumBits = b) + (hI : σ indexA = List.replicate i true) (hJ : σ indexB = []) + (hCount : σ ringDegree = List.replicate b.length true) (hLoop : σ loop1 = []) + (hK : σ indexC = []) (hS : σ scratchA = []) (hOut : σ productBits = out) + (hi : i < a.length) (hsize : a.length + b.length ≤ out.length) : + RunsIn bodyProgram.step (cfg bodyStart (storeTapes σ)) + (cfg bodyDone (storeTapes (bodyResult σ i + (convolutionUpdateRow a b i (List.range' 0 b.length) out)))) + (b.length * (8 * a.length + 16 * b.length + 43) + 4 * b.length + 17) := by + let out' := convolutionUpdateRow a b i (List.range' 0 b.length) out + let ρ := TapeConvolutionRow.frame σ 0 b.length out' + have hcopy := TapeStoreRuns.copy (by decide : ringDegree ≠ loop1) σ hLoop + have hrow := TapeConvolutionRow.runs_row σ a b i 0 b.length out + hA hB hI hK hS hi (by omega) hsize + have hentry : TapeConvolutionRow.frame σ b.length 0 out = + Function.update σ loop1 (σ ringDegree) := by + funext r + by_cases hl : r = loop1 + · subst r + simp [hCount] + · by_cases hj : r = indexB + · subst r + simp [TapeConvolutionRow.frame, hJ, loop1, indexB] + · by_cases hp : r = productBits + · subst r + simp [TapeConvolutionRow.frame, hOut, productBits, loop1, indexB] + · simp [TapeConvolutionRow.frame, Function.update, hl, hj, hp] + have hrow' : RunsIn TapeConvolutionRow.program.step + (cfg TapeConvolutionRow.start (storeTapes (Function.update σ loop1 (σ ringDegree)))) + (cfg TapeConvolutionRow.done (storeTapes ρ)) + (b.length * (8 * a.length + 16 * b.length + 43) + 3) := by + simpa only [hentry, Nat.zero_add, ρ, out'] using hrow + have hread := join_runs (TapeCopy.code ringDegree loop1) TapeConvolutionRow.program + (fun _ => TapeConvolutionRow.start) hcopy rfl hrow' + have herase := TapeStoreRuns.erase indexB ρ + have hclean : Function.update ρ indexB [] = Function.update σ productBits out' := by + funext r + by_cases hj : r = indexB + · subst r + simp [Function.update, hJ, indexB, productBits] + · by_cases hl : r = loop1 + · subst r + simp [ρ, Function.update, hLoop, loop1, indexB, productBits] + · by_cases hp : r = productBits + · subst r + simp [ρ, Function.update, productBits, indexB] + · simp [ρ, TapeConvolutionRow.frame, Function.update, hj, hl, hp] + have hclear := join_runs readProgram (TapeErase.code indexB) + (fun _ => TapeErase.State.start) hread rfl herase + have hinc := increment indexA (storeTapes (Function.update σ productBits out')) i (by + simp [hI, counterTape, indexA, productBits]) + have hinc' : RunsIn (incProgram indexA).step + (cfg IncState.start (storeTapes (Function.update ρ indexB []))) + (cfg IncState.done (storeTapes (bodyResult σ i out'))) 2 := by + simpa only [hclean, bodyResult, storeTapes_update, counterTape] using hinc + have hall := join_runs clearProgram (incProgram indexA) (fun _ => IncState.start) + hclear rfl hinc' + have hlenCopy : (σ ringDegree).length = b.length := by simp [hCount] + have hlenErase : (ρ indexB).length = b.length := by simp [ρ] + have htime : (2 * b.length + 4 + 1 + + (b.length * (8 * a.length + 16 * b.length + 43) + 3)) + 1 + + (2 * b.length + 5) + 1 + 2 = + b.length * (8 * a.length + 16 * b.length + 43) + 4 * b.length + 17 := by omega + simpa only [bodyProgram, bodyStart, bodyDone, hlenCopy, hlenErase, htime, out'] using hall + +@[simp] theorem body_done (h : TapeHeads) : bodyProgram bodyDone h = none := rfl + +abbrev State := LoopState DecState BodyState + +def program : TapeMultiProgram State := + loopCode (decProgram loop0) bodyProgram DecState.start bodyStart decPositive + +def start : State := loopTest DecState.start +def done : State := loopDone + +def frame (σ : TapeStore) (remaining row : ℕ) (out : List Bool) : TapeStore := + fun r => if r = loop0 then List.replicate remaining true + else if r = indexA then List.replicate row true + else if r = productBits then out else σ r + +@[simp] theorem frame_counter (σ : TapeStore) (n i : ℕ) (out : List Bool) : + frame σ n i out loop0 = List.replicate n true := by simp [frame] + +@[simp] theorem frame_index (σ : TapeStore) (n i : ℕ) (out : List Bool) : + frame σ n i out indexA = List.replicate i true := by simp [frame, loop0, indexA] + +@[simp] theorem frame_output (σ : TapeStore) (n i : ℕ) (out : List Bool) : + frame σ n i out productBits = out := by simp [frame, loop0, indexA, productBits] + +theorem update_counter (σ : TapeStore) (n n' i : ℕ) (out : List Bool) : + Function.update (frame σ n i out) loop0 (List.replicate n' true) = frame σ n' i out := by + funext r + by_cases hr : r = loop0 + · subst r + simp + · simp [frame, Function.update, hr] + +theorem bodyResult_frame (σ : TapeStore) (n i : ℕ) (out out' : List Bool) : + bodyResult (frame σ n i out) i out' = frame σ n (i + 1) out' := by + funext r + by_cases hr : r = indexA + · subst r + simp [bodyResult] + · by_cases hp : r = productBits + · subst r + simp [bodyResult, indexA, productBits] + · simp [bodyResult, Function.update, frame, hr, hp] + +theorem runs_rows (σ : TapeStore) (a b : List Bool) (i n : ℕ) (out : List Bool) + (hA : σ hashBits = a) (hB : σ accumBits = b) + (hJ : σ indexB = []) (hCount : σ ringDegree = List.replicate b.length true) + (hLoop : σ loop1 = []) (hK : σ indexC = []) (hS : σ scratchA = []) + (hi : i + n ≤ a.length) (hsize : a.length + b.length ≤ out.length) : + RunsIn program.step (cfg start (storeTapes (frame σ n i out))) + (cfg done (storeTapes (frame σ 0 (i + n) + (convolutionUpdateRows a b (List.range' i n) out)))) + (n * (b.length * (8 * a.length + 16 * b.length + 43) + 4 * b.length + 23) + 3) := by + induction n generalizing i out with + | zero => + have hd := decrement_empty loop0 (storeTapes (frame σ 0 i out)) (by simp []) + have he := loop_exit (decProgram loop0) bodyProgram DecState.start bodyStart + decPositive hd rfl rfl + simpa only [program, start, done, List.range'_zero, convolutionUpdateRows_nil, + Nat.add_zero, Nat.zero_mul, Nat.zero_add] using he + | succ n ih => + have hi' : i < a.length := by omega + let out' := convolutionUpdateRow a b i (List.range' 0 b.length) out + have hd := decrement_cons loop0 (storeTapes (frame σ (n + 1) i out)) + (List.replicate n true) true (by simp [List.replicate_succ]) + have hd' : RunsIn (decProgram loop0).step + (cfg DecState.start (storeTapes (frame σ (n + 1) i out))) + (cfg (DecState.done true) (storeTapes (frame σ n i out))) 4 := by + simpa only [← storeTapes_update, update_counter] using hd + have hb := runs_body (frame σ n i out) a b out i + (by simp [frame, hA, hashBits, loop0, indexA, productBits]) + (by simp [frame, hB, accumBits, loop0, indexA, productBits]) + (by simp) (by simp [frame, hJ, indexB, loop0, indexA, productBits]) + (by simp [frame, hCount, ringDegree, loop0, indexA, productBits]) + (by simp [frame, hLoop, loop1, loop0, indexA, productBits]) + (by simp [frame, hK, indexC, loop0, indexA, productBits]) + (by simp [frame, hS, scratchA, loop0, indexA, productBits]) + (by simp) hi' hsize + have hb' : RunsIn bodyProgram.step + (cfg bodyStart (storeTapes (frame σ n i out))) + (cfg bodyDone (storeTapes (frame σ n (i + 1) out'))) + (b.length * (8 * a.length + 16 * b.length + 43) + 4 * b.length + 17) := by + simpa only [bodyResult_frame, out'] using hb + have hit := loop_iter (decProgram loop0) bodyProgram DecState.start bodyStart + decPositive hd' rfl rfl hb' rfl + have hrest := ih (i + 1) out' (by omega) (by simpa [out'] using hsize) + have hall := hit.trans hrest + have htime : 4 + 1 + + (b.length * (8 * a.length + 16 * b.length + 43) + 4 * b.length + 17) + 1 + + (n * (b.length * (8 * a.length + 16 * b.length + 43) + 4 * b.length + 23) + 3) = + (n + 1) * (b.length * (8 * a.length + 16 * b.length + 43) + 4 * b.length + 23) + 3 := by + rw [Nat.add_mul, Nat.one_mul] + omega + have hindex : i + 1 + n = i + (n + 1) := by omega + simpa only [program, start, done, List.range'_succ, convolutionUpdateRows_step, + ← List.range_eq_range', htime, hindex, out'] using hall + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeConvolutionRows +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeConvolutionStep.lean b/lean/OAI/Computability/DepthThree/TapeConvolutionStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4ab10ca8260baf57647aabbb00c1205b852a7f9 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeConvolutionStep.lean @@ -0,0 +1,125 @@ +import OAI.Computability.DepthThree.TapeStoreRepresentation + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeConvolutionStep + +open TapeMultiProgram TapeRouting TapeUnary TapeArithmetic TapeRegister + +abbrev SetupState := TapeCopy.State ⊕ TapeCopy.State +abbrev SumState := SetupState ⊕ AddState +abbrev TermState := SumState ⊕ TapeProductTerm.State +abbrev ClearState := TermState ⊕ TapeErase.State +abbrev State := ClearState ⊕ IncState + +def copyIndices : TapeMultiProgram SetupState := + joinCode (TapeCopy.code indexA indexC) (TapeCopy.code indexB scratchA) + (fun _ => TapeCopy.State.start) + +def sumIndices : TapeMultiProgram SumState := + joinCode copyIndices (addProgram scratchA indexC) (fun _ => addStart) + +def term : TapeMultiProgram TermState := + joinCode sumIndices + (TapeProductTerm.program indexA hashBits indexB accumBits indexC productBits) + (fun _ => TapeProductTerm.start) + +def clear : TapeMultiProgram ClearState := + joinCode term (TapeErase.code indexC) (fun _ => TapeErase.State.start) + +def program : TapeMultiProgram State := + joinCode clear (incProgram indexB) (fun _ => IncState.start) + +def start : State := .inl (.inl (.inl (.inl (.inl TapeCopy.State.start)))) +def done : State := .inr IncState.done + +def resultStore (σ : TapeStore) (j : ℕ) (out : List Bool) : TapeStore := + Function.update (Function.update σ productBits out) indexB (List.replicate (j + 1) true) + +theorem runs_step (σ : TapeStore) (pa sa pb sb pc sc : List Bool) (a b old : Bool) + (hi : σ indexA = List.replicate pa.length true) + (hj : σ indexB = List.replicate pb.length true) + (hk : σ indexC = []) (hs : σ scratchA = []) + (ha : σ hashBits = pa ++ a :: sa) (hb : σ accumBits = pb ++ b :: sb) + (hc : σ productBits = pc ++ old :: sc) (hlen : pc.length = pa.length + pb.length) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (resultStore σ pb.length + (pc ++ Bool.xor old (a && b) :: sc)))) + (8 * pa.length + 16 * pb.length + 37) := by + let σ₁ := Function.update σ indexC (σ indexA) + let σ₂ := Function.update σ₁ scratchA (σ₁ indexB) + let σ₃ := Function.update (Function.update σ₂ scratchA []) indexC + (List.replicate (pa.length + pb.length) true) + let σ₄ := Function.update σ₃ productBits (pc ++ Bool.xor old (a && b) :: sc) + let σ₅ := Function.update σ₄ indexC [] + let σ₆ := Function.update σ₅ indexB (List.replicate (pb.length + 1) true) + have hcopyA := TapeStoreRuns.copy (by decide : indexA ≠ indexC) σ hk + have hcopyB := TapeStoreRuns.copy (by decide : indexB ≠ scratchA) σ₁ (by + simp [σ₁, hs, indexC, scratchA]) + have hsetup := join_runs (TapeCopy.code indexA indexC) (TapeCopy.code indexB scratchA) + (fun _ => TapeCopy.State.start) hcopyA rfl hcopyB + have hadd := TapeStoreRuns.add (by decide : scratchA ≠ indexC) σ₂ pb.length pa.length + (by simp [σ₂, σ₁, hj, indexB, indexC]) + (by simp [σ₂, σ₁, hi, scratchA, indexC]) + have hsum := join_runs copyIndices (addProgram scratchA indexC) + (fun _ => addStart) hsetup rfl hadd + have hprod := TapeProductTerm.runs_product_term + indexA hashBits indexB accumBits indexC productBits + (by decide) (by decide) (by decide) (storeTapes σ₃) + pa sa pb sb pc sc a b old + (by simp [σ₃, σ₂, σ₁, hi, counterTape, indexA, indexB, indexC, scratchA]) + (by simp [σ₃, σ₂, σ₁, ha, hashBits, indexC, scratchA]) + (by simp [σ₃, σ₂, σ₁, hj, counterTape, indexA, indexB, indexC, scratchA]) + (by simp [σ₃, σ₂, σ₁, hb, accumBits, indexC, scratchA]) + (by simp [σ₃, counterTape, hlen]) + (by simp [σ₃, σ₂, σ₁, hc, productBits, indexC, scratchA]) + have hprod' : RunsIn + (TapeProductTerm.program indexA hashBits indexB accumBits indexC productBits).step + (cfg TapeProductTerm.start (storeTapes σ₃)) + (cfg (TapeProductTerm.done a b old) (storeTapes σ₄)) + (2 * (pa.length + pb.length + pc.length) + 14) := by + simpa only [σ₄, storeTapes_update] using hprod + have hterm := join_runs sumIndices + (TapeProductTerm.program indexA hashBits indexB accumBits indexC productBits) + (fun _ => TapeProductTerm.start) hsum rfl hprod' + have herase := TapeStoreRuns.erase indexC σ₄ + have hclear := join_runs term (TapeErase.code indexC) + (fun _ => TapeErase.State.start) hterm rfl herase + have hinc := increment indexB (storeTapes σ₅) pb.length (by + simp [σ₅, σ₄, σ₃, σ₂, σ₁, counterTape, hj, indexB, indexC, scratchA, productBits]) + have hinc' : RunsIn (incProgram indexB).step (cfg IncState.start (storeTapes σ₅)) + (cfg IncState.done (storeTapes σ₆)) 2 := by + simpa only [σ₆, storeTapes_update, counterTape] using hinc + have hall := join_runs clear (incProgram indexB) (fun _ => IncState.start) hclear rfl hinc' + have hstore : σ₆ = resultStore σ pb.length (pc ++ Bool.xor old (a && b) :: sc) := by + funext r + by_cases hp : r = productBits + · subst r + simp [σ₆, σ₅, σ₄, resultStore, indexB, indexC, productBits] + · by_cases hj' : r = indexB + · subst r + simp [σ₆, resultStore] + · by_cases hk' : r = indexC + · subst r + simp [σ₆, σ₅, resultStore, hk, indexB, indexC, productBits] + · by_cases hs' : r = scratchA + · subst r + simp [σ₆, σ₅, σ₄, σ₃, resultStore, hs, indexB, indexC, scratchA, productBits] + · simp [σ₆, σ₅, σ₄, σ₃, σ₂, σ₁, resultStore, hp, hj', hk', hs'] + have hlenA : (σ indexA).length = pa.length := by simp [hi] + have hlenB : (σ₁ indexB).length = pb.length := by simp [σ₁, hj, indexB, indexC] + have hlenK : (σ₄ indexC).length = pa.length + pb.length := by + simp [σ₄, σ₃, productBits, indexC] + have htime : (((2 * pa.length + 4 + 1 + (2 * pb.length + 4)) + 1 + + (8 * pb.length + 3)) + 1 + (2 * (pa.length + pb.length + pc.length) + 14)) + + 1 + (2 * (pa.length + pb.length) + 5) + 1 + 2 = + 8 * pa.length + 16 * pb.length + 37 := by omega + simpa only [program, start, done, hstore, hlenA, hlenB, hlenK, htime] using hall + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeConvolutionStep +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeConvolve.lean b/lean/OAI/Computability/DepthThree/TapeConvolve.lean new file mode 100644 index 0000000000000000000000000000000000000000..87808b34b728a3e3c9660f72d82a75d47003052f --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeConvolve.lean @@ -0,0 +1,80 @@ +import OAI.Computability.DepthThree.TapeConvolutionPrepare + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeConvolve + +open TapeMultiProgram TapeRouting TapeUnary TapeArithmetic TapeRegister + +abbrev WorkState := TapeConvolutionPrepare.State ⊕ TapeConvolutionRows.State +abbrev State := WorkState ⊕ TapeErase.State + +def work : TapeMultiProgram WorkState := + joinCode TapeConvolutionPrepare.program TapeConvolutionRows.program + (fun _ => TapeConvolutionRows.start) + +def program : TapeMultiProgram State := + joinCode work (TapeErase.code indexA) (fun _ => TapeErase.State.start) + +def start : State := .inl (.inl TapeConvolutionPrepare.start) +def done : State := .inr TapeErase.State.done + +def cost (r : ℕ) : ℕ := r * (r * (24 * r + 43) + 4 * r + 23) + 32 * r + 32 + +theorem runs_convolve (σ : TapeStore) (a b : List Bool) (r : ℕ) + (hA : σ hashBits = a) (hB : σ accumBits = b) + (hlenA : a.length = r) (hlenB : b.length = r) + (hCount : σ ringDegree = List.replicate r true) + (hL0 : σ loop0 = []) (hL1 : σ loop1 = []) + (hI : σ indexA = []) (hJ : σ indexB = []) + (hK : σ indexC = []) (hS : σ scratchA = []) (hOut : σ productBits = []) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update σ productBits (convolveBitLists a b)))) + (cost r) := by + have hp := TapeConvolutionPrepare.runs_prepare σ r hCount hL0 hL1 hI hOut + have hr := TapeConvolutionRows.runs_rows σ a b 0 r (List.replicate (r + r) false) + hA hB hJ (by simpa only [hlenB] using hCount) hL1 hK hS (by omega) (by simp [hlenA, hlenB]) + have hout : convolutionUpdateRows a b (List.range' 0 r) (List.replicate (r + r) false) = + convolveBitLists a b := by + rw [← convolveByUpdates_eq] + simp only [convolveByUpdates, hlenA, hlenB, List.range_eq_range'] + have hr' : RunsIn TapeConvolutionRows.program.step + (cfg TapeConvolutionRows.start + (storeTapes (TapeConvolutionRows.frame σ r 0 (List.replicate (r + r) false)))) + (cfg TapeConvolutionRows.done + (storeTapes (TapeConvolutionRows.frame σ 0 r (convolveBitLists a b)))) + (r * (r * (8 * r + 16 * r + 43) + 4 * r + 23) + 3) := by + simpa only [Nat.zero_add, hout, hlenA, hlenB] using hr + have hw := join_runs TapeConvolutionPrepare.program TapeConvolutionRows.program + (fun _ => TapeConvolutionRows.start) hp rfl hr' + let ρ := TapeConvolutionRows.frame σ 0 r (convolveBitLists a b) + have he := TapeStoreRuns.erase indexA ρ + have hall := join_runs work (TapeErase.code indexA) (fun _ => TapeErase.State.start) hw rfl he + have hframe : Function.update ρ indexA [] = Function.update σ productBits (convolveBitLists a b) := by + funext k + by_cases hi : k = indexA + · subst k + simp [hI, indexA, productBits] + · by_cases hl : k = loop0 + · subst k + simp [ρ, Function.update, hL0, indexA, loop0, productBits] + · by_cases hp : k = productBits + · subst k + simp [ρ, Function.update, indexA, productBits] + · simp [ρ, TapeConvolutionRows.frame, Function.update, hi, hl, hp] + have hlen : (ρ indexA).length = r := by simp [ρ] + have hlinear : 8 * r + 16 * r + 43 = 24 * r + 43 := by omega + have htime : (30 * r + 22 + 1 + + (r * (r * (8 * r + 16 * r + 43) + 4 * r + 23) + 3)) + 1 + (2 * r + 5) = cost r := by + rw [hlinear] + unfold cost + omega + simpa only [program, start, done, hframe, hlen, htime] using hall + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeConvolve +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeCopy.lean b/lean/OAI/Computability/DepthThree/TapeCopy.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1bb4b3ee5f3aaf6202e77f70d695b856a82abde --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeCopy.lean @@ -0,0 +1,218 @@ +import OAI.Computability.DepthThree.TapeMultiRoutines +import OAI.Computability.DepthThree.TapeWordRewind + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 + +namespace DepthThreeLowerBound +namespace TapeCopy + +open Turing TapeMultiProgram + +inductive State where + | start + | scan + | rewind + | done + deriving DecidableEq, Inhabited + +instance : Fintype State where + elems := {.start, .scan, .rewind, .done} + complete := by + intro state + cases state <;> simp + +def onPair {α : Type uDepth1} (src dst : TapeRegister) (base : TapeRegister → α) + (s d : α) : TapeRegister → α := + fun r => if r = src then s else if r = dst then d else base r + +@[simp] theorem onPair_src {α : Type uDepth2} (src dst : TapeRegister) + (base : TapeRegister → α) (s d : α) : onPair src dst base s d src = s := by + simp [onPair] + +@[simp] theorem onPair_dst {α : Type uDepth3} {src dst : TapeRegister} (hne : src ≠ dst) + (base : TapeRegister → α) (s d : α) : onPair src dst base s d dst = d := by + simp [onPair, Ne.symm hne] + +theorem onPair_other {α : Type uDepth4} (src dst : TapeRegister) + (base : TapeRegister → α) (s d : α) (r : TapeRegister) + (hs : r ≠ src) (hd : r ≠ dst) : onPair src dst base s d r = base r := by + simp [onPair, hs, hd] + +def emit {Q : Type uDepth5} (src dst : TapeRegister) (q : Q) (h : TapeHeads) + (s d : TapeSymbol) (m : HeadMove) : Option (Q × TapeHeads × TapeMoves) := + some (q, onPair src dst h s d, onPair src dst stayMoves m m) + +def code (src dst : TapeRegister) : TapeMultiProgram State + | .start, h => emit src dst .scan h (h src) (h dst) .right + | .scan, h => + match (h src).1 with + | .bit b => emit src dst .scan h (h src) (rawInputSymbol b) .right + | .endMark => emit src dst .rewind h (h src) (cleanAtom .endMark) .stay + | _ => none + | .rewind, h => + if (h src).1 = .home then emit src dst .done h (h src) (h dst) .stay + else emit src dst .rewind h (h src) (h dst) .left + | .done, _ => none + +theorem step_emit {Q : Type uDepth6} (P : TapeMultiProgram Q) + {src dst : TapeRegister} (hne : src ≠ dst) + (T : TapeTapes) (S D : Tape TapeSymbol) (q q' : Q) + (s d : TapeSymbol) (m : HeadMove) + (h : P q (heads (onPair src dst T S D)) = + emit src dst q' (heads (onPair src dst T S D)) s d m) : + P.step (cfg q (onPair src dst T S D)) = + some (cfg q' (onPair src dst T (m.apply (S.write s)) (m.apply (D.write d)))) := by + have he := multiTapeStep_eq_some (c := cfg q (onPair src dst T S D)) + (code := P) h + change P.step (cfg q (onPair src dst T S D)) = + some (multiTapeUpdate (cfg q (onPair src dst T S D)) q' + (onPair src dst (heads (onPair src dst T S D)) s d) + (onPair src dst stayMoves m m)) at he + rw [he] + congr 1 + apply congrArg (cfg q') + funext r + by_cases hs : r = src + · subst r + simp [cfg, onPair] + · by_cases hd : r = dst + · subst r + simp [cfg, onPair, Ne.symm hne] + · simp [cfg, onPair, heads, stayMoves, hs, hd] + +theorem step_start {src dst : TapeRegister} (hne : src ≠ dst) + (T : TapeTapes) (S D : Tape TapeSymbol) : + (code src dst).step (cfg .start (onPair src dst T S D)) = + some (cfg .scan (onPair src dst T (S.move .right) (D.move .right))) := by + have h := step_emit (code src dst) hne T S D .start .scan S.head D.head .right + (by simp [code, heads, hne]) + simpa only [Tape.write_self, HeadMove.apply_right] using h + +theorem step_scan_bit {src dst : TapeRegister} (hne : src ≠ dst) + (T : TapeTapes) (S D : Tape TapeSymbol) (b : Bool) + (hS : S.head = rawInputSymbol b) : + (code src dst).step (cfg .scan (onPair src dst T S D)) = + some (cfg .scan (onPair src dst T (S.move .right) + ((D.write (rawInputSymbol b)).move .right))) := by + have h := step_emit (code src dst) hne T S D .scan .scan S.head (rawInputSymbol b) .right + (by simp [code, heads, hS, rawInputSymbol, cleanAtom]) + simpa only [Tape.write_self, HeadMove.apply_right] using h + +theorem step_scan_end {src dst : TapeRegister} (hne : src ≠ dst) + (T : TapeTapes) (S D : Tape TapeSymbol) (hS : S.head = cleanAtom .endMark) : + (code src dst).step (cfg .scan (onPair src dst T S D)) = + some (cfg .rewind (onPair src dst T S (D.write (cleanAtom .endMark)))) := by + have h := step_emit (code src dst) hne T S D .scan .rewind S.head (cleanAtom .endMark) .stay + (by simp [code, heads, hS, cleanAtom]) + simpa only [Tape.write_self, HeadMove.apply_stay] using h + +theorem step_rewind_move {src dst : TapeRegister} (hne : src ≠ dst) + (T : TapeTapes) (S D : Tape TapeSymbol) (hS : S.head.1 ≠ .home) : + (code src dst).step (cfg .rewind (onPair src dst T S D)) = + some (cfg .rewind (onPair src dst T (S.move .left) (D.move .left))) := by + have h := step_emit (code src dst) hne T S D .rewind .rewind S.head D.head .left + (by simp [code, heads, hne, hS]) + simpa only [Tape.write_self, HeadMove.apply_left] using h + +theorem step_rewind_home {src dst : TapeRegister} (hne : src ≠ dst) + (T : TapeTapes) (S D : Tape TapeSymbol) (hS : S.head.1 = .home) : + (code src dst).step (cfg .rewind (onPair src dst T S D)) = + some (cfg .done (onPair src dst T S D)) := by + have h := step_emit (code src dst) hne T S D .rewind .done S.head D.head .stay + (by simp [code, heads, hne, hS]) + simpa only [Tape.write_self, HeadMove.apply_stay] using h + +theorem write_mk₂ (L R : List TapeSymbol) (a : TapeSymbol) : + (Tape.mk₂ L R).write a = Tape.mk₂ L (a :: R.tail) := by + cases R <;> rfl + +theorem runs_scan {src dst : TapeRegister} (hne : src ≠ dst) + (T : TapeTapes) (bits : List Bool) (L R : List TapeSymbol) (hR : R.tail = []) : + RunsIn (code src dst).step + (cfg .scan (onPair src dst T + (Tape.mk₂ L (encodeInput bits ++ [cleanAtom .endMark])) (Tape.mk₂ L R))) + (cfg .rewind (onPair src dst T + (Tape.mk₂ ((encodeInput bits).reverse ++ L) [cleanAtom .endMark]) + (Tape.mk₂ ((encodeInput bits).reverse ++ L) [cleanAtom .endMark]))) + (bits.length + 1) := by + induction bits generalizing L R with + | nil => + have h := RunsIn.single (step_scan_end hne T + (Tape.mk₂ L [cleanAtom .endMark]) (Tape.mk₂ L R) rfl) + simpa only [encodeInput, List.map_nil, List.nil_append, List.reverse_nil, + List.length_nil, Nat.zero_add, write_mk₂, hR] using h + | cons b bits ih => + have hfirst := RunsIn.single (step_scan_bit hne T + (Tape.mk₂ L (rawInputSymbol b :: (encodeInput bits ++ [cleanAtom .endMark]))) + (Tape.mk₂ L R) b rfl) + have hrest := ih (rawInputSymbol b :: L) [] rfl + simp only [write_mk₂, TapeWord.move_right_mk₂_cons, hR] at hfirst + have hboth := hfirst.trans hrest + simpa only [encodeInput, List.map_cons, List.cons_append, List.reverse_cons, + List.append_assoc, List.nil_append, List.length_cons, Nat.add_comm, + Nat.add_left_comm, Nat.add_assoc] using hboth + +theorem runs_rewind {src dst : TapeRegister} (hne : src ≠ dst) + (T : TapeTapes) (bits : List Bool) (a : TapeSymbol) (R : List TapeSymbol) + (ha : a.1 ≠ .home) : + RunsIn (code src dst).step + (cfg .rewind (onPair src dst T + (Tape.mk₂ (encodeInput bits ++ [cleanAtom .home]) (a :: R)) + (Tape.mk₂ (encodeInput bits ++ [cleanAtom .home]) (a :: R)))) + (cfg .done (onPair src dst T + (Tape.mk₂ [] (cleanAtom .home :: ((encodeInput bits).reverse ++ a :: R))) + (Tape.mk₂ [] (cleanAtom .home :: ((encodeInput bits).reverse ++ a :: R))))) + (bits.length + 2) := by + induction bits generalizing a R with + | nil => + have hfirst := RunsIn.single (step_rewind_move hne T + (Tape.mk₂ [cleanAtom .home] (a :: R)) + (Tape.mk₂ [cleanAtom .home] (a :: R)) ha) + simp only [TapeWord.move_left_mk₂_cons] at hfirst + have hlast := RunsIn.single (step_rewind_home hne T + (Tape.mk₂ [] (cleanAtom .home :: a :: R)) + (Tape.mk₂ [] (cleanAtom .home :: a :: R)) rfl) + simpa only [encodeInput, List.map_nil, List.nil_append, List.reverse_nil, + List.length_nil, Nat.zero_add] using hfirst.trans hlast + | cons b bits ih => + have hfirst := RunsIn.single (step_rewind_move hne T + (Tape.mk₂ (rawInputSymbol b :: (encodeInput bits ++ [cleanAtom .home])) (a :: R)) + (Tape.mk₂ (rawInputSymbol b :: (encodeInput bits ++ [cleanAtom .home])) (a :: R)) ha) + simp only [TapeWord.move_left_mk₂_cons] at hfirst + have hrest := ih (rawInputSymbol b) (a :: R) (by simp [rawInputSymbol, cleanAtom]) + simpa only [encodeInput, List.map_cons, List.cons_append, List.reverse_cons, + List.append_assoc, List.nil_append, List.length_cons, Nat.add_comm, + Nat.add_left_comm, Nat.add_assoc] using hfirst.trans hrest + +theorem runs_copy {src dst : TapeRegister} (hne : src ≠ dst) + (T : TapeTapes) (bits : List Bool) : + RunsIn (code src dst).step + (cfg .start (onPair src dst T (wordTape bits) (wordTape []))) + (cfg .done (onPair src dst T (wordTape bits) (wordTape bits))) + (2 * bits.length + 4) := by + have hstart := RunsIn.single (step_start hne T (wordTape bits) (wordTape [])) + have hscan := runs_scan hne T bits [cleanAtom .home] [cleanAtom .endMark] rfl + have hback := runs_rewind hne T bits.reverse (cleanAtom .endMark) [] (by simp [cleanAtom]) + have hreverse : encodeInput bits.reverse = (encodeInput bits).reverse := by + simp [encodeInput] + simp only [hreverse, List.reverse_reverse, List.length_reverse] at hback + have hstart' : RunsIn (code src dst).step + (cfg .start (onPair src dst T (wordTape bits) (wordTape []))) + (cfg .scan (onPair src dst T + (Tape.mk₂ [cleanAtom .home] (encodeInput bits ++ [cleanAtom .endMark])) + (Tape.mk₂ [cleanAtom .home] [cleanAtom .endMark]))) 1 := by + simpa only [wordTape_right, cursorTape, encodeInput, List.map_nil, + List.reverse_nil, List.nil_append] using hstart + have hboth := (hstart'.trans hscan).trans hback + simpa only [wordTape, Tape.mk₁, Nat.two_mul, Nat.add_assoc, Nat.add_comm, + Nat.add_left_comm] using hboth + +@[simp] theorem step_done (src dst : TapeRegister) (T : TapeTapes) : + (code src dst).step (cfg .done T) = none := rfl + +end TapeCopy +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeCopyAdd.lean b/lean/OAI/Computability/DepthThree/TapeCopyAdd.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e7977929ff1d364a2794a3ae0b60a2b75094c14 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeCopyAdd.lean @@ -0,0 +1,48 @@ +import OAI.Computability.DepthThree.TapeStoreRepresentation + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeCopyAdd + +open TapeMultiProgram TapeRouting TapeArithmetic + +abbrev State := TapeCopy.State ⊕ AddState + +def program (src scratch dst : TapeRegister) : TapeMultiProgram State := + joinCode (TapeCopy.code src scratch) (addProgram scratch dst) (fun _ => addStart) + +def start : State := .inl .start +def done : State := .inr addDone + +@[simp] theorem program_done (src scratch dst : TapeRegister) (h : TapeHeads) : + program src scratch dst done h = none := rfl + +theorem runs_add {src scratch dst : TapeRegister} + (hsc : src ≠ scratch) (hcd : scratch ≠ dst) (σ : TapeStore) (n m : ℕ) + (hn : σ src = List.replicate n true) (hm : σ dst = List.replicate m true) + (hc : σ scratch = []) : + RunsIn (program src scratch dst).step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update σ dst (List.replicate (m + n) true)))) + (10 * n + 8) := by + let τ := Function.update σ scratch (List.replicate n true) + have hcopy := TapeStoreRuns.copy hsc σ hc + have hcopy' : RunsIn (TapeCopy.code src scratch).step + (cfg TapeCopy.State.start (storeTapes σ)) + (cfg TapeCopy.State.done (storeTapes τ)) (2 * n + 4) := by + simpa only [hn, List.length_replicate] using hcopy + have hadd := TapeStoreRuns.add hcd τ n m + (by simp [τ]) (by simp [τ, hm, Ne.symm hcd]) + have hclear : Function.update τ scratch [] = σ := by + dsimp [τ] + rw [Function.update_idem, ← hc, Function.update_eq_self] + rw [hclear] at hadd + have hall := join_runs (TapeCopy.code src scratch) (addProgram scratch dst) + (fun _ => addStart) hcopy' rfl hadd + have hcost : (2 * n + 4) + 1 + (8 * n + 3) = 10 * n + 8 := by omega + simpa only [program, start, done, hcost] using hall + +end TapeCopyAdd +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeDecodeBlock.lean b/lean/OAI/Computability/DepthThree/TapeDecodeBlock.lean new file mode 100644 index 0000000000000000000000000000000000000000..ead800fe30103a0d383768ca2b95e980bd3f888d --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeDecodeBlock.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DepthThree.TapeInputPrepare +import OAI.Computability.DepthThree.TapeInputBlocks +import Mathlib.Tactic.Linarith + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeDecodeBlock + +open TapeMultiProgram TapeRouting + +abbrev FinishState := TapeInputBlocks.State ⊕ TapeErase.State + +def finishProgram (kind : InputBlockKind) : TapeMultiProgram FinishState := + joinCode (TapeInputBlocks.canonicalProgram kind) (TapeErase.code TapeRegister.temp0) + (fun _ => TapeErase.State.start) + +def finishStart : FinishState := .inl TapeInputBlocks.start +def finishDone : FinishState := .inr TapeErase.State.done + +abbrev State (kind : InputBlockKind) := TapeInputPrepare.State kind ⊕ FinishState + +def program (kind : InputBlockKind) : TapeMultiProgram (State kind) := + joinCode (TapeInputPrepare.program kind) (finishProgram kind) (fun _ => finishStart) + +def start (kind : InputBlockKind) : State kind := .inl (TapeInputPrepare.start kind) +def done (kind : InputBlockKind) : State kind := .inr finishDone + +@[simp] theorem program_done (kind : InputBlockKind) (h : TapeHeads) : + program kind (done kind) h = none := rfl + +def outputStore (σ : TapeStore) (w : List Bool) (kind : InputBlockKind) : TapeStore := + Function.update σ (TapeInputBlocks.outputRegister kind) (inputBlockData w kind) + +theorem runs_block (σ : TapeStore) (w : List Bool) (kind : InputBlockKind) + (hfit : InputFits w) (hw : σ TapeRegister.input = w) + (hd : σ 2 = List.replicate (dataDimension w.length) true) + (hr : σ 3 = List.replicate (hashDimension (dataDimension w.length)) true) + (ht : σ 4 = List.replicate (independenceOrder (dataDimension w.length)) true) + (h29 : σ 29 = []) (h30 : σ 30 = []) (h31 : σ 31 = []) + (h5 : σ 5 = []) (h6 : σ 6 = []) (h7 : σ 7 = []) + (hout : σ (TapeInputBlocks.outputRegister kind) = []) : + RunsIn (program kind).step (cfg (start kind) (storeTapes σ)) + (cfg (done kind) (storeTapes (outputStore σ w kind))) + (200 * (w.length + 1) ^ 2) := by + let τ := TapeInputPrepare.outputStore σ w.length kind + let υ := Function.update (Function.update τ TapeRegister.temp1 []) + (TapeInputBlocks.outputRegister kind) (inputBlockData w kind) + have hp := TapeInputPrepare.runs_prepare σ w.length kind hd hr ht h29 h30 h31 h5 h6 h7 + have hi : τ TapeRegister.temp0 = List.replicate (inputBlockOffset w.length kind) true := by + simp [τ, TapeInputPrepare.outputStore, TapeRegister.temp0] + have hc : τ TapeRegister.temp1 = List.replicate (inputBlockLength w.length kind) true := by + simp [τ, TapeInputPrepare.outputStore, TapeRegister.temp1] + have hx := TapeInputBlocks.runs_canonical_block kind τ w hfit + (by simpa [τ, TapeInputPrepare.outputStore, TapeRegister.input] using hw) hi hc + (by simpa [τ, TapeInputPrepare.outputStore, TapeRegister.temp2] using h31) + (by cases kind <;> simpa [τ, TapeInputPrepare.outputStore, + TapeInputBlocks.outputRegister, TapeRegister.dataBits, TapeRegister.keyBits, + TapeRegister.polyBits, TapeRegister.coeffBits] using hout) + have he := TapeStoreRuns.erase TapeRegister.temp0 υ + have hindex : υ TapeRegister.temp0 = + List.replicate (inputBlockOffset w.length kind) true := by + cases kind <;> simp [υ, τ, TapeInputPrepare.outputStore, + TapeInputBlocks.outputRegister, TapeRegister.temp0, TapeRegister.temp1, + TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] + have hrestore : Function.update υ TapeRegister.temp0 [] = outputStore σ w kind := by + funext q + cases kind <;> by_cases hq29 : q = 29 <;> by_cases hq30 : q = 30 <;> + simp_all [υ, τ, TapeInputPrepare.outputStore, outputStore, + TapeInputBlocks.outputRegister, TapeRegister.temp0, TapeRegister.temp1, + TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits, + Function.update_apply] + rw [hrestore, hindex, List.length_replicate] at he + have hf := join_runs (TapeInputBlocks.canonicalProgram kind) + (TapeErase.code TapeRegister.temp0) (fun _ => TapeErase.State.start) hx rfl he + have hall := join_runs (TapeInputPrepare.program kind) (finishProgram kind) + (fun _ => finishStart) hp (by simp) hf + apply hall.mono + have hpbound := TapeInputPrepare.cost_le w.length kind + have hxbound := TapeInputBlocks.canonical_cost_le hfit kind + have hobound := inputBlock_offset_le hfit kind + nlinarith [Nat.zero_le (w.length ^ 2)] + +end TapeDecodeBlock +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeDecodeBlocks.lean b/lean/OAI/Computability/DepthThree/TapeDecodeBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a7d0104f6336ad3725b1b5ebbddf2e41778dd15 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeDecodeBlocks.lean @@ -0,0 +1,121 @@ +import OAI.Computability.DepthThree.TapeDecodeBlock + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeDecodeBlocks + +open TapeMultiProgram TapeRouting + +abbrev TailState := TapeDecodeBlock.State .polynomial ⊕ TapeDecodeBlock.State .coefficients + +def tailProgram : TapeMultiProgram TailState := + joinCode (TapeDecodeBlock.program .polynomial) (TapeDecodeBlock.program .coefficients) + (fun _ => TapeDecodeBlock.start .coefficients) + +def tailStart : TailState := .inl (TapeDecodeBlock.start .polynomial) +def tailDone : TailState := .inr (TapeDecodeBlock.done .coefficients) + +abbrev RestState := TapeDecodeBlock.State .hash ⊕ TailState + +def restProgram : TapeMultiProgram RestState := + joinCode (TapeDecodeBlock.program .hash) tailProgram (fun _ => tailStart) + +def restStart : RestState := .inl (TapeDecodeBlock.start .hash) +def restDone : RestState := .inr tailDone + +abbrev State := TapeDecodeBlock.State .data ⊕ RestState + +def program : TapeMultiProgram State := + joinCode (TapeDecodeBlock.program .data) restProgram (fun _ => restStart) + +def start : State := .inl (TapeDecodeBlock.start .data) +def done : State := .inr restDone + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +def outputStore (σ : TapeStore) (w : List Bool) : TapeStore := + TapeDecodeBlock.outputStore + (TapeDecodeBlock.outputStore + (TapeDecodeBlock.outputStore (TapeDecodeBlock.outputStore σ w .data) w .hash) + w .polynomial) w .coefficients + +@[simp] theorem outputStore_block (σ : TapeStore) (w : List Bool) (kind : InputBlockKind) : + outputStore σ w (TapeInputBlocks.outputRegister kind) = inputBlockData w kind := by + cases kind <;> simp [outputStore, TapeDecodeBlock.outputStore, + TapeInputBlocks.outputRegister, TapeRegister.dataBits, TapeRegister.keyBits, + TapeRegister.polyBits, TapeRegister.coeffBits] + +theorem outputStore_other (σ : TapeStore) (w : List Bool) (q : TapeRegister) + (h15 : q ≠ 15) (h16 : q ≠ 16) (h17 : q ≠ 17) (h18 : q ≠ 18) : + outputStore σ w q = σ q := by + simp [outputStore, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, + TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, + TapeRegister.coeffBits, Function.update, h15, h16, h17, h18] + +theorem runs_decode (σ : TapeStore) (w : List Bool) + (hfit : InputFits w) (hw : σ TapeRegister.input = w) + (hd : σ 2 = List.replicate (dataDimension w.length) true) + (hr : σ 3 = List.replicate (hashDimension (dataDimension w.length)) true) + (ht : σ 4 = List.replicate (independenceOrder (dataDimension w.length)) true) + (h29 : σ 29 = []) (h30 : σ 30 = []) (h31 : σ 31 = []) + (h5 : σ 5 = []) (h6 : σ 6 = []) (h7 : σ 7 = []) + (h15 : σ 15 = []) (h16 : σ 16 = []) (h17 : σ 17 = []) (h18 : σ 18 = []) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (outputStore σ w))) (804 * (w.length + 1) ^ 2) := by + let σ1 := TapeDecodeBlock.outputStore σ w .data + let σ2 := TapeDecodeBlock.outputStore σ1 w .hash + let σ3 := TapeDecodeBlock.outputStore σ2 w .polynomial + have h0 := TapeDecodeBlock.runs_block σ w .data hfit hw hd hr ht + h29 h30 h31 h5 h6 h7 h15 + have h1 := TapeDecodeBlock.runs_block σ1 w .hash hfit + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using hw) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using hd) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using hr) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using ht) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h29) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h30) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h31) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h5) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h6) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h7) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h16) + have h2 := TapeDecodeBlock.runs_block σ2 w .polynomial hfit + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using hw) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using hd) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using hr) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using ht) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h29) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h30) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h31) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h5) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h6) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h7) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h17) + have h3 := TapeDecodeBlock.runs_block σ3 w .coefficients hfit + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using hw) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using hd) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using hr) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using ht) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h29) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h30) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h31) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h5) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h6) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h7) + (by simpa [σ1, σ2, σ3, TapeDecodeBlock.outputStore, TapeInputBlocks.outputRegister, TapeRegister.input, TapeRegister.dataBits, TapeRegister.keyBits, TapeRegister.polyBits, TapeRegister.coeffBits] using h18) + have htail := join_runs (TapeDecodeBlock.program .polynomial) + (TapeDecodeBlock.program .coefficients) (fun _ => TapeDecodeBlock.start .coefficients) + h2 (by simp) h3 + have hrest := join_runs (TapeDecodeBlock.program .hash) tailProgram + (fun _ => tailStart) h1 (by simp) htail + have hall := join_runs (TapeDecodeBlock.program .data) restProgram + (fun _ => restStart) h0 (by simp) hrest + apply hall.mono + have hpos : 1 ≤ (w.length + 1) ^ 2 := Nat.pow_pos (Nat.succ_pos _) + omega + +end TapeDecodeBlocks +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeDecodeParsed.lean b/lean/OAI/Computability/DepthThree/TapeDecodeParsed.lean new file mode 100644 index 0000000000000000000000000000000000000000..92c60acd8dbb47058be1b566691f6b8d0e7f4d60 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeDecodeParsed.lean @@ -0,0 +1,60 @@ +import OAI.Computability.DepthThree.TapeParse +import OAI.Computability.DepthThree.TapeDecodeBlocks + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeDecodeParsed + +open TapeMultiProgram + +def outputStore (w : List Bool) : TapeStore := + TapeDecodeBlocks.outputStore (TapeParse.outputStore w) w + +@[simp] theorem outputStore_block (w : List Bool) (kind : InputBlockKind) : + outputStore w (TapeInputBlocks.outputRegister kind) = inputBlockData w kind := + TapeDecodeBlocks.outputStore_block _ _ _ + +theorem outputStore_other (w : List Bool) (q : TapeRegister) + (h15 : q ≠ 15) (h16 : q ≠ 16) (h17 : q ≠ 17) (h18 : q ≠ 18) : + outputStore w q = TapeParse.outputStore w q := + TapeDecodeBlocks.outputStore_other _ _ _ h15 h16 h17 h18 + +@[simp] theorem outputStore_data (w : List Bool) : + outputStore w 2 = List.replicate (dataDimension w.length) true := by + rw [outputStore_other w 2 (by decide) (by decide) (by decide) (by decide)] + exact TapeParse.outputStore_data w + +@[simp] theorem outputStore_hash (w : List Bool) : + outputStore w 3 = List.replicate (hashDimension (dataDimension w.length)) true := by + rw [outputStore_other w 3 (by decide) (by decide) (by decide) (by decide)] + exact TapeParse.outputStore_hash w + +@[simp] theorem outputStore_order (w : List Bool) : + outputStore w 4 = List.replicate (independenceOrder (dataDimension w.length)) true := by + rw [outputStore_other w 4 (by decide) (by decide) (by decide) (by decide)] + exact TapeParse.outputStore_order w + +theorem outputStore_empty (w : List Bool) (q : TapeRegister) + (h0 : q ≠ 0) (h1 : q ≠ 1) (h2 : q ≠ 2) (h3 : q ≠ 3) + (h4 : q ≠ 4) (h8 : q ≠ 8) (h15 : q ≠ 15) (h16 : q ≠ 16) + (h17 : q ≠ 17) (h18 : q ≠ 18) : outputStore w q = [] := by + rw [outputStore_other w q h15 h16 h17 h18] + exact TapeParse.outputStore_empty w q h0 h1 h2 h3 h4 h8 + +theorem runs_decode (w : List Bool) (hfit : InputFits w) : + RunsIn TapeDecodeBlocks.program.step + (cfg TapeDecodeBlocks.start (storeTapes (TapeParse.outputStore w))) + (cfg TapeDecodeBlocks.done (storeTapes (outputStore w))) + (804 * (w.length + 1) ^ 2) := by + apply TapeDecodeBlocks.runs_decode _ w hfit + · exact TapeParse.outputStore_input w + · exact TapeParse.outputStore_data w + · exact TapeParse.outputStore_hash w + · exact TapeParse.outputStore_order w + all_goals apply TapeParse.outputStore_empty <;> decide + +end TapeDecodeParsed +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeDivideFive.lean b/lean/OAI/Computability/DepthThree/TapeDivideFive.lean new file mode 100644 index 0000000000000000000000000000000000000000..4964c68324de2c370b21e89dd0f1986cff0421db --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeDivideFive.lean @@ -0,0 +1,142 @@ +import OAI.Computability.DepthThree.TapeArithmetic +import Mathlib.Data.Fintype.Sigma + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeDivideFive + +open TapeMultiProgram TapeUnary TapeCopy TapeArithmetic + +inductive State where + | dec (phase : Fin 5) (q : DecState) + | inc (q : IncState) + | done (remainder : Fin 5) + deriving DecidableEq, Fintype + +def nextPhase (phase : Fin 5) : Fin 5 := + ⟨(phase.val + 1) % 5, Nat.mod_lt _ (by decide)⟩ + +def residue (n : ℕ) : Fin 5 := ⟨n % 5, Nat.mod_lt _ (by decide)⟩ + +def program (counter destination : TapeRegister) : TapeMultiProgram State + | .dec phase q, h => + match decProgram counter q h with + | some (q', writes, moves) => some (.dec phase q', writes, moves) + | none => + match q with + | .done false => jump (.done phase) h + | .done true => + if phase.val = 4 then jump (.inc .start) h + else jump (.dec (nextPhase phase) .start) h + | _ => none + | .inc q, h => + match incProgram destination q h with + | some (q', writes, moves) => some (.inc q', writes, moves) + | none => jump (.dec 0 .start) h + | .done _, _ => none + +private theorem dec_runs (counter destination : TapeRegister) (phase : Fin 5) + {a b : DecState} {T U : TapeTapes} {n : ℕ} + (h : RunsIn (decProgram counter).step (cfg a T) (cfg b U) n) : + RunsIn (program counter destination).step + (cfg (.dec phase a) T) (cfg (.dec phase b) U) n := by + have he := runs_map (decProgram counter) (program counter destination) + (State.dec phase) (by + intro q heads q' writes moves hc + simp only [program, hc]) h + exact he + +private theorem inc_runs (counter destination : TapeRegister) + {a b : IncState} {T U : TapeTapes} {n : ℕ} + (h : RunsIn (incProgram destination).step (cfg a T) (cfg b U) n) : + RunsIn (program counter destination).step + (cfg (.inc a) T) (cfg (.inc b) U) n := by + have he := runs_map (incProgram destination) (program counter destination) + State.inc (by + intro q heads q' writes moves hc + simp only [program, hc]) h + exact he + +theorem runs_phase {counter destination : TapeRegister} (hne : counter ≠ destination) + (T : TapeTapes) (n m : ℕ) (phase : Fin 5) : + RunsIn (program counter destination).step + (cfg (.dec phase .start) + (onPair counter destination T (counterTape n) (counterTape m))) + (cfg (.done (residue (phase.val + n))) + (onPair counter destination T (counterTape 0) + (counterTape (m + (phase.val + n) / 5)))) + (8 * n + 3) := by + induction n generalizing m phase with + | zero => + have hd := decrement_empty counter + (onPair counter destination T (counterTape 0) (counterTape m)) + (by simp [counterTape]) + have hrun := dec_runs counter destination phase hd + have hj := step_jump (program counter destination) + (.dec phase (.done false)) (.done phase) + (onPair counter destination T (counterTape 0) (counterTape m)) rfl + have hall := hrun.trans (RunsIn.single hj) + have hr : residue phase.val = phase := by + apply Fin.ext + exact Nat.mod_eq_of_lt phase.is_lt + simpa only [Nat.add_zero, Nat.mul_zero, Nat.zero_add, + Nat.div_eq_of_lt phase.is_lt, hr] using hall + | succ n ih => + have hd := decrement_cons counter + (onPair counter destination T (counterTape (n + 1)) (counterTape m)) + (List.replicate n true) true (by simp [counterTape, List.replicate_succ]) + simp only [update_onPair_src] at hd + have hrun := dec_runs counter destination phase hd + have hpBound := phase.is_lt + by_cases hp : phase.val = 4 + · have hj := step_jump (program counter destination) + (.dec phase (.done true)) (.inc .start) + (onPair counter destination T (counterTape n) (counterTape m)) + (by simp [program, decProgram, hp]) + have hi := increment destination + (onPair counter destination T (counterTape n) (counterTape m)) m + (by simp [hne]) + simp only [update_onPair_dst hne] at hi + have hinc := inc_runs counter destination hi + have hk := step_jump (program counter destination) (.inc .done) + (.dec 0 .start) + (onPair counter destination T (counterTape n) (counterTape (m + 1))) rfl + have hall := (((hrun.trans (RunsIn.single hj)).trans hinc).trans + (RunsIn.single hk)).trans (ih (m + 1) 0) + have hv : m + 1 + n / 5 = m + (phase.val + (n + 1)) / 5 := by omega + have hr : residue (phase.val + (n + 1)) = residue n := by + apply Fin.ext + dsimp [residue] + omega + have ht : 4 + 1 + 2 + 1 + (8 * n + 3) = 8 * (n + 1) + 3 := by omega + simpa only [Fin.val_zero, Nat.zero_add, hv, hr, ht] using hall + · have hphase : phase.val + 1 < 5 := by omega + have hnext : (nextPhase phase).val = phase.val + 1 := + Nat.mod_eq_of_lt hphase + have hj := step_jump (program counter destination) + (.dec phase (.done true)) (.dec (nextPhase phase) .start) + (onPair counter destination T (counterTape n) (counterTape m)) + (by simp [program, decProgram, hp]) + have hall := (hrun.trans (RunsIn.single hj)).trans (ih m (nextPhase phase)) + have hv : (nextPhase phase).val + n = phase.val + (n + 1) := by omega + have ht : 4 + 1 + (8 * n + 3) ≤ 8 * (n + 1) + 3 := by omega + simpa only [hv] using hall.mono ht + +theorem runs_divide {counter destination : TapeRegister} (hne : counter ≠ destination) + (T : TapeTapes) (n m : ℕ) : + RunsIn (program counter destination).step + (cfg (.dec 0 .start) + (onPair counter destination T (counterTape n) (counterTape m))) + (cfg (.done (residue n)) + (onPair counter destination T (counterTape 0) (counterTape (m + n / 5)))) + (8 * n + 3) := by + simpa only [Fin.val_zero, Nat.zero_add] using runs_phase hne T n m 0 + +@[simp] theorem done_halts (counter destination : TapeRegister) (r : Fin 5) + (h : TapeHeads) : program counter destination (.done r) h = none := rfl + +end TapeDivideFive +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeEncoding.lean b/lean/OAI/Computability/DepthThree/TapeEncoding.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca5423308d6986f3f07df9869b00f7a9c109dd4a --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeEncoding.lean @@ -0,0 +1,195 @@ +import Mathlib.Algebra.BigOperators.Group.List.Basic +import Mathlib.Data.Fintype.Pi +import Mathlib.Data.Fintype.Prod +import Mathlib.Data.Fintype.Sum +import Mathlib.Data.List.FinRange +import Mathlib.Tactic.DeriveFintype + +namespace OAI + +namespace DepthThreeLowerBound + +abbrev TapeRegister := Fin 32 + +namespace TapeRegister + +abbrev input : TapeRegister := 0 +abbrev length : TapeRegister := 1 +abbrev dataLength : TapeRegister := 2 +abbrev ringDegree : TapeRegister := 3 +abbrev coeffCount : TapeRegister := 4 +abbrev candidate : TapeRegister := 5 +abbrev powerTarget : TapeRegister := 6 +abbrev powerScratch : TapeRegister := 7 +abbrev requiredLength : TapeRegister := 8 +abbrev loop0 : TapeRegister := 9 +abbrev loop1 : TapeRegister := 10 +abbrev loop2 : TapeRegister := 11 +abbrev loop3 : TapeRegister := 12 +abbrev loop4 : TapeRegister := 13 +abbrev loop5 : TapeRegister := 14 +abbrev dataBits : TapeRegister := 15 +abbrev keyBits : TapeRegister := 16 +abbrev polyBits : TapeRegister := 17 +abbrev coeffBits : TapeRegister := 18 +abbrev hashBits : TapeRegister := 19 +abbrev accumBits : TapeRegister := 20 +abbrev productBits : TapeRegister := 21 +abbrev indexA : TapeRegister := 22 +abbrev indexB : TapeRegister := 23 +abbrev indexC : TapeRegister := 24 +abbrev scratchA : TapeRegister := 25 +abbrev scratchB : TapeRegister := 26 +abbrev scratchC : TapeRegister := 27 +abbrev savedCount : TapeRegister := 28 +abbrev temp0 : TapeRegister := 29 +abbrev temp1 : TapeRegister := 30 +abbrev temp2 : TapeRegister := 31 + +end TapeRegister + +inductive TapeAtom where + | blank + | home + | delimiter (r : TapeRegister) + | bit (b : Bool) + | endMark + deriving DecidableEq, Fintype, Inhabited + +abbrev TapeMark := Fin 4 + +abbrev TapeSymbol := TapeAtom × (TapeMark → Bool) + +def cleanAtom (a : TapeAtom) : TapeSymbol := (a, fun _ => false) + +def blankSymbol : TapeSymbol := cleanAtom .blank + +def rawInputSymbol (b : Bool) : TapeSymbol := cleanAtom (.bit b) + +@[simp] theorem cleanAtom_atom (a : TapeAtom) : (cleanAtom a).1 = a := rfl + +@[simp] theorem cleanAtom_mark (a : TapeAtom) (m : TapeMark) : + (cleanAtom a).2 m = false := rfl + +@[simp] theorem default_tapeSymbol : (default : TapeSymbol) = blankSymbol := rfl + +theorem cleanAtom_injective : Function.Injective cleanAtom := by + intro a b h + exact congrArg Prod.fst h + +theorem rawInputSymbol_injective : Function.Injective rawInputSymbol := by + intro a b h + have hab : TapeAtom.bit a = TapeAtom.bit b := congrArg Prod.fst h + cases hab + rfl + +@[simp] theorem rawInputSymbol_ne_blank (b : Bool) : rawInputSymbol b ≠ blankSymbol := by + intro h + have hab : TapeAtom.bit b = TapeAtom.blank := congrArg Prod.fst h + cases hab + +abbrev TapeStore := TapeRegister → List Bool + +def tapeRegisters : List TapeRegister := List.ofFn id + +@[simp] theorem tapeRegisters_length : tapeRegisters.length = 32 := by + simp [tapeRegisters] + +@[simp] theorem mem_tapeRegisters (r : TapeRegister) : r ∈ tapeRegisters := by + change r ∈ List.ofFn (fun i : TapeRegister => i) + exact List.mem_ofFn.mpr ⟨r, rfl⟩ + +theorem tapeRegisters_nodup : tapeRegisters.Nodup := by + exact List.nodup_ofFn_ofInjective (fun _ _ h => h) + +def encodeInput (bits : List Bool) : List TapeSymbol := bits.map rawInputSymbol + +@[simp] theorem encodeInput_length (bits : List Bool) : + (encodeInput bits).length = bits.length := by + simp [encodeInput] + +def encodeBlock (σ : TapeStore) (r : TapeRegister) : List TapeSymbol := + cleanAtom (.delimiter r) :: encodeInput (σ r) + +def encodeStore (σ : TapeStore) : List TapeSymbol := + cleanAtom .home :: (tapeRegisters.flatMap (encodeBlock σ) ++ [cleanAtom .endMark]) + +@[simp] theorem encodeBlock_length (σ : TapeStore) (r : TapeRegister) : + (encodeBlock σ r).length = (σ r).length + 1 := by + simp [encodeBlock] + +theorem encodeBlocks_length (σ : TapeStore) (rs : List TapeRegister) : + (rs.flatMap (encodeBlock σ)).length = + rs.length + (rs.map (fun r => (σ r).length)).sum := by + induction rs with + | nil => simp + | cons r rs ih => + simp [ih, Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] + +theorem encodeStore_length (σ : TapeStore) : + (encodeStore σ).length = + 34 + (tapeRegisters.map (fun r => (σ r).length)).sum := by + simp [encodeStore, Nat.add_comm] + simp only [← Nat.add_assoc] + +@[simp] theorem encodeStore_head? (σ : TapeStore) : + (encodeStore σ).head? = some (cleanAtom .home) := rfl + +@[simp] theorem encodeStore_ne_nil (σ : TapeStore) : encodeStore σ ≠ [] := by + simp [encodeStore] + +theorem encodeInput_symbols {bits : List Bool} {s : TapeSymbol} + (hs : s ∈ encodeInput bits) : + (∃ b : Bool, s.1 = .bit b) ∧ ∀ m, s.2 m = false := by + rcases List.mem_map.mp hs with ⟨b, _, rfl⟩ + exact ⟨⟨b, rfl⟩, fun _ => rfl⟩ + +theorem encodeBlock_symbols {σ : TapeStore} {r : TapeRegister} {s : TapeSymbol} + (hs : s ∈ encodeBlock σ r) : + s.1 ≠ .blank ∧ s.1 ≠ .home ∧ s.1 ≠ .endMark ∧ ∀ m, s.2 m = false := by + rcases List.mem_cons.mp hs with hs | hs + · subst s + simp [cleanAtom] + · obtain ⟨⟨b, hb⟩, hm⟩ := encodeInput_symbols hs + exact ⟨by simp [hb], by simp [hb], by simp [hb], hm⟩ + +theorem encodeBlocks_symbols {σ : TapeStore} {rs : List TapeRegister} {s : TapeSymbol} + (hs : s ∈ rs.flatMap (encodeBlock σ)) : + s.1 ≠ .blank ∧ s.1 ≠ .home ∧ s.1 ≠ .endMark ∧ ∀ m, s.2 m = false := by + rcases List.mem_flatMap.mp hs with ⟨r, _, hr⟩ + exact encodeBlock_symbols hr + +theorem encodeStore_no_blank {σ : TapeStore} {s : TapeSymbol} + (hs : s ∈ encodeStore σ) : s.1 ≠ .blank := by + rcases List.mem_cons.mp hs with hs | hs + · subst s + simp [cleanAtom] + · rcases List.mem_append.mp hs with hs | hs + · exact (encodeBlocks_symbols hs).1 + · have hs' : s = cleanAtom .endMark := List.mem_singleton.mp hs + subst s + simp [cleanAtom] + +theorem encodeStore_clean {σ : TapeStore} {s : TapeSymbol} + (hs : s ∈ encodeStore σ) (m : TapeMark) : s.2 m = false := by + rcases List.mem_cons.mp hs with hs | hs + · subst s + rfl + · rcases List.mem_append.mp hs with hs | hs + · exact (encodeBlocks_symbols hs).2.2.2 m + · have hs' : s = cleanAtom .endMark := List.mem_singleton.mp hs + subst s + rfl + +theorem encodeStore_tail_no_home {σ : TapeStore} {s : TapeSymbol} + (hs : s ∈ (encodeStore σ).tail) : s.1 ≠ .home := by + change s ∈ tapeRegisters.flatMap (encodeBlock σ) ++ [cleanAtom .endMark] at hs + rcases List.mem_append.mp hs with hs | hs + · exact (encodeBlocks_symbols hs).2.1 + · have hs' : s = cleanAtom .endMark := List.mem_singleton.mp hs + subst s + simp [cleanAtom] + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeErase.lean b/lean/OAI/Computability/DepthThree/TapeErase.lean new file mode 100644 index 0000000000000000000000000000000000000000..66b2740d0bbd28a4ca1ae1a7941797cd4b4b860e --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeErase.lean @@ -0,0 +1,179 @@ +import OAI.Computability.DepthThree.TapeCopy + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeErase + +open Turing TapeMultiProgram + +inductive State where + | start + | scan + | erase + | install + | done + deriving DecidableEq, Inhabited + +instance : Fintype State where + elems := {.start, .scan, .erase, .install, .done} + complete := by + intro state + cases state <;> simp + +def code (r : TapeRegister) : TapeMultiProgram State + | .start, h => move r .right .scan h + | .scan, h => + match (h r).1 with + | .bit _ => move r .right .scan h + | .endMark => jump .erase h + | _ => none + | .erase, h => + if (h r).1 = .home then move r .right .install h + else writeMove r blankSymbol .left .erase h + | .install, h => writeMove r (cleanAtom .endMark) .left .done h + | .done, _ => none + +theorem step_start (r : TapeRegister) (T : TapeTapes) (S : Tape TapeSymbol) : + (code r).step (cfg .start (Function.update T r S)) = + some (cfg .scan (Function.update T r (S.move .right))) := by + have h := TapeMultiProgram.step_move (code r) .start .scan (Function.update T r S) + r .right (by rfl) + simpa only [Function.update_self, Function.update_idem, HeadMove.apply_right] using h + +theorem step_scan_bit (r : TapeRegister) (T : TapeTapes) (S : Tape TapeSymbol) + (b : Bool) (hS : S.head = rawInputSymbol b) : + (code r).step (cfg .scan (Function.update T r S)) = + some (cfg .scan (Function.update T r (S.move .right))) := by + have h := TapeMultiProgram.step_move (code r) .scan .scan (Function.update T r S) + r .right (by simp [code, heads, hS, rawInputSymbol, cleanAtom]) + simpa only [Function.update_self, Function.update_idem, HeadMove.apply_right] using h + +theorem step_scan_end (r : TapeRegister) (T : TapeTapes) (S : Tape TapeSymbol) + (hS : S.head = cleanAtom .endMark) : + (code r).step (cfg .scan (Function.update T r S)) = + some (cfg .erase (Function.update T r S)) := by + exact TapeMultiProgram.step_jump (code r) .scan .erase (Function.update T r S) + (by simp [code, heads, hS, cleanAtom]) + +theorem step_erase_symbol (r : TapeRegister) (T : TapeTapes) (S : Tape TapeSymbol) + (hS : S.head.1 ≠ .home) : + (code r).step (cfg .erase (Function.update T r S)) = + some (cfg .erase (Function.update T r ((S.write blankSymbol).move .left))) := by + have h := TapeMultiProgram.step_writeMove (code r) .erase .erase + (Function.update T r S) r blankSymbol .left (by simp [code, heads, hS]) + simpa only [Function.update_self, Function.update_idem, HeadMove.apply_left] using h + +theorem step_erase_home (r : TapeRegister) (T : TapeTapes) (S : Tape TapeSymbol) + (hS : S.head.1 = .home) : + (code r).step (cfg .erase (Function.update T r S)) = + some (cfg .install (Function.update T r (S.move .right))) := by + have h := TapeMultiProgram.step_move (code r) .erase .install + (Function.update T r S) r .right (by simp [code, heads, hS]) + simpa only [Function.update_self, Function.update_idem, HeadMove.apply_right] using h + +theorem step_install (r : TapeRegister) (T : TapeTapes) (S : Tape TapeSymbol) : + (code r).step (cfg .install (Function.update T r S)) = + some (cfg .done (Function.update T r + ((S.write (cleanAtom .endMark)).move .left))) := by + have h := TapeMultiProgram.step_writeMove (code r) .install .done + (Function.update T r S) r (cleanAtom .endMark) .left (by rfl) + simpa only [Function.update_self, Function.update_idem, HeadMove.apply_left] using h + +theorem mk₂_append_blanks (L R : List TapeSymbol) (n : ℕ) : + Tape.mk₂ L (R ++ List.replicate n blankSymbol) = Tape.mk₂ L R := by + have h : ListBlank.mk (R ++ List.replicate n blankSymbol) = ListBlank.mk R := by + apply Quotient.sound' + exact Or.inr ⟨n, by simp only [default_tapeSymbol]⟩ + exact congrArg (Tape.mk' (ListBlank.mk L)) h + +theorem runs_scan (r : TapeRegister) (T : TapeTapes) (bits : List Bool) + (L : List TapeSymbol) : + RunsIn (code r).step + (cfg .scan (Function.update T r + (Tape.mk₂ L (encodeInput bits ++ [cleanAtom .endMark])))) + (cfg .erase (Function.update T r + (Tape.mk₂ ((encodeInput bits).reverse ++ L) [cleanAtom .endMark]))) + (bits.length + 1) := by + induction bits generalizing L with + | nil => + have h := RunsIn.single (step_scan_end r T (Tape.mk₂ L [cleanAtom .endMark]) rfl) + simpa only [encodeInput, List.map_nil, List.nil_append, List.reverse_nil, + List.length_nil, Nat.zero_add] using h + | cons b bits ih => + have hfirst := RunsIn.single (step_scan_bit r T + (Tape.mk₂ L (rawInputSymbol b :: (encodeInput bits ++ [cleanAtom .endMark]))) b rfl) + simp only [TapeWord.move_right_mk₂_cons] at hfirst + have hrest := ih (rawInputSymbol b :: L) + simpa only [encodeInput, List.map_cons, List.cons_append, List.reverse_cons, + List.append_assoc, List.nil_append, List.length_cons, Nat.add_comm, + Nat.add_left_comm, Nat.add_assoc] using hfirst.trans hrest + +theorem runs_finish (r : TapeRegister) (T : TapeTapes) (n : ℕ) : + RunsIn (code r).step + (cfg .erase (Function.update T r + (Tape.mk₂ [] (cleanAtom .home :: blankSymbol :: List.replicate n blankSymbol)))) + (cfg .done (Function.update T r (wordTape []))) 2 := by + have hfirst := RunsIn.single (step_erase_home r T + (Tape.mk₂ [] (cleanAtom .home :: blankSymbol :: List.replicate n blankSymbol)) rfl) + simp only [TapeWord.move_right_mk₂_cons] at hfirst + have hlast := RunsIn.single (step_install r T + (Tape.mk₂ [cleanAtom .home] (blankSymbol :: List.replicate n blankSymbol))) + simp only [TapeCopy.write_mk₂, List.tail_cons, TapeWord.move_left_mk₂_cons] at hlast + have ht : Tape.mk₂ [] (cleanAtom .home :: cleanAtom .endMark :: + List.replicate n blankSymbol) = wordTape [] := by + exact mk₂_append_blanks [] [cleanAtom .home, cleanAtom .endMark] n + rw [ht] at hlast + exact hfirst.trans hlast + +theorem runs_erase_back (r : TapeRegister) (T : TapeTapes) (bits : List Bool) + (a : TapeSymbol) (n : ℕ) (ha : a.1 ≠ .home) : + RunsIn (code r).step + (cfg .erase (Function.update T r + (Tape.mk₂ (encodeInput bits ++ [cleanAtom .home]) + (a :: List.replicate n blankSymbol)))) + (cfg .done (Function.update T r (wordTape []))) (bits.length + 3) := by + induction bits generalizing a n with + | nil => + have hfirst := RunsIn.single (step_erase_symbol r T + (Tape.mk₂ [cleanAtom .home] (a :: List.replicate n blankSymbol)) ha) + simp only [TapeCopy.write_mk₂, List.tail_cons, TapeWord.move_left_mk₂_cons] at hfirst + simpa only [encodeInput, List.map_nil, List.nil_append, List.length_nil, + Nat.zero_add] using hfirst.trans (runs_finish r T n) + | cons b bits ih => + have hfirst := RunsIn.single (step_erase_symbol r T + (Tape.mk₂ (rawInputSymbol b :: (encodeInput bits ++ [cleanAtom .home])) + (a :: List.replicate n blankSymbol)) ha) + simp only [TapeCopy.write_mk₂, List.tail_cons, TapeWord.move_left_mk₂_cons] at hfirst + have hrest := ih (rawInputSymbol b) (n + 1) (by simp [rawInputSymbol, cleanAtom]) + simp only [List.replicate_succ] at hrest + simpa only [encodeInput, List.map_cons, List.cons_append, List.length_cons, + Nat.add_comm, Nat.add_left_comm, Nat.add_assoc] using hfirst.trans hrest + +theorem runs_erase (r : TapeRegister) (T : TapeTapes) (bits : List Bool) : + RunsIn (code r).step + (cfg .start (Function.update T r (wordTape bits))) + (cfg .done (Function.update T r (wordTape []))) (2 * bits.length + 5) := by + have hstart := RunsIn.single (step_start r T (wordTape bits)) + have hscan := runs_scan r T bits [cleanAtom .home] + have hback := runs_erase_back r T bits.reverse (cleanAtom .endMark) 0 + (by simp [cleanAtom]) + have hreverse : encodeInput bits.reverse = (encodeInput bits).reverse := by + simp [encodeInput] + simp only [hreverse, List.length_reverse, List.replicate_zero] at hback + have hstart' : RunsIn (code r).step + (cfg .start (Function.update T r (wordTape bits))) + (cfg .scan (Function.update T r + (Tape.mk₂ [cleanAtom .home] (encodeInput bits ++ [cleanAtom .endMark])))) 1 := by + simpa only [wordTape_right, cursorTape, encodeInput, List.map_nil, + List.reverse_nil, List.nil_append] using hstart + simpa only [Nat.two_mul, Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using + (hstart'.trans hscan).trans hback + +@[simp] theorem step_done (r : TapeRegister) (T : TapeTapes) : + (code r).step (cfg .done T) = none := rfl + +end TapeErase +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeEvaluation.lean b/lean/OAI/Computability/DepthThree/TapeEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ca0d191c5f2a948d8f8aa0343fcea05ce78da20 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeEvaluation.lean @@ -0,0 +1,160 @@ +import OAI.Computability.DepthThree.TapeHashClean +import OAI.Computability.DepthThree.TapeHorner +import OAI.Computability.DepthThree.TapeOutput +import OAI.Computability.DepthThree.LanguageInputBlockWords + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeEvaluation + +open TapeMultiProgram TapeRouting TapeRegister + +structure Prepared (σ : TapeStore) (w : List Bool) : Prop where + workspace : TapeHornerMultiply.Workspace σ (decodeInput w).ringDegree + clean : TapeHornerPrepare.Clean σ + data_length : σ dataLength = List.replicate (decodeInput w).dataSize true + coefficient_count : σ coeffCount = List.replicate (decodeInput w).coefficientCount true + data_bits : σ dataBits = inputBlockData w .data + key_bits : σ keyBits = inputBlockData w .hash + polynomial_bits : σ polyBits = inputBlockData w .polynomial + coefficient_bits : σ coeffBits = inputBlockData w .coefficients + hash_empty : σ hashBits = [] + +abbrev WorkState := TapeHashClean.State ⊕ TapeHorner.State +abbrev State := WorkState ⊕ TapeOutput.State + +def work : TapeMultiProgram WorkState := + joinCode TapeHashClean.program TapeHorner.program (fun _ => TapeHorner.start) + +def program : TapeMultiProgram State := + joinCode work TapeOutput.program (fun _ => TapeOutput.start) + +def start : State := .inl (.inl TapeHashClean.start) +def done (answer : Bool) : State := .inr (TapeOutput.done answer) + +def acceptFlag : State → Bool + | .inr (.inr b) => b + | _ => false + +@[simp] theorem acceptFlag_done (b : Bool) : acceptFlag (done b) = b := rfl +@[simp] theorem program_done (b : Bool) (h : TapeHeads) : program (done b) h = none := rfl + +def hashWord (w : List Bool) : List Bool := + List.ofFn (wordHash (decodeInput w).hashSeed (decodeInput w).data) + +def evaluationWord (w : List Bool) : List Bool := List.ofFn (decodeInput w).evaluationBits + +def outputStore (σ : TapeStore) (w : List Bool) : TapeStore := + Function.update (Function.update σ hashBits (hashWord w)) accumBits (evaluationWord w) + +def cost (w : List Bool) : ℕ := + 210 * ((decodeInput w).dataSize + (decodeInput w).ringDegree + 1) ^ 3 + + TapeHorner.cost (decodeInput w).ringDegree (decodeInput w).coefficientCount + 7 + +theorem cost_le (w : List Bool) : cost w ≤ 20000 * (w.length + 1) ^ 4 := by + let d := (decodeInput w).dataSize + let r := (decodeInput w).ringDegree + let t := (decodeInput w).coefficientCount + let N := w.length + 1 + have hd : d ≤ w.length := by + have h := five_mul_dataDimension_le w.length + change dataDimension w.length ≤ w.length + omega + have hr : r ≤ d := hashDimension_le d + have ht : t ≤ d := independenceOrder_le d + have h3 := Nat.pow_le_pow_left (show d + r + 1 ≤ 2 * N by dsimp [N]; omega) 3 + have h4 := Nat.pow_le_pow_left (show r + t + 1 ≤ 2 * N by dsimp [N]; omega) 4 + have h34 : N ^ 3 ≤ N ^ 4 := Nat.pow_le_pow_right (by dsimp [N]; omega) (by decide) + have h14 : 1 ≤ N ^ 4 := by + simpa using Nat.pow_le_pow_left (show 1 ≤ N by dsimp [N]; omega) 4 + have hH := TapeHorner.cost_le r t + simp only [mul_pow, show (2 : ℕ) ^ 3 = 8 by decide] at h3 + simp only [mul_pow, show (2 : ℕ) ^ 4 = 16 by decide] at h4 + change 210 * (d + r + 1) ^ 3 + TapeHorner.cost r t + 7 ≤ 20000 * N ^ 4 + omega + +theorem runs_evaluate_cost (w : List Bool) (σ : TapeStore) + (hfit : InputFits w) (hprep : Prepared σ w) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg (done (language w)) (storeTapes (outputStore σ w))) (cost w) := by + let q := decodeInput w + let H := hashWord w + let E := evaluationWord w + let U := Function.update σ hashBits H + let V := outputStore σ w + have hhash := TapeHashClean.runs_wordHash σ q.hashSeed q.data + hprep.data_length hprep.workspace.degree hprep.workspace.indexA_empty + hprep.workspace.indexB_empty hprep.workspace.indexC_empty + hprep.workspace.scratch_empty hprep.hash_empty + (hprep.key_bits.trans (inputBlockData_hash_eq_ofFn hfit)) + (hprep.data_bits.trans (inputBlockData_data_eq_ofFn hfit)) + have hW : TapeHornerMultiply.Workspace U q.ringDegree := by + refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ + · simpa [U, ringDegree, hashBits] using hprep.workspace.degree + · simpa [U, loop0, hashBits] using hprep.workspace.loop0_empty + · simpa [U, loop1, hashBits] using hprep.workspace.loop1_empty + · simpa [U, indexA, hashBits] using hprep.workspace.indexA_empty + · simpa [U, indexB, hashBits] using hprep.workspace.indexB_empty + · simpa [U, indexC, hashBits] using hprep.workspace.indexC_empty + · simpa [U, scratchA, hashBits] using hprep.workspace.scratch_empty + · simpa [U, productBits, hashBits] using hprep.workspace.product_empty + have hC : TapeHornerPrepare.Clean U := by + refine ⟨?_, ?_, ?_, ?_, ?_, ?_⟩ + · simpa [U, loop2, hashBits] using hprep.clean.count + · simpa [U, loop3, hashBits] using hprep.clean.cursor + · simpa [U, loop4, hashBits] using hprep.clean.countScratch + · simpa [U, loop5, hashBits] using hprep.clean.mulScratch + · simpa [U, scratchB, hashBits] using hprep.clean.coefficient + · simpa [U, accumBits, hashBits] using hprep.clean.accumulator + have hhorner := TapeHorner.runs_horner U (inputBlockData w .polynomial) H + (decodedCoefficientBlocks w) q.ringDegree hW hC + (by simp [U, hprep.polynomial_bits, polyBits, hashBits]) (by simp [U]) + (by simpa [U, hprep.coefficient_bits, coeffBits, hashBits] using + inputBlockData_coefficients_eq_flatten hfit) + (by simpa [U, decodedCoefficientBlocks_length, coeffCount, hashBits] using + hprep.coefficient_count) + (inputBlockData_polynomial_length hfit) (by simp [H, hashWord, q]) + (decodedCoefficientBlocks_row_length w) + have hsemantic : hornerBitLists q.ringDegree (inputBlockData w .polynomial) H + (decodedCoefficientBlocks w) = E := by + simpa only [hashByUpdates_inputBlocks hfit, H, E, hashWord, evaluationWord, q] using + hornerBitLists_inputBlocks hfit + have hhorner' : RunsIn TapeHorner.program.step (cfg TapeHorner.start (storeTapes U)) + (cfg TapeHorner.done (storeTapes V)) (TapeHorner.cost q.ringDegree q.coefficientCount) := by + simpa only [hsemantic, decodedCoefficientBlocks_length, V, outputStore, U, E, H] using hhorner + have hwork := join_runs TapeHashClean.program TapeHorner.program + (fun _ => TapeHorner.start) hhash rfl hhorner' + have hlen : E.length = q.ringDegree := by simp [E, evaluationWord, q] + have hpos : 0 < E.length := by rw [hlen]; exact decoded_ringDegree_pos hfit + have hsplit : E = E.getD 0 false :: E.drop 1 := by + simpa using TapeNaturalAccess.split E 0 hpos + have hout := TapeOutput.runs_output V (E.getD 0 false) (E.drop 1) + (by simp [V, outputStore, hprep.workspace.indexA_empty, indexA, hashBits, accumBits]) + (by simpa [V, outputStore, E] using hsplit) + have hlanguage : language w = !(E.getD 0 false) := by + have hl := language_eq_final_bit hfit + rw [hashByUpdates_inputBlocks hfit] at hl + change language w = !((hornerBitLists q.ringDegree + (inputBlockData w .polynomial) H (decodedCoefficientBlocks w)).getD 0 false) at hl + simpa only [hsemantic] using hl + rw [← hlanguage] at hout + have hall := join_runs work TapeOutput.program (fun _ => TapeOutput.start) hwork rfl hout + have htime : (210 * (q.dataSize + q.ringDegree + 1) ^ 3 + 1 + + TapeHorner.cost q.ringDegree q.coefficientCount) + 1 + 5 = cost w := by + unfold cost + dsimp [q] + omega + simpa only [program, start, done, htime, V] using hall + +theorem runs_evaluate (w : List Bool) (σ : TapeStore) + (hfit : InputFits w) (hprep : Prepared σ w) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg (done (language w)) (storeTapes (outputStore σ w))) + (20000 * (w.length + 1) ^ 4) := + (runs_evaluate_cost w σ hfit hprep).mono (cost_le w) + +end TapeEvaluation +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeFill.lean b/lean/OAI/Computability/DepthThree/TapeFill.lean new file mode 100644 index 0000000000000000000000000000000000000000..9afe84c1f2830300bd901a7cca38061ddc8dcc3a --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeFill.lean @@ -0,0 +1,82 @@ +import OAI.Computability.DepthThree.TapeArithmetic + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeFill + +open Turing TapeMultiProgram TapeRouting TapeUnary TapeCopy TapeArithmetic + +def pushProgram (r : TapeRegister) (b : Bool) : TapeMultiProgram IncState + | .start, h => writeMove r (rawInputSymbol b) .left .newHome h + | .newHome, h => writeMove r (cleanAtom .home) .stay .done h + | .done, _ => none + +theorem runs_push (r : TapeRegister) (b : Bool) (T : TapeTapes) (bits : List Bool) + (hT : T r = wordTape bits) : + RunsIn (pushProgram r b).step (cfg IncState.start T) + (cfg IncState.done (Function.update T r (wordTape (b :: bits)))) 2 := by + let middle := ((T r).write (rawInputSymbol b)).move Dir.left + have h₁ := step_writeMove (pushProgram r b) IncState.start IncState.newHome + T r (rawInputSymbol b) HeadMove.left rfl + have h₂ := step_writeMove (pushProgram r b) IncState.newHome IncState.done + (Function.update T r middle) r (cleanAtom .home) HeadMove.stay rfl + have hm : middle.write (cleanAtom .home) = wordTape (b :: bits) := by + dsimp [middle] + rw [hT, prepend_home] + have h₁' : (pushProgram r b).step (cfg IncState.start T) = + some (cfg IncState.newHome (Function.update T r middle)) := h₁ + have h₂' : (pushProgram r b).step (cfg IncState.newHome (Function.update T r middle)) = + some (cfg IncState.done (Function.update T r (wordTape (b :: bits)))) := by + simpa only [Function.update_self, HeadMove.apply_stay, Function.update_idem, hm] using h₂ + exact (RunsIn.single h₁').trans (RunsIn.single h₂') + +abbrev FillState := LoopState DecState IncState + +def fillProgram (counter destination : TapeRegister) (b : Bool) : TapeMultiProgram FillState := + loopCode (decProgram counter) (pushProgram destination b) + DecState.start IncState.start decPositive + +def fillStart : FillState := loopTest DecState.start +def fillDone : FillState := loopDone + +theorem runs_fill {counter destination : TapeRegister} (hne : counter ≠ destination) + (b : Bool) (T : TapeTapes) (n : ℕ) (bits : List Bool) : + RunsIn (fillProgram counter destination b).step + (cfg fillStart (onPair counter destination T (counterTape n) (wordTape bits))) + (cfg fillDone (onPair counter destination T + (counterTape 0) (wordTape (List.replicate n b ++ bits)))) + (8 * n + 3) := by + induction n generalizing bits with + | zero => + have hd := decrement_empty counter + (onPair counter destination T (counterTape 0) (wordTape bits)) (by simp [counterTape]) + have he := loop_exit (decProgram counter) (pushProgram destination b) + DecState.start IncState.start decPositive hd rfl rfl + simpa only [fillProgram, fillStart, fillDone, List.replicate_zero, List.nil_append, + Nat.mul_zero, Nat.zero_add] using he + | succ n ih => + have hd := decrement_cons counter + (onPair counter destination T (counterTape (n + 1)) (wordTape bits)) + (List.replicate n true) true (by simp [counterTape, List.replicate_succ]) + simp only [update_onPair_src] at hd + have hp := runs_push destination b + (onPair counter destination T (counterTape n) (wordTape bits)) bits (by simp [hne]) + simp only [update_onPair_dst hne] at hp + have hit := loop_iter (decProgram counter) (pushProgram destination b) + DecState.start IncState.start decPositive hd rfl rfl hp rfl + have hrest := ih (b :: bits) + have hall := hit.trans hrest + have hword : List.replicate n b ++ b :: bits = List.replicate (n + 1) b ++ bits := by + rw [List.replicate_succ'] + simp only [List.append_assoc, List.cons_append, List.nil_append] + have htime : 4 + 1 + 2 + 1 + (8 * n + 3) = 8 * (n + 1) + 3 := by omega + simpa only [fillProgram, fillStart, fillDone, hword, htime] using hall + +@[simp] theorem fill_done (counter destination : TapeRegister) (b : Bool) (h : TapeHeads) : + fillProgram counter destination b fillDone h = none := rfl + +end TapeFill +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeForLoop.lean b/lean/OAI/Computability/DepthThree/TapeForLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..738a4ed71f7bcee76743a053a270175db6aed35c --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeForLoop.lean @@ -0,0 +1,135 @@ +import OAI.Computability.DepthThree.TapeRouting +import OAI.Computability.DepthThree.TapeUnary +import OAI.Computability.DepthThree.TapeUnaryCompare +import Mathlib.Data.Nat.Init +import Lean.Elab.Tactic.Omega + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 uDepth7 uDepth8 uDepth9 uDepth10 uDepth11 uDepth12 uDepth13 uDepth14 uDepth15 + +namespace DepthThreeLowerBound +namespace TapeForLoop + +open TapeMultiProgram TapeRouting TapeUnary + +abbrev BodyState (Q : Type uDepth1) := Q ⊕ IncState +abbrev State (Q : Type uDepth2) := LoopState TapeUnaryCompare.State (BodyState Q) + +def bodyProgram {Q : Type uDepth3} (r : TapeRegister) (P : TapeMultiProgram Q) : + TapeMultiProgram (BodyState Q) := + joinCode P (incProgram r) (fun _ => IncState.start) + +def bodyStart {Q : Type uDepth4} (q : Q) : BodyState Q := .inl q + +def bodyDone {Q : Type uDepth5} : BodyState Q := .inr .done + +def again : TapeUnaryCompare.State → Bool + | .done .lt => true + | _ => false + +def program {Q : Type uDepth6} (r s : TapeRegister) (P : TapeMultiProgram Q) + (qStart : Q) : TapeMultiProgram (State Q) := + loopCode (TapeUnaryCompare.program r s) (bodyProgram r P) + (.scan .beginR) (bodyStart qStart) again + +def start {Q : Type uDepth7} : State Q := loopTest (.scan .beginR) + +def done {Q : Type uDepth8} : State Q := loopDone + +@[simp] theorem body_done {Q : Type uDepth9} (r : TapeRegister) (P : TapeMultiProgram Q) + (h : TapeHeads) : bodyProgram r P bodyDone h = none := rfl + +@[simp] theorem program_done {Q : Type uDepth10} (r s : TapeRegister) + (P : TapeMultiProgram Q) (qStart : Q) (h : TapeHeads) : + program r s P qStart done h = none := rfl + +theorem runs_body {Q : Type uDepth11} (r : TapeRegister) (P : TapeMultiProgram Q) + (qStart qDone : Q) (T U : TapeTapes) (j B : ℕ) + (hU : U r = counterTape (j + 1)) + (hbody : RunsIn P.step (cfg qStart T) + (cfg qDone (Function.update U r (counterTape j))) B) + (hhalt : P qDone (heads (Function.update U r (counterTape j))) = none) : + RunsIn (bodyProgram r P).step (cfg (bodyStart qStart) T) + (cfg bodyDone U) (B + 3) := by + have hi := increment r (Function.update U r (counterTape j)) j + (Function.update_self _ _ _) + have hu : Function.update (Function.update U r (counterTape j)) r + (counterTape (j + 1)) = U := by + rw [Function.update_idem] + exact Function.update_eq_self_iff.mpr hU.symm + rw [hu] at hi + have h := join_runs P (incProgram r) (fun _ => IncState.start) hbody hhalt hi + simpa only [bodyProgram, bodyStart, bodyDone, Nat.add_assoc] using h + +theorem runs_iteration {Q : Type uDepth12} {r s : TapeRegister} (hrs : r ≠ s) + (P : TapeMultiProgram Q) (qStart qDone : Q) (T U : TapeTapes) (j n B : ℕ) + (hj : j < n) (hR : T r = counterTape j) (hS : T s = counterTape n) + (hU : U r = counterTape (j + 1)) + (hbody : RunsIn P.step (cfg qStart T) + (cfg qDone (Function.update U r (counterTape j))) B) + (hhalt : P qDone (heads (Function.update U r (counterTape j))) = none) : + RunsIn (program r s P qStart).step (cfg start T) (cfg start U) + (B + 4 * j + 12) := by + have ht := TapeUnaryCompare.runs_compare hrs T j n hR hS + have ho := (TapeUnaryCompareScan.result_eq_lt_iff j n).mpr hj + rw [Nat.min_eq_left hj.le, ho] at ht + have hb := runs_body r P qStart qDone T U j B hU hbody hhalt + have h := loop_iter (TapeUnaryCompare.program r s) (bodyProgram r P) + (.scan .beginR) (bodyStart qStart) again ht rfl rfl hb rfl + exact h.mono (by omega) + +theorem runs_exit {Q : Type uDepth13} {r s : TapeRegister} (hrs : r ≠ s) + (P : TapeMultiProgram Q) (qStart : Q) (T : TapeTapes) (n : ℕ) + (hR : T r = counterTape n) (hS : T s = counterTape n) : + RunsIn (program r s P qStart).step (cfg start T) (cfg done T) (4 * n + 8) := by + have ht := TapeUnaryCompare.runs_compare hrs T n n hR hS + have ho := (TapeUnaryCompareScan.result_eq_eq_iff n n).mpr rfl + rw [Nat.min_self, ho] at ht + have h := loop_exit (TapeUnaryCompare.program r s) (bodyProgram r P) + (.scan .beginR) (bodyStart qStart) again ht rfl rfl + exact h.mono (by omega) + +theorem runs {Q : Type uDepth14} {r s : TapeRegister} (hrs : r ≠ s) + (P : TapeMultiProgram Q) (qStart qDone : Q) (σ : ℕ → TapeTapes) (n B : ℕ) + (hindex : ∀ j ≤ n, σ j r = counterTape j) + (hbound : ∀ j ≤ n, σ j s = counterTape n) + (hbody : ∀ j < n, RunsIn P.step (cfg qStart (σ j)) + (cfg qDone (Function.update (σ (j + 1)) r (counterTape j))) B) + (hhalt : ∀ h, P qDone h = none) (i : ℕ) (hi : i ≤ n) : + RunsIn (program r s P qStart).step (cfg start (σ i)) (cfg done (σ n)) + ((n - i) * (B + 4 * n + 12) + (4 * n + 8)) := by + refine Nat.decreasingInduction (motive := fun j _ => + RunsIn (program r s P qStart).step (cfg start (σ j)) (cfg done (σ n)) + ((n - j) * (B + 4 * n + 12) + (4 * n + 8))) ?_ ?_ hi + · intro j hj ih + have hjn : j ≤ n := hj.le + have hstep := runs_iteration hrs P qStart qDone (σ j) (σ (j + 1)) j n B hj + (hindex j hjn) (hbound j hjn) (hindex (j + 1) hj) + (hbody j hj) (hhalt _) + have hstep' := hstep.mono (show B + 4 * j + 12 ≤ B + 4 * n + 12 by omega) + have hall := hstep'.trans ih + have hd : n - j = (n - (j + 1)) + 1 := by omega + apply hall.mono + rw [hd, Nat.add_mul, Nat.one_mul] + omega + · simpa only [Nat.sub_self, Nat.zero_mul, Nat.zero_add] using + runs_exit hrs P qStart (σ n) n (hindex n (Nat.le_refl n)) + (hbound n (Nat.le_refl n)) + +theorem runs_zero {Q : Type uDepth15} {r s : TapeRegister} (hrs : r ≠ s) + (P : TapeMultiProgram Q) (qStart qDone : Q) (σ : ℕ → TapeTapes) (n B : ℕ) + (hindex : ∀ j ≤ n, σ j r = counterTape j) + (hbound : ∀ j ≤ n, σ j s = counterTape n) + (hbody : ∀ j < n, RunsIn P.step (cfg qStart (σ j)) + (cfg qDone (Function.update (σ (j + 1)) r (counterTape j))) B) + (hhalt : ∀ h, P qDone h = none) : + RunsIn (program r s P qStart).step (cfg start (σ 0)) (cfg done (σ n)) + (n * (B + 4 * n + 12) + (4 * n + 8)) := by + simpa only [Nat.sub_zero] using + runs hrs P qStart qDone σ n B hindex hbound hbody hhalt 0 (Nat.zero_le n) + +end TapeForLoop +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHash.lean b/lean/OAI/Computability/DepthThree/TapeHash.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8889b9a51286a221741eac791492462e9d75786 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHash.lean @@ -0,0 +1,100 @@ +import OAI.Computability.DepthThree.TapeHashInitialize +import OAI.Computability.DepthThree.TapeHashOuter + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHash + +open TapeMultiProgram TapeRouting TapeRegister + +abbrev State := TapeHashInitialize.State ⊕ TapeHashOuter.State + +def program : TapeMultiProgram State := + joinCode TapeHashInitialize.program TapeHashOuter.program (fun _ => TapeHashOuter.start) + +def start : State := .inl TapeHashInitialize.start +def done : State := .inr TapeHashOuter.done + +def resultStore (σ : TapeStore) (r : ℕ) : TapeStore := + Function.update (Function.update σ hashBits (hashByUpdates r (σ keyBits) (σ dataBits))) + indexC (List.replicate r true) + +theorem cost_le (d r : ℕ) : + 10 * r + 8 + 1 + (r * (64 * (d + r + 1) ^ 2 + 4 * r + 12) + (4 * r + 8)) ≤ + 200 * (d + r + 1) ^ 3 := by + let N := d + r + 1 + have hN : 1 ≤ N := by dsimp [N]; omega + have hr : r ≤ N := by dsimp [N]; omega + have hsq : N ≤ N ^ 2 := by + have h := Nat.mul_le_mul_left N hN + simpa only [Nat.mul_one, pow_two] using h + have hterm : 64 * N ^ 2 + 4 * r + 12 ≤ 80 * N ^ 2 := by nlinarith + have hprod := Nat.mul_le_mul hr hterm + have hprod' : r * (64 * N ^ 2 + 4 * r + 12) ≤ 80 * N ^ 3 := by + calc + _ ≤ N * (80 * N ^ 2) := hprod + _ = _ := by ring + have hcube : N ≤ N ^ 3 := by + have h := Nat.mul_le_mul_left N (show 1 ≤ N ^ 2 by omega) + calc + N ≤ N * N ^ 2 := by simpa only [Nat.mul_one] using h + _ = N ^ 3 := by ring + change 10 * r + 8 + 1 + (r * (64 * N ^ 2 + 4 * r + 12) + (4 * r + 8)) ≤ 200 * N ^ 3 + nlinarith + +theorem runs_hash (σ : TapeStore) (d r : ℕ) + (hd : σ dataLength = List.replicate d true) + (hr : σ ringDegree = List.replicate r true) + (ha : σ indexA = []) (hb : σ indexB = []) (hc : σ indexC = []) + (hs : σ scratchA = []) (hh : σ hashBits = []) + (hkey : (σ keyBits).length = d + r - 1) (hdata : (σ dataBits).length = d) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (resultStore σ r))) (200 * (d + r + 1) ^ 3) := by + let τ := Function.update σ hashBits (List.replicate r false) + have hinit := TapeHashInitialize.runs_initialize σ r hr hs hh + have houter := TapeHashOuter.runs_outer τ d r + (by simp [τ, hd, dataLength, hashBits]) + (by simp [τ, hr, ringDegree, hashBits]) + (by simp [τ, ha, indexA, hashBits]) + (by simp [τ, hb, indexB, hashBits]) + (by simp [τ, hc, indexC, hashBits]) + (by simpa [τ, keyBits, hashBits] using hkey) + (by simpa [τ, dataBits, hashBits] using hdata) + (by simp [τ]) + have hall := join_runs TapeHashInitialize.program TapeHashOuter.program + (fun _ => TapeHashOuter.start) hinit rfl houter + have hstore : TapeHashOuter.progressStore τ r = resultStore σ r := by + funext q + by_cases hc' : q = indexC + · subst q + simp [TapeHashOuter.progressStore, resultStore] + · by_cases hh' : q = hashBits + · subst q + simp [TapeHashOuter.progressStore, resultStore, hashByUpdates, τ, + indexC, hashBits, keyBits, dataBits] + · simp [TapeHashOuter.progressStore, resultStore, τ, hc', hh'] + have hbounded := hall.mono (cost_le d r) + simpa only [program, start, done, hstore] using hbounded + +theorem runs_wordHash (σ : TapeStore) {d r : ℕ} + (u : BitWord (d + r - 1)) (x : BitWord d) + (hd : σ dataLength = List.replicate d true) + (hr : σ ringDegree = List.replicate r true) + (ha : σ indexA = []) (hb : σ indexB = []) (hc : σ indexC = []) + (hs : σ scratchA = []) (hh : σ hashBits = []) + (hkey : σ keyBits = List.ofFn u) (hdata : σ dataBits = List.ofFn x) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update (Function.update σ hashBits + (List.ofFn (wordHash u x))) indexC (List.replicate r true)))) + (200 * (d + r + 1) ^ 3) := by + have h := runs_hash σ d r hd hr ha hb hc hs hh + (by simp [hkey]) (by simp [hdata]) + simpa only [resultStore, hkey, hdata, hashByUpdates_ofFn_eq] using h + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeHash +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHashClean.lean b/lean/OAI/Computability/DepthThree/TapeHashClean.lean new file mode 100644 index 0000000000000000000000000000000000000000..31b86ca69fe963467ffd744f3d04337d021dc664 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHashClean.lean @@ -0,0 +1,66 @@ +import OAI.Computability.DepthThree.TapeHash + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHashClean + +open TapeMultiProgram TapeRouting TapeRegister + +abbrev State := TapeHash.State ⊕ TapeErase.State + +def program : TapeMultiProgram State := + joinCode TapeHash.program (TapeErase.code indexC) (fun _ => TapeErase.State.start) + +def start : State := .inl TapeHash.start +def done : State := .inr TapeErase.State.done + +theorem cost_le (d r : ℕ) : + 200 * (d + r + 1) ^ 3 + 1 + (2 * r + 5) ≤ 210 * (d + r + 1) ^ 3 := by + let N := d + r + 1 + have hN : 1 ≤ N := by dsimp [N]; omega + have hr : r < N := by dsimp [N]; omega + have hsq : N ≤ N ^ 2 := by + simpa only [Nat.mul_one, pow_two] using Nat.mul_le_mul_left N hN + have hcube : N ≤ N ^ 3 := by + have h := Nat.mul_le_mul_left N (show 1 ≤ N ^ 2 by omega) + calc + N ≤ N * N ^ 2 := by simpa only [Nat.mul_one] using h + _ = N ^ 3 := by ring + change 200 * N ^ 3 + 1 + (2 * r + 5) ≤ 210 * N ^ 3 + nlinarith + +theorem runs_wordHash (σ : TapeStore) {d r : ℕ} + (u : BitWord (d + r - 1)) (x : BitWord d) + (hd : σ dataLength = List.replicate d true) + (hr : σ ringDegree = List.replicate r true) + (ha : σ indexA = []) (hb : σ indexB = []) (hc : σ indexC = []) + (hs : σ scratchA = []) (hh : σ hashBits = []) + (hkey : σ keyBits = List.ofFn u) (hdata : σ dataBits = List.ofFn x) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update σ hashBits (List.ofFn (wordHash u x))))) + (210 * (d + r + 1) ^ 3) := by + let τ := Function.update (Function.update σ hashBits (List.ofFn (wordHash u x))) + indexC (List.replicate r true) + have hhash := TapeHash.runs_wordHash σ u x hd hr ha hb hc hs hh hkey hdata + have herase := TapeStoreRuns.erase indexC τ + have hall := join_runs TapeHash.program (TapeErase.code indexC) + (fun _ => TapeErase.State.start) hhash rfl herase + have hC : (Function.update σ hashBits (List.ofFn (wordHash u x))) indexC = [] := by + simp [hc, indexC, hashBits] + have hstore : Function.update τ indexC [] = + Function.update σ hashBits (List.ofFn (wordHash u x)) := by + simp only [τ, Function.update_idem, ← hC, Function.update_eq_self] + have hlen : (τ indexC).length = r := by simp [τ] + have hall' : RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update σ hashBits (List.ofFn (wordHash u x))))) + (200 * (d + r + 1) ^ 3 + 1 + (2 * r + 5)) := by + simpa only [program, start, done, hstore, hlen] using hall + exact hall'.mono (cost_le d r) + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeHashClean +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHashInitialize.lean b/lean/OAI/Computability/DepthThree/TapeHashInitialize.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a0602fe02133ef428176384b1bf5150c27956c3 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHashInitialize.lean @@ -0,0 +1,47 @@ +import OAI.Computability.DepthThree.TapeStoreRepresentation + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHashInitialize + +open TapeMultiProgram TapeRouting TapeRegister + +abbrev State := TapeCopy.State ⊕ TapeFill.FillState + +def program : TapeMultiProgram State := + joinCode (TapeCopy.code ringDegree scratchA) (TapeFill.fillProgram scratchA hashBits false) + (fun _ => TapeFill.fillStart) + +def start : State := .inl TapeCopy.State.start +def done : State := .inr TapeFill.fillDone + +theorem runs_initialize (σ : TapeStore) (r : ℕ) + (hr : σ ringDegree = List.replicate r true) + (hs : σ scratchA = []) (hh : σ hashBits = []) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update σ hashBits (List.replicate r false)))) + (10 * r + 8) := by + let τ := Function.update σ scratchA (σ ringDegree) + have hcopy := TapeStoreRuns.copy (by decide : ringDegree ≠ scratchA) σ hs + have hfill := TapeStoreRuns.fill (by decide : scratchA ≠ hashBits) false τ r + (by simp [τ, hr]) + have hall := join_runs (TapeCopy.code ringDegree scratchA) + (TapeFill.fillProgram scratchA hashBits false) (fun _ => TapeFill.fillStart) + hcopy rfl hfill + have hstore : Function.update (Function.update τ scratchA []) hashBits + (List.replicate r false ++ τ hashBits) = + Function.update σ hashBits (List.replicate r false) := by + have hreset : Function.update τ scratchA [] = σ := by + simp only [τ, Function.update_idem, ← hs, Function.update_eq_self] + rw [hreset] + simp [τ, hh, hashBits, scratchA] + have htime : 2 * r + 4 + 1 + (8 * r + 3) = 10 * r + 8 := by omega + simpa only [program, start, done, hstore, hr, List.length_replicate, htime] using hall + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeHashInitialize +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHashInner.lean b/lean/OAI/Computability/DepthThree/TapeHashInner.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb373c1247eec194a5cef82bad12b2009fedf6b9 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHashInner.lean @@ -0,0 +1,94 @@ +import OAI.Computability.DepthThree.TapeHashStep +import OAI.Computability.DepthThree.TapeForLoop +import OAI.Computability.DepthThree.LanguageBitHashUpdates + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHashInner + +open TapeMultiProgram TapeUnary TapeRegister + +abbrev State := TapeForLoop.State TapeHashStep.State + +def program : TapeMultiProgram State := + TapeForLoop.program indexB dataLength TapeHashStep.program TapeHashStep.start + +def start : State := TapeForLoop.start +def done : State := TapeForLoop.done + +def progressStore (σ : TapeStore) (i j : ℕ) : TapeStore := + Function.update (Function.update (Function.update σ hashBits + (hashUpdateRow (σ keyBits) (σ dataBits) i (List.range j) (σ hashBits))) + indexA (List.replicate (i + j) true)) indexB (List.replicate j true) + +theorem progress_zero (σ : TapeStore) (i : ℕ) + (ha : σ indexA = List.replicate i true) (hb : σ indexB = []) : + progressStore σ i 0 = σ := by + simp only [progressStore, List.range_zero, hashUpdateRow_nil, + Function.update_eq_self, Nat.add_zero, List.replicate_zero, ← ha, ← hb] + +theorem progress_step (σ : TapeStore) (i j : ℕ) : + TapeHashStep.resultStore (progressStore σ i j) i j = + Function.update (progressStore σ i (j + 1)) indexB (List.replicate j true) := by + funext r + by_cases hb : r = indexB + · subst r + simp [TapeHashStep.resultStore, progressStore, indexA, indexB, hashBits] + · by_cases ha : r = indexA + · subst r + simp [TapeHashStep.resultStore, progressStore, indexA, indexB, Nat.add_assoc] + · by_cases hh : r = hashBits + · subst r + simp [TapeHashStep.resultStore, progressStore, hashUpdateRow_range_succ, + indexA, indexB, hashBits, keyBits, dataBits] + · simp [TapeHashStep.resultStore, progressStore, hb, ha, hh] + +theorem runs_inner (σ : TapeStore) (i d r : ℕ) + (hi : i < r) (hd : σ dataLength = List.replicate d true) + (ha : σ indexA = List.replicate i true) (hb : σ indexB = []) + (hc : σ indexC = List.replicate i true) + (hkey : (σ keyBits).length = d + r - 1) + (hdata : (σ dataBits).length = d) (hout : (σ hashBits).length = r) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (progressStore σ i d))) + (d * (4 * i + 8 * d + 29) + 4 * d + 8) := by + let τ : ℕ → TapeTapes := fun j => storeTapes (progressStore σ i j) + have hindex : ∀ j ≤ d, τ j indexB = counterTape j := by + intro j hj + simp [τ, progressStore, counterTape] + have hbound : ∀ j ≤ d, τ j dataLength = counterTape d := by + intro j hj + simp [τ, progressStore, counterTape, hd, dataLength, indexA, indexB, hashBits] + have hbody : ∀ j < d, RunsIn TapeHashStep.program.step + (cfg TapeHashStep.start (τ j)) + (cfg TapeHashStep.done (Function.update (τ (j + 1)) indexB (counterTape j))) + (4 * i + 4 * d + 17) := by + intro j hj + have hkey' : i + j < (progressStore σ i j keyBits).length := by + simpa [progressStore, keyBits, indexA, indexB, hashBits, hkey] using + (hashReadIndex_lt hi hj) + have hdata' : j < (progressStore σ i j dataBits).length := by + simpa [progressStore, dataBits, indexA, indexB, hashBits, hdata] using hj + have hout' : i < (progressStore σ i j hashBits).length := by + simpa [progressStore, indexA, indexB, hashBits, hout] using hi + have hs := TapeHashStep.runs_step (progressStore σ i j) i j + (by simp [progressStore, indexA, indexB]) + (by simp [progressStore]) + (by simp [progressStore, hc, indexA, indexB, indexC, hashBits]) + hkey' hdata' hout' + have hs' := hs.mono (show 4 * i + 4 * j + 17 ≤ 4 * i + 4 * d + 17 by omega) + simpa only [τ, progress_step, storeTapes_update, counterTape] using hs' + have hall := TapeForLoop.runs_zero (by decide : indexB ≠ dataLength) + TapeHashStep.program TapeHashStep.start TapeHashStep.done τ d (4 * i + 4 * d + 17) + hindex hbound hbody TapeHashStep.program_done + have htime : d * (4 * i + 4 * d + 17 + 4 * d + 12) + (4 * d + 8) = + d * (4 * i + 8 * d + 29) + 4 * d + 8 := by ring + simpa only [program, start, done, τ, progress_zero σ i ha hb, htime] using hall + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeHashInner +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHashOuter.lean b/lean/OAI/Computability/DepthThree/TapeHashOuter.lean new file mode 100644 index 0000000000000000000000000000000000000000..702cc8218ed4fce028e1bef60e3ccf9bf066375c --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHashOuter.lean @@ -0,0 +1,92 @@ +import OAI.Computability.DepthThree.TapeHashRow + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHashOuter + +open TapeMultiProgram TapeUnary TapeRegister + +abbrev State := TapeForLoop.State TapeHashRow.State + +def program : TapeMultiProgram State := + TapeForLoop.program indexC ringDegree TapeHashRow.program TapeHashRow.start + +def start : State := TapeForLoop.start +def done : State := TapeForLoop.done + +def progressStore (σ : TapeStore) (i : ℕ) : TapeStore := + Function.update (Function.update σ hashBits + (hashUpdateRows (σ keyBits) (σ dataBits) (List.range i) (σ hashBits))) + indexC (List.replicate i true) + +theorem progress_zero (σ : TapeStore) (hc : σ indexC = []) : + progressStore σ 0 = σ := by + simp only [progressStore, List.range_zero, hashUpdateRows_nil, + Function.update_eq_self, List.replicate_zero, ← hc] + +theorem progress_step (σ : TapeStore) (i d : ℕ) (hd : (σ dataBits).length = d) : + TapeHashRow.resultStore (progressStore σ i) i d = + Function.update (progressStore σ (i + 1)) indexC (List.replicate i true) := by + funext q + by_cases hc : q = indexC + · subst q + simp [TapeHashRow.resultStore, progressStore, indexC, hashBits] + · by_cases hh : q = hashBits + · subst q + simp [TapeHashRow.resultStore, progressStore, hashUpdateRows_range_succ, hd, + indexC, hashBits, keyBits, dataBits] + · simp [TapeHashRow.resultStore, progressStore, hc, hh] + +theorem row_cost_le (i d r : ℕ) (hi : i ≤ r) : + d * (4 * i + 8 * d + 29) + 4 * i + 8 * d + 25 ≤ + 64 * (d + r + 1) ^ 2 := by + have hm := Nat.mul_le_mul_left d + (show 4 * i + 8 * d + 29 ≤ 4 * r + 8 * d + 29 by omega) + have hfirst : d * (4 * i + 8 * d + 29) + 4 * i + 8 * d + 25 ≤ + d * (4 * r + 8 * d + 29) + 4 * r + 8 * d + 25 := by omega + apply hfirst.trans + nlinarith [Nat.zero_le (d * r)] + +theorem runs_outer (σ : TapeStore) (d r : ℕ) + (hd : σ dataLength = List.replicate d true) + (hr : σ ringDegree = List.replicate r true) + (ha : σ indexA = []) (hb : σ indexB = []) (hc : σ indexC = []) + (hkey : (σ keyBits).length = d + r - 1) + (hdata : (σ dataBits).length = d) (hout : (σ hashBits).length = r) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (progressStore σ r))) + (r * (64 * (d + r + 1) ^ 2 + 4 * r + 12) + (4 * r + 8)) := by + let τ : ℕ → TapeTapes := fun i => storeTapes (progressStore σ i) + have hindex : ∀ i ≤ r, τ i indexC = counterTape i := by + intro i hi + simp [τ, progressStore, counterTape] + have hbound : ∀ i ≤ r, τ i ringDegree = counterTape r := by + intro i hi + simp [τ, progressStore, counterTape, hr, ringDegree, indexC, hashBits] + have hbody : ∀ i < r, RunsIn TapeHashRow.program.step + (cfg TapeHashRow.start (τ i)) + (cfg TapeHashRow.done (Function.update (τ (i + 1)) indexC (counterTape i))) + (64 * (d + r + 1) ^ 2) := by + intro i hi + have hs := TapeHashRow.runs_row (progressStore σ i) i d r hi + (by simp [progressStore, hd, dataLength, indexC, hashBits]) + (by simp [progressStore, ha, indexA, indexC, hashBits]) + (by simp [progressStore, hb, indexB, indexC, hashBits]) + (by simp [progressStore]) + (by simpa [progressStore, keyBits, indexC, hashBits] using hkey) + (by simpa [progressStore, dataBits, indexC, hashBits] using hdata) + (by simp [progressStore, hout, indexC, hashBits]) + have hs' := hs.mono (row_cost_le i d r hi.le) + simpa only [τ, progress_step σ i d hdata, storeTapes_update, counterTape] using hs' + have hall := TapeForLoop.runs_zero (by decide : indexC ≠ ringDegree) + TapeHashRow.program TapeHashRow.start TapeHashRow.done τ r (64 * (d + r + 1) ^ 2) + hindex hbound hbody TapeHashRow.program_done + simpa only [program, start, done, τ, progress_zero σ hc] using hall + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeHashOuter +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHashRow.lean b/lean/OAI/Computability/DepthThree/TapeHashRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ff4cf2f9f731c8dd9ab1fe0b532ac5f8c50b388 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHashRow.lean @@ -0,0 +1,93 @@ +import OAI.Computability.DepthThree.TapeHashInner + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHashRow + +open TapeMultiProgram TapeRouting TapeRegister + +abbrev RunState := TapeCopy.State ⊕ TapeHashInner.State +abbrev ClearState := RunState ⊕ TapeErase.State +abbrev State := ClearState ⊕ TapeErase.State + +def runProgram : TapeMultiProgram RunState := + joinCode (TapeCopy.code indexC indexA) TapeHashInner.program + (fun _ => TapeHashInner.start) + +def clearProgram : TapeMultiProgram ClearState := + joinCode runProgram (TapeErase.code indexA) (fun _ => TapeErase.State.start) + +def program : TapeMultiProgram State := + joinCode clearProgram (TapeErase.code indexB) (fun _ => TapeErase.State.start) + +def start : State := .inl (.inl (.inl TapeCopy.State.start)) +def done : State := .inr TapeErase.State.done + +def resultStore (σ : TapeStore) (i d : ℕ) : TapeStore := + Function.update σ hashBits + (hashUpdateRow (σ keyBits) (σ dataBits) i (List.range d) (σ hashBits)) + +theorem runs_row (σ : TapeStore) (i d r : ℕ) + (hi : i < r) (hd : σ dataLength = List.replicate d true) + (ha : σ indexA = []) (hb : σ indexB = []) + (hc : σ indexC = List.replicate i true) + (hkey : (σ keyBits).length = d + r - 1) + (hdata : (σ dataBits).length = d) (hout : (σ hashBits).length = r) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (resultStore σ i d))) + (d * (4 * i + 8 * d + 29) + 4 * i + 8 * d + 25) := by + let τ := Function.update σ indexA (σ indexC) + let τ₁ := TapeHashInner.progressStore τ i d + let τ₂ := Function.update τ₁ indexA [] + let τ₃ := Function.update τ₂ indexB [] + have hcopy := TapeStoreRuns.copy (by decide : indexC ≠ indexA) σ ha + have hinner := TapeHashInner.runs_inner τ i d r hi + (by simp [τ, hd, dataLength, indexA]) + (by simp [τ, hc]) + (by simp [τ, hb, indexA, indexB]) + (by simp [τ, hc, indexA, indexC]) + (by simpa [τ, indexA, keyBits] using hkey) + (by simpa [τ, indexA, dataBits] using hdata) + (by simpa [τ, indexA, hashBits] using hout) + have hrun := join_runs (TapeCopy.code indexC indexA) TapeHashInner.program + (fun _ => TapeHashInner.start) hcopy rfl hinner + have heraseA := TapeStoreRuns.erase indexA τ₁ + have hclear := join_runs runProgram (TapeErase.code indexA) + (fun _ => TapeErase.State.start) hrun rfl heraseA + have heraseB := TapeStoreRuns.erase indexB τ₂ + have hall := join_runs clearProgram (TapeErase.code indexB) + (fun _ => TapeErase.State.start) hclear rfl heraseB + have hstore : τ₃ = resultStore σ i d := by + funext q + by_cases hB : q = indexB + · subst q + simp [τ₃, resultStore, hb, indexB, hashBits] + · by_cases hA : q = indexA + · subst q + simp [τ₃, τ₂, resultStore, ha, indexA, indexB, hashBits] + · by_cases hH : q = hashBits + · subst q + simp [τ₃, τ₂, τ₁, TapeHashInner.progressStore, τ, resultStore, + indexA, indexB, hashBits, keyBits, dataBits] + · simp [τ₃, τ₂, τ₁, TapeHashInner.progressStore, τ, resultStore, hB, hA, hH] + have hlenC : (σ indexC).length = i := by simp [hc] + have hlenA : (τ₁ indexA).length = i + d := by + simp [τ₁, TapeHashInner.progressStore, indexA, indexB] + have hlenB : (τ₂ indexB).length = d := by + simp [τ₂, τ₁, TapeHashInner.progressStore, indexA, indexB] + have htime : ((2 * i + 4 + 1 + (d * (4 * i + 8 * d + 29) + 4 * d + 8)) + + 1 + (2 * (i + d) + 5)) + 1 + (2 * d + 5) = + d * (4 * i + 8 * d + 29) + 4 * i + 8 * d + 25 := by ring + have hall' : RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes τ₃)) + (d * (4 * i + 8 * d + 29) + 4 * i + 8 * d + 25) := by + simpa only [program, start, done, hlenC, hlenA, hlenB, htime] using hall + simpa only [hstore] using hall' + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeHashRow +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHashStep.lean b/lean/OAI/Computability/DepthThree/TapeHashStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f142ce9ad5cf6a916f475bdfee50313d99b101c --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHashStep.lean @@ -0,0 +1,52 @@ +import OAI.Computability.DepthThree.TapeNaturalAccess + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHashStep + +open TapeMultiProgram TapeRouting TapeUnary TapeRegister + +abbrev State := TapeProductTerm.State ⊕ IncState + +def program : TapeMultiProgram State := + joinCode (TapeProductTerm.program indexA keyBits indexB dataBits indexC hashBits) + (incProgram indexA) (fun _ => IncState.start) + +def start : State := .inl TapeProductTerm.start +def done : State := .inr IncState.done + +def resultStore (σ : TapeStore) (i j : ℕ) : TapeStore := + Function.update (Function.update σ hashBits + (xorListAt (σ hashBits) i ((σ keyBits).getD (i + j) false && (σ dataBits).getD j false))) + indexA (List.replicate (i + j + 1) true) + +theorem runs_step (σ : TapeStore) (i j : ℕ) + (ha : σ indexA = List.replicate (i + j) true) + (hb : σ indexB = List.replicate j true) + (hc : σ indexC = List.replicate i true) + (hkey : i + j < (σ keyBits).length) + (hdata : j < (σ dataBits).length) (hout : i < (σ hashBits).length) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (resultStore σ i j))) (4 * i + 4 * j + 17) := by + let τ := Function.update σ hashBits + (xorListAt (σ hashBits) i ((σ keyBits).getD (i + j) false && (σ dataBits).getD j false)) + have hterm := TapeNaturalAccess.productTerm indexA keyBits indexB dataBits indexC hashBits + (by decide) (by decide) (by decide) σ (i + j) j i ha hb hc hkey hdata hout + have hinc := increment indexA (storeTapes τ) (i + j) (by + simp [τ, ha, counterTape, indexA, hashBits]) + have hinc' : RunsIn (incProgram indexA).step (cfg IncState.start (storeTapes τ)) + (cfg IncState.done (storeTapes (resultStore σ i j))) 2 := by + simpa only [resultStore, τ, storeTapes_update, counterTape] using hinc + have hall := join_runs + (TapeProductTerm.program indexA keyBits indexB dataBits indexC hashBits) + (incProgram indexA) (fun _ => IncState.start) hterm rfl hinc' + have htime : 2 * ((i + j) + j + i) + 14 + 1 + 2 = 4 * i + 4 * j + 17 := by omega + simpa only [program, start, done, htime] using hall + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeHashStep +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHorner.lean b/lean/OAI/Computability/DepthThree/TapeHorner.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e83978f56cca79c03a1f2c294c5464eca89e26f --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHorner.lean @@ -0,0 +1,62 @@ +import OAI.Computability.DepthThree.TapeHornerPrepare + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHorner + +open TapeMultiProgram TapeRouting TapeRegister TapeHornerMultiply + +abbrev State := TapeHornerPrepare.State ⊕ TapeHornerLoop.State + +def program : TapeMultiProgram State := + joinCode TapeHornerPrepare.program TapeHornerLoop.program (fun _ => TapeHornerLoop.start) + +def start : State := .inl TapeHornerPrepare.start +def done : State := .inr TapeHornerLoop.done + +def cost (r t : ℕ) : ℕ := + TapeHornerPrepare.cost r t + t * (TapeHornerBody.cost r (t * r) + 6) + 4 + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +theorem cost_le (r t : ℕ) : cost r t ≤ 1000 * (r + t + 1) ^ 4 := by + unfold cost TapeHornerPrepare.cost TapeHornerBody.cost TapeHornerMultiply.cost + TapeConvolve.cost TapeRemainder.cost TapeRemainderOuter.iterationCost + ring_nf + omega + +theorem runs_horner (σ : TapeStore) (p h : List Bool) (blocks : List (List Bool)) (r : ℕ) + (hW : Workspace σ r) (hC : TapeHornerPrepare.Clean σ) + (hP : σ polyBits = p) (hH : σ hashBits = h) + (hB : σ coeffBits = blocks.flatten) + (hT : σ coeffCount = List.replicate blocks.length true) + (hp : p.length = r) (hh : h.length = r) + (hblocks : ∀ b ∈ blocks, b.length = r) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update σ accumBits (hornerBitLists r p h blocks)))) + (cost r blocks.length) := by + have hlen := block_flatten_length r blocks hblocks + have hpref := TapeHornerPrepare.runs_prepare σ r blocks.length hW hC hT + have hl := TapeHornerLoop.runs_loop σ p h blocks [] (List.replicate r false) + r (blocks.length * r) hW hP hH hp hh (by simp) hblocks + (by simpa only [List.append_nil] using hB) (by omega) hC.countScratch hC.coefficient + rw [hlen, hornerFrom_zero_eq_hornerBitLists r p h blocks hblocks] at hl + have hfinal : TapeHornerLoop.frame σ 0 0 (hornerBitLists r p h blocks) = + Function.update σ accumBits (hornerBitLists r p h blocks) := by + funext q + by_cases h2 : q = loop2 <;> by_cases h3 : q = loop3 <;> by_cases ha : q = accumBits <;> + simp_all [TapeHornerLoop.frame, Function.update, hC.count, hC.cursor, + loop2, loop3, accumBits] + rw [hfinal] at hl + have hall := join_runs TapeHornerPrepare.program TapeHornerLoop.program + (fun _ => TapeHornerLoop.start) hpref rfl hl + have ht : TapeHornerPrepare.cost r blocks.length + 1 + + (blocks.length * (TapeHornerBody.cost r (blocks.length * r) + 6) + 3) = + cost r blocks.length := by unfold cost; omega + simpa only [program, start, done, ht] using hall + +end TapeHorner +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHornerBody.lean b/lean/OAI/Computability/DepthThree/TapeHornerBody.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c16dfe5d80cb772b5de27b4522b2148dc9c9e3e --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHornerBody.lean @@ -0,0 +1,96 @@ +import OAI.Computability.DepthThree.TapeHornerExtract +import OAI.Computability.DepthThree.TapeHornerMultiply +import OAI.Computability.DepthThree.TapeXor +import OAI.Computability.DepthThree.LanguageBitHornerLoop + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHornerBody + +open TapeMultiProgram TapeRouting TapeRegister TapeHornerMultiply + +abbrev ProductState := TapeHornerExtract.State ⊕ TapeHornerMultiply.State +abbrev WorkState := ProductState ⊕ TapeXor.State +abbrev State := WorkState ⊕ TapeErase.State + +def product : TapeMultiProgram ProductState := + joinCode TapeHornerExtract.program TapeHornerMultiply.program + (fun _ => TapeHornerMultiply.start) + +def work : TapeMultiProgram WorkState := + joinCode product (TapeXor.program scratchB accumBits) (fun _ => TapeXor.start) + +def program : TapeMultiProgram State := + joinCode work (TapeErase.code scratchB) (fun _ => TapeErase.State.start) + +def start : State := .inl (.inl (.inl TapeHornerExtract.start)) +def done : State := .inr TapeErase.State.done + +def cost (r offset : ℕ) : ℕ := + r * (2 * offset + r + 19) + TapeHornerMultiply.cost r + 4 * r + 20 + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +theorem runs_body (σ : TapeStore) (p h a «prefix» b suffix : List Bool) (r : ℕ) + (hW : Workspace σ r) (hP : σ polyBits = p) (hH : σ hashBits = h) + (hA : σ accumBits = a) (hp : p.length = r) (hh : h.length = r) + (ha : a.length = r) (hb : b.length = r) + (hsource : σ coeffBits = «prefix» ++ b ++ suffix) + (hcursor : σ loop3 = List.replicate («prefix».length + r) true) + (hcount : σ loop4 = []) (hbuffer : σ scratchB = []) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update + (Function.update σ loop3 (List.replicate «prefix».length true)) + accumBits (hornerStep r p h b a)))) (cost r «prefix».length) := by + let U := Function.update (Function.update σ loop3 (List.replicate «prefix».length true)) + scratchB b + let V := Function.update U accumBits (multiplyBitLists r p h a) + let W := Function.update V accumBits (hornerStep r p h b a) + have he := TapeHornerExtract.runs_extract σ «prefix» b suffix r hsource hcursor + hW.degree hb hcount hbuffer + have hU : Workspace U r := by + rcases hW with ⟨hd, h0, h1, hi, hj, hk, hs, ho⟩ + constructor <;> + simp_all [U, Function.update, loop3, scratchB, ringDegree, loop0, loop1, + indexA, indexB, indexC, scratchA, productBits] + have hm := TapeHornerMultiply.runs_multiply U p h a r hU + (by simp [U, hP, polyBits, loop3, scratchB]) + (by simp [U, hH, hashBits, loop3, scratchB]) + (by simp [U, hA, accumBits, loop3, scratchB]) hp hh ha + have hprod := join_runs TapeHornerExtract.program TapeHornerMultiply.program + (fun _ => TapeHornerMultiply.start) he rfl hm + have hx := TapeXor.runs_store (src := scratchB) (dst := accumBits) (by decide) + V b (multiplyBitLists r p h a) + (by simp [V, U, scratchB, accumBits]) (by simp [V]) + (by simp [hb]) + have hx' : RunsIn (TapeXor.program scratchB accumBits).step + (cfg TapeXor.start (storeTapes V)) (cfg TapeXor.done (storeTapes W)) + (2 * r + 4) := by + simpa only [W, hornerStep, hb] using hx + have hw := join_runs product (TapeXor.program scratchB accumBits) + (fun _ => TapeXor.start) hprod rfl hx' + have hclear := TapeStoreRuns.erase scratchB W + have hclear' : RunsIn (TapeErase.code scratchB).step + (cfg TapeErase.State.start (storeTapes W)) + (cfg TapeErase.State.done (storeTapes (Function.update W scratchB []))) + (2 * r + 5) := by + simpa [W, V, U, hb, scratchB, accumBits] using hclear + have hall := join_runs work (TapeErase.code scratchB) + (fun _ => TapeErase.State.start) hw rfl hclear' + have hfinal : Function.update W scratchB [] = + Function.update (Function.update σ loop3 (List.replicate «prefix».length true)) + accumBits (hornerStep r p h b a) := by + funext q + by_cases hb' : q = scratchB <;> by_cases ha' : q = accumBits <;> + by_cases hl : q = loop3 <;> + simp_all [W, V, U, Function.update, scratchB, accumBits, loop3] + have htime : ((r * (2 * «prefix».length + r + 19) + 8 + 1 + + TapeHornerMultiply.cost r) + 1 + (2 * r + 4)) + 1 + (2 * r + 5) = + cost r «prefix».length := by unfold cost; omega + simpa only [program, start, done, hfinal, htime] using hall + +end TapeHornerBody +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHornerExtract.lean b/lean/OAI/Computability/DepthThree/TapeHornerExtract.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1858f8e67f230f221273a3d4a0bf9d4f2879bd9 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHornerExtract.lean @@ -0,0 +1,70 @@ +import OAI.Computability.DepthThree.TapeInputBlocks + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHornerExtract + +open TapeMultiProgram TapeRouting TapeRegister TapeInputBlockLoop + +def registers : Registers where + toFun i := match i.val with + | 0 => coeffBits + | 1 => loop3 + | 2 => loop4 + | 3 => loop5 + | _ => scratchB + inj' := by decide + +abbrev State := TapeCopy.State ⊕ TapeInputBlockLoop.State + +def program : TapeMultiProgram State := + joinCode (TapeCopy.code ringDegree loop4) (TapeInputBlockLoop.program registers) + (fun _ => TapeInputBlockLoop.start) + +def start : State := .inl TapeCopy.State.start +def done : State := .inr TapeInputBlockLoop.done + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +theorem runs_extract (σ : TapeStore) («prefix» block suffix : List Bool) (r : ℕ) + (hsource : σ coeffBits = «prefix» ++ block ++ suffix) + (hcursor : σ loop3 = List.replicate («prefix».length + r) true) + (hdegree : σ ringDegree = List.replicate r true) + (hblock : block.length = r) (hcount : σ loop4 = []) + (hdest : σ scratchB = []) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update + (Function.update σ loop3 (List.replicate «prefix».length true)) scratchB block))) + (r * (2 * «prefix».length + r + 19) + 8) := by + let U := Function.update σ loop4 (List.replicate r true) + have hc := TapeStoreRuns.copy (src := ringDegree) (dst := loop4) (by decide) σ hcount + have hc' : RunsIn (TapeCopy.code ringDegree loop4).step + (cfg TapeCopy.State.start (storeTapes σ)) (cfg TapeCopy.State.done (storeTapes U)) + (2 * r + 4) := by + simpa only [hdegree, List.length_replicate] using hc + have hb := TapeInputBlockLoop.runs_block registers σ «prefix» block suffix [] hsource + have hi : blockStore registers σ («prefix».length + block.length) block.length [] = U := by + funext q + by_cases h4 : q = loop4 <;> by_cases h3 : q = loop3 <;> + by_cases hd : q = scratchB <;> + simp_all [blockStore, registers, count, index, destination, U, Function.update_apply, + loop4, loop3, scratchB] + have ho : blockStore registers σ «prefix».length 0 (block ++ []) = + Function.update (Function.update σ loop3 (List.replicate «prefix».length true)) + scratchB block := by + funext q + by_cases h4 : q = loop4 <;> by_cases h3 : q = loop3 <;> + by_cases hd : q = scratchB <;> + simp_all [blockStore, registers, count, index, destination, Function.update_apply] + rw [hi, ho, hblock] at hb + have hall := join_runs (TapeCopy.code ringDegree loop4) + (TapeInputBlockLoop.program registers) (fun _ => TapeInputBlockLoop.start) hc' rfl hb + have ht : (2 * r + 4) + 1 + (r * (2 * «prefix».length + r + 17) + 3) = + r * (2 * «prefix».length + r + 19) + 8 := by ring + simpa only [program, start, done, ht] using hall + +end TapeHornerExtract +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHornerLoop.lean b/lean/OAI/Computability/DepthThree/TapeHornerLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..518052cc7abbe6993d9932da57a373e9e2699e15 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHornerLoop.lean @@ -0,0 +1,131 @@ +import OAI.Computability.DepthThree.TapeHornerBody + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHornerLoop + +open TapeMultiProgram TapeRouting TapeRegister TapeUnary TapeArithmetic TapeHornerMultiply + +abbrev State := LoopState DecState TapeHornerBody.State + +def program : TapeMultiProgram State := + loopCode (decProgram loop2) TapeHornerBody.program DecState.start TapeHornerBody.start + decPositive + +def start : State := loopTest DecState.start +def done : State := loopDone + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +def frame (σ : TapeStore) (remaining offset : ℕ) (a : List Bool) : TapeStore := + Function.update (Function.update (Function.update σ loop2 (List.replicate remaining true)) + loop3 (List.replicate offset true)) accumBits a + +@[simp] theorem frame_count (σ : TapeStore) (k j : ℕ) (a : List Bool) : + frame σ k j a loop2 = List.replicate k true := by + simp [frame, loop2, loop3, accumBits] + +@[simp] theorem frame_cursor (σ : TapeStore) (k j : ℕ) (a : List Bool) : + frame σ k j a loop3 = List.replicate j true := by + simp [frame, loop2, loop3, accumBits] + +@[simp] theorem frame_accum (σ : TapeStore) (k j : ℕ) (a : List Bool) : + frame σ k j a accumBits = a := by simp [frame] + +theorem frame_workspace (σ : TapeStore) (k j r : ℕ) (a : List Bool) + (hW : Workspace σ r) : Workspace (frame σ k j a) r := by + rcases hW with ⟨hd, h0, h1, hi, hj, hk, hs, ho⟩ + constructor <;> + simp_all [frame, Function.update, loop2, loop3, accumBits, ringDegree, loop0, loop1, + indexA, indexB, indexC, scratchA, productBits] + +@[simp] theorem update_frame_count (σ : TapeStore) (k k' j : ℕ) (a : List Bool) : + Function.update (frame σ k j a) loop2 (List.replicate k' true) = frame σ k' j a := by + funext q + by_cases h2 : q = loop2 <;> by_cases h3 : q = loop3 <;> by_cases ha : q = accumBits <;> + simp_all [frame, Function.update, loop2, loop3, accumBits] + +@[simp] theorem update_frame_cursor (σ : TapeStore) (k j j' : ℕ) (a : List Bool) : + Function.update (frame σ k j a) loop3 (List.replicate j' true) = frame σ k j' a := by + funext q + by_cases h3 : q = loop3 <;> by_cases ha : q = accumBits <;> + simp_all [frame, Function.update, loop2, loop3, accumBits] + +@[simp] theorem update_frame_accum (σ : TapeStore) (k j : ℕ) (a b : List Bool) : + Function.update (frame σ k j a) accumBits b = frame σ k j b := by + simp only [frame, Function.update_idem] + +theorem body_cost_mono (r m n : ℕ) (hmn : m ≤ n) : + TapeHornerBody.cost r m ≤ TapeHornerBody.cost r n := by + have hm : r * (2 * m + r + 19) ≤ r * (2 * n + r + 19) := + Nat.mul_le_mul_left r (by omega) + unfold TapeHornerBody.cost + omega + +theorem runs_loop (σ : TapeStore) (p h : List Bool) (bs : List (List Bool)) + (suffix a : List Bool) (r N : ℕ) + (hW : Workspace σ r) (hP : σ polyBits = p) (hH : σ hashBits = h) + (hp : p.length = r) (hh : h.length = r) (ha : a.length = r) + (hblocks : ∀ b ∈ bs, b.length = r) + (hsource : σ coeffBits = bs.flatten ++ suffix) + (hN : bs.flatten.length ≤ N) (hcount : σ loop4 = []) (hbuffer : σ scratchB = []) : + RunsIn program.step + (cfg start (storeTapes (frame σ bs.length bs.flatten.length a))) + (cfg done (storeTapes (frame σ 0 0 (hornerFrom r p h bs a)))) + (bs.length * (TapeHornerBody.cost r N + 6) + 3) := by + induction bs using List.reverseRecOn generalizing suffix a with + | nil => + have hd := decrement_empty loop2 (storeTapes (frame σ 0 0 a)) + (by simp []) + have he := loop_exit (decProgram loop2) TapeHornerBody.program + DecState.start TapeHornerBody.start decPositive hd rfl rfl + simpa [program, start, done] using he + | append_singleton bs b ih => + have hb : b.length = r := hblocks b (by simp) + have hbs : ∀ c ∈ bs, c.length = r := fun c hc => + hblocks c (List.mem_append_left [b] hc) + have hlen : (bs ++ [b]).flatten.length = bs.flatten.length + r := by + simp [hb] + have hsrc : σ coeffBits = bs.flatten ++ b ++ suffix := by + simpa only [List.flatten_append, List.flatten_singleton] using hsource + have hNb : bs.flatten.length ≤ N := by rw [hlen] at hN; omega + have hd := decrement loop2 + (storeTapes (frame σ (bs.length + 1) (bs.flatten.length + r) a)) + (bs.length + 1) (by simp [counterTape]) + have hd' : RunsIn (decProgram loop2).step + (cfg DecState.start (storeTapes (frame σ (bs.length + 1) (bs.flatten.length + r) a))) + (cfg (DecState.done true) (storeTapes (frame σ bs.length (bs.flatten.length + r) a))) 4 := by + simpa only [Nat.add_sub_cancel, Nat.zero_lt_succ, decide_true, + counterTape, ← storeTapes_update, update_frame_count] using hd + have hbody := TapeHornerBody.runs_body + (frame σ bs.length (bs.flatten.length + r) a) p h a bs.flatten b suffix r + (frame_workspace σ _ _ r a hW) + (by simp [frame, hP, polyBits, loop2, loop3, accumBits]) + (by simp [frame, hH, hashBits, loop2, loop3, accumBits]) + (by simp) hp hh ha hb + (by simp [frame, hsrc, coeffBits, loop2, loop3, accumBits]) + (by simp) + (by simp [frame, hcount, loop4, loop2, loop3, accumBits]) + (by simp [frame, hbuffer, scratchB, loop2, loop3, accumBits]) + simp only [update_frame_cursor, update_frame_accum] at hbody + have hbody' := hbody.mono (body_cost_mono r bs.flatten.length N hNb) + have hit := loop_iter (decProgram loop2) TapeHornerBody.program + DecState.start TapeHornerBody.start decPositive hd' rfl rfl hbody' rfl + have hsrc' : σ coeffBits = bs.flatten ++ (b ++ suffix) := by + simpa only [List.append_assoc] using hsrc + have hrest := ih (suffix := b ++ suffix) (a := hornerStep r p h b a) + (hornerStep_length r p h b a hb) hbs hsrc' hNb + have hall := hit.trans hrest + have ht : (4 + 1 + TapeHornerBody.cost r N + 1) + + (bs.length * (TapeHornerBody.cost r N + 6) + 3) = + (bs.length + 1) * (TapeHornerBody.cost r N + 6) + 3 := by + rw [Nat.add_mul, Nat.one_mul] + omega + simpa only [program, start, done, List.length_append, List.length_singleton, hlen, + hornerFrom_append_singleton, ht] using hall + +end TapeHornerLoop +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHornerMultiply.lean b/lean/OAI/Computability/DepthThree/TapeHornerMultiply.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3f72ba3b365510e2177e9d23e9da55aac610190 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHornerMultiply.lean @@ -0,0 +1,95 @@ +import OAI.Computability.DepthThree.TapeConvolve +import OAI.Computability.DepthThree.TapeRemainder +import OAI.Computability.DepthThree.TapeHornerTake +import OAI.Computability.DepthThree.LanguageBitReductionLoop + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHornerMultiply + +open TapeMultiProgram TapeRouting TapeRegister + +structure Workspace (σ : TapeStore) (r : ℕ) : Prop where + degree : σ ringDegree = List.replicate r true + loop0_empty : σ loop0 = [] + loop1_empty : σ loop1 = [] + indexA_empty : σ indexA = [] + indexB_empty : σ indexB = [] + indexC_empty : σ indexC = [] + scratch_empty : σ scratchA = [] + product_empty : σ productBits = [] + +abbrev WorkState := TapeConvolve.State ⊕ TapeRemainder.State +abbrev State := WorkState ⊕ TapeHornerTake.State + +def work : TapeMultiProgram WorkState := + joinCode TapeConvolve.program TapeRemainder.program (fun _ => TapeRemainder.start) + +def program : TapeMultiProgram State := + joinCode work TapeHornerTake.program (fun _ => TapeHornerTake.start) + +def start : State := .inl (.inl TapeConvolve.start) +def done : State := .inr TapeHornerTake.done + +def cost (r : ℕ) : ℕ := + TapeConvolve.cost r + TapeRemainder.cost r + r * (r + 27) + 8 * r + 31 + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +theorem runs_multiply (σ : TapeStore) (p h a : List Bool) (r : ℕ) + (hW : Workspace σ r) (hP : σ polyBits = p) (hH : σ hashBits = h) + (hA : σ accumBits = a) (hp : p.length = r) (hh : h.length = r) + (ha : a.length = r) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update σ accumBits (multiplyBitLists r p h a)))) + (cost r) := by + let c := convolveBitLists h a + let U := Function.update σ productBits c + let v := reduceByUpdates p r c + let V := Function.update σ productBits v + have hc := TapeConvolve.runs_convolve σ h a r hH hA hh ha hW.degree + hW.loop0_empty hW.loop1_empty hW.indexA_empty hW.indexB_empty + hW.indexC_empty hW.scratch_empty hW.product_empty + have hc' : RunsIn TapeConvolve.program.step (cfg TapeConvolve.start (storeTapes σ)) + (cfg TapeConvolve.done (storeTapes U)) (TapeConvolve.cost r) := hc + have hr := TapeRemainder.runs_remainder U p c + (by simp [U, hP, polyBits, productBits]) (by simp [U]) + (by simp [U, hp, hW.degree, ringDegree, productBits]) + (by simp [c, hp, hh, ha, Nat.two_mul]) + (by simp [U, hW.loop0_empty, loop0, productBits]) + (by simp [U, hW.loop1_empty, loop1, productBits]) + (by simp [U, hW.indexA_empty, indexA, productBits]) + (by simp [U, hW.indexB_empty, indexB, productBits]) + (by simp [U, hW.indexC_empty, indexC, productBits]) + (by simp [U, hW.scratch_empty, scratchA, productBits]) + have hr' : RunsIn TapeRemainder.program.step (cfg TapeRemainder.start (storeTapes U)) + (cfg TapeRemainder.done (storeTapes V)) (TapeRemainder.cost r) := by + simpa only [U, V, v, hp, Function.update_idem] using hr + have hw := join_runs TapeConvolve.program TapeRemainder.program + (fun _ => TapeRemainder.start) hc' rfl hr' + have hvlen : v.length = 2 * r := by + simp [v, c, reduceByUpdates_length, hh, ha, Nat.two_mul] + have ht := TapeHornerTake.runs_take V a v r + (by simp [V, hA, accumBits, productBits]) (by simp [V]) ha hvlen + (by simp [V, hW.degree, ringDegree, productBits]) + (by simp [V, hW.loop1_empty, loop1, productBits]) + (by simp [V, hW.indexA_empty, indexA, productBits]) + (by simp [V, hW.scratch_empty, scratchA, productBits]) + have hv : v.take r = multiplyBitLists r p h a := + reduceByUpdates_convolve_eq_multiplyBitLists r p h a hp hh ha + have hfinal : Function.update (Function.update V accumBits (v.take r)) productBits [] = + Function.update σ accumBits (multiplyBitLists r p h a) := by + funext q + by_cases hprod : q = productBits <;> by_cases hacc : q = accumBits <;> + simp_all [V, Function.update, hW.product_empty, accumBits, productBits] + rw [hfinal] at ht + have hall := join_runs work TapeHornerTake.program (fun _ => TapeHornerTake.start) hw rfl ht + have htime : (TapeConvolve.cost r + 1 + TapeRemainder.cost r) + 1 + + (r * (r + 27) + 8 * r + 29) = cost r := by unfold cost; omega + simpa only [program, start, done, htime] using hall + +end TapeHornerMultiply +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHornerPrepare.lean b/lean/OAI/Computability/DepthThree/TapeHornerPrepare.lean new file mode 100644 index 0000000000000000000000000000000000000000..9eb78ffcf0c81f24f45843d761f7abf6e999bd77 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHornerPrepare.lean @@ -0,0 +1,129 @@ +import OAI.Computability.DepthThree.TapeHornerLoop +import OAI.Computability.DepthThree.TapeMultiply + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHornerPrepare + +open TapeMultiProgram TapeRouting TapeRegister TapeUnary TapeHornerMultiply + +structure Clean (σ : TapeStore) : Prop where + count : σ loop2 = [] + cursor : σ loop3 = [] + countScratch : σ loop4 = [] + mulScratch : σ loop5 = [] + coefficient : σ scratchB = [] + accumulator : σ accumBits = [] + +abbrev ZeroState := TapeCopy.State ⊕ TapeFill.FillState +abbrev CountState := ZeroState ⊕ TapeCopy.State +abbrev CursorState := CountState ⊕ TapeCopy.State +abbrev State := CursorState ⊕ TapeMultiply.State + +def zeroProgram : TapeMultiProgram ZeroState := + joinCode (TapeCopy.code ringDegree scratchA) (TapeFill.fillProgram scratchA accumBits false) + (fun _ => TapeFill.fillStart) + +def countProgram : TapeMultiProgram CountState := + joinCode zeroProgram (TapeCopy.code coeffCount loop2) (fun _ => TapeCopy.State.start) + +def cursorProgram : TapeMultiProgram CursorState := + joinCode countProgram (TapeCopy.code coeffCount loop4) (fun _ => TapeCopy.State.start) + +def program : TapeMultiProgram State := + joinCode cursorProgram (TapeMultiply.program loop4 ringDegree loop5 loop3) + (fun _ => TapeMultiply.start) + +def start : State := .inl (.inl (.inl (.inl TapeCopy.State.start))) +def done : State := .inr TapeMultiply.done + +def cost (r t : ℕ) : ℕ := t * (10 * r + 18) + 10 * r + 22 + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +theorem runs_zero (σ : TapeStore) (r : ℕ) + (hr : σ ringDegree = List.replicate r true) + (hs : σ scratchA = []) (ha : σ accumBits = []) : + RunsIn zeroProgram.step (cfg (.inl TapeCopy.State.start) (storeTapes σ)) + (cfg (.inr TapeFill.fillDone) + (storeTapes (Function.update σ accumBits (List.replicate r false)))) (10 * r + 8) := by + let U := Function.update σ scratchA (σ ringDegree) + have hc := TapeStoreRuns.copy (by decide : ringDegree ≠ scratchA) σ hs + have hf := TapeStoreRuns.fill (by decide : scratchA ≠ accumBits) false U r + (by simp [U, hr]) + have hall := join_runs (TapeCopy.code ringDegree scratchA) + (TapeFill.fillProgram scratchA accumBits false) (fun _ => TapeFill.fillStart) hc rfl hf + have hfinal : Function.update (Function.update U scratchA []) accumBits + (List.replicate r false ++ U accumBits) = + Function.update σ accumBits (List.replicate r false) := by + have hu : Function.update U scratchA [] = σ := by + simp only [U, Function.update_idem, ← hs, Function.update_eq_self] + rw [hu] + simp [U, ha, accumBits, scratchA] + have ht : 2 * r + 4 + 1 + (8 * r + 3) = 10 * r + 8 := by omega + simpa only [zeroProgram, hfinal, hr, List.length_replicate, ht] using hall + +theorem runs_prepare (σ : TapeStore) (r t : ℕ) (hW : Workspace σ r) (hC : Clean σ) + (ht : σ coeffCount = List.replicate t true) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (TapeHornerLoop.frame σ t (t * r) (List.replicate r false)))) + (cost r t) := by + let U := Function.update σ accumBits (List.replicate r false) + let V := Function.update U loop2 (List.replicate t true) + let W := Function.update V loop4 (List.replicate t true) + have hz := runs_zero σ r hW.degree hW.scratch_empty hC.accumulator + have hc := TapeStoreRuns.copy (by decide : coeffCount ≠ loop2) U + (by simp [U, hC.count, accumBits, loop2]) + have hc' : RunsIn (TapeCopy.code coeffCount loop2).step + (cfg TapeCopy.State.start (storeTapes U)) (cfg TapeCopy.State.done (storeTapes V)) + (2 * t + 4) := by + simpa [V, U, ht, coeffCount, accumBits] using hc + have hzc := join_runs zeroProgram (TapeCopy.code coeffCount loop2) + (fun _ => TapeCopy.State.start) hz rfl hc' + have hmcopy := TapeStoreRuns.copy (by decide : coeffCount ≠ loop4) V + (by simp [V, U, hC.countScratch, loop4, loop2, accumBits]) + have hmcopy' : RunsIn (TapeCopy.code coeffCount loop4).step + (cfg TapeCopy.State.start (storeTapes V)) (cfg TapeCopy.State.done (storeTapes W)) + (2 * t + 4) := by + simpa [W, V, U, ht, coeffCount, loop2, accumBits] using hmcopy + have hp := join_runs countProgram (TapeCopy.code coeffCount loop4) + (fun _ => TapeCopy.State.start) hzc rfl hmcopy' + have hm := TapeMultiply.runs_mul + (outer := loop4) (source := ringDegree) (scratch := loop5) (destination := loop3) + (by decide) (by decide) (by decide) (by decide) (by decide) (by decide) + (storeTapes V) t r 0 + have hi : TapeMultiply.tapes loop4 ringDegree loop5 loop3 (storeTapes V) t r 0 0 = + storeTapes W := by + funext q + by_cases h4 : q = loop4 <;> by_cases hd : q = ringDegree <;> + by_cases h5 : q = loop5 <;> by_cases h3 : q = loop3 <;> + simp_all [TapeMultiply.tapes, TapeCopy.onPair, storeTapes, counterTape, + W, V, U, Function.update, hW.degree, hC.mulScratch, hC.cursor, + loop4, ringDegree, loop5, loop3, loop2, accumBits] + have ho : TapeMultiply.tapes loop4 ringDegree loop5 loop3 (storeTapes V) 0 r 0 (0 + t * r) = + storeTapes (Function.update V loop3 (List.replicate (t * r) true)) := by + funext q + by_cases h4 : q = loop4 <;> by_cases hd : q = ringDegree <;> + by_cases h5 : q = loop5 <;> by_cases h3 : q = loop3 <;> + simp_all [TapeMultiply.tapes, TapeCopy.onPair, storeTapes, counterTape, + V, U, Function.update, hW.degree, hC.countScratch, hC.mulScratch, + loop4, ringDegree, loop5, loop3, loop2, accumBits] + rw [hi, ho] at hm + have hall := join_runs cursorProgram (TapeMultiply.program loop4 ringDegree loop5 loop3) + (fun _ => TapeMultiply.start) hp rfl hm + have hfinal : Function.update V loop3 (List.replicate (t * r) true) = + TapeHornerLoop.frame σ t (t * r) (List.replicate r false) := by + funext q + by_cases h2 : q = loop2 <;> by_cases h3 : q = loop3 <;> by_cases ha : q = accumBits <;> + simp_all [V, U, TapeHornerLoop.frame, Function.update, loop2, loop3, accumBits] + have htime : ((10 * r + 8 + 1 + (2 * t + 4)) + 1 + (2 * t + 4)) + + 1 + (t * (10 * r + 14) + 3) = cost r t := by + unfold cost + ring + simpa only [program, start, done, hfinal, htime] using hall + +end TapeHornerPrepare +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeHornerTake.lean b/lean/OAI/Computability/DepthThree/TapeHornerTake.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3174436344070acde683bd16a444bd5c11cccaa --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeHornerTake.lean @@ -0,0 +1,104 @@ +import OAI.Computability.DepthThree.TapeInputBlocks + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeHornerTake + +open TapeMultiProgram TapeRouting TapeRegister TapeInputBlockLoop + +def registers : Registers where + toFun i := match i.val with + | 0 => productBits + | 1 => indexA + | 2 => loop1 + | 3 => scratchA + | _ => accumBits + inj' := by decide + +abbrev PrepareState := TapeErase.State ⊕ TapeCopy.State +abbrev WorkState := PrepareState ⊕ TapeInputBlocks.State +abbrev State := WorkState ⊕ TapeErase.State + +def prepare : TapeMultiProgram PrepareState := + joinCode (TapeErase.code accumBits) (TapeCopy.code ringDegree loop1) + (fun _ => TapeCopy.State.start) + +def work : TapeMultiProgram WorkState := + joinCode prepare (TapeInputBlocks.program registers) (fun _ => TapeInputBlocks.start) + +def program : TapeMultiProgram State := + joinCode work (TapeErase.code productBits) (fun _ => TapeErase.State.start) + +def start : State := .inl (.inl (.inl TapeErase.State.start)) +def done : State := .inr TapeErase.State.done + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +theorem runs_take (σ : TapeStore) (a c : List Bool) (r : ℕ) + (hacc : σ accumBits = a) (hprod : σ productBits = c) + (hlenA : a.length = r) (hlenC : c.length = 2 * r) + (hdegree : σ ringDegree = List.replicate r true) + (hcount : σ loop1 = []) (hindex : σ indexA = []) (hscratch : σ scratchA = []) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update + (Function.update σ accumBits (c.take r)) productBits []))) + (r * (r + 27) + 8 * r + 29) := by + let U := Function.update σ accumBits [] + let V := Function.update U loop1 (List.replicate r true) + let W := Function.update U accumBits (c.take r) + have he := TapeStoreRuns.erase accumBits σ + have he' : RunsIn (TapeErase.code accumBits).step + (cfg TapeErase.State.start (storeTapes σ)) (cfg TapeErase.State.done (storeTapes U)) + (2 * r + 5) := by + simpa only [hacc, hlenA] using he + have hc := TapeStoreRuns.copy (src := ringDegree) (dst := loop1) (by decide) U + (by simp [U, hcount, accumBits, loop1]) + have hc' : RunsIn (TapeCopy.code ringDegree loop1).step + (cfg TapeCopy.State.start (storeTapes U)) (cfg TapeCopy.State.done (storeTapes V)) + (2 * r + 4) := by + simpa [V, U, hdegree, ringDegree, accumBits] using hc + have hp := join_runs (TapeErase.code accumBits) (TapeCopy.code ringDegree loop1) + (fun _ => TapeCopy.State.start) he' rfl hc' + have hlen : (c.take r).length = r := by + apply List.length_take_of_le + omega + have hb := TapeInputBlocks.runs_extract registers V [] (c.take r) (c.drop r) [] + (by simp [registers, source, V, U, hprod, productBits, loop1, accumBits]) + (by simp [registers, index, V, U, hindex, indexA, loop1, accumBits]) + (by simp [registers, count, V, hlen]) + (by simp [registers, scratch, V, U, hscratch, scratchA, loop1, accumBits]) + (by simp [registers, destination, V, U, loop1, accumBits]) + have hout : Function.update (Function.update V (count registers) []) + (destination registers) (c.take r ++ []) = W := by + funext q + by_cases hl : q = loop1 <;> by_cases ha : q = accumBits <;> + simp_all [V, U, W, count, destination, registers, Function.update_apply] + have hb' : RunsIn (TapeInputBlocks.program registers).step + (cfg TapeInputBlocks.start (storeTapes V)) (cfg TapeInputBlocks.done (storeTapes W)) + (r * (r + 27) + 12) := by + simpa only [hout, hlen, List.length_nil, Nat.mul_zero, Nat.zero_add] using hb + have hw := join_runs prepare (TapeInputBlocks.program registers) + (fun _ => TapeInputBlocks.start) hp rfl hb' + have hclear := TapeStoreRuns.erase productBits W + have hclear' : RunsIn (TapeErase.code productBits).step + (cfg TapeErase.State.start (storeTapes W)) + (cfg TapeErase.State.done (storeTapes (Function.update W productBits []))) + (4 * r + 5) := by + simpa [W, U, hprod, hlenC, productBits, accumBits, ← Nat.mul_assoc] using hclear + have hall := join_runs work (TapeErase.code productBits) + (fun _ => TapeErase.State.start) hw rfl hclear' + have hfinal : Function.update W productBits [] = + Function.update (Function.update σ accumBits (c.take r)) productBits [] := by + simp only [W, U, Function.update_idem] + have ht : ((2 * r + 5 + 1 + (2 * r + 4)) + 1 + (r * (r + 27) + 12)) + + 1 + (4 * r + 5) = r * (r + 27) + 8 * r + 29 := by omega + have ht' : ((2 * r + 5 + 1 + (2 * r + 4)) + 1 + (r * (r + 27) + 12)) + + 1 + (4 * r + 5) ≤ r * (r + 27) + 8 * r + 29 := ht.le + have h := hall.mono ht' + simpa only [program, start, done, hfinal] using h + +end TapeHornerTake +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeInitialization.lean b/lean/OAI/Computability/DepthThree/TapeInitialization.lean new file mode 100644 index 0000000000000000000000000000000000000000..81ba45647e0d12be989193a3e07fb36de08b7a68 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeInitialization.lean @@ -0,0 +1,288 @@ +import OAI.Computability.DepthThree.TapeMultiProgram +import OAI.Computability.DepthThree.TapeWordRewind +import Lean.Elab.Tactic.Omega + +namespace OAI + +universe uDepth1 uDepth2 + +namespace DepthThreeLowerBound + +open Turing + +inductive InitState + | start + | home + | prepare + | scan + | rewind + | done + deriving DecidableEq, Inhabited + +instance : Fintype InitState where + elems := {.start, .home, .prepare, .scan, .rewind, .done} + complete := by + intro state + cases state <;> simp + +private def initActive (r : TapeRegister) : Prop := + r = TapeRegister.input ∨ r = TapeRegister.length + +private instance (r : TapeRegister) : Decidable (initActive r) := + inferInstanceAs (Decidable (r = TapeRegister.input ∨ r = TapeRegister.length)) + +def initializationCode : TapeMultiProgram InitState + | .start, h => some (.home, h, fun _ => .left) + | .home, _ => some (.prepare, fun _ => cleanAtom .home, fun _ => .right) + | .prepare, h => some (.scan, + (fun r => if initActive r then h r else cleanAtom .endMark), + (fun r => if initActive r then .stay else .left)) + | .scan, h => + match (h TapeRegister.input).1 with + | .bit _ => some (.scan, + (fun r => if r = TapeRegister.length then rawInputSymbol true else h r), + (fun r => if initActive r then .right else .stay)) + | .blank => some (.rewind, + (fun r => if initActive r then cleanAtom .endMark else h r), + fun _ => .stay) + | _ => none + | .rewind, h => + if (h TapeRegister.input).1 = .home then + some (.done, h, fun _ => .stay) + else some (.rewind, h, fun r => if initActive r then .left else .stay) + | .done, _ => none + +def rawInputTapes (bits : List Bool) : TapeTapes := fun r => + if r = TapeRegister.input then Tape.mk₁ (encodeInput bits) else Tape.mk₁ [] + +def initializedTapes (bits : List Bool) : TapeTapes := fun r => + if r = TapeRegister.input then wordTape bits + else if r = TapeRegister.length then wordTape (List.replicate bits.length true) + else wordTape [] + +@[simp] theorem initializedTapes_input (bits : List Bool) : + initializedTapes bits TapeRegister.input = wordTape bits := by + simp [initializedTapes] + +@[simp] theorem initializedTapes_length (bits : List Bool) : + initializedTapes bits TapeRegister.length = + wordTape (List.replicate bits.length true) := by + simp [initializedTapes, TapeRegister.input, TapeRegister.length] + +theorem initializedTapes_other (bits : List Bool) (r : TapeRegister) + (hi : r ≠ TapeRegister.input) (hl : r ≠ TapeRegister.length) : + initializedTapes bits r = wordTape [] := by + simp [initializedTapes, hi, hl] + +@[simp] theorem initializedTapes_head (bits : List Bool) (r : TapeRegister) : + (initializedTapes bits r).head = cleanAtom .home := by + simp only [initializedTapes] + split_ifs <;> exact wordTape_head _ + +private theorem init_step {q q' : InitState} {T U : TapeTapes} + {writes : TapeHeads} {moves : TapeMoves} + (hc : initializationCode q (fun r => (T r).head) = some (q', writes, moves)) + (ht : ∀ r, (moves r).apply ((T r).write (writes r)) = U r) : + TapeMultiProgram.step initializationCode ⟨q, T⟩ = some ⟨q', U⟩ := by + have hu : multiTapeUpdate (⟨q, T⟩ : TapeMultiCfg InitState) q' writes moves = + ⟨q', U⟩ := by + change MultiTapeCfg.mk q' (fun r => (moves r).apply ((T r).write (writes r))) = _ + exact congrArg (MultiTapeCfg.mk q') (funext ht) + change multiTapeStep initializationCode _ = _ + rw [multiTapeStep_eq_some (code := initializationCode) + (c := (⟨q, T⟩ : TapeMultiCfg InitState)) hc, hu] + +private theorem init_raw_left {Γ : Type uDepth1} [Inhabited Γ] (R : List Γ) : + (Tape.mk₁ R).move Dir.left = Tape.mk₂ [] (default :: R) := + Tape.move_left_mk' (ListBlank.mk ([] : List Γ)) (ListBlank.mk R) + +private theorem init_write_nil {Γ : Type uDepth2} [Inhabited Γ] (L : List Γ) (a : Γ) : + (Tape.mk₂ L []).write a = Tape.mk₂ L [a] := rfl + +private def initHomeTapes (bits : List Bool) : TapeTapes := fun r => + Tape.mk₂ [cleanAtom .home] (if r = TapeRegister.input then encodeInput bits else []) + +private def initScanTapes (left right : List Bool) : TapeTapes := fun r => + if r = TapeRegister.input then + Tape.mk₂ (encodeInput left ++ [cleanAtom .home]) (encodeInput right) + else if r = TapeRegister.length then + Tape.mk₂ (List.replicate left.length (rawInputSymbol true) ++ [cleanAtom .home]) [] + else wordTape [] + +private def initRewindTapes (left right : List Bool) : TapeTapes := fun r => + if r = TapeRegister.input then + Tape.mk₂ (encodeInput left ++ [cleanAtom .home]) + (encodeInput right ++ [cleanAtom .endMark]) + else if r = TapeRegister.length then + Tape.mk₂ (List.replicate left.length (rawInputSymbol true) ++ [cleanAtom .home]) + (List.replicate right.length (rawInputSymbol true) ++ [cleanAtom .endMark]) + else wordTape [] + +private theorem initialization_start (bits : List Bool) : + TapeMultiProgram.step initializationCode ⟨.start, rawInputTapes bits⟩ = + some ⟨.home, fun r => (rawInputTapes bits r).move Dir.left⟩ := by + apply init_step rfl + intro r + simp only [Tape.write_self, HeadMove.apply_left] + +private theorem initialization_home (bits : List Bool) : + TapeMultiProgram.step initializationCode + ⟨.home, fun r => (rawInputTapes bits r).move Dir.left⟩ = + some ⟨.prepare, initHomeTapes bits⟩ := by + apply init_step rfl + intro r + by_cases hi : r = TapeRegister.input <;> + simp [rawInputTapes, initHomeTapes, hi, init_raw_left, + TapeWord.write_mk₂_cons, TapeWord.move_right_mk₂_cons] + +private theorem initialization_prepare (bits : List Bool) : + TapeMultiProgram.step initializationCode ⟨.prepare, initHomeTapes bits⟩ = + some ⟨.scan, initScanTapes [] bits⟩ := by + apply init_step rfl + intro r + by_cases hi : r = TapeRegister.input + · subst r + simp [initActive, initHomeTapes, initScanTapes, encodeInput] + · by_cases hl : r = TapeRegister.length + · subst r + simp [initActive, initHomeTapes, initScanTapes, TapeRegister.input, TapeRegister.length] + · simp [initActive, initHomeTapes, initScanTapes, hi, hl, init_write_nil, + TapeWord.move_left_mk₂_cons, wordTape, encodeInput, Tape.mk₁] + +private theorem initialization_scan_bit (left right : List Bool) (b : Bool) : + TapeMultiProgram.step initializationCode ⟨.scan, initScanTapes left (b :: right)⟩ = + some ⟨.scan, initScanTapes (b :: left) right⟩ := by + apply init_step rfl + intro r + by_cases hi : r = TapeRegister.input + · subst r + simp [initActive, initScanTapes, encodeInput, TapeRegister.input, + TapeRegister.length, TapeWord.move_right_mk₂_cons] + · by_cases hl : r = TapeRegister.length + · subst r + simp [initActive, initScanTapes, TapeRegister.input, TapeRegister.length, + init_write_nil, TapeWord.move_right_mk₂_cons, List.replicate_succ] + · simp [initActive, initScanTapes, hi, hl, wordTape, Tape.mk₁, + TapeWord.write_mk₂_cons] + +private theorem initialization_scan_end (left : List Bool) : + TapeMultiProgram.step initializationCode ⟨.scan, initScanTapes left []⟩ = + some ⟨.rewind, initRewindTapes left []⟩ := by + apply init_step (by rfl) + intro r + by_cases hi : r = TapeRegister.input + · subst r + simp [initActive, initScanTapes, initRewindTapes, encodeInput, init_write_nil] + · by_cases hl : r = TapeRegister.length + · subst r + simp [initActive, initScanTapes, initRewindTapes, init_write_nil, + TapeRegister.input, TapeRegister.length] + · simp [initActive, initScanTapes, initRewindTapes, hi, hl, wordTape, Tape.mk₁, + TapeWord.write_mk₂_cons] + +private theorem initRewind_head_ne_home (left right : List Bool) : + ((initRewindTapes left right TapeRegister.input).head).1 ≠ TapeAtom.home := by + cases right <;> simp [initRewindTapes, encodeInput, rawInputSymbol, cleanAtom] + +private theorem initialization_rewind_bit (left right : List Bool) (b : Bool) : + TapeMultiProgram.step initializationCode ⟨.rewind, initRewindTapes (b :: left) right⟩ = + some ⟨.rewind, initRewindTapes left (b :: right)⟩ := by + apply init_step (writes := fun r => (initRewindTapes (b :: left) right r).head) + (moves := fun r => if initActive r then .left else .stay) (by + simp only [initializationCode, initRewind_head_ne_home, ↓reduceIte]) + intro r + by_cases hi : r = TapeRegister.input + · subst r + simp [initActive, initRewindTapes, encodeInput, TapeWord.move_left_mk₂_cons] + · by_cases hl : r = TapeRegister.length + · subst r + simp [initActive, initRewindTapes, TapeRegister.input, TapeRegister.length, + List.replicate_succ, TapeWord.move_left_mk₂_cons] + · simp [initActive, initRewindTapes, hi, hl, wordTape, Tape.mk₁, + TapeWord.write_mk₂_cons] + +private theorem initialization_rewind_home (right : List Bool) : + TapeMultiProgram.step initializationCode ⟨.rewind, initRewindTapes [] right⟩ = + some ⟨.rewind, initializedTapes right⟩ := by + apply init_step (writes := fun r => (initRewindTapes [] right r).head) + (moves := fun r => if initActive r then .left else .stay) (by + simp only [initializationCode, initRewind_head_ne_home, ↓reduceIte]) + intro r + by_cases hi : r = TapeRegister.input + · subst r + simp [initActive, initRewindTapes, initializedTapes, encodeInput, + TapeWord.move_left_mk₂_cons, wordTape, Tape.mk₁] + · by_cases hl : r = TapeRegister.length + · subst r + simp [initActive, initRewindTapes, initializedTapes, encodeInput, + TapeRegister.input, TapeRegister.length, TapeWord.move_left_mk₂_cons, + wordTape, Tape.mk₁] + · simp [initActive, initRewindTapes, initializedTapes, hi, hl, wordTape, Tape.mk₁, + TapeWord.write_mk₂_cons] + +private theorem initialization_finish (bits : List Bool) : + TapeMultiProgram.step initializationCode ⟨.rewind, initializedTapes bits⟩ = + some ⟨.done, initializedTapes bits⟩ := by + apply init_step (writes := fun r => (initializedTapes bits r).head) + (moves := fun _ => .stay) (by simp [initializationCode]) + intro r + simp only [Tape.write_self, HeadMove.apply_stay] + +private theorem initialization_scan_runs (left right : List Bool) : + RunsIn (TapeMultiProgram.step initializationCode) + ⟨.scan, initScanTapes left right⟩ + ⟨.scan, initScanTapes (right.reverse ++ left) []⟩ right.length := by + induction right generalizing left with + | nil => + simpa using RunsIn.refl (TapeMultiProgram.step initializationCode) + (⟨.scan, initScanTapes left []⟩ : TapeMultiCfg InitState) + | cons b right ih => + have h := (RunsIn.single (initialization_scan_bit left right b)).trans (ih (b :: left)) + simpa only [List.reverse_cons, List.append_assoc, List.singleton_append, + List.length_cons, Nat.add_comm] using h + +private theorem initialization_rewind_runs (left right : List Bool) : + RunsIn (TapeMultiProgram.step initializationCode) + ⟨.rewind, initRewindTapes left right⟩ + ⟨.rewind, initializedTapes (left.reverse ++ right)⟩ (left.length + 1) := by + induction left generalizing right with + | nil => simpa using RunsIn.single (initialization_rewind_home right) + | cons b left ih => + have h := (RunsIn.single (initialization_rewind_bit left right b)).trans (ih (b :: right)) + simpa only [List.reverse_cons, List.append_assoc, List.singleton_append, + List.length_cons, Nat.add_comm, Nat.add_left_comm, Nat.add_assoc] using h + +theorem initialization_runs (bits : List Bool) : + RunsIn (TapeMultiProgram.step initializationCode) + ⟨.start, rawInputTapes bits⟩ ⟨.done, initializedTapes bits⟩ (2 * bits.length + 6) := by + have hsetup := ((RunsIn.single (initialization_start bits)).trans + (RunsIn.single (initialization_home bits))).trans + (RunsIn.single (initialization_prepare bits)) + have hscan := initialization_scan_runs [] bits + simp only [List.append_nil] at hscan + have hrewind := initialization_rewind_runs bits.reverse [] + simp only [List.reverse_reverse, List.append_nil, List.length_reverse] at hrewind + have h := (((hsetup.trans hscan).trans + (RunsIn.single (initialization_scan_end bits.reverse))).trans hrewind).trans + (RunsIn.single (initialization_finish bits)) + exact h.mono (by omega) + +@[simp] theorem initialization_done (T : TapeTapes) : + TapeMultiProgram.step initializationCode ⟨.done, T⟩ = none := rfl + +def initializationMachine : FiniteMultiTapeMachine := + TapeMultiProgram.machine initializationCode .start (fun _ => true) + +@[simp] theorem initializationMachine_init (bits : List Bool) : + initializationMachine.init bits = ⟨.start, rawInputTapes bits⟩ := rfl + +theorem initializationMachine_halts (bits : List Bool) : + MultiTapeHaltsIn initializationMachine bits true (2 * bits.length + 6) := by + apply (multiTapeHaltsIn_iff_runsIn _ _ _ _).2 + refine ⟨⟨.done, initializedTapes bits⟩, ?_, ?_, rfl⟩ + · exact initialization_runs bits + · exact initialization_done _ + +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeInputBlockLoop.lean b/lean/OAI/Computability/DepthThree/TapeInputBlockLoop.lean new file mode 100644 index 0000000000000000000000000000000000000000..40b5ae24b8b6c91a663b955d09e9d29faa4ca6b8 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeInputBlockLoop.lean @@ -0,0 +1,182 @@ +import OAI.Computability.DepthThree.TapeReadPush +import Mathlib.Data.List.Induction +import Mathlib.Tactic.Ring + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeInputBlockLoop + +open TapeMultiProgram TapeCopy TapeRouting TapeUnary TapeArithmetic + +abbrev Registers := Fin 5 ↪ TapeRegister + +abbrev source (R : Registers) := R 0 +abbrev index (R : Registers) := R 1 +abbrev count (R : Registers) := R 2 +abbrev scratch (R : Registers) := R 3 +abbrev destination (R : Registers) := R 4 + +@[simp] theorem register_eq (R : Registers) (i j : Fin 5) : + R i = R j ↔ i = j := R.injective.eq_iff + +theorem index_ne_source (R : Registers) : index R ≠ source R := by + simp [index, source] + +def blockStore (R : Registers) (σ : TapeStore) (pos remaining : ℕ) + (bits : List Bool) : TapeStore := + Function.update + (Function.update (Function.update σ (count R) (List.replicate remaining true)) + (index R) (List.replicate pos true)) (destination R) bits + +@[simp] theorem blockStore_source (R : Registers) (σ : TapeStore) + (pos remaining : ℕ) (bits : List Bool) : + blockStore R σ pos remaining bits (source R) = σ (source R) := by + simp [blockStore, source, index, count, destination] + +@[simp] theorem blockStore_index (R : Registers) (σ : TapeStore) + (pos remaining : ℕ) (bits : List Bool) : + blockStore R σ pos remaining bits (index R) = List.replicate pos true := by + simp [blockStore, index, count, destination] + +@[simp] theorem blockStore_count (R : Registers) (σ : TapeStore) + (pos remaining : ℕ) (bits : List Bool) : + blockStore R σ pos remaining bits (count R) = List.replicate remaining true := by + simp [blockStore, index, count, destination] + +@[simp] theorem blockStore_destination (R : Registers) (σ : TapeStore) + (pos remaining : ℕ) (bits : List Bool) : + blockStore R σ pos remaining bits (destination R) = bits := by + simp [blockStore] + +@[simp] theorem update_blockStore_count (R : Registers) (σ : TapeStore) + (pos remaining remaining' : ℕ) (bits : List Bool) : + Function.update (blockStore R σ pos remaining bits) (count R) + (List.replicate remaining' true) = blockStore R σ pos remaining' bits := by + funext q + by_cases hc : q = count R <;> by_cases hi : q = index R <;> + by_cases hd : q = destination R <;> + simp_all [blockStore, Function.update, count, index, destination] + +@[simp] theorem update_blockStore_index (R : Registers) (σ : TapeStore) + (pos pos' remaining : ℕ) (bits : List Bool) : + Function.update (blockStore R σ pos remaining bits) (index R) + (List.replicate pos' true) = blockStore R σ pos' remaining bits := by + funext q + by_cases hc : q = count R <;> by_cases hi : q = index R <;> + by_cases hd : q = destination R <;> + simp_all [blockStore, Function.update, count, index, destination] + +@[simp] theorem update_blockStore_destination (R : Registers) (σ : TapeStore) + (pos remaining : ℕ) (bits bits' : List Bool) : + Function.update (blockStore R σ pos remaining bits) (destination R) bits' = + blockStore R σ pos remaining bits' := by + simp only [blockStore, Function.update_idem] + +abbrev BodyState := DecState ⊕ TapeReadPush.State + +def bodyProgram (R : Registers) : TapeMultiProgram BodyState := + joinCode (decProgram (index R)) + (TapeReadPush.program (index R) (source R) (destination R)) + (fun _ => TapeReadPush.start) + +def bodyStart : BodyState := .inl DecState.start +def bodyDone (b : Bool) : BodyState := .inr (TapeReadPush.done b) + +@[simp] theorem body_done (R : Registers) (b : Bool) (h : TapeHeads) : + bodyProgram R (bodyDone b) h = none := rfl + +theorem runs_body (R : Registers) (σ : TapeStore) («prefix» suffix acc : List Bool) + (b : Bool) (remaining : ℕ) + (hsource : σ (source R) = «prefix» ++ b :: suffix) : + RunsIn (bodyProgram R).step + (cfg bodyStart (storeTapes + (blockStore R σ («prefix».length + 1) remaining acc))) + (cfg (bodyDone b) (storeTapes + (blockStore R σ «prefix».length remaining (b :: acc)))) + (2 * «prefix».length + 12) := by + have hd := decrement (index R) + (storeTapes (blockStore R σ («prefix».length + 1) remaining acc)) + («prefix».length + 1) (by simp [counterTape]) + have hd' : RunsIn (decProgram (index R)).step + (cfg DecState.start (storeTapes (blockStore R σ («prefix».length + 1) remaining acc))) + (cfg (DecState.done true) (storeTapes (blockStore R σ «prefix».length remaining acc))) 4 := by + simpa only [Nat.add_sub_cancel, Nat.zero_lt_succ, decide_true, + counterTape, ← storeTapes_update, update_blockStore_index] using hd + have hp := TapeReadPush.runs_store (index_ne_source R) (destination R) + (blockStore R σ «prefix».length remaining acc) «prefix» suffix b + (by simp) (by simpa using hsource) + have hp' : RunsIn + (TapeReadPush.program (index R) (source R) (destination R)).step + (cfg TapeReadPush.start (storeTapes (blockStore R σ «prefix».length remaining acc))) + (cfg (TapeReadPush.done b) + (storeTapes (blockStore R σ «prefix».length remaining (b :: acc)))) + (2 * «prefix».length + 7) := by + simpa only [blockStore_destination, update_blockStore_destination] using hp + have hall := join_runs (decProgram (index R)) + (TapeReadPush.program (index R) (source R) (destination R)) + (fun _ => TapeReadPush.start) hd' rfl hp' + have ht : 4 + 1 + (2 * «prefix».length + 7) = 2 * «prefix».length + 12 := by omega + simpa only [bodyProgram, bodyStart, bodyDone, ht] using hall + +abbrev State := LoopState DecState BodyState + +def program (R : Registers) : TapeMultiProgram State := + loopCode (decProgram (count R)) (bodyProgram R) + DecState.start bodyStart decPositive + +def start : State := loopTest DecState.start +def done : State := loopDone + +@[simp] theorem program_done (R : Registers) (h : TapeHeads) : + program R done h = none := rfl + +theorem runs_block (R : Registers) (σ : TapeStore) + («prefix» block suffix acc : List Bool) + (hsource : σ (source R) = «prefix» ++ block ++ suffix) : + RunsIn (program R).step + (cfg start (storeTapes + (blockStore R σ («prefix».length + block.length) block.length acc))) + (cfg done (storeTapes (blockStore R σ «prefix».length 0 (block ++ acc)))) + (block.length * (2 * «prefix».length + block.length + 17) + 3) := by + induction block using List.reverseRecOn generalizing suffix acc with + | nil => + have hd := decrement_empty (count R) + (storeTapes (blockStore R σ «prefix».length 0 acc)) (by simp []) + have he := loop_exit (decProgram (count R)) (bodyProgram R) + DecState.start bodyStart decPositive hd rfl rfl + simpa only [program, start, done, List.length_nil, List.nil_append, + Nat.add_zero, Nat.zero_mul, Nat.zero_add] using he + | append_singleton block b ih => + have hd := decrement (count R) + (storeTapes (blockStore R σ («prefix».length + block.length + 1) + (block.length + 1) acc)) (block.length + 1) (by simp [counterTape]) + have hd' : RunsIn (decProgram (count R)).step + (cfg DecState.start (storeTapes (blockStore R σ + («prefix».length + block.length + 1) (block.length + 1) acc))) + (cfg (DecState.done true) (storeTapes (blockStore R σ + («prefix».length + block.length + 1) block.length acc))) 4 := by + simpa only [Nat.add_sub_cancel, Nat.zero_lt_succ, decide_true, + counterTape, ← storeTapes_update, update_blockStore_count] using hd + have hs : σ (source R) = («prefix» ++ block) ++ b :: suffix := by + simpa only [List.append_assoc, List.cons_append, List.nil_append] using hsource + have hb := runs_body R σ («prefix» ++ block) suffix acc b block.length hs + simp only [List.length_append] at hb + have hit := loop_iter (decProgram (count R)) (bodyProgram R) + DecState.start bodyStart decPositive hd' rfl rfl hb (by simp) + have hs' : σ (source R) = «prefix» ++ block ++ (b :: suffix) := hs + have hrest := ih (b :: suffix) (b :: acc) hs' + have hall := hit.trans hrest + have ht : 4 + 1 + (2 * («prefix».length + block.length) + 12) + 1 + + (block.length * (2 * «prefix».length + block.length + 17) + 3) = + (block.length + 1) * (2 * «prefix».length + (block.length + 1) + 17) + 3 := by + ring + have hi : «prefix».length + (block.length + 1) = «prefix».length + block.length + 1 := by + omega + simpa only [program, start, done, List.length_append, List.length_singleton, + List.append_assoc, List.cons_append, List.nil_append, hi, ht] using hall + +end TapeInputBlockLoop +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeInputBlocks.lean b/lean/OAI/Computability/DepthThree/TapeInputBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3d7aa65235056de274ab0eda504c04575d1f614 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeInputBlocks.lean @@ -0,0 +1,236 @@ +import OAI.Computability.DepthThree.TapeInputBlockLoop +import OAI.Computability.DepthThree.LanguageInputBlockLists + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeInputBlocks + +open TapeMultiProgram TapeCopy TapeRouting TapeUnary TapeArithmetic +open TapeInputBlockLoop + +abbrev PrepareState := TapeCopy.State ⊕ AddState + +def prepareProgram (R : Registers) : TapeMultiProgram PrepareState := + joinCode (TapeCopy.code (count R) (scratch R)) + (addProgram (scratch R) (index R)) (fun _ => addStart) + +def prepareStart : PrepareState := .inl TapeCopy.State.start +def prepareDone : PrepareState := .inr addDone + +abbrev State := PrepareState ⊕ TapeInputBlockLoop.State + +def program (R : Registers) : TapeMultiProgram State := + joinCode (prepareProgram R) (TapeInputBlockLoop.program R) + (fun _ => TapeInputBlockLoop.start) + +def start : State := .inl prepareStart +def done : State := .inr TapeInputBlockLoop.done + +@[simp] theorem prepare_done (R : Registers) (h : TapeHeads) : + prepareProgram R prepareDone h = none := rfl + +@[simp] theorem program_done (R : Registers) (h : TapeHeads) : + program R done h = none := rfl + +theorem runs_prepare (R : Registers) (σ : TapeStore) (offset len : ℕ) + (hi : σ (index R) = List.replicate offset true) + (hc : σ (count R) = List.replicate len true) + (hs : σ (scratch R) = []) : + RunsIn (prepareProgram R).step (cfg prepareStart (storeTapes σ)) + (cfg prepareDone (storeTapes + (Function.update σ (index R) (List.replicate (offset + len) true)))) + (10 * len + 8) := by + have hcs : count R ≠ scratch R := by simp [count, scratch] + have hsi : scratch R ≠ index R := by simp [scratch, index] + let U := Function.update σ (scratch R) (List.replicate len true) + have hcopy := TapeStoreRuns.copy hcs σ hs + have hcopy' : RunsIn (TapeCopy.code (count R) (scratch R)).step + (cfg TapeCopy.State.start (storeTapes σ)) + (cfg TapeCopy.State.done (storeTapes U)) (2 * len + 4) := by + simpa only [hc, List.length_replicate] using hcopy + have hadd := TapeStoreRuns.add hsi U len offset + (by simp [U]) (by simp [U, hi, Ne.symm hsi]) + have hclear : Function.update U (scratch R) [] = σ := by + dsimp [U] + rw [Function.update_idem, ← hs, Function.update_eq_self] + have hadd' : RunsIn (addProgram (scratch R) (index R)).step + (cfg addStart (storeTapes U)) + (cfg addDone (storeTapes + (Function.update σ (index R) (List.replicate (offset + len) true)))) + (8 * len + 3) := by + simpa only [hclear] using hadd + have hall := join_runs (TapeCopy.code (count R) (scratch R)) + (addProgram (scratch R) (index R)) (fun _ => addStart) hcopy' rfl hadd' + have ht : (2 * len + 4) + 1 + (8 * len + 3) = 10 * len + 8 := by omega + simpa only [prepareProgram, prepareStart, prepareDone, ht] using hall + +theorem blockStore_prepared (R : Registers) (σ : TapeStore) (offset len : ℕ) + (acc : List Bool) (hc : σ (count R) = List.replicate len true) + (hd : σ (destination R) = acc) : + blockStore R σ (offset + len) len acc = + Function.update σ (index R) (List.replicate (offset + len) true) := by + funext q + by_cases hq : q = destination R <;> by_cases hi : q = index R <;> + by_cases hk : q = count R <;> + simp_all [blockStore, Function.update, count, index, destination] + +theorem blockStore_finished (R : Registers) (σ : TapeStore) (offset : ℕ) + (bits : List Bool) (hi : σ (index R) = List.replicate offset true) : + blockStore R σ offset 0 bits = + Function.update (Function.update σ (count R) []) (destination R) bits := by + funext q + by_cases hq : q = destination R <;> by_cases hk : q = count R <;> + by_cases hj : q = index R <;> + simp_all [blockStore, Function.update, count, index, destination] + +theorem runs_extract (R : Registers) (σ : TapeStore) + («prefix» block suffix acc : List Bool) + (hinput : σ (source R) = «prefix» ++ block ++ suffix) + (hi : σ (index R) = List.replicate «prefix».length true) + (hc : σ (count R) = List.replicate block.length true) + (hs : σ (scratch R) = []) + (hd : σ (destination R) = acc) : + RunsIn (program R).step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update (Function.update σ (count R) []) + (destination R) (block ++ acc)))) + (block.length * (2 * «prefix».length + block.length + 27) + 12) := by + have hp := runs_prepare R σ «prefix».length block.length hi hc hs + have hb := TapeInputBlockLoop.runs_block R σ «prefix» block suffix acc hinput + rw [blockStore_prepared R σ «prefix».length block.length acc hc hd, + blockStore_finished R σ «prefix».length (block ++ acc) hi] at hb + have hall := join_runs (prepareProgram R) (TapeInputBlockLoop.program R) + (fun _ => TapeInputBlockLoop.start) hp (by simp) hb + have ht : (10 * block.length + 8) + 1 + + (block.length * (2 * «prefix».length + block.length + 17) + 3) = + block.length * (2 * «prefix».length + block.length + 27) + 12 := by ring + simpa only [program, start, done, ht] using hall + +def outputRegister : InputBlockKind → TapeRegister + | .data => TapeRegister.dataBits + | .hash => TapeRegister.keyBits + | .polynomial => TapeRegister.polyBits + | .coefficients => TapeRegister.coeffBits + +def canonicalRegisters (kind : InputBlockKind) : Registers where + toFun i := match i.val with + | 0 => TapeRegister.input + | 1 => TapeRegister.temp0 + | 2 => TapeRegister.temp1 + | 3 => TapeRegister.temp2 + | _ => outputRegister kind + inj' := by cases kind <;> decide + +@[simp] theorem canonical_source (kind : InputBlockKind) : + source (canonicalRegisters kind) = TapeRegister.input := rfl + +@[simp] theorem canonical_index (kind : InputBlockKind) : + index (canonicalRegisters kind) = TapeRegister.temp0 := rfl + +@[simp] theorem canonical_count (kind : InputBlockKind) : + count (canonicalRegisters kind) = TapeRegister.temp1 := rfl + +@[simp] theorem canonical_scratch (kind : InputBlockKind) : + scratch (canonicalRegisters kind) = TapeRegister.temp2 := rfl + +@[simp] theorem canonical_destination (kind : InputBlockKind) : + destination (canonicalRegisters kind) = outputRegister kind := rfl + +def canonicalProgram (kind : InputBlockKind) : TapeMultiProgram State := + program (canonicalRegisters kind) + +@[simp] theorem canonical_done (kind : InputBlockKind) (h : TapeHeads) : + canonicalProgram kind done h = none := rfl + +theorem canonical_cost_le {w : List Bool} (hfit : InputFits w) (kind : InputBlockKind) : + inputBlockLength w.length kind * + (2 * inputBlockOffset w.length kind + inputBlockLength w.length kind + 27) + 12 ≤ + w.length * (3 * w.length + 27) + 12 := by + have hend := inputBlock_end_le hfit kind + have hlen : inputBlockLength w.length kind ≤ w.length := by omega + apply Nat.add_le_add_right _ 12 + exact Nat.mul_le_mul hlen (by omega) + +theorem runs_canonical_block (kind : InputBlockKind) (σ : TapeStore) (w : List Bool) + (hfit : InputFits w) (hw : σ TapeRegister.input = w) + (hi : σ TapeRegister.temp0 = List.replicate (inputBlockOffset w.length kind) true) + (hc : σ TapeRegister.temp1 = List.replicate (inputBlockLength w.length kind) true) + (hs : σ TapeRegister.temp2 = []) (hd : σ (outputRegister kind) = []) : + RunsIn (canonicalProgram kind).step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update (Function.update σ TapeRegister.temp1 []) + (outputRegister kind) (inputBlockData w kind)))) + (inputBlockLength w.length kind * + (2 * inputBlockOffset w.length kind + inputBlockLength w.length kind + 27) + 12) := by + have hall := runs_extract (canonicalRegisters kind) σ + (w.take (inputBlockOffset w.length kind)) (inputBlockData w kind) + (w.drop (inputBlockOffset w.length kind + inputBlockLength w.length kind)) [] + (by simpa only [canonical_source, hw] using inputBlock_reconstruct w kind) + (by simpa only [canonical_index, inputBlock_prefix_length hfit kind] using hi) + (by simpa only [canonical_count, inputBlockData_length hfit kind] using hc) + (by simpa only [canonical_scratch] using hs) + (by simpa only [canonical_destination] using hd) + simpa only [canonicalProgram, canonical_count, canonical_destination, + List.append_nil, inputBlock_prefix_length hfit kind, + inputBlockData_length hfit kind] using hall + +theorem runs_data (σ : TapeStore) (w : List Bool) (hfit : InputFits w) + (hw : σ TapeRegister.input = w) (hi : σ TapeRegister.temp0 = []) + (hc : σ TapeRegister.temp1 = List.replicate (dataDimension w.length) true) + (hs : σ TapeRegister.temp2 = []) (hd : σ TapeRegister.dataBits = []) : + RunsIn (canonicalProgram .data).step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update (Function.update σ TapeRegister.temp1 []) + TapeRegister.dataBits (inputBlockData w .data)))) + (dataDimension w.length * (dataDimension w.length + 27) + 12) := by + simpa only [inputBlockOffset, inputBlockLength, outputRegister, Nat.mul_zero, + Nat.zero_add] using runs_canonical_block .data σ w hfit hw hi hc hs hd + +theorem runs_hash (σ : TapeStore) (w : List Bool) (hfit : InputFits w) + (hw : σ TapeRegister.input = w) + (hi : σ TapeRegister.temp0 = + List.replicate (hashOffset (dataDimension w.length)) true) + (hc : σ TapeRegister.temp1 = + List.replicate (hashBlockLength (dataDimension w.length)) true) + (hs : σ TapeRegister.temp2 = []) (hd : σ TapeRegister.keyBits = []) : + RunsIn (canonicalProgram .hash).step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update (Function.update σ TapeRegister.temp1 []) + TapeRegister.keyBits (inputBlockData w .hash)))) + (hashBlockLength (dataDimension w.length) * + (2 * hashOffset (dataDimension w.length) + + hashBlockLength (dataDimension w.length) + 27) + 12) := + runs_canonical_block .hash σ w hfit hw hi hc hs hd + +theorem runs_polynomial (σ : TapeStore) (w : List Bool) (hfit : InputFits w) + (hw : σ TapeRegister.input = w) + (hi : σ TapeRegister.temp0 = + List.replicate (polynomialOffset (dataDimension w.length)) true) + (hc : σ TapeRegister.temp1 = + List.replicate (hashDimension (dataDimension w.length)) true) + (hs : σ TapeRegister.temp2 = []) (hd : σ TapeRegister.polyBits = []) : + RunsIn (canonicalProgram .polynomial).step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update (Function.update σ TapeRegister.temp1 []) + TapeRegister.polyBits (inputBlockData w .polynomial)))) + (hashDimension (dataDimension w.length) * + (2 * polynomialOffset (dataDimension w.length) + + hashDimension (dataDimension w.length) + 27) + 12) := + runs_canonical_block .polynomial σ w hfit hw hi hc hs hd + +theorem runs_coefficients (σ : TapeStore) (w : List Bool) (hfit : InputFits w) + (hw : σ TapeRegister.input = w) + (hi : σ TapeRegister.temp0 = + List.replicate (coefficientsOffset (dataDimension w.length)) true) + (hc : σ TapeRegister.temp1 = List.replicate + (independenceOrder (dataDimension w.length) * hashDimension (dataDimension w.length)) true) + (hs : σ TapeRegister.temp2 = []) (hd : σ TapeRegister.coeffBits = []) : + RunsIn (canonicalProgram .coefficients).step (cfg start (storeTapes σ)) + (cfg done (storeTapes (Function.update (Function.update σ TapeRegister.temp1 []) + TapeRegister.coeffBits (inputBlockData w .coefficients)))) + ((independenceOrder (dataDimension w.length) * hashDimension (dataDimension w.length)) * + (2 * coefficientsOffset (dataDimension w.length) + + independenceOrder (dataDimension w.length) * hashDimension (dataDimension w.length) + + 27) + 12) := + runs_canonical_block .coefficients σ w hfit hw hi hc hs hd + +end TapeInputBlocks +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeInputGuard.lean b/lean/OAI/Computability/DepthThree/TapeInputGuard.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb23b13ea92be71bf4abc875e66e09b0cf8f8fd2 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeInputGuard.lean @@ -0,0 +1,251 @@ +import OAI.Computability.DepthThree.TapeInputGuardLength +import OAI.Computability.DepthThree.TapeUnaryCompare +import OAI.Computability.DepthThree.LanguageParser +import Mathlib.Data.Fintype.Sigma +import Mathlib.Tactic.Linarith + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeInputGuard + +open TapeMultiProgram TapeRouting TapeUnary + +def positiveResult : TapeUnaryCompare.State → Bool + | .done o => decide (o = .gt) + | _ => false + +def atLeastResult : TapeUnaryCompare.State → Bool + | .done o => decide (o ≠ .lt) + | _ => false + +def atMostResult : TapeUnaryCompare.State → Bool + | .done o => decide (o ≠ .gt) + | _ => false + +@[simp] theorem positiveResult_result (d : ℕ) : + positiveResult (.done (TapeUnaryCompareScan.result d 0)) = decide (0 < d) := by + simp [positiveResult, TapeUnaryCompareScan.result_eq_gt_iff] + +@[simp] theorem atLeastResult_result (t : ℕ) : + atLeastResult (.done (TapeUnaryCompareScan.result t 2)) = decide (2 ≤ t) := by + simp [atLeastResult, TapeUnaryCompareScan.result_eq_lt_iff] + omega + +@[simp] theorem atMostResult_result (L n : ℕ) : + atMostResult (.done (TapeUnaryCompareScan.result L n)) = decide (L ≤ n) := by + simp [atMostResult, TapeUnaryCompareScan.result_eq_gt_iff] + +inductive CheckState where + | data (q : TapeUnaryCompare.State) + | order (dataOK : Bool) (q : TapeUnaryCompare.State) + | space (smallOK : Bool) (q : TapeUnaryCompare.State) + | clear (accepted : Bool) (q : TapeErase.State) + | done (accepted : Bool) + deriving DecidableEq, Fintype + +def checkProgram : TapeMultiProgram CheckState + | .data q, h => + match TapeUnaryCompare.program 2 5 q h with + | some out => some (.data out.1, out.2) + | none => jump (.order (positiveResult q) (.scan .beginR)) h + | .order b q, h => + match TapeUnaryCompare.program 4 6 q h with + | some out => some (.order b out.1, out.2) + | none => jump (.space (b && atLeastResult q) (.scan .beginR)) h + | .space b q, h => + match TapeUnaryCompare.program 8 1 q h with + | some out => some (.space b out.1, out.2) + | none => jump (.clear (b && atMostResult q) .start) h + | .clear b q, h => + match TapeErase.code 6 q h with + | some out => some (.clear b out.1, out.2) + | none => jump (.done b) h + | .done _, _ => none + +def checkStart : CheckState := .data (.scan .beginR) + +theorem runs_checks (σ : TapeStore) (n d t L : ℕ) + (h1 : σ 1 = List.replicate n true) (h2 : σ 2 = List.replicate d true) + (h4 : σ 4 = List.replicate t true) (h5 : σ 5 = []) + (h6 : σ 6 = List.replicate 2 true) (h8 : σ 8 = List.replicate L true) : + RunsIn checkProgram.step (cfg checkStart (storeTapes σ)) + (cfg (.done (decide (0 < d ∧ 2 ≤ t ∧ L ≤ n))) + (storeTapes (Function.update σ 6 []))) (4*n+42) := by + let od := TapeUnaryCompareScan.result d 0 + let ot := TapeUnaryCompareScan.result t 2 + let oL := TapeUnaryCompareScan.result L n + let bd := positiveResult (.done od) + let bt := bd && atLeastResult (.done ot) + let bL := bt && atMostResult (.done oL) + have hd := TapeUnaryCompare.runs_compare (r := 2) (s := 5) (by decide) + (storeTapes σ) d 0 (by simp [storeTapes, h2]) (by simp [storeTapes, h5]) + simp only [Nat.min_zero, Nat.mul_zero, Nat.zero_add] at hd + have hd' := runs_map (TapeUnaryCompare.program 2 5) checkProgram CheckState.data (by + intro q h q' writes moves he + simp only [checkProgram, he]) hd + have hdl := RunsIn.single (step_jump checkProgram (.data (.done od)) + (.order bd (.scan .beginR)) (storeTapes σ) rfl) + have ht := TapeUnaryCompare.runs_compare (r := 4) (s := 6) (by decide) + (storeTapes σ) t 2 (by simp [storeTapes, h4]) (by simp [storeTapes, h6]) + have ht0 := ht.mono (show 4 * min t 2 + 7 ≤ 15 by + have hm := Nat.min_le_right t 2 + omega) + have ht' := runs_map (TapeUnaryCompare.program 4 6) checkProgram (CheckState.order bd) (by + intro q h q' writes moves he + simp only [checkProgram, he]) ht0 + have htl := RunsIn.single (step_jump checkProgram (.order bd (.done ot)) + (.space bt (.scan .beginR)) (storeTapes σ) rfl) + have hL := TapeUnaryCompare.runs_compare (r := 8) (s := 1) (by decide) + (storeTapes σ) L n (by simp [storeTapes, h8]) (by simp [storeTapes, h1]) + have hL0 := hL.mono (show 4 * min L n + 7 ≤ 4*n+7 by + have hm := Nat.min_le_right L n + omega) + have hL' := runs_map (TapeUnaryCompare.program 8 1) checkProgram (CheckState.space bt) (by + intro q h q' writes moves he + simp only [checkProgram, he]) hL0 + have hLl := RunsIn.single (step_jump checkProgram (.space bt (.done oL)) + (.clear bL .start) (storeTapes σ) rfl) + have he := TapeStoreRuns.erase 6 σ + simp only [h6, List.length_replicate] at he + have he' := runs_map (TapeErase.code 6) checkProgram (CheckState.clear bL) (by + intro q h q' writes moves heq + simp only [checkProgram, heq]) he + have hel := RunsIn.single (step_jump checkProgram (.clear bL .done) (.done bL) + (storeTapes (Function.update σ 6 [])) rfl) + have hall := ((((((hd'.trans hdl).trans ht').trans htl).trans hL').trans hLl).trans he').trans hel + have hb : bL = decide (0 < d ∧ 2 ≤ t ∧ L ≤ n) := by + simp [bL, bt, bd, od, ot, oL, Bool.and_assoc] + have hc : ((((((7+1)+15)+1)+(4*n+7))+1)+(2*2+5))+1 = 4*n+42 := by omega + simpa only [mapCfg, cfg, checkStart, hb, hc] using hall + +abbrev TwoState := IncState ⊕ IncState +def twoProgram : TapeMultiProgram TwoState := + joinCode (incProgram 6) (incProgram 6) (fun _ => IncState.start) +def twoStart : TwoState := .inl .start +def twoDone : TwoState := .inr .done + +theorem runs_two (σ : TapeStore) (h6 : σ 6 = []) : + RunsIn twoProgram.step (cfg twoStart (storeTapes σ)) + (cfg twoDone (storeTapes (Function.update σ 6 (List.replicate 2 true)))) 5 := by + let σ1 := Function.update σ 6 (List.replicate 1 true) + have h1 := increment 6 (storeTapes σ) 0 (by simp [storeTapes, counterTape, h6]) + have h1' : RunsIn (incProgram 6).step (cfg IncState.start (storeTapes σ)) + (cfg IncState.done (storeTapes σ1)) 2 := by + simpa only [σ1, storeTapes_update, counterTape] using h1 + have h2 := increment 6 (storeTapes σ1) 1 (by simp [σ1, storeTapes, counterTape]) + have h2' : RunsIn (incProgram 6).step (cfg IncState.start (storeTapes σ1)) + (cfg IncState.done (storeTapes (Function.update σ 6 (List.replicate 2 true)))) 2 := by + simpa only [σ1, ← storeTapes_update, counterTape, Function.update_idem] using h2 + exact join_runs (incProgram 6) (incProgram 6) (fun _ => IncState.start) h1' rfl h2' + +abbrev TestState := TwoState ⊕ CheckState +def testProgram : TapeMultiProgram TestState := + joinCode twoProgram checkProgram (fun _ => checkStart) +def testStart : TestState := .inl twoStart +def testDone (b : Bool) : TestState := .inr (.done b) + +theorem runs_test (σ : TapeStore) (n d t L : ℕ) + (h1 : σ 1 = List.replicate n true) (h2 : σ 2 = List.replicate d true) + (h4 : σ 4 = List.replicate t true) (h5 : σ 5 = []) (h6 : σ 6 = []) + (h8 : σ 8 = List.replicate L true) : + RunsIn testProgram.step (cfg testStart (storeTapes σ)) + (cfg (testDone (decide (0 < d ∧ 2 ≤ t ∧ L ≤ n))) (storeTapes σ)) (4*n+48) := by + let τ := Function.update σ 6 (List.replicate 2 true) + have htwo := runs_two σ h6 + have hc := runs_checks τ n d t L (by simp [τ, h1]) (by simp [τ, h2]) + (by simp [τ, h4]) (by simp [τ, h5]) (by simp [τ]) (by simp [τ, h8]) + have hrestore : Function.update τ 6 [] = σ := by + dsimp [τ] + rw [Function.update_idem, ← h6, Function.update_eq_self] + rw [hrestore] at hc + have h := join_runs twoProgram checkProgram (fun _ => checkStart) htwo rfl hc + have ht : 5+1+(4*n+42) = 4*n+48 := by omega + simpa only [testProgram, testStart, testDone, ht] using h + +abbrev State := LengthState ⊕ TestState +def program : TapeMultiProgram State := + joinCode lengthProgram testProgram (fun _ => testStart) +def start : State := .inl lengthStart +def done (accepted : Bool) : State := .inr (testDone accepted) + +def cost (n d r t : ℕ) : ℕ := lengthCost d r t + 4*n + 49 + +theorem cost_eq (n d r t : ℕ) : + cost n d r t = 12*d + 20*r + 16*t + 10*(t*r) + 4*n + 94 := by + unfold cost lengthCost + omega + +theorem cost_le_square (n d r t : ℕ) (hd : d ≤ n+1) (hr : r ≤ n+1) (ht : t ≤ n+1) : + cost n d r t ≤ 200 * (n+1)^2 := by + rw [cost_eq] + have hm : t*r ≤ (n+1)*(n+1) := Nat.mul_le_mul ht hr + nlinarith + +theorem cost_parameters_le (n : ℕ) : + cost n (dataDimension n) (hashDimension (dataDimension n)) + (independenceOrder (dataDimension n)) ≤ 200 * (n+1)^2 := by + have hd : dataDimension n ≤ n+1 := by unfold dataDimension; omega + exact cost_le_square n _ _ _ hd ((hashDimension_le _).trans hd) + ((independenceOrder_le _).trans hd) + +theorem runs_guard (σ : TapeStore) (n d r t : ℕ) + (h1 : σ 1 = List.replicate n true) (h2 : σ 2 = List.replicate d true) + (h3 : σ 3 = List.replicate r true) (h4 : σ 4 = List.replicate t true) + (h5 : σ 5 = []) (h6 : σ 6 = []) (h8 : σ 8 = []) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg (done (decide (0 < d ∧ 2 ≤ t ∧ requiredLength d r t ≤ n))) + (storeTapes (outputStore σ d r t))) (cost n d r t) := by + have hl := runs_length σ d r t h2 h3 h4 h5 h6 h8 + have ht := runs_test (outputStore σ d r t) n d t (requiredLength d r t) + (by simp [outputStore, h1]) (by simp [outputStore, h2]) + (by simp [outputStore, h4]) (by simp [outputStore, h5]) + (by simp [outputStore, h6]) (by simp [outputStore]) + have h := join_runs lengthProgram testProgram (fun _ => testStart) hl rfl ht + have hc : lengthCost d r t + 1 + (4*n+48) = cost n d r t := by + unfold cost + omega + simpa only [program, start, done, hc] using h + +theorem runs_inputFits (w : List Bool) (σ : TapeStore) + (h1 : σ 1 = List.replicate w.length true) + (h2 : σ 2 = List.replicate (dataDimension w.length) true) + (h3 : σ 3 = List.replicate (hashDimension (dataDimension w.length)) true) + (h4 : σ 4 = List.replicate (independenceOrder (dataDimension w.length)) true) + (h5 : σ 5 = []) (h6 : σ 6 = []) (h8 : σ 8 = []) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg (done (decide (InputFits w))) + (storeTapes (outputStore σ (dataDimension w.length) + (hashDimension (dataDimension w.length)) (independenceOrder (dataDimension w.length))))) + (cost w.length (dataDimension w.length) (hashDimension (dataDimension w.length)) + (independenceOrder (dataDimension w.length))) := by + have hguard : decide (InputFits w) = + decide (0 < dataDimension w.length ∧ + 2 ≤ independenceOrder (dataDimension w.length) ∧ + requiredLength (dataDimension w.length) (hashDimension (dataDimension w.length)) + (independenceOrder (dataDimension w.length)) ≤ w.length) := by + apply decide_eq_decide.mpr + simp only [InputFits, requiredLength_parameters] + rw [hguard] + exact runs_guard σ w.length (dataDimension w.length) (hashDimension (dataDimension w.length)) + (independenceOrder (dataDimension w.length)) h1 h2 h3 h4 h5 h6 h8 + +theorem runs_inputFits_quadratic (w : List Bool) (σ : TapeStore) + (h1 : σ 1 = List.replicate w.length true) + (h2 : σ 2 = List.replicate (dataDimension w.length) true) + (h3 : σ 3 = List.replicate (hashDimension (dataDimension w.length)) true) + (h4 : σ 4 = List.replicate (independenceOrder (dataDimension w.length)) true) + (h5 : σ 5 = []) (h6 : σ 6 = []) (h8 : σ 8 = []) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg (done (decide (InputFits w))) + (storeTapes (outputStore σ (dataDimension w.length) + (hashDimension (dataDimension w.length)) (independenceOrder (dataDimension w.length))))) + (200 * (w.length+1)^2) := + (runs_inputFits w σ h1 h2 h3 h4 h5 h6 h8).mono (cost_parameters_le w.length) + +@[simp] theorem program_done (b : Bool) (h : TapeHeads) : program (done b) h = none := rfl + +end TapeInputGuard +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeInputGuardLength.lean b/lean/OAI/Computability/DepthThree/TapeInputGuardLength.lean new file mode 100644 index 0000000000000000000000000000000000000000..b21c76d8a1d6fc0398fd7dbd51990c81655dbee4 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeInputGuardLength.lean @@ -0,0 +1,187 @@ +import OAI.Computability.DepthThree.TapeCopyAdd +import OAI.Computability.DepthThree.TapeMultiply +import OAI.Computability.DepthThree.LanguageParameters +import Mathlib.Tactic.Ring + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeInputGuard + +open TapeMultiProgram TapeRouting TapeUnary TapeCopy + +def requiredLength (d r t : ℕ) : ℕ := d + (d + r - 1) + r + t * r + +theorem requiredLength_parameters (d : ℕ) : + requiredLength d (hashDimension d) (independenceOrder d) = blockLen d := rfl + +def outputStore (σ : TapeStore) (d r t : ℕ) : TapeStore := + Function.update σ 8 (List.replicate (requiredLength d r t) true) + +@[simp] theorem outputStore_length (σ : TapeStore) (d r t : ℕ) : + outputStore σ d r t 8 = List.replicate (requiredLength d r t) true := by + simp [outputStore] + +theorem outputStore_other (σ : TapeStore) (d r t : ℕ) (q : TapeRegister) + (hq : q ≠ 8) : outputStore σ d r t q = σ q := by + simp [outputStore, Function.update, hq] + +abbrev ProductState := TapeCopy.State ⊕ TapeMultiply.State + +def productProgram : TapeMultiProgram ProductState := + joinCode (TapeCopy.code 4 5) (TapeMultiply.program 5 3 6 8) + (fun _ => TapeMultiply.start) + +def productStart : ProductState := .inl .start +def productDone : ProductState := .inr TapeMultiply.done + +theorem runs_product (σ : TapeStore) (t r z : ℕ) + (h3 : σ 3 = List.replicate r true) (h4 : σ 4 = List.replicate t true) + (h5 : σ 5 = []) (h6 : σ 6 = []) (h8 : σ 8 = List.replicate z true) : + RunsIn productProgram.step (cfg productStart (storeTapes σ)) + (cfg productDone (storeTapes (Function.update σ 8 (List.replicate (z + t*r) true)))) + (t * (10*r + 14) + 2*t + 8) := by + let τ := Function.update σ 5 (List.replicate t true) + have hc := TapeStoreRuns.copy (src := 4) (dst := 5) (by decide) σ h5 + have hc' : RunsIn (TapeCopy.code 4 5).step (cfg TapeCopy.State.start (storeTapes σ)) + (cfg TapeCopy.State.done (storeTapes τ)) (2*t+4) := by + simpa only [τ, h4, List.length_replicate] using hc + have hin : TapeMultiply.tapes 5 3 6 8 (storeTapes σ) t r 0 z = storeTapes τ := by + funext q + by_cases hq5 : q = 5 + · subst q; simp [TapeMultiply.tapes, onPair, storeTapes, τ, counterTape] + · by_cases hq3 : q = 3 + · subst q; simp [TapeMultiply.tapes, onPair, storeTapes, τ, counterTape, h3] + · by_cases hq6 : q = 6 + · subst q; simp [TapeMultiply.tapes, onPair, storeTapes, τ, counterTape, h6] + · by_cases hq8 : q = 8 + · subst q; simp [TapeMultiply.tapes, onPair, storeTapes, τ, counterTape, h8] + · simp [TapeMultiply.tapes, onPair, storeTapes, τ, hq5, hq3, hq6, hq8] + have hout : TapeMultiply.tapes 5 3 6 8 (storeTapes σ) 0 r 0 (z+t*r) = + storeTapes (Function.update σ 8 (List.replicate (z+t*r) true)) := by + funext q + by_cases hq5 : q = 5 + · subst q; simp [TapeMultiply.tapes, onPair, storeTapes, counterTape, h5] + · by_cases hq3 : q = 3 + · subst q; simp [TapeMultiply.tapes, onPair, storeTapes, counterTape, h3] + · by_cases hq6 : q = 6 + · subst q; simp [TapeMultiply.tapes, onPair, storeTapes, counterTape, h6] + · by_cases hq8 : q = 8 + · subst q; simp [TapeMultiply.tapes, onPair, storeTapes, counterTape] + · simp [TapeMultiply.tapes, onPair, storeTapes, Function.update, + hq5, hq3, hq6, hq8] + have hm := TapeMultiply.runs_mul (outer := 5) (source := 3) (scratch := 6) + (destination := 8) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (storeTapes σ) t r z + rw [hin, hout] at hm + have h := join_runs (TapeCopy.code 4 5) (TapeMultiply.program 5 3 6 8) + (fun _ => TapeMultiply.start) hc' rfl hm + have ht : (2*t+4)+1+(t*(10*r+14)+3) = t*(10*r+14)+2*t+8 := by omega + simpa only [productProgram, productStart, productDone, ht] using h + +abbrev RingSumState := TapeCopyAdd.State ⊕ TapeCopyAdd.State +def ringSumProgram : TapeMultiProgram RingSumState := + joinCode (TapeCopyAdd.program 3 5 8) (TapeCopyAdd.program 3 5 8) + (fun _ => TapeCopyAdd.start) +def ringSumStart : RingSumState := .inl TapeCopyAdd.start +def ringSumDone : RingSumState := .inr TapeCopyAdd.done + +abbrev AddSumState := TapeCopyAdd.State ⊕ RingSumState +def addSumProgram : TapeMultiProgram AddSumState := + joinCode (TapeCopyAdd.program 2 5 8) ringSumProgram (fun _ => ringSumStart) +def addSumStart : AddSumState := .inl TapeCopyAdd.start +def addSumDone : AddSumState := .inr ringSumDone + +abbrev SumState := TapeCopy.State ⊕ AddSumState +def sumProgram : TapeMultiProgram SumState := + joinCode (TapeCopy.code 2 8) addSumProgram (fun _ => addSumStart) +def sumStart : SumState := .inl .start +def sumDone : SumState := .inr addSumDone + +theorem runs_sum (σ : TapeStore) (d r : ℕ) + (h2 : σ 2 = List.replicate d true) (h3 : σ 3 = List.replicate r true) + (h5 : σ 5 = []) (h8 : σ 8 = []) : + RunsIn sumProgram.step (cfg sumStart (storeTapes σ)) + (cfg sumDone (storeTapes (Function.update σ 8 (List.replicate (d+d+r+r) true)))) + (12*d+20*r+31) := by + let σ1 := Function.update σ 8 (List.replicate d true) + let σ2 := Function.update σ 8 (List.replicate (d+d) true) + let σ3 := Function.update σ 8 (List.replicate (d+d+r) true) + have hc := TapeStoreRuns.copy (src := 2) (dst := 8) (by decide) σ h8 + have hc' : RunsIn (TapeCopy.code 2 8).step (cfg TapeCopy.State.start (storeTapes σ)) + (cfg TapeCopy.State.done (storeTapes σ1)) (2*d+4) := by + simpa only [σ1, h2, List.length_replicate] using hc + have ha := TapeCopyAdd.runs_add (src := 2) (scratch := 5) (dst := 8) + (by decide) (by decide) σ1 d d (by simp [σ1, h2]) (by simp [σ1]) (by simp [σ1, h5]) + have ha' : RunsIn (TapeCopyAdd.program 2 5 8).step + (cfg TapeCopyAdd.start (storeTapes σ1)) (cfg TapeCopyAdd.done (storeTapes σ2)) + (10*d+8) := by simpa only [σ1, σ2, Function.update_idem] using ha + have hb := TapeCopyAdd.runs_add (src := 3) (scratch := 5) (dst := 8) + (by decide) (by decide) σ2 r (d+d) (by simp [σ2, h3]) (by simp [σ2]) + (by simp [σ2, h5]) + have hb' : RunsIn (TapeCopyAdd.program 3 5 8).step + (cfg TapeCopyAdd.start (storeTapes σ2)) (cfg TapeCopyAdd.done (storeTapes σ3)) + (10*r+8) := by simpa only [σ2, σ3, Function.update_idem] using hb + have he := TapeCopyAdd.runs_add (src := 3) (scratch := 5) (dst := 8) + (by decide) (by decide) σ3 r (d+d+r) (by simp [σ3, h3]) (by simp [σ3]) + (by simp [σ3, h5]) + simp only [σ3, Function.update_idem] at he + have hr := join_runs (TapeCopyAdd.program 3 5 8) (TapeCopyAdd.program 3 5 8) + (fun _ => TapeCopyAdd.start) hb' rfl he + have hd := join_runs (TapeCopyAdd.program 2 5 8) ringSumProgram + (fun _ => ringSumStart) ha' rfl hr + have h := join_runs (TapeCopy.code 2 8) addSumProgram + (fun _ => addSumStart) hc' rfl hd + have ht : (2*d+4)+1+((10*d+8)+1+((10*r+8)+1+(10*r+8))) = + 12*d+20*r+31 := by omega + simpa only [sumProgram, sumStart, sumDone, addSumProgram, addSumStart, addSumDone, + ringSumProgram, ringSumStart, ringSumDone, ht] using h + +abbrev TailState := DecState ⊕ ProductState +def tailProgram : TapeMultiProgram TailState := + joinCode (decProgram 8) productProgram (fun _ => productStart) +def tailStart : TailState := .inl .start +def tailDone : TailState := .inr productDone + +abbrev LengthState := SumState ⊕ TailState +def lengthProgram : TapeMultiProgram LengthState := + joinCode sumProgram tailProgram (fun _ => tailStart) +def lengthStart : LengthState := .inl sumStart +def lengthDone : LengthState := .inr tailDone + +def lengthCost (d r t : ℕ) : ℕ := 12*d+20*r+16*t+10*(t*r)+45 + +theorem runs_length (σ : TapeStore) (d r t : ℕ) + (h2 : σ 2 = List.replicate d true) (h3 : σ 3 = List.replicate r true) + (h4 : σ 4 = List.replicate t true) (h5 : σ 5 = []) (h6 : σ 6 = []) + (h8 : σ 8 = []) : + RunsIn lengthProgram.step (cfg lengthStart (storeTapes σ)) + (cfg lengthDone (storeTapes (outputStore σ d r t))) (lengthCost d r t) := by + let z := d+d+r+r + let σS := Function.update σ 8 (List.replicate z true) + let σD := Function.update σ 8 (List.replicate (z-1) true) + have hs := runs_sum σ d r h2 h3 h5 h8 + have hd := decrement 8 (storeTapes σS) z (by simp [σS, storeTapes, counterTape]) + have hd' : RunsIn (decProgram 8).step (cfg DecState.start (storeTapes σS)) + (cfg (DecState.done (decide (0 < z))) (storeTapes σD)) 4 := by + simpa only [σS, σD, ← storeTapes_update, counterTape, Function.update_idem] using hd + have hp := runs_product σD t r (z-1) (by simp [σD, h3]) (by simp [σD, h4]) + (by simp [σD, h5]) (by simp [σD, h6]) (by simp [σD]) + have hz : z-1 = d+(d+r-1)+r := by dsimp [z]; omega + have ho : Function.update σD 8 (List.replicate (z-1+t*r) true) = + outputStore σ d r t := by + simp only [σD, Function.update_idem, outputStore, requiredLength, hz] + rw [ho] at hp + have htail := join_runs (decProgram 8) productProgram (fun _ => productStart) hd' rfl hp + have h := join_runs sumProgram tailProgram (fun _ => tailStart) hs rfl htail + have ht : (12*d+20*r+31)+1+(4+1+(t*(10*r+14)+2*t+8)) = + lengthCost d r t := by unfold lengthCost; ring + simpa only [lengthProgram, lengthStart, lengthDone, tailProgram, tailStart, tailDone, + σS, z, ht] using h + +@[simp] theorem lengthProgram_done (h : TapeHeads) : lengthProgram lengthDone h = none := rfl + +end TapeInputGuard +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeInputPrepare.lean b/lean/OAI/Computability/DepthThree/TapeInputPrepare.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4cf5eff23e632661a43a31714aa69f3e72e125e --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeInputPrepare.lean @@ -0,0 +1,311 @@ +import OAI.Computability.DepthThree.LanguageInputBlockLists +import OAI.Computability.DepthThree.TapeCopyAdd +import OAI.Computability.DepthThree.TapeProductLength +import Mathlib.Tactic.Linarith + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeInputPrepare + +open TapeMultiProgram TapeRouting TapeUnary + +abbrev SumMinusState := TapeCopy.State ⊕ (TapeCopyAdd.State ⊕ DecState) + +def sumMinusProgram (dst : TapeRegister) : TapeMultiProgram SumMinusState := + joinCode (TapeCopy.code 2 dst) + (joinCode (TapeCopyAdd.program 3 31 dst) (decProgram dst) (fun _ => .start)) + (fun _ => .inl TapeCopyAdd.start) + +def sumMinusStart : SumMinusState := .inl .start + +def sumMinusDone (d r : ℕ) : SumMinusState := + .inr (.inr (.done (decide (0 < d + r)))) + +@[simp] theorem sumMinusProgram_done (dst : TapeRegister) (d r : ℕ) (h : TapeHeads) : + sumMinusProgram dst (sumMinusDone d r) h = none := rfl + +private theorem runs_decrement (dst : TapeRegister) (σ : TapeStore) (n : ℕ) + (hn : σ dst = List.replicate n true) : + RunsIn (decProgram dst).step (cfg DecState.start (storeTapes σ)) + (cfg (.done (decide (0 < n))) + (storeTapes (Function.update σ dst (List.replicate (n - 1) true)))) 4 := by + have h := TapeUnary.decrement dst (storeTapes σ) n (by simp [storeTapes, hn, counterTape]) + simpa only [storeTapes_update, counterTape] using h + +theorem runs_sumMinus {dst : TapeRegister} + (h2 : (2 : TapeRegister) ≠ dst) (h3 : (3 : TapeRegister) ≠ dst) + (h31 : (31 : TapeRegister) ≠ dst) (σ : TapeStore) (d r : ℕ) + (hd : σ 2 = List.replicate d true) (hr : σ 3 = List.replicate r true) + (he : σ dst = []) (hc : σ 31 = []) : + RunsIn (sumMinusProgram dst).step (cfg sumMinusStart (storeTapes σ)) + (cfg (sumMinusDone d r) + (storeTapes (Function.update σ dst (List.replicate (d + r - 1) true)))) + (2 * d + 10 * r + 18) := by + let copied := Function.update σ dst (List.replicate d true) + let added := Function.update σ dst (List.replicate (d + r) true) + have hcopy := TapeStoreRuns.copy h2 σ he + simp only [hd, List.length_replicate] at hcopy + have hadd := TapeCopyAdd.runs_add (src := 3) (scratch := 31) (dst := dst) + (by decide) h31 copied r d (by simp [copied, h3, hr]) + (by simp [copied]) (by simp [copied, h31, hc]) + have hadd' : RunsIn (TapeCopyAdd.program 3 31 dst).step + (cfg TapeCopyAdd.start (storeTapes copied)) + (cfg TapeCopyAdd.done (storeTapes added)) (10 * r + 8) := by + simpa only [copied, added, Function.update_idem] using hadd + have hdec := runs_decrement dst added (d + r) (by simp [added]) + have hdec' : RunsIn (decProgram dst).step + (cfg DecState.start (storeTapes added)) + (cfg (.done (decide (0 < d + r))) + (storeTapes (Function.update σ dst (List.replicate (d + r - 1) true)))) 4 := by + simpa only [added, Function.update_idem] using hdec + have htail := join_runs (TapeCopyAdd.program 3 31 dst) (decProgram dst) + (fun _ => DecState.start) hadd' rfl hdec' + have h := join_runs (TapeCopy.code 2 dst) + (joinCode (TapeCopyAdd.program 3 31 dst) (decProgram dst) (fun _ => DecState.start)) + (fun _ => .inl TapeCopyAdd.start) hcopy rfl htail + have hcost : 2 * d + 4 + 1 + (10 * r + 8 + 1 + 4) = + 2 * d + 10 * r + 18 := by omega + simpa only [sumMinusProgram, sumMinusStart, sumMinusDone, hcost] using h + +abbrev OffsetState := SumMinusState ⊕ TapeCopyAdd.State + +def offsetProgram : TapeMultiProgram OffsetState := + joinCode (sumMinusProgram 29) (TapeCopyAdd.program 2 31 29) + (fun _ => TapeCopyAdd.start) + +def offsetStart : OffsetState := .inl sumMinusStart +def offsetDone : OffsetState := .inr TapeCopyAdd.done + +@[simp] theorem offsetProgram_done (h : TapeHeads) : offsetProgram offsetDone h = none := rfl + +theorem runs_offset (σ : TapeStore) (d r : ℕ) + (hd : σ 2 = List.replicate d true) (hr : σ 3 = List.replicate r true) + (he : σ 29 = []) (hc : σ 31 = []) : + RunsIn offsetProgram.step (cfg offsetStart (storeTapes σ)) + (cfg offsetDone + (storeTapes (Function.update σ 29 (List.replicate (d + (d + r - 1)) true)))) + (12 * d + 10 * r + 27) := by + let τ := Function.update σ 29 (List.replicate (d + r - 1) true) + have hs := runs_sumMinus (dst := 29) (by decide) (by decide) (by decide) + σ d r hd hr he hc + have ha := TapeCopyAdd.runs_add (src := 2) (scratch := 31) (dst := 29) + (by decide) (by decide) τ d (d + r - 1) + (by simp [τ, hd]) (by simp [τ]) (by simp [τ, hc]) + have ha' : RunsIn (TapeCopyAdd.program 2 31 29).step + (cfg TapeCopyAdd.start (storeTapes τ)) + (cfg TapeCopyAdd.done + (storeTapes (Function.update σ 29 (List.replicate (d + (d + r - 1)) true)))) + (10 * d + 8) := by + simpa only [τ, Function.update_idem, Nat.add_comm (d + r - 1) d] using ha + have h := join_runs (sumMinusProgram 29) (TapeCopyAdd.program 2 31 29) + (fun _ => TapeCopyAdd.start) hs rfl ha' + have hcost : 2 * d + 10 * r + 18 + 1 + (10 * d + 8) = + 12 * d + 10 * r + 27 := by omega + simpa only [offsetProgram, offsetStart, offsetDone, hcost] using h + +def terminalProgram : TapeMultiProgram Unit := fun _ _ => none + +abbrev HashState := TapeCopy.State ⊕ (SumMinusState ⊕ Unit) + +def hashProgram : TapeMultiProgram HashState := + joinCode (TapeCopy.code 2 29) + (joinCode (sumMinusProgram 30) terminalProgram (fun _ => ())) + (fun _ => .inl sumMinusStart) + +def hashStart : HashState := .inl .start +def hashDone : HashState := .inr (.inr ()) + +abbrev PolynomialState := OffsetState ⊕ TapeCopy.State + +def polynomialProgram : TapeMultiProgram PolynomialState := + joinCode offsetProgram (TapeCopy.code 3 30) (fun _ => TapeCopy.State.start) + +def polynomialStart : PolynomialState := .inl offsetStart +def polynomialDone : PolynomialState := .inr .done + +abbrev CoefficientsState := OffsetState ⊕ (TapeCopyAdd.State ⊕ TapeProductLength.State) + +def coefficientsProgram : TapeMultiProgram CoefficientsState := + joinCode offsetProgram + (joinCode (TapeCopyAdd.program 3 31 29) TapeProductLength.program + (fun _ => TapeProductLength.start)) + (fun _ => .inl TapeCopyAdd.start) + +def coefficientsStart : CoefficientsState := .inl offsetStart +def coefficientsDone : CoefficientsState := .inr (.inr TapeProductLength.done) + +def State : InputBlockKind → Type + | .data => TapeCopy.State + | .hash => HashState + | .polynomial => PolynomialState + | .coefficients => CoefficientsState + +instance (kind : InputBlockKind) : Fintype (State kind) := by + cases kind <;> dsimp [State] <;> infer_instance + +def program : (kind : InputBlockKind) → TapeMultiProgram (State kind) + | .data => TapeCopy.code 2 30 + | .hash => hashProgram + | .polynomial => polynomialProgram + | .coefficients => coefficientsProgram + +def start : (kind : InputBlockKind) → State kind + | .data => .start + | .hash => hashStart + | .polynomial => polynomialStart + | .coefficients => coefficientsStart + +def done : (kind : InputBlockKind) → State kind + | .data => .done + | .hash => hashDone + | .polynomial => polynomialDone + | .coefficients => coefficientsDone + +def outputStore (σ : TapeStore) (n : ℕ) (kind : InputBlockKind) : TapeStore := + Function.update + (Function.update σ 29 (List.replicate (inputBlockOffset n kind) true)) + 30 (List.replicate (inputBlockLength n kind) true) + +@[simp] theorem outputStore_offset (σ : TapeStore) (n : ℕ) (kind : InputBlockKind) : + outputStore σ n kind 29 = List.replicate (inputBlockOffset n kind) true := by + simp [outputStore] + +@[simp] theorem outputStore_length (σ : TapeStore) (n : ℕ) (kind : InputBlockKind) : + outputStore σ n kind 30 = List.replicate (inputBlockLength n kind) true := by + simp [outputStore] + +theorem outputStore_other (σ : TapeStore) (n : ℕ) (kind : InputBlockKind) + (s : TapeRegister) (h29 : s ≠ 29) (h30 : s ≠ 30) : + outputStore σ n kind s = σ s := by + simp [outputStore, Function.update, h29, h30] + +def cost (n : ℕ) : InputBlockKind → ℕ := + let d := dataDimension n + let r := hashDimension d + let t := independenceOrder d + fun kind => match kind with + | .data => 2 * d + 4 + | .hash => 4 * d + 10 * r + 24 + | .polynomial => 12 * d + 12 * r + 32 + | .coefficients => 12 * d + 20 * r + 45 + t * (10 * r + 16) + +private theorem runs_hash (σ : TapeStore) (d r : ℕ) + (hd : σ 2 = List.replicate d true) (hr : σ 3 = List.replicate r true) + (h29 : σ 29 = []) (h30 : σ 30 = []) (h31 : σ 31 = []) : + RunsIn hashProgram.step (cfg hashStart (storeTapes σ)) + (cfg hashDone (storeTapes (Function.update + (Function.update σ 29 (List.replicate d true)) + 30 (List.replicate (d + r - 1) true)))) (4 * d + 10 * r + 24) := by + let τ := Function.update σ 29 (List.replicate d true) + have hc := TapeStoreRuns.copy (src := 2) (dst := 29) (by decide) σ h29 + simp only [hd, List.length_replicate] at hc + have hs := runs_sumMinus (dst := 30) (by decide) (by decide) (by decide) τ d r + (by simp [τ, hd]) (by simp [τ, hr]) (by simp [τ, h30]) (by simp [τ, h31]) + have hz := RunsIn.refl terminalProgram.step + (cfg () (storeTapes (Function.update τ 30 (List.replicate (d + r - 1) true)))) + have htail := join_runs (sumMinusProgram 30) terminalProgram (fun _ => ()) hs rfl hz + have h := join_runs (TapeCopy.code 2 29) + (joinCode (sumMinusProgram 30) terminalProgram (fun _ => ())) + (fun _ => .inl sumMinusStart) hc rfl htail + have hcost : 2 * d + 4 + 1 + (2 * d + 10 * r + 18 + 1 + 0) = + 4 * d + 10 * r + 24 := by omega + simpa only [hashProgram, hashStart, hashDone, τ, hcost] using h + +private theorem runs_polynomial (σ : TapeStore) (d r : ℕ) + (hd : σ 2 = List.replicate d true) (hr : σ 3 = List.replicate r true) + (h29 : σ 29 = []) (h30 : σ 30 = []) (h31 : σ 31 = []) : + RunsIn polynomialProgram.step (cfg polynomialStart (storeTapes σ)) + (cfg polynomialDone (storeTapes (Function.update + (Function.update σ 29 (List.replicate (d + (d + r - 1)) true)) + 30 (List.replicate r true)))) (12 * d + 12 * r + 32) := by + let τ := Function.update σ 29 (List.replicate (d + (d + r - 1)) true) + have ho := runs_offset σ d r hd hr h29 h31 + have hc := TapeStoreRuns.copy (src := 3) (dst := 30) (by decide) τ (by simp [τ, h30]) + have hs : τ 3 = List.replicate r true := by simp [τ, hr] + simp only [hs, List.length_replicate] at hc + have h := join_runs offsetProgram (TapeCopy.code 3 30) + (fun _ => TapeCopy.State.start) ho rfl hc + have hcost : 12 * d + 10 * r + 27 + 1 + (2 * r + 4) = + 12 * d + 12 * r + 32 := by omega + simpa only [polynomialProgram, polynomialStart, polynomialDone, τ, hcost] using h + +private theorem runs_coefficients (σ : TapeStore) (d r t : ℕ) + (hd : σ 2 = List.replicate d true) (hr : σ 3 = List.replicate r true) + (ht : σ 4 = List.replicate t true) (h29 : σ 29 = []) (h30 : σ 30 = []) + (h31 : σ 31 = []) (h5 : σ 5 = []) (h6 : σ 6 = []) : + RunsIn coefficientsProgram.step (cfg coefficientsStart (storeTapes σ)) + (cfg coefficientsDone (storeTapes (Function.update + (Function.update σ 29 (List.replicate (d + (d + r - 1) + r) true)) + 30 (List.replicate (t * r) true)))) + (12 * d + 20 * r + 45 + t * (10 * r + 16)) := by + let τ := Function.update σ 29 (List.replicate (d + (d + r - 1)) true) + let υ := Function.update σ 29 (List.replicate (d + (d + r - 1) + r) true) + have ho := runs_offset σ d r hd hr h29 h31 + have ha := TapeCopyAdd.runs_add (src := 3) (scratch := 31) (dst := 29) + (by decide) (by decide) τ r (d + (d + r - 1)) + (by simp [τ, hr]) (by simp [τ]) (by simp [τ, h31]) + have ha' : RunsIn (TapeCopyAdd.program 3 31 29).step + (cfg TapeCopyAdd.start (storeTapes τ)) + (cfg TapeCopyAdd.done (storeTapes υ)) (10 * r + 8) := by + simpa only [τ, υ, Function.update_idem] using ha + have hp := TapeProductLength.runs_product υ t r (by simp [υ, ht]) + (by simp [υ, hr]) (by simp [υ, h5]) (by simp [υ, h6]) (by simp [υ, h30]) + have htail := join_runs (TapeCopyAdd.program 3 31 29) TapeProductLength.program + (fun _ => TapeProductLength.start) ha' rfl hp + have h := join_runs offsetProgram + (joinCode (TapeCopyAdd.program 3 31 29) TapeProductLength.program + (fun _ => TapeProductLength.start)) + (fun _ => .inl TapeCopyAdd.start) ho rfl htail + have hcost : 12 * d + 10 * r + 27 + 1 + (10 * r + 8 + 1 + + (t * (10 * r + 16) + 8)) = 12 * d + 20 * r + 45 + t * (10 * r + 16) := by omega + simpa only [coefficientsProgram, coefficientsStart, coefficientsDone, + TapeProductLength.outputStore, TapeProductLength.cost, υ, hcost] using h + +theorem runs_prepare (σ : TapeStore) (n : ℕ) (kind : InputBlockKind) + (hd : σ 2 = List.replicate (dataDimension n) true) + (hr : σ 3 = List.replicate (hashDimension (dataDimension n)) true) + (ht : σ 4 = List.replicate (independenceOrder (dataDimension n)) true) + (h29 : σ 29 = []) (h30 : σ 30 = []) (h31 : σ 31 = []) + (h5 : σ 5 = []) (h6 : σ 6 = []) (_h7 : σ 7 = []) : + RunsIn (program kind).step (cfg (start kind) (storeTapes σ)) + (cfg (done kind) (storeTapes (outputStore σ n kind))) (cost n kind) := by + cases kind with + | data => + have h := TapeStoreRuns.copy (src := 2) (dst := 30) (by decide) σ h30 + have he : Function.update σ 29 [] = σ := Function.update_eq_self_iff.mpr h29.symm + simpa only [State, program, start, done, outputStore, inputBlockOffset, inputBlockLength, + cost, List.replicate_zero, he, hd, List.length_replicate] using h + | hash => + simpa only [State, program, start, done, outputStore, inputBlockOffset, inputBlockLength, + hashOffset, hashBlockLength, cost] using + runs_hash σ (dataDimension n) (hashDimension (dataDimension n)) hd hr h29 h30 h31 + | polynomial => + simpa only [State, program, start, done, outputStore, inputBlockOffset, inputBlockLength, + polynomialOffset, hashOffset, hashBlockLength, cost] using + runs_polynomial σ (dataDimension n) (hashDimension (dataDimension n)) hd hr h29 h30 h31 + | coefficients => + simpa only [State, program, start, done, outputStore, inputBlockOffset, inputBlockLength, + coefficientsOffset, polynomialOffset, hashOffset, hashBlockLength, cost] using + runs_coefficients σ (dataDimension n) (hashDimension (dataDimension n)) + (independenceOrder (dataDimension n)) hd hr ht h29 h30 h31 h5 h6 + +theorem cost_le (n : ℕ) (kind : InputBlockKind) : cost n kind ≤ 128 * (n + 1) ^ 2 := by + have hd : dataDimension n ≤ n := Nat.div_le_self n 5 + have hr : hashDimension (dataDimension n) ≤ n := + Nat.le_trans (hashDimension_le (dataDimension n)) hd + have ht : independenceOrder (dataDimension n) ≤ n := + Nat.le_trans (independenceOrder_le (dataDimension n)) hd + have hp : independenceOrder (dataDimension n) * + (10 * hashDimension (dataDimension n) + 16) ≤ n * (10 * n + 16) := + Nat.mul_le_mul ht (by omega) + cases kind <;> dsimp [cost] <;> nlinarith + +@[simp] theorem program_done (kind : InputBlockKind) (h : TapeHeads) : + program kind (done kind) h = none := by + cases kind <;> rfl + +end TapeInputPrepare +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeMultiProgram.lean b/lean/OAI/Computability/DepthThree/TapeMultiProgram.lean new file mode 100644 index 0000000000000000000000000000000000000000..21d677ed080cc259561f34f3761af383ee388457 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeMultiProgram.lean @@ -0,0 +1,93 @@ +import OAI.Computability.DepthThree.TapeEncoding +import OAI.Computability.DepthThree.TapeWord +import OAI.Computability.DepthThree.MultiTapeMachine + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 uDepth7 + +namespace DepthThreeLowerBound + +open Turing + +abbrev TapeHeads := TapeRegister → TapeSymbol +abbrev TapeMoves := TapeRegister → HeadMove +abbrev TapeTapes := TapeRegister → Tape TapeSymbol +abbrev TapeMultiCfg (Q : Type uDepth1) := MultiTapeCfg TapeRegister TapeSymbol Q +abbrev TapeMultiProgram (Q : Type uDepth2) := + Q → TapeHeads → Option (Q × TapeHeads × TapeMoves) + +def wordTape (bits : List Bool) : Tape TapeSymbol := + Tape.mk₁ (cleanAtom .home :: (encodeInput bits ++ [cleanAtom .endMark])) + +def cursorTape (before after : List Bool) : Tape TapeSymbol := + Tape.mk₂ ((encodeInput before).reverse ++ [cleanAtom .home]) + (encodeInput after ++ [cleanAtom .endMark]) + +@[simp] theorem wordTape_head (bits : List Bool) : + (wordTape bits).head = cleanAtom .home := rfl + +@[simp] theorem cursorTape_head_cons (before after : List Bool) (b : Bool) : + (cursorTape before (b :: after)).head = rawInputSymbol b := rfl + +@[simp] theorem cursorTape_head_nil (before : List Bool) : + (cursorTape before []).head = cleanAtom .endMark := rfl + +@[simp] theorem wordTape_right (bits : List Bool) : + (wordTape bits).move Dir.right = cursorTape [] bits := rfl + +theorem cursorTape_right (before after : List Bool) (b : Bool) : + (cursorTape before (b :: after)).move Dir.right = + cursorTape (before ++ [b]) after := by + simp only [cursorTape, encodeInput, List.map_append, List.map_cons, List.map_nil, + List.reverse_append, List.reverse_cons, List.reverse_nil, List.nil_append, + List.cons_append, TapeWord.move_right_mk₂_cons] + +namespace TapeMultiProgram + +def step {Q : Type uDepth3} (P : TapeMultiProgram Q) : TapeMultiCfg Q → Option (TapeMultiCfg Q) := + multiTapeStep P + +def cfg {Q : Type uDepth4} (q : Q) (T : TapeTapes) : TapeMultiCfg Q := ⟨q, T⟩ + +def heads (T : TapeTapes) : TapeHeads := fun r => (T r).head + +def stayMoves : TapeMoves := fun _ => .stay + +def moveOnly (r : TapeRegister) (d : HeadMove) : TapeMoves := + Function.update stayMoves r d + +def writeOnly (r : TapeRegister) (symbol : TapeSymbol) (h : TapeHeads) : TapeHeads := + Function.update h r symbol + +def jump {Q : Type uDepth5} (q : Q) (h : TapeHeads) : + Option (Q × TapeHeads × TapeMoves) := some (q, h, stayMoves) + +def move {Q : Type uDepth6} (r : TapeRegister) (d : HeadMove) (q : Q) (h : TapeHeads) : + Option (Q × TapeHeads × TapeMoves) := some (q, h, moveOnly r d) + +def writeMove {Q : Type uDepth7} (r : TapeRegister) (symbol : TapeSymbol) + (d : HeadMove) (q : Q) (h : TapeHeads) : + Option (Q × TapeHeads × TapeMoves) := + some (q, writeOnly r symbol h, moveOnly r d) + +def isAtom (a : TapeAtom) (r : TapeRegister) (h : TapeHeads) : Bool := + decide ((h r).1 = a) + +def machine {Q : Type} [Fintype Q] (P : TapeMultiProgram Q) + (initial : Q) (accept : Q → Bool) : FiniteMultiTapeMachine where + K := TapeRegister + inputTape := TapeRegister.input + Γ := TapeSymbol + Q := Q + initialState := initial + inputSymbol := rawInputSymbol + input_injective := rawInputSymbol_injective + input_ne_blank := by simpa only [default_tapeSymbol] using rawInputSymbol_ne_blank + code := P + accept := accept + +end TapeMultiProgram +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeMultiRoutines.lean b/lean/OAI/Computability/DepthThree/TapeMultiRoutines.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f804a76b8fc80dab0535e69a74a7bfc2e9d49f5 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeMultiRoutines.lean @@ -0,0 +1,117 @@ +import OAI.Computability.DepthThree.TapeMultiProgram + +namespace OAI + +universe uDepth1 uDepth2 uDepth3 uDepth4 uDepth5 uDepth6 uDepth7 uDepth8 uDepth9 uDepth10 uDepth11 uDepth12 uDepth13 + +namespace DepthThreeLowerBound + +theorem runSteps_map_of_some {S : Type uDepth1} {T : Type uDepth2} {step : S → Option S} + {next : T → Option T} (f : S → T) + (hstep : ∀ a b, step a = some b → next (f a) = some (f b)) + {n : ℕ} {a b : S} (h : runSteps step n (some a) = some b) : + runSteps next n (some (f a)) = some (f b) := by + induction n generalizing a with + | zero => + have hab : a = b := Option.some.inj h + subst a + rfl + | succ n ih => + rw [runSteps_succ_left] at h ⊢ + cases he : step a with + | none => + have hfalse : (none : Option S) = some b := by + simpa only [Option.bind_some, he, runSteps_none] using h + cases hfalse + | some c => + have hc : runSteps step n (some c) = some b := by + simpa only [Option.bind_some, he] using h + simpa only [Option.bind_some, hstep a c he] using ih hc + +theorem RunsIn.map {S : Type uDepth3} {T : Type uDepth4} {step : S → Option S} {next : T → Option T} + (f : S → T) + (hstep : ∀ a b, step a = some b → next (f a) = some (f b)) + {a b : S} {n : ℕ} (h : RunsIn step a b n) : + RunsIn next (f a) (f b) n := by + obtain ⟨k, hk, he⟩ := h + exact ⟨k, hk, runSteps_map_of_some f hstep he⟩ + +namespace TapeMultiProgram + +def mapCfg {Q : Type uDepth5} {R : Type uDepth6} (f : Q → R) (c : TapeMultiCfg Q) : TapeMultiCfg R := + ⟨f c.q, c.tapes⟩ + +theorem step_jump {Q : Type uDepth7} (P : TapeMultiProgram Q) (q q' : Q) (T : TapeTapes) + (h : P q (heads T) = jump q' (heads T)) : + P.step (cfg q T) = some (cfg q' T) := by + have he := multiTapeStep_eq_some (c := cfg q T) (code := P) h + simpa only [step, cfg, heads, jump, multiTapeUpdate, stayMoves, + HeadMove.apply_stay, Turing.Tape.write_self] using he + +theorem step_move {Q : Type uDepth8} (P : TapeMultiProgram Q) (q q' : Q) + (T : TapeTapes) (r : TapeRegister) (d : HeadMove) + (h : P q (heads T) = move r d q' (heads T)) : + P.step (cfg q T) = some (cfg q' (Function.update T r (d.apply (T r)))) := by + have he := multiTapeStep_eq_some (c := cfg q T) (code := P) h + change P.step (cfg q T) = some (multiTapeUpdate (cfg q T) q' + (heads T) (moveOnly r d)) at he + rw [he] + congr 1 + apply congrArg (cfg q') + funext k + by_cases hk : k = r + · subst k + simp [cfg, heads, moveOnly, Turing.Tape.write_self] + · simp [cfg, heads, moveOnly, stayMoves, hk] + +theorem step_writeMove {Q : Type uDepth9} (P : TapeMultiProgram Q) (q q' : Q) + (T : TapeTapes) (r : TapeRegister) (symbol : TapeSymbol) (d : HeadMove) + (h : P q (heads T) = writeMove r symbol d q' (heads T)) : + P.step (cfg q T) = + some (cfg q' (Function.update T r (d.apply ((T r).write symbol)))) := by + have he := multiTapeStep_eq_some (c := cfg q T) (code := P) h + change P.step (cfg q T) = some (multiTapeUpdate (cfg q T) q' + (writeOnly r symbol (heads T)) (moveOnly r d)) at he + rw [he] + congr 1 + apply congrArg (cfg q') + funext k + by_cases hk : k = r + · subst k + simp [cfg, writeOnly, moveOnly] + · simp [cfg, heads, writeOnly, moveOnly, stayMoves, hk] + +theorem step_map {Q : Type uDepth10} {R : Type uDepth11} (P : TapeMultiProgram Q) (P' : TapeMultiProgram R) + (f : Q → R) + (hcode : ∀ q h q' writes moves, + P q h = some (q', writes, moves) → + P' (f q) h = some (f q', writes, moves)) + (a b : TapeMultiCfg Q) (h : P.step a = some b) : + P'.step (mapCfg f a) = some (mapCfg f b) := by + cases hp : P a.q (heads a.tapes) with + | none => + have hn : P.step a = none := (multiTapeStep_eq_none_iff P a).2 hp + have hfalse : (none : Option (TapeMultiCfg Q)) = some b := hn.symm.trans h + cases hfalse + | some out => + rcases out with ⟨q, writes, moves⟩ + have hb : b = multiTapeUpdate a q writes moves := by + exact (Option.some.inj ((multiTapeStep_eq_some (c := a) (code := P) hp).symm.trans h)).symm + subst b + have he := multiTapeStep_eq_some (c := mapCfg f a) (code := P') + (hcode a.q (heads a.tapes) q writes moves hp) + simpa only [step, mapCfg, multiTapeUpdate, heads] using he + +theorem runs_map {Q : Type uDepth12} {R : Type uDepth13} (P : TapeMultiProgram Q) (P' : TapeMultiProgram R) + (f : Q → R) + (hcode : ∀ q h q' writes moves, + P q h = some (q', writes, moves) → + P' (f q) h = some (f q', writes, moves)) + {a b : TapeMultiCfg Q} {n : ℕ} (h : RunsIn P.step a b n) : + RunsIn P'.step (mapCfg f a) (mapCfg f b) n := + h.map (mapCfg f) (step_map P P' f hcode) + +end TapeMultiProgram +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeMultiply.lean b/lean/OAI/Computability/DepthThree/TapeMultiply.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab710ba1fcf166642f81b9aba8650a9e392c1252 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeMultiply.lean @@ -0,0 +1,178 @@ +import OAI.Computability.DepthThree.TapeArithmetic + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeMultiply + +open TapeMultiProgram TapeRouting TapeUnary TapeCopy TapeArithmetic + +def tapes (outer source scratch destination : TapeRegister) (T : TapeTapes) + (n m k z : ℕ) : TapeTapes := + onPair outer source (onPair scratch destination T (counterTape k) (counterTape z)) + (counterTape n) (counterTape m) + +@[simp] theorem tapes_outer (outer source scratch destination : TapeRegister) + (T : TapeTapes) (n m k z : ℕ) : + tapes outer source scratch destination T n m k z outer = counterTape n := by + simp [tapes] + +@[simp] theorem tapes_source {outer source scratch destination : TapeRegister} + (hos : outer ≠ source) (T : TapeTapes) (n m k z : ℕ) : + tapes outer source scratch destination T n m k z source = counterTape m := by + simp [tapes, hos] + +@[simp] theorem tapes_scratch {outer source scratch destination : TapeRegister} + (hoc : outer ≠ scratch) (hsc : source ≠ scratch) (T : TapeTapes) (n m k z : ℕ) : + tapes outer source scratch destination T n m k z scratch = counterTape k := by + simp [tapes, onPair, Ne.symm hoc, Ne.symm hsc] + +@[simp] theorem tapes_destination {outer source scratch destination : TapeRegister} + (hod : outer ≠ destination) (hsd : source ≠ destination) (hcd : scratch ≠ destination) + (T : TapeTapes) (n m k z : ℕ) : + tapes outer source scratch destination T n m k z destination = counterTape z := by + simp [tapes, onPair, Ne.symm hod, Ne.symm hsd, Ne.symm hcd] + +theorem tapes_other (outer source scratch destination : TapeRegister) + (T : TapeTapes) (n m k z : ℕ) (r : TapeRegister) + (ho : r ≠ outer) (hs : r ≠ source) (hc : r ≠ scratch) (hd : r ≠ destination) : + tapes outer source scratch destination T n m k z r = T r := by + simp [tapes, onPair, ho, hs, hc, hd] + +private theorem update_outer (outer source scratch destination : TapeRegister) + (T : TapeTapes) (n m k z n' : ℕ) : + Function.update (tapes outer source scratch destination T n m k z) outer + (counterTape n') = tapes outer source scratch destination T n' m k z := by + exact update_onPair_src outer source + (onPair scratch destination T (counterTape k) (counterTape z)) + (counterTape n) (counterTape m) (counterTape n') + +private theorem overlay_source_scratch {outer source scratch destination : TapeRegister} + (hos : outer ≠ source) (hoc : outer ≠ scratch) (hsc : source ≠ scratch) + (T : TapeTapes) (n m k z m' k' : ℕ) : + onPair source scratch (tapes outer source scratch destination T n m k z) + (counterTape m') (counterTape k') = + tapes outer source scratch destination T n m' k' z := by + funext r + by_cases ho : r = outer + · subst r + simp [tapes, onPair, hos, hoc] + · by_cases hs : r = source + · subst r + simp [tapes, onPair, Ne.symm hos] + · by_cases hc : r = scratch + · subst r + simp [tapes, onPair, Ne.symm hoc, Ne.symm hsc] + · simp [tapes, onPair, ho, hs, hc] + +private theorem overlay_scratch_destination {outer source scratch destination : TapeRegister} + (hos : outer ≠ source) (hoc : outer ≠ scratch) (hod : outer ≠ destination) + (hsc : source ≠ scratch) (hsd : source ≠ destination) + (T : TapeTapes) (n m k z k' z' : ℕ) : + onPair scratch destination (tapes outer source scratch destination T n m k z) + (counterTape k') (counterTape z') = + tapes outer source scratch destination T n m k' z' := by + funext r + by_cases ho : r = outer + · subst r + simp [tapes, onPair, hoc, hod] + · by_cases hs : r = source + · subst r + simp [tapes, onPair, Ne.symm hos, hsc, hsd] + · by_cases hc : r = scratch + · subst r + simp [tapes, onPair, Ne.symm hoc, Ne.symm hsc] + · by_cases hd : r = destination <;> + simp [tapes, onPair, ho, hs, hc, hd, Ne.symm hod, Ne.symm hsd] + +abbrev BodyState := TapeCopy.State ⊕ AddState + +def bodyProgram (source scratch destination : TapeRegister) : TapeMultiProgram BodyState := + joinCode (TapeCopy.code source scratch) (addProgram scratch destination) + (fun _ => addStart) + +def bodyStart : BodyState := .inl .start +def bodyDone : BodyState := .inr addDone + +theorem runs_body {outer source scratch destination : TapeRegister} + (hos : outer ≠ source) (hoc : outer ≠ scratch) (hod : outer ≠ destination) + (hsc : source ≠ scratch) (hsd : source ≠ destination) (hcd : scratch ≠ destination) + (T : TapeTapes) (n m z : ℕ) : + RunsIn (bodyProgram source scratch destination).step + (cfg bodyStart (tapes outer source scratch destination T n m 0 z)) + (cfg bodyDone (tapes outer source scratch destination T n m 0 (z + m))) + (10 * m + 8) := by + have hcopy := runs_copy hsc (tapes outer source scratch destination T n m 0 z) + (List.replicate m true) + simp only [List.length_replicate] at hcopy + change RunsIn (TapeCopy.code source scratch).step + (cfg TapeCopy.State.start (onPair source scratch + (tapes outer source scratch destination T n m 0 z) (counterTape m) (counterTape 0))) + (cfg TapeCopy.State.done (onPair source scratch + (tapes outer source scratch destination T n m 0 z) (counterTape m) (counterTape m))) + (2 * m + 4) at hcopy + simp only [overlay_source_scratch hos hoc hsc] at hcopy + have hadd := runs_add hcd (tapes outer source scratch destination T n m m z) m z + simp only [overlay_scratch_destination hos hoc hod hsc hsd] at hadd + have h := join_runs (TapeCopy.code source scratch) (addProgram scratch destination) + (fun _ => addStart) hcopy rfl hadd + have htime : 2 * m + 4 + 1 + (8 * m + 3) = 10 * m + 8 := by omega + simpa only [bodyProgram, bodyStart, bodyDone, htime] using h + +@[simp] theorem body_done (source scratch destination : TapeRegister) (h : TapeHeads) : + bodyProgram source scratch destination bodyDone h = none := rfl + +abbrev State := LoopState DecState BodyState + +def program (outer source scratch destination : TapeRegister) : TapeMultiProgram State := + loopCode (decProgram outer) (bodyProgram source scratch destination) + DecState.start bodyStart decPositive + +def start : State := loopTest DecState.start +def done : State := loopDone + +theorem runs_mul {outer source scratch destination : TapeRegister} + (hos : outer ≠ source) (hoc : outer ≠ scratch) (hod : outer ≠ destination) + (hsc : source ≠ scratch) (hsd : source ≠ destination) (hcd : scratch ≠ destination) + (T : TapeTapes) (n m z : ℕ) : + RunsIn (program outer source scratch destination).step + (cfg start (tapes outer source scratch destination T n m 0 z)) + (cfg done (tapes outer source scratch destination T 0 m 0 (z + n * m))) + (n * (10 * m + 14) + 3) := by + induction n generalizing z with + | zero => + have hdec := decrement_empty outer + (tapes outer source scratch destination T 0 m 0 z) (by simp [counterTape]) + have h := loop_exit (decProgram outer) (bodyProgram source scratch destination) + DecState.start bodyStart decPositive hdec rfl rfl + simpa only [program, start, done, Nat.zero_mul, Nat.add_zero, Nat.zero_add] using h + | succ n ih => + have hdec := decrement_cons outer + (tapes outer source scratch destination T (n + 1) m 0 z) + (List.replicate n true) true (by simp [counterTape, List.replicate_succ]) + change RunsIn (decProgram outer).step + (cfg DecState.start (tapes outer source scratch destination T (n + 1) m 0 z)) + (cfg (DecState.done true) (Function.update + (tapes outer source scratch destination T (n + 1) m 0 z) outer (counterTape n))) + 4 at hdec + simp only [update_outer] at hdec + have hbody := runs_body hos hoc hod hsc hsd hcd T n m z + have hit := loop_iter (decProgram outer) (bodyProgram source scratch destination) + DecState.start bodyStart decPositive hdec rfl rfl hbody rfl + have hall := hit.trans (ih (z + m)) + have hacc : z + m + n * m = z + (n + 1) * m := by + rw [Nat.add_mul, Nat.one_mul] + omega + have htime : 4 + 1 + (10 * m + 8) + 1 + (n * (10 * m + 14) + 3) = + (n + 1) * (10 * m + 14) + 3 := by + rw [Nat.add_mul, Nat.one_mul] + omega + simpa only [program, start, done, hacc, htime] using hall + +@[simp] theorem program_done (outer source scratch destination : TapeRegister) (h : TapeHeads) : + program outer source scratch destination done h = none := rfl + +end TapeMultiply +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeNaturalAccess.lean b/lean/OAI/Computability/DepthThree/TapeNaturalAccess.lean new file mode 100644 index 0000000000000000000000000000000000000000..725775175d77ed5fb1d412f9c7cf4b4482eee121 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeNaturalAccess.lean @@ -0,0 +1,87 @@ +import OAI.Computability.DepthThree.TapeStoreRepresentation +import OAI.Computability.DepthThree.LanguageBitConvolutionUpdates + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeNaturalAccess + +open TapeMultiProgram TapeUnary + +theorem take_length (xs : List Bool) (i : ℕ) (hi : i < xs.length) : + (xs.take i).length = i := List.length_take_of_le hi.le + +theorem split (xs : List Bool) (i : ℕ) (hi : i < xs.length) : + xs = xs.take i ++ xs.getD i false :: xs.drop (i + 1) := by + rw [List.getD_eq_getElem _ _ hi, ← List.drop_eq_getElem_cons hi, + List.take_append_drop] + +theorem xorListAt_eq_split (xs : List Bool) (i : ℕ) (hi : i < xs.length) + (v : Bool) : + xorListAt xs i v = + xs.take i ++ Bool.xor (xs.getD i false) v :: xs.drop (i + 1) := by + calc + xorListAt xs i v = xorListAt + (xs.take i ++ xs.getD i false :: xs.drop (i + 1)) (xs.take i).length v := by + rw [take_length xs i hi, ← split xs i hi] + _ = _ := xorListAt_split _ _ _ _ + +theorem read (index array : TapeRegister) (hne : index ≠ array) + (σ : TapeStore) (i : ℕ) (hi : σ index = List.replicate i true) + (hib : i < (σ array).length) : + RunsIn (TapeArray.code index array id).step + (cfg TapeArray.State.start (storeTapes σ)) + (cfg (TapeArray.State.done ((σ array).getD i false)) (storeTapes σ)) + (2 * i + 4) := by + have h := TapeProductTerm.read_at hne (storeTapes σ) + ((σ array).take i) ((σ array).drop (i + 1)) ((σ array).getD i false) + (by simp only [storeTapes_apply, hi, counterTape, take_length _ _ hib]) + (congrArg wordTape (split _ _ hib)) + simpa only [take_length _ _ hib] using h + +theorem xorAt (index array : TapeRegister) (hne : index ≠ array) + (σ : TapeStore) (i : ℕ) (v : Bool) (hi : σ index = List.replicate i true) + (hib : i < (σ array).length) : + RunsIn (TapeArray.code index array (fun old => Bool.xor old v)).step + (cfg TapeArray.State.start (storeTapes σ)) + (cfg (TapeArray.State.done ((σ array).getD i false)) + (storeTapes (Function.update σ array (xorListAt (σ array) i v)))) + (2 * i + 4) := by + have h := TapeProductTerm.modify_at hne (fun old => Bool.xor old v) (storeTapes σ) + ((σ array).take i) ((σ array).drop (i + 1)) ((σ array).getD i false) + (by simp only [storeTapes_apply, hi, counterTape, take_length _ _ hib]) + (congrArg wordTape (split _ _ hib)) + simpa only [take_length _ _ hib, storeTapes_update, xorListAt_eq_split _ _ hib] using h + +theorem productTerm (ia a ib b ic c : TapeRegister) + (hia : ia ≠ a) (hib : ib ≠ b) (hic : ic ≠ c) + (σ : TapeStore) (i j k : ℕ) + (hi : σ ia = List.replicate i true) + (hj : σ ib = List.replicate j true) + (hk : σ ic = List.replicate k true) + (hAi : i < (σ a).length) (hBj : j < (σ b).length) (hCk : k < (σ c).length) : + RunsIn (TapeProductTerm.program ia a ib b ic c).step + (cfg TapeProductTerm.start (storeTapes σ)) + (cfg (TapeProductTerm.done ((σ a).getD i false) ((σ b).getD j false) + ((σ c).getD k false)) + (storeTapes (Function.update σ c + (xorListAt (σ c) k ((σ a).getD i false && (σ b).getD j false))))) + (2 * (i + j + k) + 14) := by + have h := TapeProductTerm.runs_product_term ia a ib b ic c hia hib hic (storeTapes σ) + ((σ a).take i) ((σ a).drop (i + 1)) + ((σ b).take j) ((σ b).drop (j + 1)) + ((σ c).take k) ((σ c).drop (k + 1)) + ((σ a).getD i false) ((σ b).getD j false) ((σ c).getD k false) + (by simp only [storeTapes_apply, hi, counterTape, take_length _ _ hAi]) + (congrArg wordTape (split _ _ hAi)) + (by simp only [storeTapes_apply, hj, counterTape, take_length _ _ hBj]) + (congrArg wordTape (split _ _ hBj)) + (by simp only [storeTapes_apply, hk, counterTape, take_length _ _ hCk]) + (congrArg wordTape (split _ _ hCk)) + simpa only [take_length _ _ hAi, take_length _ _ hBj, take_length _ _ hCk, + storeTapes_update, xorListAt_eq_split _ _ hCk] using h + +end TapeNaturalAccess +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeOutput.lean b/lean/OAI/Computability/DepthThree/TapeOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d2dc0aa71ae9d800dd4610841acd39933e0ed25 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeOutput.lean @@ -0,0 +1,47 @@ +import OAI.Computability.DepthThree.TapeStoreRepresentation + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeOutput + +open TapeMultiProgram TapeRouting + +abbrev State := TapeArray.State ⊕ Bool + +def haltProgram : TapeMultiProgram Bool := fun _ _ => none + +def acceptFlag : TapeArray.State → Bool + | .done b => !b + | _ => false + +def program : TapeMultiProgram State := + joinCode (TapeArray.code TapeRegister.indexA TapeRegister.accumBits id) + haltProgram acceptFlag + +def start : State := .inl .start +def done (answer : Bool) : State := .inr answer + +@[simp] theorem program_done (answer : Bool) (h : TapeHeads) : + program (done answer) h = none := rfl + +theorem runs_output (σ : TapeStore) (b : Bool) (tail : List Bool) + (hi : σ TapeRegister.indexA = []) + (ha : σ TapeRegister.accumBits = b :: tail) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg (done (!b)) (storeTapes σ)) 5 := by + have hr := TapeProductTerm.read_at + (index := TapeRegister.indexA) (array := TapeRegister.accumBits) + (by decide) (storeTapes σ) [] tail b + (by simp [storeTapes, TapeUnary.counterTape, hi]) + (by simp [storeTapes, ha]) + have hh := join_runs (TapeArray.code TapeRegister.indexA TapeRegister.accumBits id) + haltProgram acceptFlag hr rfl + (RunsIn.refl haltProgram.step (cfg (!b) (storeTapes σ))) + simpa only [State, program, start, done, acceptFlag, List.length_nil, Nat.mul_zero, + Nat.zero_add, Nat.add_zero] using hh + +end TapeOutput +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeParameterCost.lean b/lean/OAI/Computability/DepthThree/TapeParameterCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..273ea516b4cfb318d56c1fc526a2da263035c348 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeParameterCost.lean @@ -0,0 +1,135 @@ +import OAI.Computability.DepthThree.TapeParameterSearch +import Mathlib.Algebra.Order.BigOperators.Group.Finset + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeParameterCost + +open scoped BigOperators + +private theorem pow_bound {c k : ℕ} (hk : k ≤ 7) : c ^ k ≤ (c + 1) ^ 7 := + Nat.le_trans (Nat.pow_le_pow_left (Nat.le_succ c) k) + (Nat.pow_le_pow_right (Nat.succ_pos c) hk) + +private theorem power_positive (c : ℕ) : 1 ≤ (c + 1) ^ 7 := + Nat.pow_pos (Nat.succ_pos c) + +theorem power_cost {k : ℕ} (hk : k ≤ 6) (c : ℕ) : + TapePower.cost k 1 c ≤ 108 * (c + 1) ^ 7 := by + have hs : (∑ j ∈ Finset.range k, c ^ j) ≤ 6 * (c + 1) ^ 6 := by + calc + (∑ j ∈ Finset.range k, c ^ j) ≤ ∑ _j ∈ Finset.range k, (c + 1) ^ 6 := by + apply Finset.sum_le_sum + intro j hj + have hjk := Finset.mem_range.mp hj + exact Nat.le_trans (Nat.pow_le_pow_left (Nat.le_succ c) j) + (Nat.pow_le_pow_right (Nat.succ_pos c) (by omega : j ≤ 6)) + _ = k * (c + 1) ^ 6 := by simp + _ ≤ 6 * (c + 1) ^ 6 := Nat.mul_le_mul_right _ hk + have hc : 10 * c + 14 ≤ 14 * (c + 1) := by omega + have hp := power_positive c + calc + TapePower.cost k 1 c = (10 * c + 14) * (∑ j ∈ Finset.range k, c ^ j) + 4 * k := by + rw [TapePower.cost_eq_sum, Nat.one_mul] + _ ≤ (10 * c + 14) * (6 * (c + 1) ^ 6) + 24 := + Nat.add_le_add (Nat.mul_le_mul_left _ hs) (by omega) + _ ≤ (14 * (c + 1)) * (6 * (c + 1) ^ 6) + 24 := + Nat.add_le_add_right (Nat.mul_le_mul_right _ hc) _ + _ = 84 * (c + 1) ^ 7 + 24 := by ring + _ ≤ 108 * (c + 1) ^ 7 := by omega + +theorem compare_cost {k : ℕ} (hk : k ≤ 6) (c D : ℕ) : + TapePowerCompare.cost k c D ≤ 124 * (c + 1) ^ 7 := by + have hp := power_cost hk c + have hmin := Nat.le_trans (Nat.min_le_left (c ^ k) D) (pow_bound (by omega : k ≤ 7)) + have hpos := power_positive c + unfold TapePowerCompare.cost + omega + +theorem body_cost {k : ℕ} (hk : k ≤ 6) (two : Bool) (c : ℕ) : + TapeSearchBody.cost k two c ≤ 16 * (c + 1) ^ 7 := by + have hp : c ^ k ≤ (c + 1) ^ 7 := pow_bound (by omega) + have hpos := power_positive c + cases two <;> simp [TapeSearchBody.cost, TapeSearchBody.incrementCost] <;> omega + +theorem search_cost {k : ℕ} (hk : k ≤ 6) (two : Bool) (D fuel c B : ℕ) + (hc : c + TapeSearchBody.amount two * fuel ≤ B) : + TapePowerSearch.cost k two D fuel c ≤ (fuel + 1) * 144 * (B + 1) ^ 7 := by + induction fuel generalizing c with + | zero => + have hcB : c ≤ B := by simpa using hc + have hp : (c + 1) ^ 7 ≤ (B + 1) ^ 7 := + Nat.pow_le_pow_left (Nat.add_le_add_right hcB 1) 7 + have hcmp := Nat.le_trans (compare_cost hk c D) (Nat.mul_le_mul_left 124 hp) + have hpos := power_positive B + simp only [TapePowerSearch.cost, Nat.zero_add, Nat.one_mul] + omega + | succ fuel ih => + have hcB : c ≤ B := by omega + have hnext : c + TapeSearchBody.amount two + TapeSearchBody.amount two * fuel ≤ B := by + rw [Nat.mul_succ] at hc + omega + have hr := ih (c + TapeSearchBody.amount two) hnext + have hp : (c + 1) ^ 7 ≤ (B + 1) ^ 7 := + Nat.pow_le_pow_left (Nat.add_le_add_right hcB 1) 7 + have hcmp := Nat.le_trans (compare_cost hk c D) (Nat.mul_le_mul_left 124 hp) + have hb := Nat.le_trans (body_cost hk two c) (Nat.mul_le_mul_left 16 hp) + have hpos := power_positive B + have hprefix : TapePowerCompare.cost k c D + 1 + TapeSearchBody.cost k two c + 1 ≤ + 144 * (B + 1) ^ 7 := by omega + calc + TapePowerSearch.cost k two D (fuel + 1) c ≤ + 144 * (B + 1) ^ 7 + (fuel + 1) * 144 * (B + 1) ^ 7 := + Nat.add_le_add hprefix hr + _ = (fuel + 1 + 1) * 144 * (B + 1) ^ 7 := by ring + +theorem cube_cost (d : ℕ) : TapeParameterSearch.cubeCost d ≤ 200 * (d + 3) ^ 8 := by + have hr := hashDimension_le d + have hs := search_cost (by decide : 3 ≤ 6) false (d ^ 2) (hashDimension d) 0 d + (by simpa [TapeSearchBody.amount] using hr) + have hprod : (hashDimension d + 1) * 144 * (d + 1) ^ 7 ≤ 144 * (d + 1) ^ 8 := by + calc + _ ≤ (d + 1) * 144 * (d + 1) ^ 7 := + Nat.mul_le_mul_right _ (Nat.mul_le_mul_right _ (Nat.add_le_add_right hr 1)) + _ = _ := by ring + have hs' := Nat.le_trans hs hprod + have hbase : (d + 1) ^ 8 ≤ (d + 3) ^ 8 := Nat.pow_le_pow_left (by omega) 8 + have hsearch := Nat.le_trans hs' (Nat.mul_le_mul_left 144 hbase) + have hp : (hashDimension d) ^ 3 ≤ (d + 3) ^ 8 := + Nat.le_trans (Nat.pow_le_pow_left (by omega : hashDimension d ≤ d + 3) 3) + (Nat.pow_le_pow_right (by omega : 0 < d + 3) (by decide : 3 ≤ 8)) + have hpos : 1 ≤ (d + 3) ^ 8 := Nat.pow_pos (by omega) + unfold TapeParameterSearch.cubeCost + omega + +theorem sixth_cost (d : ℕ) : TapeParameterSearch.sixthCost d ≤ 200 * (d + 3) ^ 8 := by + have ht := independenceOrder_le d + have he := independenceOrder_even d + have hterminal : 2 * (independenceOrder d / 2 + 1) = independenceOrder d + 2 := by + obtain ⟨a, ha⟩ := he + omega + have hs := search_cost (by decide : 6 ≤ 6) true d + (independenceOrder d / 2 + 1) 0 (d + 2) + (by simp [TapeSearchBody.amount]; omega) + have hprod : (independenceOrder d / 2 + 1 + 1) * 144 * (d + 2 + 1) ^ 7 ≤ + 144 * (d + 3) ^ 8 := by + calc + _ ≤ (d + 3) * 144 * (d + 3) ^ 7 := by + apply Nat.mul_le_mul + · exact Nat.mul_le_mul_right 144 (by omega) + · apply Nat.pow_le_pow_left + omega + _ = _ := by ring + have hsearch := Nat.le_trans hs hprod + have hp : (independenceOrder d + 2) ^ 6 ≤ (d + 3) ^ 8 := + Nat.le_trans (Nat.pow_le_pow_left (by omega : independenceOrder d + 2 ≤ d + 3) 6) + (Nat.pow_le_pow_right (by omega : 0 < d + 3) (by decide : 6 ≤ 8)) + have hpos : 1 ≤ (d + 3) ^ 8 := Nat.pow_pos (by omega) + unfold TapeParameterSearch.sixthCost + omega + +end TapeParameterCost +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeParameterSearch.lean b/lean/OAI/Computability/DepthThree/TapeParameterSearch.lean new file mode 100644 index 0000000000000000000000000000000000000000..65643a13a117218c86f930088bdff07dc7c5336a --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeParameterSearch.lean @@ -0,0 +1,135 @@ +import OAI.Computability.DepthThree.TapePowerSearch + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeParameterSearch + +open TapeMultiProgram TapeRouting TapeUnary TapePowerSearch + +private theorem erase_output (k : ℕ) (R : Registers) (σ : TapeStore) (c : ℕ) + (ho : σ (R 0) = []) (hd : σ (R 3) = []) : + RunsIn (TapeErase.code (TapePower.resultRegister k (R 0) (R 3))).step + (cfg TapeErase.State.start (storeTapes (TapePowerCompare.outputStore k (R 0) (R 3) + (candidateStore R σ c) c))) + (cfg TapeErase.State.done (storeTapes (candidateStore R σ c))) (2 * c ^ k + 5) := by + have h := TapeStoreRuns.erase (TapePower.resultRegister k (R 0) (R 3)) + (TapePowerCompare.outputStore k (R 0) (R 3) (candidateStore R σ c) c) + have ho' : candidateStore R σ c (R 0) = [] := by + simpa [candidateStore, R.injective.ne (by decide : (0 : Fin 5) ≠ 1)] using ho + have hd' : candidateStore R σ c (R 3) = [] := by + simpa [candidateStore, R.injective.ne (by decide : (3 : Fin 5) ≠ 1)] using hd + simpa only [TapePowerCompare.outputStore_result, List.length_replicate, + TapePowerCompare.outputStore_clear k (R 0) (R 3) (candidateStore R σ c) c ho' hd'] using h + +private theorem decrement_candidate (R : Registers) (σ : TapeStore) (c : ℕ) : + RunsIn (decProgram (R 1)).step + (cfg DecState.start (storeTapes (candidateStore R σ (c + 1)))) + (cfg (DecState.done true) (storeTapes (candidateStore R σ c))) 4 := by + have h := decrement_cons (R 1) (storeTapes (candidateStore R σ (c + 1))) + (List.replicate c true) true (by + simp [storeTapes, candidateStore, List.replicate_succ]) + have he : Function.update (storeTapes (candidateStore R σ (c + 1))) (R 1) + (wordTape (List.replicate c true)) = storeTapes (candidateStore R σ c) := by + rw [← storeTapes_update] + simp [candidateStore] + simpa only [he] using h + +abbrev CubeState := TapePowerSearch.State 3 ⊕ TapeErase.State + +def cubeProgram (R : Registers) : TapeMultiProgram CubeState := + joinCode (TapePowerSearch.program 3 false continueLt R) + (TapeErase.code (TapePower.resultRegister 3 (R 0) (R 3))) + (fun _ => TapeErase.State.start) + +def cubeStart : CubeState := .inl (TapePowerSearch.start 3) +def cubeDone : CubeState := .inr .done + +def cubeCost (d : ℕ) : ℕ := + TapePowerSearch.cost 3 false (d ^ 2) (hashDimension d) 0 + 1 + + (2 * (hashDimension d) ^ 3 + 5) + +theorem runs_cube (R : Registers) (σ : TapeStore) (d : ℕ) + (ho : σ (R 0) = []) (hs : σ (R 2) = []) (hd : σ (R 3) = []) + (ht : σ (R 4) = List.replicate (d ^ 2) true) : + RunsIn (cubeProgram R).step + (cfg cubeStart (storeTapes (candidateStore R σ 0))) + (cfg cubeDone (storeTapes (candidateStore R σ (hashDimension d)))) + (cubeCost d) := by + have hc := TapePowerSearch.runs_cube R σ d ho hs hd ht + have he := erase_output 3 R σ (hashDimension d) ho hd + exact join_runs _ _ _ hc rfl he + +@[simp] theorem cube_done (R : Registers) (h : TapeHeads) : + cubeProgram R cubeDone h = none := rfl + +abbrev DecreaseState := DecState ⊕ DecState + +def decreaseProgram (R : Registers) : TapeMultiProgram DecreaseState := + joinCode (decProgram (R 1)) (decProgram (R 1)) (fun _ => DecState.start) + +def decreaseStart : DecreaseState := .inl .start +def decreaseDone : DecreaseState := .inr (.done true) + +theorem runs_decrease (R : Registers) (σ : TapeStore) (c : ℕ) : + RunsIn (decreaseProgram R).step + (cfg decreaseStart (storeTapes (candidateStore R σ (c + 2)))) + (cfg decreaseDone (storeTapes (candidateStore R σ c))) 9 := by + have h₁ := decrement_candidate R σ (c + 1) + have h₂ := decrement_candidate R σ c + have h := join_runs (decProgram (R 1)) (decProgram (R 1)) + (fun _ => DecState.start) h₁ rfl h₂ + have he : c + 1 + 1 = c + 2 := by omega + simpa only [decreaseProgram, decreaseStart, decreaseDone, he] using h + +abbrev CleanupState := TapeErase.State ⊕ DecreaseState + +def cleanupProgram (R : Registers) : TapeMultiProgram CleanupState := + joinCode (TapeErase.code (TapePower.resultRegister 6 (R 0) (R 3))) + (decreaseProgram R) (fun _ => decreaseStart) + +def cleanupStart : CleanupState := .inl .start +def cleanupDone : CleanupState := .inr decreaseDone + +theorem runs_cleanup (R : Registers) (σ : TapeStore) (c : ℕ) + (ho : σ (R 0) = []) (hd : σ (R 3) = []) : + RunsIn (cleanupProgram R).step + (cfg cleanupStart (storeTapes (TapePowerCompare.outputStore 6 (R 0) (R 3) + (candidateStore R σ (c + 2)) (c + 2)))) + (cfg cleanupDone (storeTapes (candidateStore R σ c))) + (2 * (c + 2) ^ 6 + 5 + 1 + 9) := by + have he := erase_output 6 R σ (c + 2) ho hd + have hd := runs_decrease R σ c + exact join_runs _ _ _ he rfl hd + +abbrev SixthState := TapePowerSearch.State 6 ⊕ CleanupState + +def sixthProgram (R : Registers) : TapeMultiProgram SixthState := + joinCode (TapePowerSearch.program 6 true continueLe R) (cleanupProgram R) + (fun _ => cleanupStart) + +def sixthStart : SixthState := .inl (TapePowerSearch.start 6) +def sixthDone : SixthState := .inr cleanupDone + +def sixthCost (d : ℕ) : ℕ := + TapePowerSearch.cost 6 true d (independenceOrder d / 2 + 1) 0 + 1 + + (2 * (independenceOrder d + 2) ^ 6 + 5 + 1 + 9) + +theorem runs_sixth (R : Registers) (σ : TapeStore) (d : ℕ) + (ho : σ (R 0) = []) (hs : σ (R 2) = []) (hd : σ (R 3) = []) + (ht : σ (R 4) = List.replicate d true) : + RunsIn (sixthProgram R).step + (cfg sixthStart (storeTapes (candidateStore R σ 0))) + (cfg sixthDone (storeTapes (candidateStore R σ (independenceOrder d)))) + (sixthCost d) := by + have hs := TapePowerSearch.runs_sixth_boundary R σ d ho hs hd ht + have hc := runs_cleanup R σ (independenceOrder d) ho hd + exact join_runs _ _ _ hs rfl hc + +@[simp] theorem sixth_done (R : Registers) (h : TapeHeads) : + sixthProgram R sixthDone h = none := rfl + +end TapeParameterSearch +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeParameters.lean b/lean/OAI/Computability/DepthThree/TapeParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e6d1fb44de5e368b9221f0b6afb327280d694ae --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeParameters.lean @@ -0,0 +1,243 @@ +import OAI.Computability.DepthThree.TapeParameterSearch +import OAI.Computability.DepthThree.TapeDivideFive +import Mathlib.Tactic.FinCases + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeParameters + +open TapeMultiProgram TapeRouting TapeUnary TapeCopy + +def cubeRegisters : TapePowerSearch.Registers where + toFun i := if i = 0 then 7 else if i = 1 then 3 else if i = 2 then 9 + else if i = 3 then 5 else 6 + inj' := by intro i j; fin_cases i <;> fin_cases j <;> decide + +def sixthRegisters : TapePowerSearch.Registers where + toFun i := if i = 0 then 7 else if i = 1 then 4 else if i = 2 then 9 + else if i = 3 then 5 else 2 + inj' := by intro i j; fin_cases i <;> fin_cases j <;> decide + +@[simp] theorem cubeRegisters_zero : cubeRegisters 0 = 7 := rfl +@[simp] theorem cubeRegisters_one : cubeRegisters 1 = 3 := rfl +@[simp] theorem cubeRegisters_two : cubeRegisters 2 = 9 := rfl +@[simp] theorem cubeRegisters_three : cubeRegisters 3 = 5 := rfl +@[simp] theorem cubeRegisters_four : cubeRegisters 4 = 6 := rfl +@[simp] theorem sixthRegisters_zero : sixthRegisters 0 = 7 := rfl +@[simp] theorem sixthRegisters_one : sixthRegisters 1 = 4 := rfl +@[simp] theorem sixthRegisters_two : sixthRegisters 2 = 9 := rfl +@[simp] theorem sixthRegisters_three : sixthRegisters 3 = 5 := rfl +@[simp] theorem sixthRegisters_four : sixthRegisters 4 = 2 := rfl + +def dataStore (σ : TapeStore) (n : ℕ) : TapeStore := + Function.update σ 2 (List.replicate (dataDimension n) true) + +def outputStore (σ : TapeStore) (n : ℕ) : TapeStore := + Function.update + (Function.update (dataStore σ n) 3 (List.replicate (hashDimension (dataDimension n)) true)) + 4 (List.replicate (independenceOrder (dataDimension n)) true) + +@[simp] theorem outputStore_data (σ : TapeStore) (n : ℕ) : + outputStore σ n 2 = List.replicate (dataDimension n) true := by + simp [outputStore, dataStore] + +@[simp] theorem outputStore_hash (σ : TapeStore) (n : ℕ) : + outputStore σ n 3 = List.replicate (hashDimension (dataDimension n)) true := by + simp [outputStore] + +@[simp] theorem outputStore_order (σ : TapeStore) (n : ℕ) : + outputStore σ n 4 = List.replicate (independenceOrder (dataDimension n)) true := by + simp [outputStore] + +theorem outputStore_other (σ : TapeStore) (n : ℕ) (r : TapeRegister) + (h2 : r ≠ 2) (h3 : r ≠ 3) (h4 : r ≠ 4) : outputStore σ n r = σ r := by + simp [outputStore, dataStore, Function.update, h2, h3, h4] + +abbrev LengthState := TapeCopy.State ⊕ TapeDivideFive.State + +def lengthProgram : TapeMultiProgram LengthState := + joinCode (TapeCopy.code 1 5) (TapeDivideFive.program 5 2) + (fun _ => TapeDivideFive.State.dec 0 .start) + +def lengthStart : LengthState := .inl .start +def lengthDone (n : ℕ) : LengthState := .inr (.done (TapeDivideFive.residue n)) + +theorem runs_length (σ : TapeStore) (n : ℕ) + (h1 : σ 1 = List.replicate n true) (h2 : σ 2 = []) (h5 : σ 5 = []) : + RunsIn lengthProgram.step (cfg lengthStart (storeTapes σ)) + (cfg (lengthDone n) (storeTapes (dataStore σ n))) (10 * n + 8) := by + let copied := Function.update σ 5 (List.replicate n true) + have hcopy := TapeStoreRuns.copy (src := 1) (dst := 5) (by decide) σ h5 + simp only [h1, List.length_replicate] at hcopy + have hi : onPair 5 2 (storeTapes copied) (counterTape n) (counterTape 0) = + storeTapes copied := + TapeProductTerm.onPair_eq_self (by simp [copied, storeTapes, counterTape]) + (by simp [copied, storeTapes, counterTape, h2]) + have hrestore : Function.update copied 5 [] = σ := by + dsimp [copied] + rw [Function.update_idem] + exact Function.update_eq_self_iff.mpr h5.symm + have ho : onPair 5 2 (storeTapes copied) (counterTape 0) (counterTape (n / 5)) = + storeTapes (dataStore σ n) := by + have he : onPair 5 2 (storeTapes copied) (counterTape 0) (counterTape (n / 5)) = + storeTapes (Function.update (Function.update copied 5 []) 2 + (List.replicate (n / 5) true)) := by + rw [onPair_eq_updates (by decide : (5 : TapeRegister) ≠ 2)] + simp only [storeTapes_update, counterTape, List.replicate_zero] + simpa only [hrestore, dataStore, dataDimension] using he + have hdivide := TapeDivideFive.runs_divide (counter := 5) (destination := 2) + (by decide) (storeTapes copied) n 0 + simp only [Nat.zero_add, hi, ho] at hdivide + have h := join_runs (TapeCopy.code 1 5) (TapeDivideFive.program 5 2) + (fun _ => TapeDivideFive.State.dec 0 .start) hcopy rfl hdivide + have hc : 2 * n + 4 + 1 + (8 * n + 3) = 10 * n + 8 := by omega + simpa only [lengthProgram, lengthStart, lengthDone, copied, hc] using h + +abbrev SquareState := IncState ⊕ TapePower.State 2 + +def squareProgram : TapeMultiProgram SquareState := + joinCode (incProgram 6) (TapePower.program 2 6 2 7 5) (fun _ => TapePower.start 2) + +def squareStart : SquareState := .inl .start +def squareDone : SquareState := .inr (TapePower.done 2) +def squareCost (d : ℕ) : ℕ := 2 + 1 + TapePower.cost 2 1 d + +theorem runs_square (σ : TapeStore) (d : ℕ) + (h2 : σ 2 = List.replicate d true) (h5 : σ 5 = []) + (h6 : σ 6 = []) (h7 : σ 7 = []) : + RunsIn squareProgram.step (cfg squareStart (storeTapes σ)) + (cfg squareDone (storeTapes (Function.update σ 6 (List.replicate (d ^ 2) true)))) + (squareCost d) := by + have hinc := increment 6 (storeTapes σ) 0 (by simp [storeTapes, counterTape, h6]) + have hinner : onPair 7 5 (storeTapes σ) (counterTape 0) (counterTape 0) = + storeTapes σ := TapeProductTerm.onPair_eq_self + (by simp [storeTapes, counterTape, h7]) (by simp [storeTapes, counterTape, h5]) + have houter : onPair 6 2 (storeTapes σ) (counterTape 0) (counterTape d) = + storeTapes σ := TapeProductTerm.onPair_eq_self + (by simp [storeTapes, counterTape, h6]) (by simp [storeTapes, counterTape, h2]) + have hi : TapeMultiply.tapes 6 2 7 5 (storeTapes σ) 1 d 0 0 = + Function.update (storeTapes σ) 6 (counterTape 1) := by + unfold TapeMultiply.tapes + rw [hinner] + simpa only [houter] using + (TapeArithmetic.update_onPair_src 6 2 (storeTapes σ) + (counterTape 0) (counterTape d) (counterTape 1)).symm + have hp := TapePower.runs_power 2 (outer := 6) (source := 2) (scratch := 7) + (destination := 5) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) (storeTapes σ) 1 d + have ho := TapePowerCompare.result_store 2 (outer := 6) (source := 2) (scratch := 7) + (destination := 5) (by decide) (by decide) (by decide) (by decide) (by decide) + (by decide) σ d h6 h2 h7 h5 + change TapePower.resultTapes 2 6 2 7 5 (storeTapes σ) 1 d = + storeTapes (Function.update σ 6 (List.replicate (d ^ 2) true)) at ho + rw [hi, ho] at hp + exact join_runs _ _ _ hinc rfl hp + +abbrev FinishState := TapeErase.State ⊕ TapeParameterSearch.SixthState + +def finishProgram : TapeMultiProgram FinishState := + joinCode (TapeErase.code 6) (TapeParameterSearch.sixthProgram sixthRegisters) + (fun _ => TapeParameterSearch.sixthStart) + +def finishStart : FinishState := .inl .start +def finishDone : FinishState := .inr TapeParameterSearch.sixthDone + +abbrev RootsState := TapeParameterSearch.CubeState ⊕ FinishState + +def rootsProgram : TapeMultiProgram RootsState := + joinCode (TapeParameterSearch.cubeProgram cubeRegisters) finishProgram (fun _ => finishStart) + +def rootsStart : RootsState := .inl TapeParameterSearch.cubeStart +def rootsDone : RootsState := .inr finishDone + +abbrev WorkState := SquareState ⊕ RootsState + +def workProgram : TapeMultiProgram WorkState := + joinCode squareProgram rootsProgram (fun _ => rootsStart) + +def workStart : WorkState := .inl squareStart +def workDone : WorkState := .inr rootsDone + +abbrev State := LengthState ⊕ WorkState + +def program : TapeMultiProgram State := + joinCode lengthProgram workProgram (fun _ => workStart) + +def start : State := .inl lengthStart +def done : State := .inr workDone + +def cost (n : ℕ) : ℕ := + 10 * n + 2 * (dataDimension n) ^ 2 + 20 + TapePower.cost 2 1 (dataDimension n) + + TapeParameterSearch.cubeCost (dataDimension n) + + TapeParameterSearch.sixthCost (dataDimension n) + +private theorem candidate_zero (R : TapePowerSearch.Registers) (σ : TapeStore) + (h : σ (R 1) = []) : TapePowerSearch.candidateStore R σ 0 = σ := by + change Function.update σ (R 1) [] = σ + exact Function.update_eq_self_iff.mpr h.symm + +theorem runs_parameters (σ : TapeStore) (n : ℕ) + (h1 : σ 1 = List.replicate n true) + (h2 : σ 2 = []) (h3 : σ 3 = []) (h4 : σ 4 = []) + (h5 : σ 5 = []) (h6 : σ 6 = []) (h7 : σ 7 = []) (h9 : σ 9 = []) : + RunsIn program.step (cfg start (storeTapes σ)) + (cfg done (storeTapes (outputStore σ n))) (cost n) := by + let d := dataDimension n + let σD := dataStore σ n + let σS := Function.update σD 6 (List.replicate (d ^ 2) true) + let σC := Function.update σS 3 (List.replicate (hashDimension d) true) + let σR := Function.update σD 3 (List.replicate (hashDimension d) true) + have hlength := runs_length σ n h1 h2 h5 + have hsquare := runs_square σD d (by simp [σD, dataStore, d]) + (by simpa [σD, dataStore] using h5) (by simpa [σD, dataStore] using h6) + (by simpa [σD, dataStore] using h7) + have hcube := TapeParameterSearch.runs_cube cubeRegisters σS d + (by simpa [σS, σD, dataStore] using h7) + (by simpa [σS, σD, dataStore] using h9) + (by simpa [σS, σD, dataStore] using h5) + (by simp [σS]) + have hc0 : TapePowerSearch.candidateStore cubeRegisters σS 0 = σS := + candidate_zero cubeRegisters σS (by simpa [σS, σD, dataStore] using h3) + rw [hc0] at hcube + change RunsIn (TapeParameterSearch.cubeProgram cubeRegisters).step + (cfg TapeParameterSearch.cubeStart (storeTapes σS)) + (cfg TapeParameterSearch.cubeDone (storeTapes σC)) + (TapeParameterSearch.cubeCost d) at hcube + have herase := TapeStoreRuns.erase 6 σC + have hclear : Function.update σC 6 [] = σR := by + funext r + by_cases hr : r = 6 + · subst r + simp [σR, σD, dataStore, h6] + · simp [σC, σR, σS, Function.update, hr] + have hc6 : σC 6 = List.replicate (d ^ 2) true := by simp [σC, σS] + rw [hclear, hc6, List.length_replicate] at herase + have hsixth := TapeParameterSearch.runs_sixth sixthRegisters σR d + (by simpa [σR, σD, dataStore] using h7) + (by simpa [σR, σD, dataStore] using h9) + (by simpa [σR, σD, dataStore] using h5) + (by simp [σR, σD, dataStore, d]) + have hs0 : TapePowerSearch.candidateStore sixthRegisters σR 0 = σR := + candidate_zero sixthRegisters σR (by simpa [σR, σD, dataStore] using h4) + rw [hs0] at hsixth + change RunsIn (TapeParameterSearch.sixthProgram sixthRegisters).step + (cfg TapeParameterSearch.sixthStart (storeTapes σR)) + (cfg TapeParameterSearch.sixthDone (storeTapes (outputStore σ n))) + (TapeParameterSearch.sixthCost d) at hsixth + have hfinish := join_runs (TapeErase.code 6) (TapeParameterSearch.sixthProgram sixthRegisters) + (fun _ => TapeParameterSearch.sixthStart) herase rfl hsixth + have hroots := join_runs (TapeParameterSearch.cubeProgram cubeRegisters) finishProgram + (fun _ => finishStart) hcube rfl hfinish + have hwork := join_runs squareProgram rootsProgram (fun _ => rootsStart) hsquare rfl hroots + have h := join_runs lengthProgram workProgram (fun _ => workStart) hlength rfl hwork + apply h.mono + dsimp only [cost, squareCost, d] + omega + +@[simp] theorem program_done (h : TapeHeads) : program done h = none := rfl + +end TapeParameters +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeParametersBound.lean b/lean/OAI/Computability/DepthThree/TapeParametersBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a3d77c84f086253cf05ec50481611633bd27cb5 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeParametersBound.lean @@ -0,0 +1,37 @@ +import OAI.Computability.DepthThree.TapeParameters +import OAI.Computability.DepthThree.TapeParameterCost + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeParameters + +theorem cost_le (n : ℕ) : cost n ≤ 600 * (n + 3) ^ 8 := by + have hd : dataDimension n ≤ n := Nat.div_le_self n 5 + have hbase : (dataDimension n + 3) ^ 8 ≤ (n + 3) ^ 8 := + Nat.pow_le_pow_left (Nat.add_le_add_right hd 3) 8 + have hc := Nat.le_trans (TapeParameterCost.cube_cost (dataDimension n)) + (Nat.mul_le_mul_left 200 hbase) + have hs := Nat.le_trans (TapeParameterCost.sixth_cost (dataDimension n)) + (Nat.mul_le_mul_left 200 hbase) + have hpbase : (dataDimension n + 1) ^ 7 ≤ (n + 3) ^ 8 := + Nat.le_trans (Nat.pow_le_pow_left (by omega : dataDimension n + 1 ≤ n + 3) 7) + (Nat.pow_le_pow_right (by omega : 0 < n + 3) (by decide : 7 ≤ 8)) + have hp := Nat.le_trans (TapeParameterCost.power_cost (by decide : 2 ≤ 6) + (dataDimension n)) (Nat.mul_le_mul_left 108 hpbase) + have hn : n ≤ (n + 3) ^ 8 := by + calc + n ≤ n + 3 := by omega + _ = (n + 3) ^ 1 := by simp + _ ≤ (n + 3) ^ 8 := Nat.pow_le_pow_right (by omega) (by decide) + have hd2 : (dataDimension n) ^ 2 ≤ (n + 3) ^ 8 := + Nat.le_trans (Nat.pow_le_pow_left (by omega : dataDimension n ≤ n + 3) 2) + (Nat.pow_le_pow_right (by omega : 0 < n + 3) (by decide : 2 ≤ 8)) + have hpos : 1 ≤ (n + 3) ^ 8 := Nat.pow_pos (by omega) + unfold cost + omega + +end TapeParameters +end DepthThreeLowerBound + +end OAI diff --git a/lean/OAI/Computability/DepthThree/TapeParse.lean b/lean/OAI/Computability/DepthThree/TapeParse.lean new file mode 100644 index 0000000000000000000000000000000000000000..643c2c2c5fba4cd773d1e720a4e0836beac55ab9 --- /dev/null +++ b/lean/OAI/Computability/DepthThree/TapeParse.lean @@ -0,0 +1,120 @@ +import OAI.Computability.DepthThree.TapeInitialization +import OAI.Computability.DepthThree.TapeParametersBound +import OAI.Computability.DepthThree.TapeInputGuard + +namespace OAI + +namespace DepthThreeLowerBound +namespace TapeParse + +open TapeMultiProgram TapeRouting + +def inputStore (w : List Bool) : TapeStore := fun r => + if r = TapeRegister.input then w + else if r = TapeRegister.length then List.replicate w.length true else [] + +theorem initializedTapes_eq_store (w : List Bool) : + initializedTapes w = storeTapes (inputStore w) := by + funext r + unfold initializedTapes storeTapes inputStore + split_ifs <;> rfl + +def outputStore (w : List Bool) : TapeStore := + TapeInputGuard.outputStore (TapeParameters.outputStore (inputStore w) w.length) + (dataDimension w.length) (hashDimension (dataDimension w.length)) + (independenceOrder (dataDimension w.length)) + +@[simp] theorem outputStore_input (w : List Bool) : outputStore w 0 = w := by + simp [outputStore, TapeInputGuard.outputStore, TapeParameters.outputStore, + TapeParameters.dataStore, inputStore, TapeRegister.input] + +@[simp] theorem outputStore_data (w : List Bool) : + outputStore w 2 = List.replicate (dataDimension w.length) true := by + simp [outputStore, TapeInputGuard.outputStore] + +@[simp] theorem outputStore_hash (w : List Bool) : + outputStore w 3 = List.replicate (hashDimension (dataDimension w.length)) true := by + simp [outputStore, TapeInputGuard.outputStore] + +@[simp] theorem outputStore_order (w : List Bool) : + outputStore w 4 = List.replicate (independenceOrder (dataDimension w.length)) true := by + simp [outputStore, TapeInputGuard.outputStore] + +theorem outputStore_empty (w : List Bool) (r : TapeRegister) + (h0 : r ≠ 0) (h1 : r ≠ 1) (h2 : r ≠ 2) (h3 : r ≠ 3) + (h4 : r ≠ 4) (h8 : r ≠ 8) : outputStore w r = [] := by + simp [outputStore, TapeInputGuard.outputStore, TapeParameters.outputStore, + TapeParameters.dataStore, inputStore, TapeRegister.input, TapeRegister.length, + Function.update, h0, h1, h2, h3, h4, h8] + +abbrev WorkState := TapeParameters.State ⊕ TapeInputGuard.State + +def workProgram : TapeMultiProgram WorkState := + joinCode TapeParameters.program TapeInputGuard.program (fun _ => TapeInputGuard.start) + +def workStart : WorkState := .inl TapeParameters.start +def workDone (accepted : Bool) : WorkState := .inr (TapeInputGuard.done accepted) + +abbrev State := InitState ⊕ WorkState + +def program : TapeMultiProgram State := + joinCode initializationCode workProgram (fun _ => workStart) + +def start : State := .inl InitState.start +def done (accepted : Bool) : State := .inr (workDone accepted) + +def acceptFlag : State → Bool + | .inr (.inr (.inr (.inr (.done b)))) => b + | _ => false + +@[simp] theorem acceptFlag_done (b : Bool) : acceptFlag (done b) = b := rfl + +@[simp] theorem program_done (b : Bool) (h : TapeHeads) : program (done b) h = none := rfl + +theorem runs_parse (w : List Bool) : + RunsIn program.step (cfg start (rawInputTapes w)) + (cfg (done (decide (InputFits w))) (storeTapes (outputStore w))) + (1000 * (w.length + 3) ^ 8) := by + let σ := inputStore w + let τ := TapeParameters.outputStore σ w.length + have hi := initialization_runs w + rw [initializedTapes_eq_store] at hi + have hp := TapeParameters.runs_parameters σ w.length + (by simp [σ, inputStore, TapeRegister.input, TapeRegister.length]) + (by simp [σ, inputStore, TapeRegister.input, TapeRegister.length]) + (by simp [σ, inputStore, TapeRegister.input, TapeRegister.length]) + (by simp [σ, inputStore, TapeRegister.input, TapeRegister.length]) + (by simp [σ, inputStore, TapeRegister.input, TapeRegister.length]) + (by simp [σ, inputStore, TapeRegister.input, TapeRegister.length]) + (by simp [σ, inputStore, TapeRegister.input, TapeRegister.length]) + (by simp [σ, inputStore, TapeRegister.input, TapeRegister.length]) + have hp' := hp.mono (TapeParameters.cost_le w.length) + have hg := TapeInputGuard.runs_inputFits_quadratic w τ + (by simp [τ, σ, TapeParameters.outputStore, TapeParameters.dataStore, + inputStore, TapeRegister.input, TapeRegister.length]) + (by simp [τ]) (by simp [τ]) (by simp [τ]) + (by simp [τ, σ, TapeParameters.outputStore, TapeParameters.dataStore, + inputStore, TapeRegister.input, TapeRegister.length]) + (by simp [τ, σ, TapeParameters.outputStore, TapeParameters.dataStore, + inputStore, TapeRegister.input, TapeRegister.length]) + (by simp [τ, σ, TapeParameters.outputStore, TapeParameters.dataStore, + inputStore, TapeRegister.input, TapeRegister.length]) + have hw := join_runs TapeParameters.program TapeInputGuard.program + (fun _ => TapeInputGuard.start) hp' (by simp) hg + have hall := join_runs initializationCode workProgram (fun _ => workStart) hi rfl hw + apply hall.mono + have hquad : (w.length + 1) ^ 2 ≤ (w.length + 3) ^ 8 := + Nat.le_trans (Nat.pow_le_pow_left (by omega : w.length + 1 ≤ w.length + 3) 2) + (Nat.pow_le_pow_right (by omega : 0 < w.length + 3) (by decide : 2 ≤ 8)) + have hn : w.length ≤ (w.length + 3) ^ 8 := by + calc + w.length ≤ w.length + 3 := by omega + _ = (w.length + 3) ^ 1 := by simp + _ ≤ (w.length + 3) ^ 8 := Nat.pow_le_pow_right (by omega) (by decide) + have hpos : 1 ≤ (w.length + 3) ^ 8 := Nat.pow_pos (by omega) + omega + +end TapeParse +end DepthThreeLowerBound + +end OAI