Download data/lean/OAI/Computability/MinUncut/Estimates/ListDecoding.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.52 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MinUncut/Estimates/ListDecoding.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/MinUncut/Estimates/ListDecoding.lean
-
curl -L -o ListDecoding.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MinUncut/Estimates/ListDecoding.lean
8.52 kB
| import Mathlib | |
| import OAI.Computability.MinUncut.Games.HintSoundness | |
| namespace OAI | |
| noncomputable section | |
| open scoped BigOperators | |
| namespace MinUncut.Outer | |
| open MinUncut.Inner | |
| attribute [local instance] Classical.propDecidable BinaryFourier.dualFintype | |
| def paddedChoice {A : Type*} [Nonempty A] (S : Finset A) {L : β} (i : Fin L) : A := | |
| if h : i.val<S.card then ((Finset.equivFin S).symm β¨i.val,hβ©).val else Classical.ofNonempty | |
| lemma paddedChoice_covers {A : Type*} [Nonempty A] (S : Finset A) {L : β} | |
| (hS : S.cardβ€L) (a : A) (ha : a β S) : β i : Fin L, paddedChoice S i=a := by | |
| let j := (Finset.equivFin S) β¨a,haβ© | |
| let i : Fin L := β¨j.val,j.isLt.trans_le hSβ© | |
| refine β¨i,?_β© | |
| simp only [paddedChoice,i,dite_eq_left j.isLt] | |
| exact congrArg Subtype.val ((Finset.equivFin S).symm_apply_apply β¨a,haβ©) | |
| variable {Name I : Type*} [Fintype I] | |
| structure HintLists (Name I : Type*) [Fintype I] (q : β) where | |
| first : (U : I β Equation Name) β (Fin q β Forms (FirstAlphabet U)) β Finset (FirstAlphabet U) | |
| second : (V : I β SecondQuestion Name) β (Fin q β Forms (SecondAlphabet V)) β Finset (SecondAlphabet V) | |
| def HintLists.strategy {q L R : β} (lists : HintLists Name I q) (z : Fin L Γ Fin R) : | |
| HintedStrategy Name I q where | |
| first U B := paddedChoice (lists.first U B) z.1 | |
| second V B := paddedChoice (lists.second V B) z.2 | |
| def HintLists.matches {q : β} (lists : HintLists Name I q) | |
| (U : I β Equation Name) (hidden : I β Bool) (pos : I β Fin 3) | |
| (B : Fin q β Forms (SecondAlphabet (secondQuestion U hidden pos))) : Prop := | |
| β a β lists.first U (fun j => formPullback (projection U hidden pos) (B j)), | |
| β b β lists.second (secondQuestion U hidden pos) B, projection U hidden pos a=b | |
| lemma HintLists.matching_le_sum {q L R : β} (lists : HintLists Name I q) | |
| (hL : β U B, (lists.first U B).cardβ€L) | |
| (hR : β V B, (lists.second V B).cardβ€R) | |
| (U : I β Equation Name) (hidden : I β Bool) (pos : I β Fin 3) | |
| (B : Fin q β Forms (SecondAlphabet (secondQuestion U hidden pos))) : | |
| (if lists.matches U hidden pos B then (1 : β) else 0) β€ | |
| β z : Fin L Γ Fin R, if hintedAcceptance (lists.strategy z) U hidden pos B then 1 else 0 := by | |
| classical | |
| by_cases hm : lists.matches U hidden pos B | |
| Β· rw [ite_eq_left hm] | |
| obtain β¨a,ha,b,hb,habβ© := hm | |
| obtain β¨i,hiβ© := paddedChoice_covers _ (hL _ _) a ha | |
| obtain β¨j,hjβ© := paddedChoice_covers _ (hR _ _) b hb | |
| have hwin : hintedAcceptance (lists.strategy (i,j)) U hidden pos B := by | |
| change projection U hidden pos (paddedChoice _ i)=paddedChoice _ j | |
| rw [hi,hj] | |
| exact hab | |
| have hs := Finset.single_le_sum (s := Finset.univ) (f := fun z : Fin L Γ Fin R => | |
| if hintedAcceptance (lists.strategy z) U hidden pos B then (1 : β) else 0) | |
| (fun _ _ => by positivity) (Finset.mem_univ (i,j)) | |
| simpa only [ite_eq_left hwin] using hs | |
| Β· rw [ite_eq_right hm] | |
| exact Finset.sum_nonneg (fun _ _ => by positivity) | |
| theorem HintLists.shared_soundness [Fintype Name] | |
| {S : Type*} [Fintype S] [Nonempty S] (equations : S β Equation Name) | |
| (hsound : β s : Name β Fβ, equationFraction equations s β€ 3/4) | |
| {q L R : β} (lists : HintLists Name I q) | |
| (hL : β U B, (lists.first U B).cardβ€L) | |
| (hR : β V B, (lists.second V B).cardβ€R) (hidden : I β Bool) : | |
| (πΌ w : I β S Γ Fin 3, | |
| πΌ B : Fin q β Forms (SecondAlphabet | |
| (secondQuestion (sampledEquations equations w) hidden (sampledPositions w))), | |
| if lists.matches (sampledEquations equations w) hidden (sampledPositions w) B | |
| then (1 : β) else 0) β€ | |
| (L : β)*(R : β)*hintRate q ^ Fintype.card {i // hidden i=true} := by | |
| calc | |
| _ β€ πΌ w : I β S Γ Fin 3, | |
| πΌ B : Fin q β Forms (SecondAlphabet | |
| (secondQuestion (sampledEquations equations w) hidden (sampledPositions w))), | |
| β z : Fin L Γ Fin R, | |
| if hintedAcceptance (lists.strategy z) (sampledEquations equations w) hidden | |
| (sampledPositions w) B then (1 : β) else 0 := by | |
| apply Finset.expect_le_expect | |
| intro w _ | |
| exact Finset.expect_le_expect (fun B _ => lists.matching_le_sum hL hR _ hidden _ B) | |
| _ = β z : Fin L Γ Fin R, πΌ w : I β S Γ Fin 3, | |
| πΌ B : Fin q β Forms (SecondAlphabet | |
| (secondQuestion (sampledEquations equations w) hidden (sampledPositions w))), | |
| if hintedAcceptance (lists.strategy z) (sampledEquations equations w) hidden | |
| (sampledPositions w) B then (1 : β) else 0 := by | |
| simp_rw [Finset.expect_sum_comm] | |
| _ β€ β _z : Fin L Γ Fin R, hintRate q ^ Fintype.card {i // hidden i=true} := by | |
| apply Finset.sum_le_sum | |
| intro z _ | |
| exact shared_hint_soundness equations hsound (lists.strategy z) hidden | |
| _ = _ := by simp [mul_assoc] | |
| open scoped BigOperators | |
| open MinUncut.Inner | |
| attribute [local instance] Classical.propDecidable BinaryFourier.dualFintype | |
| variable {Name I : Type*} [Fintype I] | |
| abbrev CoordinateSlot (E : Equation Name) := Fin (Module.finrank Fβ (alphabet E).direction) β Fβ | |
| abbrev FirstCoordinateSpace (U : I β Equation Name) := β i, CoordinateSlot (U i) | |
| def firstCoordinates (U : I β Equation Name) : | |
| FirstCoordinateSpace U βα΅[Fβ] FirstAlphabet U := | |
| (LinearEquiv.piCongrRight (fun i => coordinates (U i))).toAffineEquiv.trans | |
| (AffineEquiv.vaddConst Fβ (fun i => origin (U i))) | |
| omit [Fintype I] in | |
| @[simp] lemma firstCoordinates_apply (U : I β Equation Name) | |
| (v : FirstCoordinateSpace U) (i : I) : | |
| (firstCoordinates U v i).val = directionEmbedding (U i) (v i) + (origin (U i)).val := rfl | |
| omit [Fintype I] in | |
| lemma firstCoordinates_symm_apply (U : I β Equation Name) (a : FirstAlphabet U) (i : I) : | |
| (firstCoordinates U).symm a i = (alphabetCoordinates (U i)).symm (a i) := rfl | |
| def formsTransport {V W A B : Type*} [AddCommGroup V] [Module Fβ V] [AddTorsor V A] | |
| [AddCommGroup W] [Module Fβ W] [AddTorsor W B] (e : A βα΅[Fβ] B) : | |
| Forms B ββ[Fβ] Forms A where | |
| toFun f := f.comp e.toAffineMap | |
| invFun f := f.comp e.symm.toAffineMap | |
| left_inv f := by ext b; simp | |
| right_inv f := by ext a; simp | |
| map_add' f g := by ext a; rfl | |
| map_smul' c f := by ext a; rfl | |
| def firstFormCoordinates (U : I β Equation Name) : | |
| (Fβ Γ (β i, Module.Dual Fβ (CoordinateSlot (U i)))) ββ[Fβ] Forms (FirstAlphabet U) := | |
| ((LinearEquiv.refl Fβ Fβ).prodCongr | |
| (LinearMap.lsum Fβ (fun i => CoordinateSlot (U i)) Fβ)).trans | |
| ((AffineMap.toConstProdLinearMap Fβ).symm.trans (formsTransport (firstCoordinates U)).symm) | |
| lemma firstFormCoordinates_apply (U : I β Equation Name) (ΞΊ : Fβ) | |
| (b : β i, Module.Dual Fβ (CoordinateSlot (U i))) (a : FirstAlphabet U) : | |
| firstFormCoordinates U (ΞΊ,b) a = | |
| (β i, b i ((alphabetCoordinates (U i)).symm (a i)))+ΞΊ := by | |
| change (β i, (b i).comp (LinearMap.proj i)) ((firstCoordinates U).symm a)+ΞΊ=_ | |
| simp only [LinearMap.sum_apply,LinearMap.comp_apply,LinearMap.proj_apply, | |
| firstCoordinates_symm_apply] | |
| abbrev TupleCoordinateData (U : I β Equation Name) (d : β) := | |
| (Fin d β Fβ) Γ (β i, OuterSmoothness.JointForms.Block | |
| (Module.finrank Fβ (alphabet (U i)).direction) d) | |
| def tupleCoordinateSlice (U : I β Equation Name) (d : β) (k : Fin d) : | |
| TupleCoordinateData U d ββ[Fβ] (Fβ Γ (β i, Module.Dual Fβ (CoordinateSlot (U i)))) where | |
| toFun z := (z.1 k,fun i => z.2 i k) | |
| map_add' _ _ := rfl | |
| map_smul' _ _ := rfl | |
| def tupleCoordinateGenerator (U : I β Equation Name) (d : β) : | |
| TupleCoordinateData U d ββ[Fβ] (Fin d β Forms (FirstAlphabet U)) := | |
| LinearMap.pi (fun k => (firstFormCoordinates U).toLinearMap.comp (tupleCoordinateSlice U d k)) | |
| lemma tupleCoordinateGenerator_surjective (U : I β Equation Name) (d : β) : | |
| Function.Surjective (tupleCoordinateGenerator U d) := by | |
| intro f | |
| let z := fun k => (firstFormCoordinates U).symm (f k) | |
| refine β¨(fun k => (z k).1,fun i k => (z k).2 i),?_β© | |
| funext k | |
| exact (firstFormCoordinates U).apply_symm_apply (f k) | |
| lemma uniform_tupleCoordinateGenerator (U : I β Equation Name) (d : β) | |
| (f : (Fin d β Forms (FirstAlphabet U)) β β) : | |
| (πΌ z : TupleCoordinateData U d, f (tupleCoordinateGenerator U d z)) = πΌ L, f L := | |
| IndependentSquares.expect_surjective_linear _ (tupleCoordinateGenerator_surjective U d) f | |
| end MinUncut.Outer | |
| end | |
| end OAI | |