src/ZF/ex/BinEx.thy
author wenzelm
Sun, 05 Jan 2025 13:24:17 +0100
changeset 81726 27ba0fed2071
parent 81122 84e459f09198
permissions -rw-r--r--
tuned NEWS;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35762
af3ff2ba4c54 removed old CVS Ids;
wenzelm
parents: 16417
diff changeset
     1
(*  Title:      ZF/ex/BinEx.thy
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     3
    Copyright   1994  University of Cambridge
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     4
35762
af3ff2ba4c54 removed old CVS Ids;
wenzelm
parents: 16417
diff changeset
     5
Examples of performing binary arithmetic by simplification.
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     6
*)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     7
65449
c82e63b11b8b clarified main ZF.thy / ZFC.thy, and avoid name clash with global HOL/Main.thy;
wenzelm
parents: 61395
diff changeset
     8
theory BinEx imports ZF begin
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
     9
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    10
lemma "#13  $+  #19 = #32"
81122
84e459f09198 tuned comments: all times are < 1ms;
wenzelm
parents: 76213
diff changeset
    11
by simp
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    12
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    13
lemma "#1234  $+  #5678 = #6912"
81122
84e459f09198 tuned comments: all times are < 1ms;
wenzelm
parents: 76213
diff changeset
    14
by simp
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    15
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    16
lemma "#1359  $+  #-2468 = #-1109"
81122
84e459f09198 tuned comments: all times are < 1ms;
wenzelm
parents: 76213
diff changeset
    17
by simp
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    18
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    19
lemma "#93746  $+  #-46375 = #47371"
81122
84e459f09198 tuned comments: all times are < 1ms;
wenzelm
parents: 76213
diff changeset
    20
by simp
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    21
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    22
lemma "$- #65745 = #-65745"
81122
84e459f09198 tuned comments: all times are < 1ms;
wenzelm
parents: 76213
diff changeset
    23
by simp
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    24
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    25
lemma "$- #-54321 = #54321"
81122
84e459f09198 tuned comments: all times are < 1ms;
wenzelm
parents: 76213
diff changeset
    26
by simp
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    27
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    28
lemma "#13  $*  #19 = #247"
81122
84e459f09198 tuned comments: all times are < 1ms;
wenzelm
parents: 76213
diff changeset
    29
by simp
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    30
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    31
lemma "#-84  $*  #51 = #-4284"
81122
84e459f09198 tuned comments: all times are < 1ms;
wenzelm
parents: 76213
diff changeset
    32
by simp
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    33
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    34
(*The worst case for 8-bit operands *)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    35
lemma "#255  $*  #255 = #65025"
81122
84e459f09198 tuned comments: all times are < 1ms;
wenzelm
parents: 76213
diff changeset
    36
by simp
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    37
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    38
lemma "#1359  $*  #-2468 = #-3354012"
81122
84e459f09198 tuned comments: all times are < 1ms;
wenzelm
parents: 76213
diff changeset
    39
by simp
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    40
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    41
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    42
(** Comparisons **)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    43
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    44
lemma "(#89) $* #10 \<noteq> #889"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    45
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    46
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    47
lemma "(#13) $< #18 $- #4"
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 "(#-345) $< #-242 $+ #-100"
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 "(#13557456) $< #18678654"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    54
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    55
61395
4f8c2c4a0a8c tuned syntax -- more symbols;
wenzelm
parents: 35762
diff changeset
    56
lemma "(#999999) $\<le> (#1000001 $+ #1) $- #2"
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    57
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    58
61395
4f8c2c4a0a8c tuned syntax -- more symbols;
wenzelm
parents: 35762
diff changeset
    59
lemma "(#1234567) $\<le> #1234567"
11399
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
81122
84e459f09198 tuned comments: all times are < 1ms;
wenzelm
parents: 76213
diff changeset
    63
(*** Quotient and remainder [they could be faster] ***)
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    64
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    65
lemma "#23 zdiv #3 = #7"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    66
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    67
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    68
lemma "#23 zmod #3 = #2"
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
(** negative dividend **)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    72
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    73
lemma "#-23 zdiv #3 = #-8"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    74
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    75
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    76
lemma "#-23 zmod #3 = #1"
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
(** negative divisor **)
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    80
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    81
lemma "#23 zdiv #-3 = #-8"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    82
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    83
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    84
lemma "#23 zmod #-3 = #-1"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    85
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    86
81122
84e459f09198 tuned comments: all times are < 1ms;
wenzelm
parents: 76213
diff changeset
    87
(** negative dividend and divisor **)
11399
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    88
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    89
lemma "#-23 zdiv #-3 = #7"
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    90
by simp
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    91
1605aeb98fd5 two Isar tactic scripts
paulson
parents:
diff changeset
    92
lemma "#-23 zmod #-3 = #-2"
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
end