Candidate kernel and lift conditions for affine-chart recognition
Definitionrsg_paper_chart_semanticscomputational-complexitygraph-theory
This module defines the positions, kernel of pure profiles, lifts and edge tests associated with an encoded candidate in the proof of Theorem 5.3. It gives the interfaces for proving that binary elimination solves the mathematical lift conditions and that a compatible system has a bounded candidate encoding.
Definition code
import Definitions.Def_rsg_paper_chart_checker
import Mathlib.Data.ZMod.Basic
import Mathlib.Tactic.Abel
import Mathlib
import Definitions.Def_rsg_paper_structure
import Definitions.Def_rsg_paper_complexity
import Mathlib.Algebra.Field.ZMod
import Mathlib.LinearAlgebra.Dual.Lemmas
import Mathlib.LinearAlgebra.Pi
import Mathlib.Combinatorics.SimpleGraph.Connectivity.Connected
import Mathlib.Data.Finite.Sum
import Mathlib.Data.Fintype.Sum
import Mathlib.Data.Fintype.Sigma
import Mathlib.Data.Set.Card
import Definitions.Def_rsg_recognition_core
import Mathlib.Tactic.FinCases
import Mathlib.Data.Fin.VecNotation
import Mathlib.Data.Fintype.Prod
import Mathlib.Tactic.Ring
import Definitions.Def_rsg_paper_vig_strip
import Mathlib.Data.Fintype.EquivFin
import Mathlib.Logic.Equiv.Sum
import Definitions.Def_QuantumMaxCutFiniteNumericRuntime
import Mathlib.Combinatorics.SimpleGraph.Bipartite
import Mathlib.Data.List.NodupEquivFin
import Mathlib.Analysis.SpecialFunctions.Log.Base
import Mathlib.Combinatorics.SimpleGraph.Prod
import Mathlib.Tactic.LinearCombination
import Definitions.Def_rsg_paper_eig_bipartite_lift
import Mathlib.Data.Sym.Sym2.Order
import Mathlib.LinearAlgebra.Dimension.Finite
import Mathlib.LinearAlgebra.Dimension.Constructions
import Mathlib.LinearAlgebra.LinearIndependent.Lemmas
import Mathlib.LinearAlgebra.Dimension.Finrank
import Mathlib.LinearAlgebra.Basis.VectorSpace
import Mathlib.Logic.Equiv.Fin.Basic
section
set_option autoImplicit false
namespace RSGPaper.EIGAmbientLabel
abbrev Bit := ZMod 2
abbrev Bits (n : ℕ) := Fin n → Bit
private theorem bit_add_self (x : Bit) : x + x = 0 := by
revert x
decide
private theorem bits_add_self {n : ℕ} (x : Bits n) : x + x = 0 :=
funext fun i => bit_add_self (x i)
def twiceBit : Bit →+ ZMod 4 where
toFun b := if b = 0 then 0 else 2
map_zero' := rfl
map_add' := by decide
/-- Only additivity in the two arguments is used by the label group. -/
structure Bilinear (W Z : Type) [AddCommGroup W] [AddCommGroup Z] where
value : W → W → Z
add_left : ∀ x y z, value (x + y) z = value x z + value y z
add_right : ∀ x y z, value x (y + z) = value x y + value x z
@[simp] theorem Bilinear.zero_left {W Z : Type} [AddCommGroup W] [AddCommGroup Z]
(B : Bilinear W Z) (x : W) : B.value 0 x = 0 := by
have h := B.add_left 0 0 x
rw [zero_add] at h
exact add_left_cancel (h.symm.trans (add_zero _).symm)
@[simp] theorem Bilinear.zero_right {W Z : Type} [AddCommGroup W] [AddCommGroup Z]
(B : Bilinear W Z) (x : W) : B.value x 0 = 0 := by
have h := B.add_right x 0 0
rw [zero_add] at h
exact add_left_cancel (h.symm.trans (add_zero _).symm)
structure Rule (w z : ℕ) where
flags : Bilinear (Bits w) (Bits z)
output : Bilinear (Bits w) Bit
@[ext] structure Label {w z : ℕ} (rule : Rule w z) (taps : ℕ) where
bits : Bits w
tap : Bits taps
y : ZMod 4
flags : Bits z
variable {w z d : ℕ} {R : Rule w z}
private def product (a b : Label R d) : Label R d :=
⟨a.bits + b.bits, a.tap + b.tap, a.y + b.y + twiceBit (R.output.value a.bits b.bits),
a.flags + b.flags + R.flags.value a.bits b.bits⟩
private def identity : Label R d := ⟨0, 0, 0, 0⟩
private def inverse (a : Label R d) : Label R d :=
⟨a.bits, a.tap, -a.y - twiceBit (R.output.value a.bits a.bits),
a.flags + R.flags.value a.bits a.bits⟩
instance : Group (Label R d) where
mul := product
one := identity
inv := inverse
mul_assoc a b c := by
apply Label.ext
· exact add_assoc a.bits b.bits c.bits
· exact add_assoc a.tap b.tap c.tap
· change (a.y + b.y + twiceBit (R.output.value a.bits b.bits)) + c.y +
twiceBit (R.output.value (a.bits + b.bits) c.bits) =
a.y + (b.y + c.y + twiceBit (R.output.value b.bits c.bits)) +
twiceBit (R.output.value a.bits (b.bits + c.bits))
rw [R.output.add_left, R.output.add_right, map_add, map_add]
abel
· change (a.flags + b.flags + R.flags.value a.bits b.bits) + c.flags +
R.flags.value (a.bits + b.bits) c.bits =
a.flags + (b.flags + c.flags + R.flags.value b.bits c.bits) +
R.flags.value a.bits (b.bits + c.bits)
rw [R.flags.add_left, R.flags.add_right]
abel
one_mul a := by
apply Label.ext
· exact zero_add a.bits
· exact zero_add a.tap
· change 0 + a.y + twiceBit (R.output.value 0 a.bits) = a.y
simp
· change 0 + a.flags + R.flags.value 0 a.bits = a.flags
simp
mul_one a := by
apply Label.ext
· exact add_zero a.bits
· exact add_zero a.tap
· change a.y + 0 + twiceBit (R.output.value a.bits 0) = a.y
simp
· change a.flags + 0 + R.flags.value a.bits 0 = a.flags
simp
inv_mul_cancel a := by
apply Label.ext
· exact bits_add_self _
· exact bits_add_self _
· change -a.y - twiceBit (R.output.value a.bits a.bits) + a.y +
twiceBit (R.output.value a.bits a.bits) = 0
abel
· change a.flags + R.flags.value a.bits a.bits + a.flags + R.flags.value a.bits a.bits = 0
calc
_ = (a.flags + a.flags) + (R.flags.value a.bits a.bits + R.flags.value a.bits a.bits) := by abel
_ = 0 := by simp only [bits_add_self, add_zero]
end RSGPaper.EIGAmbientLabel
end
section
set_option autoImplicit false
namespace RSGPaper.EIGBinaryAddress
def number : (n : ℕ) → (Fin n → Bool) → ℕ
| 0, _ => 0
| n + 1, bits => (bits 0).toNat + 2 * number n (fun i => bits i.succ)
end RSGPaper.EIGBinaryAddress
end
section
set_option autoImplicit false
namespace RSGPaper.EIGSiteChecks
open EIGAmbientLabel
def fromBool (b : Bool) : Bit := if b then 1 else 0
end RSGPaper.EIGSiteChecks
end
section
set_option autoImplicit false
namespace RSGPaper.ChartTransporters
open RSGRecognition
theorem add_self {A : Type} [AddCommGroup A] [Module (ZMod 2) A] (a : A) : a + a = 0 := by
have two : (2 : ZMod 2) = 0 := by decide
rw [← two_smul (ZMod 2), two, zero_smul]
theorem add_cancel_right {A : Type} [AddCommGroup A] [Module (ZMod 2) A] (a b : A) :
a + b + b = a := by rw [add_assoc, add_self, add_zero]
section Relation
variable {A : Type} [AddCommGroup A] [Module (ZMod 2) A]
end Relation
variable {d r : ℕ}
def chartAction (a : Pos d) (f : Profile d r) : Equiv.Perm (Pos d × Lab r) where
toFun p := (p.1 + a, p.2 + f p.1)
invFun p := (p.1 + a, p.2 + f (p.1 + a))
left_inv p := by
change (p.1 + a + a, p.2 + f p.1 + f (p.1 + a + a)) = p
rw [add_cancel_right, add_cancel_right]
right_inv p := by
change (p.1 + a + a, p.2 + f (p.1 + a) + f (p.1 + a)) = p
rw [add_cancel_right, add_cancel_right]
def perm {V : Type} (ch : BinaryChart V) (a : Pos ch.d) (f : Profile ch.d ch.r) : Equiv.Perm V :=
ch.coord.trans ((chartAction a f).trans ch.coord.symm)
@[simp] theorem coords {V : Type} (ch : BinaryChart V) (a : Pos ch.d) (f : Profile ch.d ch.r) (x : V) :
ch.coord (perm ch a f x) = ((ch.coord x).1 + a, (ch.coord x).2 + f (ch.coord x).1) := by
change ch.coord (ch.coord.symm _) = _
rw [Equiv.apply_symm_apply]
rfl
end RSGPaper.ChartTransporters
end
section
set_option autoImplicit false
namespace RSGPaper.ChartActions
open RSGRecognition
open ChartTransporters
variable {V : Type} (ch : BinaryChart V)
def shiftProfile (a : Pos ch.d) (f : Profile ch.d ch.r) : Profile ch.d ch.r := fun x => f (x + a)
theorem comp (a b : Pos ch.d) (f g : Profile ch.d ch.r) :
perm ch a f * perm ch b g = perm ch (a + b) (g + shiftProfile ch b f) := by
apply Equiv.ext
intro x
apply ch.coord.injective
change ch.coord (perm ch a f (perm ch b g x)) = _
rw [coords, coords, coords]
apply Prod.ext
· change (ch.coord x).1 + b + a = (ch.coord x).1 + (a + b)
rw [add_assoc, add_comm b a]
· change (ch.coord x).2 + g (ch.coord x).1 + f ((ch.coord x).1 + b) =
(ch.coord x).2 + (g (ch.coord x).1 + f ((ch.coord x).1 + b))
rw [add_assoc]
theorem identity : perm ch 0 0 = 1 := by
apply Equiv.ext
intro x
apply ch.coord.injective
rw [coords]
simp
theorem inverse (a : Pos ch.d) (f : Profile ch.d ch.r) :
(perm ch a f)⁻¹ = perm ch a (shiftProfile ch a f) := by
have one : perm ch a f * perm ch a (shiftProfile ch a f) = 1 := by
rw [comp, add_self, add_self, identity]
calc
_ = (perm ch a f)⁻¹ * (perm ch a f * perm ch a (shiftProfile ch a f)) := by rw [one, mul_one]
_ = _ := by rw [← mul_assoc, inv_mul_cancel, one_mul]
end RSGPaper.ChartActions
end
section
set_option autoImplicit false
namespace RSGPaper.ChartParser
open RSGRecognition
open OAI.MetricKMedian.Binary.Automatic
open QMCNumericRuntime (parser_drop_poly parser_take_poly)
theorem unary_prefix (n : ℕ) (rest : Word) :
unary (List.replicate n true ++ [false] ++ rest) = n := by
unfold unary
induction n with
| zero => rfl
| succ n ih =>
have smaller : (List.replicate n true ++ false :: rest).findIdx (!·) = n := by
simpa only [List.append_assoc, List.singleton_append] using ih
simp [List.replicate_succ, List.findIdx_cons, smaller]
theorem payload_prefix (n : ℕ) (rest : Word) :
payload (List.replicate n true ++ [false] ++ rest) = rest := by
rw [payload, unary_prefix]
have width : (List.replicate n true ++ [false]).length = n + 1 := by simp
rw [← width, List.drop_left]
theorem split_frame (bits rest : Word) : split (frame bits ++ rest) = (bits, rest) := by
have len : unary (frame bits ++ rest) = bits.length := by
simpa only [frame, List.append_assoc] using unary_prefix bits.length (bits ++ rest)
have body : payload (frame bits ++ rest) = bits ++ rest := by
unfold frame
simpa only [List.append_assoc] using payload_prefix bits.length (bits ++ rest)
simp only [split, len, body, List.take_left, List.drop_left]
theorem parse_correct {n : ℕ} (G : SimpleGraph (Fin n)) (adj : DecidableRel G.Adj) (ch : BinaryChart (Fin n)) :
parse (chartInstanceWord G adj ch) =
(n, ch.d, ch.r, (List.ofFn fun i : Fin n => List.ofFn fun j : Fin n => @decide (G.Adj i j) (adj i j)).flatten,
(List.ofFn fun i : Fin n => bitsOf (ch.coord i).1 ++ bitsOf (ch.coord i).2).flatten) := by
unfold parse chartInstanceWord
rw [split_frame]
dsimp only
have graphSize : unary (graphWord G adj) = n := unary_prefix _ _
have graphData : payload (graphWord G adj) = (List.ofFn fun i : Fin n =>
List.ofFn fun j : Fin n => @decide (G.Adj i j) (adj i j)).flatten := payload_prefix _ _
have chartShape : chartWord ch = List.replicate ch.d true ++ [false] ++
(List.replicate ch.r true ++ [false] ++
(List.ofFn fun i : Fin n => bitsOf (ch.coord i).1 ++ bitsOf (ch.coord i).2).flatten) := by
simp only [chartWord, List.append_assoc]
rw [graphSize, graphData, chartShape, unary_prefix, payload_prefix, unary_prefix, payload_prefix]
end RSGPaper.ChartParser
end
section
set_option autoImplicit false
namespace RSGPaper.ChartTime
open RSGRecognition
theorem chart_card {n : ℕ} (ch : BinaryChart (Fin n)) : n = 2 ^ (ch.d + ch.r) := by
have card := Fintype.card_congr ch.coord
simpa [Fintype.card_prod, Fintype.card_fun, pow_add] using card
end RSGPaper.ChartTime
end
section
set_option autoImplicit false
namespace RSGPaper.ChartNumericInput
open RSGRecognition
open ChartParser
open EIGNumericRuntime
open ChartTransporters
open OAI.MetricKMedian.Binary.Automatic
open OAI.MetricKMedian.Binary
open QMCNumericRuntime (parser_take_poly parser_drop_poly)
private theorem flat_length {α : Type} {n : ℕ} (rows : Fin n → List α) (k : ℕ) (width : ∀ i, (rows i).length = k) :
(List.ofFn rows).flatten.length = n * k := by
induction n with
| zero => simp
| succ n ih =>
rw [List.ofFn_succ, List.flatten_cons, List.length_append, width, ih _ (fun i => width i.succ), Nat.succ_mul, add_comm]
theorem input_length {n : ℕ} (G : SimpleGraph (Fin n)) (isAdj : DecidableRel G.Adj) (ch : BinaryChart (Fin n)) :
(chartInstanceWord G isAdj ch).length =
2 * (n + 1 + n * n) + 1 + (ch.d + ch.r + 2 + n * (ch.d + ch.r)) := by
unfold chartInstanceWord frame graphWord chartWord
simp only [List.length_append, List.length_replicate, List.length_singleton]
rw [flat_length _ n (by intro j; simp), flat_length _ (ch.d + ch.r) (by intro j; simp [RSGPaper.bitsOf])]
omega
theorem order_le_length {n : ℕ} (G : SimpleGraph (Fin n)) (isAdj : DecidableRel G.Adj) (ch : BinaryChart (Fin n)) :
n ≤ (chartInstanceWord G isAdj ch).length := by
rw [input_length]
omega
section Correct
variable {n : ℕ} (G : SimpleGraph (Fin n)) (isAdj : DecidableRel G.Adj) (ch : BinaryChart (Fin n))
local notation "data" => read (chartInstanceWord G isAdj ch)
def vectorCode {s : ℕ} (v : Fin s → ZMod 2) : ℕ :=
EIGBinaryAddress.number s (fun i => decide (v i = 1))
end Correct
end RSGPaper.ChartNumericInput
end
section
set_option autoImplicit false
namespace RSGPaper.TransporterDual
open RSGRecognition
open ChartTransporters
open ChartNumericInput
open NumericTransporters
open OAI.MetricKMedian.Binary.Automatic
open EIGAmbientLabel (Bit Bits)
open QMCNumericRuntime (parser_take_poly)
section Correct
variable {n : ℕ} (G : SimpleGraph (Fin n)) (isAdj : DecidableRel G.Adj) (ch : BinaryChart (Fin n))
local notation "data" => ChartNumericInput.read (chartInstanceWord G isAdj ch)
theorem labelFuel_width : (labelFuel data).length = ch.r := by
have rEq : r data = ch.r := by simp [r, ChartNumericInput.read, ChartParser.parse_correct]
have rle : ch.r ≤ (fuel data).length := by
have input := order_le_length G isAdj ch
have below := Nat.lt_two_pow_self (n := ch.r)
have count := ChartTime.chart_card ch
have total : 2 ^ ch.r ≤ 2 ^ (ch.d + ch.r) := Nat.pow_le_pow_right (by decide) (Nat.le_add_left _ _)
exact (below.le.trans (total.trans_eq count.symm)).trans input
simp [labelFuel, rEq, Nat.min_eq_left rle]
end Correct
end RSGPaper.TransporterDual
end
section
set_option autoImplicit false
namespace RSGPaper.ChartLiftFamilies
open RSGRecognition
open ChartTransporters
open ChartActions
variable {V : Type} (ch : BinaryChart V)
abbrev Profiles := Profile ch.d ch.r
structure Closed (D : Submodule (ZMod 2) (Profiles ch)) (lift : Pos ch.d → Profiles ch) : Prop where
invariant : ∀ a (f : Profiles ch), f ∈ D → shiftProfile ch a f ∈ D
zero : lift 0 ∈ D
mul : ∀ a b, lift b + shiftProfile ch b (lift a) + lift (a + b) ∈ D
theorem shift_add (a : Pos ch.d) (f g : Profiles ch) :
shiftProfile ch a (f + g) = shiftProfile ch a f + shiftProfile ch a g := rfl
theorem mem_add_fixed {D : Submodule (ZMod 2) (Profiles ch)} {f g : Profiles ch}
(inside : g ∈ D) : f + g ∈ D ↔ f ∈ D := by
constructor
· intro h
have both := D.add_mem h inside
rwa [add_cancel_right] at both
· exact fun h => D.add_mem h inside
theorem closed_under_mul {D : Submodule (ZMod 2) (Profiles ch)} {lift : Pos ch.d → Profiles ch}
(laws : Closed ch D lift) {a b : Pos ch.d} {f g : Profiles ch}
(fg : f + lift a ∈ D) (gg : g + lift b ∈ D) :
(g + shiftProfile ch b f) + lift (a + b) ∈ D := by
have shifted := laws.invariant b _ fg
rw [shift_add] at shifted
have sum := D.add_mem (D.add_mem gg shifted) (laws.mul a b)
have identity : (g + lift b) + (shiftProfile ch b f + shiftProfile ch b (lift a)) +
(lift b + shiftProfile ch b (lift a) + lift (a + b)) =
((g + shiftProfile ch b f) + lift (a + b)) +
(lift b + lift b) + (shiftProfile ch b (lift a) + shiftProfile ch b (lift a)) := by abel
rwa [identity, add_self, add_self, add_zero, add_zero] at sum
theorem closed_under_inv {D : Submodule (ZMod 2) (Profiles ch)} {lift : Pos ch.d → Profiles ch}
(laws : Closed ch D lift) {a : Pos ch.d} {f : Profiles ch} (fg : f + lift a ∈ D) :
shiftProfile ch a f + lift a ∈ D := by
have shift := laws.invariant a _ fg
rw [shift_add] at shift
have self := laws.mul a a
rw [add_self a, mem_add_fixed ch laws.zero] at self
have sum := D.add_mem shift self
have identity : shiftProfile ch a f + shiftProfile ch a (lift a) +
(lift a + shiftProfile ch a (lift a)) =
(shiftProfile ch a f + lift a) + (shiftProfile ch a (lift a) + shiftProfile ch a (lift a)) := by abel
rwa [identity, add_self, add_zero] at sum
def support (D : Submodule (ZMod 2) (Profiles ch)) (lift : Pos ch.d → Profiles ch)
(laws : Closed ch D lift) : Subgroup (Equiv.Perm V) where
carrier := {g | ∃ a f, g = perm ch a f ∧ f + lift a ∈ D}
one_mem' := ⟨0, 0, (identity ch).symm, by simpa only [zero_add] using laws.zero⟩
mul_mem' := by
rintro _ _ ⟨a,f,rfl,fg⟩ ⟨b,g,rfl,gg⟩
exact ⟨a+b, g + shiftProfile ch b f, comp ch a b f g, closed_under_mul ch laws fg gg⟩
inv_mem' := by
rintro _ ⟨a,f,rfl,fg⟩
exact ⟨a, shiftProfile ch a f, inverse ch a f, closed_under_inv ch laws fg⟩
end RSGPaper.ChartLiftFamilies
end
section
set_option autoImplicit false
namespace RSGPaper.ChartZeroLabels
open RSGRecognition
open ChartTransporters
open ChartActions
variable {V : Type} (ch : BinaryChart V) (G : SimpleGraph V)
def direction (u v : V) : Pos ch.d := (ch.coord u).1 + (ch.coord v).1
end RSGPaper.ChartZeroLabels
end
section
set_option autoImplicit false
namespace RSGPaper.ChartTestSemantics
open RSGRecognition
open ChartTransporters
open ChartActions
open ChartLiftFamilies
variable {V : Type} (G : SimpleGraph V) (ch : BinaryChart V)
abbrev Kernel := Submodule (ZMod 2) (Profiles ch)
def EdgeTests (D : Kernel ch) (lift : Pos ch.d → Profiles ch) : Prop :=
∀ u v, G.Adj u v →
let a := ChartZeroLabels.direction ch u v
∃ f : Profiles ch, f + lift a ∈ D ∧ delta a f = 0 ∧
f (ch.coord u).1 = (ch.coord u).2 + (ch.coord v).2 ∧
f (ch.coord v).1 = (ch.coord v).2 + (ch.coord u).2 ∧
∀ g ∈ D, g (ch.coord u).1 = 0 → g (ch.coord v).1 = 0 → delta a g = 0
end RSGPaper.ChartTestSemantics
end
section
set_option autoImplicit false
namespace RSGPaper.ChartDirections
variable {V : Type} (G : SimpleGraph V) (ch : BinaryChart V)
def dirs : Set (Pos ch.d) :=
{a | ∃ u v, G.Adj u v ∧ (ch.coord v).1 = (ch.coord u).1 + a}
end RSGPaper.ChartDirections
end
section
set_option autoImplicit false
namespace RSGPaper.ChartCompleteness
open RSGRecognition
open ChartTransporters
open ChartActions
open ChartLiftFamilies
open ChartTestSemantics
variable {V : Type} (G : SimpleGraph V) (ch : BinaryChart V)
structure Candidate (D : Kernel ch) (lift : Pos ch.d → Profiles ch) where
laws : Closed ch D lift
automorphisms : support ch D lift laws ≤ GraphAut G
directionRank : ∀ a ≠ 0, a ∈ ChartDirections.dirs G ch →
Module.finrank (ZMod 2) (D.map (delta a)) ≤ ch.r
dimension : Module.finrank (ZMod 2) D ≤ (ch.d + 1) * ch.r
edges : EdgeTests G ch D lift
end RSGPaper.ChartCompleteness
end
section
set_option autoImplicit false
namespace RSGPaper.ChartFactors
open Module
abbrev Bit := ZMod 2
abbrev Space (n : ℕ) := Fin n → Bit
end RSGPaper.ChartFactors
end
section
set_option autoImplicit false
namespace RSGPaper.ChartModelSemantics
open ChartModelBits
open ChartFactors (Bit Space)
open EIGSiteChecks (fromBool)
open TransporterDual (labelFuel)
def matrixMap (rows cols : ℕ) (f : ℕ → ℕ → Bool) : Space cols →ₗ[Bit] Space rows :=
LinearMap.pi fun i => ∑ j : Fin cols, fromBool (f i.val j.val) • LinearMap.proj j
def actMap (q : Model) (j width : ℕ) : Space width →ₗ[Bit] Space width :=
let r := (labelFuel q.1).length
LinearMap.id +
(matrixMap width r (leftBit q j)).comp (matrixMap r width (rightBit q j))
def rootMap (q : Model) (width : ℕ) : Space width →ₗ[Bit] Space (labelFuel q.1).length :=
matrixMap (labelFuel q.1).length width (readBit q)
def foldMap (q : Model) (coeff m : ℕ) (indices : List ℕ)
(initial : Space m →ₗ[Bit] Space m) : Space m →ₗ[Bit] Space m :=
indices.foldl (fun old j => if coeff.testBit j then (actMap q j m).comp old else old) initial
def profileMap (q : Model) (p m : ℕ) : Space m →ₗ[Bit] Space (labelFuel q.1).length :=
(rootMap q m).comp
(foldMap q (coefficients q p) m (List.range (positionFuel q.1).length).reverse LinearMap.id)
end RSGPaper.ChartModelSemantics
end
section
set_option autoImplicit false
namespace RSGPaper.ChartLayout
open EIGAmbientLabel (Bit Bits)
def length (s r m n : ℕ) : ℕ := s * s * r + m + s * s * m + n * n * m
end RSGPaper.ChartLayout
end
section
set_option autoImplicit false
namespace RSGPaper.ChartLinearLifts
open RSGRecognition
open ChartTransporters
open ChartActions
open ChartLiftFamilies
open ChartTestSemantics
open ChartFactors
variable {V : Type} (G : SimpleGraph V) (ch : BinaryChart V)
def EdgeCenters (D : Kernel ch) : Prop :=
∀ u v, G.Adj u v → ∀ f ∈ D, f (ch.coord u).1 = 0 → f (ch.coord v).1 = 0 →
delta (ChartZeroLabels.direction ch u v) f = 0
end RSGPaper.ChartLinearLifts
end
section
set_option autoImplicit false
set_option maxHeartbeats 1800000
noncomputable section
namespace RSGPaper.ChartPackedSemantics
open RSGRecognition
open ChartFactors
open ChartNumericInput
open ChartModelBits
open ChartPackedLifts
open ChartTransporters
open ChartLiftFamilies
open ChartLinearLifts
open ChartLayout
open ChartModelSemantics
open OAI.MetricKMedian.Binary
def reindex {width dest : ℕ} (eq : width = dest) : Space width →ₗ[Bit] Space dest :=
LinearMap.pi fun j => LinearMap.proj (Fin.cast eq.symm j)
section Valid
variable {n : ℕ} (G : SimpleGraph (Fin n)) (isAdj : DecidableRel G.Adj) (ch : BinaryChart (Fin n)) (mask : ℕ)
local notation "data" => ChartNumericInput.read (chartInstanceWord G isAdj ch)
local notation "modelBits" => model data mask
local notation "sites" => (2 ^ ch.d)
local notation "rankWidth" => nkernel modelBits
local notation "N" => ChartLayout.length sites ch.r rankWidth n
theorem number_labels : nlabels modelBits = ch.r :=
TransporterDual.labelFuel_width G isAdj ch
def kernel : Space rankWidth →ₗ[Bit] Profiles ch :=
LinearMap.pi fun p =>
(reindex (number_labels G isAdj ch mask)).comp (profileMap modelBits (vectorCode p) rankWidth)
end Valid
end RSGPaper.ChartPackedSemantics
end
section
set_option autoImplicit false
namespace RSGPaper.ChartRoot
open RSGRecognition
open ChartTransporters
open ChartActions
open ChartLiftFamilies
open ChartTestSemantics
variable {V : Type} (G : SimpleGraph V) (ch : BinaryChart V)
def root : V := ch.coord.symm (0, 0)
def RootTest (D : Kernel ch) : Prop :=
∃ f ∈ D, f 0 = 0 ∧ ∀ v, G.Adj (root ch) v → f (ch.coord v).1 ≠ 0
end RSGPaper.ChartRoot
end
section
set_option autoImplicit false
set_option maxHeartbeats 1800000
namespace RSGPaper.ChartCheckerCorrect
open RSGRecognition
open ChartFactors
open ChartNumericInput
open ChartModelBits
open ChartPackedLifts
open ChartActions
open ChartTransporters
open ChartLiftFamilies
open ChartRoot
open ChartTestSemantics
open ChartLinearLifts
open ChartCompleteness
open ChartPackedSemantics
open ChartKernelChecks
section Valid
variable {n : ℕ} (G : SimpleGraph (Fin n)) (isAdj : DecidableRel G.Adj) (ch : BinaryChart (Fin n))
variable (full : Bool)
local notation "word" => chartInstanceWord G isAdj ch
local notation "data" => ChartNumericInput.read word
local notation "system" => HasChartSystem G ch (kind full)
def Captures (D : Kernel ch) : Prop :=
∃ mask < ChartBudget.cap word,
let modelBits := model data mask
modelBits.2.2 ≤ maxDim data ∧ (kernel G isAdj ch mask).range = D ∧
(full = true → rootWitness modelBits = true)
end Valid
end RSGPaper.ChartCheckerCorrect
end
Source
Sirawit Pongnakintr, Riemannian Symmetric Graphs, Hexagon preprint 2611.01261v2, https://hexagonmath.org/2611.01261v2, Theorem 5.3 and its proof.