Download data/lean/OAI/Computability/Scheduling/FrameInvariants.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 21.1 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/Scheduling/FrameInvariants.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/Scheduling/FrameInvariants.lean
-
curl -L -o FrameInvariants.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/Scheduling/FrameInvariants.lean
21.1 kB
| import OAI.Computability.Scheduling.CutoffSimplification | |
| namespace OAI | |
| section | |
| namespace ThreeMachine.Structure | |
| namespace Layout | |
| variable {J : Type} [Fintype J] | |
| theorem time_bounds (p : Layout J) (hfull : 3 β£ Fintype.card J) (x : J) : | |
| 1 β€ p.time x β§ p.time x β€ Fintype.card J / 3 := by | |
| obtain β¨T, hTβ© := hfull | |
| have hp := (p x).isLt | |
| dsimp [time] | |
| omega | |
| noncomputable def slot (p : Layout J) (s : β) : Finset J := by | |
| classical | |
| exact Finset.univ.filter (fun x => p.time x = s) | |
| @[simp] theorem mem_slot (p : Layout J) (s : β) (x : J) : | |
| x β p.slot s β p.time x = s := by | |
| classical | |
| simp [slot] | |
| theorem card_slot (p : Layout J) (hfull : 3 β£ Fintype.card J) (s : β) | |
| (hs : 1 β€ s) (hsT : s β€ Fintype.card J / 3) : (p.slot s).card = 3 := by | |
| classical | |
| obtain β¨T, hTβ© := hfull | |
| let i : Fin (Fintype.card J) := β¨3 * (s - 1), by omegaβ© | |
| let j : Fin (Fintype.card J) := β¨3 * (s - 1) + 1, by omegaβ© | |
| let k : Fin (Fintype.card J) := β¨3 * (s - 1) + 2, by omegaβ© | |
| apply Finset.card_eq_three.mpr | |
| refine β¨p.symm i, p.symm j, p.symm k, ?_, ?_, ?_, ?_β© | |
| Β· intro he | |
| have hev := congrArg Fin.val (p.symm.injective he) | |
| dsimp [i, j] at hev | |
| omega | |
| Β· intro he | |
| have hev := congrArg Fin.val (p.symm.injective he) | |
| dsimp [i, k] at hev | |
| omega | |
| Β· intro he | |
| have hev := congrArg Fin.val (p.symm.injective he) | |
| dsimp [j, k] at hev | |
| omega | |
| Β· ext x | |
| simp only [mem_slot, Finset.mem_insert, Finset.mem_singleton] | |
| have hxi : x = p.symm i β (p x).val = 3 * (s - 1) := by | |
| rw [Equiv.eq_symm_apply] | |
| exact Fin.ext_iff | |
| have hxj : x = p.symm j β (p x).val = 3 * (s - 1) + 1 := by | |
| rw [Equiv.eq_symm_apply] | |
| exact Fin.ext_iff | |
| have hxk : x = p.symm k β (p x).val = 3 * (s - 1) + 2 := by | |
| rw [Equiv.eq_symm_apply] | |
| exact Fin.ext_iff | |
| rw [hxi, hxj, hxk] | |
| dsimp [time] | |
| omega | |
| noncomputable def triple (p : Layout J) (hfull : 3 β£ Fintype.card J) | |
| (s : β) (hs : 1 β€ s) (hsT : s β€ Fintype.card J / 3) : Triple J := | |
| β¨p.slot s, p.card_slot hfull s hs hsTβ© | |
| theorem triple_at (p : Layout J) (hfull : 3 β£ Fintype.card J) | |
| (s : β) (hs : 1 β€ s) (hsT : s β€ Fintype.card J / 3) : | |
| (Boundary.actual (p.triple hfull s hs hsT)).At p.time (Fintype.card J / 3) s := by | |
| exact β¨hs, hsT, fun x => p.mem_slot s xβ© | |
| def reverse (p : Layout J) : Layout J := p.trans Fin.revPerm | |
| @[simp] theorem reverse_reverse (p : Layout J) : p.reverse.reverse = p := by | |
| ext x | |
| simp [reverse] | |
| theorem reverse_time (p : Layout J) (hfull : 3 β£ Fintype.card J) (x : J) : | |
| p.reverse.time x = Fintype.card J / 3 + 1 - p.time x := by | |
| obtain β¨T, hTβ© := hfull | |
| have hp := (p x).isLt | |
| change (Fintype.card J - ((p x).val + 1)) / 3 + 1 = | |
| Fintype.card J / 3 + 1 - ((p x).val / 3 + 1) | |
| omega | |
| theorem reverse_respects {p : Layout J} {r : J β J β Prop} | |
| (hfull : 3 β£ Fintype.card J) (hp : p.Respects r) : | |
| p.reverse.Respects (fun x y => r y x) := by | |
| intro x y hyx | |
| rw [p.reverse_time hfull, p.reverse_time hfull] | |
| have hxy := hp y x hyx | |
| have hx := p.time_bounds hfull x | |
| have hy := p.time_bounds hfull y | |
| omega | |
| theorem reverse_full {p : Layout J} {r : J β J β Prop} (hp : p.Full r) : | |
| p.reverse.Full (fun x y => r y x) := β¨hp.1, reverse_respects hp.1 hp.2β© | |
| theorem FixedOutside.reverse {p q : Layout J} {W : Set J} | |
| (h : p.FixedOutside q W) : p.reverse.FixedOutside q.reverse W := by | |
| intro x hx | |
| simp [Layout.reverse, h x hx] | |
| end Layout | |
| namespace Boundary | |
| variable {J : Type} [Fintype J] | |
| theorem at_reverse {p : Layout J} (hfull : 3 β£ Fintype.card J) | |
| {B : Boundary J} {s : β} (h : B.At p.time (Fintype.card J / 3) s) : | |
| B.reverse.At p.reverse.time (Fintype.card J / 3) (Fintype.card J / 3 + 1 - s) := by | |
| cases B with | |
| | left => dsimp [At] at h; subst s; rfl | |
| | right => dsimp [At] at h; subst s; simp [reverse, At] | |
| | actual Z => | |
| dsimp only [At] at h | |
| refine β¨by omega, by omega, ?_β© | |
| intro x | |
| rw [h.2.2, p.reverse_time hfull] | |
| have hx := p.time_bounds hfull x | |
| omega | |
| end Boundary | |
| end ThreeMachine.Structure | |
| namespace ThreeMachine.Structure | |
| section IntervalHelpers | |
| variable {J : Type} [Fintype J] | |
| theorem Layout.FixedOutside.window {p q : Layout J} {W : Set J} {a b : β} | |
| (h : p.FixedOutside q W) (hW : β x, x β W β x β Window p.time a b) : | |
| β x, x β W β x β Window q.time a b := by | |
| intro x | |
| constructor | |
| Β· exact h.time_range (fun z hz => (hW z).mp hz) | |
| Β· intro hx | |
| by_contra hn | |
| have he := h.time hn | |
| apply hn | |
| apply (hW x).mpr | |
| change a < q.time x β§ q.time x < b at hx | |
| change a < p.time x β§ p.time x < b | |
| simpa only [he] using hx | |
| theorem Layout.FixedOutside.boundary {p q : Layout J} {W : Set J} {a b s T : β} | |
| {B : Boundary J} (h : p.FixedOutside q W) | |
| (hW : β x, x β W β x β Window p.time a b) | |
| (hs : s β€ a β¨ b β€ s) (hB : B.At p.time T s) : B.At q.time T s := by | |
| cases B with | |
| | left => exact hB | |
| | right => exact hB | |
| | actual Z => | |
| refine β¨hB.1, hB.2.1, ?_β© | |
| intro x | |
| by_cases hx : x β W | |
| Β· have hp := (hW x).mp hx | |
| have hq := (h.window hW x).mp hx | |
| have hnp : p.time x β s := by rcases hs with hs | hs <;> dsimp [Window] at hp <;> omega | |
| have hnq : q.time x β s := by rcases hs with hs | hs <;> dsimp [Window] at hq <;> omega | |
| rw [hB.2.2] | |
| exact iff_of_false hnp hnq | |
| Β· rw [hB.2.2, h.time hx] | |
| theorem PastInvariant.reorder {r : J β J β Prop} {p q : Layout J} | |
| {K : GlobalList J} {A : Boundary J} {a b : β} {W : Set J} | |
| (hpast : PastInvariant r p.time K A a) (hfix : p.FixedOutside q W) | |
| (hW : β x, x β W β x β Window p.time a b) : | |
| PastInvariant r q.time K A a := by | |
| intro x hx htime | |
| have hnW : x β W := by | |
| intro hw | |
| have h := ((hfix.window hW) x).mp hw | |
| exact (not_lt_of_ge htime) h.1 | |
| have ht : p.time x = q.time x := (hfix.time hnW).symm | |
| exact hpast x hx (ht βΈ htime) | |
| def SwapInvariant [DecidableEq J] (r : J β J β Prop) (p : Layout J) | |
| (W : Set J) (K : GlobalList J) (rank : J β β) (A : Boundary J) (a : β) : Prop := | |
| β q : Layout J, p.FixedOutside q W β q.Respects r β | |
| β x β W, x β A.desc r β β y, q.time y = a β y β K.Qual β | |
| K.KeyLT rank x y β Β¬(q.exchange x y).Respects r | |
| theorem SwapInvariant.reorder [DecidableEq J] {r : J β J β Prop} {p q : Layout J} | |
| {W : Set J} {K : GlobalList J} {rank : J β β} {A : Boundary J} {a : β} | |
| (h : SwapInvariant r p W K rank A a) (hfix : p.FixedOutside q W) : | |
| SwapInvariant r q W K rank A a := by | |
| intro u hqu hu x hx hnx y hy hyq hkey | |
| exact h u (hfix.trans hqu) hu x hx hnx y hy hyq hkey | |
| theorem ideal_has_separator_interval {r : J β J β Prop} {S : Set J} | |
| (p : Layout J) (hp : p.Full r) {W : Finset J} {a b : β} | |
| (hW : β x, x β W β x β Window p.time a b) (hne : W.Nonempty) | |
| (htrans : β β¦x y zβ¦, r x y β r y z β r x z) | |
| (hideal : IdealOn W r S) : | |
| β q : Layout J, p.FixedOutside q (W : Set J) β§ q.Full r β§ | |
| β t, a < t β§ t < b β§ Separator W r q.time S t := by | |
| classical | |
| let priority := fun x : J => if x β S then (p x).val else Fintype.card J + (p x).val | |
| have hprefix : PrefixOn W priority S := by | |
| intro x _ hx y _ hy | |
| simp only [priority, ite_eq_left hx, ite_eq_right hy] | |
| have := (p x).isLt | |
| omega | |
| obtain β¨q, hfix, hqβ© := exists_normalizedOn p W r priority hp.2 | |
| have hWq : β x, x β W β x β Window q.time a b := hfix.window hW | |
| obtain β¨x, hx, hminβ© := W.exists_min_image q.time hne | |
| have hclosed : SlotClosed W q.time := by | |
| intro z hz y he | |
| apply (hWq y).mpr | |
| have hzt := (hWq z).mp hz | |
| change a < q.time z β§ q.time z < b at hzt | |
| change a < q.time y β§ q.time y < b | |
| simpa only [he] using hzt | |
| have hbefore : EarlierHigh W r q.time S (q.time x) := by | |
| intro z hz ht _ | |
| have := hmin z hz | |
| omega | |
| obtain β¨t, _hst, hpath, hsepβ© := walk_to_separator htrans hq.1 hclosed | |
| (Or.inl β¨x, hx, rflβ©) hideal hprefix | |
| (normalizedOn_local_obstruction hq hWq) hbefore | |
| have ht : β z β W, q.time z = t := by | |
| rcases hpath.endpoint with he | β¨z, hz, hztβ© | |
| Β· exact β¨x, hx, he.symmβ© | |
| Β· exact β¨z, hz, hztβ© | |
| obtain β¨z, hz, hztβ© := ht | |
| have hztBounds := (hWq z).mp hz | |
| change a < q.time z β§ q.time z < b at hztBounds | |
| refine β¨q, hfix, β¨hp.1, hq.1β©, t, ?_, ?_, hsepβ© <;> omega | |
| end IntervalHelpers | |
| end ThreeMachine.Structure | |
| namespace ThreeMachine.Structure | |
| section BoundaryWalk | |
| variable {J : Type} [Fintype J] | |
| theorem exception_global_ready {r : J β J β Prop} {p : Layout J} | |
| {E : Finset J} {a v : β} {S : Set J} {x : J} | |
| (htrans : β β¦u z wβ¦, r u z β r z w β r u w) (hp : p.Respects r) | |
| (hE : β z, z β E β a < p.time z β§ p.time z < v) | |
| (hideal : IdealOn E r S) (hx : Exception E r p.time S a x) : | |
| β u, r u x β p.time u < a := by | |
| intro u hux | |
| have htx := hp u x hux | |
| have hxt := (hE x).mp hx.mem | |
| by_contra hn | |
| have hau : a β€ p.time u := by omega | |
| rcases hau.eq_or_lt with he | hl | |
| Β· exact hx.not_desc β¨u, he.symm, huxβ© | |
| Β· have hu : u β E := (hE u).mpr β¨hl, htx.trans hxt.2β© | |
| have := exception_ready htrans hp hideal hx u hu hux | |
| omega | |
| omit [Fintype J] in | |
| theorem advance_carry_descendant {r : J β J β Prop} {time priority : J β β} | |
| {E : Finset J} {H S : Set J} {a v s : β} {x y : J} | |
| (htrans : β β¦u z wβ¦, r u z β r z w β r u w) | |
| (hrespect : β u z, r u z β time u < time z) | |
| (hE : β z, z β E β a < time z β§ time z < v) | |
| (hH : GlobalUpset r H) (hhigh : β z β E, z β H β z β S) | |
| (hideal : IdealOn E r S) (hprefix : PrefixOn E priority S) | |
| (hnorm : LocalObstruction E r time priority) | |
| (has : a β€ s) (hx : Exception E r time S s x) | |
| (hfirst : s = a β β z β H, time z = a β β u β E, r z u β§ time u β€ time x) | |
| (hyH : y β H) (hys : time y = s) : | |
| β z β E, time z = time x β§ r y z β§ z β H := by | |
| have hready := exception_ready htrans hrespect hideal hx | |
| have hforce : β z β E, z β S β s β€ time z β time z < time x β | |
| β u β E, r z u β§ time u β€ time x := by | |
| intro z hz hnS hsz hzx | |
| exact hnorm x hx.mem z hz hzx (hprefix x hx.mem hx.low z hz hnS) | |
| (fun u hu hux => (hready u hu hux).trans_le hsz) | |
| have hsucc : β u β E, r y u β§ time u β€ time x := by | |
| by_cases hsa : s = a | |
| Β· exact hfirst hsa y hyH (hys.trans hsa) | |
| Β· have hyE : y β E := (hE y).mpr | |
| β¨by omega, by have := (hE x).mp hx.mem; have := hx.later; omegaβ© | |
| exact hforce y hyE (hhigh y hyE hyH) (by omega) (by have := hx.later; omega) | |
| obtain β¨u, hu, hyu, hutβ© := hsucc | |
| have huH := hH hyu hyH | |
| have hsu : s β€ time u := by have := hrespect y u hyu; omega | |
| obtain β¨z, hz, hzt, huz, _hnSβ© := trace_to_slot htrans hrespect hideal hforce | |
| u hu (hhigh u hu huH) hsu hut | |
| have hyz : r y z := by | |
| rcases huz with e | hur | |
| Β· simpa [e] using hyu | |
| Β· exact htrans hyu hur | |
| exact β¨z, hz, hzt, hyz, hH hyz hyHβ© | |
| theorem first_boundary_force [DecidableEq J] | |
| {r : J β J β Prop} {p : Layout J} {E : Finset J} {a v : β} | |
| {S H : Set J} {x : J} | |
| (htrans : β β¦u z wβ¦, r u z β r z w β r u w) (hp : p.Respects r) | |
| (hE : β z, z β E β a < p.time z β§ p.time z < v) | |
| (hideal : IdealOn E r S) (hx : Exception E r p.time S a x) | |
| (hno : β y β H, p.time y = a β Β¬(p.exchange x y).Respects r) : | |
| β y β H, p.time y = a β β u β E, r y u β§ p.time u β€ p.time x := by | |
| have hready : β u, r u x β p.time u < a := | |
| exception_global_ready htrans hp hE hideal hx | |
| intro y hy hya | |
| by_contra hn | |
| have hsucc : β u, r y u β p.time x < p.time u := by | |
| intro u hyu | |
| by_contra hntu | |
| have hxv := ((hE x).mp hx.mem).2 | |
| have hyut := hp y u hyu | |
| have huE : u β E := (hE u).mpr β¨by omega, by omegaβ© | |
| exact hn β¨u, huE, hyu, by omegaβ© | |
| have hyx : p.time y < p.time x := by have := hx.later; omega | |
| exact hno y hy hya (respects_exchange hp x y hyx (fun u hur => by | |
| have := hready u hur; omega) hsucc) | |
| end BoundaryWalk | |
| end ThreeMachine.Structure | |
| namespace ThreeMachine.Structure | |
| section VaryingWalk | |
| variable {J : Type} | |
| inductive CutoffWalk (E : Finset J) (r : J β J β Prop) (time priority : J β β) | |
| (Sfinal : Set J) (a : β) : β β Prop | |
| | refl : CutoffWalk E r time priority Sfinal a a | |
| | step {s : β} {x : J} {U : Set J} | |
| (prev : CutoffWalk E r time priority Sfinal a s) | |
| (ideal : IdealOn E r U) (isPrefix : PrefixOn E priority U) | |
| (below : β z β E, z β U β z β Sfinal) | |
| (exception : Exception E r time U s x) : | |
| CutoffWalk E r time priority Sfinal a (time x) | |
| theorem CutoffWalk.le {E : Finset J} {r : J β J β Prop} {time priority : J β β} | |
| {S : Set J} {a t : β} (h : CutoffWalk E r time priority S a t) : a β€ t := by | |
| induction h with | |
| | refl => exact le_rfl | |
| | step _ _ _ _ hx ih => exact ih.trans hx.later.le | |
| theorem CutoffWalk.mono {E : Finset J} {r : J β J β Prop} {time priority : J β β} | |
| {S S' : Set J} {a t : β} (h : CutoffWalk E r time priority S a t) | |
| (hsub : β z β E, z β S β z β S') : CutoffWalk E r time priority S' a t := by | |
| induction h with | |
| | refl => exact .refl | |
| | step _ hi hp hb hx ih => exact .step ih hi hp (fun z hz hu => hsub z hz (hb z hz hu)) hx | |
| theorem CutoffWalk.trans_advance {E : Finset J} {r : J β J β Prop} | |
| {time priority : J β β} {S U : Set J} {a s t : β} | |
| (h : CutoffWalk E r time priority S a s) (hp : AdvancePath E r time U s t) | |
| (hi : IdealOn E r U) (hprefix : PrefixOn E priority U) | |
| (hbelow : β z β E, z β U β z β S) : | |
| CutoffWalk E r time priority S a t := by | |
| induction hp with | |
| | refl => exact h | |
| | step _ hx ih => exact .step ih hi hprefix hbelow hx | |
| theorem CutoffWalk.carry {E : Finset J} {r : J β J β Prop} {time priority : J β β} | |
| {S H : Set J} {a v t : β} | |
| (htrans : β β¦u z wβ¦, r u z β r z w β r u w) | |
| (hrespect : β u z, r u z β time u < time z) | |
| (hE : β z, z β E β a < time z β§ time z < v) | |
| (hH : GlobalUpset r H) (hhigh : β z β E, z β H β z β S) | |
| (hnorm : LocalObstruction E r time priority) | |
| (hfirst : β U, IdealOn E r U β PrefixOn E priority U β | |
| (β z β E, z β U β z β S) β β x, Exception E r time U a x β | |
| β y β H, time y = a β β u β E, r y u β§ time u β€ time x) | |
| (hwalk : CutoffWalk E r time priority S a t) : | |
| β y β H, time y = a β β z, time z = t β§ (z = y β¨ r y z) β§ z β H := by | |
| induction hwalk with | |
| | refl => exact fun y hy ht => β¨y, ht, Or.inl rfl, hyβ© | |
| | @step s x U prev hi hp hb hx ih => | |
| intro y hy hyt | |
| obtain β¨z, hzt, hyz, hzHβ© := ih y hy hyt | |
| obtain β¨w, _hw, hwt, hzw, hwHβ© := advance_carry_descendant htrans hrespect hE hH | |
| (fun z hz hzH hzU => hhigh z hz hzH (hb z hz hzU)) hi hp hnorm prev.le hx | |
| (fun hsa => hfirst U hi hp hb x (by simpa only [hsa] using hx)) hzH hzt | |
| refine β¨w, hwt, Or.inr ?_, hwHβ© | |
| rcases hyz with rfl | hyz | |
| Β· exact hzw | |
| Β· exact htrans hyz hzw | |
| end VaryingWalk | |
| section PastUpdate | |
| variable {J : Type} [Fintype J] | |
| omit [Fintype J] in | |
| theorem Boundary.weakPred_witness {r : J β J β Prop} {time : J β β} | |
| {T a : β} {A : Boundary J} {x : J} | |
| (hA : A.At time T a) (ha : a β€ T) (hx : x β A.weakPred r) : | |
| β y, time y = a β§ (x = y β¨ r x y) := by | |
| cases A with | |
| | left => exact False.elim hx | |
| | right => simp only [Boundary.At] at hA; omega | |
| | actual Z => | |
| rcases hx with β¨y, hy, hxyβ© | hx | |
| Β· exact β¨y, (hA.2.2 y).mp hy, Or.inr hxyβ© | |
| Β· exact β¨x, (hA.2.2 x).mp hx, Or.inl rflβ© | |
| theorem past_update {r : J β J β Prop} {p : Layout J} {priority : J β β} | |
| {E : Finset J} {a v ap : β} {A A' : Boundary J} {K K' : GlobalList J} | |
| {S H : Set J} | |
| (hp : p.Full r) (htrans : β β¦u z wβ¦, r u z β r z w β r u w) | |
| (hA : A.At p.time (Fintype.card J / 3) a) | |
| (hA' : A'.At p.time (Fintype.card J / 3) ap) | |
| (ha : a β€ Fintype.card J / 3) (hap : ap < v) | |
| (hE : β z, z β E β a < p.time z β§ p.time z < v) | |
| (hparent : PastInvariant r p.time K A a) | |
| (hH : GlobalUpset r H) (hHO : H β K.Qual) | |
| (hearly : β z β K'.Qual, p.time z β€ a β z β H) | |
| (hhigh : β z β E, z β K'.Qual β z β S) | |
| (hHhigh : β z β E, z β H β z β S) | |
| (hsep : A'.Separates r p.time E S ap) | |
| (hnorm : LocalObstruction E r p.time priority) | |
| (hfirst : β U, IdealOn E r U β PrefixOn E priority U β | |
| (β z β E, z β U β z β S) β β x, Exception E r p.time U a x β | |
| β y β H, p.time y = a β β u β E, r y u β§ p.time u β€ p.time x) | |
| (hwalk : CutoffWalk E r p.time priority S a ap) : | |
| PastInvariant r p.time K' A' ap := by | |
| intro z hz hzt | |
| by_cases hae : p.time z β€ a | |
| Β· have hzH := hearly z hz hae | |
| obtain β¨y, hya, hzyβ© := Boundary.weakPred_witness hA ha (hparent z (hHO hzH) hae) | |
| have hyH : y β H := by | |
| rcases hzy with rfl | hzy | |
| Β· exact hzH | |
| Β· exact hH hzy hzH | |
| obtain β¨w, hwt, hyw, _hwHβ© := hwalk.carry htrans hp.2 hE hH hHhigh hnorm hfirst y hyH hya | |
| have hwmem : w β A'.weakPred r := | |
| (Boundary.mem_weak_at_time (p.time_bounds hp.1) hA' hwt).1 | |
| rcases hzy with rfl | hzy | |
| Β· rcases hyw with rfl | hyw | |
| Β· exact hwmem | |
| Β· exact Boundary.weakPred_downset htrans A' hyw hwmem | |
| Β· have hzw : r z w := by | |
| rcases hyw with rfl | hyw | |
| Β· exact hzy | |
| Β· exact htrans hzy hyw | |
| exact Boundary.weakPred_downset htrans A' hzw hwmem | |
| Β· have hzE := (hE z).mpr β¨by omega, by omegaβ© | |
| rcases hzt.eq_or_lt with he | hl | |
| Β· exact (Boundary.mem_weak_at_time (p.time_bounds hp.1) hA' he).1 | |
| Β· exact A'.pred_subset_weakPred r (hsep.1 z hzE hl (hhigh z hzE hz)) | |
| end PastUpdate | |
| end ThreeMachine.Structure | |
| namespace ThreeMachine.Structure | |
| section ChildSwaps | |
| variable {J : Type} [Fintype J] [DecidableEq J] | |
| omit [DecidableEq J] in | |
| theorem Layout.FixedOutside.earlier_positions {p q : Layout J} {W : Set J} {a b : β} | |
| (hfix : p.FixedOutside q W) (hW : β x, x β W β x β Window p.time a b) | |
| {y : J} (hy : p.time y β€ a) : β j, j β€ p y β q.symm j = p.symm j := by | |
| intro j hj | |
| have hn : p.symm j β W := by | |
| intro hmem | |
| have ht := ((hW _).mp hmem).1 | |
| dsimp [Layout.time] at ht hy | |
| have hjv : j.val β€ (p y).val := hj | |
| simp only [p.apply_symm_apply] at ht | |
| omega | |
| apply q.injective | |
| rw [q.apply_symm_apply, hfix _ hn, p.apply_symm_apply] | |
| theorem swap_from_normalized {r : J β J β Prop} {p : Layout J} | |
| {E W : Set J} {a b ap bp : β} {A' : Boundary J} | |
| {K : GlobalList J} {rank priority : J β β} | |
| (hE : β x, x β E β x β Window p.time a b) | |
| (hW : β x, x β W β x β Window p.time ap bp) | |
| (ha : a < ap) (hb : bp β€ b) (hab : ap < bp) | |
| (hnorm : p.NormalizedOn E r priority) | |
| (hqual : β x β W, x β A'.desc r β x β K.Qual) | |
| (hkeys : β x β W, x β K.Qual β β y, p.time y = ap β y β K.Qual β | |
| K.KeyLT rank x y β priority x < priority y) : | |
| SwapInvariant r p W K rank A' ap := by | |
| intro q hfix _hq x hx hnx y hy hyq hkey hswap | |
| have hWx := (hfix.window hW x).mp hx | |
| have hnWy : y β W := by | |
| intro hw | |
| have ht := ((hfix.window hW) y).mp hw | |
| exact (lt_irrefl ap) (hy βΈ ht.1) | |
| have hpya : p.time y = ap := (hfix.time hnWy).symm.trans hy | |
| have hWE : W β E := by | |
| intro z hz | |
| have ht := (hW z).mp hz | |
| exact (hE z).mpr β¨ha.trans ht.1, ht.2.trans_le hbβ© | |
| have hyE : y β E := (hE y).mpr β¨by omega, by omegaβ© | |
| exact normalizedOn_prefix_no_exchange hnorm (hfix.mono hWE) (hWE hx) hyE | |
| (hfix.earlier_positions hW hpya.le) (by have := hWx.1; omega) | |
| (hkeys x hx (hqual x hx hnx) y hpya hyq hkey) hswap | |
| theorem swap_inherited {r : J β J β Prop} {p : Layout J} | |
| {W W' : Set J} {K K' : GlobalList J} {rank : J β β} {A : Boundary J} {a : β} | |
| (hparent : SwapInvariant r p W K rank A a) (hsub : W' β W) | |
| (hqual : β y β K'.Qual, y β K.Qual) | |
| (hkeys : β x β W', x β A.desc r β β y β K'.Qual, | |
| K'.KeyLT rank x y β K.KeyLT rank x y) : | |
| SwapInvariant r p W' K' rank A a := by | |
| intro q hfix hq x hx hnx y hy hyq hkey | |
| exact hparent q (hfix.mono hsub) hq x (hsub hx) hnx y hy | |
| (hqual y hyq) (hkeys x hx hnx y hyq hkey) | |
| theorem swap_prune {r : J β J β Prop} {p : Layout J} | |
| {W : Set J} {K : GlobalList J} {rank : J β β} {A : Boundary J} {a : β} | |
| (hparent : SwapInvariant r p W K rank A a) : | |
| SwapInvariant r p W (K.prune W) rank A a := by | |
| intro q hfix hq x hx hnx y hy hyq hkey | |
| exact hparent q hfix hq x hx hnx y hy (K.prune_qual_subset W hyq) | |
| (GlobalList.prune_key hx hkey) | |
| end ChildSwaps | |
| end ThreeMachine.Structure | |
| end | |
| end OAI | |