The item, name, and size tracks
Lax833301.Tracks · concepts/Lax833301/Tracks.lean · lax-833301
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
Each item has a lock interval, a binary name of common length, and the size word . Boundary probes delimit windows. The name track can offer one bit per stage. The size track offers alternating slots, with every third window boundary in the overlap between consecutive bins.
Concept map
In the paper
- page 2 of this submission's paper
Lean source view on GitHub
| 1 | import Lax833301.Schedules |
| 2 | import Lax833301.ThreePartition |
| 3 | import Mathlib.Data.Nat.Log |
| 4 | |
| 5 | /-! |
| 6 | --- |
| 7 | title: The item, name, and size tracks |
| 8 | type: definition |
| 9 | --- |
| 10 | Each item has a lock interval, a binary name of common length, and the size |
| 11 | word . Boundary probes delimit windows. The name track can |
| 12 | offer one bit per stage. The size track offers alternating slots, with |
| 13 | every third window boundary in the overlap between consecutive bins. |
| 14 | -/ |
| 15 | |
| 16 | namespace Lax833301.Tracks |
| 17 | |
| 18 | open Schedules ThreePartition |
| 19 | |
| 20 | abbrev items (I : Instance) := 3*I.m |
| 21 | def nameLength (I : Instance) := Nat.clog 2 (items I) |
| 22 | abbrev stages (I : Instance) := items I * nameLength I |
| 23 | abbrev slots (I : Instance) := 2*I.m*I.b |
| 24 | |
| 25 | abbrev Blocker (I : Instance) := Fin (items I) ⊕ (Fin (stages I + 1) × Fin 4) ⊕ Fin (slots I) |
| 26 | abbrev Fixed (I : Instance) := Fin 4 ⊕ (Fin (stages I) × Bool) ⊕ (Blocker I × Bool) |
| 27 | abbrev Probe (I : Instance) := Fin (items I + 1) ⊕ (Fin (items I) × Fin (nameLength I)) ⊕ |
| 28 | (Σ i : Fin (items I), Fin (2*I.size i)) |
| 29 | |
| 30 | /-- Natural-number labels used to specify consecutive pairs on the tracks. -/ |
| 31 | inductive Label where |
| 32 | | entry | exit | gate | collector |
| 33 | | stage (u : ℕ) (endOfStage : Bool) |
| 34 | | item (i : ℕ) (close : Bool) |
| 35 | | name (u r : ℕ) (close : Bool) |
| 36 | | slot (v : ℕ) (close : Bool) |
| 37 | | boundary (j : ℕ) |
| 38 | | bit (i u : ℕ) |
| 39 | | letter (i v : ℕ) |
| 40 | deriving DecidableEq |
| 41 | |
| 42 | def endpoint {I : Instance} (b : Blocker I) (close : Bool) : Label := |
| 43 | match b with |
| 44 | | .inl i => .item i close |
| 45 | | .inr (.inl (u,r)) => .name u r close |
| 46 | | .inr (.inr v) => .slot v close |
| 47 | |
| 48 | def fixedLabel {I : Instance} : Fixed I → Label |
| 49 | | .inl j => match j.val with |
| 50 | | 0 => .entry | 1 => .exit | 2 => .gate | _ => .collector |
| 51 | | .inr (.inl (u,e)) => .stage u e |
| 52 | | .inr (.inr (b,c)) => endpoint b c |
| 53 | |
| 54 | def probeLabel {I : Instance} : Probe I → Label |
| 55 | | .inl j => .boundary j |
| 56 | | .inr (.inl (i,u)) => .bit i u |
| 57 | | .inr (.inr ⟨i,v⟩) => .letter i v |
| 58 | |
| 59 | def nameKind (r : Fin 4) : Kind := ⟨3+r.val, by omega⟩ |
| 60 | |
| 61 | def color {I : Instance} : Blocker I → Kind |
| 62 | | .inl _ => 2 |
| 63 | | .inr (.inl (_,r)) => nameKind r |
| 64 | | .inr (.inr v) => if v.val % 2 = 0 then 1 else 0 |
| 65 | |
| 66 | def test {I : Instance} : Probe I → Kind |
| 67 | | .inl _ => 2 |
| 68 | | .inr (.inl (i,u)) => |
| 69 | let bit := (i.val.testBit u.val).toNat |
| 70 | nameKind ⟨2*((u.val+1)%2)+bit, by cases h : i.val.testBit u.val <;> simp [bit,h] <;> omega⟩ |
| 71 | | .inr (.inr ⟨_,v⟩) => if v.val % 2 = 0 then 0 else 1 |
| 72 | |
| 73 | def itemSize (I : Instance) (i : ℕ) : ℕ := |
| 74 | if h : i < items I then I.size ⟨i,h⟩ else 0 |
| 75 | |
| 76 | /-- The first size blocker of the next bin opens before the common boundary; |
| 77 | the last size blocker of the preceding bin closes after it. -/ |
| 78 | def binBoundary (I : Instance) (j k : ℕ) : Prop := |
| 79 | 0 < j ∧ j < items I ∧ j % 3 = 0 ∧ k = 2*(j/3)*I.b |
| 80 | |
| 81 | def crossed (I : Instance) (u r : ℕ) : ℕ := |
| 82 | if r/2 = (u % nameLength I + 1) % 2 then r ^^^ 1 else r |
| 83 | |
| 84 | /-- Consecutive track events and the additional precedence arcs, tested on |
| 85 | labels of actual events. Indices in labels start at zero. -/ |
| 86 | def precedes (I : Instance) : Label → Label → Prop |
| 87 | | .entry, .slot v false => v = 0 |
| 88 | | .entry, .name u _ false => u = 0 |
| 89 | | .gate, .item _ false => True |
| 90 | | .item _ true, .collector => True |
| 91 | | .collector, .boundary j => j = items I |
| 92 | | .boundary j, .gate => j = 0 |
| 93 | | .item i false, .item k true => i = k |
| 94 | | .item i false, .bit k u => i = k ∧ u = 0 |
| 95 | | .bit i u, .bit k v => i = k ∧ v = u+1 |
| 96 | | .bit i u, .letter k v => i = k ∧ u+1 = nameLength I ∧ v = 0 |
| 97 | | .letter i v, .letter k w => i = k ∧ w = v+1 |
| 98 | | .letter i v, .item k true => i = k ∧ v+1 = 2*itemSize I i |
| 99 | | .name u _ false, .boundary j => u = 0 ∧ j = 0 |
| 100 | | .boundary j, .name u _ true => j = items I ∧ u = stages I |
| 101 | | .name u _ true, .exit => u = stages I |
| 102 | | .name u r false, .name v s true => |
| 103 | (u = v ∧ r = s) ∨ (u = v+1 ∧ s = crossed I v r) |
| 104 | | .stage u false, .name v _ c => v = if c then u else u+1 |
| 105 | | .name v _ c, .stage u true => v = if c then u else u+1 |
| 106 | | .stage u true, .stage v false => v = u+1 ∧ v % nameLength I ≠ 0 |
| 107 | | .boundary j, .stage u false => u = j * nameLength I |
| 108 | | .stage u true, .boundary j => u+1 = j * nameLength I |
| 109 | | .slot v false, .boundary j => (v = 0 ∧ j = 0) ∨ binBoundary I j v |
| 110 | | .boundary j, .slot v true => |
| 111 | (j = items I ∧ v+1 = slots I) ∨ binBoundary I j (v+1) |
| 112 | | .slot v true, .exit => v+1 = slots I |
| 113 | | .slot v false, .slot w false => v = 0 ∧ w = 1 |
| 114 | | .slot v false, .slot w true => v = w ∨ v = w+1 |
| 115 | | .slot v true, .slot w false => w = v+2 |
| 116 | | .slot v true, .slot w true => w = v+1 ∧ w+1 = slots I |
| 117 | | _, _ => False |
| 118 | |
| 119 | noncomputable def template (I : Instance) : Template where |
| 120 | Fixed := Fixed I |
| 121 | Probe := Probe I |
| 122 | Blocker := Blocker I |
| 123 | entry := .inl 0 |
| 124 | exit := .inl 1 |
| 125 | collector := .inl 3 |
| 126 | opening b := .inr (.inr (b,false)) |
| 127 | closing b := .inr (.inr (b,true)) |
| 128 | color := color |
| 129 | test := test |
| 130 | arc u v := precedes I (Sum.elim fixedLabel probeLabel u) (Sum.elim fixedLabel probeLabel v) |
| 131 | |
| 132 | end Lax833301.Tracks |
| 133 |
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments