@@ -1215,11 +1215,11 @@ by induction l; simp *
1215
1215
/- find -/
1216
1216
1217
1217
section find
1218
- variables ( p : α → Prop ) [decidable_pred p]
1218
+ variables { p : α → Prop } [decidable_pred p] {l : list α} {a : α}
1219
1219
1220
1220
/-- `find p l` is the first element of `l` satisfying `p`, or `none` if no such
1221
1221
element exists. -/
1222
- def find : list α → option α
1222
+ def find (p : α → Prop ) [decidable_pred p] : list α → option α
1223
1223
| [] := none
1224
1224
| (a::l) := if p a then some a else find l
1225
1225
@@ -1231,34 +1231,30 @@ def find_indexes_aux (p : α → Prop) [decidable_pred p] : list α → nat →
1231
1231
def find_indexes (p : α → Prop ) [decidable_pred p] (l : list α) : list nat :=
1232
1232
find_indexes_aux p l 0
1233
1233
1234
- @[simp] theorem find_nil : find p [] = none := rfl
1234
+ @[simp] theorem find_nil (p : α → Prop ) [decidable_pred p] : find p [] = none :=
1235
+ rfl
1235
1236
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 :=
1238
1238
if_pos h
1239
1239
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 :=
1242
1241
if_neg h
1243
1242
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 :=
1246
1244
begin
1247
1245
induction l with a l IH, {simp},
1248
1246
by_cases p a; simp [h, IH]
1249
1247
end
1250
1248
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 :=
1253
1250
begin
1254
1251
induction l with b l IH, {contradiction},
1255
1252
by_cases p b; simp [h] at H,
1256
1253
{ subst b, assumption },
1257
1254
{ exact IH H }
1258
1255
end
1259
1256
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 :=
1262
1258
begin
1263
1259
induction l with b l IH, {contradiction},
1264
1260
by_cases p b; simp [h] at H,
0 commit comments