author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Wed, 09 Dec 2009 15:57:47 +0100 | |
changeset 663 | 0dd10a900cae |
parent 654 | 02fd9de9d45e |
child 672 | c63685837706 |
permissions | -rw-r--r-- |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
theory IntEx2 |
597
8a1c8dc72b5c
directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
588
diff
changeset
|
2 |
imports "../QuotMain" |
604
0cf166548856
isabelle make tests all examples
Christian Urban <urbanc@in.tum.de>
parents:
601
diff
changeset
|
3 |
(*uses |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
("Tools/numeral.ML") |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
("Tools/numeral_syntax.ML") |
604
0cf166548856
isabelle make tests all examples
Christian Urban <urbanc@in.tum.de>
parents:
601
diff
changeset
|
6 |
("Tools/int_arith.ML")*) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
7 |
begin |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
|
578
070161f1996a
updated Isabelle and deleted mono rules
Christian Urban <urbanc@in.tum.de>
parents:
570
diff
changeset
|
9 |
|
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
fun |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
intrel :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool" (infix "\<approx>" 50) |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
12 |
where |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
"intrel (x, y) (u, v) = (x + v = u + y)" |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
quotient int = "nat \<times> nat" / intrel |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
apply(unfold equivp_def) |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
17 |
apply(auto simp add: mem_def expand_fun_eq) |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
18 |
done |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
19 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
20 |
instantiation int :: "{zero, one, plus, minus, uminus, times, ord, abs, sgn}" |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
21 |
begin |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
22 |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
23 |
quotient_def |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
24 |
zero_int::"0 :: int" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
25 |
where |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
26 |
"(0::nat, 0::nat)" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
27 |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
28 |
thm zero_int_def |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
29 |
|
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
30 |
quotient_def |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
31 |
one_int::"1 :: int" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
32 |
where |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
33 |
"(1::nat, 0::nat)" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
34 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
35 |
fun |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
36 |
plus_raw :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> (nat \<times> nat)" |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
37 |
where |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
38 |
"plus_raw (x, y) (u, v) = (x + u, y + v)" |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
39 |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
40 |
quotient_def |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
41 |
plus_int::"(op +) :: (int \<Rightarrow> int \<Rightarrow> int)" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
42 |
where |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
43 |
"plus_raw" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
45 |
fun |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
minus_raw :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat)" |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
47 |
where |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
"minus_raw (x, y) = (y, x)" |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
49 |
|
579
eac2662a21ec
Solved all quotient goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
570
diff
changeset
|
50 |
quotient_def |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
51 |
uminus_int::"(uminus :: (int \<Rightarrow> int))" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
52 |
where |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
53 |
"minus_raw" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
54 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
55 |
definition |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
56 |
minus_int_def [code del]: "z - w = z + (-w::int)" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
57 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
58 |
fun |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
59 |
times_raw :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> (nat \<times> nat)" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
60 |
where |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
61 |
"times_raw (x, y) (u, v) = (x*u + y*v, x*v + y*u)" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
62 |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
63 |
quotient_def |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
64 |
times_int::"(op *) :: (int \<Rightarrow> int \<Rightarrow> int)" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
65 |
where |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
66 |
"times_raw" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
67 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
68 |
fun |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
69 |
less_eq_raw :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
70 |
where |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
71 |
"less_eq_raw (x, y) (u, v) = (x+v \<le> u+y)" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
72 |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
73 |
quotient_def |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
74 |
less_eq_int :: "(op \<le>) :: int \<Rightarrow> int \<Rightarrow> bool" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
75 |
where |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
76 |
"less_eq_raw" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
77 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
78 |
definition |
570 | 79 |
less_int_def [code del]: "(z\<Colon>int) < w = (z \<le> w \<and> z \<noteq> w)" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
80 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
81 |
definition |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
82 |
abs_int_def: "\<bar>i\<Colon>int\<bar> = (if i < 0 then - i else i)" |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
83 |
|
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
84 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
85 |
definition |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
86 |
sgn_int_def: "sgn (i\<Colon>int) = (if i=0 then 0 else if 0<i then 1 else - 1)" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
87 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
88 |
instance .. |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
89 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
90 |
end |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
91 |
|
636
520a4084d064
changed names of attributes
Christian Urban <urbanc@in.tum.de>
parents:
610
diff
changeset
|
92 |
lemma plus_raw_rsp[quot_respect]: |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
93 |
shows "(op \<approx> ===> op \<approx> ===> op \<approx>) plus_raw plus_raw" |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
94 |
by auto |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
95 |
|
636
520a4084d064
changed names of attributes
Christian Urban <urbanc@in.tum.de>
parents:
610
diff
changeset
|
96 |
lemma minus_raw_rsp[quot_respect]: |
579
eac2662a21ec
Solved all quotient goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
570
diff
changeset
|
97 |
shows "(op \<approx> ===> op \<approx>) minus_raw minus_raw" |
eac2662a21ec
Solved all quotient goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
570
diff
changeset
|
98 |
by auto |
eac2662a21ec
Solved all quotient goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
570
diff
changeset
|
99 |
|
636
520a4084d064
changed names of attributes
Christian Urban <urbanc@in.tum.de>
parents:
610
diff
changeset
|
100 |
lemma mult_raw_rsp[quot_respect]: |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
101 |
shows "(op \<approx> ===> op \<approx> ===> op \<approx>) times_raw times_raw" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
102 |
apply(auto) |
600
5d932e7a856c
List moved after QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
597
diff
changeset
|
103 |
apply(simp add: algebra_simps) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
104 |
sorry |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
105 |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
106 |
lemma less_eq_raw_rsp[quot_respect]: |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
107 |
shows "(op \<approx> ===> op \<approx> ===> op =) less_eq_raw less_eq_raw" |
570 | 108 |
by auto |
109 |
||
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
110 |
lemma plus_assoc_raw: |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
111 |
shows "plus_raw (plus_raw i j) k \<approx> plus_raw i (plus_raw j k)" |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
112 |
by (cases i, cases j, cases k) (simp) |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
113 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
114 |
lemma plus_sym_raw: |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
115 |
shows "plus_raw i j \<approx> plus_raw j i" |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
116 |
by (cases i, cases j) (simp) |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
117 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
118 |
lemma plus_zero_raw: |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
119 |
shows "plus_raw (0, 0) i \<approx> i" |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
120 |
by (cases i) (simp) |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
121 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
122 |
lemma plus_minus_zero_raw: |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
123 |
shows "plus_raw (minus_raw i) i \<approx> (0, 0)" |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
124 |
by (cases i) (simp) |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
125 |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
126 |
lemma times_assoc_raw: |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
127 |
shows "times_raw (times_raw i j) k \<approx> times_raw i (times_raw j k)" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
128 |
by (cases i, cases j, cases k) |
600
5d932e7a856c
List moved after QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
597
diff
changeset
|
129 |
(simp add: algebra_simps) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
130 |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
131 |
lemma times_sym_raw: |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
132 |
shows "times_raw i j \<approx> times_raw j i" |
600
5d932e7a856c
List moved after QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
597
diff
changeset
|
133 |
by (cases i, cases j) (simp add: algebra_simps) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
134 |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
135 |
lemma times_one_raw: |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
136 |
shows "times_raw (1, 0) i \<approx> i" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
137 |
by (cases i) (simp) |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
138 |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
139 |
lemma times_plus_comm_raw: |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
140 |
shows "times_raw (plus_raw i j) k \<approx> plus_raw (times_raw i k) (times_raw j k)" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
141 |
by (cases i, cases j, cases k) |
600
5d932e7a856c
List moved after QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
597
diff
changeset
|
142 |
(simp add: algebra_simps) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
143 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
144 |
lemma one_zero_distinct: |
579
eac2662a21ec
Solved all quotient goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
570
diff
changeset
|
145 |
shows "\<not> (0, 0) \<approx> ((1::nat), (0::nat))" |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
146 |
by simp |
579
eac2662a21ec
Solved all quotient goals.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
570
diff
changeset
|
147 |
|
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
148 |
text{*The integers form a @{text comm_ring_1}*} |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
149 |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
150 |
print_quotconsts |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
151 |
ML {* qconsts_lookup @{theory} @{term "op + :: int \<Rightarrow> int \<Rightarrow> int"} *} |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
152 |
|
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
153 |
ML {* dest_Type (snd (dest_Const @{term "0 :: int"})) *} |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
154 |
ML {* @{term "0 :: int"} *} |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
155 |
|
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
156 |
thm plus_assoc_raw |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
157 |
|
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
158 |
instance int :: comm_ring_1 |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
159 |
proof |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
160 |
fix i j k :: int |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
161 |
show "(i + j) + k = i + (j + k)" |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
162 |
by (lifting plus_assoc_raw) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
163 |
show "i + j = j + i" |
654
02fd9de9d45e
tuned the examples and flagged the problematic cleaning lemmas in FSet
Christian Urban <urbanc@in.tum.de>
parents:
636
diff
changeset
|
164 |
by (lifting plus_sym_raw) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
165 |
show "0 + i = (i::int)" |
654
02fd9de9d45e
tuned the examples and flagged the problematic cleaning lemmas in FSet
Christian Urban <urbanc@in.tum.de>
parents:
636
diff
changeset
|
166 |
by (lifting plus_zero_raw) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
167 |
show "- i + i = 0" |
654
02fd9de9d45e
tuned the examples and flagged the problematic cleaning lemmas in FSet
Christian Urban <urbanc@in.tum.de>
parents:
636
diff
changeset
|
168 |
by (lifting plus_minus_zero_raw) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
169 |
show "i - j = i + - j" |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
170 |
by (simp add: minus_int_def) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
171 |
show "(i * j) * k = i * (j * k)" |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
172 |
by (lifting times_assoc_raw) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
173 |
show "i * j = j * i" |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
174 |
by (lifting times_sym_raw) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
175 |
show "1 * i = i" |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
176 |
by (lifting times_one_raw) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
177 |
show "(i + j) * k = i * k + j * k" |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
178 |
by (lifting times_plus_comm_raw) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
179 |
show "0 \<noteq> (1::int)" |
654
02fd9de9d45e
tuned the examples and flagged the problematic cleaning lemmas in FSet
Christian Urban <urbanc@in.tum.de>
parents:
636
diff
changeset
|
180 |
by (lifting one_zero_distinct) |
568
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
181 |
qed |
0384e039b7f2
added new example for Ints; regularise does not work in all instances
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
182 |
|
570 | 183 |
term of_nat |
184 |
thm of_nat_def |
|
185 |
||
186 |
lemma int_def: "of_nat m = ABS_int (m, 0)" |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
187 |
apply(induct m) |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
188 |
apply(simp add: zero_int_def) |
570 | 189 |
apply(simp) |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
190 |
apply(simp add: plus_int_def one_int_def) |
570 | 191 |
oops |
192 |
||
193 |
lemma le_antisym_raw: |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
194 |
shows "less_eq_raw i j \<Longrightarrow> less_eq_raw j i \<Longrightarrow> i \<approx> j" |
570 | 195 |
by (cases i, cases j) (simp) |
196 |
||
197 |
lemma le_refl_raw: |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
198 |
shows "less_eq_raw i i" |
570 | 199 |
by (cases i) (simp) |
200 |
||
201 |
lemma le_trans_raw: |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
202 |
shows "less_eq_raw i j \<Longrightarrow> less_eq_raw j k \<Longrightarrow> less_eq_raw i k" |
570 | 203 |
by (cases i, cases j, cases k) (simp) |
204 |
||
205 |
lemma le_cases_raw: |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
206 |
shows "less_eq_raw i j \<or> less_eq_raw j i" |
570 | 207 |
by (cases i, cases j) |
208 |
(simp add: linorder_linear) |
|
209 |
||
210 |
instance int :: linorder |
|
211 |
proof |
|
212 |
fix i j k :: int |
|
213 |
show antisym: "i \<le> j \<Longrightarrow> j \<le> i \<Longrightarrow> i = j" |
|
654
02fd9de9d45e
tuned the examples and flagged the problematic cleaning lemmas in FSet
Christian Urban <urbanc@in.tum.de>
parents:
636
diff
changeset
|
214 |
by (lifting le_antisym_raw) |
570 | 215 |
show "(i < j) = (i \<le> j \<and> \<not> j \<le> i)" |
216 |
by (auto simp add: less_int_def dest: antisym) |
|
217 |
show "i \<le> i" |
|
654
02fd9de9d45e
tuned the examples and flagged the problematic cleaning lemmas in FSet
Christian Urban <urbanc@in.tum.de>
parents:
636
diff
changeset
|
218 |
by (lifting le_refl_raw) |
570 | 219 |
show "i \<le> j \<Longrightarrow> j \<le> k \<Longrightarrow> i \<le> k" |
654
02fd9de9d45e
tuned the examples and flagged the problematic cleaning lemmas in FSet
Christian Urban <urbanc@in.tum.de>
parents:
636
diff
changeset
|
220 |
by (lifting le_trans_raw) |
570 | 221 |
show "i \<le> j \<or> j \<le> i" |
654
02fd9de9d45e
tuned the examples and flagged the problematic cleaning lemmas in FSet
Christian Urban <urbanc@in.tum.de>
parents:
636
diff
changeset
|
222 |
by (lifting le_cases_raw) |
570 | 223 |
qed |
224 |
||
225 |
instantiation int :: distrib_lattice |
|
226 |
begin |
|
227 |
||
228 |
definition |
|
229 |
"(inf \<Colon> int \<Rightarrow> int \<Rightarrow> int) = min" |
|
230 |
||
231 |
definition |
|
232 |
"(sup \<Colon> int \<Rightarrow> int \<Rightarrow> int) = max" |
|
233 |
||
234 |
instance |
|
235 |
by intro_classes |
|
236 |
(auto simp add: inf_int_def sup_int_def min_max.sup_inf_distrib1) |
|
237 |
||
238 |
end |
|
239 |
||
240 |
lemma le_plus_raw: |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
241 |
shows "less_eq_raw i j \<Longrightarrow> less_eq_raw (plus_raw k i) (plus_raw k j)" |
570 | 242 |
by (cases i, cases j, cases k) (simp) |
243 |
||
244 |
||
245 |
instance int :: pordered_cancel_ab_semigroup_add |
|
246 |
proof |
|
247 |
fix i j k :: int |
|
248 |
show "i \<le> j \<Longrightarrow> k + i \<le> k + j" |
|
654
02fd9de9d45e
tuned the examples and flagged the problematic cleaning lemmas in FSet
Christian Urban <urbanc@in.tum.de>
parents:
636
diff
changeset
|
249 |
by (lifting le_plus_raw) |
570 | 250 |
qed |
251 |
||
252 |
lemma test: |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
253 |
"\<lbrakk>less_eq_raw i j \<and> \<not>i \<approx> j; less_eq_raw (0, 0) k \<and> \<not>(0, 0) \<approx> k\<rbrakk> |
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
254 |
\<Longrightarrow> less_eq_raw (times_raw k i) (times_raw k j) \<and> \<not>times_raw k i \<approx> times_raw k j" |
570 | 255 |
apply(cases i, cases j, cases k) |
600
5d932e7a856c
List moved after QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
597
diff
changeset
|
256 |
apply(auto simp add: algebra_simps) |
570 | 257 |
sorry |
258 |
||
259 |
||
260 |
text{*The integers form an ordered integral domain*} |
|
261 |
instance int :: ordered_idom |
|
262 |
proof |
|
263 |
fix i j k :: int |
|
264 |
show "i < j \<Longrightarrow> 0 < k \<Longrightarrow> k * i < k * j" |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
265 |
unfolding less_int_def |
654
02fd9de9d45e
tuned the examples and flagged the problematic cleaning lemmas in FSet
Christian Urban <urbanc@in.tum.de>
parents:
636
diff
changeset
|
266 |
by (lifting test) |
570 | 267 |
show "\<bar>i\<bar> = (if i < 0 then -i else i)" |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
268 |
by (simp only: abs_int_def) |
570 | 269 |
show "sgn (i\<Colon>int) = (if i=0 then 0 else if 0<i then 1 else - 1)" |
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
270 |
by (simp only: sgn_int_def) |
570 | 271 |
qed |
272 |
||
273 |
instance int :: lordered_ring |
|
274 |
proof |
|
275 |
fix k :: int |
|
276 |
show "abs k = sup k (- k)" |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
277 |
by (auto simp add: sup_int_def abs_int_def less_minus_self_iff [symmetric]) |
570 | 278 |
qed |
279 |
||
280 |
lemmas int_distrib = |
|
281 |
left_distrib [of "z1::int" "z2" "w", standard] |
|
282 |
right_distrib [of "w::int" "z1" "z2", standard] |
|
283 |
left_diff_distrib [of "z1::int" "z2" "w", standard] |
|
284 |
right_diff_distrib [of "w::int" "z1" "z2", standard] |
|
285 |
||
286 |
||
287 |
subsection {* Embedding of the Integers into any @{text ring_1}: @{text of_int}*} |
|
288 |
||
289 |
(* |
|
290 |
context ring_1 |
|
291 |
begin |
|
292 |
||
293 |
||
294 |
definition |
|
295 |
of_int :: "int \<Rightarrow> 'a" |
|
296 |
where |
|
297 |
"of_int |
|
298 |
*) |
|
299 |
||
300 |
||
301 |
subsection {* Binary representation *} |
|
302 |
||
303 |
text {* |
|
304 |
This formalization defines binary arithmetic in terms of the integers |
|
305 |
rather than using a datatype. This avoids multiple representations (leading |
|
306 |
zeroes, etc.) See @{text "ZF/Tools/twos-compl.ML"}, function @{text |
|
307 |
int_of_binary}, for the numerical interpretation. |
|
308 |
||
309 |
The representation expects that @{text "(m mod 2)"} is 0 or 1, |
|
310 |
even if m is negative; |
|
311 |
For instance, @{text "-5 div 2 = -3"} and @{text "-5 mod 2 = 1"}; thus |
|
312 |
@{text "-5 = (-3)*2 + 1"}. |
|
313 |
||
314 |
This two's complement binary representation derives from the paper |
|
315 |
"An Efficient Representation of Arithmetic for Term Rewriting" by |
|
316 |
Dave Cohen and Phil Watson, Rewriting Techniques and Applications, |
|
317 |
Springer LNCS 488 (240-251), 1991. |
|
318 |
*} |
|
319 |
||
320 |
subsubsection {* The constructors @{term Bit0}, @{term Bit1}, @{term Pls} and @{term Min} *} |
|
321 |
||
322 |
definition |
|
323 |
Pls :: int where |
|
324 |
[code del]: "Pls = 0" |
|
325 |
||
326 |
definition |
|
327 |
Min :: int where |
|
328 |
[code del]: "Min = - 1" |
|
329 |
||
330 |
definition |
|
331 |
Bit0 :: "int \<Rightarrow> int" where |
|
332 |
[code del]: "Bit0 k = k + k" |
|
333 |
||
334 |
definition |
|
335 |
Bit1 :: "int \<Rightarrow> int" where |
|
336 |
[code del]: "Bit1 k = 1 + k + k" |
|
337 |
||
338 |
class number = -- {* for numeric types: nat, int, real, \dots *} |
|
339 |
fixes number_of :: "int \<Rightarrow> 'a" |
|
340 |
||
600
5d932e7a856c
List moved after QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
597
diff
changeset
|
341 |
(*use "~~/src/HOL/Tools/numeral.ML" |
570 | 342 |
|
343 |
syntax |
|
344 |
"_Numeral" :: "num_const \<Rightarrow> 'a" ("_") |
|
345 |
||
346 |
use "~~/src/HOL/Tools/numeral_syntax.ML" |
|
600
5d932e7a856c
List moved after QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
597
diff
changeset
|
347 |
|
570 | 348 |
setup NumeralSyntax.setup |
349 |
||
350 |
abbreviation |
|
351 |
"Numeral0 \<equiv> number_of Pls" |
|
352 |
||
353 |
abbreviation |
|
354 |
"Numeral1 \<equiv> number_of (Bit1 Pls)" |
|
355 |
||
356 |
lemma Let_number_of [simp]: "Let (number_of v) f = f (number_of v)" |
|
357 |
-- {* Unfold all @{text let}s involving constants *} |
|
358 |
unfolding Let_def .. |
|
359 |
||
360 |
definition |
|
361 |
succ :: "int \<Rightarrow> int" where |
|
362 |
[code del]: "succ k = k + 1" |
|
363 |
||
364 |
definition |
|
365 |
pred :: "int \<Rightarrow> int" where |
|
366 |
[code del]: "pred k = k - 1" |
|
367 |
||
368 |
lemmas |
|
369 |
max_number_of [simp] = max_def |
|
370 |
[of "number_of u" "number_of v", standard, simp] |
|
371 |
and |
|
372 |
min_number_of [simp] = min_def |
|
373 |
[of "number_of u" "number_of v", standard, simp] |
|
374 |
-- {* unfolding @{text minx} and @{text max} on numerals *} |
|
375 |
||
376 |
lemmas numeral_simps = |
|
377 |
succ_def pred_def Pls_def Min_def Bit0_def Bit1_def |
|
378 |
||
379 |
text {* Removal of leading zeroes *} |
|
380 |
||
381 |
lemma Bit0_Pls [simp, code_post]: |
|
382 |
"Bit0 Pls = Pls" |
|
383 |
unfolding numeral_simps by simp |
|
384 |
||
385 |
lemma Bit1_Min [simp, code_post]: |
|
386 |
"Bit1 Min = Min" |
|
387 |
unfolding numeral_simps by simp |
|
388 |
||
389 |
lemmas normalize_bin_simps = |
|
390 |
Bit0_Pls Bit1_Min |
|
600
5d932e7a856c
List moved after QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
597
diff
changeset
|
391 |
*) |
601
81f40b8bde7b
added "end" to each example theory
Christian Urban <urbanc@in.tum.de>
parents:
600
diff
changeset
|
392 |
|
663
0dd10a900cae
Different syntax for definitions that allows overloading and retrieving of definitions by matching whole constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
654
diff
changeset
|
393 |
end |