def
definition
ringSeq
show as:
view math explainer →
open explainer
Read the cached plain-language explainer.
open lean source
IndisputableMonolith.Masses.Ribbons on GitHub at line 58.
browse module
All declarations in this module, on Recognition.
explainer page
depends on
formal source
55abbrev Word := List Ribbon
56
57/-- Deterministic ring pattern for a given tag: spread across ticks, alternate direction. -/
58def ringSeq (tag : GaugeTag) (n : Nat) : Word :=
59 (List.range n).map (fun k =>
60 let t : Tick := ⟨k % 8, by have : (k % 8) < 8 := Nat.mod_lt _ (by decide); simpa using this⟩
61 let d := k % 2 = 0
62 { start := t, dir := d, bit := 1, tag := tag })
63
64/-- One left‑to‑right cancellation pass: drop the first adjacent cancelling pair if present. -/
65def rewriteOnce : Word → Word :=
66 fun w =>
67 match w with
68 | [] => []
69 | a :: [] => [a]
70 | a :: b :: rest =>
71 if cancels a b then rest else a :: rewriteOnce (b :: rest)
72
73/-- Normalization via bounded passes: at most length passes strictly reduce on success. -/
74def normalForm (w : Word) : Word :=
75 let rec normalize (current : Word) (passes : Nat) : Word :=
76 if passes = 0 then current
77 else
78 let next := rewriteOnce current
79 if next.length = current.length then current
80 else normalize next (passes - 1)
81 normalize w w.length
82
83/-- Reduced length ℓ(W) as length of the normal form. -/
84@[simp] def ell (w : Word) : Nat := (normalForm w).length
85
86/-- Net winding on the eight‑tick clock (abstracted): +1 for dir, −1 otherwise. -/
87noncomputable def winding (w : Word) : Int :=
88 (w.map (fun r => if r.dir then (1 : Int) else (-1 : Int))).foldl (·+·) 0