]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/contribs/ng_assembly/freescale/nat.ma
freescale porting, work in progress
[helm.git] / helm / software / matita / contribs / ng_assembly / freescale / nat.ma
index 1b5f5f46a30a200f308bdacc7a512f5a4fc35286..4753b4cac745c482654b4547ed63bae7c15bfe64 100755 (executable)
 (**************************************************************************)
 
 (* ********************************************************************** *)
-(*                           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,15 +37,6 @@ 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 ]
@@ -76,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).