Download data/lean/OAI/Combinatorics/ContingencyTables/Transport/ComplementChain.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 14.9 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/ContingencyTables/Transport/ComplementChain.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/ContingencyTables/Transport/ComplementChain.lean
-
curl -L -o ComplementChain.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/ContingencyTables/Transport/ComplementChain.lean
14.9 kB
| import OAI.Combinatorics.ContingencyTables.Transport.ObservableBounds | |
| namespace OAI | |
| /-! | |
| # The manuscript's original omission coordinates | |
| Complementation reverses defect labels and their multipliers. We prove the | |
| actual chain energy, conditional projection, and variance identities before | |
| transferring the variance and observable inequalities back to the original | |
| factorial lift f. The final theorems assume its omission property. | |
| -/ | |
| namespace ContingencyTables.ComplementChain | |
| open scoped BigOperators Classical | |
| open CommonBasesFPRAS BinaryContraction DegreeCompletion PairedComplement ObservableVariance ObservableBounds | |
| variable {Ξ : Type*} [Fintype Ξ] [DecidableEq Ξ] | |
| omit [Fintype Ξ] [DecidableEq Ξ] in | |
| lemma plain_complement (gs : List (Ξ Γ Ξ)) (S : Set Ξ) : | |
| PlainState gs SαΆ β PlainState gs S := by | |
| unfold PlainState PairSingle | |
| simp only [Set.mem_compl_iff] | |
| constructor <;> intro h p hp <;> have hh := h p hp <;> tauto | |
| omit [Fintype Ξ] [DecidableEq Ξ] in | |
| lemma defect_complement (gs : List (Ξ Γ Ξ)) (p r : Ξ Γ Ξ) (S : Set Ξ) : | |
| DefectState gs p r SαΆ β DefectState gs r p S := by | |
| unfold DefectState PairEmpty PairFull PairSingle | |
| simp only [Set.mem_compl_iff, not_not] | |
| constructor | |
| Β· rintro β¨hp,hr,hpr,hep,hfr,hsβ© | |
| refine β¨hr,hp,hpr.symm,hfr,hep,?_β© | |
| intro t ht htr htp | |
| have h := hs t ht htp htr | |
| tauto | |
| Β· rintro β¨hr,hp,hrp,her,hfp,hsβ© | |
| refine β¨hp,hr,hrp.symm,hfp,her,?_β© | |
| intro t ht htp htr | |
| have h := hs t ht htr htp | |
| tauto | |
| omit [Fintype Ξ] [DecidableEq Ξ] in | |
| lemma state_complement (gs : List (Ξ Γ Ξ)) (S : Set Ξ) : | |
| ChainState gs SαΆ β ChainState gs S := by | |
| unfold ChainState | |
| rw [plain_complement] | |
| constructor | |
| Β· rintro (h | β¨p,r,hβ©) | |
| Β· exact Or.inl h | |
| Β· exact Or.inr β¨r,p,(defect_complement gs p r S).mp hβ© | |
| Β· rintro (h | β¨p,r,hβ©) | |
| Β· exact Or.inl h | |
| Β· exact Or.inr β¨r,p,(defect_complement gs r p S).mpr hβ© | |
| omit [Fintype Ξ] [DecidableEq Ξ] in | |
| lemma adjacent_complement (S T : Set Ξ) : ExchangeAdjacent SαΆ TαΆ β ExchangeAdjacent S T := by | |
| have hf (S T : Set Ξ) (h : ExchangeAdjacent S T) : ExchangeAdjacent SαΆ TαΆ := by | |
| obtain β¨A,a,b,hab,ha,hb,rfl,rflβ© := h | |
| let B := (insert a (insert b A))αΆ | |
| refine β¨B,b,a,hab.symm,?_,?_,?_,?_β© | |
| Β· simp [B] | |
| Β· simp [B] | |
| Β· ext x | |
| simp only [B, Set.mem_compl_iff, Set.mem_insert_iff] | |
| constructor | |
| Β· intro hx | |
| by_cases hxb : x = b | |
| Β· exact Or.inl hxb | |
| Β· exact Or.inr (by tauto) | |
| Β· intro hx | |
| rcases hx with rfl | hx | |
| Β· exact not_or.mpr β¨hab.symm, hbβ© | |
| Β· tauto | |
| Β· ext x | |
| simp only [B, Set.mem_compl_iff, Set.mem_insert_iff] | |
| constructor | |
| Β· intro hx | |
| by_cases hxa : x = a | |
| Β· exact Or.inl hxa | |
| Β· exact Or.inr (by tauto) | |
| Β· intro hx | |
| rcases hx with rfl | hx | |
| Β· exact not_or.mpr β¨hab, haβ© | |
| Β· tauto | |
| exact β¨fun h => by simpa using hf SαΆ TαΆ h, hf S Tβ© | |
| omit [Fintype Ξ] [DecidableEq Ξ] in | |
| def complementEquiv : Set Ξ β Set Ξ where | |
| toFun := compl | |
| invFun := compl | |
| left_inv := compl_compl | |
| right_inv := compl_compl | |
| omit [Fintype Ξ] [DecidableEq Ξ] in | |
| def reverseMultiplier (w : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β) : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β := | |
| fun p r => w r p | |
| lemma multiplier_complement (gs : List (Ξ Γ Ξ)) (w : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β) (S : Set Ξ) : | |
| chainMultiplier gs (reverseMultiplier w) SαΆ = chainMultiplier gs w S := by | |
| by_cases he : β p r, DefectState gs p r S | |
| Β· obtain β¨p,r,hβ© := he | |
| rw [chainMultiplier_defect gs _ SαΆ ((defect_complement gs r p S).mpr h), | |
| chainMultiplier_defect gs w S h] | |
| rfl | |
| Β· have hec : Β¬ β p r, DefectState gs p r SαΆ := by | |
| rintro β¨p,r,hβ© | |
| exact he β¨r,p,(defect_complement gs p r S).mp hβ© | |
| simp only [chainMultiplier, dite_eq_right he, dite_eq_right hec] | |
| lemma weight_complement (gs : List (Ξ Γ Ξ)) (w : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β) | |
| (f : Set Ξ β β) (S : Set Ξ) : | |
| chainWeight gs (reverseMultiplier w) (complementWeight f) SαΆ = chainWeight gs w f S := by | |
| simp only [chainWeight, multiplier_complement, complementWeight, compl_compl] | |
| lemma chain_sum_complement (gs : List (Ξ Γ Ξ)) (w : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β) | |
| (f J : Set Ξ β β) : | |
| (β S β chainStates gs, chainWeight gs (reverseMultiplier w) (complementWeight f) S * J S) = | |
| β S β chainStates gs, chainWeight gs w f S * J SαΆ := by | |
| simp only [chainStates, Finset.sum_filter] | |
| apply Fintype.sum_equiv complementEquiv | |
| intro S | |
| change (if ChainState gs S then _ else 0) = (if ChainState gs SαΆ then _ else 0) | |
| rw [state_complement] | |
| by_cases h : ChainState gs S | |
| Β· simp only [ite_eq_left h] | |
| have hw := weight_complement gs w f SαΆ | |
| simp only [compl_compl] at hw | |
| rw [hw] | |
| simp only [complementEquiv, Equiv.coe_fn_mk, compl_compl] | |
| Β· simp only [ite_eq_right h] | |
| lemma total_complement (gs : List (Ξ Γ Ξ)) (w : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β) (f : Set Ξ β β) : | |
| chainTotal gs (reverseMultiplier w) (complementWeight f) = chainTotal gs w f := by | |
| simpa only [chainTotal, mul_one] using chain_sum_complement gs w f (fun _ => 1) | |
| lemma mean_complement (gs : List (Ξ Γ Ξ)) (w : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β) (f H : Set Ξ β β) : | |
| chainMean gs (reverseMultiplier w) (complementWeight f) (complementWeight H) = chainMean gs w f H := by | |
| unfold chainMean | |
| rw [total_complement, chain_sum_complement] | |
| simp only [complementWeight, compl_compl] | |
| lemma variance_complement (gs : List (Ξ Γ Ξ)) (w : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β) (f H : Set Ξ β β) : | |
| chainVariance gs (reverseMultiplier w) (complementWeight f) (complementWeight H) = | |
| chainVariance gs w f H := by | |
| unfold chainVariance | |
| rw [total_complement, mean_complement, chain_sum_complement] | |
| simp only [complementWeight, compl_compl] | |
| lemma conductance_complement (gs : List (Ξ Γ Ξ)) (w : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β) | |
| (f : Set Ξ β β) (ST : Set Ξ Γ Set Ξ) : | |
| chainConductance gs (reverseMultiplier w) (complementWeight f) (ST.1αΆ,ST.2αΆ) = | |
| chainConductance gs w f ST := by | |
| simp only [chainConductance, multiplier_complement, complementWeight, compl_compl] | |
| lemma energy_complement (gs : List (Ξ Γ Ξ)) (w : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β) (f H : Set Ξ β β) : | |
| restrictedEnergy (chainEdges gs) (chainConductance gs (reverseMultiplier w) (complementWeight f)) | |
| (complementWeight H) β β = | |
| restrictedEnergy (chainEdges gs) (chainConductance gs w f) H β β := by | |
| have hr (ST : Set Ξ Γ Set Ξ) : EdgeRespects β β ST := by simp [EdgeRespects, Respects] | |
| unfold restrictedEnergy | |
| simp only [hr, ite_true, chainEdges, Finset.sum_filter] | |
| congr 1 | |
| let E : (Set Ξ Γ Set Ξ) β (Set Ξ Γ Set Ξ) := Equiv.prodCongr complementEquiv complementEquiv | |
| apply Fintype.sum_equiv E | |
| intro ST | |
| change (if ChainState gs ST.1 β§ ChainState gs ST.2 β§ ExchangeAdjacent ST.1 ST.2 then _ else 0) = | |
| (if ChainState gs ST.1αΆ β§ ChainState gs ST.2αΆ β§ ExchangeAdjacent ST.1αΆ ST.2αΆ then _ else 0) | |
| rw [state_complement, state_complement, adjacent_complement] | |
| by_cases h : ChainState gs ST.1 β§ ChainState gs ST.2 β§ ExchangeAdjacent ST.1 ST.2 | |
| Β· simp only [ite_eq_left h] | |
| have hc := conductance_complement gs w f (ST.1αΆ,ST.2αΆ) | |
| simp only [compl_compl] at hc | |
| rw [hc] | |
| rfl | |
| Β· simp only [ite_eq_right h] | |
| lemma dirichlet_complement (gs : List (Ξ Γ Ξ)) (w : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β) (f H : Set Ξ β β) : | |
| chainDirichlet gs (reverseMultiplier w) (complementWeight f) (complementWeight H) = | |
| chainDirichlet gs w f H := by | |
| unfold chainDirichlet | |
| rw [total_complement, energy_complement] | |
| lemma plain_mass_complement (gs : List (Ξ Γ Ξ)) (hgs : SlotsFresh gs β ) | |
| (hcover : pairSupport gs = Set.univ) (f : Set Ξ β β) : | |
| slotTotal gs (complementWeight f) β = slotTotal gs f β := by | |
| exact slotTotal_complement gs f β β (by simp) (by simpa using hgs) (by simpa using hcover) | |
| lemma defect_mass_complement (gs : List (Ξ Γ Ξ)) (hgs : SlotsFresh gs β ) | |
| (hcover : pairSupport gs = Set.univ) (f : Set Ξ β β) | |
| (p r : Ξ Γ Ξ) (hp : p β gs) (hr : r β gs) (hpr : p β r) : | |
| slotDefect gs (complementWeight f) β p r = slotDefect gs f β r p := by | |
| exact slotDefect_complement gs f β β (by simp) (by simpa using hgs) (by simpa using hcover) p r hp hr hpr | |
| lemma projection_complement (gs : List (Ξ Γ Ξ)) (hgs : SlotsFresh gs β ) | |
| (hcover : pairSupport gs = Set.univ) (f H : Set Ξ β β) : | |
| observableProjection gs (complementWeight f) (complementWeight H) = | |
| complementWeight (observableProjection gs f H) := by | |
| have hmul : (fun S => complementWeight f S * complementWeight H S) = | |
| complementWeight (fun S => f S * H S) := rfl | |
| funext S | |
| change observableProjection gs (complementWeight f) (complementWeight H) S = | |
| observableProjection gs f H SαΆ | |
| by_cases he : β p r, DefectState gs p r S | |
| Β· obtain β¨p,r,hβ© := he | |
| have hc : DefectState gs r p SαΆ := (defect_complement gs r p S).mpr h | |
| rw [observableProjection_defect gs _ _ S h, observableProjection_defect gs f H SαΆ hc] | |
| unfold defectMean | |
| rw [hmul, defect_mass_complement gs hgs hcover _ p r h.1 h.2.1 h.2.2.1, | |
| defect_mass_complement gs hgs hcover f p r h.1 h.2.1 h.2.2.1] | |
| Β· have hec : Β¬ β p r, DefectState gs p r SαΆ := by | |
| rintro β¨p,r,hβ© | |
| exact he β¨r,p,(defect_complement gs p r S).mp hβ© | |
| simp only [observableProjection, dite_eq_right he, dite_eq_right hec, complementWeight] | |
| lemma slotVariance_complement (gs : List (Ξ Γ Ξ)) (hgs : SlotsFresh gs β ) | |
| (hcover : pairSupport gs = Set.univ) (f H : Set Ξ β β) : | |
| slotVariance gs (complementWeight f) (complementWeight H) β = slotVariance gs f H β := by | |
| unfold slotVariance | |
| change slotTotal gs (complementWeight (fun S => f S*(H S)^2)) β - | |
| (slotTotal gs (complementWeight (fun S => f S*H S)) β )^2/slotTotal gs (complementWeight f) β = _ | |
| rw [plain_mass_complement gs hgs hcover, plain_mass_complement gs hgs hcover, | |
| plain_mass_complement gs hgs hcover] | |
| /-- The actual manuscript variance theorem in original omission coordinates. -/ | |
| theorem omission_twoLift_transversal_variance (gs : List (Ξ Γ Ξ)) (f g H : Set Ξ β β) | |
| (w : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β) (q : β) (hq : 0 β€ q) | |
| (hf : DegreePositive f gs.length) (hg : DegreePositive g gs.length) | |
| (hsigf : OmissionProperty f gs.length) (hsigg : AdditionProperty g gs.length) | |
| (hgs : SlotsFresh gs β ) (hcover : pairSupport gs = Set.univ) | |
| (hw : β p r, 0 < w p r) | |
| (hgood : β p β gs, β r β gs, p β r β | |
| slotTotal gs f β /(4*slotDefect gs f β p r) β€ w p r) | |
| (hagree : β S, PlainState gs S β f S = g S) | |
| (hcompare : β S, ChainState gs S β f S β€ q*g S) : | |
| slotVariance gs f H β β€ (gs.length : β)*(1+8*(gs.length : β)*q^2)* | |
| restrictedEnergy (chainEdges gs) (chainConductance gs w f) H β β := by | |
| have hcard := slots_ground_card gs hgs hcover | |
| have hhalf : Fintype.card Ξ - gs.length = gs.length := by omega | |
| have hfc : DegreePositive (complementWeight f) gs.length := by | |
| simpa only [hhalf] using complement_degreePositive f gs.length (by omega) hf | |
| have hgc : DegreePositive (complementWeight g) gs.length := by | |
| simpa only [hhalf] using complement_degreePositive g gs.length (by omega) hg | |
| have hsf : AdditionProperty (complementWeight f) gs.length := by | |
| simpa only [OmissionProperty, hhalf] using hsigf | |
| have hsg : OmissionProperty (complementWeight g) gs.length := by | |
| have hcc : complementWeight (complementWeight g) = g := by funext S; simp [complementWeight] | |
| simpa only [OmissionProperty, hhalf, hcc] using hsigg | |
| have hgood' : β p β gs, β r β gs, p β r β | |
| slotTotal gs (complementWeight f) β /(4*slotDefect gs (complementWeight f) β p r) β€ reverseMultiplier w p r := by | |
| intro p hp r hr hpr | |
| rw [plain_mass_complement gs hgs hcover, defect_mass_complement gs hgs hcover f p r hp hr hpr] | |
| exact hgood r hr p hp hpr.symm | |
| have ht := validDegree_twoLift_transversal_variance gs (complementWeight f) (complementWeight g) | |
| (complementWeight H) (reverseMultiplier w) q hq hfc hgc hsf hsg hgs hcover | |
| (fun p r => hw r p) hgood' | |
| (fun S hS => hagree SαΆ ((plain_complement gs S).mpr hS)) | |
| (fun S hS => hcompare SαΆ ((state_complement gs S).mpr hS)) | |
| rwa [slotVariance_complement gs hgs hcover f H, energy_complement gs w f H] at ht | |
| /-- The paper's observable PoincarΓ© theorem for the literal first factorial | |
| lift, assuming its omission property only at the actual subset degree. -/ | |
| theorem omission_observable_poincare (gs : List (Ξ Γ Ξ)) (hgs : SlotsFresh gs β ) (hne : gs β []) | |
| (hcover : pairSupport gs = Set.univ) (w : (Ξ Γ Ξ) β (Ξ Γ Ξ) β β) | |
| (hw : β p r, 0 < w p r) (f H : Set Ξ β β) | |
| (hf : DegreePositive f gs.length) (hsig : OmissionProperty f gs.length) | |
| (q : β) (hq : 1 β€ q) | |
| (hlower : β p β gs, β r β gs, p β r β slotTotal gs f β /(4*slotDefect gs f β p r) β€ w p r) | |
| (hupper : β p β gs, β r β gs, p β r β w p r β€ 4*slotTotal gs f β /slotDefect gs f β p r) : | |
| chainVariance gs w f (observableProjection gs f H) β€ | |
| observableConstant gs.length q * chainDirichlet gs w f H := by | |
| have hcard := slots_ground_card gs hgs hcover | |
| have hhalf : Fintype.card Ξ - gs.length = gs.length := by omega | |
| have hfc : DegreePositive (complementWeight f) gs.length := by | |
| simpa only [hhalf] using complement_degreePositive f gs.length (by omega) hf | |
| have hsf : AdditionProperty (complementWeight f) gs.length := by | |
| simpa only [OmissionProperty, hhalf] using hsig | |
| have hl : β p β gs, β r β gs, p β r β | |
| slotTotal gs (complementWeight f) β /(4*slotDefect gs (complementWeight f) β p r) β€ reverseMultiplier w p r := by | |
| intro p hp r hr hpr | |
| rw [plain_mass_complement gs hgs hcover, defect_mass_complement gs hgs hcover f p r hp hr hpr] | |
| exact hlower r hr p hp hpr.symm | |
| have hu : β p β gs, β r β gs, p β r β | |
| reverseMultiplier w p r β€ 4*slotTotal gs (complementWeight f) β /slotDefect gs (complementWeight f) β p r := by | |
| intro p hp r hr hpr | |
| rw [plain_mass_complement gs hgs hcover, defect_mass_complement gs hgs hcover f p r hp hr hpr] | |
| exact hupper r hr p hp hpr.symm | |
| have ht := validDegree_observable_poincare gs hgs hne hcover (reverseMultiplier w) | |
| (fun p r => hw r p) (complementWeight f) (complementWeight H) hfc hsf q hq hl hu | |
| rwa [projection_complement gs hgs hcover, variance_complement, dirichlet_complement] at ht | |
| end ContingencyTables.ComplementChain | |
| end OAI | |