Documentation

LeanPool.OrderMaintenance.Proof.Top.Lists

M5: list facts #

theorem OrderMaintenance.Proof.Top.Array.size_setX {α : Type} [Inhabited α] (a : Array α) (i : ℕ) (v : α) :
(a.setX i v).size = if i < a.size then a.size else i + 1
theorem OrderMaintenance.Proof.Top.sublist_of_subset_common {A B L : List ℕ} :
A.Sublist L → B.Sublist L → L.Nodup → A ⊆ B → A.Sublist B

Two sublists of a list of distinct elements: inclusion is a sublist.

Filters changed at one element #

theorem OrderMaintenance.Proof.Top.filter_erase_of {l : List ℕ} (hl : l.Nodup) {p p' : ℕ → Bool} {c : ℕ} (hpp : ∀ x ∈ l, x ≠ c → p' x = p x) (hc : p' c = false) :
theorem OrderMaintenance.Proof.Top.filter_snoc_of {l : List ℕ} (hl : l.Nodup) {p p' : ℕ → Bool} {c : ℕ} (hpp : ∀ x ∈ l, x ≠ c → p' x = p x) (hc : p' c = true) (hpc : p c = false) (hcl : c ∈ l) (hbefore : ∀ x ∈ l, p x = true → x ≠ c → Before l x c) :
theorem OrderMaintenance.Proof.Top.filter_cons_of {l : List ℕ} (hl : l.Nodup) {p p' : ℕ → Bool} {c : ℕ} (hpp : ∀ x ∈ l, x ≠ c → p' x = p x) (hc : p' c = true) (hpc : p c = false) (hcl : c ∈ l) (hafter : ∀ x ∈ l, p x = true → x ≠ c → Before l c x) :

Convex filters #

theorem OrderMaintenance.Proof.Top.filter_infix_of_convex {l : List ℕ} (hl : l.Nodup) {p : ℕ → Bool} (hcv : ∀ (a b d : ℕ), p a = true → p d = true → Before l a b → Before l b d → p b = true) :

A filter that is convex (closed under betweenness) is a block of the list.

Ends of a list #

theorem OrderMaintenance.Proof.Top.before_headD {l : List ℕ} {c d : ℕ} (hc : c ∈ l) (hne : c ≠ l.headD d) :
Before l (l.headD d) c
theorem OrderMaintenance.Proof.Top.before_getLastD {l : List ℕ} {c d : ℕ} (hc : c ∈ l) (hne : c ≠ l.getLastD d) :
Before l c (l.getLastD d)
theorem OrderMaintenance.Proof.Top.succOf_infix {l r : List ℕ} {y z : ℕ} (hl : l.Nodup) (h : y :: z :: r <:+: l) :
succOf l y = z

In a block y :: z :: _ of a nodup list, z follows y.

theorem OrderMaintenance.Proof.Top.predOf_infix {l r : List ℕ} {y z : ℕ} (hl : l.Nodup) (h : r ++ [z, y] <:+: l) :
predOf l y = z

Erasing an element #

theorem OrderMaintenance.Proof.Top.before_erase {l : List ℕ} (hl : l.Nodup) {a b v : ℕ} (ha : a ≠ v) (hb : b ≠ v) :
Before (l.erase v) a b ↔ Before l a b
theorem OrderMaintenance.Proof.Top.sublist_erase_of_not_mem {l m : List ℕ} {v : ℕ} (h : l.Sublist m) (hv : v ∉ l) :
l.Sublist (m.erase v)
theorem OrderMaintenance.Proof.Top.infix_erase {l t : List ℕ} {v : ℕ} (hl : l.Nodup) (h : t <:+: l) (hv : v ∉ t) :
t <:+: l.erase v

Inserting around an element in a list and a superlist #

theorem OrderMaintenance.Proof.Top.sublist_split_mid {A B P Q : List ℕ} {x : ℕ} (h : (A ++ x :: B).Sublist (P ++ x :: Q)) (hP : x ∉ P) (hQ : x ∉ Q) :
theorem OrderMaintenance.Proof.Top.sublist_around {A B P Q : List ℕ} {x y z : ℕ} (h : (A ++ x :: B).Sublist (P ++ x :: Q)) (hP : x ∉ P) (hQ : x ∉ Q) :
(A ++ y :: x :: z :: B).Sublist (P ++ y :: x :: z :: Q)
theorem OrderMaintenance.Proof.Top.before_dedup {L1 L2 : List ℕ} {x a b : ℕ} (h : Before (L1 ++ x :: x :: L2) a b) (hab : a ≠ b) :
Before (L1 ++ x :: L2) a b
theorem OrderMaintenance.Proof.Top.before_proj {A B : List ℕ} {x y z c d : ℕ} (hyA : y ∉ A) (hzA : z ∉ A) (hyB : y ∉ B) (hzB : z ∉ B) (h : Before (A ++ y :: x :: z :: B) c d) :
have p := fun (e : ℕ) => if e = y ∨ e = z then x else e; p c = p d ∨ Before (A ++ x :: B) (p c) (p d)

Collapsing y and z onto x maps the order A, y, x, z, B onto A, x, B.

theorem OrderMaintenance.Proof.Top.before_lift {A B : List ℕ} {x y z c d : ℕ} (hnd : (A ++ y :: x :: z :: B).Nodup) (hc : c ∈ A ++ y :: x :: z :: B) (hd : d ∈ A ++ y :: x :: z :: B) (hne : (if c = y ∨ c = z then x else c) ≠ if d = y ∨ d = z then x else d) (h : Before (A ++ x :: B) (if c = y ∨ c = z then x else c) (if d = y ∨ d = z then x else d)) :
Before (A ++ y :: x :: z :: B) c d

Order in A, x, B lifts to A, y, x, z, B through the collapse of y, z onto x.

Replacing one element #

theorem OrderMaintenance.Proof.Top.mem_replace1_of_ne {l ys : List ℕ} {x y : ℕ} (hx : x ∈ l) (hxy : x ≠ y) :
x ∈ l.replace1 y ys
theorem OrderMaintenance.Proof.Top.mem_replace1_new {l ys : List ℕ} {y z : ℕ} (hy : y ∈ l) (hz : z ∈ ys) :
z ∈ l.replace1 y ys
theorem OrderMaintenance.Proof.Top.mem_replace1 {l ys : List ℕ} {y z : ℕ} (hz : z ∈ l.replace1 y ys) :
z ∈ l ∨ z ∈ ys
theorem OrderMaintenance.Proof.Top.infix_replace1 {T l ys : List ℕ} {y : ℕ} (h : T <:+: l) (hy : y ∉ T) :
T <:+: l.replace1 y ys
theorem OrderMaintenance.Proof.Top.infix_take {l : List ℕ} (hl : l.Nodup) {a b k : ℕ} (h : [a, b] <:+: l) (hb : b ∈ List.take k l) :
theorem OrderMaintenance.Proof.Top.infix_drop {l : List ℕ} (hl : l.Nodup) {a b k : ℕ} (h : [a, b] <:+: l) (ha : a ∈ List.drop k l) :

Infix triples #

theorem OrderMaintenance.Proof.Top.infix3_left {l : List ℕ} {a b c : ℕ} (h : [a, b, c] <:+: l) :
[a, b] <:+: l
theorem OrderMaintenance.Proof.Top.infix3_right {l : List ℕ} {a b c : ℕ} (h : [a, b, c] <:+: l) :
[b, c] <:+: l
theorem OrderMaintenance.Proof.Top.before_pred {l : List ℕ} (hl : l.Nodup) {a b x : ℕ} (h : [a, b] <:+: l) (hx : Before l x b) :
x = a ∨ Before l x a

What precedes b in a nodup list, with a right before b, is a or precedes a.

theorem OrderMaintenance.Proof.Top.before_succ {l : List ℕ} (hl : l.Nodup) {b c x : ℕ} (h : [b, c] <:+: l) (hx : Before l b x) :
x = c ∨ Before l c x

What follows b in a nodup list, with c right after b, is c or follows c.