examples of arithmetic on the naturals
authorpaulson
Mon, 19 Jul 1999 15:32:14 +0200
changeset 7037 77d596a5ffae
parent 7036 895c7c1e56ba
child 7038 e01513f1390a
examples of arithmetic on the naturals
src/HOL/ex/BinEx.ML
--- a/src/HOL/ex/BinEx.ML	Mon Jul 19 15:31:42 1999 +0200
+++ b/src/HOL/ex/BinEx.ML	Mon Jul 19 15:32:14 1999 +0200
@@ -11,6 +11,8 @@
 
 set proof_timing;
 
+(**** The Integers ****)
+
 (*** Addition ***)
 
 Goal "(#13::int)  +  #19 = #32";
@@ -83,7 +85,7 @@
 result();
 
 
-(*** Division and Remainder ***)
+(*** Quotient and Remainder ***)
 
 Goal "(#10::int) div #3 = #3";
 by (Simp_tac 1);
@@ -141,6 +143,114 @@
 result();
 
 
+(** division by shifting **)
+
+Goal "#10000000 div #2 = (#5000000::int)";
+by (Simp_tac 1);
+result();
+
+Goal "#10000001 mod #2 = (#1::int)";
+by (Simp_tac 1);
+result();
+
+Goal "#10000055 div #32 = (#312501::int)";
+by (Simp_tac 1);
+
+Goal "#10000055 mod #32 = (#23::int)";
+by (Simp_tac 1);
+
+Goal "#100094 div #144 = (#695::int)";
+by (Simp_tac 1);
+result();
+
+Goal "#100094 mod #144 = (#14::int)";
+by (Simp_tac 1);
+result();
+
+
+
+(**** The Natural Numbers ****)
+
+(** Successor **)
+
+Goal "Suc #99999 = #100000";
+by (asm_simp_tac (simpset() addsimps [Suc_nat_number_of]) 1);
+	(*not a default rewrite since sometimes we want to have Suc(#nnn)*)
+result();
+
+
+(** Addition **)
+
+Goal "(#13::nat)  +  #19 = #32";
+by (Simp_tac 1);
+result();
+
+Goal "(#1234::nat)  +  #5678 = #6912";
+by (Simp_tac 1);
+result();
+
+Goal "(#973646::nat) +  #6475 = #980121";
+by (Simp_tac 1);
+result();
+
+
+(** Subtraction **)
+
+Goal "(#32::nat)  -  #14 = #18";
+by (Simp_tac 1);
+result();
+
+Goal "(#14::nat)  -  #15 = #0";
+by (Simp_tac 1);
+result();
+
+Goal "(#14::nat)  -  #1576644 = #0";
+by (Simp_tac 1);
+result();
+
+Goal "(#48273776::nat)  -  #3873737 = #44400039";
+by (Simp_tac 1);
+result();
+
+
+(** Multiplication **)
+
+Goal "(#12::nat) * #11 = #132";
+by (Simp_tac 1);
+result();
+
+Goal "(#647::nat) * #3643 = #2357021";
+by (Simp_tac 1);
+result();
+
+
+(** Quotient and Remainder **)
+
+Goal "(#10::nat) div #3 = #3";
+by (Simp_tac 1);
+result();
+
+Goal "(#10::nat) mod #3 = #1";
+by (Simp_tac 1);
+result();
+
+Goal "(#10000::nat) div #9 = #1111";
+by (Simp_tac 1);
+result();
+
+Goal "(#10000::nat) mod #9 = #1";
+by (Simp_tac 1);
+result();
+
+Goal "(#10000::nat) div #16 = #625";
+by (Simp_tac 1);
+result();
+
+Goal "(#10000::nat) mod #16 = #0";
+by (Simp_tac 1);
+result();
+
+
 (*** Testing the cancellation of complementary terms ***)
 
 Goal "y + (x + -x) = (#0::int) + y";