2014-07-31 21:36:13 +00:00
|
|
|
----------------------------------------------------------------------------------------------------
|
|
|
|
--- Copyright (c) 2014 Parikshit Khanna. All rights reserved.
|
|
|
|
--- Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
--- Authors: Parikshit Khanna, Jeremy Avigad
|
|
|
|
----------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Theory list
|
|
|
|
-- ===========
|
|
|
|
--
|
|
|
|
-- Basic properties of lists.
|
|
|
|
|
2014-08-01 16:37:23 +00:00
|
|
|
import data.nat
|
2014-10-02 00:51:17 +00:00
|
|
|
open nat eq.ops
|
2014-07-31 21:36:13 +00:00
|
|
|
inductive list (T : Type) : Type :=
|
2015-02-26 01:00:10 +00:00
|
|
|
| nil {} : list T
|
|
|
|
| cons : T → list T → list T
|
2014-07-31 21:36:13 +00:00
|
|
|
|
2014-09-04 23:36:06 +00:00
|
|
|
namespace list
|
2014-07-31 21:36:13 +00:00
|
|
|
theorem list_induction_on {T : Type} {P : list T → Prop} (l : list T) (Hnil : P nil)
|
|
|
|
(Hind : forall x : T, forall l : list T, forall H : P l, P (cons x l)) : P l :=
|
2014-09-04 22:03:59 +00:00
|
|
|
list.rec Hnil Hind l
|
2014-07-31 21:36:13 +00:00
|
|
|
|
|
|
|
definition concat {T : Type} (s t : list T) : list T :=
|
2014-09-04 22:03:59 +00:00
|
|
|
list.rec t (fun x : T, fun l : list T, fun u : list T, cons x u) s
|
2014-07-31 21:36:13 +00:00
|
|
|
|
2015-01-25 04:23:21 +00:00
|
|
|
attribute concat [reducible]
|
2014-07-31 21:36:13 +00:00
|
|
|
theorem concat_nil {T : Type} (t : list T) : concat t nil = t :=
|
2014-09-04 23:36:06 +00:00
|
|
|
list_induction_on t (eq.refl (concat nil nil))
|
2014-07-31 21:36:13 +00:00
|
|
|
(take (x : T) (l : list T) (H : concat l nil = l),
|
2014-09-04 23:36:06 +00:00
|
|
|
H ▸ (eq.refl (concat (cons x l) nil)))
|
|
|
|
end list
|