src/ZF/ex/BinEx.ML
changeset 11315 fbca0f74bcef
parent 9570 e16e168984e1
equal deleted inserted replaced
11314:f6eebbbed449 11315:fbca0f74bcef
     4     Copyright   1994  University of Cambridge
     4     Copyright   1994  University of Cambridge
     5 
     5 
     6 Examples of performing binary arithmetic by simplification
     6 Examples of performing binary arithmetic by simplification
     7 *)
     7 *)
     8 
     8 
     9 context Bin.thy;
     9 context Main.thy;
    10 
    10 
    11 (*All runtimes below are on a 300MHz Pentium*)
    11 (*All runtimes below are on a 300MHz Pentium*)
    12 
    12 
    13 Goal "#13  $+  #19 = #32";
    13 Goal "#13  $+  #19 = #32";
    14 by (Simp_tac 1);    (*0 secs*)
    14 by (Simp_tac 1);    (*0 secs*)
    53 result();
    53 result();
    54 
    54 
    55 
    55 
    56 (** Comparisons **)
    56 (** Comparisons **)
    57 
    57 
    58 Goal "(#89) $* #10 ~= #889";  
    58 Goal "(#89) $* #10 \\<noteq> #889";  
    59 by (Simp_tac 1); 
    59 by (Simp_tac 1); 
    60 result();
    60 result();
    61 
    61 
    62 Goal "(#13) $< #18 $- #4";  
    62 Goal "(#13) $< #18 $- #4";  
    63 by (Simp_tac 1); 
    63 by (Simp_tac 1); 
    76 result();
    76 result();
    77 
    77 
    78 Goal "(#1234567) $<= #1234567";  
    78 Goal "(#1234567) $<= #1234567";  
    79 by (Simp_tac 1); 
    79 by (Simp_tac 1); 
    80 result();
    80 result();
       
    81 
       
    82 
       
    83 (*** Quotient and remainder!! [they could be faster] ***)
       
    84 
       
    85 Goal "#23 zdiv #3 = #7";
       
    86 by (Simp_tac 1); 
       
    87 result();
       
    88 
       
    89 Goal "#23 zmod #3 = #2";
       
    90 by (Simp_tac 1); 
       
    91 result();
       
    92 
       
    93 (** negative dividend **)
       
    94 
       
    95 Goal "#-23 zdiv #3 = #-8";
       
    96 by (Simp_tac 1); 
       
    97 result();
       
    98 
       
    99 Goal "#-23 zmod #3 = #1";
       
   100 by (Simp_tac 1); 
       
   101 result();
       
   102 
       
   103 (** negative divisor **)
       
   104 
       
   105 Goal "#23 zdiv #-3 = #-8";
       
   106 by (Simp_tac 1); 
       
   107 result();
       
   108 
       
   109 Goal "#23 zmod #-3 = #-1";
       
   110 by (Simp_tac 1); 
       
   111 result();
       
   112 
       
   113 (** Negative dividend and divisor **)
       
   114 
       
   115 Goal "#-23 zdiv #-3 = #7";
       
   116 by (Simp_tac 1); 
       
   117 result();
       
   118 
       
   119 Goal "#-23 zmod #-3 = #-2";
       
   120 by (Simp_tac 1); 
       
   121 result();
       
   122