Download data/lean/OAI/Combinatorics/ContingencyTables/Transport/ChoiceContextEnumeration.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.26 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/ContingencyTables/Transport/ChoiceContextEnumeration.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/ContingencyTables/Transport/ChoiceContextEnumeration.lean
-
curl -L -o ChoiceContextEnumeration.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/ContingencyTables/Transport/ChoiceContextEnumeration.lean
5.26 kB
| import OAI.Combinatorics.ContingencyTables.Transport.ContextWeightedEnumeration | |
| import OAI.Combinatorics.ContingencyTables.Sampling.PhysicalPrefixEnergies | |
| import OAI.Combinatorics.ContingencyTables.Transport.FiniteChoiceFibres | |
| namespace OAI | |
| /-! # Literal finite choice fibres equal the transport child sums -/ | |
| namespace ContingencyTables.SmallContextEnumeration | |
| open scoped BigOperators Classical | |
| open SmallContextCoordinates SmallContextFibres PhysicalCompletionFibres | |
| open LargePairEnumeration BalancedEnumeration BalancedFamily | |
| open FirstPaperContextTransport FirstPaperPhysicalMarginal ExcessContextProfiles SmallGraphProfiles | |
| open FiniteExposureVariance | |
| open IntegerWeightedTransport | |
| universe u | |
| variable {I J : Type u} [Fintype I] [Fintype J] [LinearOrder I] [LinearOrder J] | |
| def rawChoice (small : I β J β Bool) (U : β) (x : Cells small β Fin (U+1)) : | |
| SmallProfile small := fun p => if p.2 then U-(x p.1).val else (x p.1).val | |
| def earlierChoices (small : I β J β Bool) (s : IΓJ) (U : β) | |
| (x : Cells small β Fin (U+1)) : Earlier small s β Fin (U+1) := fun a => x a.val | |
| omit [Fintype I] [Fintype J] in | |
| lemma earlierChoices_eq_iff (small : I β J β Bool) (s : IΓJ) (U : β) | |
| (x : Cells small β Fin (U+1)) (Ο : Earlier small s β Fin (U+1)) : | |
| earlierChoices small s U x=Ο β β a : Earlier small s,x a.val=Ο a := | |
| funext_iff | |
| def ChoiceContext (small : I β J β Bool) (s : IΓJ) (hs : small s.1 s.2=true) (U : β) | |
| (Ο : Earlier small s β Fin (U+1)) (k : Fin (U+1)) := | |
| {x : Cells small β Fin (U+1) // earlierChoices small s U x=Ο β§ x β¨s,hsβ©=k} | |
| noncomputable instance choiceContextFintype (small : I β J β Bool) (s : IΓJ) | |
| (hs : small s.1 s.2=true) (U : β) (Ο : Earlier small s β Fin (U+1)) (k : Fin (U+1)) : | |
| Fintype (ChoiceContext small s hs U Ο k) := by unfold ChoiceContext; infer_instance | |
| noncomputable def choiceContextEquiv (small : I β J β Bool) (s : IΓJ) | |
| (hs : small s.1 s.2=true) (U : β) (Ο : Earlier small s β Fin (U+1)) (k : Fin (U+1)) : | |
| (Later small s β Fin (U+1)) β ChoiceContext small s hs U Ο k where | |
| toFun y := β¨splitChoices small s hs U Ο k y,funext (splitChoices_prefix small s hs U Ο k y), | |
| splitChoices_special small s hs U Ο k yβ© | |
| invFun x := fun a => x.val a.val | |
| left_inv y := by funext a; exact splitChoices_later small s hs U Ο k y a | |
| right_inv x := by | |
| apply Subtype.ext | |
| funext a | |
| obtain β¨v,rflβ© := (cellSplitEquiv small s hs).surjective a | |
| rcases v with p|(_|t) | |
| Β· exact (splitChoices_prefix small s hs U Ο k _ p).trans (congrFun x.property.1 p).symm | |
| Β· exact (splitChoices_special small s hs U Ο k _).trans x.property.2.symm | |
| Β· exact splitChoices_later small s hs U Ο k _ t | |
| lemma choice_fibre_sum (small : I β J β Bool) (s : IΓJ) (hs : small s.1 s.2=true) | |
| (U : β) (Ο : Earlier small s β Fin (U+1)) (k : Fin (U+1)) | |
| (F : (Cells small β Fin (U+1)) β β) : | |
| (β x,fibreWeight (fibreWeight F (earlierChoices small s U) Ο) (fun x => x β¨s,hsβ©) k x)= | |
| β x : ChoiceContext small s hs U Ο k,F x.val := by | |
| exact double_fibre_sum F (earlierChoices small s U) (fun x => x β¨s,hsβ©) Ο k | |
| omit [Fintype I] [Fintype J] in | |
| lemma prefixChoices_extension (small : I β J β Bool) (s : IΓJ) (U : β) | |
| (Ο : Earlier small s β Fin (U+1)) : | |
| prefixChoices small s (prefixExtension small s U Ο) U (prefixExtension_bounded small s U Ο)=Ο := by | |
| funext a | |
| apply Fin.ext | |
| exact prefixExtension_at small s U Ο a | |
| /-- The child mass and every child moment are the actual finite fibre | |
| sums of balanced physical choices, retaining all large completions. -/ | |
| theorem eliminate_context_eq_choice_fibre (small : I β J β Bool) (B : I β J β β) | |
| (s : IΓJ) (hs : small s.1 s.2=true) (U : β) | |
| (hB : β i j,small i j=true β B i j=U) | |
| (Ο : Earlier small s β Fin (U+1)) (k : Fin (U+1)) | |
| {n : β} (e : Fin n β Later small s) (F : SmallProfile small β β) : | |
| eliminate (widths (fun _ : Fin n => U)) | |
| (fun p => F (assemble small s hs (prefixExtension small s U Ο) U e p)) (childProfile U k.val)= | |
| β x,fibreWeight (fibreWeight (fun x => F (rawChoice small U x)) | |
| (earlierChoices small s U) Ο) (fun x => x β¨s,hsβ©) k x := by | |
| rw [eliminate_context_eq_weighted_sum small B s hs _ U hB | |
| (prefixExtension_bounded small s U Ο),choice_fibre_sum] | |
| have he := Fintype.sum_equiv | |
| (balancedContextEquiv small B s hs (prefixExtension small s U Ο) U hB | |
| (prefixExtension_bounded small s U Ο) k) | |
| (fun y => F (rawChoice small U (splitChoices small s hs U Ο k y))) | |
| (fun z => F (naturalProfile z.val)) (fun y => by | |
| change F (rawChoice small U (splitChoices small s hs U Ο k y))= | |
| F (rawChoice small U (splitChoices small s hs U | |
| (prefixChoices small s (prefixExtension small s U Ο) U (prefixExtension_bounded small s U Ο)) k y)) | |
| rw [prefixChoices_extension]) | |
| have hc := Fintype.sum_equiv (choiceContextEquiv small s hs U Ο k) | |
| (fun y => F (rawChoice small U (splitChoices small s hs U Ο k y))) | |
| (fun x => F (rawChoice small U x.val)) (fun _ => rfl) | |
| exact he.symm.trans hc | |
| end ContingencyTables.SmallContextEnumeration | |
| end OAI | |