math / data /lean /OAI /Computability /PerfectCompleteness /Construction /MixedSourceLocalOddLists.lean
Download data/lean/OAI/Computability/PerfectCompleteness/Construction/MixedSourceLocalOddLists.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 13.7 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/PerfectCompleteness/Construction/MixedSourceLocalOddLists.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/PerfectCompleteness/Construction/MixedSourceLocalOddLists.lean
-
curl -L -o MixedSourceLocalOddLists.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/PerfectCompleteness/Construction/MixedSourceLocalOddLists.lean
13.7 kB
| import OAI.Computability.PerfectCompleteness.Construction.SourceLocalOddLists | |
| namespace OAI | |
| section | |
| namespace PerfectCompleteness.MixedSourceLocalOddLists | |
| open scoped BigOperators Classical | |
| open PointwiseSpaces TreeSourceSpaces SourceAnswerEquiv | |
| open UniqueGamesTheorem.Foundations.Games | |
| abbrev F2 := ZMod 2 | |
| noncomputable section | |
| section Composition | |
| variable {A B C : Type*} [Fintype A] [Fintype B] [Fintype C] | |
| [DecidableEq A] [DecidableEq B] [DecidableEq C] | |
| private theorem parity_comp (Ο : A β B) (Ο : B β C) (L : Finset A) : | |
| OddLists.parityPushforward Ο (OddLists.parityPushforward Ο L) = | |
| OddLists.parityPushforward (Ο β Ο) L := by | |
| let f : A β F2 := fun a => if a β L then 1 else 0 | |
| have hf : OddLists.support f = L := by | |
| ext a | |
| by_cases ha : a β L <;> simp [OddLists.mem_support, f, ha] | |
| rw [β hf, OddLists.parityPushforward_support, OddLists.parityPushforward_support, | |
| OddLists.parityPushforward_support] | |
| congr 1 | |
| funext c | |
| calc | |
| (β b, if Ο b = c then β a, if Ο a = b then f a else 0 else 0) = | |
| β b, β a, if Ο b = c then (if Ο a = b then f a else 0) else 0 := by | |
| apply Finset.sum_congr rfl | |
| intro b _ | |
| by_cases hb : Ο b = c <;> simp only [hb, ite_true, ite_false, Finset.sum_const_zero] | |
| _ = β a, β b, if Ο b = c then (if Ο a = b then f a else 0) else 0 := | |
| Finset.sum_comm | |
| _ = β a, if (Ο β Ο) a = c then f a else 0 := by | |
| apply Finset.sum_congr rfl | |
| intro a _ | |
| rw [Finset.sum_eq_single (Ο a)] | |
| Β· simp only [Function.comp_apply, ite_true] | |
| Β· intro b _ hb | |
| simp only [ite_eq_right (Ne.symm hb), ite_self] | |
| Β· intro h | |
| exact (h (Finset.mem_univ _)).elim | |
| private theorem oddList_map_comp {s : Nat} (Ο : A β B) (Ο : B β C) | |
| (L : OddLists.OddList s A) : | |
| OddLists.OddList.map Ο (OddLists.OddList.map Ο L) = | |
| OddLists.OddList.map (Ο β Ο) L := by | |
| apply Subtype.ext | |
| exact parity_comp Ο Ο L.val | |
| end Composition | |
| private theorem map_eq_of_map_eq {A B : Type*} {s : Nat} | |
| {fβ fβ : Fintype B} {dβ dβ : DecidableEq B} | |
| (Ο : A β B) (L : OddLists.OddList s A) (R : OddLists.OddList s B) | |
| (accepted : @OddLists.OddList.map A B s fβ dβ Ο L = R) : | |
| @OddLists.OddList.map A B s fβ dβ Ο L = R := by | |
| have hf : fβ = fβ := Subsingleton.elim _ _ | |
| cases hf | |
| have hd : dβ = dβ := Subsingleton.elim _ _ | |
| cases hd | |
| exact accepted | |
| variable {branch : Nat β Nat} {h t v m s : Nat} | |
| (clauses : Fin m β SourceClause.NormalizedClause v) | |
| private theorem encoded_accepts {B : Type*} [Fintype B] [DecidableEq B] | |
| (e : SourceOddLists.Occurrences m t) | |
| (Ο : LeftDomain clauses (SourceOddLists.left e) β B) | |
| (Ο : B β SourceOddLists.RightLabels t) | |
| (hcomm : Ο β Ο = (actualProjection clauses e : | |
| LeftDomain clauses (SourceOddLists.left e) β SourceOddLists.RightLabels t)) | |
| (L : OddLists.OddList s (LeftDomain clauses (SourceOddLists.left e))) | |
| (R : OddLists.OddList s B) (hnative : OddLists.OddList.map Ο L = R) : | |
| OddLists.OddList.map (SourceOddLists.projection clauses e) | |
| (encodeOddList clauses (SourceOddLists.left e) L) = OddLists.OddList.map Ο R := by | |
| let actual : LeftDomain clauses (SourceOddLists.left e) β SourceOddLists.RightLabels t := | |
| actualProjection clauses e | |
| have henc0 := encodeOddList_projection clauses e L | |
| have henc : OddLists.OddList.map actual L = | |
| OddLists.OddList.map (SourceOddLists.projection clauses e) | |
| (encodeOddList clauses (SourceOddLists.left e) L) := | |
| map_eq_of_map_eq (B := SourceOddLists.RightLabels t) actual L _ henc0.symm | |
| calc | |
| _ = OddLists.OddList.map actual L := henc.symm | |
| _ = OddLists.OddList.map (Ο β Ο) L := | |
| congrArg (fun f : LeftDomain clauses (SourceOddLists.left e) β SourceOddLists.RightLabels t => | |
| OddLists.OddList.map f L) hcomm.symm | |
| _ = OddLists.OddList.map Ο (OddLists.OddList.map Ο L) := (oddList_map_comp Ο Ο L).symm | |
| _ = OddLists.OddList.map Ο R := congrArg (OddLists.OddList.map Ο) hnative | |
| abbrev Endpoints := RecursiveSpaces.Slots branch h β Fin t β SourceKeys.Endpoint v m | |
| def slotsOf (q : Endpoints (branch := branch) (h := h) (t := t) (v := v) (m := m)) : | |
| RecursiveSpaces.Slots branch h β Fin t β MixedSupport.Slot := | |
| fun leaf k => SourceKeys.slot clauses (q leaf k) | |
| abbrev RightForms := | |
| (q : Endpoints (branch := branch) (h := h) (t := t) (v := v) (m := m)) β | |
| SourceLocalOddLists.Form (slotsOf clauses q) | |
| def defaultValue : (q : SourceKeys.Endpoint v m) β (SourceKeys.slot clauses q).Domain | |
| | .clause c => (clauseAnswerEquiv (clauses c).signs).symm 0 | |
| | .variable _ => false | |
| def readBit : (q : SourceKeys.Endpoint v m) β (SourceKeys.slot clauses q).Domain β Bool | |
| | .clause _, _ => false | |
| | .variable _, b => b | |
| def leafToBits (q : Fin t β SourceKeys.Endpoint v m) | |
| (a : MixedSupport.Assignment (fun k => SourceKeys.slot clauses (q k))) : | |
| SourceOddLists.RightLabels t := | |
| fun k => readBit clauses (q k) (a k) | |
| def rightResponse (positive : 0 < s) (forms : RightForms (branch := branch) (h := h) (t := t) clauses) | |
| (q : Endpoints (branch := branch) (h := h) (t := t) (v := v) (m := m)) | |
| (leaf : RecursiveSpaces.Slots branch h) : OddLists.OddList s (SourceOddLists.RightLabels t) := | |
| OddLists.OddList.map (leafToBits clauses (q leaf)) | |
| (SourceLocalOddLists.extract positive (slotsOf clauses q) (forms q) leaf | |
| (fun k => defaultValue clauses (q leaf k))) | |
| def target : Bool β SourceClause.Occurrence m β SourceKeys.Endpoint v m | |
| | false, e => .clause e.1 | |
| | true, e => .variable ((clauses e.1).variable e.2) | |
| def step : (projected : Bool) β (e : SourceClause.Occurrence m) β | |
| SourceKeys.Step clauses (.clause e.1) (target clauses projected e) | |
| | false, e => .keep (.clause e.1) | |
| | true, e => .select e.1 e.2 | |
| def rightEndpoints (projected : RecursiveSpaces.Slots branch h β Bool) | |
| (e : SourceLocalOddLists.Occurrences (branch := branch) (h := h) (m := m) (t := t)) : | |
| Endpoints (branch := branch) (h := h) (t := t) (v := v) (m := m) := | |
| fun leaf k => target clauses (projected leaf) (e leaf k) | |
| def treeProjection (projected : RecursiveSpaces.Slots branch h β Bool) | |
| (e : SourceLocalOddLists.Occurrences (branch := branch) (h := h) (m := m) (t := t)) : | |
| β leaf k, MixedSupport.Projection | |
| (leftTreeSlots clauses (fun j => SourceOddLists.left (e j)) leaf k) | |
| (slotsOf clauses (rightEndpoints clauses projected e) leaf k) := | |
| fun leaf k => (step clauses (projected leaf) (e leaf k)).projection | |
| theorem clean_leaf_projection (projected : RecursiveSpaces.Slots branch h β Bool) | |
| (e : SourceLocalOddLists.Occurrences (branch := branch) (h := h) (m := m) (t := t)) | |
| (leaf : RecursiveSpaces.Slots branch h) (hp : projected leaf = true) : | |
| leafToBits clauses (rightEndpoints clauses projected e leaf) β | |
| MixedSupport.projectionMap (treeProjection clauses projected e leaf) = | |
| actualProjection clauses (e leaf) := by | |
| funext a k | |
| change readBit clauses (target clauses (projected leaf) (e leaf k)) | |
| ((step clauses (projected leaf) (e leaf k)).projection.map (a k)) = | |
| (a k).val.at (e leaf k).2 | |
| rw [hp] | |
| rfl | |
| section Clean | |
| open SourceLocalOddLists (CleanLeaves fill) | |
| variable (clean : RecursiveSpaces.Slots branch h β Prop) | |
| (projected : RecursiveSpaces.Slots branch h β Bool) | |
| (background : SourceLocalOddLists.Occurrences (branch := branch) (h := h) (m := m) (t := t)) | |
| def strategy (positive : 0 < s) | |
| (leftForms : SourceLocalOddLists.LeftForms (branch := branch) (h := h) (t := t) clauses) (rightForms : RightForms (branch := branch) (h := h) (t := t) clauses) : | |
| Strategy (CleanLeaves clean β Fin t β Fin m) (CleanLeaves clean β Fin t β Fin v) | |
| (CleanLeaves clean β OddLists.OddList s (SourceOddLists.LeftLabels t)) | |
| (CleanLeaves clean β OddLists.OddList s (SourceOddLists.RightLabels t)) := | |
| (fun q leaf => SourceLocalOddLists.leftResponse clauses positive leftForms | |
| (fill clean (fun j => SourceOddLists.left (background j)) q) leaf.val, | |
| fun q leaf => rightResponse clauses positive rightForms | |
| (fill clean (rightEndpoints clauses projected background) | |
| (fun i k => SourceKeys.Endpoint.variable (q i k))) leaf.val) | |
| theorem fill_rightEndpoints (hclean : β leaf, clean leaf β projected leaf = true) | |
| (e : CleanLeaves clean β SourceOddLists.Occurrences m t) : | |
| fill clean (rightEndpoints clauses projected background) | |
| (fun i k => SourceKeys.Endpoint.variable (SourceOddLists.right clauses (e i) k)) = | |
| rightEndpoints clauses projected (fill clean background e) := by | |
| funext leaf k | |
| by_cases hc : clean leaf | |
| Β· simp only [SourceLocalOddLists.fill, dite_eq_left hc, rightEndpoints, hclean leaf hc, target] | |
| rfl | |
| Β· simp only [SourceLocalOddLists.fill, dite_eq_right hc, rightEndpoints] | |
| theorem strategy_wins [NeZero m] (positive : 0 < s) | |
| (leftForms : SourceLocalOddLists.LeftForms (branch := branch) (h := h) (t := t) clauses) (rightForms : RightForms (branch := branch) (h := h) (t := t) clauses) | |
| (hclean : β leaf, clean leaf β projected leaf = true) | |
| (e : CleanLeaves clean β SourceOddLists.Occurrences m t) | |
| (z : Module.Dual F2 (squareSpace | |
| (H (leftTreeSlots clauses (fun j => SourceOddLists.left (fill clean background e j)))))) | |
| (hform : leftForms (fun j => SourceOddLists.left (fill clean background e j)) = | |
| OddListExtraction.multiplicationForm | |
| (H (leftTreeSlots clauses (fun j => SourceOddLists.left (fill clean background e j)))) z) | |
| (hone : | |
| (1 : Domain (leftTreeSlots clauses (fun j => SourceOddLists.left (fill clean background e j))) β F2) β | |
| squareSpace (H (leftTreeSlots clauses (fun j => SourceOddLists.left (fill clean background e j))))) | |
| (hnorm : z β¨1, honeβ© = 1) | |
| (hrank : OddListExtraction.formRank | |
| (H (leftTreeSlots clauses (fun j => SourceOddLists.left (fill clean background e j)))) | |
| (leftForms (fun j => SourceOddLists.left (fill clean background e j))) β€ s) | |
| (hagree : β f g, | |
| rightForms (rightEndpoints clauses projected (fill clean background e)) f g = | |
| OddListExtraction.multiplicationForm | |
| (H (leftTreeSlots clauses (fun j => SourceOddLists.left (fill clean background e j)))) z | |
| (HPullback (treeProjection clauses projected (fill clean background e)) f) | |
| (HPullback (treeProjection clauses projected (fill clean background e)) g)) : | |
| (IndexedRepetition.game (SourceOddLists.game s clauses t) (CleanLeaves clean)).wins | |
| (strategy clauses clean projected background positive leftForms rightForms) e = true := by | |
| simp only [OccurrenceGame.wins, IndexedRepetition.game, SourceOddLists.game, | |
| OddListGame.game, OccurrenceGame.ofProjection, strategy, decide_eq_true_eq] | |
| intro leaf | |
| rw [SourceLocalOddLists.fill_comp clean background e SourceOddLists.left, | |
| fill_rightEndpoints clauses clean projected background hclean e] | |
| let full : SourceLocalOddLists.Occurrences (branch := branch) (h := h) (m := m) (t := t) := | |
| fill clean background e | |
| let qL : SourceLocalOddLists.LeftQuestions (branch := branch) (h := h) (t := t) (m := m) := | |
| fun j => SourceOddLists.left (full j) | |
| let qR : Endpoints (branch := branch) (h := h) (t := t) (v := v) (m := m) := | |
| rightEndpoints clauses projected full | |
| let slotsL : RecursiveSpaces.Slots branch h β Fin t β MixedSupport.Slot := | |
| leftTreeSlots (branch := branch) (n := h) clauses qL | |
| let slotsR : RecursiveSpaces.Slots branch h β Fin t β MixedSupport.Slot := | |
| slotsOf (branch := branch) (h := h) (t := t) clauses qR | |
| let L : OddLists.OddList s (LeftDomain clauses (SourceOddLists.left (full leaf.val))) := | |
| SourceLocalOddLists.extract (branch := branch) (h := h) (t := t) | |
| positive slotsL (leftForms qL) leaf.val | |
| ((leftEquiv clauses (SourceOddLists.left (full leaf.val))).symm (fun _ => 0)) | |
| let R : OddLists.OddList s (LeafDomain slotsR leaf.val) := | |
| SourceLocalOddLists.extract (branch := branch) (h := h) (t := t) | |
| positive slotsR (rightForms qR) leaf.val | |
| (fun k => defaultValue clauses (qR leaf.val k)) | |
| let Ο : LeftDomain clauses (SourceOddLists.left (full leaf.val)) β LeafDomain slotsR leaf.val := | |
| MixedSupport.projectionMap | |
| (treeProjection (branch := branch) (h := h) (t := t) clauses projected full leaf.val) | |
| let Ο : LeafDomain slotsR leaf.val β SourceOddLists.RightLabels t := | |
| leafToBits clauses (qR leaf.val) | |
| have hraw := SourceLocalOddLists.extract_accepts (branch := branch) (h := h) (t := t) | |
| (slots := slotsL) (projected := slotsR) positive | |
| (treeProjection (branch := branch) (h := h) (t := t) clauses projected full) | |
| leaf.val (leftForms qL) (rightForms qR) z hform hone hnorm hrank hagree | |
| ((leftEquiv clauses (SourceOddLists.left (full leaf.val))).symm (fun _ => 0)) | |
| (fun k => defaultValue clauses (qR leaf.val k)) | |
| have hnative : OddLists.OddList.map Ο L = R := map_eq_of_map_eq Ο L R hraw | |
| have hcomm : Ο β Ο = | |
| (actualProjection clauses (full leaf.val) : | |
| LeftDomain clauses (SourceOddLists.left (full leaf.val)) β SourceOddLists.RightLabels t) := | |
| clean_leaf_projection clauses projected full leaf.val (hclean leaf.val leaf.property) | |
| have haccept := encoded_accepts clauses (full leaf.val) Ο Ο hcomm L R hnative | |
| rw [β SourceLocalOddLists.fill_clean clean background e leaf] | |
| change OddLists.OddList.map (SourceOddLists.projection clauses (full leaf.val)) | |
| (encodeOddList clauses (SourceOddLists.left (full leaf.val)) L) = OddLists.OddList.map Ο R | |
| exact haccept | |
| end Clean | |
| end | |
| end PerfectCompleteness.MixedSourceLocalOddLists | |
| end | |
| end OAI | |