roseking's picture
Add lean source and binary files (part 61)
ea76aac verified
Raw History Blame Contribute Delete
4.6 kB
import Mathlib
import OAI.Computability.MaxCut.Encoding.BinaryRowTransport
namespace OAI
/-! Local extraction of the genuine linear row maps from complete supplied inputs. -/
namespace MaxCutGames.Soundness.ActualInputRows
open MaxCutGames.Integration.BinaryLinear
open MaxCutGames.Reduction
open ConditionalIncidences PartnerMapCoordinates RawPartnerTarget BinaryRowTransport
noncomputable section
attribute [local instance] Classical.propDecidable
variable {k : Nat} {Q Id Name : Type}
def restrictedFirst (rhs : Id → Bool)
(qa : ZeroInformation.FirstInput (Fin k) Q Id) (x : ActualHomogeneous.E k) : Q → F2 :=
let p := (PartnerLinear.sourceLinearEquiv (fun j => rhs (qa.question j))).symm x
fun q => ofBit (qa.row p.homogeneous
(fun j => ConcreteExtraction.tripleCoordinates (p.coordinates j)) q)
def firstMap (rhs : Id → Bool) (qa : ZeroInformation.FirstInput (Fin k) Q Id) :
ActualHomogeneous.E k →ₗ[F2] (Q → F2) :=
if h : ∃ Z : ActualHomogeneous.E k →ₗ[F2] (Q → F2),
∀ x, Z x = restrictedFirst rhs qa x then Classical.choose h else 0
theorem firstMap_eq (rhs : Id → Bool) (qa : ZeroInformation.FirstInput (Fin k) Q Id)
(Z : ActualHomogeneous.E k →ₗ[F2] (Q → F2))
(hZ : ∀ x, restrictedFirst rhs qa x = Z x) : firstMap rhs qa = Z := by
have h : ∃ W : ActualHomogeneous.E k →ₗ[F2] (Q → F2),
∀ x, W x = restrictedFirst rhs qa x := ⟨Z, fun x => (hZ x).symm⟩
unfold firstMap
rw [dite_eq_left h]
exact LinearMap.ext (fun x => (Classical.choose_spec h x).trans (hZ x))
def restrictedSecond (J : Finset (Fin k))
(qb : ZeroInformation.SecondInput (Fin k) Q Id Name) (v : RawPoint J) : Q → F2 :=
let y := (pointEquiv (fun _ : Fin k => false) J).symm v
fun q => ofBit (qb.row y.homogeneous
(fun j => ConcreteExtraction.tripleCoordinates (y.full j)) y.single q)
def secondMap (J : Finset (Fin k))
(qb : ZeroInformation.SecondInput (Fin k) Q Id Name) : RawPoint J →ₗ[F2] (Q → F2) :=
if h : ∃ Y : RawPoint J →ₗ[F2] (Q → F2),
∀ v, Y v = restrictedSecond J qb v then Classical.choose h else 0
theorem secondMap_eq (J : Finset (Fin k))
(qb : ZeroInformation.SecondInput (Fin k) Q Id Name) (Y : RawPoint J →ₗ[F2] (Q → F2))
(hY : ∀ v, restrictedSecond J qb v = Y v) : secondMap J qb = Y := by
have h : ∃ W : RawPoint J →ₗ[F2] (Q → F2),
∀ v, W v = restrictedSecond J qb v := ⟨Y, fun v => (hY v).symm⟩
unfold secondMap
rw [dite_eq_left h]
exact LinearMap.ext (fun v => (Classical.choose_spec h v).trans (hY v))
/-- The first player's extraction on the actual sampled input equals `Y π`.
There is no assumption that an arbitrary input row is linear. -/
theorem firstMap_actual [Fintype Q] [DecidableEq Q]
(J : Finset (Fin k)) (rhs : Id → Bool) (occ : Fin k → Id)
(slot : Fin k → PartnerProjection.Slot) (Y : RawPoint J →ₗ[F2] (Q → F2)) :
firstMap rhs (actualFirst J (rowCoefficients J (gammaOfRawMap J Y))
(fun j => (occ j, ConcreteExtraction.slotIndex (slot j)))) =
Y.comp (rawProjection (fun j => rhs (occ j)) J slot) := by
apply firstMap_eq
intro x
let p := (PartnerLinear.sourceLinearEquiv (fun j => rhs (occ j))).symm x
have h := actual_pullbackRow (fun j => rhs (occ j)) J (gammaOfRawMap J Y) slot p
rw [← rawMap_on_partner (fun j => rhs (occ j)) J Y] at h
funext q
have he := congrArg ofBit (congrFun h q).symm
simp only [rowBits, ofBit_toBit, restrictedFirst, actualFirst,
ZeroInformation.firstInput, rawProjection, p, LinearMap.comp_apply,
LinearEquiv.coe_toLinearMap] at he ⊢
convert he using 1
congr 5
/-- The second player's extraction equals the genuine supplied raw target map. -/
theorem secondMap_actual [Fintype Q] [DecidableEq Q]
(J : Finset (Fin k)) (names : Id → Fin 3 → Name) (draw : Draw (Fin k) Id)
(Y : RawPoint J →ₗ[F2] (Q → F2)) :
secondMap J (actualSecond J names (rowCoefficients J (gammaOfRawMap J Y)) draw) = Y := by
apply secondMap_eq
intro v
let y := (pointEquiv (fun _ : Fin k => false) J).symm v
have h := actual_partnerRow (fun _ : Fin k => false) J (gammaOfRawMap J Y) y
rw [← rawMap_on_partner (fun _ : Fin k => false) J Y] at h
have hy : pointEquiv (fun _ : Fin k => false) J y = v :=
(pointEquiv (fun _ : Fin k => false) J).apply_symm_apply v
rw [hy] at h
funext q
have he := congrArg ofBit (congrFun h q).symm
simpa only [rowBits, ofBit_toBit, restrictedSecond, actualSecond,
ZeroInformation.secondInput, y] using he
end
end MaxCutGames.Soundness.ActualInputRows
end OAI