lean4-htt/tests/lean/run/list_elab1.lean
2016-06-10 18:29:41 -07:00

31 lines
1.1 KiB
Text

----------------------------------------------------------------------------------------------------
--- 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.
import data.nat
open nat eq.ops
inductive List (T : Type) : Type :=
| nil {} : List T
| cons : T → List T → List T
namespace List
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 :=
List.rec Hnil Hind l
definition concat {T : Type} (s t : List T) : List T :=
List.rec t (fun x : T, fun l : List T, fun u : List T, cons x u) s
attribute concat [reducible]
theorem concat_nil {T : Type} (t : List T) : concat t nil = t :=
List_induction_on t (eq.refl (concat nil nil))
(take (x : T) (l : List T) (H : concat l nil = l),
H ▸ (eq.refl (concat (cons x l) nil)))
end List