|
2 | 2 | Copyright (c) 2014 Parikshit Khanna. All rights reserved.
|
3 | 3 | Released under Apache 2.0 license as described in the file LICENSE.
|
4 | 4 | Authors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro
|
5 |
| -
|
6 |
| -Basic properties of lists. |
7 | 5 | -/
|
8 | 6 | import
|
9 | 7 | tactic.interactive tactic.mk_iff_of_inductive_prop
|
10 | 8 | logic.basic logic.function logic.relator
|
11 | 9 | algebra.group order.basic
|
12 | 10 | data.list.defs data.nat.basic data.option.basic
|
13 | 11 | data.bool data.prod data.fin
|
| 12 | + |
| 13 | +/-! |
| 14 | +# Basic properties of lists |
| 15 | +-/ |
| 16 | + |
14 | 17 | open function nat
|
15 | 18 |
|
16 | 19 | namespace list
|
@@ -306,12 +309,6 @@ by induction s; intros; contradiction
|
306 | 309 | theorem append_ne_nil_of_ne_nil_right (s t : list α) : t ≠ [] → s ++ t ≠ [] :=
|
307 | 310 | by induction s; intros; contradiction
|
308 | 311 |
|
309 |
| -theorem append_foldl (f : α → β → α) (a : α) (s t : list β) : foldl f a (s ++ t) = foldl f (foldl f a s) t := |
310 |
| -by {induction s with b s H generalizing a, refl, simp only [foldl, cons_append], rw H _} |
311 |
| - |
312 |
| -theorem append_foldr (f : α → β → β) (a : β) (s t : list α) : foldr f a (s ++ t) = foldr f (foldr f a t) s := |
313 |
| -by {induction s with b s H generalizing a, refl, simp only [foldr, cons_append], rw H _} |
314 |
| - |
315 | 312 | @[simp] lemma append_eq_nil {p q : list α} : (p ++ q) = [] ↔ p = [] ∧ q = [] :=
|
316 | 313 | by cases p; simp only [nil_append, cons_append, eq_self_iff_true, true_and, false_and]
|
317 | 314 |
|
@@ -1086,6 +1083,8 @@ end insert_nth
|
1086 | 1083 |
|
1087 | 1084 | /- map -/
|
1088 | 1085 |
|
| 1086 | +@[simp] lemma map_nil (f : α → β) : map f [] = [] := rfl |
| 1087 | + |
1089 | 1088 | lemma map_congr {f g : α → β} : ∀ {l : list α}, (∀ x ∈ l, f x = g x) → map f l = map g l
|
1090 | 1089 | | [] _ := rfl
|
1091 | 1090 | | (a::l) h := let ⟨h₁, h₂⟩ := forall_mem_cons.1 h in
|
@@ -1495,6 +1494,9 @@ variables [monoid α] {l l₁ l₂ : list α} {a : α}
|
1495 | 1494 | @[simp, to_additive]
|
1496 | 1495 | theorem prod_nil : ([] : list α).prod = 1 := rfl
|
1497 | 1496 |
|
| 1497 | +@[to_additive] |
| 1498 | +theorem prod_singleton : [a].prod = a := one_mul a |
| 1499 | + |
1498 | 1500 | @[simp, to_additive]
|
1499 | 1501 | theorem prod_cons : (a::l).prod = a * l.prod :=
|
1500 | 1502 | calc (a::l).prod = foldl (*) (a * 1) l : by simp only [list.prod, foldl_cons, one_mul, mul_one]
|
|
0 commit comments