author | bulwahn |
Wed, 23 Mar 2011 08:50:29 +0100 | |
changeset 42087 | 5e236f6ef04f |
parent 41231 | 2e901158675e |
child 42159 | 234ec7011e5d |
permissions | -rw-r--r-- |
14592 | 1 |
(* Title: HOL/ex/Quickcheck_Examples.thy |
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
2 |
Author: Stefan Berghofer, Lukas Bulwahn |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
3 |
Copyright 2004 - 2010 TU Muenchen |
14592 | 4 |
*) |
5 |
||
6 |
header {* Examples for the 'quickcheck' command *} |
|
7 |
||
28314 | 8 |
theory Quickcheck_Examples |
41231
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
9 |
imports Complex_Main |
28314 | 10 |
begin |
14592 | 11 |
|
12 |
text {* |
|
13 |
The 'quickcheck' command allows to find counterexamples by evaluating |
|
40654 | 14 |
formulae. |
15 |
Currently, there are two different exploration schemes: |
|
16 |
- random testing: this is incomplete, but explores the search space faster. |
|
17 |
- exhaustive testing: this is complete, but increasing the depth leads to |
|
18 |
exponentially many assignments. |
|
19 |
||
20 |
quickcheck can handle quantifiers on finite universes. |
|
21 |
||
14592 | 22 |
*} |
23 |
||
24 |
subsection {* Lists *} |
|
25 |
||
26 |
theorem "map g (map f xs) = map (g o f) xs" |
|
40917 | 27 |
quickcheck[random, expect = no_counterexample] |
28 |
quickcheck[exhaustive, size = 3, expect = no_counterexample] |
|
14592 | 29 |
oops |
30 |
||
31 |
theorem "map g (map f xs) = map (f o g) xs" |
|
40917 | 32 |
quickcheck[random, expect = counterexample] |
33 |
quickcheck[exhaustive, expect = counterexample] |
|
14592 | 34 |
oops |
35 |
||
36 |
theorem "rev (xs @ ys) = rev ys @ rev xs" |
|
40917 | 37 |
quickcheck[random, expect = no_counterexample] |
38 |
quickcheck[exhaustive, expect = no_counterexample] |
|
42087
5e236f6ef04f
changing timeout behaviour of quickcheck to proceed after command rather than failing; adding a test case for timeout
bulwahn
parents:
41231
diff
changeset
|
39 |
quickcheck[exhaustive, size = 1000, timeout = 0.1] |
14592 | 40 |
oops |
41 |
||
42 |
theorem "rev (xs @ ys) = rev xs @ rev ys" |
|
40917 | 43 |
quickcheck[random, expect = counterexample] |
44 |
quickcheck[exhaustive, expect = counterexample] |
|
14592 | 45 |
oops |
46 |
||
47 |
theorem "rev (rev xs) = xs" |
|
40917 | 48 |
quickcheck[random, expect = no_counterexample] |
49 |
quickcheck[exhaustive, expect = no_counterexample] |
|
14592 | 50 |
oops |
51 |
||
52 |
theorem "rev xs = xs" |
|
40917 | 53 |
quickcheck[random, expect = counterexample] |
54 |
quickcheck[exhaustive, expect = counterexample] |
|
14592 | 55 |
oops |
56 |
||
25891 | 57 |
text {* An example involving functions inside other data structures *} |
58 |
||
28314 | 59 |
primrec app :: "('a \<Rightarrow> 'a) list \<Rightarrow> 'a \<Rightarrow> 'a" where |
25891 | 60 |
"app [] x = x" |
28314 | 61 |
| "app (f # fs) x = app fs (f x)" |
25891 | 62 |
|
63 |
lemma "app (fs @ gs) x = app gs (app fs x)" |
|
40917 | 64 |
quickcheck[random, expect = no_counterexample] |
65 |
quickcheck[exhaustive, size = 4, expect = no_counterexample] |
|
25891 | 66 |
by (induct fs arbitrary: x) simp_all |
67 |
||
68 |
lemma "app (fs @ gs) x = app fs (app gs x)" |
|
40917 | 69 |
quickcheck[random, expect = counterexample] |
70 |
quickcheck[exhaustive, expect = counterexample] |
|
25891 | 71 |
oops |
72 |
||
28314 | 73 |
primrec occurs :: "'a \<Rightarrow> 'a list \<Rightarrow> nat" where |
14592 | 74 |
"occurs a [] = 0" |
28314 | 75 |
| "occurs a (x#xs) = (if (x=a) then Suc(occurs a xs) else occurs a xs)" |
14592 | 76 |
|
28314 | 77 |
primrec del1 :: "'a \<Rightarrow> 'a list \<Rightarrow> 'a list" where |
14592 | 78 |
"del1 a [] = []" |
28314 | 79 |
| "del1 a (x#xs) = (if (x=a) then xs else (x#del1 a xs))" |
14592 | 80 |
|
25891 | 81 |
text {* A lemma, you'd think to be true from our experience with delAll *} |
14592 | 82 |
lemma "Suc (occurs a (del1 a xs)) = occurs a xs" |
83 |
-- {* Wrong. Precondition needed.*} |
|
40917 | 84 |
quickcheck[random, expect = counterexample] |
85 |
quickcheck[exhaustive, expect = counterexample] |
|
14592 | 86 |
oops |
87 |
||
88 |
lemma "xs ~= [] \<longrightarrow> Suc (occurs a (del1 a xs)) = occurs a xs" |
|
40917 | 89 |
quickcheck[random, expect = counterexample] |
90 |
quickcheck[exhaustive, expect = counterexample] |
|
14592 | 91 |
-- {* Also wrong.*} |
92 |
oops |
|
93 |
||
94 |
lemma "0 < occurs a xs \<longrightarrow> Suc (occurs a (del1 a xs)) = occurs a xs" |
|
40917 | 95 |
quickcheck[random, expect = no_counterexample] |
96 |
quickcheck[exhaustive, expect = no_counterexample] |
|
28314 | 97 |
by (induct xs) auto |
14592 | 98 |
|
28314 | 99 |
primrec replace :: "'a \<Rightarrow> 'a \<Rightarrow> 'a list \<Rightarrow> 'a list" where |
14592 | 100 |
"replace a b [] = []" |
28314 | 101 |
| "replace a b (x#xs) = (if (x=a) then (b#(replace a b xs)) |
14592 | 102 |
else (x#(replace a b xs)))" |
103 |
||
104 |
lemma "occurs a xs = occurs b (replace a b xs)" |
|
40917 | 105 |
quickcheck[random, expect = counterexample] |
106 |
quickcheck[exhaustive, expect = counterexample] |
|
14592 | 107 |
-- {* Wrong. Precondition needed.*} |
108 |
oops |
|
109 |
||
110 |
lemma "occurs b xs = 0 \<or> a=b \<longrightarrow> occurs a xs = occurs b (replace a b xs)" |
|
40917 | 111 |
quickcheck[random, expect = no_counterexample] |
112 |
quickcheck[exhaustive, expect = no_counterexample] |
|
28314 | 113 |
by (induct xs) simp_all |
14592 | 114 |
|
115 |
||
116 |
subsection {* Trees *} |
|
117 |
||
118 |
datatype 'a tree = Twig | Leaf 'a | Branch "'a tree" "'a tree" |
|
119 |
||
28314 | 120 |
primrec leaves :: "'a tree \<Rightarrow> 'a list" where |
14592 | 121 |
"leaves Twig = []" |
28314 | 122 |
| "leaves (Leaf a) = [a]" |
123 |
| "leaves (Branch l r) = (leaves l) @ (leaves r)" |
|
14592 | 124 |
|
28314 | 125 |
primrec plant :: "'a list \<Rightarrow> 'a tree" where |
14592 | 126 |
"plant [] = Twig " |
28314 | 127 |
| "plant (x#xs) = Branch (Leaf x) (plant xs)" |
14592 | 128 |
|
28314 | 129 |
primrec mirror :: "'a tree \<Rightarrow> 'a tree" where |
14592 | 130 |
"mirror (Twig) = Twig " |
28314 | 131 |
| "mirror (Leaf a) = Leaf a " |
132 |
| "mirror (Branch l r) = Branch (mirror r) (mirror l)" |
|
14592 | 133 |
|
134 |
theorem "plant (rev (leaves xt)) = mirror xt" |
|
40917 | 135 |
quickcheck[random, expect = counterexample] |
136 |
quickcheck[exhaustive, expect = counterexample] |
|
14592 | 137 |
--{* Wrong! *} |
138 |
oops |
|
139 |
||
140 |
theorem "plant((leaves xt) @ (leaves yt)) = Branch xt yt" |
|
40917 | 141 |
quickcheck[random, expect = counterexample] |
142 |
quickcheck[exhaustive, expect = counterexample] |
|
14592 | 143 |
--{* Wrong! *} |
144 |
oops |
|
145 |
||
146 |
datatype 'a ntree = Tip "'a" | Node "'a" "'a ntree" "'a ntree" |
|
147 |
||
28314 | 148 |
primrec inOrder :: "'a ntree \<Rightarrow> 'a list" where |
14592 | 149 |
"inOrder (Tip a)= [a]" |
28314 | 150 |
| "inOrder (Node f x y) = (inOrder x)@[f]@(inOrder y)" |
14592 | 151 |
|
28314 | 152 |
primrec root :: "'a ntree \<Rightarrow> 'a" where |
14592 | 153 |
"root (Tip a) = a" |
28314 | 154 |
| "root (Node f x y) = f" |
14592 | 155 |
|
28314 | 156 |
theorem "hd (inOrder xt) = root xt" |
40917 | 157 |
quickcheck[random, expect = counterexample] |
158 |
quickcheck[exhaustive, expect = counterexample] |
|
159 |
--{* Wrong! *} |
|
14592 | 160 |
oops |
161 |
||
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
162 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
163 |
subsection {* Exhaustive Testing beats Random Testing *} |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
164 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
165 |
text {* Here are some examples from mutants from the List theory |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
166 |
where exhaustive testing beats random testing *} |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
167 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
168 |
lemma |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
169 |
"[] ~= xs ==> hd xs = last (x # xs)" |
40917 | 170 |
quickcheck[random] |
171 |
quickcheck[exhaustive, expect = counterexample] |
|
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
172 |
oops |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
173 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
174 |
lemma |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
175 |
assumes "!!i. [| i < n; i < length xs |] ==> P (xs ! i)" "n < length xs ==> ~ P (xs ! n)" |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
176 |
shows "drop n xs = takeWhile P xs" |
40917 | 177 |
quickcheck[random, iterations = 10000, quiet] |
178 |
quickcheck[exhaustive, expect = counterexample] |
|
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
179 |
oops |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
180 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
181 |
lemma |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
182 |
"i < length (List.transpose (List.transpose xs)) ==> xs ! i = map (%xs. xs ! i) [ys<-xs. i < length ys]" |
40917 | 183 |
quickcheck[random, iterations = 10000] |
184 |
quickcheck[exhaustive, expect = counterexample] |
|
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
185 |
oops |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
186 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
187 |
lemma |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
188 |
"i < n - m ==> f (lcm m i) = map f [m..<n] ! i" |
40917 | 189 |
quickcheck[random, iterations = 10000, finite_types = false] |
190 |
quickcheck[exhaustive, finite_types = false, expect = counterexample] |
|
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
191 |
oops |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
192 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
193 |
lemma |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
194 |
"i < n - m ==> f (lcm m i) = map f [m..<n] ! i" |
40917 | 195 |
quickcheck[random, iterations = 10000, finite_types = false] |
196 |
quickcheck[exhaustive, finite_types = false, expect = counterexample] |
|
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
197 |
oops |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
198 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
199 |
lemma |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
200 |
"ns ! k < length ns ==> k <= listsum ns" |
40917 | 201 |
quickcheck[random, iterations = 10000, finite_types = false, quiet] |
202 |
quickcheck[exhaustive, finite_types = false, expect = counterexample] |
|
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
203 |
oops |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
204 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
205 |
lemma |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
206 |
"[| ys = x # xs1; zs = xs1 @ xs |] ==> ys @ zs = x # xs" |
40917 | 207 |
quickcheck[random, iterations = 10000] |
208 |
quickcheck[exhaustive, expect = counterexample] |
|
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
209 |
oops |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
210 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
211 |
lemma |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
212 |
"i < length xs ==> take (Suc i) xs = [] @ xs ! i # take i xs" |
40917 | 213 |
quickcheck[random, iterations = 10000] |
214 |
quickcheck[exhaustive, expect = counterexample] |
|
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
215 |
oops |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
216 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
217 |
lemma |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
218 |
"i < length xs ==> take (Suc i) xs = (xs ! i # xs) @ take i []" |
40917 | 219 |
quickcheck[random, iterations = 10000] |
220 |
quickcheck[exhaustive, expect = counterexample] |
|
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
221 |
oops |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
222 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
223 |
lemma |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
224 |
"[| sorted (rev (map length xs)); i < length xs |] ==> xs ! i = map (%ys. ys ! i) [ys<-remdups xs. i < length ys]" |
40917 | 225 |
quickcheck[random] |
226 |
quickcheck[exhaustive, expect = counterexample] |
|
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
227 |
oops |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
228 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
229 |
lemma |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
230 |
"[| sorted (rev (map length xs)); i < length xs |] ==> xs ! i = map (%ys. ys ! i) [ys<-List.transpose xs. {..<i} (length ys)]" |
40917 | 231 |
quickcheck[random] |
232 |
quickcheck[exhaustive, expect = counterexample] |
|
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
233 |
oops |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
234 |
|
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
235 |
lemma |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
236 |
"(ys = zs) = (xs @ ys = splice xs zs)" |
40917 | 237 |
quickcheck[random] |
238 |
quickcheck[exhaustive, expect = counterexample] |
|
40645
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
239 |
oops |
03ce94672ee6
adding test cases for smallcheck and adding examples where exhaustive testing is more successful
bulwahn
parents:
37929
diff
changeset
|
240 |
|
41231
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
241 |
subsection {* Examples with quantifiers *} |
40654 | 242 |
|
243 |
text {* |
|
244 |
These examples show that we can handle quantifiers. |
|
245 |
*} |
|
246 |
||
247 |
lemma "(\<exists>x. P x) \<longrightarrow> (\<forall>x. P x)" |
|
40917 | 248 |
quickcheck[random, expect = counterexample] |
249 |
quickcheck[exhaustive, expect = counterexample] |
|
40654 | 250 |
oops |
251 |
||
252 |
lemma "(\<forall>x. \<exists>y. P x y) \<longrightarrow> (\<exists>y. \<forall>x. P x y)" |
|
40917 | 253 |
quickcheck[random, expect = counterexample] |
40654 | 254 |
quickcheck[expect = counterexample] |
255 |
oops |
|
256 |
||
257 |
lemma "(\<exists>x. P x) \<longrightarrow> (EX! x. P x)" |
|
40917 | 258 |
quickcheck[random, expect = counterexample] |
40654 | 259 |
quickcheck[expect = counterexample] |
260 |
oops |
|
261 |
||
41231
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
262 |
subsection {* Examples with numerical types *} |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
263 |
|
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
264 |
text {* |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
265 |
Quickcheck supports the common types nat, int, rat and real. |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
266 |
*} |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
267 |
|
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
268 |
lemma |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
269 |
"(x :: nat) > 0 ==> y > 0 ==> z > 0 ==> x * x + y * y \<noteq> z * z" |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
270 |
quickcheck[exhaustive, size = 10, expect = counterexample] |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
271 |
quickcheck[random, size = 10] |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
272 |
oops |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
273 |
|
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
274 |
lemma |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
275 |
"(x :: int) > 0 ==> y > 0 ==> z > 0 ==> x * x + y * y \<noteq> z * z" |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
276 |
quickcheck[exhaustive, size = 10, expect = counterexample] |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
277 |
quickcheck[random, size = 10] |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
278 |
oops |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
279 |
|
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
280 |
lemma |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
281 |
"(x :: rat) > 0 ==> y > 0 ==> z > 0 ==> x * x + y * y \<noteq> z * z" |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
282 |
quickcheck[exhaustive, size = 10, expect = counterexample] |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
283 |
quickcheck[random, size = 10] |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
284 |
oops |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
285 |
|
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
286 |
lemma |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
287 |
"(x :: real) > 0 ==> y > 0 ==> z > 0 ==> x * x + y * y \<noteq> z * z" |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
288 |
quickcheck[exhaustive, size = 10, expect = counterexample] |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
289 |
quickcheck[random, size = 10] |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
290 |
oops |
2e901158675e
adding exhaustive tester instances for numeric types: code_numeral, nat, rat and real
bulwahn
parents:
40917
diff
changeset
|
291 |
|
14592 | 292 |
end |