]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/contribs/ng_assembly/freescale/option.ma
new ng freescale, no external dependencies
[helm.git] / helm / software / matita / contribs / ng_assembly / freescale / option.ma
diff --git a/helm/software/matita/contribs/ng_assembly/freescale/option.ma b/helm/software/matita/contribs/ng_assembly/freescale/option.ma
new file mode 100644 (file)
index 0000000..2041a2a
--- /dev/null
@@ -0,0 +1,59 @@
+(**************************************************************************)
+(*       ___                                                              *)
+(*      ||M||                                                             *)
+(*      ||A||       A project by Andrea Asperti                           *)
+(*      ||T||                                                             *)
+(*      ||I||       Developers:                                           *)
+(*      ||T||         The HELM team.                                      *)
+(*      ||A||         http://helm.cs.unibo.it                             *)
+(*      \   /                                                             *)
+(*       \ /        This file is distributed under the terms of the       *)
+(*        v         GNU General Public License Version 2                  *)
+(*                                                                        *)
+(**************************************************************************)
+
+(* ********************************************************************** *)
+(*                           Progetto FreeScale                           *)
+(*                                                                        *)
+(* Sviluppato da:                                                         *)
+(*   Cosimo Oliboni, oliboni@cs.unibo.it                                  *)
+(*                                                                        *)
+(* Questo materiale fa parte della tesi:                                  *)
+(*   "Formalizzazione Interattiva dei Microcontroller a 8bit FreeScale"   *)
+(*                                                                        *)
+(*                    data ultima modifica 15/11/2007                     *)
+(* ********************************************************************** *)
+
+include "freescale/bool.ma".
+
+(* ****** *)
+(* OPTION *)
+(* ****** *)
+
+ninductive option (A:Type) : Type ≝
+  None : option A
+| Some : A → option A.
+
+ndefinition option_ind : ΠA:Type.ΠP:option A → Prop.P (None A) → (Πa:A.P (Some A a)) → Πo:option A.P o ≝
+λA:Type.λP:option A → Prop.λp:P (None A).λf:Πa:A.P (Some A a).λo:option A.
+ match o with [ None ⇒ p | Some (a:A) ⇒ f a ].
+
+ndefinition option_rec : ΠA:Type.ΠP:option A → Set.P (None A) → (Πa:A.P (Some A a)) → Πo:option A.P o ≝
+λA:Type.λP:option A → Set.λp:P (None A).λf:Πa:A.P (Some A a).λo:option A.
+ match o with [ None ⇒ p | Some (a:A) ⇒ f a ].
+
+ndefinition option_rect : ΠA:Type.ΠP:option A → Type.P (None A) → (Πa:A.P (Some A a)) → Πo:option A.P o ≝
+λA:Type.λP:option A → Type.λp:P (None A).λf:Πa:A.P (Some A a).λo:option A.
+ match o with [ None ⇒ p | Some (a:A) ⇒ f a ].
+
+ndefinition eq_option ≝
+λT.λo1,o2:option T.λf:T → T → bool.
+ match o1 with
+  [ None ⇒ match o2 with [ None ⇒ true | Some _ ⇒ false ]
+  | Some x1 ⇒ match o2 with [ None ⇒ false | Some x2 ⇒ f x1 x2 ]
+  ].
+
+(* option map = match ... with [ None ⇒ None ? | Some .. ⇒ .. ] *)
+ndefinition opt_map ≝
+λT1,T2:Type.λt:option T1.λf:T1 → option T2.
+ match t with [ None ⇒ None ? | Some x ⇒ (f x) ].