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: Cosimo Oliboni, oliboni@cs.unibo.it *)
19 (* Cosimo Oliboni, oliboni@cs.unibo.it *)
21 (* ********************************************************************** *)
23 include "num/bool.ma".
29 inductive nat : Type ≝
33 interpretation "Natural numbers" 'N = nat.
35 default "natural numbers" cic:/matita/common/nat/nat.ind.
37 alias num (instance 0) = "natural number".
39 nlet rec eq_nat (n1,n2:nat) on n1 ≝
41 [ O ⇒ match n2 with [ O ⇒ true | S _ ⇒ false ]
42 | S n1' ⇒ match n2 with [ O ⇒ false | S n2' ⇒ eq_nat n1' n2' ]
48 | (S p) ⇒ match m with
49 [ O ⇒ false | (S q) ⇒ le_nat p q ]
52 nlet rec plus (n1,n2:nat) on n1 ≝
55 | (S n1') ⇒ S (plus n1' n2) ].
57 interpretation "natural plus" 'plus x y = (plus x y).
59 nlet rec times (n1,n2:nat) on n1 ≝
62 | (S n1') ⇒ n2 + (times n1' n2) ].
64 interpretation "natural times" 'times x y = (times x y).
72 | (S q) ⇒ minus p q ]].
74 interpretation "natural minus" 'minus x y = (minus x y).
76 nlet rec div_aux p m n : nat ≝
77 match (le_nat m n) with
82 | (S q) ⇒ S (div_aux q (m-(S n)) n)]].
84 ndefinition div : nat → nat → nat ≝
87 | (S p) ⇒ div_aux n n p].
89 interpretation "natural divide" 'divide x y = (div x y).