Semantic invariants of the inductive-counting controller #
The sets in this file are ghost state used in the proofs. They are not part of the controller's registers. A scan selects distinct identifiers because its candidate register increases; equality of its selected count with the round count then forces exhaustiveness.
Main definitions #
Cslib.InductiveCounting.Graph: the graph restricted to the vertex interval.Cslib.InductiveCounting.roundSet: the finite set represented by a round count.Cslib.InductiveCounting.Invariant: the semantic assertion at each instruction.
References #
theorem Cslib.InductiveCounting.reachable_lt {N source u : ℕ} {edge : ℕ → ℕ → Bool} (hsource : source < N) (h : Relation.ReflTransGen (Graph N edge) source u) :
theorem Cslib.InductiveCounting.within_lt {N source k u : ℕ} {edge : ℕ → ℕ → Bool} (hsource : source < N) (h : Relation.RelatesWithinSteps (Graph N edge) source u k) :
@[simp]
def Cslib.InductiveCounting.ScanPrefix (N : ℕ) (edge : ℕ → ℕ → Bool) (bad : ℕ → Bool) (source : ℕ) (s : State) :
The selected identifiers form a subset of the processed prefix. The ghost set S is not
stored by the algorithm. Omissions are allowed here and detected by the final count check.
Instances For
theorem Cslib.InductiveCounting.scanPrefix_skip {N source : ℕ} {edge : ℕ → ℕ → Bool} {bad : ℕ → Bool} {s : State} (h : ScanPrefix N edge bad source s) :
ScanPrefix N edge bad source
{ phase := s.phase, round := s.round, count := s.count, target := s.target, nextCount := s.nextCount,
candidate := s.candidate + 1, selected := s.selected, remaining := s.remaining, current := s.current,
guess := s.guess, bits := s.bits, hit := s.hit, finalScan := s.finalScan }
theorem Cslib.InductiveCounting.scanPrefix_observe {N width source : ℕ} {edge : ℕ → ℕ → Bool} {bad : ℕ → Bool} {s : State} {choice : Bool} (h : ScanPrefix N edge bad source s) (hu : s.candidate ∈ roundSet N edge source s.round) (hp : s.phase = Phase.observe) :
ScanPrefix N edge bad source (instruction N width source s (answer edge bad s) choice)
theorem Cslib.InductiveCounting.scan_final_safe {N source : ℕ} {edge : ℕ → ℕ → Bool} {bad : ℕ → Bool} {s : State} (hsource : source < N) (hc : RoundCorrect N edge source s) (hp : ScanPrefix N edge bad source s) (he : s.selected = s.count) (hf : s.finalScan = true) (hk : s.round + 1 = N) (hh : s.hit = false) :
Safe N source edge bad
theorem Cslib.InductiveCounting.invariant_instruction {N width source : ℕ} {edge : ℕ → ℕ → Bool} {bad : ℕ → Bool} {s : State} (hsource : source < N) (h : Invariant N edge bad source s) (choice : Bool) :
Invariant N edge bad source (instruction N width source s (answer edge bad s) choice)
Every underlying instruction preserves the semantic assertion. A rejected branch has no proof obligation; dishonest omissions can survive temporarily but cannot pass a count check.