]> matita.cs.unibo.it Git - helm.git/blob - matita/library/datatypes/constructors.ma
tagged 0.5.0-rc1
[helm.git] / matita / library / datatypes / 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 set "baseuri" "cic:/matita/datatypes/constructors/".
16 include "logic/equality.ma".
17
18 inductive void : Set \def.
19
20 inductive unit : Set ≝ something: unit.
21
22 inductive Prod (A,B:Type) : Type \def
23 pair : A \to B \to Prod A B.
24
25 interpretation "Pair construction" 'pair x y =
26  (cic:/matita/datatypes/constructors/Prod.ind#xpointer(1/1/1) _ _ x y).
27
28 notation "hvbox(\langle x break , y \rangle )" with precedence 89
29 for @{ 'pair $x $y}.
30
31 interpretation "Product" 'product x y =
32  (cic:/matita/datatypes/constructors/Prod.ind#xpointer(1/1) x y).
33
34 notation "hvbox(x break \times y)" with precedence 89
35 for @{ 'product $x $y}.
36
37 definition fst \def \lambda A,B:Type.\lambda p: Prod A B.
38 match p with
39 [(pair a b) \Rightarrow a]. 
40
41 definition snd \def \lambda A,B:Type.\lambda p: Prod A B.
42 match p with
43 [(pair a b) \Rightarrow b].
44
45 interpretation "First projection" 'fst x =
46  (cic:/matita/datatypes/constructors/fst.con _ _ x).
47
48 notation "\fst x" with precedence 89
49 for @{ 'fst $x}.
50
51 interpretation "Second projection" 'snd x =
52  (cic:/matita/datatypes/constructors/snd.con _ _ x).
53
54 notation "\snd x" with precedence 89
55 for @{ 'snd $x}.
56
57 theorem eq_pair_fst_snd: \forall A,B:Type.\forall p:Prod A B.
58 p = 〈 (\fst p), (\snd p) 〉.
59 intros.elim p.simplify.reflexivity.
60 qed.
61
62 inductive Sum (A,B:Type) : Type \def
63   inl : A \to Sum A B
64 | inr : B \to Sum A B.
65
66 interpretation "Disjoint union" 'plus A B =
67  (cic:/matita/datatypes/constructors/Sum.ind#xpointer(1/1) A B).
68
69 inductive option (A:Type) : Type ≝
70    None : option A
71  | Some : A → option A.