X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2Fcontribs%2Fng_assembly%2Ffreescale%2Fnat.ma;h=4753b4cac745c482654b4547ed63bae7c15bfe64;hb=633b66b935bbc2c38a5abc2be958359335123258;hp=cff29e3c32ad53b176126457446bccd9010bebf7;hpb=55274856efac172aba293d4216fdc659d07a89d7;p=helm.git diff --git a/helm/software/matita/contribs/ng_assembly/freescale/nat.ma b/helm/software/matita/contribs/ng_assembly/freescale/nat.ma index cff29e3c3..4753b4cac 100755 --- a/helm/software/matita/contribs/ng_assembly/freescale/nat.ma +++ b/helm/software/matita/contribs/ng_assembly/freescale/nat.ma @@ -13,15 +13,11 @@ (**************************************************************************) (* ********************************************************************** *) -(* Progetto FreeScale *) +(* Progetto FreeScale *) (* *) -(* Sviluppato da: *) -(* Cosimo Oliboni, oliboni@cs.unibo.it *) +(* Sviluppato da: Cosimo Oliboni, oliboni@cs.unibo.it *) +(* 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/pts.ma". @@ -41,21 +37,19 @@ default "natural numbers" cic:/matita/freescale/nat/nat.ind. alias num (instance 0) = "natural number". -nlet rec nat_ind (P:nat → Prop) (p:P O) (f:Πn:nat.P n → P (S n)) (n:nat) on n : P n ≝ - match n with [ O ⇒ p | S (n1:nat) ⇒ f n1 (nat_ind P p f n1) ]. - -nlet rec nat_rec (P:nat → Set) (p:P O) (f:Πn:nat.P n → P (S n)) (n:nat) on n : P n ≝ - match n with [ O ⇒ p | S (n1:nat) ⇒ f n1 (nat_rec P p f n1) ]. - -nlet rec nat_rect (P:nat → Type) (p:P O) (f:Πn:nat.P n → P (S n)) (n:nat) on n : P n ≝ - match n with [ O ⇒ p | S (n1:nat) ⇒ f n1 (nat_rect P p f n1) ]. - nlet rec eq_nat (n1,n2:nat) on n1 ≝ match n1 with [ O ⇒ match n2 with [ O ⇒ true | S _ ⇒ false ] | S n1' ⇒ match n2 with [ O ⇒ false | S n2' ⇒ eq_nat n1' n2' ] ]. +nlet rec le_nat n m ≝ + match n with + [ O ⇒ true + | (S p) ⇒ match m with + [ O ⇒ false | (S q) ⇒ le_nat p q ] + ]. + nlet rec plus (n1,n2:nat) on n1 ≝ match n1 with [ O ⇒ n2 @@ -69,3 +63,28 @@ nlet rec times (n1,n2:nat) on n1 ≝ | (S n1') ⇒ n2 + (times n1' n2) ]. interpretation "natural times" 'times x y = (times x y). + +nlet rec minus n m ≝ + match n with + [ O ⇒ O + | (S p) ⇒ + match m with + [O ⇒ (S p) + | (S q) ⇒ minus p q ]]. + +interpretation "natural minus" 'minus x y = (minus x y). + +nlet rec div_aux p m n : nat ≝ +match (le_nat m n) with +[ true ⇒ O +| false ⇒ + match p with + [ O ⇒ O + | (S q) ⇒ S (div_aux q (m-(S n)) n)]]. + +ndefinition div : nat → nat → nat ≝ +λn,m.match m with + [ O ⇒ S n + | (S p) ⇒ div_aux n n p]. + +interpretation "natural divide" 'divide x y = (div x y).