feat(library/data/list/basic): use 'show' instead of 'change' tactic

This commit is contained in:
Leonardo de Moura 2015-03-04 20:40:06 -08:00
parent b8afba47ad
commit 53df3d86ee

View file

@ -43,10 +43,8 @@ theorem append_nil_right : ∀ (t : list T), t ++ nil = t
theorem append.assoc : ∀ (s t u : list T), s ++ t ++ u = s ++ (t ++ u) theorem append.assoc : ∀ (s t u : list T), s ++ t ++ u = s ++ (t ++ u)
| append.assoc nil t u := rfl | append.assoc nil t u := rfl
| append.assoc (a :: l) t u := | append.assoc (a :: l) t u :=
begin show a :: (l ++ t ++ u) = (a :: l) ++ (t ++ u),
change a :: (l ++ t ++ u) = (a :: l) ++ (t ++ u), by rewrite (append.assoc l t u)
rewrite append.assoc
end
/- length -/ /- length -/
@ -83,10 +81,8 @@ theorem concat_cons (x y : T) (l : list T) : concat x (y::l) = y::(concat x l)
theorem concat_eq_append (a : T) : ∀ (l : list T), concat a l = l ++ [a] theorem concat_eq_append (a : T) : ∀ (l : list T), concat a l = l ++ [a]
| concat_eq_append nil := rfl | concat_eq_append nil := rfl
| concat_eq_append (b :: l) := | concat_eq_append (b :: l) :=
begin show b :: (concat a l) = (b :: l) ++ (a :: nil),
change b :: (concat a l) = (b :: l) ++ (a :: nil), by rewrite concat_eq_append
rewrite concat_eq_append
end
-- add_rewrite append_nil append_cons -- add_rewrite append_nil append_cons
@ -140,10 +136,8 @@ theorem head_cons [h : inhabited T] (a : T) (l : list T) : head (a::l) = a
theorem head_concat [h : inhabited T] (t : list T) : ∀ {s : list T}, s ≠ nil → head (s ++ t) = head s theorem head_concat [h : inhabited T] (t : list T) : ∀ {s : list T}, s ≠ nil → head (s ++ t) = head s
| @head_concat nil H := absurd rfl H | @head_concat nil H := absurd rfl H
| @head_concat (a :: s) H := | @head_concat (a :: s) H :=
begin show head (a :: (s ++ t)) = head (a :: s),
change head (a :: (s ++ t)) = head (a :: s), by rewrite head_cons
rewrite head_cons
end
definition tail : list T → list T definition tail : list T → list T
| tail nil := nil | tail nil := nil
@ -309,17 +303,14 @@ theorem map_cons (f : A → B) (a : A) (l : list A) : map f (a :: l) = f a :: ma
theorem map_map (g : B → C) (f : A → B) : ∀ l : list A, map g (map f l) = map (g ∘ f) l theorem map_map (g : B → C) (f : A → B) : ∀ l : list A, map g (map f l) = map (g ∘ f) l
| map_map nil := rfl | map_map nil := rfl
| map_map (a :: l) := | map_map (a :: l) :=
begin show (g ∘ f) a :: map g (map f l) = map (g ∘ f) (a :: l),
rewrite [▸ (g ∘ f) a :: map g (map f l) = _, map_map l] by rewrite (map_map l)
end
theorem len_map (f : A → B) : ∀ l : list A, length (map f l) = length l theorem len_map (f : A → B) : ∀ l : list A, length (map f l) = length l
| len_map nil := rfl | len_map nil := rfl
| len_map (a :: l) := | len_map (a :: l) :=
begin show length (map f l) + 1 = length l + 1,
rewrite ▸ length (map f l) + 1 = length l + 1, by rewrite (len_map l)
rewrite (len_map l)
end
definition foldl (f : A → B → A) : A → list B → A definition foldl (f : A → B → A) : A → list B → A
| foldl a nil := a | foldl a nil := a
@ -375,7 +366,8 @@ definition unzip : list (A × B) → list A × list B
theorem unzip_nil : unzip (@nil (A × B)) = (nil, nil) theorem unzip_nil : unzip (@nil (A × B)) = (nil, nil)
theorem unzip_cons (a : A) (b : B) (l : list (A × B)) : unzip ((a, b) :: l) = match unzip l with (la, lb) := (a :: la, b :: lb) end theorem unzip_cons (a : A) (b : B) (l : list (A × B)) :
unzip ((a, b) :: l) = match unzip l with (la, lb) := (a :: la, b :: lb) end
theorem zip_unzip : ∀ (l : list (A × B)), zip (pr₁ (unzip l)) (pr₂ (unzip l)) = l theorem zip_unzip : ∀ (l : list (A × B)), zip (pr₁ (unzip l)) (pr₂ (unzip l)) = l
| zip_unzip nil := rfl | zip_unzip nil := rfl
@ -393,7 +385,7 @@ end combinators
end list end list
attribute list.decidable_eq [instance] attribute list.decidable_eq [instance]
attribute list.decidable_mem [instance] attribute list.decidable_mem [instance]
attribute list.decidable_any [instance] attribute list.decidable_any [instance]
attribute list.decidable_all [instance] attribute list.decidable_all [instance]