math / data /lean /OAI /Computability /PerfectCompleteness /Algebra /CanonicalMatrixTable.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
4.81 kB
import OAI.Computability.PerfectCompleteness.Algebra.EvaluationMatrix
import OAI.Computability.PerfectCompleteness.Foundations.LinearEvaluationLemmas
import OAI.Computability.PerfectCompleteness.Foundations.QuotientTableAgreementLemmas
namespace OAI
section
namespace PerfectCompleteness.CanonicalMatrixTable
noncomputable section
open scoped Classical
open ClauseSupport MixedSupport CanonicalKeys
open DirectionQuotient (F2)
variable {n : Nat} {K Z : Type*} [AddCommGroup K] [Module F2 K]
(slots : Fin n β†’ Slot) (H : Submodule F2 (Assignment slots β†’ F2))
(other : Assignment slots β†’ Z) (Οƒ : KeyStrategy.Strategy n)
abbrev Matrix := Module.Dual F2 H β†’β‚—[F2] K
def query (X : Matrix (K := K) slots H) : Assignment slots β†’ K Γ— Z :=
EvaluationMatrix.joint H other X
def response (X : Matrix (K := K) slots H) : K Γ— Z :=
KeyStrategy.response Οƒ .left slots (query slots H other X)
def partialTable (useful : Matrix (K := K) slots H β†’ Prop) (X : Matrix (K := K) slots H) : Option (K Γ— Z) :=
if useful X then some (response slots H other Οƒ X) else none
theorem response_realized (X : Matrix (K := K) slots H) :
βˆƒ x : Assignment slots,
EvaluationMatrix.evaluate H X x = (response slots H other Οƒ X).1 ∧
other x = (response slots H other Οƒ X).2 := by
obtain ⟨x, hx⟩ := KeyStrategy.response_mem_range Οƒ .left slots (query slots H other X)
exact ⟨x, congrArg Prod.fst hx, congrArg Prod.snd hx⟩
def rightQuery (a : K) (X : Matrix (K := K) slots H) : Assignment slots β†’ DirectionQuotient.Space a Γ— Z :=
DirectionQuotient.projectWithSide a ∘ query slots H other X
theorem rightQuery_shift (a : K) (X : Matrix (K := K) slots H) (h : H) :
rightQuery slots H other a (EvaluationMatrix.shift H X a h) =
rightQuery slots H other a X := by
funext x
apply Prod.ext
Β· change DirectionQuotient.proj a
(EvaluationMatrix.evaluate H X x + h.val x β€’ a) =
DirectionQuotient.proj a (EvaluationMatrix.evaluate H X x)
rw [map_add, map_smul]
have ha : DirectionQuotient.proj a a = 0 :=
(DirectionQuotient.proj_eq_zero_iff a a).mpr (Or.inr rfl)
simp [ha]
Β· rfl
theorem rightResponse_shift (a : K) (X : Matrix (K := K) slots H) (h : H) :
KeyStrategy.response Οƒ .right slots
(rightQuery slots H other a (EvaluationMatrix.shift H X a h)) =
KeyStrategy.response Οƒ .right slots (rightQuery slots H other a X) := by
rw [rightQuery_shift]
def Accepts (a : K) (X : Matrix (K := K) slots H) : Prop :=
CanonicalEdges.coarsen slots (query slots H other X) (DirectionQuotient.projectWithSide a)
(KeyStrategy.label Οƒ .left slots (query slots H other X)) =
KeyStrategy.label Οƒ .right slots (rightQuery slots H other a X)
theorem accepts_iff (a : K) (X : Matrix (K := K) slots H) :
Accepts slots H other Οƒ a X ↔
DirectionQuotient.projectWithSide a (response slots H other Οƒ X) =
KeyStrategy.response Οƒ .right slots (rightQuery slots H other a X) :=
CanonicalEdges.coarsen_eq_iff slots (query slots H other X)
(DirectionQuotient.projectWithSide a) _ _
theorem accepted_response_in_fiber (a : K) (X : Matrix (K := K) slots H) (h : H)
(hacc : Accepts slots H other Οƒ a (EvaluationMatrix.shift H X a h)) :
DirectionQuotient.projectWithSide a
(response slots H other Οƒ (EvaluationMatrix.shift H X a h)) =
KeyStrategy.response Οƒ .right slots (rightQuery slots H other a X) := by
have h := (accepts_iff slots H other Οƒ a (EvaluationMatrix.shift H X a h)).mp hacc
rwa [rightResponse_shift] at h
theorem card_accepted_responses_le_two [Finite K] [Finite Z]
(a : K) (ha : a β‰  0) (X : Matrix (K := K) slots H) :
Nat.card {y : K Γ— Z // βˆƒ h : H,
Accepts slots H other Οƒ a (EvaluationMatrix.shift H X a h) ∧
response slots H other Οƒ (EvaluationMatrix.shift H X a h) = y} ≀ 2 := by
let z := KeyStrategy.response Οƒ .right slots (rightQuery slots H other a X)
let intoFiber :
{y : K Γ— Z // βˆƒ h : H,
Accepts slots H other Οƒ a (EvaluationMatrix.shift H X a h) ∧
response slots H other Οƒ (EvaluationMatrix.shift H X a h) = y} β†’
{y : K Γ— Z // DirectionQuotient.projectWithSide a y = z} := fun y =>
⟨y.val, by
obtain ⟨h, hacc, hy⟩ := y.property
rw [← hy]
exact accepted_response_in_fiber slots H other Οƒ a X h hacc⟩
calc
_ ≀ Nat.card {y : K Γ— Z // DirectionQuotient.projectWithSide a y = z} :=
Nat.card_le_card_of_injective intoFiber (by
intro y y' he
exact Subtype.ext (congrArg
(fun v : {y : K Γ— Z // DirectionQuotient.projectWithSide a y = z} => v.val) he))
_ = 2 := DirectionQuotient.card_projectWithSide_fiber a ha z
end
end PerfectCompleteness.CanonicalMatrixTable
end
end OAI