X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2Fcontribs%2Fng_assembly%2Ffreescale%2Fnat.ma;h=aacc7b1dd26f3d0d398751ee25ba661ccaa854e7;hb=ee9a771a3cf2124ef65906ae75eb0ba7e2e4303b;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..aacc7b1dd 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". @@ -56,6 +52,13 @@ nlet rec eq_nat (n1,n2:nat) on n1 ≝ | 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 +72,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).