]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/ng_assembly/common/option.ma
62da6590013f8edc1d5c9518904ccb96a8ae4ac0
[helm.git] / helm / software / matita / contribs / ng_assembly / common / option.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 (* ********************************************************************** *)
16 (*                          Progetto FreeScale                            *)
17 (*                                                                        *)
18 (*   Sviluppato da: Ing. Cosimo Oliboni, oliboni@cs.unibo.it              *)
19 (*   Sviluppo: 2008-2010                                                  *)
20 (*                                                                        *)
21 (* ********************************************************************** *)
22
23 include "num/bool.ma".
24
25 (* ****** *)
26 (* OPTION *)
27 (* ****** *)
28
29 ninductive option (A:Type) : Type ≝
30   None : option A
31 | Some : A → option A.
32
33 ndefinition eq_option ≝
34 λT.λf:T → T → bool.λop1,op2:option T.
35  match op1 with
36   [ None ⇒ match op2 with [ None ⇒ true | Some _ ⇒ false ]
37   | Some x1 ⇒ match op2 with [ None ⇒ false | Some x2 ⇒ f x1 x2 ]
38   ].
39
40 (* option map = match ... with [ None ⇒ None ? | Some .. ⇒ .. ] *)
41 ndefinition opt_map ≝
42 λT1,T2:Type.λt:option T1.λf:T1 → option T2.
43  match t with [ None ⇒ None ? | Some x ⇒ (f x) ].