Skip to content

Commit

Permalink
feat(List/Enum): add lemmas about ∀ x ∈ l.enum, p x etc (#16789)
Browse files Browse the repository at this point in the history
  • Loading branch information
urkud committed Sep 18, 2024
1 parent f1027bc commit d7e322a
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions Mathlib/Data/List/Enum.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Yakov Pechersky, Eric Wieser
-/
import Batteries.Tactic.Alias
import Mathlib.Tactic.TypeStar
import Mathlib.Data.Nat.Notation
import Mathlib.Data.List.Basic

/-!
# Properties of `List.enum`
## Deprecation note
Everything in this file has been replaced by theorems in Lean4,
Many lemmas in this file have been replaced by theorems in Lean4,
in terms of `xs[i]?` and `xs[i]` rather than `get` and `get?`.
The results here are unused in Mathlib, and deprecated.
The deprecated results here are unused in Mathlib.
Any downstream users who can not easily adapt may remove the deprecations as needed.
-/

Expand Down Expand Up @@ -64,4 +63,20 @@ set_option linter.deprecated false in
theorem mem_enum_iff_get? {x : ℕ × α} {l : List α} : x ∈ enum l ↔ l.get? x.1 = x.2 :=
mk_mem_enum_iff_get?

theorem forall_mem_enumFrom {l : List α} {n : ℕ} {p : ℕ × α → Prop} :
(∀ x ∈ l.enumFrom n, p x) ↔ ∀ (i : ℕ) (_ : i < length l), p (n + i, l[i]) := by
simp only [forall_mem_iff_getElem, getElem_enumFrom, enumFrom_length]

theorem forall_mem_enum {l : List α} {p : ℕ × α → Prop} :
(∀ x ∈ l.enum, p x) ↔ ∀ (i : ℕ) (_ : i < length l), p (i, l[i]) :=
forall_mem_enumFrom.trans <| by simp

theorem exists_mem_enumFrom {l : List α} {n : ℕ} {p : ℕ × α → Prop} :
(∃ x ∈ l.enumFrom n, p x) ↔ ∃ (i : ℕ) (_ : i < length l), p (n + i, l[i]) := by
simp only [exists_mem_iff_getElem, getElem_enumFrom, enumFrom_length]

theorem exists_mem_enum {l : List α} {p : ℕ × α → Prop} :
(∃ x ∈ l.enum, p x) ↔ ∃ (i : ℕ) (_ : i < length l), p (i, l[i]) :=
exists_mem_enumFrom.trans <| by simp

end List

0 comments on commit d7e322a

Please sign in to comment.