author | huffman |
Sat, 27 Nov 2010 14:34:54 -0800 | |
changeset 40773 | 6c12f5e24e34 |
parent 39359 | 6f49c7fbb1b1 |
child 40992 | 8cacefe9851c |
permissions | -rw-r--r-- |
33197 | 1 |
(* Title: HOL/Nitpick_Examples/Mono_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:
35071
diff
changeset
|
3 |
Copyright 2009, 2010 |
33197 | 4 |
|
5 |
Examples featuring Nitpick's monotonicity check. |
|
6 |
*) |
|
7 |
||
8 |
header {* Examples Featuring Nitpick's Monotonicity Check *} |
|
9 |
||
10 |
theory Mono_Nits |
|
11 |
imports Main |
|
12 |
begin |
|
13 |
||
14 |
ML {* |
|
15 |
exception FAIL |
|
16 |
||
35339 | 17 |
val subst = [] |
37268 | 18 |
val defs = Nitpick_HOL.all_axioms_of @{context} subst |> #1 |
35339 | 19 |
val def_table = Nitpick_HOL.const_def_table @{context} subst defs |
35071
3df45b0ce819
adapted example following previous Nitpick change and fixed minor optimization in Nitpick
blanchet
parents:
34982
diff
changeset
|
20 |
val hol_ctxt : Nitpick_HOL.hol_context = |
33197 | 21 |
{thy = @{theory}, ctxt = @{context}, max_bisim_depth = ~1, boxes = [], |
34982
7b8c366e34a2
added support for nonstandard models to Nitpick (based on an idea by Koen Claessen) and did other fixes to Nitpick
blanchet
parents:
34124
diff
changeset
|
22 |
stds = [(NONE, true)], wfs = [], user_axioms = NONE, debug = false, |
38210 | 23 |
whacks = [], binary_ints = SOME false, destroy_constrs = false, |
39359 | 24 |
specialize = false, star_linear_preds = false, tac_timeout = NONE, |
25 |
evals = [], case_names = [], def_table = def_table, |
|
36389
8228b3a4a2ba
remove "skolemize" option from Nitpick, since Skolemization is always useful
blanchet
parents:
35812
diff
changeset
|
26 |
nondef_table = Symtab.empty, user_nondefs = [], |
34124
c4628a1dcf75
added support for binary nat/int representation to Nitpick
blanchet
parents:
33698
diff
changeset
|
27 |
simp_table = Unsynchronized.ref Symtab.empty, psimp_table = Symtab.empty, |
35807
e4d1b5cbd429
added support for "specification" and "ax_specification" constructs to Nitpick
blanchet
parents:
35386
diff
changeset
|
28 |
choice_spec_table = Symtab.empty, intro_table = Symtab.empty, |
e4d1b5cbd429
added support for "specification" and "ax_specification" constructs to Nitpick
blanchet
parents:
35386
diff
changeset
|
29 |
ground_thm_table = Inttab.empty, ersatz_table = [], |
e4d1b5cbd429
added support for "specification" and "ax_specification" constructs to Nitpick
blanchet
parents:
35386
diff
changeset
|
30 |
skolems = Unsynchronized.ref [], special_funs = Unsynchronized.ref [], |
e4d1b5cbd429
added support for "specification" and "ax_specification" constructs to Nitpick
blanchet
parents:
35386
diff
changeset
|
31 |
unrolled_preds = Unsynchronized.ref [], wf_cache = Unsynchronized.ref [], |
e4d1b5cbd429
added support for "specification" and "ax_specification" constructs to Nitpick
blanchet
parents:
35386
diff
changeset
|
32 |
constr_cache = Unsynchronized.ref []} |
33197 | 33 |
(* term -> bool *) |
35812
394fe2b064cd
solve error in "Nitpick_Mono" + short path when no finite functions are inferred
blanchet
parents:
35807
diff
changeset
|
34 |
fun is_mono t = |
394fe2b064cd
solve error in "Nitpick_Mono" + short path when no finite functions are inferred
blanchet
parents:
35807
diff
changeset
|
35 |
Nitpick_Mono.formulas_monotonic hol_ctxt false @{typ 'a} ([t], []) |
33197 | 36 |
fun is_const t = |
37 |
let val T = fastype_of t in |
|
38 |
is_mono (Logic.mk_implies (Logic.mk_equals (Free ("dummyP", T), t), |
|
39 |
@{const False})) |
|
40 |
end |
|
41 |
fun mono t = is_mono t orelse raise FAIL |
|
42 |
fun nonmono t = not (is_mono t) orelse raise FAIL |
|
43 |
fun const t = is_const t orelse raise FAIL |
|
44 |
fun nonconst t = not (is_const t) orelse raise FAIL |
|
45 |
*} |
|
46 |
||
47 |
ML {* const @{term "A::('a\<Rightarrow>'b)"} *} |
|
48 |
ML {* const @{term "(A::'a set) = A"} *} |
|
49 |
ML {* const @{term "(A::'a set set) = A"} *} |
|
50 |
ML {* const @{term "(\<lambda>x::'a set. x a)"} *} |
|
35386
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
51 |
ML {* const @{term "{{a::'a}} = C"} *} |
33197 | 52 |
ML {* const @{term "{f::'a\<Rightarrow>nat} = {g::'a\<Rightarrow>nat}"} *} |
35386
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
53 |
ML {* const @{term "A \<union> (B::'a set)"} *} |
33197 | 54 |
ML {* const @{term "P (a::'a)"} *} |
55 |
ML {* const @{term "\<lambda>a::'a. b (c (d::'a)) (e::'a) (f::'a)"} *} |
|
56 |
ML {* const @{term "\<forall>A::'a set. A a"} *} |
|
57 |
ML {* const @{term "\<forall>A::'a set. P A"} *} |
|
58 |
ML {* const @{term "P \<or> Q"} *} |
|
35386
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
59 |
ML {* const @{term "A \<union> B = (C::'a set)"} *} |
33197 | 60 |
ML {* const @{term "(if P then (A::'a set) else B) = C"} *} |
35386
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
61 |
ML {* const @{term "let A = (C::'a set) in A \<union> B"} *} |
33197 | 62 |
ML {* const @{term "THE x::'b. P x"} *} |
35386
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
63 |
ML {* const @{term "(\<lambda>x::'a. False)"} *} |
33197 | 64 |
ML {* const @{term "(\<lambda>x::'a. True)"} *} |
35386
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
65 |
ML {* const @{term "Let (a::'a) A"} *} |
33197 | 66 |
ML {* const @{term "A (a::'a)"} *} |
35386
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
67 |
ML {* const @{term "insert (a::'a) A = B"} *} |
33197 | 68 |
ML {* const @{term "- (A::'a set)"} *} |
35386
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
69 |
ML {* const @{term "finite (A::'a set)"} *} |
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
70 |
ML {* const @{term "\<not> finite (A::'a set)"} *} |
33197 | 71 |
ML {* const @{term "finite (A::'a set set)"} *} |
72 |
ML {* const @{term "\<lambda>a::'a. A a \<and> \<not> B a"} *} |
|
73 |
ML {* const @{term "A < (B::'a set)"} *} |
|
74 |
ML {* const @{term "A \<le> (B::'a set)"} *} |
|
75 |
ML {* const @{term "[a::'a]"} *} |
|
76 |
ML {* const @{term "[a::'a set]"} *} |
|
77 |
ML {* const @{term "[A \<union> (B::'a set)]"} *} |
|
78 |
ML {* const @{term "[A \<union> (B::'a set)] = [C]"} *} |
|
37477
e482320bcbfe
adjusted Nitpick examples to latest changes + make them slightly faster
blanchet
parents:
37268
diff
changeset
|
79 |
ML {* const @{term "{(\<lambda>x::'a. x = a)} = C"} *} |
33197 | 80 |
|
81 |
ML {* nonconst @{term "\<forall>P (a::'a). P a"} *} |
|
82 |
ML {* nonconst @{term "\<forall>a::'a. P a"} *} |
|
83 |
ML {* nonconst @{term "(\<lambda>a::'a. \<not> A a) = B"} *} |
|
35386
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
84 |
ML {* nonconst @{term "THE x::'a. P x"} *} |
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
85 |
ML {* nonconst @{term "SOME x::'a. P x"} *} |
33197 | 86 |
|
87 |
ML {* mono @{prop "Q (\<forall>x::'a set. P x)"} *} |
|
88 |
ML {* mono @{prop "P (a::'a)"} *} |
|
35386
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
89 |
ML {* mono @{prop "{a} = {b::'a}"} *} |
33197 | 90 |
ML {* mono @{prop "P (a::'a) \<and> P \<union> P = P"} *} |
91 |
ML {* mono @{prop "\<forall>F::'a set set. P"} *} |
|
92 |
ML {* mono @{prop "\<not> (\<forall>F f g (h::'a set). F f \<and> F g \<and> \<not> f a \<and> g a \<longrightarrow> F h)"} *} |
|
93 |
ML {* mono @{prop "\<not> Q (\<forall>x::'a set. P x)"} *} |
|
35386
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
94 |
ML {* mono @{prop "\<not> (\<forall>x::'a. P x)"} *} |
33197 | 95 |
|
35386
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
96 |
ML {* nonmono @{prop "\<forall>x::'a. P x"} *} |
45a4e19d3ebd
more work on the new monotonicity stuff in Nitpick
blanchet
parents:
35385
diff
changeset
|
97 |
ML {* nonmono @{prop "myall P = (P = (\<lambda>x::'a. True))"} *} |
33197 | 98 |
ML {* nonmono @{prop "\<forall>F f g (h::'a set). F f \<and> F g \<and> \<not> f a \<and> g a \<longrightarrow> F h"} *} |
99 |
||
100 |
end |