]> matita.cs.unibo.it Git - helm.git/blob - list2.ma
b9a7327de68e8173fb2714ffac490c30ee40fccf
[helm.git] / list2.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "ground_2/notation/constructors/nil_0.ma".
16 include "ground_2/notation/constructors/cons_3.ma".
17 include "ground_2/notation/functions/append_2.ma".
18 include "ground_2/lib/arith.ma".
19
20 (* LISTS OF PAIRS ***********************************************************)
21
22 inductive list2 (A1,A2:Type[0]) : Type[0] :=
23   | nil2 : list2 A1 A2
24   | cons2: A1 → A2 → list2 A1 A2 → list2 A1 A2.
25
26 interpretation "nil (list of pairs)" 'Nil = (nil2 ? ?).
27
28 interpretation "cons (list of pairs)" 'Cons hd1 hd2 tl = (cons2 ? ? hd1 hd2 tl).
29
30 rec definition append2 (A1,A2:Type[0]) (l1,l2:list2 A1 A2) on l1 ≝ match l1 with
31 [ nil2           ⇒ l2
32 | cons2 a1 a2 tl ⇒ {a1, a2} @ append2 A1 A2 tl l2
33 ].
34
35 interpretation "append (list of pairs)"
36    'Append l1 l2 = (append2 ? ? l1 l2).
37
38 rec definition length2 (A1,A2:Type[0]) (l:list2 A1 A2) on l ≝ match l with
39 [ nil2        ⇒ 0
40 | cons2 _ _ l ⇒ ⫯(length2 A1 A2 l)
41 ].
42
43 interpretation "length (list of pairs)"
44    'card l = (length2 ? ? l).