src/ZF/ex/BinEx.thy
author haftmann
Fri, 17 Jun 2005 16:12:49 +0200
changeset 16417 9bc16273c2d4
parent 11399 1605aeb98fd5
child 35762 af3ff2ba4c54
permissions -rw-r--r--
migrated theory headers to new format
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     1
(*  Title:      ZF/ex/BinEx.ML
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     2
    ID:         $Id$
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     4
    Copyright   1994  University of Cambridge
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     5
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     6
Examples of performing binary arithmetic by simplification
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     7
*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     8
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 11399
diff changeset
     9
theory BinEx imports Main begin
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    10
(*All runtimes below are on a 300MHz Pentium*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    11
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    12
lemma "#13  $+  #19 = #32"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    13
by simp (*0 secs*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    14
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    15
lemma "#1234  $+  #5678 = #6912"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    16
by simp (*190 msec*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    17
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    18
lemma "#1359  $+  #-2468 = #-1109"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    19
by simp (*160 msec*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    20
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    21
lemma "#93746  $+  #-46375 = #47371"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    22
by simp (*300 msec*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    23
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    24
lemma "$- #65745 = #-65745"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    25
by simp (*80 msec*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    26
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    27
(* negation of ~54321 *)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    28
lemma "$- #-54321 = #54321"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    29
by simp (*90 msec*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    30
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    31
lemma "#13  $*  #19 = #247"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    32
by simp (*110 msec*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    33
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    34
lemma "#-84  $*  #51 = #-4284"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    35
by simp (*210 msec*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    36
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    37
(*The worst case for 8-bit operands *)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    38
lemma "#255  $*  #255 = #65025"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    39
by simp (*730 msec*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    40
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    41
lemma "#1359  $*  #-2468 = #-3354012"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    42
by simp (*1.04 secs*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    43
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    44
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    45
(** Comparisons **)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    46
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    47
lemma "(#89) $* #10 \<noteq> #889"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    48
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    49
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    50
lemma "(#13) $< #18 $- #4"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    51
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    52
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    53
lemma "(#-345) $< #-242 $+ #-100"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    54
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    55
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    56
lemma "(#13557456) $< #18678654"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    57
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    58
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    59
lemma "(#999999) $<= (#1000001 $+ #1) $- #2"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    60
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    61
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    62
lemma "(#1234567) $<= #1234567"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    63
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    64
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    65
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    66
(*** Quotient and remainder!! [they could be faster] ***)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    67
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    68
lemma "#23 zdiv #3 = #7"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    69
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    70
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    71
lemma "#23 zmod #3 = #2"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    72
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    73
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    74
(** negative dividend **)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    75
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    76
lemma "#-23 zdiv #3 = #-8"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    77
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    78
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    79
lemma "#-23 zmod #3 = #1"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    80
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    81
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    82
(** negative divisor **)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    83
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    84
lemma "#23 zdiv #-3 = #-8"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    85
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    86
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    87
lemma "#23 zmod #-3 = #-1"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    88
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    89
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    90
(** Negative dividend and divisor **)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    91
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    92
lemma "#-23 zdiv #-3 = #7"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    93
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    94
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    95
lemma "#-23 zmod #-3 = #-2"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    96
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    97
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    98
end
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    99