Eight-marker and six-marker netlists with explicit time semantics
DefinitionLawsOfForm_ModulatorDefines NOR gates, both source circuit netlists, repeated simultaneous gate updates, samples after alternating held inputs, and complete tick traces. Gate numbering is documented in the source coverage map. Zero hold is a total-function boundary case; the theorem targets require hold at least four. No output wave, period or equilibrium is assumed by the definitions.
import Mathlib.Data.Bool.Basic
import Mathlib.Data.Fin.Basic
set_option autoImplicit false
namespace LawsOfForm
def nor2 (a b : Bool) : Bool := !(a || b)
def nor3 (a b c : Bool) : Bool := !(a || b || c)
def eightStep (a : Bool) (s : Fin 8 → Bool) : Fin 8 → Bool := fun i =>
match i.val with
| 0 => nor2 a (s 7)
| 1 => nor2 (s 0) (s 2)
| 2 => nor2 (s 0) (s 3)
| 3 => nor2 (s 2) (s 4)
| 4 => nor2 a (s 6)
| 5 => nor2 (s 4) (s 3)
| 6 => nor2 (s 1) (s 7)
| _ => nor2 (s 6) (s 5)
def sixStep (a : Bool) (s : Fin 6 → Bool) : Fin 6 → Bool := fun i =>
match i.val with
| 0 => nor3 (s 1) (s 2) (s 3)
| 1 => nor3 a (s 0) (s 2)
| 2 => nor3 a (s 1) (s 3)
| 3 => nor3 (s 1) (s 2) (s 5)
| 4 => nor3 (s 1) (s 3) (s 5)
| _ => nor3 (s 2) (s 3) (s 4)
def settle {n : Nat} (step : Bool → (Fin n → Bool) → Fin n → Bool)
(a : Bool) : Nat → (Fin n → Bool) → Fin n → Bool
| 0, s => s
| k + 1, s => step a (settle step a k s)
def sampledTrace {n : Nat} (step : Bool → (Fin n → Bool) → Fin n → Bool)
(hold : Nat) (initial : Fin n → Bool) : Nat → Fin n → Bool
| 0 => initial
| k + 1 => settle step (decide (k % 2 = 0)) hold (sampledTrace step hold initial k)
def tickTrace {n : Nat} (step : Bool → (Fin n → Bool) → Fin n → Bool)
(hold : Nat) (initial : Fin n → Bool) : Nat → Fin n → Bool
| 0 => initial
| t + 1 => step (decide ((t / hold) % 2 = 0)) (tickTrace step hold initial t)
end LawsOfForm
Read-back
What the Lean code literally says, in plain math · Codex (GPT-6)
LawsOfForm.nor2. For any two Boolean values , this definition returns the Boolean value , where is Boolean disjunction and is Boolean negation. Its output is exactly when both and are , and is for each of the other three input pairs.
LawsOfForm.nor3. For any three Boolean values , this definition returns the Boolean value , where is Boolean disjunction and is Boolean negation. Its output is exactly when all three inputs are , and is for every other input triple.
LawsOfForm.eightStep. For any Boolean input and any Boolean state indexed by the integers , this definition returns the Boolean state given by , , , , , , , and , with and denoting Boolean disjunction and negation. Every right-hand side uses the supplied state , so all eight outputs are computed from the same old state; none uses a newly computed output. The last equation applies exactly to index , because no index outside is available. Both Boolean choices of and every assignment of Boolean values to the eight state entries are allowed.
LawsOfForm.sixStep. For any Boolean input and any Boolean state indexed by the integers , this definition returns the Boolean state given by , , , , , and , with and denoting Boolean disjunction and negation. Every right-hand side uses the supplied state , so all six outputs are computed from the same old state; none uses a newly computed output. The last equation applies exactly to index , because no index outside is available. Both Boolean choices of and every assignment of Boolean values to the six state entries are allowed.
LawsOfForm.settle. For every natural number , including , let be the set of Boolean states indexed by the integers , and let be any supplied update function. For any fixed Boolean input , any natural number , and any initial state , this definition returns the state specified by and for every ; equivalently, for each , and . Thus zero iterations return the supplied state, and a positive iteration count applies exactly that many times, always with the same input , first computing the preceding whole state and then applying to it. The update function has no additional hypotheses, and the definition neither tests for nor requires an unchanged state. When , the index set is empty, has exactly one state, and every iteration returns that empty state.
LawsOfForm.sampledTrace. For every natural number , including , let be the set of Boolean states indexed by , and let be any supplied update function. For any natural number supplied as the hold count and any initial state , this definition gives a state at each natural time , starting with . To obtain from for any , set if the natural remainder is , and set otherwise; starting from , compute for every integer , and set . These are equations of whole states, or equivalently , , , and for every . Each time increment therefore performs exactly successive applications with a fixed Boolean input: the transition from time to time uses , the transition from time to time uses , and the input continues alternating according to the parity of the departure time . If , no application of is performed at any transition and at every natural time. If , every time has the unique empty state. No further conditions are imposed on , , or the initial state.
LawsOfForm.tickTrace. For every natural number , including , let be the set of Boolean states indexed by , and let be any supplied update function. For any natural number supplied as the hold count and any initial state , this definition gives a state at each natural time , with and for every , where exactly when and otherwise. Here is natural-number division and is natural-number remainder; natural-number division by zero has value . For each , the equations are and : each time increment applies exactly once to the entire previous state, using an input determined by the departure time . If , then ; for each natural number , the input is at departure times and at departure times . In particular, the transition from time to time uses . If , then for every natural time , and the definition still applies once on every transition, always with that input. If , every time has the unique empty state. No further conditions are imposed on , , or the initial state.