X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2Fcontribs%2Fng_assembly%2Ffreescale%2Foption.ma;fp=helm%2Fsoftware%2Fmatita%2Fcontribs%2Fng_assembly%2Ffreescale%2Foption.ma;h=2041a2a556a2d87957766fb1d224375f0913f2e8;hb=55274856efac172aba293d4216fdc659d07a89d7;hp=0000000000000000000000000000000000000000;hpb=5e3174ab11d8a4e4779d561cd48227a050a0d1a2;p=helm.git 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 index 000000000..2041a2a55 --- /dev/null +++ b/helm/software/matita/contribs/ng_assembly/freescale/option.ma @@ -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) ].