| author | krauss |
| Mon, 30 May 2011 17:07:48 +0200 | |
| changeset 43071 | c9859f634cef |
| parent 42756 | 6b7ef9b724fd |
| permissions | -rw-r--r-- |
| 42343 | 1 |
(* Title: HOL/Metis_Examples/Clausify.thy |
| 42338 | 2 |
Author: Jasmin Blanchette, TU Muenchen |
3 |
||
4 |
Testing Metis's clausifier. |
|
5 |
*) |
|
6 |
||
| 42343 | 7 |
theory Clausify |
| 42338 | 8 |
imports Complex_Main |
9 |
begin |
|
10 |
||
11 |
(* FIXME: shouldn't need this *) |
|
12 |
declare [[unify_search_bound = 100]] |
|
13 |
declare [[unify_trace_bound = 100]] |
|
14 |
||
|
42747
f132d13fcf75
use the same code for extensionalization in Metis and Sledgehammer and generalize that code so that it gracefully handles negations (e.g. negated conjecture), formulas of the form (%x. t) = u, etc.
blanchet
parents:
42350
diff
changeset
|
15 |
|
| 42345 | 16 |
text {* Definitional CNF for facts *}
|
17 |
||
18 |
declare [[meson_max_clauses = 10]] |
|
19 |
||
20 |
axiomatization q :: "nat \<Rightarrow> nat \<Rightarrow> bool" where |
|
21 |
qax: "\<exists>b. \<forall>a. (q b a \<and> q 0 0 \<and> q 1 a \<and> q a 1) \<or> (q 0 1 \<and> q 1 0 \<and> q a b \<and> q 1 1)" |
|
22 |
||
23 |
declare [[metis_new_skolemizer = false]] |
|
24 |
||
25 |
lemma "\<exists>b. \<forall>a. (q b a \<or> q a b)" |
|
26 |
by (metis qax) |
|
27 |
||
28 |
lemma "\<exists>b. \<forall>a. (q b a \<or> q a b)" |
|
29 |
by (metisFT qax) |
|
30 |
||
31 |
lemma "\<exists>b. \<forall>a. (q b a \<and> q 0 0 \<and> q 1 a \<and> q a 1) \<or> (q 0 1 \<and> q 1 0 \<and> q a b \<and> q 1 1)" |
|
32 |
by (metis qax) |
|
33 |
||
34 |
lemma "\<exists>b. \<forall>a. (q b a \<and> q 0 0 \<and> q 1 a \<and> q a 1) \<or> (q 0 1 \<and> q 1 0 \<and> q a b \<and> q 1 1)" |
|
35 |
by (metisFT qax) |
|
36 |
||
37 |
declare [[metis_new_skolemizer]] |
|
38 |
||
39 |
lemma "\<exists>b. \<forall>a. (q b a \<or> q a b)" |
|
40 |
by (metis qax) |
|
41 |
||
42 |
lemma "\<exists>b. \<forall>a. (q b a \<or> q a b)" |
|
43 |
by (metisFT qax) |
|
44 |
||
45 |
lemma "\<exists>b. \<forall>a. (q b a \<and> q 0 0 \<and> q 1 a \<and> q a 1) \<or> (q 0 1 \<and> q 1 0 \<and> q a b \<and> q 1 1)" |
|
46 |
by (metis qax) |
|
47 |
||
48 |
lemma "\<exists>b. \<forall>a. (q b a \<and> q 0 0 \<and> q 1 a \<and> q a 1) \<or> (q 0 1 \<and> q 1 0 \<and> q a b \<and> q 1 1)" |
|
49 |
by (metisFT qax) |
|
50 |
||
51 |
declare [[meson_max_clauses = 60]] |
|
52 |
||
53 |
axiomatization r :: "nat \<Rightarrow> nat \<Rightarrow> bool" where |
|
54 |
rax: "(r 0 0 \<and> r 0 1 \<and> r 0 2 \<and> r 0 3) \<or> |
|
55 |
(r 1 0 \<and> r 1 1 \<and> r 1 2 \<and> r 1 3) \<or> |
|
56 |
(r 2 0 \<and> r 2 1 \<and> r 2 2 \<and> r 2 3) \<or> |
|
57 |
(r 3 0 \<and> r 3 1 \<and> r 3 2 \<and> r 3 3)" |
|
58 |
||
59 |
declare [[metis_new_skolemizer = false]] |
|
60 |
||
61 |
lemma "r 0 0 \<or> r 1 1 \<or> r 2 2 \<or> r 3 3" |
|
62 |
by (metis rax) |
|
63 |
||
64 |
lemma "r 0 0 \<or> r 1 1 \<or> r 2 2 \<or> r 3 3" |
|
65 |
by (metisFT rax) |
|
66 |
||
67 |
declare [[metis_new_skolemizer]] |
|
68 |
||
69 |
lemma "r 0 0 \<or> r 1 1 \<or> r 2 2 \<or> r 3 3" |
|
70 |
by (metis rax) |
|
71 |
||
72 |
lemma "r 0 0 \<or> r 1 1 \<or> r 2 2 \<or> r 3 3" |
|
73 |
by (metisFT rax) |
|
74 |
||
| 42350 | 75 |
lemma "(r 0 0 \<and> r 0 1 \<and> r 0 2 \<and> r 0 3) \<or> |
76 |
(r 1 0 \<and> r 1 1 \<and> r 1 2 \<and> r 1 3) \<or> |
|
77 |
(r 2 0 \<and> r 2 1 \<and> r 2 2 \<and> r 2 3) \<or> |
|
78 |
(r 3 0 \<and> r 3 1 \<and> r 3 2 \<and> r 3 3)" |
|
79 |
by (metis rax) |
|
80 |
||
81 |
lemma "(r 0 0 \<and> r 0 1 \<and> r 0 2 \<and> r 0 3) \<or> |
|
82 |
(r 1 0 \<and> r 1 1 \<and> r 1 2 \<and> r 1 3) \<or> |
|
83 |
(r 2 0 \<and> r 2 1 \<and> r 2 2 \<and> r 2 3) \<or> |
|
84 |
(r 3 0 \<and> r 3 1 \<and> r 3 2 \<and> r 3 3)" |
|
85 |
by (metisFT rax) |
|
86 |
||
|
42747
f132d13fcf75
use the same code for extensionalization in Metis and Sledgehammer and generalize that code so that it gracefully handles negations (e.g. negated conjecture), formulas of the form (%x. t) = u, etc.
blanchet
parents:
42350
diff
changeset
|
87 |
|
| 42345 | 88 |
text {* Definitional CNF for goal *}
|
89 |
||
| 42338 | 90 |
axiomatization p :: "nat \<Rightarrow> nat \<Rightarrow> bool" where |
| 42345 | 91 |
pax: "\<exists>b. \<forall>a. (p b a \<and> p 0 0 \<and> p 1 a) \<or> (p 0 1 \<and> p 1 0 \<and> p a b)" |
| 42338 | 92 |
|
93 |
declare [[metis_new_skolemizer = false]] |
|
94 |
||
95 |
lemma "\<exists>b. \<forall>a. \<exists>x. (p b a \<or> x) \<and> (p 0 0 \<or> x) \<and> (p 1 a \<or> x) \<and> |
|
96 |
(p 0 1 \<or> \<not> x) \<and> (p 1 0 \<or> \<not> x) \<and> (p a b \<or> \<not> x)" |
|
97 |
by (metis pax) |
|
98 |
||
99 |
lemma "\<exists>b. \<forall>a. \<exists>x. (p b a \<or> x) \<and> (p 0 0 \<or> x) \<and> (p 1 a \<or> x) \<and> |
|
100 |
(p 0 1 \<or> \<not> x) \<and> (p 1 0 \<or> \<not> x) \<and> (p a b \<or> \<not> x)" |
|
101 |
by (metisFT pax) |
|
102 |
||
103 |
declare [[metis_new_skolemizer]] |
|
104 |
||
105 |
lemma "\<exists>b. \<forall>a. \<exists>x. (p b a \<or> x) \<and> (p 0 0 \<or> x) \<and> (p 1 a \<or> x) \<and> |
|
106 |
(p 0 1 \<or> \<not> x) \<and> (p 1 0 \<or> \<not> x) \<and> (p a b \<or> \<not> x)" |
|
107 |
by (metis pax) |
|
108 |
||
109 |
lemma "\<exists>b. \<forall>a. \<exists>x. (p b a \<or> x) \<and> (p 0 0 \<or> x) \<and> (p 1 a \<or> x) \<and> |
|
110 |
(p 0 1 \<or> \<not> x) \<and> (p 1 0 \<or> \<not> x) \<and> (p a b \<or> \<not> x)" |
|
111 |
by (metisFT pax) |
|
112 |
||
|
42747
f132d13fcf75
use the same code for extensionalization in Metis and Sledgehammer and generalize that code so that it gracefully handles negations (e.g. negated conjecture), formulas of the form (%x. t) = u, etc.
blanchet
parents:
42350
diff
changeset
|
113 |
|
| 42338 | 114 |
text {* New Skolemizer *}
|
115 |
||
116 |
declare [[metis_new_skolemizer]] |
|
117 |
||
118 |
lemma |
|
119 |
fixes x :: real |
|
|
42342
6babd86a54a4
handle case where the same Skolem name is given different types in different subgoals in the new Skolemizer (this can happen if several type-instances of the same fact are needed by Metis, cf. example in "Clausify.thy") -- the solution reintroduces old code removed in a6725f293377
blanchet
parents:
42340
diff
changeset
|
120 |
assumes fn_le: "!!n. f n \<le> x" and 1: "f ----> lim f" |
| 42338 | 121 |
shows "lim f \<le> x" |
122 |
by (metis 1 LIMSEQ_le_const2 fn_le) |
|
123 |
||
124 |
definition |
|
125 |
bounded :: "'a::metric_space set \<Rightarrow> bool" where |
|
126 |
"bounded S \<longleftrightarrow> (\<exists>x eee. \<forall>y\<in>S. dist x y \<le> eee)" |
|
127 |
||
128 |
lemma "bounded T \<Longrightarrow> S \<subseteq> T ==> bounded S" |
|
129 |
by (metis bounded_def subset_eq) |
|
130 |
||
131 |
lemma |
|
132 |
assumes a: "Quotient R Abs Rep" |
|
133 |
shows "symp R" |
|
134 |
using a unfolding Quotient_def using sympI |
|
135 |
by metisFT |
|
136 |
||
137 |
lemma |
|
138 |
"(\<exists>x \<in> set xs. P x) \<longleftrightarrow> |
|
|
42342
6babd86a54a4
handle case where the same Skolem name is given different types in different subgoals in the new Skolemizer (this can happen if several type-instances of the same fact are needed by Metis, cf. example in "Clausify.thy") -- the solution reintroduces old code removed in a6725f293377
blanchet
parents:
42340
diff
changeset
|
139 |
(\<exists>ys x zs. xs = ys @ x # zs \<and> P x \<and> (\<forall>z \<in> set zs. \<not> P z))" |
| 42338 | 140 |
by (metis split_list_last_prop [where P = P] in_set_conv_decomp) |
141 |
||
|
42342
6babd86a54a4
handle case where the same Skolem name is given different types in different subgoals in the new Skolemizer (this can happen if several type-instances of the same fact are needed by Metis, cf. example in "Clausify.thy") -- the solution reintroduces old code removed in a6725f293377
blanchet
parents:
42340
diff
changeset
|
142 |
lemma ex_tl: "EX ys. tl ys = xs" |
|
6babd86a54a4
handle case where the same Skolem name is given different types in different subgoals in the new Skolemizer (this can happen if several type-instances of the same fact are needed by Metis, cf. example in "Clausify.thy") -- the solution reintroduces old code removed in a6725f293377
blanchet
parents:
42340
diff
changeset
|
143 |
using tl.simps(2) by fast |
|
6babd86a54a4
handle case where the same Skolem name is given different types in different subgoals in the new Skolemizer (this can happen if several type-instances of the same fact are needed by Metis, cf. example in "Clausify.thy") -- the solution reintroduces old code removed in a6725f293377
blanchet
parents:
42340
diff
changeset
|
144 |
|
|
6babd86a54a4
handle case where the same Skolem name is given different types in different subgoals in the new Skolemizer (this can happen if several type-instances of the same fact are needed by Metis, cf. example in "Clausify.thy") -- the solution reintroduces old code removed in a6725f293377
blanchet
parents:
42340
diff
changeset
|
145 |
lemma "(\<exists>ys\<Colon>nat list. tl ys = xs) \<and> (\<exists>bs\<Colon>int list. tl bs = as)" |
|
6babd86a54a4
handle case where the same Skolem name is given different types in different subgoals in the new Skolemizer (this can happen if several type-instances of the same fact are needed by Metis, cf. example in "Clausify.thy") -- the solution reintroduces old code removed in a6725f293377
blanchet
parents:
42340
diff
changeset
|
146 |
by (metis ex_tl) |
|
6babd86a54a4
handle case where the same Skolem name is given different types in different subgoals in the new Skolemizer (this can happen if several type-instances of the same fact are needed by Metis, cf. example in "Clausify.thy") -- the solution reintroduces old code removed in a6725f293377
blanchet
parents:
42340
diff
changeset
|
147 |
|
| 42338 | 148 |
end |