]> matita.cs.unibo.it Git - helm.git/blob - constructors.ma
926dd35fcac48eecab79c23ea66dcc24bf75acc1
[helm.git] / constructors.ma
1 (**************************************************************************)
2 (*       ___                                                                *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||       A.Asperti, C.Sacerdoti Coen,                          *)
8 (*      ||A||       E.Tassi, S.Zacchiroli                                 *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU Lesser General Public License Version 2.1         *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "logic/equality.ma".
16
17 inductive void : Set \def.
18
19 inductive unit : Set ≝ something: unit.
20
21 inductive Prod (A,B:Type) : Type \def
22 pair : A \to B \to Prod A B.
23
24 interpretation "Pair construction" 'pair x y =
25  (cic:/matita/datatypes/constructors/Prod.ind#xpointer(1/1/1) _ _ x y).
26
27 notation "hvbox(\langle x break , y \rangle )" with precedence 89
28 for @{ 'pair $x $y}.
29
30 interpretation "Product" 'product x y =
31  (cic:/matita/datatypes/constructors/Prod.ind#xpointer(1/1) x y).
32
33 notation "hvbox(x break \times y)" with precedence 89
34 for @{ 'product $x $y}.
35
36 definition fst \def \lambda A,B:Type.\lambda p: Prod A B.
37 match p with
38 [(pair a b) \Rightarrow a]. 
39
40 definition snd \def \lambda A,B:Type.\lambda p: Prod A B.
41 match p with
42 [(pair a b) \Rightarrow b].
43
44 interpretation "First projection" 'fst x =
45  (cic:/matita/datatypes/constructors/fst.con _ _ x).
46
47 notation "\fst x" with precedence 89
48 for @{ 'fst $x}.
49
50 interpretation "Second projection" 'snd x =
51  (cic:/matita/datatypes/constructors/snd.con _ _ x).
52
53 notation "\snd x" with precedence 89
54 for @{ 'snd $x}.
55
56 theorem eq_pair_fst_snd: \forall A,B:Type.\forall p:Prod A B.
57 p = 〈 (\fst p), (\snd p) 〉.
58 intros.elim p.simplify.reflexivity.
59 qed.
60
61 inductive Sum (A,B:Type) : Type \def
62   inl : A \to Sum A B
63 | inr : B \to Sum A B.
64
65 interpretation "Disjoint union" 'plus A B =
66  (cic:/matita/datatypes/constructors/Sum.ind#xpointer(1/1) A B).
67
68 inductive option (A:Type) : Type ≝
69    None : option A
70  | Some : A → option A.