Contents
- Tangle drawings
- The same tangle
- Stacking drawings respects the moves
- The category of tangles, 𝒯
- Cells: a tangle between two rows of yarn and loops
- Well-formedness of drawings
- Checkable move chains for
Iso - Shifted moves; a flip slides through a block exchange
- Moves keep drawings well formed
- A crossing passes a word that does not touch its strands
- Two standard moves derived from
Mv
Tangle drawings
- A drawing (
MWord) is a list of events (Gen). Read it from bottom to top. Each height has one event. - At each height, the strands have the numbers
0, 1, …from the left. - An event is a crossing (
cross), a cup (cup) or a cap (cap). - An event fits a row of
wstrands when the strands that it uses exist. topWidth b u: the number of strands at the top ofu, frombstrands at the bottom.nonewhen an event does not fit.WF b t u:ugoes frombstrands totstrands.shiftW,swapBlocks,mirrorAux,reverseCrossings: operations on drawings. The shorthand builds the stitch insides with them (knitInterior,splitInteriorK).
inductive Gen where
| cross (i : Nat) (lo : Bool)
| cup (i : Nat)
| cap (i : Nat)
deriving DecidableEq, Reprcross 0 true. The strand from the left is in front.cross 0 false. The strand from the right is in front.cup 0. Two strands start.cap 0. Two strands join and stop.abbrev MWord := List Gen
namespace Gen
def fits : Gen → Nat → Bool
| cross i _, w => decide (i + 1 < w)
| cup i, w => decide (i ≤ w)
| cap i, w => decide (i + 1 < w)
def widthAfter : Gen → Nat → Nat
| cross .., w => w
| cup _, w => w + 2
| cap _, w => w - 2
def lo : Gen → Nat
| cross i _ => i
| cup i => i
| cap i => i
def ins : Gen → Nat
| cross .. => 2
| cup _ => 0
| cap _ => 2
def outs : Gen → Nat
| cross .. => 2
| cup _ => 2
| cap _ => 0
def withLo : Gen → Nat → Gen
| cross _ s, j => cross j s
| cup _, j => cup j
| cap _, j => cap j
def isCup : Gen → Bool
| cup _ => true
| _ => false
def isCap : Gen → Bool
| cap _ => true
| _ => false
def shift (k : Nat) : Gen → Gen
| cross i lo => cross (i + k) lo
| cup i => cup (i + k)
| cap i => cap (i + k)
end Gen
def topWidth : Nat → MWord → Option Nat
| w, [] => some w
| w, g :: gs => if g.fits w then topWidth (g.widthAfter w) gs else none
def WF (b t : Nat) (u : MWord) : Prop := topWidth b u = some t
instance (b t : Nat) (u : MWord) : Decidable (WF b t u) := by unfold WF; infer_instanceOperations on drawings
def shiftW (k : Nat) (u : MWord) : MWord := u.map (Gen.shift k)
def swapBlocks (at_ left right : Nat) (lo : Bool) : MWord :=
(List.range right).flatMap fun moved =>
(List.range left).map fun step1 => Gen.cross (at_ + left - 1 - step1 + moved) lo
def mirrorAux : Nat → MWord → MWord
| _, [] => []
| w, g :: gs =>
let g' := match g with
| Gen.cross i lo => Gen.cross (w - 2 - i) (!lo)
| Gen.cup i => Gen.cup (w - i)
| Gen.cap i => Gen.cap (w - 2 - i)
g' :: mirrorAux (g.widthAfter w) gs
def reverseCrossings (u : MWord) : MWord :=
u.map fun
| Gen.cross i lo => Gen.cross i (!lo)
| g => g The same tangle
Mv: the 14 moves. Each move replaces a piecelhsof a drawing withrhs. The rest of the drawing does not change. A move applies in the two directions.- Move groups: far commutation, zig-zag, cup and cap slides, R1 (on a strand, at a cup, at a cap), R2, R3 with three crossings of one sign.
Step1 b u v: one move changesuintov. The two drawings are well formed frombstrands.Iso b u v: a finite chain of moves changesuintov.Isois a relation on drawings. The Reidemeister theorem for drawings of this form makesIsoequal to isotopy rel boundary. Lean does not contain that theorem.- Two relations of the published lists are not in
Mv: the rotation of a crossing and the pitchfork (a cup or a cap that slides through one strand). Mvhas R3 only with three crossings of one sign.- The rotation of a crossing and R3 with mixed signs are proved from
Mv:rotR,rotL,r3Mixed. - This package does not prove the pitchfork from
Mv.
inductive Mv where
| farR (g h : Gen)
| farL (g h : Gen)
| zigR (i : Nat)
| zigL (i : Nat)
| cupSlideR (i : Nat) (s : Bool)
| cupSlideL (i : Nat) (s : Bool)
| capSlideR (i : Nat) (s : Bool)
| capSlideL (i : Nat) (s : Bool)
| r1R (i : Nat) (s : Bool)
| r1L (i : Nat) (s : Bool)
| r1cup (i : Nat) (s : Bool)
| r1cap (i : Nat) (s : Bool)
| r2 (i : Nat) (s : Bool)
| r3 (i : Nat) (s : Bool)
deriving DecidableEq, Repr
namespace Mv
open Gen
def lhs : Mv → MWord
| farR g h => [g, h]
| farL g h => [g, h]
| zigR i => [cup (i + 1), cap i]
| zigL i => [cup i, cap (i + 1)]
| cupSlideR i s => [cup (i + 1), cross i s, cross (i + 1) s]
| cupSlideL i s => [cup i, cross (i + 1) s, cross i s]
| capSlideR i s => [cross i s, cross (i + 1) s, cap i]
| capSlideL i s => [cross (i + 1) s, cross i s, cap (i + 1)]
| r1R i s => [cup (i + 1), cross i s, cap (i + 1)]
| r1L i s => [cup i, cross (i + 1) s, cap i]
| r1cup i s => [cup i, cross i s]
| r1cap i s => [cross i s, cap i]
| r2 i s => [cross i s, cross i (!s)]
| r3 i s => [cross i s, cross (i + 1) s, cross i s]
def rhs : Mv → MWord
| farR g h => [h.withLo (h.lo - g.outs + g.ins), g]
| farL g h => [h, g.withLo (g.lo + h.outs - h.ins)]
| zigR _ => []
| zigL _ => []
| cupSlideR i _ => [cup i]
| cupSlideL i _ => [cup (i + 1)]
| capSlideR i _ => [cap (i + 1)]
| capSlideL i _ => [cap i]
| r1R .. => []
| r1L .. => []
| r1cup i _ => [cup i]
| r1cap i _ => [cap i]
| r2 .. => []
| r3 i s => [cross (i + 1) s, cross i s, cross (i + 1) s]
def ok : Mv → Bool
| farR g h => decide (g.lo + g.outs ≤ h.lo)
| farL g h => decide (h.lo + h.ins ≤ g.lo)
| _ => true
end MvOne instance of each move: at strand 0, with the strand from the right in front. Left side ↔ right side.
Far commutation
farRfarLZig-zag
zigRzigLCup and cap slides
cupSlideRcupSlideLcapSlideRcapSlideLR1
r1Rr1Lr1cupr1capR2 and R3
r2r3def Step1 (b : Nat) (u v : MWord) : Prop :=
(topWidth b u).isSome ∧ (topWidth b v).isSome ∧
∃ (p q : MWord) (m : Mv), m.ok = true ∧ u = p ++ m.lhs ++ q ∧ v = p ++ m.rhs ++ q
def Iso (b : Nat) : MWord → MWord → Prop := Relation.EqvGen (Step1 b)theorem Iso.refl (b : Nat) (u : MWord) : Iso b u uProof
:= Relation.EqvGen.refl u theorem Iso.symm {b : Nat} {u v : MWord} (h : Iso b u v) : Iso b v uProof
:= Relation.EqvGen.symm _ _ h theorem Iso.trans {b : Nat} {u v w : MWord} (h₁ : Iso b u v) (h₂ : Iso b v w) : Iso b u wProof
:=
Relation.EqvGen.trans _ _ _ h₁ h₂ Stacking drawings respects the moves
topWidth_append,topWidth_append_of: the top width of two stacked drawings.Iso.topWidth_eq: related drawings have the same top width.Iso.prefix,Iso.suffix: a move chain stays valid with a drawing added below or above.
theorem topWidth_append (a : Nat) (u v : MWord) :
topWidth a (u ++ v) = (topWidth a u).bind (fun c => topWidth c v)Proof
:= by
induction u generalizing a with
| nil => simp [topWidth]
| cons g gs ih =>
simp only [List.cons_append, topWidth]
split <;> simp_all theorem topWidth_append_of {a b c : Nat} {u v : MWord} (hu : topWidth a u = some b)
(hv : topWidth b v = some c) : topWidth a (u ++ v) = some cProof
:= by
rw [topWidth_append, hu]; exact hv Related drawings have the same top width
def nCups (u : MWord) : Nat := (u.filter Gen.isCup).length
def nCaps (u : MWord) : Nat := (u.filter Gen.isCap).lengththeorem nCups_append (u v : MWord) : nCups (u ++ v) = nCups u + nCups vProof
:= by
simp [nCups, List.filter_append] theorem nCaps_append (u v : MWord) : nCaps (u ++ v) = nCaps u + nCaps vProof
:= by
simp [nCaps, List.filter_append] theorem topWidth_count {w c : Nat} {u : MWord} (h : topWidth w u = some c) :
c + 2 * nCaps u = w + 2 * nCups uProof
:= by
induction u generalizing w with
| nil => simp_all [topWidth, nCups, nCaps]
| cons g gs ih =>
simp only [topWidth] at h
split at h
· rename_i hf
have := ih h
cases g <;> simp_all [nCups, nCaps, Gen.isCup, Gen.isCap, Gen.widthAfter, Gen.fits, List.filter_cons] <;>
omega
· exact absurd h (by simp) theorem Gen.isCup_withLo (g : Gen) (j : Nat) : (g.withLo j).isCup = g.isCupProof
:= by cases g <;> rfl theorem Gen.isCap_withLo (g : Gen) (j : Nat) : (g.withLo j).isCap = g.isCapProof
:= by cases g <;> rfl theorem Mv.counts (m : Mv) : nCups m.lhs + nCaps m.rhs = nCups m.rhs + nCaps m.lhsProof
:= by
cases m with
| farR g h =>
simp only [Mv.lhs, Mv.rhs, nCups, nCaps, List.filter_cons, Gen.isCup_withLo, Gen.isCap_withLo]
split <;> split <;> split <;> split <;> simp_all
| farL g h =>
simp only [Mv.lhs, Mv.rhs, nCups, nCaps, List.filter_cons, Gen.isCup_withLo, Gen.isCap_withLo]
split <;> split <;> split <;> split <;> simp_all
| _ => simp [Mv.lhs, Mv.rhs, nCups, nCaps, Gen.isCup, Gen.isCap, List.filter_cons] theorem Step1.topWidth_eq {b : Nat} {u v : MWord} (h : Step1 b u v) : topWidth b u = topWidth b vProof
:= by
obtain ⟨hu, hv, p, q, m, -, rfl, rfl⟩ := h
obtain ⟨cu, hcu⟩ := Option.isSome_iff_exists.mp hu
obtain ⟨cv, hcv⟩ := Option.isSome_iff_exists.mp hv
have e1 := topWidth_count hcu
have e2 := topWidth_count hcv
have h1 := m.counts
simp only [nCups_append, nCaps_append] at e1 e2
rw [hcu, hcv]
congr 1
omega theorem Iso.topWidth_eq {b : Nat} {u v : MWord} (h : Iso b u v) : topWidth b u = topWidth b vProof
:= by
induction h with
| rel _ _ h => exact h.topWidth_eq
| refl => rfl
| symm _ _ _ ih => exact ih.symm
| trans _ _ _ _ _ ih1 ih2 => exact ih1.trans ih2 Congruence
theorem Step1.prefix {b c : Nat} {P u v : MWord} (hP : topWidth b P = some c) (h : Step1 c u v) :
Step1 b (P ++ u) (P ++ v)Proof
:= by
obtain ⟨hu, hv, p, q, m, hok, rfl, rfl⟩ := h
refine ⟨?_, ?_, P ++ p, q, m, hok, by simp, by simp⟩
· rw [topWidth_append, hP]; exact hu
· rw [topWidth_append, hP]; exact hv theorem Iso.prefix {b c : Nat} {P u v : MWord} (hP : topWidth b P = some c) (h : Iso c u v) :
Iso b (P ++ u) (P ++ v)Proof
:= by
induction h with
| rel _ _ h => exact Relation.EqvGen.rel _ _ (h.prefix hP)
| refl => exact Iso.refl _ _
| symm _ _ _ ih => exact ih.symm
| trans _ _ _ _ _ ih1 ih2 => exact ih1.trans ih2 theorem topWidth_append_congr {b : Nat} {u v : MWord} (Q : MWord) (h : topWidth b u = topWidth b v) :
topWidth b (u ++ Q) = topWidth b (v ++ Q)Proof
:= by
rw [topWidth_append, topWidth_append, h] theorem Step1.suffix {b : Nat} {u v : MWord} (Q : MWord) (h : Step1 b u v) (hQ : (topWidth b (u ++ Q)).isSome) :
Step1 b (u ++ Q) (v ++ Q)Proof
:= by
have he := topWidth_append_congr Q h.topWidth_eq
obtain ⟨-, -, p, q, m, hok, rfl, rfl⟩ := h
exact ⟨hQ, he ▸ hQ, p, q ++ Q, m, hok, by simp, by simp⟩ theorem Iso.suffix {b : Nat} {u v : MWord} (Q : MWord) (h : Iso b u v) (hQ : (topWidth b (u ++ Q)).isSome) :
Iso b (u ++ Q) (v ++ Q)Proof
:= by
induction h with
| rel x y h => exact Relation.EqvGen.rel _ _ (h.suffix Q hQ)
| refl => exact Iso.refl _ _
| symm x y hxy ih =>
have he := topWidth_append_congr Q (Iso.topWidth_eq hxy)
exact (ih (he ▸ hQ)).symm
| trans x y z hxy _ ih1 ih2 =>
have he := topWidth_append_congr Q (Iso.topWidth_eq hxy)
exact (ih1 hQ).trans (ih2 (he ▸ hQ)) The category of tangles, 𝒯
| Part | Definition |
|---|---|
| Objects | TangleObj: a number of strand ends |
Arrows m ⟶ n |
Tangle m n: well-formed drawings from m to n strands, quotient by Iso m |
| Composition | Stacking: u below, v above, u ++ v |
Identity on m |
The empty drawing |
iso_append_congr: stacking respectsIso. The proof usesIso.prefixandIso.suffix.- The category laws are the laws of list concatenation.
open CategoryTheory
@[ext]
structure TangleObj where
strands : Nat
deriving DecidableEq, Repr
abbrev Drawing (m n : Nat) : Type := {u : MWord // WF m n u}
instance drawingSetoid (m n : Nat) : Setoid (Drawing m n) where
r a b := Iso m a.1 b.1
iseqv := ⟨fun a => Iso.refl m a.1, Iso.symm, Iso.trans⟩
def Tangle (m n : Nat) : Type := Quotient (drawingSetoid m n)
def Tangle.mk {m n : Nat} (u : MWord) (h : WF m n u) : Tangle m n := Quotient.mk _ ⟨u, h⟩theorem Tangle.mk_eq_mk {m n : Nat} {u v : MWord} (hu : WF m n u) (hv : WF m n v) :
Tangle.mk u hu = Tangle.mk v hv ↔ Iso m u vProof
:=
Quotient.eq (r := drawingSetoid m n) theorem Tangle.mk_congr {m n : Nat} {u v : MWord} (hu : WF m n u) (hv : WF m n v) (h : u = v) :
Tangle.mk u hu = Tangle.mk v hvProof
:= by
subst h; rfl theorem Tangle.ind {m n : Nat} {P : Tangle m n → Prop} (h : ∀ u hu, P (Tangle.mk u hu)) (t : Tangle m n) : P tProof
:=
Quotient.inductionOn t fun a => h a.1 a.2 theorem iso_append_congr {m n k : Nat} {u u' v v' : MWord} (hv' : WF n k v')
(hu : Iso m u u') (hv : WF m n u) (hvv : Iso n v v') : Iso m (u ++ v) (u' ++ v')Proof
:=
(Iso.prefix hv hvv).trans
(Iso.suffix v' hu (by rw [topWidth_append_of hv hv']; rfl)) def Tangle.comp {m n k : Nat} : Tangle m n → Tangle n k → Tangle m k :=
Quotient.lift₂ (s₁ := drawingSetoid m n) (s₂ := drawingSetoid n k)
(fun a b => Tangle.mk (a.1 ++ b.1) (topWidth_append_of a.2 b.2))
(fun a _ _ b' ha hb => (Tangle.mk_eq_mk _ _).2 (iso_append_congr b'.2 ha a.2 hb))@[simp] theorem Tangle.mk_comp_mk {m n k : Nat} {u v : MWord} (hu : WF m n u) (hv : WF n k v) :
Tangle.comp (Tangle.mk u hu) (Tangle.mk v hv) = Tangle.mk (u ++ v) (topWidth_append_of hu hv)Proof
:= rfl def Tangle.id (m : Nat) : Tangle m m := Tangle.mk [] rfltheorem Tangle.id_comp {m n : Nat} (f : Tangle m n) : Tangle.comp (Tangle.id m) f = fProof
:= by
induction f using Tangle.ind with
| h u hu => rfl theorem Tangle.comp_id {m n : Nat} (f : Tangle m n) : Tangle.comp f (Tangle.id n) = fProof
:= by
induction f using Tangle.ind with
| h u hu =>
show Tangle.mk (u ++ []) _ = Tangle.mk u hu
exact Tangle.mk_congr _ _ (List.append_nil u) theorem Tangle.assoc {m n k l : Nat} (f : Tangle m n) (g : Tangle n k) (h : Tangle k l) :
Tangle.comp (Tangle.comp f g) h = Tangle.comp f (Tangle.comp g h)Proof
:= by
induction f using Tangle.ind with
| h u hu =>
induction g using Tangle.ind with
| h v hv =>
induction h using Tangle.ind with
| h w hw =>
simp only [Tangle.mk_comp_mk]; exact Tangle.mk_congr _ _ (List.append_assoc u v w) instance : SmallCategory TangleObj where
Hom X Y := Tangle X.strands Y.strands
id X := Tangle.id X.strands
comp f g := Tangle.comp f g
id_comp := Tangle.id_comp
comp_id := Tangle.comp_id
assoc := Tangle.assoc
def TangleObj.hom {m n : Nat} (u : MWord) (h : WF m n u) : (⟨m⟩ : TangleObj) ⟶ ⟨n⟩ := Tangle.mk u htheorem TangleObj.hom_eq_hom {m n : Nat} {u v : MWord} (hu : WF m n u) (hv : WF m n v) :
TangleObj.hom u hu = TangleObj.hom v hv ↔ Iso m u vProof
:=
Tangle.mk_eq_mk hu hv theorem TangleObj.hom_comp {m n k : Nat} {u v : MWord} (hu : WF m n u) (hv : WF n k v) :
TangleObj.hom u hu ≫ TangleObj.hom v hv = TangleObj.hom (u ++ v) (topWidth_append_of hu hv)Proof
:= rfl theorem TangleObj.id_eq (m : Nat) : 𝟙 (⟨m⟩ : TangleObj) = TangleObj.hom [] rflProof
:= rfl Cells: a tangle between two rows of yarn and loops
- A cell is one hand stitch: a bottom row, a top row and a drawing.
- A row (
CellRow), from left to right, holds the yarn (one strand) and single loops (two strands, one for each leg). Cellhas no conditions on its parts.Cell.Valid: each row holds exactly one yarn, and the drawing goes from the strands of the bottom row to the strands of the top row (CellWF).Cell.Validdoes not make a cell a known stitch.
inductive CellObj where
| yarn
| loop
deriving DecidableEq, Repr
abbrev CellRow := List CellObj
def CellObj.width : CellObj → Nat
| .yarn => 1
| .loop => 2
def cellRowWidth (r : CellRow) : Nat := (r.map CellObj.width).sum
structure Cell where
bot : CellRow
top : CellRow
word : MWord
deriving DecidableEq, Repr
def CellWF (c : Cell) : Prop := WF (cellRowWidth c.bot) (cellRowWidth c.top) c.word
instance (c : Cell) : Decidable (CellWF c) := by unfold CellWF; infer_instance
def Cell.Valid (c : Cell) : Prop := c.bot.count .yarn = 1 ∧ c.top.count .yarn = 1 ∧ CellWF c
instance (c : Cell) : Decidable c.Valid := by unfold Cell.Valid; infer_instance
def cellYarnIdx (r : CellRow) : Nat := r.idxOf .yarn Well-formedness of drawings
topWidth lemmas for Morse words. The stitch insides are well formed.
| Theorem | Statement |
|---|---|
topWidth_shift |
A word from a to c strands, moved i right, goes from i + a + e to i + c + e strands |
topWidth_crosses, swapBlocks_wf |
A word of crossings that fit keeps the number of strands |
mirror_wf, reverseCrossings_wf |
A mirror image and a word with all crossings changed keep the top width |
pullThrough_wf |
pullThrough n goes from 2n + 1 strands to 3 strands |
tuckInterior_wf |
tuckInterior d goes from 1 strand to 3 strands |
splitInterior_wf |
splitInterior d bd goes from 3 strands to 5 strands |
knitInterior_wf |
knitInterior d bd k goes from 2k + 1 strands to 3 strands |
The well-formedness of shorthand programs is runStep_wf and D_wf.
Morse-word lemmas
theorem topWidth_cons_fits {w : Nat} {g : Gen} {gs : MWord} (hf : g.fits w = true) :
topWidth w (g :: gs) = topWidth (g.widthAfter w) gsProof
:= by
simp [topWidth, hf] theorem fits_of_topWidth {w c : Nat} {g : Gen} {gs : MWord} (h : topWidth w (g :: gs) = some c) :
g.fits w = true ∧ topWidth (g.widthAfter w) gs = some cProof
:= by
simp only [topWidth] at h
split at h
· exact ⟨‹_›, h⟩
· exact absurd h (by simp) theorem topWidth_shift {a c : Nat} {u : MWord} (h : topWidth a u = some c) (i e : Nat) :
topWidth (i + a + e) (shiftW i u) = some (i + c + e)Proof
:= by
induction u generalizing a with
| nil => simp_all [topWidth, shiftW]
| cons g gs ih =>
obtain ⟨hf, h'⟩ := fits_of_topWidth h
have := ih h'
show topWidth (i + a + e) (g.shift i :: shiftW i gs) = some (i + c + e)
cases g with
| cross k lo =>
simp only [Gen.fits, decide_eq_true_eq] at hf
rw [topWidth_cons_fits (by simp [Gen.shift, Gen.fits]; omega)]
simpa [Gen.widthAfter, Gen.shift] using this
| cup k =>
simp only [Gen.fits, decide_eq_true_eq] at hf
rw [topWidth_cons_fits (by simp [Gen.shift, Gen.fits]; omega)]
simp only [Gen.widthAfter, Gen.shift] at this ⊢
rw [show i + a + e + 2 = i + (a + 2) + e by omega]; exact this
| cap k =>
simp only [Gen.fits, decide_eq_true_eq] at hf
rw [topWidth_cons_fits (by simp [Gen.shift, Gen.fits]; omega)]
simp only [Gen.widthAfter, Gen.shift] at this ⊢
rw [show i + a + e - 2 = i + (a - 2) + e by omega]; exact this theorem topWidth_crosses {w : Nat} {u : MWord}
(h : ∀ g ∈ u, ∃ k s, g = Gen.cross k s ∧ k + 1 < w) : topWidth w u = some wProof
:= by
induction u with
| nil => rfl
| cons g gs ih =>
obtain ⟨k, s, rfl, hk⟩ := h g (by simp)
rw [topWidth_cons_fits (by simp [Gen.fits]; omega)]
exact ih fun g hg => h g (by simp [hg]) theorem swapBlocks_wf {at_ left right w : Nat} (lo : Bool) (h : at_ + left + right ≤ w) :
topWidth w (swapBlocks at_ left right lo) = some wProof
:= by
apply topWidth_crosses
intro g hg
simp only [swapBlocks, List.mem_flatMap, List.mem_range, List.mem_map] at hg
obtain ⟨moved, hm, step1, hs, rfl⟩ := hg
exact ⟨_, _, rfl, by omega⟩ theorem topWidth_flatMap_keep {w : Nat} {α : Type} (l : List α) (f : α → MWord)
(h : ∀ x ∈ l, topWidth w (f x) = some w) : topWidth w (l.flatMap f) = some wProof
:= by
induction l with
| nil => rfl
| cons x xs ih =>
rw [List.flatMap_cons]
exact topWidth_append_of (h x (by simp)) (ih fun y hy => h y (by simp [hy])) theorem mirror_wf {w c : Nat} {u : MWord} (h : topWidth w u = some c) :
topWidth w (mirrorAux w u) = some cProof
:= by
induction u generalizing w with
| nil => simpa [mirrorAux, topWidth] using h
| cons g gs ih =>
obtain ⟨hf, h'⟩ := fits_of_topWidth h
have := ih h'
cases g with
| cross k lo =>
simp only [Gen.fits, decide_eq_true_eq] at hf
simp only [mirrorAux]
rw [topWidth_cons_fits (by simp [Gen.fits]; omega)]
exact this
| cup k =>
simp only [Gen.fits, decide_eq_true_eq] at hf
simp only [mirrorAux]
rw [topWidth_cons_fits (by simp [Gen.fits])]
exact this
| cap k =>
simp only [Gen.fits, decide_eq_true_eq] at hf
simp only [mirrorAux]
rw [topWidth_cons_fits (by simp [Gen.fits]; omega)]
exact this theorem reverseCrossings_wf (w : Nat) (u : MWord) : topWidth w (reverseCrossings u) = topWidth w uProof
:= by
induction u generalizing w with
| nil => rfl
| cons g gs ih =>
cases g <;> simp [reverseCrossings, topWidth, Gen.fits, Gen.widthAfter] at ih ⊢ <;> simp [ih] Box interiors
theorem pullThrough_tail_wf (j : Nat) :
topWidth (2 * j + 3) ((List.range j).reverse.flatMap fun j =>
[Gen.cross j false, Gen.cross (j + 1) false, Gen.cap (j + 2)]) = some 3Proof
:= by
induction j with
| zero => rfl
| succ j ih =>
rw [List.range_succ, List.reverse_append, List.reverse_singleton, List.singleton_append,
List.flatMap_cons]
refine topWidth_append_of ?_ ih
rw [topWidth_cons_fits (by simp [Gen.fits]; omega)]
rw [topWidth_cons_fits (by simp [Gen.fits, Gen.widthAfter]; omega)]
rw [topWidth_cons_fits (by simp [Gen.fits, Gen.widthAfter]; omega)]
simp only [topWidth, Gen.widthAfter, Option.some.injEq]
omega theorem pullThrough_wf (n : Nat) : topWidth (2 * n + 1) (pullThrough n) = some 3Proof
:= by
unfold pullThrough
have h1 : topWidth (2 * n + 1) ((List.range n).map fun k => Gen.cross k false) = some (2 * n + 1) := by
apply topWidth_crosses
intro g hg
simp only [List.mem_map, List.mem_range] at hg
obtain ⟨k, hk, rfl⟩ := hg
exact ⟨_, _, rfl, by omega⟩
have h2 : topWidth (2 * n + 1) [Gen.cup (n + 1)] = some (2 * n + 3) := by
rw [topWidth_cons_fits (by simp [Gen.fits]; omega)]
rfl
have h3 : topWidth (2 * n + 3) ((List.range n).map fun k => Gen.cross (n + 2 + k) false) =
some (2 * n + 3) := by
apply topWidth_crosses
intro g hg
simp only [List.mem_map, List.mem_range] at hg
obtain ⟨k, hk, rfl⟩ := hg
exact ⟨_, _, rfl, by omega⟩
exact topWidth_append_of (topWidth_append_of (topWidth_append_of h1 h2) h3) (pullThrough_tail_wf n) theorem knitInterior_wf (d : Dir) (bd : Bed) (k : Nat) :
topWidth (2 * k + 1) (knitInterior d bd k) = some 3Proof
:= by
unfold knitInterior
refine topWidth_append_of (topWidth_flatMap_keep _ _ ?_) ?_
· intro i hi
rw [List.mem_range] at hi
apply swapBlocks_wf
split <;> omega
· have hb : topWidth (2 * k + 1) (if bd = .f then pullThrough k else reverseCrossings (pullThrough k)) =
some 3 := by
split
· exact pullThrough_wf k
· rw [reverseCrossings_wf]; exact pullThrough_wf k
split
· exact hb
· exact mirror_wf hb theorem splitInterior_wf (d : Dir) (bd : Bed) : topWidth 3 (splitInterior d bd) = some 5Proof
:= by
cases d <;> cases bd <;> rfl theorem tuckInterior_wf (d : Dir) : topWidth 1 (tuckInterior d) = some 3Proof
:= by
cases d <;> rfl Rows
theorem cellRowWidth_append (r s : CellRow) : cellRowWidth (r ++ s) = cellRowWidth r + cellRowWidth sProof
:= by
simp [cellRowWidth] theorem cellRowWidth_cons (o : CellObj) (r : CellRow) : cellRowWidth (o :: r) = o.width + cellRowWidth rProof
:= by
simp [cellRowWidth] Checkable move chains for Iso
A Boolean checker for chains of moves. Its soundness and completeness for Iso.
| Declaration | Content |
|---|---|
applyAt |
Replace the piece x at position k of a word with y |
applyCert |
Apply one certificate step (k, m, fwd) |
checkChain |
Check a list of certificate steps from u to v |
iso_of_checkChain |
A checked chain gives Iso b u v (soundness) |
checkChain_reverse |
A checked chain can be run backwards |
iso_iff_chain |
Iso b u v holds exactly when a checked chain exists |
Isoand the movesMvare defined with the tangle drawings (Mv,Step1,Iso).Isois the move relation. It is not isotopy. The Reidemeister theorem for drawings in Morse position relates the two. Lean does not contain that theorem.- The relation is unframed: R1 is a move.
- The rotation of a crossing and R3 with mixed signs are not moves in
Mv. They are proved fromMv:rotR,rotL,r3Mixed. - The pitchfork (a cup or a cap that slides through one strand) is not a move in
Mv. This package does not prove it fromMv.
Checkable move chains
A certificate step (k, m, fwd) rewrites the word at position k. If fwd, it replaces m.lhs with m.rhs.
Else it replaces m.rhs with m.lhs. Each word of the chain must be well formed.
def applyAt (u : MWord) (k : Nat) (x y : MWord) : Option MWord :=
if k ≤ u.length ∧ (u.drop k).take x.length = x then some (u.take k ++ y ++ u.drop (k + x.length)) else none
def applyCert (u : MWord) : Nat × Mv × Bool → Option MWord
| (k, m, true) => if m.ok then applyAt u k m.lhs m.rhs else none
| (k, m, false) => if m.ok then applyAt u k m.rhs m.lhs else none
def checkChain (b : Nat) : MWord → List (Nat × Mv × Bool) → MWord → Bool
| u, [], v => decide (u = v)
| u, c :: cs, v =>
match applyCert u c with
| none => false
| some u' => (topWidth b u).isSome && (topWidth b u').isSome && checkChain b u' cs vtheorem applyAt_spec {u : MWord} {k : Nat} {x y w : MWord} (h : applyAt u k x y = some w) :
u = u.take k ++ x ++ u.drop (k + x.length) ∧ w = u.take k ++ y ++ u.drop (k + x.length)Proof
:= by
unfold applyAt at h
split at h
· rename_i hx
obtain ⟨-, hx⟩ := hx
refine ⟨?_, (Option.some.inj h).symm⟩
conv_lhs => rw [← List.take_append_drop k u]
rw [List.append_assoc]
congr 1
conv_lhs => rw [← List.take_append_drop x.length (u.drop k)]
rw [hx, List.drop_drop, Nat.add_comm]
· exact absurd h (by simp) theorem step_of_applyCert {b : Nat} {u w : MWord} {c : Nat × Mv × Bool}
(hu : (topWidth b u).isSome) (hw : (topWidth b w).isSome) (h : applyCert u c = some w) :
Iso b u wProof
:= by
obtain ⟨k, m, fwd⟩ := c
cases fwd with
| true =>
simp only [applyCert] at h
split at h
· rename_i hok
obtain ⟨h1, h2⟩ := applyAt_spec h
exact Relation.EqvGen.rel _ _ ⟨hu, hw, _, _, m, hok, h1, h2⟩
· exact absurd h (by simp)
| false =>
simp only [applyCert] at h
split at h
· rename_i hok
obtain ⟨h1, h2⟩ := applyAt_spec h
exact Relation.EqvGen.symm _ _ (Relation.EqvGen.rel _ _ ⟨hw, hu, _, _, m, hok, h2, h1⟩)
· exact absurd h (by simp) theorem iso_of_checkChain {b : Nat} :
∀ (u : MWord) (cs : List (Nat × Mv × Bool)) (v : MWord), checkChain b u cs v = true → Iso b u vProof
| u, [], v, h => by
simp only [checkChain, decide_eq_true_eq] at h
exact h ▸ Iso.refl b u
| u, c :: cs, v, h => by
simp only [checkChain] at h
split at h
· exact absurd h (by simp)
· rename_i u' hc
simp only [Bool.and_eq_true] at h
obtain ⟨⟨hu, hu'⟩, hrest⟩ := h
exact (step_of_applyCert hu hu' hc).trans (iso_of_checkChain u' cs v hrest) Iso is exactly "a checked chain exists"
iso_iff_chain: Iso b u v ↔ ∃ cs, checkChain b u cs v = true. checkChain is a total Boolean function.
theorem applyAt_of_eq (p x y q : MWord) :
applyAt (p ++ x ++ q) p.length x y = some (p ++ y ++ q)Proof
:= by
unfold applyAt
have h0 : p.length ≤ (p ++ x ++ q).length := by simp
have h1 : ((p ++ x ++ q).drop p.length).take x.length = x := by simp
have h2 : (p ++ x ++ q).take p.length = p := by simp
have h3 : (p ++ x ++ q).drop (p.length + x.length) = q := by
rw [show p.length + x.length = (p ++ x).length from (List.length_append ..).symm]
simp
rw [ite_eq_left ⟨h0, h1⟩, h2, h3] theorem applyAt_inv {u w : MWord} {k : Nat} {x y : MWord} (h : applyAt u k x y = some w) :
applyAt w k y x = some uProof
:= by
obtain ⟨hu, hw⟩ := applyAt_spec h
have hk : (u.take k).length = k := by
unfold applyAt at h
split at h
· rename_i hx
simp only [List.length_take]
omega
· exact absurd h (by simp)
rw [hw]
conv_rhs => rw [hu]
have := applyAt_of_eq (u.take k) y x (u.drop (k + x.length))
rw [hk] at this
exact this theorem checkChain_append {b : Nat} :
∀ (u : MWord) (cs₁ : List (Nat × Mv × Bool)) (v : MWord) (cs₂ : List (Nat × Mv × Bool)) (w : MWord),
checkChain b u cs₁ v = true → checkChain b v cs₂ w = true → checkChain b u (cs₁ ++ cs₂) w = trueProof
| u, [], v, cs₂, w, h₁, h₂ => by
simp only [checkChain, decide_eq_true_eq] at h₁
subst h₁; simpa using h₂
| u, c :: cs, v, cs₂, w, h₁, h₂ => by
simp only [checkChain] at h₁
split at h₁
· exact absurd h₁ (by simp)
· rename_i u' hc
simp only [Bool.and_eq_true] at h₁
obtain ⟨⟨hu, hu'⟩, hrest⟩ := h₁
simp only [List.cons_append, checkChain, hc, hu, hu', Bool.true_and]
exact checkChain_append u' cs v cs₂ w hrest h₂ theorem applyCert_inv {u w : MWord} {k : Nat} {m : Mv} {d : Bool} (h : applyCert u (k, m, d) = some w) :
applyCert w (k, m, !d) = some uProof
:= by
cases d with
| true =>
simp only [applyCert] at h ⊢
split at h
· rename_i hok; simp only [Bool.not_true, hok, ite_true]; exact applyAt_inv h
· exact absurd h (by simp)
| false =>
simp only [applyCert] at h ⊢
split at h
· rename_i hok; simp only [Bool.not_false, hok, ite_true]; exact applyAt_inv h
· exact absurd h (by simp) theorem checkChain_reverse {b : Nat} :
∀ (u : MWord) (cs : List (Nat × Mv × Bool)) (v : MWord), checkChain b u cs v = true →
∃ cs', checkChain b v cs' u = trueProof
| u, [], v, h => by
simp only [checkChain, decide_eq_true_eq] at h
exact ⟨[], by simp [checkChain, h]⟩
| u, ⟨k, m, d⟩ :: cs, v, h => by
simp only [checkChain] at h
split at h
· exact absurd h (by simp)
· rename_i u' hc
simp only [Bool.and_eq_true] at h
obtain ⟨⟨hu, hu'⟩, hrest⟩ := h
obtain ⟨cs', hcs'⟩ := checkChain_reverse u' cs v hrest
refine ⟨cs' ++ [(k, m, !d)], checkChain_append v cs' u' [(k, m, !d)] u hcs' ?_⟩
simp [checkChain, applyCert_inv hc, hu, hu'] theorem checkChain_of_step1 {b : Nat} {u v : MWord} (h : Step1 b u v) : ∃ cs, checkChain b u cs v = trueProof
:= by
obtain ⟨hu, hv, p, q, m, hok, rfl, rfl⟩ := h
refine ⟨[(p.length, m, true)], ?_⟩
have ha := applyAt_of_eq p m.lhs m.rhs q
simp only [checkChain, applyCert, hok, ite_true, ha, hu, hv, Bool.true_and, decide_true] theorem iso_iff_chain {b : Nat} {u v : MWord} : Iso b u v ↔ ∃ cs, checkChain b u cs v = trueProof
:= by
constructor
· intro h
induction h with
| rel _ _ h => exact checkChain_of_step1 h
| refl x => exact ⟨[], by simp [checkChain]⟩
| symm x y _ ih =>
obtain ⟨cs, hcs⟩ := ih
exact checkChain_reverse x cs y hcs
| trans x y z _ _ ih₁ ih₂ =>
obtain ⟨cs₁, h₁⟩ := ih₁
obtain ⟨cs₂, h₂⟩ := ih₂
exact ⟨cs₁ ++ cs₂, checkChain_append x cs₁ y cs₂ z h₁ h₂⟩
· rintro ⟨cs, hcs⟩
exact iso_of_checkChain u cs v hcs Shifted moves; a flip slides through a block exchange
Moves stay moves when strands are added on each side. A flip of a loop slides through a block exchange.
| Declaration | Content |
|---|---|
Mv.shift |
A move moved k strands to the right |
Step1.shift, Iso.shift |
A relation on b strands holds on k + b + e strands, with the words moved k to the right |
flipSlide_LY, flipSlide_YL |
A flip of a loop slides through an exchange of that loop with the yarn |
flipSlide_LLleft, flipSlide_LLright |
A flip of a loop slides through an exchange of two loops |
flipSlide_*_at |
The same four statements at each position k, with e strands on the right |
- A flip of a loop: one crossing of its two legs.
- A block exchange:
swapBlocks. Each crossing has the same signf. - The four
flipSlide_*theorems hold for both exchange signsfand both flip signss. Each proof is an explicit chain of moves at the smallest width.
def Mv.shift (k : Nat) : Mv → Mv
| farR g h => farR (g.shift k) (h.shift k)
| farL g h => farL (g.shift k) (h.shift k)
| zigR i => zigR (i + k)
| zigL i => zigL (i + k)
| cupSlideR i s => cupSlideR (i + k) s
| cupSlideL i s => cupSlideL (i + k) s
| capSlideR i s => capSlideR (i + k) s
| capSlideL i s => capSlideL (i + k) s
| r1R i s => r1R (i + k) s
| r1L i s => r1L (i + k) s
| r1cup i s => r1cup (i + k) s
| r1cap i s => r1cap (i + k) s
| r2 i s => r2 (i + k) s
| r3 i s => r3 (i + k) stheorem Gen.shift_lo (g : Gen) (k : Nat) : (g.shift k).lo = g.lo + kProof
:= by cases g <;> rfl theorem Gen.shift_ins (g : Gen) (k : Nat) : (g.shift k).ins = g.insProof
:= by cases g <;> rfl theorem Gen.shift_outs (g : Gen) (k : Nat) : (g.shift k).outs = g.outsProof
:= by cases g <;> rfl theorem Gen.withLo_shift (g : Gen) (j k : Nat) : (g.shift k).withLo j = g.withLo jProof
:= by cases g <;> rfl theorem Gen.shift_withLo (g : Gen) (j k : Nat) : (g.withLo j).shift k = g.withLo (j + k)Proof
:= by cases g <;> rfl theorem Mv.shift_ok (m : Mv) (k : Nat) (h : m.ok = true) : (m.shift k).ok = trueProof
:= by
cases m <;> simp_all [Mv.ok, Mv.shift, Gen.shift_lo, Gen.shift_ins, Gen.shift_outs] <;> omega theorem Mv.shift_lhs (m : Mv) (k : Nat) : (m.shift k).lhs = shiftW k m.lhsProof
:= by
cases m <;> simp [Mv.shift, Mv.lhs, shiftW, Gen.shift] <;> omega theorem Mv.shift_rhs (m : Mv) (k : Nat) (h : m.ok = true) : (m.shift k).rhs = shiftW k m.rhsProof
:= by
cases m with
| farR g h' =>
simp only [Mv.ok, decide_eq_true_eq] at h
simp only [Mv.shift, Mv.rhs, shiftW, List.map_cons, List.map_nil, Gen.shift_lo, Gen.shift_ins,
Gen.shift_outs, Gen.withLo_shift, Gen.shift_withLo]
congr 2; omega
| farL g h' =>
simp only [Mv.ok, decide_eq_true_eq] at h
simp only [Mv.shift, Mv.rhs, shiftW, List.map_cons, List.map_nil, Gen.shift_lo, Gen.shift_ins,
Gen.shift_outs, Gen.withLo_shift, Gen.shift_withLo]
rw [show g.lo + k + h'.outs - h'.ins = g.lo + h'.outs - h'.ins + k by omega]
| cupSlideL _ _ | capSlideR _ _ | r3 _ _ => simp [Mv.shift, Mv.rhs, shiftW, Gen.shift]; omega
| _ => simp [Mv.shift, Mv.rhs, shiftW, Gen.shift] theorem Step1.shift {b : Nat} {u v : MWord} (h : Step1 b u v) (k e : Nat) :
Step1 (k + b + e) (shiftW k u) (shiftW k v)Proof
:= by
obtain ⟨hu, hv, p, q, m, hok, rfl, rfl⟩ := h
obtain ⟨cu, hcu⟩ := Option.isSome_iff_exists.mp hu
obtain ⟨cv, hcv⟩ := Option.isSome_iff_exists.mp hv
refine ⟨by rw [topWidth_shift hcu]; rfl, by rw [topWidth_shift hcv]; rfl, shiftW k p, shiftW k q, m.shift k,
m.shift_ok k hok, ?_, ?_⟩
· simp [shiftW, Mv.shift_lhs]
· simp [shiftW, Mv.shift_rhs m k hok] theorem Iso.shift {b : Nat} {u v : MWord} (h : Iso b u v) (k e : Nat) :
Iso (k + b + e) (shiftW k u) (shiftW k v)Proof
:= by
induction h with
| rel _ _ h => exact Relation.EqvGen.rel _ _ (h.shift k e)
| refl => exact Iso.refl _ _
| symm _ _ _ ih => exact ih.symm
| trans _ _ _ _ _ ih1 ih2 => exact ih1.trans ih2 theorem shiftW_append (k : Nat) (u v : MWord) : shiftW k (u ++ v) = shiftW k u ++ shiftW k vProof
:= by
simp [shiftW] theorem shiftW_singleton (k : Nat) (g : Gen) : shiftW k [g] = [g.shift k]Proof
:= rfl theorem shiftW_swapBlocks (k a l r : Nat) (f : Bool) :
shiftW k (swapBlocks a l r f) = swapBlocks (a + k) l r fProof
:= by
simp only [shiftW, swapBlocks, List.map_flatMap, List.map_map]
apply List.flatMap_congr
intro mv _
apply List.map_congr_left
intro st hst
rw [List.mem_range] at hst
simp only [Function.comp, Gen.shift]
congr 1; omega theorem flipSlide_LY (f s : Bool) :
Iso 3 ([Gen.cross 0 s] ++ swapBlocks 0 2 1 f) (swapBlocks 0 2 1 f ++ [Gen.cross 1 s])Proof
:= by
cases f <;> cases s
· exact iso_of_checkChain _ [(0, .r3 0 false, true)] _ (by decide)
· exact iso_of_checkChain _ [(3, .r2 1 false, false), (1, .r3 0 false, false), (0, .r2 0 true, true)] _ (by decide)
· exact iso_of_checkChain _ [(3, .r2 1 true, false), (1, .r3 0 true, false), (0, .r2 0 false, true)] _ (by decide)
· exact iso_of_checkChain _ [(0, .r3 0 true, true)] _ (by decide) theorem flipSlide_YL (f s : Bool) :
Iso 3 ([Gen.cross 1 s] ++ swapBlocks 0 1 2 f) (swapBlocks 0 1 2 f ++ [Gen.cross 0 s])Proof
:= by
cases f <;> cases s
· exact iso_of_checkChain _ [(0, .r3 0 false, false)] _ (by decide)
· exact iso_of_checkChain _ [(3, .r2 0 false, false), (1, .r3 0 false, true), (0, .r2 1 true, true)] _ (by decide)
· exact iso_of_checkChain _ [(3, .r2 0 true, false), (1, .r3 0 true, true), (0, .r2 1 false, true)] _ (by decide)
· exact iso_of_checkChain _ [(0, .r3 0 true, false)] _ (by decide) theorem flipSlide_LLleft (f s : Bool) :
Iso 4 ([Gen.cross 0 s] ++ swapBlocks 0 2 2 f) (swapBlocks 0 2 2 f ++ [Gen.cross 2 s])Proof
:= by
cases f <;> cases s
· exact iso_of_checkChain _ [(0, .r3 0 false, true), (2, .r3 1 false, true)] _ (by decide)
· exact iso_of_checkChain _ [(5, .r2 2 false, false), (3, .r3 1 false, false), (1, .r3 0 false, false), (0, .r2 0 true, true)] _ (by decide)
· exact iso_of_checkChain _ [(5, .r2 2 true, false), (3, .r3 1 true, false), (1, .r3 0 true, false), (0, .r2 0 false, true)] _ (by decide)
· exact iso_of_checkChain _ [(0, .r3 0 true, true), (2, .r3 1 true, true)] _ (by decide) theorem flipSlide_LLright (f s : Bool) :
Iso 4 ([Gen.cross 2 s] ++ swapBlocks 0 2 2 f) (swapBlocks 0 2 2 f ++ [Gen.cross 0 s])Proof
:= by
cases f <;> cases s
· exact iso_of_checkChain _ [(2, .farR (Gen.cross 0 false) (Gen.cross 2 false), true), (0, .r3 1 false, false), (2, .r3 0 false, false), (1, .farR (Gen.cross 0 false) (Gen.cross 2 false), false)] _ (by decide)
· exact iso_of_checkChain _ [(2, .farR (Gen.cross 0 false) (Gen.cross 2 false), true), (5, .r2 0 false, false), (3, .r3 0 false, true), (1, .r3 1 false, true), (0, .r2 2 true, true), (1, .farR (Gen.cross 0 false) (Gen.cross 2 false), false)] _ (by decide)
· exact iso_of_checkChain _ [(2, .farR (Gen.cross 0 true) (Gen.cross 2 true), true), (5, .r2 0 true, false), (3, .r3 0 true, true), (1, .r3 1 true, true), (0, .r2 2 false, true), (1, .farR (Gen.cross 0 true) (Gen.cross 2 true), false)] _ (by decide)
· exact iso_of_checkChain _ [(2, .farR (Gen.cross 0 true) (Gen.cross 2 true), true), (0, .r3 1 true, false), (2, .r3 0 true, false), (1, .farR (Gen.cross 0 true) (Gen.cross 2 true), false)] _ (by decide) theorem flipSlide_LY_at (k e : Nat) (f s : Bool) :
Iso (k + 3 + e) ([Gen.cross k s] ++ swapBlocks k 2 1 f) (swapBlocks k 2 1 f ++ [Gen.cross (k + 1) s])Proof
:= by
have := (flipSlide_LY f s).shift k e
simpa only [shiftW_append, shiftW_swapBlocks, shiftW_singleton, Gen.shift, Nat.zero_add, Nat.add_zero, Nat.add_comm] using this theorem flipSlide_YL_at (k e : Nat) (f s : Bool) :
Iso (k + 3 + e) ([Gen.cross (k + 1) s] ++ swapBlocks k 1 2 f) (swapBlocks k 1 2 f ++ [Gen.cross k s])Proof
:= by
have := (flipSlide_YL f s).shift k e
simpa only [shiftW_append, shiftW_swapBlocks, shiftW_singleton, Gen.shift, Nat.zero_add, Nat.add_zero, Nat.add_comm] using this theorem flipSlide_LLleft_at (k e : Nat) (f s : Bool) :
Iso (k + 4 + e) ([Gen.cross k s] ++ swapBlocks k 2 2 f) (swapBlocks k 2 2 f ++ [Gen.cross (k + 2) s])Proof
:= by
have := (flipSlide_LLleft f s).shift k e
simpa only [shiftW_append, shiftW_swapBlocks, shiftW_singleton, Gen.shift, Nat.zero_add, Nat.add_zero, Nat.add_comm] using this theorem flipSlide_LLright_at (k e : Nat) (f s : Bool) :
Iso (k + 4 + e) ([Gen.cross (k + 2) s] ++ swapBlocks k 2 2 f) (swapBlocks k 2 2 f ++ [Gen.cross k s])Proof
:= by
have := (flipSlide_LLright f s).shift k e
simpa only [shiftW_append, shiftW_swapBlocks, shiftW_singleton, Gen.shift, Nat.zero_add, Nat.add_zero, Nat.add_comm] using this theorem shiftW_zero (u : MWord) : shiftW 0 u = uProof
:= by
induction u with
| nil => rfl
| cons g gs ih => cases g <;> simp_all [shiftW, Gen.shift] theorem shiftW_shiftW (a b : Nat) (u : MWord) : shiftW a (shiftW b u) = shiftW (b + a) uProof
:= by
simp only [shiftW, List.map_map]
apply List.map_congr_left
intro g _
cases g <;> simp [Gen.shift] <;> omega Moves keep drawings well formed
A move applied left to right inside a well-formed word gives a well-formed word.
| Theorem | Statement |
|---|---|
Mv.wf_farR, Mv.wf_farL |
For far commutation, the left side fits w strands with top width c iff the right side does |
Mv.wf_fwd |
For each move, if the left side fits, the right side fits with the same top width |
Step1.of_wf |
A move applied left to right inside a well-formed word is a Step1 |
macro "finish_wf" : tactic => `(tactic| (
simp only [Option.ite_none_right_eq_some, Option.some.injEq, Gen.fits, decide_eq_true_eq]
omega))theorem Gen.withLo_lo (g : Gen) : g.withLo g.lo = gProof
:= by cases g <;> rfl theorem Mv.wf_farR (g h : Gen) (hok : (Mv.farR g h).ok = true) (w c : Nat) :
topWidth w (Mv.farR g h).lhs = some c ↔ topWidth w (Mv.farR g h).rhs = some cProof
:= by
simp only [Mv.ok, decide_eq_true_eq] at hok
cases g <;> cases h <;>
simp only [Mv.lhs, Mv.rhs, topWidth, Gen.widthAfter, Gen.lo, Gen.ins, Gen.outs, Gen.withLo] at hok ⊢ <;>
finish_wf theorem Mv.wf_farL (g h : Gen) (hok : (Mv.farL g h).ok = true) (w c : Nat) :
topWidth w (Mv.farL g h).lhs = some c ↔ topWidth w (Mv.farL g h).rhs = some cProof
:= by
simp only [Mv.ok, decide_eq_true_eq] at hok
cases g <;> cases h <;>
simp only [Mv.lhs, Mv.rhs, topWidth, Gen.widthAfter, Gen.lo, Gen.ins, Gen.outs, Gen.withLo] at hok ⊢ <;>
finish_wf theorem Mv.wf_fwd (m : Mv) (hok : m.ok = true) {w c : Nat} (h : topWidth w m.lhs = some c) :
topWidth w m.rhs = some cProof
:= by
cases m with
| farR g h' => exact (Mv.wf_farR g h' hok w c).mp h
| farL g h' => exact (Mv.wf_farL g h' hok w c).mp h
| _ =>
revert h
simp only [Mv.lhs, Mv.rhs, topWidth, Gen.widthAfter, Option.ite_none_right_eq_some, Option.some.injEq]
simp only [Gen.fits, decide_eq_true_eq]
simp only [Option.ite_none_right_eq_some, Option.some.injEq]
omega theorem Step1.of_wf {b c : Nat} {p q : MWord} {m : Mv} (hok : m.ok = true)
(h : topWidth b (p ++ m.lhs ++ q) = some c) : Step1 b (p ++ m.lhs ++ q) (p ++ m.rhs ++ q)Proof
:= by
refine ⟨by rw [h]; rfl, ?_, p, q, m, hok, rfl, rfl⟩
rw [topWidth_append, topWidth_append] at h ⊢
cases hp : topWidth b p with
| none => simp [hp] at h
| some x =>
simp only [hp, Option.bind_some] at h ⊢
cases hl : topWidth x m.lhs with
| none => simp [hl] at h
| some y =>
rw [Mv.wf_fwd m hok hl]
simp only [hl, Option.bind_some] at h
simp [h] A crossing passes a word that does not touch its strands
A crossing or a cup moves through a word that shares no strand with it. The result is an Iso.
| Declaration | Content |
|---|---|
passR |
The position after u of a crossing at p right of each generator of u, or none |
iso_pass_left |
A crossing at p, p+1, left of each generator of u, passes u. Its position does not change |
iso_pass_right |
A crossing right of each generator of u passes u. Its new position is passR |
passR_shift |
u from a to c strands, placed at k: a crossing at k + a + j passes to k + c + j |
cup_pass_left |
A cup at c above a word of crossings left of strand c moves below that word |
def passR : Nat → MWord → Option Nat
| p, [] => some p
| p, g :: gs => if g.lo + g.ins ≤ p then passR (p + g.outs - g.ins) gs else nonetheorem topWidth_cons_some {w c : Nat} {g : Gen} {gs : MWord} (h : topWidth w (g :: gs) = some c) :
g.fits w = true ∧ topWidth (g.widthAfter w) gs = some cProof
:= fits_of_topWidth h theorem iso_pass_right {b p : Nat} {s : Bool} :
∀ {u : MWord} {p' c : Nat}, passR p u = some p' → topWidth b (Gen.cross p s :: u) = some c →
Iso b (Gen.cross p s :: u) (u ++ [Gen.cross p' s])Proof
| [], p', c, h, _ => by
simp only [passR, Option.some.injEq] at h
subst h; exact Iso.refl _ _
| g :: gs, p', c, h, hw => by
simp only [passR] at h
split at h
· rename_i hg
have hok : (Mv.farL (Gen.cross p s) g).ok = true := decide_eq_true hg
have hw' : topWidth b ([] ++ (Mv.farL (Gen.cross p s) g).lhs ++ gs) = some c := by
simpa [Mv.lhs] using hw
have hstep := Step1.of_wf hok hw'
simp only [Mv.lhs, Mv.rhs, Gen.lo, Gen.withLo, List.nil_append, List.cons_append] at hstep
have hwr : topWidth b (g :: Gen.cross (p + g.outs - g.ins) s :: gs) = some c := by
have := (Mv.wf_farL (Gen.cross p s) g hok b c)
have h2 := Step1.topWidth_eq hstep
rw [← h2]; exact hw
obtain ⟨hf, hrest⟩ := topWidth_cons_some hwr
have ih := iso_pass_right (b := g.widthAfter b) h hrest
have hpre : Iso b ([g] ++ (Gen.cross (p + g.outs - g.ins) s :: gs)) ([g] ++ (gs ++ [Gen.cross p' s])) :=
Iso.prefix (by simp [topWidth, hf]) ih
exact Iso.trans (Relation.EqvGen.rel _ _ hstep) (by simpa using hpre)
· exact absurd h (by simp) theorem iso_pass_left {b p : Nat} {s : Bool} :
∀ {u : MWord} {c : Nat}, (∀ g ∈ u, p + 2 ≤ g.lo) → topWidth b (Gen.cross p s :: u) = some c →
Iso b (Gen.cross p s :: u) (u ++ [Gen.cross p s])Proof
| [], c, _, _ => Iso.refl _ _
| g :: gs, c, h, hw => by
have hg := h g (by simp)
have hok : (Mv.farR (Gen.cross p s) g).ok = true := decide_eq_true hg
have hw' : topWidth b ([] ++ (Mv.farR (Gen.cross p s) g).lhs ++ gs) = some c := by
simpa [Mv.lhs] using hw
have hstep := Step1.of_wf hok hw'
have hg' : g.withLo (g.lo - (Gen.cross p s).outs + (Gen.cross p s).ins) = g := by
simp only [Gen.outs, Gen.ins]
rw [show g.lo - 2 + 2 = g.lo by omega, Gen.withLo_lo]
simp only [Mv.lhs, Mv.rhs, hg', List.nil_append, List.cons_append] at hstep
have hwr : topWidth b (g :: Gen.cross p s :: gs) = some c := by
rw [← Step1.topWidth_eq hstep]; exact hw
obtain ⟨hf, hrest⟩ := topWidth_cons_some hwr
have ih := iso_pass_left (b := g.widthAfter b) (fun g' hg' => h g' (by simp [hg'])) hrest
have hpre : Iso b ([g] ++ (Gen.cross p s :: gs)) ([g] ++ (gs ++ [Gen.cross p s])) :=
Iso.prefix (by simp [topWidth, hf]) ih
exact Iso.trans (Relation.EqvGen.rel _ _ hstep) (by simpa using hpre) theorem passR_cons_of_le {p : Nat} {g : Gen} {gs : MWord} (h : g.lo + g.ins ≤ p) :
passR p (g :: gs) = passR (p + g.outs - g.ins) gsProof
:= by
simp [passR, h] theorem passR_shift {k j : Nat} : ∀ {u : MWord} {a c : Nat}, topWidth a u = some c →
passR (k + a + j) (shiftW k u) = some (k + c + j)Proof
| [], a, c, h => by
simp only [topWidth, Option.some.injEq] at h
subst h; rfl
| g :: gs, a, c, h => by
obtain ⟨hf, hrest⟩ := topWidth_cons_some h
have ih := passR_shift (k := k) (j := j) hrest
show passR (k + a + j) (g.shift k :: shiftW k gs) = some (k + c + j)
cases g with
| cross i lo =>
simp only [Gen.fits, decide_eq_true_eq] at hf
rw [passR_cons_of_le (by simp only [Gen.shift, Gen.lo, Gen.ins]; omega)]
simp only [Gen.shift, Gen.ins, Gen.outs, Gen.widthAfter] at ih ⊢
rw [show k + a + j + 2 - 2 = k + a + j by omega]; exact ih
| cup i =>
simp only [Gen.fits, decide_eq_true_eq] at hf
rw [passR_cons_of_le (by simp only [Gen.shift, Gen.lo, Gen.ins]; omega)]
simp only [Gen.shift, Gen.ins, Gen.outs, Gen.widthAfter] at ih ⊢
rw [show k + a + j + 2 - 0 = k + (a + 2) + j by omega]; exact ih
| cap i =>
simp only [Gen.fits, decide_eq_true_eq] at hf
rw [passR_cons_of_le (by simp only [Gen.shift, Gen.lo, Gen.ins]; omega)]
simp only [Gen.shift, Gen.ins, Gen.outs, Gen.widthAfter] at ih ⊢
rw [show k + a + j + 0 - 2 = k + (a - 2) + j by omega]; exact ih theorem shiftW_lo_ge {k : Nat} {u : MWord} : ∀ g ∈ shiftW k u, k ≤ g.loProof
:= by
intro g hg
simp only [shiftW, List.mem_map] at hg
obtain ⟨g₀, -, rfl⟩ := hg
cases g₀ <;> simp [Gen.shift, Gen.lo] section
open Gen
theorem cup_pass_left {b c : Nat} : ∀ {u : MWord}, (∀ g ∈ u, ∃ i s, g = cross i s ∧ i + 2 ≤ c) →
(topWidth b (u ++ [cup c])).isSome → Iso b (u ++ [cup c]) (cup c :: u)Proof
| [], _, _ => Iso.refl _ _
| g :: gs, h, hw => by
obtain ⟨i, s, rfl, hi⟩ := h g List.mem_cons_self
obtain ⟨cw, hcw⟩ := Option.isSome_iff_exists.mp hw
obtain ⟨hf, hrest⟩ := fits_of_topWidth (by simpa using hcw)
have ih := cup_pass_left (b := (cross i s).widthAfter b) (u := gs) (fun g hg => h g (by simp [hg]))
(by rw [hrest]; rfl)
have hpre : Iso b ([cross i s] ++ (gs ++ [cup c])) ([cross i s] ++ (cup c :: gs)) :=
Iso.prefix (by simp [topWidth, hf]) ih
have hok : (Mv.farR (cross i s) (cup c)).ok = true := by
simp only [Mv.ok, Gen.lo, Gen.outs]; exact decide_eq_true (by omega)
have hw2 : topWidth b ([] ++ (Mv.farR (cross i s) (cup c)).lhs ++ gs) = some cw := by
have e := Iso.topWidth_eq hpre
simp only [List.singleton_append] at e
simp only [Mv.lhs, List.nil_append, List.cons_append]
rw [← e]; simpa using hcw
have hstep := Step1.of_wf hok hw2
simp only [Mv.lhs, Mv.rhs, Gen.withLo, Gen.lo, Gen.outs, Gen.ins, List.nil_append] at hstep
rw [show c - 2 + 2 = c by omega] at hstep
exact (by simpa using hpre : Iso b (cross i s :: (gs ++ [cup c])) (cross i s :: cup c :: gs)).trans
(Relation.EqvGen.rel _ _ (by simpa using hstep)) Two standard moves derived from Mv
The rotation of a crossing and R3 with mixed signs are not moves in Mv. This file proves them as Iso
statements. They hold at each position i, on each number of strands b that holds them, for each sign.
| Theorem | Statement |
|---|---|
rotR |
[cup (i+2), cross (i+1) s, cap i] ~ [cross i (!s)] |
rotL |
[cup i, cross (i+1) s, cap (i+2)] ~ [cross i (!s)] |
rotR_iso_rotL |
[cup (i+2), cross (i+1) s, cap i] ~ [cup i, cross (i+1) s, cap (i+2)] |
r3Mixed |
[cross i s, cross (i+1) t, cross i u] ~ [cross (i+1) u, cross i t, cross (i+1) s] if t = s ∨ s ≠ u |
Iso.shiftTo |
A chain on w strands at position 0 holds at position i on b ≥ i + w strands |
Rotation of a crossing
- Two strands at
i, i + 1. A cup opens on one side. The far strand crosses a leg of the cup. A cap closes the near strand with that leg. - The result is one crossing of the two strands. The crossing changes sign.
rotLis the mirror image ofrotR. It is alsorotRread upside down.- The proof on two strands (
rotR0,rotL0) is a chain of four moves: R2, far commutation, cap slide, zig-zag.Iso.shiftTomoves it to positioni.
R3 with mixed signs
- Three strands
A, B, Cati, i+1, i+2.cross j true: the left strand is in front. - In the left word:
Ais overBiffs,Ais overCifft,Bis overCiffu. The right word has the same pairs. - The move is valid when one strand is over both other strands. The hypothesis
t = s ∨ s ≠ ugives the six valid patterns. - The two cyclic patterns
(s, t, u) = (true, false, true)and(false, true, false)are not R3 moves. (s, s, s)is the mover3. Each of the four mixed patterns is a chain of three moves: R2, R3 of one sign, R2.
open Gen
theorem Iso.shiftTo {w b i : Nat} {u v : MWord} (h : Iso w u v) (hb : i + w ≤ b) :
Iso b (shiftW i u) (shiftW i v)Proof
:= by
have := h.shift i (b - i - w)
rwa [show i + w + (b - i - w) = b by omega] at this theorem rotR0 (s : Bool) : Iso 2 [cup 2, cross 1 s, cap 0] [cross 0 (!s)]Proof
:=
iso_of_checkChain _
[(0, .r2 0 (!s), false), (1, .farR (cross 0 s) (cup 2), true), (2, .capSlideR 0 s, true), (1, .zigR 1, true)]
_ (by cases s <;> decide) theorem rotL0 (s : Bool) : Iso 2 [cup 0, cross 1 s, cap 2] [cross 0 (!s)]Proof
:=
iso_of_checkChain _
[(0, .r2 0 (!s), false), (1, .farL (cross 0 s) (cup 0), true), (2, .capSlideL 1 s, true), (1, .zigL 0, true)]
_ (by cases s <;> decide) theorem rotR {b i : Nat} (s : Bool) (hb : i + 2 ≤ b) :
Iso b [cup (i + 2), cross (i + 1) s, cap i] [cross i (!s)]Proof
:= by
have := (rotR0 s).shiftTo hb
simpa [shiftW, Gen.shift, Nat.add_comm] using this theorem rotL {b i : Nat} (s : Bool) (hb : i + 2 ≤ b) :
Iso b [cup i, cross (i + 1) s, cap (i + 2)] [cross i (!s)]Proof
:= by
have := (rotL0 s).shiftTo hb
simpa [shiftW, Gen.shift, Nat.add_comm] using this theorem rotR_iso_rotL {b i : Nat} (s : Bool) (hb : i + 2 ≤ b) :
Iso b [cup (i + 2), cross (i + 1) s, cap i] [cup i, cross (i + 1) s, cap (i + 2)]Proof
:=
(rotR s hb).trans (rotL s hb).symm theorem r3Mixed0 (s t u : Bool) (hv : t = s ∨ s ≠ u) :
Iso 3 [cross 0 s, cross 1 t, cross 0 u] [cross 1 u, cross 0 t, cross 1 s]Proof
:= by
cases s <;> cases t <;> cases u <;> simp at hv
· exact iso_of_checkChain _ [(0, .r3 0 false, true)] _ (by decide)
· exact iso_of_checkChain _
[(0, .r2 1 true, false), (1, .r3 0 false, false), (3, .r2 0 false, true)] _ (by decide)
· exact iso_of_checkChain _
[(3, .r2 1 true, false), (1, .r3 0 true, false), (0, .r2 0 false, true)] _ (by decide)
· exact iso_of_checkChain _
[(3, .r2 1 false, false), (1, .r3 0 false, false), (0, .r2 0 true, true)] _ (by decide)
· exact iso_of_checkChain _
[(0, .r2 1 false, false), (1, .r3 0 true, false), (3, .r2 0 true, true)] _ (by decide)
· exact iso_of_checkChain _ [(0, .r3 0 true, true)] _ (by decide) theorem r3Mixed {b i : Nat} (s t u : Bool) (hv : t = s ∨ s ≠ u) (hb : i + 3 ≤ b) :
Iso b [cross i s, cross (i + 1) t, cross i u] [cross (i + 1) u, cross i t, cross (i + 1) s]Proof
:= by
have := (r3Mixed0 s t u hv).shiftTo hb
simpa [shiftW, Gen.shift, Nat.add_comm] using this References
- Turaev. 1989. "Operator invariants of tangles, and R-matrices". Izv. Akad. Nauk SSSR 53:5. §7.3, relations (27), (28); Theorem 3.2; "Operator invariants of tangles, and R-matrices". Izv. Akad. Nauk SSSR 53:5. §7.3.
- Chmutov, Duzhin, Mostovoy. "Introduction to Vassiliev Knot Invariants". arXiv:1103.5628. Theorem 1.7.7, unoriented case, moves T0–T5′.
- Chmutov, Duzhin, Mostovoy. "Introduction to Vassiliev Knot Invariants". arXiv:1103.5628. Theorem 1.7.7.