| author | blanchet |
| Thu, 14 Apr 2011 11:24:05 +0200 | |
| changeset 42351 | ad89f5462cdc |
| parent 42350 | 128dc0fa87fc |
| child 42747 | f132d13fcf75 |
| 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 |
||
| 42345 | 15 |
text {* Definitional CNF for facts *}
|
16 |
||
17 |
declare [[meson_max_clauses = 10]] |
|
18 |
||
19 |
axiomatization q :: "nat \<Rightarrow> nat \<Rightarrow> bool" where |
|
20 |
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)" |
|
21 |
||
22 |
declare [[metis_new_skolemizer = false]] |
|
23 |
||
24 |
lemma "\<exists>b. \<forall>a. (q b a \<or> q a b)" |
|
25 |
by (metis qax) |
|
26 |
||
27 |
lemma "\<exists>b. \<forall>a. (q b a \<or> q a b)" |
|
28 |
by (metisFT qax) |
|
29 |
||
30 |
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)" |
|
31 |
by (metis qax) |
|
32 |
||
33 |
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)" |
|
34 |
by (metisFT qax) |
|
35 |
||
36 |
declare [[metis_new_skolemizer]] |
|
37 |
||
38 |
lemma "\<exists>b. \<forall>a. (q b a \<or> q a b)" |
|
39 |
by (metis qax) |
|
40 |
||
41 |
lemma "\<exists>b. \<forall>a. (q b a \<or> q a b)" |
|
42 |
by (metisFT qax) |
|
43 |
||
44 |
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)" |
|
45 |
by (metis qax) |
|
46 |
||
47 |
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)" |
|
48 |
by (metisFT qax) |
|
49 |
||
50 |
declare [[meson_max_clauses = 60]] |
|
51 |
||
52 |
axiomatization r :: "nat \<Rightarrow> nat \<Rightarrow> bool" where |
|
53 |
rax: "(r 0 0 \<and> r 0 1 \<and> r 0 2 \<and> r 0 3) \<or> |
|
54 |
(r 1 0 \<and> r 1 1 \<and> r 1 2 \<and> r 1 3) \<or> |
|
55 |
(r 2 0 \<and> r 2 1 \<and> r 2 2 \<and> r 2 3) \<or> |
|
56 |
(r 3 0 \<and> r 3 1 \<and> r 3 2 \<and> r 3 3)" |
|
57 |
||
58 |
declare [[metis_new_skolemizer = false]] |
|
59 |
||
60 |
lemma "r 0 0 \<or> r 1 1 \<or> r 2 2 \<or> r 3 3" |
|
61 |
by (metis rax) |
|
62 |
||
63 |
lemma "r 0 0 \<or> r 1 1 \<or> r 2 2 \<or> r 3 3" |
|
64 |
by (metisFT rax) |
|
65 |
||
66 |
declare [[metis_new_skolemizer]] |
|
67 |
||
68 |
lemma "r 0 0 \<or> r 1 1 \<or> r 2 2 \<or> r 3 3" |
|
69 |
by (metis rax) |
|
70 |
||
71 |
lemma "r 0 0 \<or> r 1 1 \<or> r 2 2 \<or> r 3 3" |
|
72 |
by (metisFT rax) |
|
73 |
||
| 42350 | 74 |
lemma "(r 0 0 \<and> r 0 1 \<and> r 0 2 \<and> r 0 3) \<or> |
75 |
(r 1 0 \<and> r 1 1 \<and> r 1 2 \<and> r 1 3) \<or> |
|
76 |
(r 2 0 \<and> r 2 1 \<and> r 2 2 \<and> r 2 3) \<or> |
|
77 |
(r 3 0 \<and> r 3 1 \<and> r 3 2 \<and> r 3 3)" |
|
78 |
by (metis rax) |
|
79 |
||
80 |
lemma "(r 0 0 \<and> r 0 1 \<and> r 0 2 \<and> r 0 3) \<or> |
|
81 |
(r 1 0 \<and> r 1 1 \<and> r 1 2 \<and> r 1 3) \<or> |
|
82 |
(r 2 0 \<and> r 2 1 \<and> r 2 2 \<and> r 2 3) \<or> |
|
83 |
(r 3 0 \<and> r 3 1 \<and> r 3 2 \<and> r 3 3)" |
|
84 |
by (metisFT rax) |
|
85 |
||
| 42345 | 86 |
text {* Definitional CNF for goal *}
|
87 |
||
| 42338 | 88 |
axiomatization p :: "nat \<Rightarrow> nat \<Rightarrow> bool" where |
| 42345 | 89 |
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 | 90 |
|
91 |
declare [[metis_new_skolemizer = false]] |
|
92 |
||
93 |
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> |
|
94 |
(p 0 1 \<or> \<not> x) \<and> (p 1 0 \<or> \<not> x) \<and> (p a b \<or> \<not> x)" |
|
95 |
by (metis pax) |
|
96 |
||
97 |
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> |
|
98 |
(p 0 1 \<or> \<not> x) \<and> (p 1 0 \<or> \<not> x) \<and> (p a b \<or> \<not> x)" |
|
99 |
by (metisFT pax) |
|
100 |
||
101 |
declare [[metis_new_skolemizer]] |
|
102 |
||
103 |
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> |
|
104 |
(p 0 1 \<or> \<not> x) \<and> (p 1 0 \<or> \<not> x) \<and> (p a b \<or> \<not> x)" |
|
105 |
by (metis pax) |
|
106 |
||
107 |
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> |
|
108 |
(p 0 1 \<or> \<not> x) \<and> (p 1 0 \<or> \<not> x) \<and> (p a b \<or> \<not> x)" |
|
109 |
by (metisFT pax) |
|
110 |
||
111 |
text {* New Skolemizer *}
|
|
112 |
||
113 |
declare [[metis_new_skolemizer]] |
|
114 |
||
115 |
lemma |
|
116 |
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
|
117 |
assumes fn_le: "!!n. f n \<le> x" and 1: "f ----> lim f" |
| 42338 | 118 |
shows "lim f \<le> x" |
119 |
by (metis 1 LIMSEQ_le_const2 fn_le) |
|
120 |
||
121 |
definition |
|
122 |
bounded :: "'a::metric_space set \<Rightarrow> bool" where |
|
123 |
"bounded S \<longleftrightarrow> (\<exists>x eee. \<forall>y\<in>S. dist x y \<le> eee)" |
|
124 |
||
125 |
lemma "bounded T \<Longrightarrow> S \<subseteq> T ==> bounded S" |
|
126 |
by (metis bounded_def subset_eq) |
|
127 |
||
128 |
lemma |
|
129 |
assumes a: "Quotient R Abs Rep" |
|
130 |
shows "symp R" |
|
131 |
using a unfolding Quotient_def using sympI |
|
132 |
by metisFT |
|
133 |
||
134 |
lemma |
|
135 |
"(\<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
|
136 |
(\<exists>ys x zs. xs = ys @ x # zs \<and> P x \<and> (\<forall>z \<in> set zs. \<not> P z))" |
| 42338 | 137 |
by (metis split_list_last_prop [where P = P] in_set_conv_decomp) |
138 |
||
|
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 |
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
|
140 |
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
|
141 |
|
|
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 "(\<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
|
143 |
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
|
144 |
|
| 42338 | 145 |
end |