Recursive replacement of probes
Lax833301.Expansion · concepts/Lax833301/Expansion.lean · lax-833301
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
At depth the replacement is a single interval. At depth the events are the fixed events of the template and the events in a depth- copy for each probe. An external arc leaves a child's exit or arrives at its entry. A coordinate has one type per level. Its load is the number of active intervals whose prefix matches that coordinate.
Concept map
In the paper
- page 4 of this submission's paper
Lean source view on GitHub
| 1 | import Lax833301.Schedules |
| 2 | |
| 3 | /-! |
| 4 | --- |
| 5 | title: Recursive replacement of probes |
| 6 | type: definition |
| 7 | --- |
| 8 | At depth the replacement is a single interval. At depth the events |
| 9 | are the fixed events of the template and the events in a depth- copy for |
| 10 | each probe. An external arc leaves a child's exit or arrives at its entry. |
| 11 | A coordinate has one type per level. Its load is the number of active |
| 12 | intervals whose prefix matches that coordinate. |
| 13 | -/ |
| 14 | |
| 15 | namespace Lax833301.Expansion |
| 16 | |
| 17 | open Schedules |
| 18 | |
| 19 | def Event (T : Template) : ℕ → Type |
| 20 | | 0 => Bool |
| 21 | | d+1 => T.Fixed ⊕ (T.Probe × Event T d) |
| 22 | |
| 23 | def Interval (T : Template) : ℕ → Type |
| 24 | | 0 => Unit |
| 25 | | d+1 => T.Blocker ⊕ (T.Probe × Interval T d) |
| 26 | |
| 27 | def Coord : ℕ → Type |
| 28 | | 0 => Unit |
| 29 | | d+1 => Kind × Coord d |
| 30 | |
| 31 | noncomputable instance eventFinite (T : Template) (d : ℕ) : Fintype (Event T d) := by |
| 32 | induction d with |
| 33 | | zero => exact inferInstanceAs (Fintype Bool) |
| 34 | | succ d ih => exact inferInstanceAs (Fintype (T.Fixed ⊕ (T.Probe × Event T d))) |
| 35 | |
| 36 | noncomputable instance intervalFinite (T : Template) (d : ℕ) : Fintype (Interval T d) := by |
| 37 | induction d with |
| 38 | | zero => exact inferInstanceAs (Fintype Unit) |
| 39 | | succ d ih => exact inferInstanceAs (Fintype (T.Blocker ⊕ (T.Probe × Interval T d))) |
| 40 | |
| 41 | instance coordFinite (d : ℕ) : Fintype (Coord d) := by |
| 42 | induction d with |
| 43 | | zero => exact inferInstanceAs (Fintype Unit) |
| 44 | | succ d ih => exact inferInstanceAs (Fintype (Kind × Coord d)) |
| 45 | |
| 46 | def terminal (T : Template) : (d : ℕ) → Bool → Event T d |
| 47 | | 0, endPoint => endPoint |
| 48 | | _+1, endPoint => Sum.inl (if endPoint then T.exit else T.entry) |
| 49 | |
| 50 | def endpoint (T : Template) : (d : ℕ) → Interval T d → Bool → Event T d |
| 51 | | 0, _, e => e |
| 52 | | _+1, .inl i, e => Sum.inl (if e then T.closing i else T.opening i) |
| 53 | | d+1, .inr (p,i), e => Sum.inr (p, endpoint T d i e) |
| 54 | |
| 55 | def uses (T : Template) : (d : ℕ) → Interval T d → Coord d → Prop |
| 56 | | 0, _, _ => True |
| 57 | | _+1, .inl i, (r,_) => T.color i = r |
| 58 | | d+1, .inr (p,i), (r,q) => T.test p = r ∧ uses T d i q |
| 59 | |
| 60 | def port (T : Template) (d : ℕ) (e : T.Event) (last : Bool) : Event T (d+1) := |
| 61 | match e with |
| 62 | | .inl v => Sum.inl v |
| 63 | | .inr p => Sum.inr (p, terminal T d last) |
| 64 | |
| 65 | def arc (T : Template) : (d : ℕ) → Event T d → Event T d → Prop |
| 66 | | 0, a, b => a = false ∧ b = true |
| 67 | | d+1, a, b => |
| 68 | (∃ u v, T.arc u v ∧ a = port T d u true ∧ b = port T d v false) ∨ |
| 69 | ∃ p x y, arc T d x y ∧ a = Sum.inr (p,x) ∧ b = Sum.inr (p,y) |
| 70 | |
| 71 | abbrev Clock (T : Template) (d : ℕ) := Event T d → ℕ |
| 72 | |
| 73 | def child {T : Template} {d : ℕ} (f : Clock T (d+1)) (p : T.Probe) : Clock T d := |
| 74 | fun x => f (Sum.inr (p,x)) |
| 75 | |
| 76 | /-- Respect the local arcs and keep every copy between its entry and exit. -/ |
| 77 | def Legal (T : Template) : (d : ℕ) → Clock T d → Prop |
| 78 | | 0, f => f false < f true |
| 79 | | d+1, f => |
| 80 | (∀ p, Legal T d (child f p)) ∧ |
| 81 | (∀ u v, T.arc u v → f (port T d u true) < f (port T d v false)) ∧ |
| 82 | ∀ x, f (terminal T (d+1) false) ≤ f x ∧ f x ≤ f (terminal T (d+1) true) |
| 83 | |
| 84 | noncomputable def load (T : Template) : (d : ℕ) → Clock T d → ℕ → Coord d → ℕ |
| 85 | | 0, f, z, _ => if f false ≤ z ∧ z < f true then 1 else 0 |
| 86 | | d+1, f, z, (r,q) => |
| 87 | T.count (fun v => f (Sum.inl v)) z (fun i => T.color i = r) + |
| 88 | ∑ p : T.Probe, if T.test p = r then load T d (child f p) z q else 0 |
| 89 | |
| 90 | end Lax833301.Expansion |
| 91 |
Builds on
From Mathlib
none
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments