1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 (* ********************************************************************** *)
16 (* Progetto FreeScale *)
18 (* Sviluppato da: Ing. Cosimo Oliboni, oliboni@cs.unibo.it *)
19 (* Ultima modifica: 05/08/2009 *)
21 (* ********************************************************************** *)
23 include "num/bool.ma".
29 ninductive nat : Type ≝
34 interpretation "Natural numbers" 'N = nat.
36 default "natural numbers" cic:/matita/common/nat/nat.ind.
38 alias num (instance 0) = "natural number".
41 nlet rec eq_nat (n1,n2:nat) on n1 ≝
43 [ O ⇒ match n2 with [ O ⇒ true | S _ ⇒ false ]
44 | S n1' ⇒ match n2 with [ O ⇒ false | S n2' ⇒ eq_nat n1' n2' ]
50 | (S p) ⇒ match m with
51 [ O ⇒ false | (S q) ⇒ le_nat p q ]
54 interpretation "natural 'less or equal to'" 'leq x y = (le_nat x y).
56 ndefinition lt_nat ≝ λn1,n2:nat.(le_nat n1 n2) ⊗ (⊖ (eq_nat n1 n2)).
58 interpretation "natural 'less than'" 'lt x y = (lt_nat x y).
60 ndefinition ge_nat ≝ λn1,n2:nat.(⊖ (le_nat n1 n2)) ⊕ (eq_nat n1 n2).
62 interpretation "natural 'greater or equal to'" 'geq x y = (ge_nat x y).
64 ndefinition gt_nat ≝ λn1,n2:nat.⊖ (le_nat n1 n2).
66 interpretation "natural 'greater than'" 'gt x y = (gt_nat x y).
68 nlet rec plus (n1,n2:nat) on n1 ≝
71 | (S n1') ⇒ S (plus n1' n2) ].
73 interpretation "natural plus" 'plus x y = (plus x y).
75 nlet rec times (n1,n2:nat) on n1 ≝
78 | (S n1') ⇒ n2 + (times n1' n2) ].
80 interpretation "natural times" 'times x y = (times x y).
88 | (S q) ⇒ minus p q ]].
90 interpretation "natural minus" 'minus x y = (minus x y).
92 nlet rec div_aux p m n : nat ≝
93 match (le_nat m n) with
98 | (S q) ⇒ S (div_aux q (m-(S n)) n)]].
100 ndefinition div : nat → nat → nat ≝
103 | (S p) ⇒ div_aux n n p].
105 interpretation "natural divide" 'divide x y = (div x y).