Download data/lean/OAI/Computability/PerfectCompleteness/Sampling/BucketUniformLemmas.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 22.6 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/PerfectCompleteness/Sampling/BucketUniformLemmas.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/PerfectCompleteness/Sampling/BucketUniformLemmas.lean
-
curl -L -o BucketUniformLemmas.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/PerfectCompleteness/Sampling/BucketUniformLemmas.lean
22.6 kB
| import Mathlib.Algebra.BigOperators.Pi | |
| import Mathlib.LinearAlgebra.BilinearMap | |
| import Mathlib.SetTheory.Cardinal.Finite | |
| import OAI.Computability.PerfectCompleteness.Algebra.UniformLinearImage | |
| import OAI.Computability.PerfectCompleteness.Sampling.BucketSampler | |
| import OAI.Computability.PerfectCompleteness.Sampling.RationalFiniteLawLemmas | |
| import OAI.Computability.PerfectCompleteness.Sampling.RecordSeedSamplingLemmas | |
| import OAI.Computability.UniqueGames.Games.FinishBoundsLemmas | |
| namespace OAI | |
| namespace PerfectCompleteness.BucketUniform | |
| noncomputable section | |
| open scoped BigOperators Classical | |
| open UniqueGamesTheorem.Foundations.Games | |
| open BucketSampler (F2 Direction) | |
| variable {H : Type*} [AddCommGroup H] [Module F2 H] | |
| def coordinateDirection {β : Nat} (i : Fin β) : Direction β := | |
| β¨Pi.single i (1 : F2), by | |
| intro h | |
| have hi := congrFun h i | |
| simp at hiβ© | |
| def evaluateLinear (β : Nat) : (Direction β β H) ββ[F2] (Fin β β H) where | |
| toFun := BucketSampler.evaluate β (id : H β H) | |
| map_add' t u := by | |
| funext i | |
| simp only [BucketSampler.evaluate, id_eq, Pi.add_apply, smul_add, | |
| Finset.sum_add_distrib] | |
| map_smul' a t := by | |
| funext i | |
| change (β v : Direction β, v.val i β’ (a β’ t v)) = | |
| a β’ β v : Direction β, v.val i β’ t v | |
| rw [Finset.smul_sum] | |
| exact Finset.sum_congr rfl (fun v _ => smul_comm _ _ _) | |
| @[simp] theorem evaluateLinear_apply (β : Nat) (t : Direction β β H) : | |
| evaluateLinear β t = BucketSampler.evaluate β (id : H β H) t := rfl | |
| theorem evaluate_single {β : Nat} (v : Direction β) (h : H) : | |
| evaluateLinear β (Pi.single v h) = BucketSampler.rankOne v.val h := by | |
| funext i | |
| change (β w : Direction β, w.val i β’ (Pi.single v h) w) = v.val i β’ h | |
| rw [Finset.sum_eq_single v] | |
| Β· simp | |
| Β· intro w _ hw | |
| simp [hw] | |
| Β· intro hv | |
| exact (hv (Finset.mem_univ v)).elim | |
| theorem evaluate_coordinate_bucket {β : Nat} (i : Fin β) (h : H) : | |
| evaluateLinear β (Pi.single (coordinateDirection i) h) = Pi.single i h := by | |
| rw [evaluate_single] | |
| funext j | |
| by_cases hij : i = j | |
| Β· subst j | |
| simp [BucketSampler.rankOne, coordinateDirection] | |
| Β· simp [BucketSampler.rankOne, coordinateDirection, Ne.symm hij] | |
| def coordinateTape {β : Nat} (rows : Fin β β H) : Direction β β H := | |
| β i : Fin β, Pi.single (coordinateDirection i) (rows i) | |
| theorem evaluate_coordinateTape {β : Nat} (rows : Fin β β H) : | |
| evaluateLinear β (coordinateTape rows) = rows := by | |
| unfold coordinateTape | |
| rw [map_sum] | |
| simp only [evaluate_coordinate_bucket, Finset.univ_sum_single] | |
| theorem evaluateLinear_surjective (β : Nat) : | |
| Function.Surjective (evaluateLinear (H := H) β) := | |
| fun rows => β¨coordinateTape rows, evaluate_coordinateTape rowsβ© | |
| theorem evaluate_surjective (β : Nat) : | |
| Function.Surjective (BucketSampler.evaluate β (id : H β H)) := | |
| evaluateLinear_surjective β | |
| theorem uniform_evaluate_law [Fintype H] (β : Nat) : | |
| (BucketSampler.tapeLaw β (FiniteDistribution.uniform H)).pushforward | |
| (BucketSampler.evaluate β (id : H β H)) = | |
| FiniteDistribution.uniform (Fin β β H) := | |
| UniformLinearImage.product_uniform_linear_image | |
| (I := Direction β) (Ξ© := fun _ => H) (R := F2) (V := Fin β β H) | |
| (evaluateLinear (H := H) β) (evaluateLinear_surjective (H := H) β) | |
| theorem uniform_array_law [Fintype H] (β : Nat) : | |
| BucketSampler.law β (FiniteDistribution.uniform H) (id : H β H) = | |
| FiniteDistribution.uniform (Fin β β H) := | |
| uniform_evaluate_law β | |
| variable {Ξ© : Type*} (V : Submodule F2 (Ξ© β F2)) | |
| def ofRowsLinear (β : Nat) : | |
| (Fin β β V) ββ[F2] (Module.Dual F2 V ββ[F2] (Fin β β F2)) where | |
| toFun := EvaluationMatrix.ofRows V | |
| map_add' rows rows' := by | |
| apply LinearMap.ext | |
| intro q | |
| funext i | |
| exact map_add q (rows i) (rows' i) | |
| map_smul' a rows := by | |
| apply LinearMap.ext | |
| intro q | |
| funext i | |
| exact map_smul q a (rows i) | |
| theorem ofRowsLinear_surjective [FiniteDimensional F2 V] (β : Nat) : | |
| Function.Surjective (ofRowsLinear V β) := | |
| fun X => β¨EvaluationMatrix.rows V X, EvaluationMatrix.ofRows_rows V Xβ© | |
| theorem uniform_matrix_law (β : Nat) [Fintype V] [FiniteDimensional F2 V] | |
| [Fintype (Module.Dual F2 V ββ[F2] (Fin β β F2))] : | |
| (BucketSampler.tapeLaw β (FiniteDistribution.uniform V)).pushforward | |
| (fun t => EvaluationMatrix.ofRows V (BucketSampler.evaluate β (id : V β V) t)) = | |
| FiniteDistribution.uniform (Module.Dual F2 V ββ[F2] (Fin β β F2)) := by | |
| calc | |
| _ = ((BucketSampler.tapeLaw β (FiniteDistribution.uniform V)).pushforward | |
| (BucketSampler.evaluate β (id : V β V))).pushforward | |
| (EvaluationMatrix.ofRows V) := | |
| (FiniteDistribution.pushforward_comp _ _ _).symm | |
| _ = (FiniteDistribution.uniform (Fin β β V)).pushforward | |
| (EvaluationMatrix.ofRows V) := by rw [uniform_evaluate_law] | |
| _ = _ := UniformLinearImage.uniform_pushforward_linearMap | |
| (ofRowsLinear V β) (ofRowsLinear_surjective V β) | |
| end | |
| end PerfectCompleteness.BucketUniform | |
| namespace PerfectCompleteness.RecursiveSamplerBiasAlgebra | |
| open PointwiseSpaces RecursiveSpaces RecursiveSampler | |
| open scoped BigOperators | |
| universe u w | |
| variable (π : Type w) [Field π] | |
| def squareProduct {X : Type u} (H : Submodule π (X β π)) : | |
| H ββ[π] H ββ[π] squareSpace H := | |
| LinearMap.mkβ π | |
| (fun g h => β¨g.val * h.val, mul_mem_squareSpace H g.property h.propertyβ©) | |
| (fun g g' h => Subtype.ext (add_mul g.val g'.val h.val)) | |
| (fun c g h => Subtype.ext (smul_mul_assoc c g.val h.val)) | |
| (fun g h h' => Subtype.ext (mul_add g.val h.val h'.val)) | |
| (fun c g h => Subtype.ext (mul_smul_comm c g.val h.val)) | |
| @[simp] theorem squareProduct_val {X : Type u} (H : Submodule π (X β π)) | |
| (g h : H) : (squareProduct π H g h).val = g.val * h.val := rfl | |
| theorem square_functional_eq_zero_of_products {X : Type u} | |
| (H : Submodule π (X β π)) (L : squareSpace H ββ[π] π) | |
| (hL : β g h : H, L (squareProduct π H g h) = 0) : L = 0 := by | |
| apply LinearMap.ext | |
| rintro β¨x, hxβ© | |
| change L β¨x, hxβ© = 0 | |
| refine Submodule.span_induction | |
| (p := fun y hy => L β¨y, hyβ© = 0) ?_ ?_ ?_ ?_ hx | |
| Β· rintro y β¨g, hg, h, hh, rflβ© | |
| exact hL β¨g, hgβ© β¨h, hhβ© | |
| Β· exact map_zero L | |
| Β· intro y z hy hz hLy hLz | |
| change L ((β¨y, hyβ© : squareSpace H) + β¨z, hzβ©) = 0 | |
| rw [map_add, hLy, hLz, add_zero] | |
| Β· intro c y hy hLy | |
| change L (c β’ (β¨y, hyβ© : squareSpace H)) = 0 | |
| rw [map_smul, hLy, smul_zero] | |
| variable {branch : Nat β Nat} {n : Nat} | |
| def childSquareLift (A : Slots branch (n + 1) β Type u) (i : Fin (branch n)) : | |
| squareSpace (space π branch n (childFamily A i)) ββ[π] | |
| space π branch (n + 1) A where | |
| toFun g := β¨pullback π (childRestriction A i) g.val, | |
| child_square_le_space A i (Submodule.mem_map_of_mem g.property)β© | |
| map_add' _ _ := Subtype.ext rfl | |
| map_smul' _ _ := Subtype.ext rfl | |
| @[simp] theorem childSquareLift_val (A : Slots branch (n + 1) β Type u) | |
| (i : Fin (branch n)) (g : squareSpace (space π branch n (childFamily A i))) : | |
| (childSquareLift π A i g).val = pullback π (childRestriction A i) g.val := rfl | |
| def childProduct (A : Slots branch (n + 1) β Type u) (i : Fin (branch n)) : | |
| space π branch n (childFamily A i) ββ[π] | |
| space π branch n (childFamily A i) ββ[π] space π branch (n + 1) A := | |
| (squareProduct π (space π branch n (childFamily A i))).comprβ | |
| (childSquareLift π A i) | |
| @[simp] theorem childProduct_val (A : Slots branch (n + 1) β Type u) | |
| (i : Fin (branch n)) (g h : space π branch n (childFamily A i)) : | |
| (childProduct π A i g h).val = | |
| pullback π (childRestriction A i) (g.val * h.val) := rfl | |
| def childBilinear (A : Slots branch (n + 1) β Type u) (i : Fin (branch n)) | |
| (f : space π branch (n + 1) A ββ[π] π) : | |
| space π branch n (childFamily A i) ββ[π] | |
| space π branch n (childFamily A i) ββ[π] π := | |
| (childProduct π A i).comprβ f | |
| @[simp] theorem childBilinear_apply (A : Slots branch (n + 1) β Type u) | |
| (i : Fin (branch n)) (f : space π branch (n + 1) A ββ[π] π) | |
| (g h : space π branch n (childFamily A i)) : | |
| childBilinear π A i f g h = | |
| f (childSquareLift π A i | |
| (squareProduct π (space π branch n (childFamily A i)) g h)) := rfl | |
| theorem eq_zero_of_child_restrictions (A : Slots branch (n + 1) β Type u) | |
| (f : space π branch (n + 1) A ββ[π] π) | |
| (hzero : β i : Fin (branch n), f.comp (childSquareLift π A i) = 0) : f = 0 := by | |
| apply LinearMap.ext | |
| rintro β¨x, hxβ© | |
| change f β¨x, hxβ© = 0 | |
| refine Submodule.iSup_induction' | |
| (fun i : Fin (branch n) => | |
| (squareSpace (space π branch n (childFamily A i))).map | |
| (pullback π (childRestriction A i))) | |
| (motive := fun y hy => f β¨y, hyβ© = 0) ?_ ?_ ?_ hx | |
| Β· intro i y hy | |
| obtain β¨g, hg, rflβ© := Submodule.mem_map.mp hy | |
| exact LinearMap.congr_fun (hzero i) β¨g, hgβ© | |
| Β· exact map_zero f | |
| Β· intro y z hy hz hfy hfz | |
| change f ((β¨y, hyβ© : space π branch (n + 1) A) + β¨z, hzβ©) = 0 | |
| rw [map_add, hfy, hfz, add_zero] | |
| theorem exists_child_restriction_ne_zero (A : Slots branch (n + 1) β Type u) | |
| (f : space π branch (n + 1) A ββ[π] π) (hf : f β 0) : | |
| β i : Fin (branch n), f.comp (childSquareLift π A i) β 0 := by | |
| classical | |
| by_contra h | |
| apply hf | |
| apply eq_zero_of_child_restrictions π A f | |
| intro i | |
| by_contra hi | |
| exact h β¨i, hiβ© | |
| theorem childBilinear_ne_zero (A : Slots branch (n + 1) β Type u) | |
| (i : Fin (branch n)) (f : space π branch (n + 1) A ββ[π] π) | |
| (hchild : f.comp (childSquareLift π A i) β 0) : | |
| childBilinear π A i f β 0 := by | |
| intro hzero | |
| apply hchild | |
| apply square_functional_eq_zero_of_products π _ _ | |
| intro g h | |
| exact LinearMap.congr_funβ hzero g h | |
| theorem ordinary_or_bilinear_ne_zero (A : Slots branch (n + 1) β Type u) | |
| (i : Fin (branch n)) (f : space π branch (n + 1) A ββ[π] π) (hf : f β 0) : | |
| (β j : OffPath i, f.comp (childSquareLift π A j.val) β 0) β¨ | |
| childBilinear π A i f β 0 := by | |
| classical | |
| obtain β¨j, hjβ© := exists_child_restriction_ne_zero π A f hf | |
| by_cases hji : j = i | |
| Β· subst j | |
| exact Or.inr (childBilinear_ne_zero π A i f hj) | |
| Β· exact Or.inl β¨β¨j, hjiβ©, hjβ© | |
| noncomputable section | |
| theorem combine_eq (A : Slots branch (n + 1) β Type u) (i : Fin (branch n)) | |
| (r : Nat) | |
| (ordinary : (j : OffPath i) β squareSpace (space π branch n (childFamily A j.val))) | |
| (left right : Fin r β space π branch n (childFamily A i)) : | |
| combine π A i r ordinary left right = | |
| (β j : OffPath i, childSquareLift π A j.val (ordinary j)) + | |
| β h : Fin r, childProduct π A i (left h) (right h) := by | |
| apply Subtype.ext | |
| change combineFunction π A i r ordinary left right = | |
| (space π branch (n + 1) A).subtype | |
| ((β j : OffPath i, childSquareLift π A j.val (ordinary j)) + | |
| β h : Fin r, childProduct π A i (left h) (right h)) | |
| rw [map_add, map_sum, map_sum] | |
| rfl | |
| theorem map_combine (A : Slots branch (n + 1) β Type u) (i : Fin (branch n)) | |
| (r : Nat) (f : space π branch (n + 1) A ββ[π] π) | |
| (ordinary : (j : OffPath i) β squareSpace (space π branch n (childFamily A j.val))) | |
| (left right : Fin r β space π branch n (childFamily A i)) : | |
| f (combine π A i r ordinary left right) = | |
| (β j : OffPath i, (f.comp (childSquareLift π A j.val)) (ordinary j)) + | |
| β h : Fin r, childBilinear π A i f (left h) (right h) := by | |
| rw [combine_eq, map_add, map_sum, map_sum] | |
| rfl | |
| end | |
| end PerfectCompleteness.RecursiveSamplerBiasAlgebra | |
| namespace PerfectCompleteness.RecursiveSampler | |
| open PointwiseSpaces RecursiveSpaces DescendantSpaces | |
| open UniqueGamesTheorem.Foundations.Games | |
| open scoped BigOperators | |
| universe u w | |
| variable {branch : Nat β Nat} {n m : Nat} | |
| abbrev CallIndex (repeats : Nat β Nat) (n : Nat) := Fin (repeats (n + 1)) Γ Bool | |
| variable (π : Type w) [Field π] | |
| abbrev OrdinaryTape (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) := | |
| (j : OffPath i) β DrawSpace π repeats (.step i p) A (.inl j) | |
| abbrev CallTapes (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) := | |
| CallIndex repeats n β Tape π repeats p (childFamily A i) | |
| def splitTapeEquiv (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) : | |
| Tape π repeats (.step i p) A β | |
| OrdinaryTape π repeats i p A Γ CallTapes π repeats i p A where | |
| toFun t := (fun j => t (.inl j), fun hb => subTape π repeats i p A t hb.1 hb.2) | |
| invFun z j := match j with | |
| | .inl j => z.1 j | |
| | .inr j => z.2 j.1 j.2 | |
| left_inv t := by | |
| funext j | |
| cases j <;> rfl | |
| right_inv z := by | |
| apply Prod.ext | |
| Β· funext j | |
| rfl | |
| Β· funext hb j | |
| rfl | |
| noncomputable def evaluateCalls (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) | |
| (calls : CallTapes π repeats i p A) : | |
| CallIndex repeats n β space π branch n (childFamily A i) := | |
| fun hb => evaluate π repeats p (childFamily A i) (calls hb) | |
| noncomputable def splitEvaluatedTape (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) | |
| (t : Tape π repeats (.step i p) A) : | |
| OrdinaryTape π repeats i p A Γ | |
| (CallIndex repeats n β space π branch n (childFamily A i)) := | |
| ((splitTapeEquiv π repeats i p A t).1, | |
| evaluateCalls π repeats i p A (splitTapeEquiv π repeats i p A t).2) | |
| noncomputable def stepCombine (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) | |
| (z : OrdinaryTape π repeats i p A Γ | |
| (CallIndex repeats n β space π branch n (childFamily A i))) : | |
| space π branch (n + 1) A := | |
| combine π A i (repeats (n + 1)) z.1 | |
| (fun h => z.2 (h, false)) (fun h => z.2 (h, true)) | |
| theorem stepCombine_splitEvaluatedTape (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) | |
| (t : Tape π repeats (.step i p) A) : | |
| stepCombine π repeats i p A (splitEvaluatedTape π repeats i p A t) = | |
| evaluate π repeats (.step i p) A t := rfl | |
| noncomputable section | |
| variable [Finite π] | |
| instance childFamilyFinite (A : Slots branch (n + 1) β Type u) | |
| [hA : β s, Finite (A s)] (i : Fin (branch n)) : | |
| β s, Finite (childFamily A i s) := fun s => hA (i, s) | |
| instance childSquareFintype (A : Slots branch (n + 1) β Type u) | |
| [hA : β s, Finite (A s)] (i : Fin (branch n)) : | |
| Fintype (squareSpace (space π branch n (childFamily A i))) := by | |
| letI : β s, Finite (childFamily A i s) := fun s => hA (i, s) | |
| exact Fintype.ofFinite _ | |
| instance ordinaryDrawFintype (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) | |
| [β s, Finite (A s)] (j : OffPath i) : | |
| Fintype (DrawSpace π repeats (.step i p) A (.inl j)) := | |
| drawSpaceFintype π repeats (.step i p) A (.inl j) | |
| instance ordinaryTapeFintype (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) | |
| [β s, Finite (A s)] : Fintype (OrdinaryTape π repeats i p A) := by | |
| letI : β j : OffPath i, Fintype (DrawSpace π repeats (.step i p) A (.inl j)) := | |
| fun j => drawSpaceFintype π repeats (.step i p) A (.inl j) | |
| exact Pi.instFintype | |
| instance callTapesFintype (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) | |
| [hA : β s, Finite (A s)] : Fintype (CallTapes π repeats i p A) := by | |
| letI : β s, Finite (childFamily A i s) := fun s => hA (i, s) | |
| letI : Fintype (Tape π repeats p (childFamily A i)) := | |
| @Pi.instFintype (DrawIndex repeats p) | |
| (DrawSpace π repeats p (childFamily A i)) | |
| (drawIndexDecidableEq repeats p) (drawIndexFintype repeats p) | |
| (fun j => drawSpaceFintype π repeats p (childFamily A i) j) | |
| exact Pi.instFintype | |
| def ordinaryLaw (π : Type w) [Field π] [Finite π] | |
| (repeats : Nat β Nat) (i : Fin (branch n)) (p : Path branch n m) | |
| (A : Slots branch (n + 1) β Type u) [β s, Finite (A s)] : | |
| FiniteDistribution (OrdinaryTape π repeats i p A) := by | |
| letI : β j : OffPath i, Fintype (DrawSpace π repeats (.step i p) A (.inl j)) := | |
| fun j => drawSpaceFintype π repeats (.step i p) A (.inl j) | |
| letI : β j : OffPath i, Nonempty (DrawSpace π repeats (.step i p) A (.inl j)) := | |
| fun j => β¨zeroDraw π repeats (.step i p) A (.inl j)β© | |
| exact FiniteProduct.law (fun j : OffPath i => | |
| FiniteDistribution.uniform (DrawSpace π repeats (.step i p) A (.inl j))) | |
| def callTapeLaw (π : Type w) [Field π] [Finite π] | |
| (repeats : Nat β Nat) (i : Fin (branch n)) (p : Path branch n m) | |
| (A : Slots branch (n + 1) β Type u) [hA : β s, Finite (A s)] : | |
| FiniteDistribution (CallTapes π repeats i p A) := by | |
| letI : β s, Finite (childFamily A i s) := fun s => hA (i, s) | |
| exact FiniteProduct.law (fun _ : CallIndex repeats n => | |
| tapeLaw π repeats p (childFamily A i)) | |
| theorem splitTape_law (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) | |
| [β s, Finite (A s)] : | |
| (tapeLaw π repeats (.step i p) A).pushforward (splitTapeEquiv π repeats i p A) = | |
| (ordinaryLaw π repeats i p A).product (callTapeLaw π repeats i p A) := by | |
| rw [β FiniteDistribution.transport_eq_pushforward] | |
| apply FiniteDistribution.eq_of_weight_eq | |
| intro z | |
| let : β j : OffPath i β (CallIndex repeats n Γ DrawIndex repeats p), | |
| Fintype (DrawSpace π repeats (.step i p) A j) := | |
| fun j => drawSpaceFintype π repeats (.step i p) A j | |
| change | |
| (β j : OffPath i β (CallIndex repeats n Γ DrawIndex repeats p), | |
| 1 / (Fintype.card (DrawSpace π repeats (.step i p) A j) : β)) = | |
| (β j : OffPath i, | |
| 1 / (Fintype.card (DrawSpace π repeats (.step i p) A (.inl j)) : β)) * | |
| β _hb : CallIndex repeats n, β j : DrawIndex repeats p, | |
| 1 / (Fintype.card (DrawSpace π repeats p (childFamily A i) j) : β) | |
| rw [Fintype.prod_sum_type, Fintype.prod_prod_type] | |
| simp only [Fintype.card_eq_nat_card] | |
| rfl | |
| theorem subTape_tuple_law (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) | |
| [β s, Finite (A s)] : | |
| (tapeLaw π repeats (.step i p) A).pushforward | |
| (fun t (hb : CallIndex repeats n) => subTape π repeats i p A t hb.1 hb.2) = | |
| callTapeLaw π repeats i p A := by | |
| calc | |
| _ = ((tapeLaw π repeats (.step i p) A).pushforward | |
| (splitTapeEquiv π repeats i p A)).pushforward Prod.snd := | |
| (FiniteDistribution.pushforward_comp _ _ Prod.snd).symm | |
| _ = _ := by | |
| rw [splitTape_law, FiniteDistribution.product_pushforward_snd] | |
| def callScalarLaw (π : Type w) [Field π] [Finite π] | |
| (repeats : Nat β Nat) (i : Fin (branch n)) (p : Path branch n m) | |
| (A : Slots branch (n + 1) β Type u) [hA : β s, Finite (A s)] | |
| [Fintype (space π branch n (childFamily A i))] : | |
| FiniteDistribution (CallIndex repeats n β space π branch n (childFamily A i)) := by | |
| letI : β s, Finite (childFamily A i s) := fun s => hA (i, s) | |
| exact FiniteProduct.law (fun _ : CallIndex repeats n => | |
| law π repeats p (childFamily A i)) | |
| theorem evaluateCalls_law (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) | |
| [β s, Finite (A s)] [Fintype (space π branch n (childFamily A i))] : | |
| (callTapeLaw π repeats i p A).pushforward (evaluateCalls π repeats i p A) = | |
| callScalarLaw π repeats i p A := | |
| FiniteProduct.pushforward_map _ (fun _ => evaluate π repeats p (childFamily A i)) | |
| theorem splitEvaluatedTape_law (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) | |
| [β s, Finite (A s)] [Fintype (space π branch n (childFamily A i))] : | |
| (tapeLaw π repeats (.step i p) A).pushforward | |
| (splitEvaluatedTape π repeats i p A) = | |
| (ordinaryLaw π repeats i p A).product (callScalarLaw π repeats i p A) := by | |
| calc | |
| _ = ((tapeLaw π repeats (.step i p) A).pushforward | |
| (splitTapeEquiv π repeats i p A)).pushforward | |
| (fun z => (z.1, evaluateCalls π repeats i p A z.2)) := | |
| (FiniteDistribution.pushforward_comp _ _ _).symm | |
| _ = ((ordinaryLaw π repeats i p A).product | |
| (callTapeLaw π repeats i p A)).pushforward | |
| (fun z => (z.1, evaluateCalls π repeats i p A z.2)) := by | |
| rw [splitTape_law] | |
| _ = (ordinaryLaw π repeats i p A).product | |
| ((callTapeLaw π repeats i p A).pushforward | |
| (evaluateCalls π repeats i p A)) := by | |
| simpa only [id_eq, FiniteDistribution.pushforward_id] using | |
| (FiniteDistribution.product_pushforward | |
| (ordinaryLaw π repeats i p A) (callTapeLaw π repeats i p A) | |
| (id : OrdinaryTape π repeats i p A β OrdinaryTape π repeats i p A) | |
| (evaluateCalls π repeats i p A)) | |
| _ = _ := by rw [evaluateCalls_law] | |
| theorem law_step (repeats : Nat β Nat) (i : Fin (branch n)) | |
| (p : Path branch n m) (A : Slots branch (n + 1) β Type u) | |
| [β s, Finite (A s)] [Fintype (space π branch n (childFamily A i))] | |
| [Fintype (space π branch (n + 1) A)] : | |
| law π repeats (.step i p) A = | |
| ((ordinaryLaw π repeats i p A).product | |
| (callScalarLaw π repeats i p A)).pushforward | |
| (stepCombine π repeats i p A) := by | |
| calc | |
| _ = ((tapeLaw π repeats (.step i p) A).pushforward | |
| (splitEvaluatedTape π repeats i p A)).pushforward | |
| (stepCombine π repeats i p A) := | |
| (FiniteDistribution.pushforward_comp _ _ _).symm | |
| _ = _ := by rw [splitEvaluatedTape_law] | |
| end | |
| end PerfectCompleteness.RecursiveSampler | |
| end OAI | |