39941
|
1 |
(* Title: HOL/Meson.thy
|
39944
|
2 |
Author: Lawrence C. Paulson, Cambridge University Computer Laboratory
|
|
3 |
Author: Tobias Nipkow, TU Muenchen
|
|
4 |
Author: Jasmin Blanchette, TU Muenchen
|
39941
|
5 |
Copyright 2001 University of Cambridge
|
|
6 |
*)
|
|
7 |
|
|
8 |
header {* MESON Proof Procedure (Model Elimination) *}
|
|
9 |
|
|
10 |
theory Meson
|
39946
|
11 |
imports Datatype
|
39941
|
12 |
uses ("Tools/Meson/meson.ML")
|
|
13 |
("Tools/Meson/meson_clausify.ML")
|
|
14 |
begin
|
|
15 |
|
|
16 |
section {* Negation Normal Form *}
|
|
17 |
|
|
18 |
text {* de Morgan laws *}
|
|
19 |
|
|
20 |
lemma meson_not_conjD: "~(P&Q) ==> ~P | ~Q"
|
|
21 |
and meson_not_disjD: "~(P|Q) ==> ~P & ~Q"
|
|
22 |
and meson_not_notD: "~~P ==> P"
|
|
23 |
and meson_not_allD: "!!P. ~(\<forall>x. P(x)) ==> \<exists>x. ~P(x)"
|
|
24 |
and meson_not_exD: "!!P. ~(\<exists>x. P(x)) ==> \<forall>x. ~P(x)"
|
|
25 |
by fast+
|
|
26 |
|
|
27 |
text {* Removal of @{text "-->"} and @{text "<->"} (positive and
|
|
28 |
negative occurrences) *}
|
|
29 |
|
|
30 |
lemma meson_imp_to_disjD: "P-->Q ==> ~P | Q"
|
|
31 |
and meson_not_impD: "~(P-->Q) ==> P & ~Q"
|
|
32 |
and meson_iff_to_disjD: "P=Q ==> (~P | Q) & (~Q | P)"
|
|
33 |
and meson_not_iffD: "~(P=Q) ==> (P | Q) & (~P | ~Q)"
|
|
34 |
-- {* Much more efficient than @{prop "(P & ~Q) | (Q & ~P)"} for computing CNF *}
|
|
35 |
and meson_not_refl_disj_D: "x ~= x | P ==> P"
|
|
36 |
by fast+
|
|
37 |
|
|
38 |
|
|
39 |
section {* Pulling out the existential quantifiers *}
|
|
40 |
|
|
41 |
text {* Conjunction *}
|
|
42 |
|
|
43 |
lemma meson_conj_exD1: "!!P Q. (\<exists>x. P(x)) & Q ==> \<exists>x. P(x) & Q"
|
|
44 |
and meson_conj_exD2: "!!P Q. P & (\<exists>x. Q(x)) ==> \<exists>x. P & Q(x)"
|
|
45 |
by fast+
|
|
46 |
|
|
47 |
|
|
48 |
text {* Disjunction *}
|
|
49 |
|
|
50 |
lemma meson_disj_exD: "!!P Q. (\<exists>x. P(x)) | (\<exists>x. Q(x)) ==> \<exists>x. P(x) | Q(x)"
|
|
51 |
-- {* DO NOT USE with forall-Skolemization: makes fewer schematic variables!! *}
|
|
52 |
-- {* With ex-Skolemization, makes fewer Skolem constants *}
|
|
53 |
and meson_disj_exD1: "!!P Q. (\<exists>x. P(x)) | Q ==> \<exists>x. P(x) | Q"
|
|
54 |
and meson_disj_exD2: "!!P Q. P | (\<exists>x. Q(x)) ==> \<exists>x. P | Q(x)"
|
|
55 |
by fast+
|
|
56 |
|
|
57 |
lemma meson_disj_assoc: "(P|Q)|R ==> P|(Q|R)"
|
|
58 |
and meson_disj_comm: "P|Q ==> Q|P"
|
|
59 |
and meson_disj_FalseD1: "False|P ==> P"
|
|
60 |
and meson_disj_FalseD2: "P|False ==> P"
|
|
61 |
by fast+
|
|
62 |
|
|
63 |
|
|
64 |
text{* Generation of contrapositives *}
|
|
65 |
|
|
66 |
text{*Inserts negated disjunct after removing the negation; P is a literal.
|
|
67 |
Model elimination requires assuming the negation of every attempted subgoal,
|
|
68 |
hence the negated disjuncts.*}
|
|
69 |
lemma make_neg_rule: "~P|Q ==> ((~P==>P) ==> Q)"
|
|
70 |
by blast
|
|
71 |
|
|
72 |
text{*Version for Plaisted's "Postive refinement" of the Meson procedure*}
|
|
73 |
lemma make_refined_neg_rule: "~P|Q ==> (P ==> Q)"
|
|
74 |
by blast
|
|
75 |
|
|
76 |
text{*@{term P} should be a literal*}
|
|
77 |
lemma make_pos_rule: "P|Q ==> ((P==>~P) ==> Q)"
|
|
78 |
by blast
|
|
79 |
|
|
80 |
text{*Versions of @{text make_neg_rule} and @{text make_pos_rule} that don't
|
|
81 |
insert new assumptions, for ordinary resolution.*}
|
|
82 |
|
|
83 |
lemmas make_neg_rule' = make_refined_neg_rule
|
|
84 |
|
|
85 |
lemma make_pos_rule': "[|P|Q; ~P|] ==> Q"
|
|
86 |
by blast
|
|
87 |
|
|
88 |
text{* Generation of a goal clause -- put away the final literal *}
|
|
89 |
|
|
90 |
lemma make_neg_goal: "~P ==> ((~P==>P) ==> False)"
|
|
91 |
by blast
|
|
92 |
|
|
93 |
lemma make_pos_goal: "P ==> ((P==>~P) ==> False)"
|
|
94 |
by blast
|
|
95 |
|
|
96 |
|
|
97 |
section {* Lemmas for Forward Proof *}
|
|
98 |
|
|
99 |
text{*There is a similarity to congruence rules*}
|
|
100 |
|
|
101 |
(*NOTE: could handle conjunctions (faster?) by
|
|
102 |
nf(th RS conjunct2) RS (nf(th RS conjunct1) RS conjI) *)
|
|
103 |
lemma conj_forward: "[| P'&Q'; P' ==> P; Q' ==> Q |] ==> P&Q"
|
|
104 |
by blast
|
|
105 |
|
|
106 |
lemma disj_forward: "[| P'|Q'; P' ==> P; Q' ==> Q |] ==> P|Q"
|
|
107 |
by blast
|
|
108 |
|
|
109 |
(*Version of @{text disj_forward} for removal of duplicate literals*)
|
|
110 |
lemma disj_forward2:
|
|
111 |
"[| P'|Q'; P' ==> P; [| Q'; P==>False |] ==> Q |] ==> P|Q"
|
|
112 |
apply blast
|
|
113 |
done
|
|
114 |
|
|
115 |
lemma all_forward: "[| \<forall>x. P'(x); !!x. P'(x) ==> P(x) |] ==> \<forall>x. P(x)"
|
|
116 |
by blast
|
|
117 |
|
|
118 |
lemma ex_forward: "[| \<exists>x. P'(x); !!x. P'(x) ==> P(x) |] ==> \<exists>x. P(x)"
|
|
119 |
by blast
|
|
120 |
|
|
121 |
|
|
122 |
section {* Clausification helper *}
|
|
123 |
|
|
124 |
lemma TruepropI: "P \<equiv> Q \<Longrightarrow> Trueprop P \<equiv> Trueprop Q"
|
|
125 |
by simp
|
|
126 |
|
|
127 |
|
|
128 |
text{* Combinator translation helpers *}
|
|
129 |
|
|
130 |
definition COMBI :: "'a \<Rightarrow> 'a" where
|
|
131 |
[no_atp]: "COMBI P = P"
|
|
132 |
|
|
133 |
definition COMBK :: "'a \<Rightarrow> 'b \<Rightarrow> 'a" where
|
|
134 |
[no_atp]: "COMBK P Q = P"
|
|
135 |
|
|
136 |
definition COMBB :: "('b => 'c) \<Rightarrow> ('a => 'b) \<Rightarrow> 'a \<Rightarrow> 'c" where [no_atp]:
|
|
137 |
"COMBB P Q R = P (Q R)"
|
|
138 |
|
|
139 |
definition COMBC :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow> 'c" where
|
|
140 |
[no_atp]: "COMBC P Q R = P R Q"
|
|
141 |
|
|
142 |
definition COMBS :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'c" where
|
|
143 |
[no_atp]: "COMBS P Q R = P R (Q R)"
|
|
144 |
|
|
145 |
lemma abs_S [no_atp]: "\<lambda>x. (f x) (g x) \<equiv> COMBS f g"
|
|
146 |
apply (rule eq_reflection)
|
|
147 |
apply (rule ext)
|
|
148 |
apply (simp add: COMBS_def)
|
|
149 |
done
|
|
150 |
|
|
151 |
lemma abs_I [no_atp]: "\<lambda>x. x \<equiv> COMBI"
|
|
152 |
apply (rule eq_reflection)
|
|
153 |
apply (rule ext)
|
|
154 |
apply (simp add: COMBI_def)
|
|
155 |
done
|
|
156 |
|
|
157 |
lemma abs_K [no_atp]: "\<lambda>x. y \<equiv> COMBK y"
|
|
158 |
apply (rule eq_reflection)
|
|
159 |
apply (rule ext)
|
|
160 |
apply (simp add: COMBK_def)
|
|
161 |
done
|
|
162 |
|
|
163 |
lemma abs_B [no_atp]: "\<lambda>x. a (g x) \<equiv> COMBB a g"
|
|
164 |
apply (rule eq_reflection)
|
|
165 |
apply (rule ext)
|
|
166 |
apply (simp add: COMBB_def)
|
|
167 |
done
|
|
168 |
|
|
169 |
lemma abs_C [no_atp]: "\<lambda>x. (f x) b \<equiv> COMBC f b"
|
|
170 |
apply (rule eq_reflection)
|
|
171 |
apply (rule ext)
|
|
172 |
apply (simp add: COMBC_def)
|
|
173 |
done
|
|
174 |
|
|
175 |
|
|
176 |
section {* Skolemization helpers *}
|
|
177 |
|
|
178 |
definition skolem :: "'a \<Rightarrow> 'a" where
|
|
179 |
[no_atp]: "skolem = (\<lambda>x. x)"
|
|
180 |
|
|
181 |
lemma skolem_COMBK_iff: "P \<longleftrightarrow> skolem (COMBK P (i\<Colon>nat))"
|
|
182 |
unfolding skolem_def COMBK_def by (rule refl)
|
|
183 |
|
|
184 |
lemmas skolem_COMBK_I = iffD1 [OF skolem_COMBK_iff]
|
|
185 |
lemmas skolem_COMBK_D = iffD2 [OF skolem_COMBK_iff]
|
|
186 |
|
|
187 |
|
|
188 |
section {* Meson package *}
|
|
189 |
|
|
190 |
ML {*
|
|
191 |
structure Meson_Choices = Named_Thms
|
|
192 |
(
|
|
193 |
val name = "meson_choice"
|
|
194 |
val description = "choice axioms for MESON's (and Metis's) skolemizer"
|
|
195 |
)
|
|
196 |
*}
|
|
197 |
|
|
198 |
use "Tools/Meson/meson.ML"
|
|
199 |
use "Tools/Meson/meson_clausify.ML"
|
|
200 |
|
|
201 |
setup {*
|
|
202 |
Meson_Choices.setup
|
|
203 |
#> Meson.setup
|
|
204 |
#> Meson_Clausify.setup
|
|
205 |
*}
|
|
206 |
|
|
207 |
end
|