author | blanchet |
Wed, 03 Nov 2010 22:26:53 +0100 | |
changeset 40341 | 03156257040f |
parent 39362 | ee65900bfced |
child 40590 | b994d855dbd2 |
permissions | -rw-r--r-- |
33197 | 1 |
(* Title: HOL/Nitpick_Examples/Typedef_Nits.thy |
2 |
Author: Jasmin Blanchette, TU Muenchen |
|
35076
cc19e2aef17e
added hotel key card example for Nitpick, and renumber atoms in Nitpick's output for increased readability
blanchet
parents:
34126
diff
changeset
|
3 |
Copyright 2009, 2010 |
33197 | 4 |
|
5 |
Examples featuring Nitpick applied to typedefs. |
|
6 |
*) |
|
7 |
||
8 |
header {* Examples Featuring Nitpick Applied to Typedefs *} |
|
9 |
||
10 |
theory Typedef_Nits |
|
35372 | 11 |
imports Complex_Main |
33197 | 12 |
begin |
13 |
||
35284
9edc2bd6d2bd
enabled Nitpick's support for quotient types + shortened the Nitpick tests a bit
blanchet
parents:
35078
diff
changeset
|
14 |
nitpick_params [card = 1\<midarrow>4, sat_solver = MiniSat_JNI, max_threads = 1, |
40341
03156257040f
standardize on seconds for Nitpick and Sledgehammer timeouts
blanchet
parents:
39362
diff
changeset
|
15 |
timeout = 60] |
33197 | 16 |
|
17 |
typedef three = "{0\<Colon>nat, 1, 2}" |
|
18 |
by blast |
|
19 |
||
20 |
definition A :: three where "A \<equiv> Abs_three 0" |
|
21 |
definition B :: three where "B \<equiv> Abs_three 1" |
|
22 |
definition C :: three where "C \<equiv> Abs_three 2" |
|
23 |
||
24 |
lemma "x = (y\<Colon>three)" |
|
25 |
nitpick [expect = genuine] |
|
26 |
oops |
|
27 |
||
28 |
typedef 'a one_or_two = "{undefined False\<Colon>'a, undefined True}" |
|
29 |
by auto |
|
30 |
||
31 |
lemma "x = (y\<Colon>unit one_or_two)" |
|
32 |
nitpick [expect = none] |
|
33 |
sorry |
|
34 |
||
35 |
lemma "x = (y\<Colon>bool one_or_two)" |
|
36 |
nitpick [expect = genuine] |
|
37 |
oops |
|
38 |
||
39 |
lemma "undefined False \<longleftrightarrow> undefined True \<Longrightarrow> x = (y\<Colon>bool one_or_two)" |
|
40 |
nitpick [expect = none] |
|
41 |
sorry |
|
42 |
||
43 |
lemma "undefined False \<longleftrightarrow> undefined True \<Longrightarrow> \<exists>x (y\<Colon>bool one_or_two). x \<noteq> y" |
|
44 |
nitpick [card = 1, expect = potential] (* unfortunate *) |
|
45 |
oops |
|
46 |
||
47 |
lemma "\<exists>x (y\<Colon>bool one_or_two). x \<noteq> y" |
|
48 |
nitpick [card = 1, expect = potential] (* unfortunate *) |
|
49 |
nitpick [card = 2, expect = none] |
|
50 |
oops |
|
51 |
||
52 |
typedef 'a bounded = |
|
53 |
"{n\<Colon>nat. finite (UNIV\<Colon>'a \<Rightarrow> bool) \<longrightarrow> n < card (UNIV\<Colon>'a \<Rightarrow> bool)}" |
|
54 |
apply (rule_tac x = 0 in exI) |
|
55 |
apply (case_tac "card UNIV = 0") |
|
56 |
by auto |
|
57 |
||
58 |
lemma "x = (y\<Colon>unit bounded)" |
|
59 |
nitpick [expect = none] |
|
60 |
sorry |
|
61 |
||
62 |
lemma "x = (y\<Colon>bool bounded)" |
|
63 |
nitpick [expect = genuine] |
|
64 |
oops |
|
65 |
||
66 |
lemma "x \<noteq> (y\<Colon>bool bounded) \<Longrightarrow> z = x \<or> z = y" |
|
39362
ee65900bfced
adapt examples to latest Nitpick changes + speed them up a little bit
blanchet
parents:
38542
diff
changeset
|
67 |
nitpick [expect = potential] (* unfortunate *) |
33197 | 68 |
sorry |
69 |
||
70 |
lemma "x \<noteq> (y\<Colon>(bool \<times> bool) bounded) \<Longrightarrow> z = x \<or> z = y" |
|
34126 | 71 |
nitpick [card = 1\<midarrow>5, expect = genuine] |
33197 | 72 |
oops |
73 |
||
74 |
lemma "True \<equiv> ((\<lambda>x\<Colon>bool. x) = (\<lambda>x. x))" |
|
75 |
nitpick [expect = none] |
|
76 |
by (rule True_def) |
|
77 |
||
78 |
lemma "False \<equiv> \<forall>P. P" |
|
79 |
nitpick [expect = none] |
|
80 |
by (rule False_def) |
|
81 |
||
82 |
lemma "() = Abs_unit True" |
|
83 |
nitpick [expect = none] |
|
84 |
by (rule Unity_def) |
|
85 |
||
86 |
lemma "() = Abs_unit False" |
|
87 |
nitpick [expect = none] |
|
88 |
by simp |
|
89 |
||
90 |
lemma "Rep_unit () = True" |
|
91 |
nitpick [expect = none] |
|
92 |
by (insert Rep_unit) (simp add: unit_def) |
|
93 |
||
94 |
lemma "Rep_unit () = False" |
|
95 |
nitpick [expect = genuine] |
|
96 |
oops |
|
97 |
||
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
98 |
lemma "Pair a b = Abs_prod (Pair_Rep a b)" |
33197 | 99 |
nitpick [card = 1\<midarrow>2, expect = none] |
100 |
by (rule Pair_def) |
|
101 |
||
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
102 |
lemma "Pair a b = Abs_prod (Pair_Rep b a)" |
33197 | 103 |
nitpick [card = 1\<midarrow>2, expect = none] |
104 |
nitpick [dont_box, expect = genuine] |
|
105 |
oops |
|
106 |
||
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
107 |
lemma "fst (Abs_prod (Pair_Rep a b)) = a" |
33197 | 108 |
nitpick [card = 2, expect = none] |
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
109 |
by (simp add: Pair_def [THEN sym]) |
33197 | 110 |
|
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
111 |
lemma "fst (Abs_prod (Pair_Rep a b)) = b" |
33197 | 112 |
nitpick [card = 1\<midarrow>2, expect = none] |
113 |
nitpick [dont_box, expect = genuine] |
|
114 |
oops |
|
115 |
||
116 |
lemma "a \<noteq> a' \<Longrightarrow> Pair_Rep a b \<noteq> Pair_Rep a' b" |
|
117 |
nitpick [expect = none] |
|
118 |
apply (rule ccontr) |
|
119 |
apply simp |
|
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
120 |
apply (drule subst [where P = "\<lambda>r. Abs_prod r = Abs_prod (Pair_Rep a b)"]) |
33197 | 121 |
apply (rule refl) |
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
122 |
by (simp add: Pair_def [THEN sym]) |
33197 | 123 |
|
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
124 |
lemma "Abs_prod (Rep_prod a) = a" |
33197 | 125 |
nitpick [card = 2, expect = none] |
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
126 |
by (rule Rep_prod_inverse) |
33197 | 127 |
|
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
128 |
lemma "Inl \<equiv> \<lambda>a. Abs_sum (Inl_Rep a)" |
33197 | 129 |
nitpick [card = 1, expect = none] |
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
130 |
by (simp add: Inl_def o_def) |
33197 | 131 |
|
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
132 |
lemma "Inl \<equiv> \<lambda>a. Abs_sum (Inr_Rep a)" |
33197 | 133 |
nitpick [card = 1, card "'a + 'a" = 2, expect = genuine] |
134 |
oops |
|
135 |
||
136 |
lemma "Inl_Rep a \<noteq> Inr_Rep a" |
|
137 |
nitpick [expect = none] |
|
138 |
by (rule Inl_Rep_not_Inr_Rep) |
|
139 |
||
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
140 |
lemma "Abs_sum (Rep_sum a) = a" |
35284
9edc2bd6d2bd
enabled Nitpick's support for quotient types + shortened the Nitpick tests a bit
blanchet
parents:
35078
diff
changeset
|
141 |
nitpick [card = 1, expect = none] |
9edc2bd6d2bd
enabled Nitpick's support for quotient types + shortened the Nitpick tests a bit
blanchet
parents:
35078
diff
changeset
|
142 |
nitpick [card = 2, expect = none] |
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
143 |
by (rule Rep_sum_inverse) |
33197 | 144 |
|
145 |
lemma "0::nat \<equiv> Abs_Nat Zero_Rep" |
|
35312 | 146 |
nitpick [expect = none] |
33197 | 147 |
by (rule Zero_nat_def_raw) |
148 |
||
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
149 |
lemma "Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))" |
35312 | 150 |
nitpick [expect = none] |
33197 | 151 |
by (rule Suc_def) |
152 |
||
37400
cf5e06d5ecaf
adjust Nitpick example to follow latest wave of renamings
blanchet
parents:
37255
diff
changeset
|
153 |
lemma "Suc n = Abs_Nat (Suc_Rep (Suc_Rep (Rep_Nat n)))" |
33197 | 154 |
nitpick [expect = genuine] |
155 |
oops |
|
156 |
||
157 |
lemma "Abs_Nat (Rep_Nat a) = a" |
|
158 |
nitpick [expect = none] |
|
159 |
by (rule Rep_Nat_inverse) |
|
160 |
||
161 |
lemma "0 \<equiv> Abs_Integ (intrel `` {(0, 0)})" |
|
34126 | 162 |
nitpick [card = 1, unary_ints, max_potential = 0, expect = none] |
33197 | 163 |
by (rule Zero_int_def_raw) |
164 |
||
165 |
lemma "Abs_list (Rep_list a) = a" |
|
34126 | 166 |
nitpick [card = 1\<midarrow>2, expect = none] |
33197 | 167 |
by (rule Rep_list_inverse) |
168 |
||
169 |
record point = |
|
170 |
Xcoord :: int |
|
171 |
Ycoord :: int |
|
172 |
||
38542
c9599ce8cbfc
adjusted to restored naming convention of logical record types
haftmann
parents:
37481
diff
changeset
|
173 |
lemma "Abs_point_ext (Rep_point_ext a) = a" |
33571 | 174 |
nitpick [expect = none] |
38542
c9599ce8cbfc
adjusted to restored naming convention of logical record types
haftmann
parents:
37481
diff
changeset
|
175 |
by (fact Rep_point_ext_inverse) |
33197 | 176 |
|
177 |
lemma "Fract a b = of_int a / of_int b" |
|
33737
e441fede163d
fixed "expect" of Nitpick examples to reflect latest changes in Nitpick
blanchet
parents:
33571
diff
changeset
|
178 |
nitpick [card = 1, expect = none] |
33197 | 179 |
by (rule Fract_of_int_quotient) |
180 |
||
181 |
lemma "Abs_Rat (Rep_Rat a) = a" |
|
33737
e441fede163d
fixed "expect" of Nitpick examples to reflect latest changes in Nitpick
blanchet
parents:
33571
diff
changeset
|
182 |
nitpick [card = 1, expect = none] |
33197 | 183 |
by (rule Rep_Rat_inverse) |
184 |
||
185 |
end |