Theoremfoldl_inv
Statement
theorem foldl_inv : ∀ (l : List Nat) (acc : List (List Nat)), (∀ a ∈ l, a < n) → Inv n r acc →
Inv n r (l.foldl (stepC n r) acc) ∧
(∀ x, ((∃ c ∈ acc, x ∈ c) ∨ x ∈ l) → ∃ c ∈ l.foldl (stepC n r) acc, x ∈ c) ∧
(l.foldl (stepC n r) acc).length ≤ acc.length + l.length
| [], acc, _, h => ⟨h, fun x hx => by simpa using hx, by simp⟩
| a :: l, acc, hl, h => by
simp only [List.foldl_cons]
obtain ⟨h1, h2, h3, h4⟩Proof
stepC_inv (r := r) (hl a List.mem_cons_self) h
obtain ⟨i1, i2, i3⟩ := foldl_inv l (stepC n r acc a) (fun b hb => hl b (List.mem_cons_of_mem _ hb)) h1
refine ⟨i1, ?_, by simp only [List.length_cons] at *; omega⟩
intro x hx
apply i2
rcases hx with ⟨c, hc, hxc⟩ | hx
· exact .inl (h2 x c hc hxc)
· rcases List.mem_cons.mp hx with rfl | hx
· exact .inl h3
· exact .inr hxProved by a term, which Lean's kernel checks directly.
Theorems it uses
Used by
In StandardElmMech/Src/GroupingProof.lean: components_valid: the canonical grouping is one the book allows (ValidNumbering).
A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.