]> matita.cs.unibo.it Git - helm.git/commitdiff
div and mod notation ('%' and '\mod')
authorStefano Zacchiroli <zack@upsilon.cc>
Mon, 26 Sep 2005 16:23:19 +0000 (16:23 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Mon, 26 Sep 2005 16:23:19 +0000 (16:23 +0000)
helm/matita/core_notation.moo
helm/matita/library/nat/div_and_mod.ma

index 449108cd9f9175d8703e8e99cdf1aa358e6d6f96..c30e5142c08d6380890a4d6b6e7b955636238542 100644 (file)
@@ -66,7 +66,7 @@ notation "hvbox(a break * b)"
   left associative with precedence 55
 for @{ 'times $a $b }.
 
-notation "hvbox(a break % b)" 
+notation "hvbox(a break \mod b)" 
   left associative with precedence 55
 for @{ 'module $a $b }.
 
index af5ee9808ea6556976ceb6a9ec392f63d50cd06e..520e99ea8f1e7a7d58f0a964fdd9021076b17938 100644 (file)
@@ -1,5 +1,5 @@
 (**************************************************************************)
-(*       ___                                                               *)
+(*       ___                                                             *)
 (*      ||M||                                                             *)
 (*      ||A||       A project by Andrea Asperti                           *)
 (*      ||T||                                                             *)
@@ -30,6 +30,9 @@ match m with
 [O \Rightarrow m
 | (S p) \Rightarrow mod_aux n n p]. 
 
+interpretation "natural remainder" 'module x y =
+  (cic:/matita/nat/div_and_mod/mod.con x y).
+
 let rec div_aux p m n : nat \def
 match (leb m n) with
 [ true \Rightarrow O
@@ -44,6 +47,9 @@ match m with
 [O \Rightarrow S n
 | (S p) \Rightarrow div_aux n n p]. 
 
+interpretation "natural divide" 'divide x y =
+  (cic:/matita/nat/div_and_mod/div.con x y).
+
 theorem le_mod_aux_m_m: 
 \forall p,n,m. n \leq p \to (mod_aux p n m) \leq m.
 intro.elim p.
@@ -61,7 +67,7 @@ simplify.apply trans_le ? n2 n.
 apply le_minus_m.apply le_S_S_to_le.assumption.
 qed.
 
-theorem lt_mod_m_m: \forall n,m. O < m \to (mod n m) < m.
+theorem lt_mod_m_m: \forall n,m. O < m \to (n \mod m) < m.
 intros 2.elim m.apply False_ind.
 apply not_le_Sn_O O H.
 simplify.apply le_S_S.apply le_mod_aux_m_m.
@@ -87,7 +93,7 @@ change with m < n1.
 apply not_le_to_lt.exact H1.
 qed.
 
-theorem div_mod: \forall n,m:nat. O < m \to n=(div n m)*m+(mod n m).
+theorem div_mod: \forall n,m:nat. O < m \to n=(n / m)*m+(n \mod m).
 intros 2.elim m.elim (not_le_Sn_O O H).
 simplify.
 apply div_aux_mod_aux.
@@ -108,7 +114,7 @@ exact not_le_Sn_O r.
 qed.
 
 theorem div_mod_spec_div_mod: 
-\forall n,m. O < m \to (div_mod_spec n m (div n m) (mod n m)).
+\forall n,m. O < m \to (div_mod_spec n m (n / m) (n \mod m)).
 intros.
 apply div_mod_spec_intro.
 apply lt_mod_m_m.assumption.
@@ -189,7 +195,7 @@ rewrite < plus_n_O.rewrite < sym_times.reflexivity.
 qed.
 
 (* some properties of div and mod *)
-theorem div_times: \forall n,m:nat. div ((S n)*m) (S n) = m.
+theorem div_times: \forall n,m:nat. ((S n)*m) / (S n) = m.
 intros.
 apply div_mod_spec_to_eq ((S n)*m) (S n) ? ? ? O.
 goal 15. (* ?11 is closed with the following tactics *)
@@ -198,26 +204,26 @@ simplify.apply le_S_S.apply le_O_n.
 apply div_mod_spec_times.
 qed.
 
-theorem div_n_n: \forall n:nat. O < n \to div n n = S O.
+theorem div_n_n: \forall n:nat. O < n \to n / n = S O.
 intros.
-apply div_mod_spec_to_eq n n (div n n) (mod n n) (S O) O.
+apply div_mod_spec_to_eq n n (n / n) (n \mod n) (S O) O.
 apply div_mod_spec_div_mod.assumption.
 constructor 1.assumption.
 rewrite < plus_n_O.simplify.rewrite < plus_n_O.reflexivity.
 qed.
 
-theorem mod_n_n: \forall n:nat. O < n \to mod n n = O.
+theorem mod_n_n: \forall n:nat. O < n \to n \mod n = O.
 intros.
-apply div_mod_spec_to_eq2 n n (div n n) (mod n n) (S O) O.
+apply div_mod_spec_to_eq2 n n (n / n) (n \mod n) (S O) O.
 apply div_mod_spec_div_mod.assumption.
 constructor 1.assumption.
 rewrite < plus_n_O.simplify.rewrite < plus_n_O.reflexivity.
 qed.
 
-theorem mod_S: \forall n,m:nat. O < m \to S (mod n m) < m \to 
-(mod (S n) m) = S (mod n m).
+theorem mod_S: \forall n,m:nat. O < m \to S (n \mod m) < m \to 
+((S n) \mod m) = S (n \mod m).
 intros.
-apply div_mod_spec_to_eq2 (S n) m (div (S n) m) (mod (S n) m) (div n m) (S (mod n m)).
+apply div_mod_spec_to_eq2 (S n) m ((S n) / m) ((S n) \mod m) (n / m) (S (n \mod m)).
 apply div_mod_spec_div_mod.assumption.
 constructor 1.assumption.rewrite < plus_n_Sm.
 apply eq_f.
@@ -225,7 +231,7 @@ apply div_mod.
 assumption.
 qed.
 
-theorem mod_O_n: \forall n:nat.mod O n = O.
+theorem mod_O_n: \forall n:nat.O \mod n = O.
 intro.elim n.simplify.reflexivity.
 simplify.reflexivity.
 qed.