Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit e1f795d

Browse files
spldigama0
authored andcommitted
chore(data/list/basic): minor cleanup of find variables (#137)
1 parent 85bc56a commit e1f795d

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

data/list/basic.lean

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,11 +1215,11 @@ by induction l; simp *
12151215
/- find -/
12161216

12171217
section find
1218-
variables (p : α → Prop) [decidable_pred p]
1218+
variables {p : α → Prop} [decidable_pred p] {l : list α} {a : α}
12191219

12201220
/-- `find p l` is the first element of `l` satisfying `p`, or `none` if no such
12211221
element exists. -/
1222-
def find : list α → option α
1222+
def find (p : α → Prop) [decidable_pred p] : list α → option α
12231223
| [] := none
12241224
| (a::l) := if p a then some a else find l
12251225

@@ -1231,34 +1231,30 @@ def find_indexes_aux (p : α → Prop) [decidable_pred p] : list α → nat →
12311231
def find_indexes (p : α → Prop) [decidable_pred p] (l : list α) : list nat :=
12321232
find_indexes_aux p l 0
12331233

1234-
@[simp] theorem find_nil : find p [] = none := rfl
1234+
@[simp] theorem find_nil (p : α → Prop) [decidable_pred p] : find p [] = none :=
1235+
rfl
12351236

1236-
@[simp] theorem find_cons_of_pos {p : α → Prop} [h : decidable_pred p] {a : α}
1237-
(l) (h : p a) : find p (a::l) = some a :=
1237+
@[simp] theorem find_cons_of_pos (l) (h : p a) : find p (a::l) = some a :=
12381238
if_pos h
12391239

1240-
@[simp] theorem find_cons_of_neg {p : α → Prop} [h : decidable_pred p] {a : α}
1241-
(l) (h : ¬ p a) : find p (a::l) = find p l :=
1240+
@[simp] theorem find_cons_of_neg (l) (h : ¬ p a) : find p (a::l) = find p l :=
12421241
if_neg h
12431242

1244-
@[simp] theorem find_eq_none {p : α → Prop} [h : decidable_pred p] {l : list α} :
1245-
find p l = none ↔ ∀ x ∈ l, ¬ p x :=
1243+
@[simp] theorem find_eq_none : find p l = none ↔ ∀ x ∈ l, ¬ p x :=
12461244
begin
12471245
induction l with a l IH, {simp},
12481246
by_cases p a; simp [h, IH]
12491247
end
12501248

1251-
@[simp] theorem find_some {p : α → Prop} [h : decidable_pred p] {l : list α} {a : α}
1252-
(H : find p l = some a) : p a :=
1249+
@[simp] theorem find_some (H : find p l = some a) : p a :=
12531250
begin
12541251
induction l with b l IH, {contradiction},
12551252
by_cases p b; simp [h] at H,
12561253
{ subst b, assumption },
12571254
{ exact IH H }
12581255
end
12591256

1260-
@[simp] theorem find_mem {p : α → Prop} [h : decidable_pred p] {l : list α} {a : α}
1261-
(H : find p l = some a) : a ∈ l :=
1257+
@[simp] theorem find_mem (H : find p l = some a) : a ∈ l :=
12621258
begin
12631259
induction l with b l IH, {contradiction},
12641260
by_cases p b; simp [h] at H,

0 commit comments

Comments
 (0)