Download data/lean/OAI/Computability/MaxCut/Games/Information.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 40 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MaxCut/Games/Information.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/MaxCut/Games/Information.lean
-
curl -L -o Information.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/MaxCut/Games/Information.lean
40 kB
| import Mathlib | |
| import OAI.Computability.MaxCut.Games.PartnerProjection | |
| namespace OAI | |
| noncomputable section | |
| namespace MaxCutGames.Soundness.ZeroInformation | |
| /-! ## The observation fibre is a Cartesian product -/ | |
| section Fibres | |
| variable {P X Y : Type} (hidden : P β Bool) (reveal : P β X β Y) (observed : P β Y) | |
| /-- The complete draw, constrained only by the observations outside the hidden set. -/ | |
| def Fibre := {sample : P β X // | |
| β j, hidden j = false β reveal j (sample j) = observed j} | |
| /-- At hidden positions the draw is unconstrained. -/ | |
| def Inside := (j : P) β hidden j = true β X | |
| /-- The remaining part of a draw, satisfying the outside observation. -/ | |
| def Outside := {sample : (j : P) β hidden j = false β X // | |
| β j hj, reveal j (sample j hj) = observed j} | |
| def fibreInside (sample : Fibre hidden reveal observed) : Inside (X := X) hidden := | |
| fun j _ => sample.val j | |
| def fibreOutside (sample : Fibre hidden reveal observed) : Outside hidden reveal observed := | |
| β¨fun j _ => sample.val j, sample.propertyβ© | |
| def assemble (inside : Inside (X := X) hidden) (outside : Outside hidden reveal observed) : | |
| Fibre hidden reveal observed := | |
| β¨fun j => if hj : hidden j = true then inside j hj else outside.val j (by | |
| cases h : hidden j | |
| Β· rfl | |
| Β· exact False.elim (hj h)), by | |
| intro j hj | |
| simp only [hj, Bool.false_eq_true, βreduceDIte] | |
| exact outside.property j hjβ© | |
| theorem inside_assemble (inside : Inside (X := X) hidden) | |
| (outside : Outside hidden reveal observed) : | |
| fibreInside hidden reveal observed (assemble hidden reveal observed inside outside) = inside := by | |
| funext j hj | |
| simp [fibreInside, assemble, hj] | |
| theorem outside_assemble (inside : Inside (X := X) hidden) | |
| (outside : Outside hidden reveal observed) : | |
| fibreOutside hidden reveal observed (assemble hidden reveal observed inside outside) = outside := by | |
| apply Subtype.ext | |
| funext j hj | |
| simp [fibreOutside, assemble, hj] | |
| theorem assemble_split (sample : Fibre hidden reveal observed) : | |
| assemble hidden reveal observed | |
| (fibreInside hidden reveal observed sample) | |
| (fibreOutside hidden reveal observed sample) = sample := by | |
| apply Subtype.ext | |
| funext j | |
| simp only [assemble, fibreInside, fibreOutside] | |
| split <;> rfl | |
| /-- A fibre is in explicit bijection with the product of unrestricted inside draws | |
| and admissible outside draws. This assertion does not posit any independence axiom. -/ | |
| theorem fibre_product (sample : Fibre hidden reveal observed) : | |
| β inside : Inside (X := X) hidden, β outside : Outside hidden reveal observed, | |
| assemble hidden reveal observed inside outside = sample := by | |
| exact β¨fibreInside hidden reveal observed sample, | |
| fibreOutside hidden reveal observed sample, | |
| assemble_split hidden reveal observed sampleβ© | |
| end Fibres | |
| /-! ## Exact weighted finite counting -/ | |
| def mass {A : Type} : List A β (A β Nat) β Nat | |
| | [], _ => 0 | |
| | a :: rest, w => w a + mass rest w | |
| theorem mass_scale {A : Type} (xs : List A) (w : A β Nat) (c : Nat) : | |
| mass xs (fun x => c * w x) = c * mass xs w := by | |
| induction xs with | |
| | nil => simp [mass] | |
| | cons a xs ih => simp only [mass, ih, Nat.mul_add] | |
| /-- `outsideWeight` may already include the indicator of a fixed observation H=h. -/ | |
| theorem rectangular_mass {A B : Type} (outside : List A) (inside : List B) | |
| (outsideWeight : A β Nat) (insideWeight : B β Nat) : | |
| mass outside (fun a => mass inside (fun b => outsideWeight a * insideWeight b)) = | |
| mass outside outsideWeight * mass inside insideWeight := by | |
| induction outside with | |
| | nil => simp [mass] | |
| | cons a outside ih => | |
| change mass inside (fun b => outsideWeight a * insideWeight b) + | |
| mass outside (fun a => mass inside (fun b => outsideWeight a * insideWeight b)) = _ | |
| rw [ih, mass_scale] | |
| simp only [mass, Nat.add_mul] | |
| /-- The division-free conditional-probability identity. If the observation has | |
| positive mass, division by that mass gives the unchanged inside law. -/ | |
| theorem conditional_inside_identity {A B : Type} (outside : List A) (inside : List B) | |
| (outsideWeight : A β Nat) (insideWeight : B β Nat) (event : B β Bool) : | |
| mass outside (fun a => mass inside (fun b => | |
| outsideWeight a * (if event b then insideWeight b else 0))) * | |
| mass inside insideWeight = | |
| mass outside (fun a => mass inside (fun b => outsideWeight a * insideWeight b)) * | |
| mass inside (fun b => if event b then insideWeight b else 0) := by | |
| rw [rectangular_mass, rectangular_mass] | |
| simp only [Nat.mul_assoc] | |
| rw [Nat.mul_comm (mass inside (fun b => if event b then insideWeight b else 0))] | |
| /-! ## Position-indexed row maps -/ | |
| abbrev Bits (R : Type) := R β Bool | |
| def zero {R : Type} : Bits R := fun _ => false | |
| def add {R : Type} (a b : Bits R) : Bits R := fun r => a r ^^ b r | |
| def scale {R : Type} (coefficient : Bits R) (bit : Bool) : Bits R := | |
| fun r => coefficient r && bit | |
| theorem scale_zero {R : Type} (bit : Bool) : | |
| scale (zero : Bits R) bit = zero := by | |
| funext r | |
| simp [scale, zero] | |
| def rowSum {P R : Type} (positions : List P) (term : P β Bits R) : Bits R := | |
| positions.foldr (fun j acc => add (term j) acc) zero | |
| theorem rowSum_congr {P R : Type} (positions : List P) (a b : P β Bits R) | |
| (h : β j, a j = b j) : rowSum positions a = rowSum positions b := by | |
| have hab : a = b := funext h | |
| rw [hab] | |
| /-- Raw row application after pulling back the retained coordinates along Ο. | |
| `single` records J, and `omega` is indexed by positions, never by names. -/ | |
| def pullbackRow {P R : Type} (positions : List P) (single : P β Bool) | |
| (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) | |
| (indices : P β Fin 3) (homogeneous : Bool) (x : P β Fin 3 β Bool) : Bits R := | |
| add (scale zeta0 homogeneous) (rowSum positions fun j => | |
| if single j then scale (omega j) (x j (indices j)) | |
| else add (scale (zeta1 j) (x j 0)) (scale (zeta2 j) (x j 1))) | |
| /-- Changing an index where its position coefficient is zero does not change the | |
| entire row map. This is an equality for all ambient coordinates, so also on E_U. -/ | |
| theorem pullbackRow_index_independent {P R : Type} (positions : List P) | |
| (single : P β Bool) (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) | |
| (i i' : P β Fin 3) | |
| (agrees : β j, single j = true β omega j β zero β i j = i' j) | |
| (homogeneous : Bool) (x : P β Fin 3 β Bool) : | |
| pullbackRow positions single zeta0 zeta1 zeta2 omega i homogeneous x = | |
| pullbackRow positions single zeta0 zeta1 zeta2 omega i' homogeneous x := by | |
| unfold pullbackRow | |
| congr 1 | |
| apply rowSum_congr | |
| intro j | |
| cases hs : single j | |
| Β· simp | |
| Β· simp only [βreduceIte] | |
| by_cases hz : omega j = zero | |
| Β· simp [hz] | |
| Β· rw [agrees j hs hz] | |
| /-- Distinct occurrence names recover the retained index at all nonzero positions. | |
| Consequently revealing outside (occurrence,name) pairs supplies exactly the indices | |
| needed by the first player; inside names and indices are unnecessary. -/ | |
| theorem pullbackRow_from_outside_names {P R O N : Type} (positions : List P) | |
| (single : P β Bool) (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) | |
| (occurrences : P β O) (name : O β Fin 3 β N) | |
| (distinct : β o i i', name o i = name o i' β i = i') | |
| (i i' : P β Fin 3) | |
| (sameNames : β j, single j = true β omega j β zero β | |
| name (occurrences j) (i j) = name (occurrences j) (i' j)) | |
| (homogeneous : Bool) (x : P β Fin 3 β Bool) : | |
| pullbackRow positions single zeta0 zeta1 zeta2 omega i homogeneous x = | |
| pullbackRow positions single zeta0 zeta1 zeta2 omega i' homogeneous x := by | |
| apply pullbackRow_index_independent | |
| intro j hj hz | |
| exact distinct (occurrences j) (i j) (i' j) (sameNames j hj hz) | |
| /-- In particular, substituting the equation for a retained third bit cannot leak | |
| the hidden right-hand side through a zero coefficient. -/ | |
| theorem zero_third_bit {R : Type} (rhs homogeneous x1 x2 : Bool) : | |
| scale (zero : Bits R) ((rhs && homogeneous) ^^ x1 ^^ x2) = zero := by | |
| exact scale_zero _ | |
| /-! ## Complete private-input reconstruction -/ | |
| /-- A raw row function on ambient first-question coordinates. Restricting it to | |
| the equation subspace gives the supplied map `Z_B Ο`. -/ | |
| abbrev FirstRow (P R : Type) := Bool β (P β Fin 3 β Bool) β Bits R | |
| /-- A raw row function on ambient partner coordinates. -/ | |
| abbrev SecondRow (P R : Type) := | |
| Bool β (P β Fin 3 β Bool) β (P β Bool) β Bits R | |
| structure FirstInput (P R O : Type) where | |
| question : P β O | |
| row : FirstRow P R | |
| /-- `Sum.inl o` records a full occurrence and `Sum.inr n` a single named bit. | |
| The summand tag preserves the set J without exposing any retained index. -/ | |
| structure SecondInput (P R O N : Type) where | |
| question : P β Sum O N | |
| row : SecondRow P R | |
| def partnerQuestion {P O N : Type} (single : P β Bool) (occurrences : P β O) | |
| (names : P β N) : P β Sum O N := | |
| fun j => if single j then .inr (names j) else .inl (occurrences j) | |
| def partnerRow {P R : Type} (positions : List P) (single : P β Bool) | |
| (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) : SecondRow P R := | |
| fun homogeneous x y => add (scale zeta0 homogeneous) (rowSum positions fun j => | |
| if single j then scale (omega j) (y j) | |
| else add (scale (zeta1 j) (x j 0)) (scale (zeta2 j) (x j 1))) | |
| /-- The raw formula really is the pullback under the retained-coordinate projection. -/ | |
| theorem partnerRow_pullback {P R : Type} (positions : List P) (single : P β Bool) | |
| (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) (indices : P β Fin 3) | |
| (homogeneous : Bool) (x : P β Fin 3 β Bool) : | |
| partnerRow positions single zeta0 zeta1 zeta2 omega homogeneous x | |
| (fun j => x j (indices j)) = | |
| pullbackRow positions single zeta0 zeta1 zeta2 omega indices homogeneous x := rfl | |
| def firstInput {P R O : Type} (positions : List P) (single : P β Bool) | |
| (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) | |
| (occurrences : P β O) (indices : P β Fin 3) : FirstInput P R O := | |
| β¨occurrences, pullbackRow positions single zeta0 zeta1 zeta2 omega indicesβ© | |
| def secondInput {P R O N : Type} (positions : List P) (single : P β Bool) | |
| (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) | |
| (occurrences : P β O) (names : P β N) : SecondInput P R O N := | |
| β¨partnerQuestion single occurrences names, | |
| partnerRow positions single zeta0 zeta1 zeta2 omegaβ© | |
| /-- A total fixed decoder for a retained index. On supported (o,n) it is uniquely | |
| determined by the distinctness of the three names. -/ | |
| noncomputable def decodeIndex {O N : Type} (name : O β Fin 3 β N) | |
| (occurrence : O) (n : N) : Fin 3 := by | |
| classical | |
| exact if h : β i, name occurrence i = n then Classical.choose h else 0 | |
| theorem decodeIndex_name {O N : Type} (name : O β Fin 3 β N) | |
| (distinct : β o i i', name o i = name o i' β i = i') (o : O) (i : Fin 3) : | |
| decodeIndex name o (name o i) = i := by | |
| classical | |
| unfold decodeIndex | |
| have he : β i', name o i' = name o i := β¨i, rflβ© | |
| simp only [he, βreduceDIte] | |
| exact distinct o _ i (Classical.choose_spec he) | |
| def reconstructQuestion {P X : Type} (hidden : P β Bool) (inside outside : P β X) : P β X := | |
| fun j => if hidden j then inside j else outside j | |
| theorem reconstructQuestion_actual {P X : Type} (hidden : P β Bool) | |
| (actual outside : P β X) (houtside : β j, hidden j = false β outside j = actual j) : | |
| reconstructQuestion hidden actual outside = actual := by | |
| funext j | |
| cases hj : hidden j | |
| Β· simp [reconstructQuestion, hj, houtside j hj] | |
| Β· simp [reconstructQuestion, hj] | |
| /-- The first reconstruction receives only fixed outside occurrence/name data, | |
| the fixed raw coefficients, and the inside occurrence draw. -/ | |
| noncomputable def reconstructFirst {P R O N : Type} (positions : List P) | |
| (single hidden : P β Bool) (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) | |
| (name : O β Fin 3 β N) (insideOccurrences outsideOccurrences : P β O) | |
| (outsideNames : P β N) : FirstInput P R O := | |
| firstInput positions single zeta0 zeta1 zeta2 omega | |
| (reconstructQuestion hidden insideOccurrences outsideOccurrences) | |
| (fun j => decodeIndex name (outsideOccurrences j) (outsideNames j)) | |
| theorem first_input_reconstruction {P R O N : Type} (positions : List P) | |
| (single hidden : P β Bool) (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) | |
| (hidden_zero : β j, hidden j = true β omega j = zero) | |
| (name : O β Fin 3 β N) | |
| (distinct : β o i i', name o i = name o i' β i = i') | |
| (occurrences outsideOccurrences : P β O) (indices : P β Fin 3) | |
| (outsideNames : P β N) | |
| (houtsideO : β j, hidden j = false β outsideOccurrences j = occurrences j) | |
| (houtsideN : β j, hidden j = false β outsideNames j = name (occurrences j) (indices j)) : | |
| reconstructFirst positions single hidden zeta0 zeta1 zeta2 omega name | |
| occurrences outsideOccurrences outsideNames = | |
| firstInput positions single zeta0 zeta1 zeta2 omega occurrences indices := by | |
| unfold reconstructFirst firstInput | |
| rw [reconstructQuestion_actual hidden occurrences outsideOccurrences houtsideO] | |
| congr 1 | |
| funext homogeneous x | |
| apply pullbackRow_index_independent | |
| intro j _ hz | |
| have hj : hidden j = false := by | |
| cases hh : hidden j | |
| Β· rfl | |
| Β· exact False.elim (hz (hidden_zero j hh)) | |
| rw [houtsideO j hj, houtsideN j hj] | |
| exact decodeIndex_name name distinct (occurrences j) (indices j) | |
| /-- The second reconstruction receives no inside occurrence: only inside names. -/ | |
| def reconstructSecond {P R O N : Type} (positions : List P) | |
| (single hidden : P β Bool) (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) | |
| (outsideOccurrences : P β O) (insideNames outsideNames : P β N) : SecondInput P R O N := | |
| secondInput positions single zeta0 zeta1 zeta2 omega outsideOccurrences | |
| (reconstructQuestion hidden insideNames outsideNames) | |
| theorem second_input_reconstruction {P R O N : Type} (positions : List P) | |
| (single hidden : P β Bool) (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) | |
| (hidden_single : β j, hidden j = true β single j = true) | |
| (occurrences outsideOccurrences : P β O) (names outsideNames : P β N) | |
| (houtsideO : β j, hidden j = false β outsideOccurrences j = occurrences j) | |
| (houtsideN : β j, hidden j = false β outsideNames j = names j) : | |
| reconstructSecond positions single hidden zeta0 zeta1 zeta2 omega | |
| outsideOccurrences names outsideNames = | |
| secondInput positions single zeta0 zeta1 zeta2 omega occurrences names := by | |
| unfold reconstructSecond secondInput | |
| rw [reconstructQuestion_actual hidden names outsideNames houtsideN] | |
| congr 1 | |
| funext j | |
| unfold partnerQuestion | |
| cases hs : single j | |
| Β· have hj : hidden j = false := by | |
| cases hh : hidden j | |
| Β· rfl | |
| Β· have contradiction := hidden_single j hh | |
| rw [hs] at contradiction | |
| contradiction | |
| simp [houtsideO j hj] | |
| Β· simp | |
| /-- The first equation subspace is determined by its occurrence question alone. -/ | |
| def FirstPoint {P O : Type} (rhs : O β Bool) (question : P β O) := | |
| {point : Bool Γ (P β Fin 3 β Bool) // β j, | |
| (point.2 j 0 ^^ point.2 j 1 ^^ point.2 j 2) = (rhs (question j) && point.1)} | |
| /-- At single positions the partner space has a free bit and no occurrence or rhs. | |
| Unused ambient coordinates are fixed to zero, giving a canonical embedding of | |
| the position-dependent coordinate space rather than extra degrees of freedom. -/ | |
| def SecondPoint {P O N : Type} (rhs : O β Bool) (question : P β Sum O N) := | |
| {point : Bool Γ (P β Fin 3 β Bool) Γ (P β Bool) // β j, | |
| match question j with | |
| | .inl o => | |
| (point.2.1 j 0 ^^ point.2.1 j 1 ^^ point.2.1 j 2) = (rhs o && point.1) β§ | |
| point.2.2 j = false | |
| | .inr _ => β i, point.2.1 j i = false} | |
| def FirstInput.suppliedMap {P R O : Type} (input : FirstInput P R O) (rhs : O β Bool) : | |
| FirstPoint rhs input.question β Bits R := | |
| fun point => input.row point.val.1 point.val.2 | |
| def SecondInput.suppliedMap {P R O N : Type} (input : SecondInput P R O N) (rhs : O β Bool) : | |
| SecondPoint rhs input.question β Bits R := | |
| fun point => input.row point.val.1 point.val.2.1 point.val.2.2 | |
| def projectFull {P : Type} (single : P β Bool) (x : P β Fin 3 β Bool) : | |
| P β Fin 3 β Bool := | |
| fun j i => if single j then false else x j i | |
| def projectSingles {P : Type} (single : P β Bool) (indices : P β Fin 3) | |
| (x : P β Fin 3 β Bool) : P β Bool := | |
| fun j => if single j then x j (indices j) else false | |
| def partnerProjection {P O N : Type} (single : P β Bool) (rhs : O β Bool) | |
| (occurrences : P β O) (names : P β N) (indices : P β Fin 3) | |
| (point : FirstPoint rhs occurrences) : | |
| SecondPoint rhs (partnerQuestion single occurrences names) := | |
| β¨(point.val.1, projectFull single point.val.2, projectSingles single indices point.val.2), by | |
| intro j | |
| cases hs : single j | |
| Β· simp only [partnerQuestion, hs, Bool.false_eq_true, βreduceIte, | |
| projectFull, projectSingles] | |
| exact β¨point.property j, True.introβ© | |
| Β· simp [partnerQuestion, hs, projectFull]β© | |
| theorem partnerRow_project {P R : Type} (positions : List P) (single : P β Bool) | |
| (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) (indices : P β Fin 3) | |
| (homogeneous : Bool) (x : P β Fin 3 β Bool) : | |
| partnerRow positions single zeta0 zeta1 zeta2 omega homogeneous | |
| (projectFull single x) (projectSingles single indices x) = | |
| pullbackRow positions single zeta0 zeta1 zeta2 omega indices homogeneous x := by | |
| unfold partnerRow pullbackRow | |
| congr 1 | |
| apply rowSum_congr | |
| intro j | |
| cases hs : single j <;> simp [hs, projectFull, projectSingles] | |
| theorem supplied_map_pullback {P R O N : Type} (positions : List P) (single : P β Bool) | |
| (zeta0 : Bits R) (zeta1 zeta2 omega : P β Bits R) (rhs : O β Bool) | |
| (occurrences : P β O) (names : P β N) (indices : P β Fin 3) | |
| (point : FirstPoint rhs occurrences) : | |
| (secondInput positions single zeta0 zeta1 zeta2 omega occurrences names).suppliedMap rhs | |
| (partnerProjection single rhs occurrences names indices point) = | |
| (firstInput positions single zeta0 zeta1 zeta2 omega occurrences indices).suppliedMap rhs point := by | |
| exact partnerRow_project positions single zeta0 zeta1 zeta2 omega indices point.val.1 point.val.2 | |
| end MaxCutGames.Soundness.ZeroInformation | |
| section | |
| open scoped BigOperators | |
| namespace MaxCutGames.Soundness.ConditionalIncidences | |
| abbrev PositionInside {P : Type} (K : Finset P) := {j : P // j β K} | |
| abbrev PositionOutside {P : Type} (K : Finset P) := {j : P // j β K} | |
| abbrev Draw (P O : Type) := P β O Γ Fin 3 | |
| abbrev InsideDraw {P : Type} (K : Finset P) (O : Type) := PositionInside K β O Γ Fin 3 | |
| def incidence {O N : Type} (name : O β Fin 3 β N) (draw : O Γ Fin 3) : O Γ N := | |
| (draw.1, name draw.1 draw.2) | |
| def insideDraw {P O : Type} (K : Finset P) (sample : Draw P O) : InsideDraw K O := | |
| fun j => sample j.val | |
| def outsideRecord {P O N : Type} (K : Finset P) (name : O β Fin 3 β N) | |
| (sample : Draw P O) : PositionOutside K β O Γ N := | |
| fun j => incidence name (sample j.val) | |
| abbrev ObservationFibre {P O N : Type} (K : Finset P) (name : O β Fin 3 β N) | |
| (observed : PositionOutside K β O Γ N) := | |
| {sample : Draw P O // outsideRecord K name sample = observed} | |
| abbrev OutsideFibre {P O N : Type} (K : Finset P) (name : O β Fin 3 β N) | |
| (observed : PositionOutside K β O Γ N) := | |
| {sample : PositionOutside K β O Γ Fin 3 // | |
| (fun j => incidence name (sample j)) = observed} | |
| instance observationFibreFintype {P O N : Type} [Fintype P] [Fintype O] | |
| (K : Finset P) (name : O β Fin 3 β N) (observed : PositionOutside K β O Γ N) : | |
| Fintype (ObservationFibre K name observed) := Fintype.ofFinite _ | |
| instance outsideFibreFintype {P O N : Type} [Fintype P] [Fintype O] | |
| (K : Finset P) (name : O β Fin 3 β N) (observed : PositionOutside K β O Γ N) : | |
| Fintype (OutsideFibre K name observed) := Fintype.ofFinite _ | |
| /-- The actual observation fibre, not an assumed rectangular probability law. -/ | |
| def observationFibreEquiv {P O N : Type} [DecidableEq P] | |
| (K : Finset P) (name : O β Fin 3 β N) | |
| (observed : PositionOutside K β O Γ N) : | |
| ObservationFibre K name observed β InsideDraw K O Γ OutsideFibre K name observed where | |
| toFun sample := | |
| (insideDraw K sample.val, β¨fun j => sample.val j.val, sample.propertyβ©) | |
| invFun pieces := | |
| β¨fun j => if hj : j β K then pieces.1 β¨j, hjβ© else pieces.2.val β¨j, hjβ©, by | |
| funext j | |
| simp only [outsideRecord, j.property, βreduceDIte] | |
| exact congrFun pieces.2.property jβ© | |
| left_inv sample := by | |
| apply Subtype.ext | |
| funext j | |
| simp only [insideDraw] | |
| split <;> rfl | |
| right_inv pieces := by | |
| apply Prod.ext | |
| Β· funext j | |
| simp [insideDraw, j.property] | |
| Β· apply Subtype.ext | |
| funext j | |
| simp [j.property] | |
| def average {A : Type} [Fintype A] (f : A β β) : β := | |
| (β a, f a) / Fintype.card A | |
| theorem average_equiv {A B : Type} [Fintype A] [Fintype B] (e : A β B) (f : B β β) : | |
| average (fun a => f (e a)) = average f := by | |
| unfold average | |
| rw [e.sum_comp, Fintype.card_congr e] | |
| /-- Cancelling the finite nonempty outside fibre gives a normalized equality. -/ | |
| theorem average_product_left {A B : Type} [Fintype A] [Fintype B] | |
| (hB : Fintype.card B β 0) (f : A β β) : | |
| average (fun ab : A Γ B => f ab.1) = average f := by | |
| unfold average | |
| rw [Fintype.sum_prod_type] | |
| simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, Fintype.card_prod, Nat.cast_mul] | |
| rw [β Finset.mul_sum] | |
| have hBq : (Fintype.card B : β) β 0 := by exact_mod_cast hB | |
| rw [mul_comm (Fintype.card A : β)] | |
| exact mul_div_mul_left _ _ hBq | |
| /-- Uniform sampling from the actual finite product is independent sampling. -/ | |
| theorem average_product_mul {A B : Type} [Fintype A] [Fintype B] | |
| (f : A β β) (g : B β β) : | |
| average (fun ab : A Γ B => f ab.1 * g ab.2) = average f * average g := by | |
| unfold average | |
| rw [Fintype.sum_prod_type] | |
| simp_rw [β Finset.mul_sum] | |
| rw [β Finset.sum_mul] | |
| simp only [Fintype.card_prod, Nat.cast_mul] | |
| exact (div_mul_div_comm _ _ _ _).symm | |
| /-- The uniform function sample is the product of its uniform coordinate laws. -/ | |
| theorem average_coordinate_product {A X : Type} [Fintype A] [DecidableEq A] [Fintype X] | |
| (f : A β X β β) : | |
| average (fun sample : A β X => β a, f a (sample a)) = β a, average (f a) := by | |
| unfold average | |
| rw [β Fintype.prod_sum] | |
| simp only [Fintype.card_pi, Nat.cast_prod] | |
| exact (Finset.prod_div_distrib _ _).symm | |
| /-- This is the usual conditional-expectation ratio in a uniform finite space: | |
| the numerator and event probability are both divided by the full sample count. -/ | |
| theorem uniform_conditional_ratio {A : Type} [Fintype A] | |
| (p : A β Prop) [Fintype {a // p a}] | |
| (hpos : 0 < Fintype.card {a // p a}) (f : {a // p a} β β) : | |
| ((β a, f a) / (Fintype.card A : β)) / | |
| ((Fintype.card {a // p a} : β) / Fintype.card A) = average f := by | |
| have hA : Fintype.card A β 0 := | |
| Nat.ne_of_gt (Nat.lt_of_lt_of_le hpos (Fintype.card_subtype_le p)) | |
| have hAq : (Fintype.card A : β) β 0 := by exact_mod_cast hA | |
| exact div_div_div_cancel_rightβ hAq _ _ | |
| section ConditionalLaw | |
| variable {P O N : Type} [Fintype P] [DecidableEq P] [Fintype O] | |
| /-- Exact finite conditional expectation for *every* function of inside draws. | |
| The denominator is the cardinality of the supported observation fibre. -/ | |
| theorem conditional_inside_average (K : Finset P) (name : O β Fin 3 β N) | |
| (observed : PositionOutside K β O Γ N) | |
| (hpos : 0 < Fintype.card (ObservationFibre K name observed)) | |
| (f : InsideDraw K O β β) : | |
| average (fun sample : ObservationFibre K name observed => f (insideDraw K sample.val)) = | |
| average f := by | |
| let e := observationFibreEquiv K name observed | |
| have hcard : Fintype.card (ObservationFibre K name observed) = | |
| Fintype.card (InsideDraw K O) * Fintype.card (OutsideFibre K name observed) := by | |
| rw [Fintype.card_congr e, Fintype.card_prod] | |
| have hout : Fintype.card (OutsideFibre K name observed) β 0 := by | |
| intro hz | |
| rw [hcard, hz, Nat.mul_zero] at hpos | |
| exact (Nat.lt_irrefl 0) hpos | |
| calc | |
| average (fun sample : ObservationFibre K name observed => f (insideDraw K sample.val)) = | |
| average (fun pieces : InsideDraw K O Γ OutsideFibre K name observed => f pieces.1) := | |
| average_equiv e (fun pieces => f pieces.1) | |
| _ = average f := average_product_left hout f | |
| /-- Pushing the fresh occurrence/slot draws through (o,i) β¦ (o,vα΅’(o)) gives | |
| exactly the repeated incidence law, with no distinct-name assumption needed. -/ | |
| theorem conditional_incidence_average (K : Finset P) (name : O β Fin 3 β N) | |
| (observed : PositionOutside K β O Γ N) | |
| (hpos : 0 < Fintype.card (ObservationFibre K name observed)) | |
| (f : (PositionInside K β O Γ N) β β) : | |
| average (fun sample : ObservationFibre K name observed => | |
| f (fun j => incidence name (sample.val j.val))) = | |
| average (fun fresh : InsideDraw K O => f (fun j => incidence name (fresh j))) := by | |
| exact conditional_inside_average K name observed hpos | |
| (fun fresh => f (fun j => incidence name (fresh j))) | |
| end ConditionalLaw | |
| /-- None is ΞΆβ; the left summand gives two coefficients per full position; | |
| the right summand gives one coefficient per single position. -/ | |
| abbrev RawSlot {P : Type} (J : Finset P) := | |
| Option ((PositionOutside J Γ Fin 2) β PositionInside J) | |
| abbrev RawCoefficients {P : Type} (J : Finset P) (D : Type) := RawSlot J β D | |
| def zeroSet {P D : Type} [DecidableEq P] [Zero D] [DecidableEq D] | |
| (J : Finset P) (gamma : RawCoefficients J D) : Finset P := | |
| J.attach.filter (fun j => gamma (some (.inr j)) = 0) |>.map β¨Subtype.val, Subtype.val_injectiveβ© | |
| theorem mem_zeroSet {P D : Type} [DecidableEq P] [Zero D] [DecidableEq D] | |
| (J : Finset P) (gamma : RawCoefficients J D) (j : P) : | |
| j β zeroSet J gamma β β hj : j β J, gamma (some (.inr β¨j, hjβ©)) = 0 := by | |
| simp [zeroSet] | |
| abbrev RawSample {P : Type} (J : Finset P) (D O : Type) := | |
| RawCoefficients J D Γ Draw P O | |
| /-- H fixes gamma and the outside incidence pairs. K is a deterministic function | |
| of gamma, so including K explicitly in H gives precisely this same event. -/ | |
| abbrev RawObservationFibre {P D O N : Type} [DecidableEq P] [Zero D] [DecidableEq D] | |
| (J : Finset P) (name : O β Fin 3 β N) (gamma : RawCoefficients J D) | |
| (observed : PositionOutside (zeroSet J gamma) β O Γ N) := | |
| {sample : RawSample J D O // sample.1 = gamma β§ | |
| outsideRecord (zeroSet J gamma) name sample.2 = observed} | |
| instance rawObservationFibreFintype {P D O N : Type} [Fintype P] [DecidableEq P] | |
| [Fintype D] [Zero D] [DecidableEq D] [Fintype O] | |
| (J : Finset P) (name : O β Fin 3 β N) (gamma : RawCoefficients J D) | |
| (observed : PositionOutside (zeroSet J gamma) β O Γ N) : | |
| Fintype (RawObservationFibre J name gamma observed) := Fintype.ofFinite _ | |
| def rawObservationFibreEquiv {P D O N : Type} [DecidableEq P] [Zero D] [DecidableEq D] | |
| (J : Finset P) (name : O β Fin 3 β N) (gamma : RawCoefficients J D) | |
| (observed : PositionOutside (zeroSet J gamma) β O Γ N) : | |
| RawObservationFibre J name gamma observed β | |
| ObservationFibre (zeroSet J gamma) name observed where | |
| toFun sample := β¨sample.val.2, sample.property.2β© | |
| invFun sample := β¨(gamma, sample.val), rfl, sample.propertyβ© | |
| left_inv sample := by | |
| apply Subtype.ext | |
| exact Prod.ext sample.property.1.symm rfl | |
| right_inv sample := rfl | |
| /-- Lemma 6.7's conditional product law in the actual independent raw sampling | |
| space, with normalized rational expectations. No independence is a hypothesis. -/ | |
| theorem raw_conditional_inside_average {P D O N : Type} [Fintype P] [DecidableEq P] | |
| [Fintype D] [Zero D] [DecidableEq D] [Fintype O] [DecidableEq O] [DecidableEq N] | |
| (J : Finset P) (name : O β Fin 3 β N) (gamma : RawCoefficients J D) | |
| (observed : PositionOutside (zeroSet J gamma) β O Γ N) | |
| (hpos : 0 < Fintype.card (RawObservationFibre J name gamma observed)) | |
| (f : InsideDraw (zeroSet J gamma) O β β) : | |
| average (fun sample : RawObservationFibre J name gamma observed => | |
| f (insideDraw (zeroSet J gamma) sample.val.2)) = average f := by | |
| let e := rawObservationFibreEquiv J name gamma observed | |
| have hpos' : 0 < Fintype.card (ObservationFibre (zeroSet J gamma) name observed) := by | |
| rwa [Fintype.card_congr e] at hpos | |
| calc | |
| average (fun sample : RawObservationFibre J name gamma observed => | |
| f (insideDraw (zeroSet J gamma) sample.val.2)) = | |
| average (fun sample : ObservationFibre (zeroSet J gamma) name observed => | |
| f (insideDraw (zeroSet J gamma) sample.val)) := by | |
| exact average_equiv e (fun sample : ObservationFibre (zeroSet J gamma) name observed => | |
| f (insideDraw (zeroSet J gamma) sample.val)) | |
| _ = average f := conditional_inside_average _ name observed hpos' f | |
| /-- The same exact law expressed as the conditional expectation ratio in the | |
| whole raw sample space. Positive probability is represented by a nonempty fibre. -/ | |
| theorem raw_conditional_ratio {P D O N : Type} [Fintype P] [DecidableEq P] | |
| [Fintype D] [Zero D] [DecidableEq D] [Fintype O] [DecidableEq O] [DecidableEq N] | |
| (J : Finset P) (name : O β Fin 3 β N) (gamma : RawCoefficients J D) | |
| (observed : PositionOutside (zeroSet J gamma) β O Γ N) | |
| (hpos : 0 < Fintype.card (RawObservationFibre J name gamma observed)) | |
| (f : InsideDraw (zeroSet J gamma) O β β) : | |
| ((β sample : RawObservationFibre J name gamma observed, | |
| f (insideDraw (zeroSet J gamma) sample.val.2)) / Fintype.card (RawSample J D O)) / | |
| ((Fintype.card (RawObservationFibre J name gamma observed) : β) / | |
| Fintype.card (RawSample J D O)) = average f := by | |
| rw [uniform_conditional_ratio _ hpos] | |
| exact raw_conditional_inside_average J name gamma observed hpos f | |
| /-- The pushed-forward product incidence law at K, stated for an arbitrary | |
| joint observable, rather than only individual coordinate marginals. -/ | |
| theorem raw_conditional_incidence_average {P D O N : Type} [Fintype P] [DecidableEq P] | |
| [Fintype D] [Zero D] [DecidableEq D] [Fintype O] [DecidableEq O] [DecidableEq N] | |
| (J : Finset P) (name : O β Fin 3 β N) (gamma : RawCoefficients J D) | |
| (observed : PositionOutside (zeroSet J gamma) β O Γ N) | |
| (hpos : 0 < Fintype.card (RawObservationFibre J name gamma observed)) | |
| (f : (PositionInside (zeroSet J gamma) β O Γ N) β β) : | |
| average (fun sample : RawObservationFibre J name gamma observed => | |
| f (fun j => incidence name (sample.val.2 j.val))) = | |
| average (fun fresh : InsideDraw (zeroSet J gamma) O => f (fun j => incidence name (fresh j))) := by | |
| exact raw_conditional_inside_average J name gamma observed hpos | |
| (fun fresh => f (fun j => incidence name (fresh j))) | |
| /-- Factorization for arbitrary per-position test functions makes the product | |
| claim explicit. Repeated names across different positions are fully permitted. -/ | |
| theorem raw_conditional_product_incidence {P D O N : Type} [Fintype P] [DecidableEq P] | |
| [Fintype D] [Zero D] [DecidableEq D] [Fintype O] [DecidableEq O] [DecidableEq N] | |
| (J : Finset P) (name : O β Fin 3 β N) (gamma : RawCoefficients J D) | |
| (observed : PositionOutside (zeroSet J gamma) β O Γ N) | |
| (hpos : 0 < Fintype.card (RawObservationFibre J name gamma observed)) | |
| (f : PositionInside (zeroSet J gamma) β O Γ N β β) : | |
| average (fun sample : RawObservationFibre J name gamma observed => | |
| β j, f j (incidence name (sample.val.2 j.val))) = | |
| β j, average (fun fresh : O Γ Fin 3 => f j (incidence name fresh)) := by | |
| calc | |
| _ = average (fun fresh : InsideDraw (zeroSet J gamma) O => | |
| β j, f j (incidence name (fresh j))) := | |
| raw_conditional_inside_average J name gamma observed hpos | |
| (fun fresh => β j, f j (incidence name (fresh j))) | |
| _ = _ := average_coordinate_product (fun j fresh => f j (incidence name fresh)) | |
| end MaxCutGames.Soundness.ConditionalIncidences | |
| end | |
| /-! | |
| # Every partner linear map has independent raw coefficient coordinates | |
| The coefficient index is exactly `ConditionalIncidences.RawSlot`: one global | |
| coefficient, two coefficients at every full position, and one at every single | |
| position. The coordinate bijection below is for every actual partner linear | |
| map, and its finite-uniform-law theorem has no distributional hypothesis. | |
| -/ | |
| open scoped BigOperators | |
| namespace MaxCutGames.Soundness.PartnerMapCoordinates | |
| open PartnerProjection | |
| open ConditionalIncidences (PositionInside PositionOutside RawSlot RawCoefficients average) | |
| open MaxCutGames.Integration.BinaryLinear (F2 ofBit toBit) | |
| variable {P : Type} [DecidableEq P] (rhs : P β Bool) (J : Finset P) | |
| def activeOf (J : Finset P) (j : P) : Bool := decide (j β J) | |
| def inactiveOfOutside (j : PositionOutside J) : PartnerLinear.Inactive (activeOf J) := | |
| β¨j.val, by simp [activeOf, j.property]β© | |
| def activeOfInside (j : PositionInside J) : PartnerLinear.Active (activeOf J) := | |
| β¨j.val, by simp [activeOf, j.property]β© | |
| def outsideOfInactive (j : PartnerLinear.Inactive (activeOf J)) : PositionOutside J := | |
| β¨j.val, by simpa [activeOf] using j.propertyβ© | |
| def insideOfActive (j : PartnerLinear.Active (activeOf J)) : PositionInside J := | |
| β¨j.val, by simpa [activeOf] using j.propertyβ© | |
| def tupleToRaw (v : PartnerLinear.PartnerCoordinates (activeOf J)) : RawSlot J β F2 | |
| | none => v.1 | |
| | some (.inl (j, i)) => | |
| if i = 0 then (v.2.1 (inactiveOfOutside J j)).1 | |
| else (v.2.1 (inactiveOfOutside J j)).2 | |
| | some (.inr j) => v.2.2 (activeOfInside J j) | |
| def tupleFromRaw (f : RawSlot J β F2) : PartnerLinear.PartnerCoordinates (activeOf J) := | |
| (f none, | |
| (fun j => (f (some (.inl (outsideOfInactive J j, 0))), | |
| f (some (.inl (outsideOfInactive J j, 1)))), | |
| fun j => f (some (.inr (insideOfActive J j))))) | |
| def tupleRawEquiv : PartnerLinear.PartnerCoordinates (activeOf J) ββ[F2] (RawSlot J β F2) where | |
| toFun := tupleToRaw J | |
| invFun := tupleFromRaw J | |
| left_inv v := by | |
| apply Prod.ext | |
| Β· rfl | |
| Β· apply Prod.ext | |
| Β· funext j | |
| apply Prod.ext <;> rfl | |
| Β· funext j | |
| rfl | |
| right_inv f := by | |
| funext s | |
| rcases s with _ | (β¨j, iβ© | j) | |
| Β· rfl | |
| Β· fin_cases i <;> rfl | |
| Β· rfl | |
| map_add' x y := by | |
| funext s | |
| rcases s with _ | (β¨j, iβ© | j) | |
| Β· rfl | |
| Β· fin_cases i <;> rfl | |
| Β· rfl | |
| map_smul' c x := by | |
| funext s | |
| rcases s with _ | (β¨j, iβ© | j) | |
| Β· rfl | |
| Β· fin_cases i <;> rfl | |
| Β· rfl | |
| /-- Free coordinates of the actual partner, indexed by the exact raw coefficient slots. -/ | |
| def pointEquiv : PartnerPoint rhs (activeOf J) ββ[F2] (RawSlot J β F2) := | |
| (PartnerLinear.partnerLinearEquiv rhs (activeOf J)).trans (tupleRawEquiv J) | |
| theorem pointEquiv_none (y : PartnerPoint rhs (activeOf J)) : | |
| pointEquiv rhs J y none = ofBit y.homogeneous := rfl | |
| theorem pointEquiv_full_first (y : PartnerPoint rhs (activeOf J)) | |
| (j : PositionOutside J) : | |
| pointEquiv rhs J y (some (.inl (j, 0))) = ofBit (y.full j.val).first := rfl | |
| theorem pointEquiv_full_second (y : PartnerPoint rhs (activeOf J)) | |
| (j : PositionOutside J) : | |
| pointEquiv rhs J y (some (.inl (j, 1))) = ofBit (y.full j.val).second := rfl | |
| theorem pointEquiv_single (y : PartnerPoint rhs (activeOf J)) | |
| (j : PositionInside J) : | |
| pointEquiv rhs J y (some (.inr j)) = ofBit (y.single j.val) := rfl | |
| variable [Fintype P] | |
| def partnerBasis : Module.Basis (RawSlot J) F2 (PartnerPoint rhs (activeOf J)) := | |
| Module.Basis.ofEquivFun (pointEquiv rhs J) | |
| variable (R : Type) [AddCommGroup R] [Module F2 R] | |
| /-- Arbitrary independent raw coefficients bijectively specify an actual linear map. -/ | |
| def mapEquiv : RawCoefficients J R ββ[F2] (PartnerPoint rhs (activeOf J) ββ[F2] R) := | |
| (partnerBasis rhs J).constr F2 | |
| def coefficients (Y : PartnerPoint rhs (activeOf J) ββ[F2] R) : RawCoefficients J R := | |
| (mapEquiv rhs J R).symm Y | |
| theorem map_coefficients (Y : PartnerPoint rhs (activeOf J) ββ[F2] R) : | |
| mapEquiv rhs J R (coefficients rhs J R Y) = Y := | |
| (mapEquiv rhs J R).apply_symm_apply Y | |
| theorem coefficients_map (gamma : RawCoefficients J R) : | |
| coefficients rhs J R (mapEquiv rhs J R gamma) = gamma := | |
| (mapEquiv rhs J R).symm_apply_apply gamma | |
| theorem mapEquiv_apply (gamma : RawCoefficients J R) (y : PartnerPoint rhs (activeOf J)) : | |
| mapEquiv rhs J R gamma y = β s, pointEquiv rhs J y s β’ gamma s := by | |
| rw [mapEquiv, Module.Basis.constr_apply_fintype] | |
| simp only [partnerBasis, Module.Basis.equivFun_ofEquivFun] | |
| /-- The raw-coefficient formula for every partner point. -/ | |
| theorem mapEquiv_expansion (gamma : RawCoefficients J R) (y : PartnerPoint rhs (activeOf J)) : | |
| mapEquiv rhs J R gamma y = | |
| ofBit y.homogeneous β’ gamma none + | |
| (β j : PositionOutside J, | |
| (ofBit (y.full j.val).first β’ gamma (some (.inl (j, 0))) + | |
| ofBit (y.full j.val).second β’ gamma (some (.inl (j, 1))))) + | |
| β j : PositionInside J, ofBit (y.single j.val) β’ gamma (some (.inr j)) := by | |
| rw [mapEquiv_apply, Fintype.sum_option, Fintype.sum_sum_type, Fintype.sum_prod_type] | |
| simp only [Fin.sum_univ_two, pointEquiv_none, pointEquiv_full_first, | |
| pointEquiv_full_second, pointEquiv_single] | |
| simp only [add_assoc] | |
| theorem every_map_expansion (Y : PartnerPoint rhs (activeOf J) ββ[F2] R) | |
| (y : PartnerPoint rhs (activeOf J)) : | |
| Y y = β s, pointEquiv rhs J y s β’ coefficients rhs J R Y s := by | |
| rw [β mapEquiv_apply, map_coefficients] | |
| theorem pullback_expansion (gamma : RawCoefficients J R) (slot : P β Slot) | |
| (x : SourcePoint rhs) : | |
| mapEquiv rhs J R gamma (PartnerLinear.projection rhs (activeOf J) slot x) = | |
| ofBit x.homogeneous β’ gamma none + | |
| (β j : PositionOutside J, | |
| (ofBit (x.coordinates j.val).first β’ gamma (some (.inl (j, 0))) + | |
| ofBit (x.coordinates j.val).second β’ gamma (some (.inl (j, 1))))) + | |
| β j : PositionInside J, | |
| ofBit (retained (slot j.val) (x.coordinates j.val)) β’ gamma (some (.inr j)) := by | |
| rw [mapEquiv_expansion] | |
| congr 1 | |
| Β· congr 1 | |
| apply Finset.sum_congr rfl | |
| intro j _ | |
| simp [PartnerLinear.projection_apply, project, activeOf, j.property] | |
| Β· apply Finset.sum_congr rfl | |
| intro j _ | |
| simp [PartnerLinear.projection_apply, project, activeOf, j.property] | |
| instance partnerMapsFintype [Fintype R] : | |
| Fintype (PartnerPoint rhs (activeOf J) ββ[F2] R) := by | |
| classical | |
| exact Fintype.ofEquiv (RawCoefficients J R) (mapEquiv rhs J R).toEquiv | |
| /-- Uniform independent coefficient tuples give exactly the uniform law on all maps. -/ | |
| theorem uniform_coefficients_maps [Fintype R] | |
| (H : (PartnerPoint rhs (activeOf J) ββ[F2] R) β β) : | |
| average (fun gamma : RawCoefficients J R => H (mapEquiv rhs J R gamma)) = average H := | |
| ConditionalIncidences.average_equiv (mapEquiv rhs J R).toEquiv H | |
| /-- For a uniformly sampled actual map, all raw coefficients have the product uniform law. -/ | |
| theorem uniform_map_coefficients_product [Fintype R] | |
| (H : RawSlot J β R β β) : | |
| average (fun Y : PartnerPoint rhs (activeOf J) ββ[F2] R => | |
| β s, H s (coefficients rhs J R Y s)) = β s, average (H s) := by | |
| calc | |
| _ = average (fun gamma : RawCoefficients J R => β s, H s (gamma s)) := | |
| ConditionalIncidences.average_equiv (mapEquiv rhs J R).symm.toEquiv | |
| (fun gamma => β s, H s (gamma s)) | |
| _ = _ := ConditionalIncidences.average_coordinate_product H | |
| end MaxCutGames.Soundness.PartnerMapCoordinates | |
| end | |
| end OAI | |