author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Wed, 28 Apr 2010 17:05:20 +0200 | |
changeset 1974 | 13298f4b212b |
permissions | -rw-r--r-- |
1974
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
1 |
(* Title: HOL/Quotient_Examples/Quotient_Int.thy |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
2 |
Author: Cezary Kaliszyk |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
3 |
Author: Christian Urban |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
4 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
5 |
Integers based on Quotients. |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
6 |
*) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
7 |
theory Quotient_Int |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
8 |
imports Quotient_Product Nat |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
9 |
begin |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
10 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
11 |
fun |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
12 |
intrel :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool" (infix "\<approx>" 50) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
13 |
where |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
14 |
"intrel (x, y) (u, v) = (x + v = u + y)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
15 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
16 |
quotient_type int = "nat \<times> nat" / intrel |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
17 |
by (auto simp add: equivp_def expand_fun_eq) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
18 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
19 |
instantiation int :: "{zero, one, plus, uminus, minus, times, ord, abs, sgn}" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
20 |
begin |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
21 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
22 |
quotient_definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
23 |
"0 \<Colon> int" is "(0\<Colon>nat, 0\<Colon>nat)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
24 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
25 |
quotient_definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
26 |
"1 \<Colon> int" is "(1\<Colon>nat, 0\<Colon>nat)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
27 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
28 |
fun |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
29 |
plus_int_raw :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> (nat \<times> nat)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
30 |
where |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
31 |
"plus_int_raw (x, y) (u, v) = (x + u, y + v)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
32 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
33 |
quotient_definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
34 |
"(op +) \<Colon> (int \<Rightarrow> int \<Rightarrow> int)" is "plus_int_raw" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
35 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
36 |
fun |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
37 |
uminus_int_raw :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
38 |
where |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
39 |
"uminus_int_raw (x, y) = (y, x)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
40 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
41 |
quotient_definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
42 |
"(uminus \<Colon> (int \<Rightarrow> int))" is "uminus_int_raw" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
43 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
44 |
definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
45 |
minus_int_def [code del]: "z - w = z + (-w\<Colon>int)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
46 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
47 |
fun |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
48 |
times_int_raw :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> (nat \<times> nat)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
49 |
where |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
50 |
"times_int_raw (x, y) (u, v) = (x*u + y*v, x*v + y*u)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
51 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
52 |
quotient_definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
53 |
"(op *) :: (int \<Rightarrow> int \<Rightarrow> int)" is "times_int_raw" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
54 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
55 |
fun |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
56 |
le_int_raw :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
57 |
where |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
58 |
"le_int_raw (x, y) (u, v) = (x+v \<le> u+y)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
59 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
60 |
quotient_definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
61 |
le_int_def: "(op \<le>) :: int \<Rightarrow> int \<Rightarrow> bool" is "le_int_raw" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
62 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
63 |
definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
64 |
less_int_def [code del]: "(z\<Colon>int) < w = (z \<le> w \<and> z \<noteq> w)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
65 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
66 |
definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
67 |
zabs_def: "\<bar>i\<Colon>int\<bar> = (if i < 0 then - i else i)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
68 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
69 |
definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
70 |
zsgn_def: "sgn (i\<Colon>int) = (if i = 0 then 0 else if 0 < i then 1 else - 1)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
71 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
72 |
instance .. |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
73 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
74 |
end |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
75 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
76 |
lemma [quot_respect]: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
77 |
shows "(op \<approx> ===> op \<approx> ===> op \<approx>) plus_int_raw plus_int_raw" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
78 |
and "(op \<approx> ===> op \<approx>) uminus_int_raw uminus_int_raw" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
79 |
and "(op \<approx> ===> op \<approx> ===> op =) le_int_raw le_int_raw" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
80 |
by auto |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
81 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
82 |
lemma times_int_raw_fst: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
83 |
assumes a: "x \<approx> z" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
84 |
shows "times_int_raw x y \<approx> times_int_raw z y" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
85 |
using a |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
86 |
apply(cases x, cases y, cases z) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
87 |
apply(auto simp add: times_int_raw.simps intrel.simps) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
88 |
apply(rename_tac u v w x y z) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
89 |
apply(subgoal_tac "u*w + z*w = y*w + v*w & u*x + z*x = y*x + v*x") |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
90 |
apply(simp add: mult_ac) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
91 |
apply(simp add: add_mult_distrib [symmetric]) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
92 |
done |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
93 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
94 |
lemma times_int_raw_snd: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
95 |
assumes a: "x \<approx> z" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
96 |
shows "times_int_raw y x \<approx> times_int_raw y z" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
97 |
using a |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
98 |
apply(cases x, cases y, cases z) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
99 |
apply(auto simp add: times_int_raw.simps intrel.simps) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
100 |
apply(rename_tac u v w x y z) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
101 |
apply(subgoal_tac "u*w + z*w = y*w + v*w & u*x + z*x = y*x + v*x") |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
102 |
apply(simp add: mult_ac) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
103 |
apply(simp add: add_mult_distrib [symmetric]) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
104 |
done |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
105 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
106 |
lemma [quot_respect]: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
107 |
shows "(op \<approx> ===> op \<approx> ===> op \<approx>) times_int_raw times_int_raw" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
108 |
apply(simp only: fun_rel_def) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
109 |
apply(rule allI | rule impI)+ |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
110 |
apply(rule equivp_transp[OF int_equivp]) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
111 |
apply(rule times_int_raw_fst) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
112 |
apply(assumption) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
113 |
apply(rule times_int_raw_snd) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
114 |
apply(assumption) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
115 |
done |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
116 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
117 |
lemma plus_assoc_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
118 |
shows "plus_int_raw (plus_int_raw i j) k \<approx> plus_int_raw i (plus_int_raw j k)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
119 |
by (cases i, cases j, cases k) (simp) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
120 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
121 |
lemma plus_sym_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
122 |
shows "plus_int_raw i j \<approx> plus_int_raw j i" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
123 |
by (cases i, cases j) (simp) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
124 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
125 |
lemma plus_zero_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
126 |
shows "plus_int_raw (0, 0) i \<approx> i" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
127 |
by (cases i) (simp) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
128 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
129 |
lemma plus_minus_zero_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
130 |
shows "plus_int_raw (uminus_int_raw i) i \<approx> (0, 0)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
131 |
by (cases i) (simp) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
132 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
133 |
lemma times_assoc_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
134 |
shows "times_int_raw (times_int_raw i j) k \<approx> times_int_raw i (times_int_raw j k)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
135 |
by (cases i, cases j, cases k) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
136 |
(simp add: algebra_simps) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
137 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
138 |
lemma times_sym_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
139 |
shows "times_int_raw i j \<approx> times_int_raw j i" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
140 |
by (cases i, cases j) (simp add: algebra_simps) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
141 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
142 |
lemma times_one_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
143 |
shows "times_int_raw (1, 0) i \<approx> i" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
144 |
by (cases i) (simp) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
145 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
146 |
lemma times_plus_comm_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
147 |
shows "times_int_raw (plus_int_raw i j) k \<approx> plus_int_raw (times_int_raw i k) (times_int_raw j k)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
148 |
by (cases i, cases j, cases k) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
149 |
(simp add: algebra_simps) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
150 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
151 |
lemma one_zero_distinct: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
152 |
shows "\<not> (0, 0) \<approx> ((1::nat), (0::nat))" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
153 |
by simp |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
154 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
155 |
text{* The integers form a @{text comm_ring_1}*} |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
156 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
157 |
instance int :: comm_ring_1 |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
158 |
proof |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
159 |
fix i j k :: int |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
160 |
show "(i + j) + k = i + (j + k)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
161 |
by (lifting plus_assoc_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
162 |
show "i + j = j + i" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
163 |
by (lifting plus_sym_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
164 |
show "0 + i = (i::int)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
165 |
by (lifting plus_zero_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
166 |
show "- i + i = 0" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
167 |
by (lifting plus_minus_zero_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
168 |
show "i - j = i + - j" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
169 |
by (simp add: minus_int_def) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
170 |
show "(i * j) * k = i * (j * k)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
171 |
by (lifting times_assoc_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
172 |
show "i * j = j * i" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
173 |
by (lifting times_sym_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
174 |
show "1 * i = i" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
175 |
by (lifting times_one_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
176 |
show "(i + j) * k = i * k + j * k" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
177 |
by (lifting times_plus_comm_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
178 |
show "0 \<noteq> (1::int)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
179 |
by (lifting one_zero_distinct) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
180 |
qed |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
181 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
182 |
lemma plus_int_raw_rsp_aux: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
183 |
assumes a: "a \<approx> b" "c \<approx> d" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
184 |
shows "plus_int_raw a c \<approx> plus_int_raw b d" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
185 |
using a |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
186 |
by (cases a, cases b, cases c, cases d) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
187 |
(simp) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
188 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
189 |
lemma add_abs_int: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
190 |
"(abs_int (x,y)) + (abs_int (u,v)) = |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
191 |
(abs_int (x + u, y + v))" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
192 |
apply(simp add: plus_int_def id_simps) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
193 |
apply(fold plus_int_raw.simps) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
194 |
apply(rule Quotient_rel_abs[OF Quotient_int]) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
195 |
apply(rule plus_int_raw_rsp_aux) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
196 |
apply(simp_all add: rep_abs_rsp_left[OF Quotient_int]) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
197 |
done |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
198 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
199 |
definition int_of_nat_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
200 |
"int_of_nat_raw m = (m :: nat, 0 :: nat)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
201 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
202 |
quotient_definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
203 |
"int_of_nat :: nat \<Rightarrow> int" is "int_of_nat_raw" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
204 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
205 |
lemma[quot_respect]: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
206 |
shows "(op = ===> op \<approx>) int_of_nat_raw int_of_nat_raw" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
207 |
by (simp add: equivp_reflp[OF int_equivp]) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
208 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
209 |
lemma int_of_nat: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
210 |
shows "of_nat m = int_of_nat m" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
211 |
by (induct m) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
212 |
(simp_all add: zero_int_def one_int_def int_of_nat_def int_of_nat_raw add_abs_int) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
213 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
214 |
lemma le_antisym_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
215 |
shows "le_int_raw i j \<Longrightarrow> le_int_raw j i \<Longrightarrow> i \<approx> j" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
216 |
by (cases i, cases j) (simp) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
217 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
218 |
lemma le_refl_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
219 |
shows "le_int_raw i i" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
220 |
by (cases i) (simp) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
221 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
222 |
lemma le_trans_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
223 |
shows "le_int_raw i j \<Longrightarrow> le_int_raw j k \<Longrightarrow> le_int_raw i k" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
224 |
by (cases i, cases j, cases k) (simp) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
225 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
226 |
lemma le_cases_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
227 |
shows "le_int_raw i j \<or> le_int_raw j i" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
228 |
by (cases i, cases j) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
229 |
(simp add: linorder_linear) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
230 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
231 |
instance int :: linorder |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
232 |
proof |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
233 |
fix i j k :: int |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
234 |
show antisym: "i \<le> j \<Longrightarrow> j \<le> i \<Longrightarrow> i = j" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
235 |
by (lifting le_antisym_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
236 |
show "(i < j) = (i \<le> j \<and> \<not> j \<le> i)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
237 |
by (auto simp add: less_int_def dest: antisym) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
238 |
show "i \<le> i" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
239 |
by (lifting le_refl_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
240 |
show "i \<le> j \<Longrightarrow> j \<le> k \<Longrightarrow> i \<le> k" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
241 |
by (lifting le_trans_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
242 |
show "i \<le> j \<or> j \<le> i" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
243 |
by (lifting le_cases_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
244 |
qed |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
245 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
246 |
instantiation int :: distrib_lattice |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
247 |
begin |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
248 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
249 |
definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
250 |
"(inf \<Colon> int \<Rightarrow> int \<Rightarrow> int) = min" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
251 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
252 |
definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
253 |
"(sup \<Colon> int \<Rightarrow> int \<Rightarrow> int) = max" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
254 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
255 |
instance |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
256 |
by intro_classes |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
257 |
(auto simp add: inf_int_def sup_int_def min_max.sup_inf_distrib1) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
258 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
259 |
end |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
260 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
261 |
lemma le_plus_int_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
262 |
shows "le_int_raw i j \<Longrightarrow> le_int_raw (plus_int_raw k i) (plus_int_raw k j)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
263 |
by (cases i, cases j, cases k) (simp) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
264 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
265 |
instance int :: ordered_cancel_ab_semigroup_add |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
266 |
proof |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
267 |
fix i j k :: int |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
268 |
show "i \<le> j \<Longrightarrow> k + i \<le> k + j" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
269 |
by (lifting le_plus_int_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
270 |
qed |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
271 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
272 |
abbreviation |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
273 |
"less_int_raw i j \<equiv> le_int_raw i j \<and> \<not>(i \<approx> j)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
274 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
275 |
lemma zmult_zless_mono2_lemma: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
276 |
fixes i j::int |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
277 |
and k::nat |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
278 |
shows "i < j \<Longrightarrow> 0 < k \<Longrightarrow> of_nat k * i < of_nat k * j" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
279 |
apply(induct "k") |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
280 |
apply(simp) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
281 |
apply(case_tac "k = 0") |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
282 |
apply(simp_all add: left_distrib add_strict_mono) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
283 |
done |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
284 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
285 |
lemma zero_le_imp_eq_int_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
286 |
fixes k::"(nat \<times> nat)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
287 |
shows "less_int_raw (0, 0) k \<Longrightarrow> (\<exists>n > 0. k \<approx> int_of_nat_raw n)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
288 |
apply(cases k) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
289 |
apply(simp add:int_of_nat_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
290 |
apply(auto) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
291 |
apply(rule_tac i="b" and j="a" in less_Suc_induct) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
292 |
apply(auto) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
293 |
done |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
294 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
295 |
lemma zero_le_imp_eq_int: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
296 |
fixes k::int |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
297 |
shows "0 < k \<Longrightarrow> \<exists>n > 0. k = of_nat n" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
298 |
unfolding less_int_def int_of_nat |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
299 |
by (lifting zero_le_imp_eq_int_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
300 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
301 |
lemma zmult_zless_mono2: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
302 |
fixes i j k::int |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
303 |
assumes a: "i < j" "0 < k" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
304 |
shows "k * i < k * j" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
305 |
using a |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
306 |
by (drule_tac zero_le_imp_eq_int) (auto simp add: zmult_zless_mono2_lemma) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
307 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
308 |
text{*The integers form an ordered integral domain*} |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
309 |
instance int :: linordered_idom |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
310 |
proof |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
311 |
fix i j k :: int |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
312 |
show "i < j \<Longrightarrow> 0 < k \<Longrightarrow> k * i < k * j" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
313 |
by (rule zmult_zless_mono2) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
314 |
show "\<bar>i\<bar> = (if i < 0 then -i else i)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
315 |
by (simp only: zabs_def) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
316 |
show "sgn (i\<Colon>int) = (if i=0 then 0 else if 0<i then 1 else - 1)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
317 |
by (simp only: zsgn_def) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
318 |
qed |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
319 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
320 |
lemmas int_distrib = |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
321 |
left_distrib [of "z1::int" "z2" "w", standard] |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
322 |
right_distrib [of "w::int" "z1" "z2", standard] |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
323 |
left_diff_distrib [of "z1::int" "z2" "w", standard] |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
324 |
right_diff_distrib [of "w::int" "z1" "z2", standard] |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
325 |
minus_add_distrib[of "z1::int" "z2", standard] |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
326 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
327 |
lemma int_induct_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
328 |
assumes a: "P (0::nat, 0)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
329 |
and b: "\<And>i. P i \<Longrightarrow> P (plus_int_raw i (1, 0))" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
330 |
and c: "\<And>i. P i \<Longrightarrow> P (plus_int_raw i (uminus_int_raw (1, 0)))" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
331 |
shows "P x" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
332 |
proof (cases x, clarify) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
333 |
fix a b |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
334 |
show "P (a, b)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
335 |
proof (induct a arbitrary: b rule: Nat.induct) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
336 |
case zero |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
337 |
show "P (0, b)" using assms by (induct b) auto |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
338 |
next |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
339 |
case (Suc n) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
340 |
then show ?case using assms by auto |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
341 |
qed |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
342 |
qed |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
343 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
344 |
lemma int_induct: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
345 |
fixes x :: int |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
346 |
assumes a: "P 0" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
347 |
and b: "\<And>i. P i \<Longrightarrow> P (i + 1)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
348 |
and c: "\<And>i. P i \<Longrightarrow> P (i - 1)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
349 |
shows "P x" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
350 |
using a b c unfolding minus_int_def |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
351 |
by (lifting int_induct_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
352 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
353 |
text {* Magnitide of an Integer, as a Natural Number: @{term nat} *} |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
354 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
355 |
definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
356 |
"int_to_nat_raw \<equiv> \<lambda>(x, y).x - (y::nat)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
357 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
358 |
quotient_definition |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
359 |
"int_to_nat::int \<Rightarrow> nat" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
360 |
is |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
361 |
"int_to_nat_raw" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
362 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
363 |
lemma [quot_respect]: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
364 |
shows "(intrel ===> op =) int_to_nat_raw int_to_nat_raw" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
365 |
by (auto iff: int_to_nat_raw_def) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
366 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
367 |
lemma nat_le_eq_zle_raw: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
368 |
assumes a: "less_int_raw (0, 0) w \<or> le_int_raw (0, 0) z" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
369 |
shows "(int_to_nat_raw w \<le> int_to_nat_raw z) = (le_int_raw w z)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
370 |
using a |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
371 |
by (cases w, cases z) (auto simp add: int_to_nat_raw_def) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
372 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
373 |
lemma nat_le_eq_zle: |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
374 |
fixes w z::"int" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
375 |
shows "0 < w \<or> 0 \<le> z \<Longrightarrow> (int_to_nat w \<le> int_to_nat z) = (w \<le> z)" |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
376 |
unfolding less_int_def |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
377 |
by (lifting nat_le_eq_zle_raw) |
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
378 |
|
13298f4b212b
Cleaning of Int and FSet Examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
379 |
end |