1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "ground_2/notation/constructors/nil_1.ma".
16 include "ground_2/notation/constructors/nil_2.ma".
17 include "ground_2/notation/constructors/cons_3.ma".
18 include "ground_2/notation/constructors/cons_5.ma".
19 include "ground_2/notation/functions/append_2.ma".
20 include "ground_2/lib/arith.ma".
22 (* LISTS ********************************************************************)
24 inductive list (A:Type[0]) : Type[0] :=
26 | cons: A → list A → list A.
28 interpretation "nil (list)" 'Nil A = (nil A).
30 interpretation "cons (list)" 'Cons A hd tl = (cons A hd tl).
32 let rec all A (R:predicate A) (l:list A) on l ≝
35 | cons hd tl ⇒ R hd ∧ all A R tl
38 inductive list2 (A1,A2:Type[0]) : Type[0] :=
40 | cons2: A1 → A2 → list2 A1 A2 → list2 A1 A2.
42 interpretation "nil (list of pairs)" 'Nil A1 A2 = (nil2 A1 A2).
44 interpretation "cons (list of pairs)" 'Cons A1 A2 hd1 hd2 tl = (cons2 A1 A2 hd1 hd2 tl).
46 let rec append2 (A1,A2:Type[0]) (l1,l2:list2 A1 A2) on l1 ≝ match l1 with
48 | cons2 a1 a2 tl ⇒ {a1, a2} @ append2 A1 A2 tl l2
51 interpretation "append (list of pairs)"
52 'Append l1 l2 = (append2 ? ? l1 l2).
54 let rec length2 (A1,A2:Type[0]) (l:list2 A1 A2) on l ≝ match l with
56 | cons2 _ _ l ⇒ length2 A1 A2 l + 1
59 interpretation "length (list of pairs)"
60 'card l = (length2 ? ? l).