math / data /lean /OAI /Algorithms /SubexponentialSAT /CosetInvariance.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
7.96 kB
import OAI.Algorithms.SubexponentialSAT.LeanCompat
namespace OAI.Algorithms
/-!
# Coset invariance of residue lifts
Section 4.3 of the candidate exposition chooses a fixed section of reduction
and applies it to the residue of a lifted row evaluation. The coordinate
lifts themselves need not preserve addition. This file isolates that fact:
only their residues must agree with the specified linear row.
-/
namespace SubexponentialSAT.CosetInvariance
section Linear
variable {R M N : Type*} [Ring R] [AddCommGroup M] [Module R M]
[AddCommGroup N] [Module R N]
/-- A row which annihilates a submodule is constant on each of its cosets. -/
theorem linear_map_eq_of_sub_mem (L : M β†’β‚—[R] N) (K : Submodule R M)
(hK : K ≀ LinearMap.ker L) {x y : M} (hxy : y - x ∈ K) :
L y = L x := by
have hzero : L (y - x) = 0 := hK hxy
simpa only [map_sub, sub_eq_zero] using hzero
theorem linear_map_add_eq_of_mem (L : M β†’β‚—[R] N) (K : Submodule R M)
(hK : K ≀ LinearMap.ker L) (x : M) {r : M} (hr : r ∈ K) :
L (x + r) = L x := by
have hzero : L r = 0 := hK hr
simp only [map_add, hzero, add_zero]
/-- Applying any fixed function preserves this exact coset invariance. -/
theorem compose_eq_of_sub_mem {A : Type*} (L : M β†’β‚—[R] N)
(K : Submodule R M) (hK : K ≀ LinearMap.ker L) (s : N β†’ A)
{x y : M} (hxy : y - x ∈ K) :
s (L y) = s (L x) :=
congrArg s (linear_map_eq_of_sub_mem L K hK hxy)
/-- The common value is genuinely a function on the quotient by the subspace. -/
def onQuotient {A : Type*} (L : M β†’β‚—[R] N) (K : Submodule R M)
(hK : K ≀ LinearMap.ker L) (s : N β†’ A) : (M β§Έ K) β†’ A :=
fun q => s (K.liftQ L hK q)
@[simp]
theorem onQuotient_mk {A : Type*} (L : M β†’β‚—[R] N) (K : Submodule R M)
(hK : K ≀ LinearMap.ker L) (s : N β†’ A) (x : M) :
onQuotient L K hK s (Submodule.Quotient.mk x) = s (L x) := rfl
end Linear
section Residue
variable {A E : Type*} [CommRing A] [CommRing E]
/-- An arbitrary fixed right inverse of a residue homomorphism.
No additive or multiplicative property is required of the lift. -/
structure ResidueSection (ρ : A β†’+* E) where
lift : E β†’ A
residue_lift : βˆ€ y, ρ (lift y) = y
namespace ResidueSection
variable {ρ : A β†’+* E} (s : ResidueSection ρ)
/-- The error between a value and the chosen lift of its residue. -/
def defect (a : A) : A := a - s.lift (ρ a)
@[simp]
theorem residue_defect (a : A) : ρ (s.defect a) = 0 := by
simp only [defect, map_sub, s.residue_lift, sub_self]
theorem defect_mem_kernel (a : A) : s.defect a ∈ RingHom.ker ρ :=
s.residue_defect a
/-- If the residue kernel is generated by p, every lift error is p-divisible. -/
theorem defect_dvd (p : A) (hker : RingHom.ker ρ = Ideal.span ({p} : Set A))
(a : A) : p ∣ s.defect a := by
rw [← Ideal.mem_span_singleton, ← hker]
exact s.defect_mem_kernel a
/-- The same interface using the elementwise kernel description. -/
theorem defect_exists_mul (p : A)
(hker : βˆ€ z : A, ρ z = 0 β†’ βˆƒ q : A, z = p * q) (a : A) :
βˆƒ q : A, s.defect a = p * q :=
hker _ (s.residue_defect a)
/-- The failure of a section to preserve addition is a residue-kernel element. -/
theorem carry_mem_kernel (x y : E) :
s.lift (x + y) - s.lift x - s.lift y ∈ RingHom.ker ρ := by
change ρ (s.lift (x + y) - s.lift x - s.lift y) = 0
simp only [map_sub, s.residue_lift, add_sub_cancel_left, sub_self]
theorem carry_dvd (p : A) (hker : RingHom.ker ρ = Ideal.span ({p} : Set A))
(x y : E) : p ∣ s.lift (x + y) - s.lift x - s.lift y := by
rw [← Ideal.mem_span_singleton, ← hker]
exact s.carry_mem_kernel x y
end ResidueSection
variable {R M : Type*} [Ring R] [AddCommGroup M] [Module R M] [Module R E]
/-- A lifted evaluation may be nonlinear because of representative carries.
Its only requirement is that reduction gives the specified linear row. -/
structure LiftedRow (ρ : A β†’+* E) (L : M β†’β‚—[R] E) where
value : M β†’ A
residue_value : βˆ€ x, ρ (value x) = L x
namespace LiftedRow
variable {ρ : A β†’+* E} {L : M β†’β‚—[R] E}
(row : LiftedRow ρ L) (s : ResidueSection ρ)
/-- The beta value in Section 4.3, defined using the lifted evaluation. -/
def beta (x : M) : A := s.lift (ρ (row.value x))
theorem beta_eq_lift_row (x : M) : row.beta s x = s.lift (L x) := by
rw [beta, row.residue_value]
@[simp]
theorem residue_beta (x : M) : ρ (row.beta s x) = L x := by
rw [beta, s.residue_lift, row.residue_value]
/-- Beta is exactly equal, not just congruent, at two inputs in one coset. -/
theorem beta_invariant (K : Submodule R M) (hK : K ≀ LinearMap.ker L)
{x y : M} (hxy : y - x ∈ K) :
row.beta s y = row.beta s x := by
rw [row.beta_eq_lift_row, row.beta_eq_lift_row]
exact compose_eq_of_sub_mem L K hK s.lift hxy
theorem beta_add_invariant (K : Submodule R M) (hK : K ≀ LinearMap.ker L)
(x : M) {r : M} (hr : r ∈ K) :
row.beta s (x + r) = row.beta s x := by
rw [row.beta_eq_lift_row, row.beta_eq_lift_row,
linear_map_add_eq_of_mem L K hK x hr]
theorem beta_factors_through_quotient (K : Submodule R M)
(hK : K ≀ LinearMap.ker L) (x : M) :
row.beta s x = onQuotient L K hK s.lift (Submodule.Quotient.mk x) := by
exact row.beta_eq_lift_row s x
/-- The lifted row can change inside a coset, but only by a kernel element. -/
theorem value_sub_mem_kernel (K : Submodule R M) (hK : K ≀ LinearMap.ker L)
{x y : M} (hxy : y - x ∈ K) :
row.value y - row.value x ∈ RingHom.ker ρ := by
change ρ (row.value y - row.value x) = 0
rw [map_sub, row.residue_value, row.residue_value,
linear_map_eq_of_sub_mem L K hK hxy, sub_self]
theorem value_sub_dvd (K : Submodule R M) (hK : K ≀ LinearMap.ker L)
(p : A) (hker : RingHom.ker ρ = Ideal.span ({p} : Set A))
{x y : M} (hxy : y - x ∈ K) :
p ∣ row.value y - row.value x := by
rw [← Ideal.mem_span_singleton, ← hker]
exact row.value_sub_mem_kernel K hK hxy
theorem value_sub_beta_mem_kernel (x : M) :
row.value x - row.beta s x ∈ RingHom.ker ρ :=
s.defect_mem_kernel (row.value x)
/-- This is the p-divisible coefficient of U after input substitution. -/
theorem value_sub_beta_dvd (p : A)
(hker : RingHom.ker ρ = Ideal.span ({p} : Set A)) (x : M) :
p ∣ row.value x - row.beta s x :=
s.defect_dvd p hker (row.value x)
end LiftedRow
end Residue
section FiniteRows
variable {R A E ΞΉ : Type*} [CommRing R] [CommRing A] [CommRing E]
[Algebra R E] [Fintype ΞΉ]
/-- A finite coefficient row over an extension ring, linear over the base ring. -/
def finiteRow (c : ΞΉ β†’ E) : (ΞΉ β†’ R) β†’β‚—[R] E where
toFun x := βˆ‘ i, c i * algebraMap R E (x i)
map_add' x y := by
simp only [Pi.add_apply, map_add, mul_add, Finset.sum_add_distrib]
map_smul' r x := by
simp only [Pi.smul_apply, smul_eq_mul, map_mul, Algebra.smul_def, Finset.mul_sum]
apply Finset.sum_congr rfl
intro i _
exact mul_left_comm _ _ _
@[simp]
theorem finiteRow_apply (c : ΞΉ β†’ E) (x : ΞΉ β†’ R) :
finiteRow c x = βˆ‘ i, c i * algebraMap R E (x i) := rfl
/-- Actual coordinate lifts give the lifted-row interface. No law about sums of
representatives is assumed: all representative carries are permitted. -/
def liftedFiniteRow (ρ : A β†’+* E) (coordinateLift : R β†’ A)
(hLift : βˆ€ r, ρ (coordinateLift r) = algebraMap R E r) (c : ΞΉ β†’ A) :
LiftedRow (R := R) ρ (finiteRow (R := R) (fun i => ρ (c i))) where
value x := βˆ‘ i, c i * coordinateLift (x i)
residue_value x := by
simp only [map_sum, map_mul, hLift, finiteRow_apply]
@[simp]
theorem liftedFiniteRow_value (ρ : A β†’+* E) (coordinateLift : R β†’ A)
(hLift : βˆ€ r, ρ (coordinateLift r) = algebraMap R E r)
(c : ΞΉ β†’ A) (x : ΞΉ β†’ R) :
(liftedFiniteRow ρ coordinateLift hLift c).value x =
βˆ‘ i, c i * coordinateLift (x i) := rfl
end FiniteRows
end SubexponentialSAT.CosetInvariance
end OAI.Algorithms