Elm Exactly

Theoremexists_min

StandardElmMech/Src/GroupingProof.lean:162, Among the unplaced classes one is ready · term proof

Statement

theorem exists_min (f : Nat → Nat) : ∀ (l : List Nat), l ≠ [] → ∃ x ∈ l, ∀ y ∈ l, f x ≤ f y
  | [], h => absurd rfl h
  | [a], _ => ⟨a, by simp, by simp⟩
  | a :: b :: l, _ => by
    obtain ⟨x, hx, hm⟩

Proof

exists_min f (b :: l) (by simp)
    by_cases h : f a ≤ f x
    · refine ⟨a, by simp, ?_⟩
      intro y hy
      rcases List.mem_cons.mp hy with rfl | hy
      · exact Nat.le_refl _
      · exact Nat.le_trans h (hm y hy)
    · refine ⟨x, List.mem_cons_of_mem _ hx, ?_⟩
      intro y hy
      rcases List.mem_cons.mp hy with rfl | hy
      · omega
      · exact hm y hy

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

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.