Elm Exactly

Theoremlen_filter_mono

StandardElmMech/Src/Graph.lean:57, Counting the members of filters · term proof

Statement

theorem len_filter_mono {α : Type} : ∀ {l : List α} {p q : α → Bool},
    (∀ x ∈ l, p x = true → q x = true) → (l.filter p).length ≤ (l.filter q).length
  | [], _, _, _ => by simp
  | x :: xs, p, q, h => by
    have ih

Proof

len_filter_mono (l := xs) (p := p) (q := q) (fun y hy => h y (List.mem_cons_of_mem _ hy))
    have hx := h x List.mem_cons_self
    simp only [List.filter_cons]
    cases hp : p x <;> cases hq : q x <;> simp_all <;> omega

Proved by a term, which Lean's kernel checks directly.

Used by

In StandardElmMech/Src/Graph.lean: Reachability on graphs over 0 .. n-1 (Plus, Reach) and its decider, proved correct (plusB_iff, reachB_iff).

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.