| author | wenzelm | 
| Mon, 11 Jul 2016 10:43:27 +0200 | |
| changeset 63433 | aa03b0487bf5 | 
| parent 62381 | a6479cb85944 | 
| child 67091 | 1393c2340eec | 
| permissions | -rw-r--r-- | 
| 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 | ||
| 60758 | 8 | section \<open>MESON Proof Method\<close> | 
| 39941 | 9 | |
| 10 | theory Meson | |
| 54553 | 11 | imports Nat | 
| 39941 | 12 | begin | 
| 13 | ||
| 60758 | 14 | subsection \<open>Negation Normal Form\<close> | 
| 39941 | 15 | |
| 60758 | 16 | text \<open>de Morgan laws\<close> | 
| 39941 | 17 | |
| 39953 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 18 | lemma not_conjD: "~(P&Q) ==> ~P | ~Q" | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 19 | and not_disjD: "~(P|Q) ==> ~P & ~Q" | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 20 | and not_notD: "~~P ==> P" | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 21 | and not_allD: "!!P. ~(\<forall>x. P(x)) ==> \<exists>x. ~P(x)" | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 22 | and not_exD: "!!P. ~(\<exists>x. P(x)) ==> \<forall>x. ~P(x)" | 
| 39941 | 23 | by fast+ | 
| 24 | ||
| 61941 | 25 | text \<open>Removal of \<open>\<longrightarrow>\<close> and \<open>\<longleftrightarrow>\<close> (positive and negative occurrences)\<close> | 
| 39941 | 26 | |
| 39953 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 27 | lemma imp_to_disjD: "P-->Q ==> ~P | Q" | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 28 | and not_impD: "~(P-->Q) ==> P & ~Q" | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 29 | and iff_to_disjD: "P=Q ==> (~P | Q) & (~Q | P)" | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 30 | and not_iffD: "~(P=Q) ==> (P | Q) & (~P | ~Q)" | 
| 61799 | 31 |     \<comment> \<open>Much more efficient than @{prop "(P & ~Q) | (Q & ~P)"} for computing CNF\<close>
 | 
| 39953 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 32 | and not_refl_disj_D: "x ~= x | P ==> P" | 
| 39941 | 33 | by fast+ | 
| 34 | ||
| 35 | ||
| 60758 | 36 | subsection \<open>Pulling out the existential quantifiers\<close> | 
| 39941 | 37 | |
| 60758 | 38 | text \<open>Conjunction\<close> | 
| 39941 | 39 | |
| 39953 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 40 | lemma conj_exD1: "!!P Q. (\<exists>x. P(x)) & Q ==> \<exists>x. P(x) & Q" | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 41 | and conj_exD2: "!!P Q. P & (\<exists>x. Q(x)) ==> \<exists>x. P & Q(x)" | 
| 39941 | 42 | by fast+ | 
| 43 | ||
| 44 | ||
| 60758 | 45 | text \<open>Disjunction\<close> | 
| 39941 | 46 | |
| 39953 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 47 | lemma disj_exD: "!!P Q. (\<exists>x. P(x)) | (\<exists>x. Q(x)) ==> \<exists>x. P(x) | Q(x)" | 
| 61799 | 48 | \<comment> \<open>DO NOT USE with forall-Skolemization: makes fewer schematic variables!!\<close> | 
| 49 | \<comment> \<open>With ex-Skolemization, makes fewer Skolem constants\<close> | |
| 39953 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 50 | and disj_exD1: "!!P Q. (\<exists>x. P(x)) | Q ==> \<exists>x. P(x) | Q" | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 51 | and disj_exD2: "!!P Q. P | (\<exists>x. Q(x)) ==> \<exists>x. P | Q(x)" | 
| 39941 | 52 | by fast+ | 
| 53 | ||
| 39953 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 54 | lemma disj_assoc: "(P|Q)|R ==> P|(Q|R)" | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 55 | and disj_comm: "P|Q ==> Q|P" | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 56 | and disj_FalseD1: "False|P ==> P" | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 57 | and disj_FalseD2: "P|False ==> P" | 
| 39941 | 58 | by fast+ | 
| 59 | ||
| 60 | ||
| 60758 | 61 | text\<open>Generation of contrapositives\<close> | 
| 39941 | 62 | |
| 60758 | 63 | text\<open>Inserts negated disjunct after removing the negation; P is a literal. | 
| 39941 | 64 | Model elimination requires assuming the negation of every attempted subgoal, | 
| 60758 | 65 | hence the negated disjuncts.\<close> | 
| 39941 | 66 | lemma make_neg_rule: "~P|Q ==> ((~P==>P) ==> Q)" | 
| 67 | by blast | |
| 68 | ||
| 60758 | 69 | text\<open>Version for Plaisted's "Postive refinement" of the Meson procedure\<close> | 
| 39941 | 70 | lemma make_refined_neg_rule: "~P|Q ==> (P ==> Q)" | 
| 71 | by blast | |
| 72 | ||
| 60758 | 73 | text\<open>@{term P} should be a literal\<close>
 | 
| 39941 | 74 | lemma make_pos_rule: "P|Q ==> ((P==>~P) ==> Q)" | 
| 75 | by blast | |
| 76 | ||
| 61799 | 77 | text\<open>Versions of \<open>make_neg_rule\<close> and \<open>make_pos_rule\<close> that don't | 
| 60758 | 78 | insert new assumptions, for ordinary resolution.\<close> | 
| 39941 | 79 | |
| 80 | lemmas make_neg_rule' = make_refined_neg_rule | |
| 81 | ||
| 82 | lemma make_pos_rule': "[|P|Q; ~P|] ==> Q" | |
| 83 | by blast | |
| 84 | ||
| 60758 | 85 | text\<open>Generation of a goal clause -- put away the final literal\<close> | 
| 39941 | 86 | |
| 87 | lemma make_neg_goal: "~P ==> ((~P==>P) ==> False)" | |
| 88 | by blast | |
| 89 | ||
| 90 | lemma make_pos_goal: "P ==> ((P==>~P) ==> False)" | |
| 91 | by blast | |
| 92 | ||
| 93 | ||
| 60758 | 94 | subsection \<open>Lemmas for Forward Proof\<close> | 
| 39941 | 95 | |
| 62381 
a6479cb85944
New and revised material for (multivariate) analysis
 paulson <lp15@cam.ac.uk> parents: 
61941diff
changeset | 96 | text\<open>There is a similarity to congruence rules. They are also useful in ordinary proofs.\<close> | 
| 39941 | 97 | |
| 98 | (*NOTE: could handle conjunctions (faster?) by | |
| 99 | nf(th RS conjunct2) RS (nf(th RS conjunct1) RS conjI) *) | |
| 100 | lemma conj_forward: "[| P'&Q'; P' ==> P; Q' ==> Q |] ==> P&Q" | |
| 101 | by blast | |
| 102 | ||
| 103 | lemma disj_forward: "[| P'|Q'; P' ==> P; Q' ==> Q |] ==> P|Q" | |
| 104 | by blast | |
| 105 | ||
| 62381 
a6479cb85944
New and revised material for (multivariate) analysis
 paulson <lp15@cam.ac.uk> parents: 
61941diff
changeset | 106 | lemma imp_forward: "[| P' \<longrightarrow> Q'; P ==> P'; Q' ==> Q |] ==> P \<longrightarrow> Q" | 
| 
a6479cb85944
New and revised material for (multivariate) analysis
 paulson <lp15@cam.ac.uk> parents: 
61941diff
changeset | 107 | by blast | 
| 
a6479cb85944
New and revised material for (multivariate) analysis
 paulson <lp15@cam.ac.uk> parents: 
61941diff
changeset | 108 | |
| 39941 | 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 | ||
| 60758 | 122 | subsection \<open>Clausification helper\<close> | 
| 39941 | 123 | |
| 124 | lemma TruepropI: "P \<equiv> Q \<Longrightarrow> Trueprop P \<equiv> Trueprop Q" | |
| 125 | by simp | |
| 126 | ||
| 47953 
a2c3706c4cb1
added "ext_cong_neq" lemma (not used yet); tuning
 blanchet parents: 
42616diff
changeset | 127 | lemma ext_cong_neq: "F g \<noteq> F h \<Longrightarrow> F g \<noteq> F h \<and> (\<exists>x. g x \<noteq> h x)" | 
| 
a2c3706c4cb1
added "ext_cong_neq" lemma (not used yet); tuning
 blanchet parents: 
42616diff
changeset | 128 | apply (erule contrapos_np) | 
| 
a2c3706c4cb1
added "ext_cong_neq" lemma (not used yet); tuning
 blanchet parents: 
42616diff
changeset | 129 | apply clarsimp | 
| 
a2c3706c4cb1
added "ext_cong_neq" lemma (not used yet); tuning
 blanchet parents: 
42616diff
changeset | 130 | apply (rule cong[where f = F]) | 
| 
a2c3706c4cb1
added "ext_cong_neq" lemma (not used yet); tuning
 blanchet parents: 
42616diff
changeset | 131 | by auto | 
| 
a2c3706c4cb1
added "ext_cong_neq" lemma (not used yet); tuning
 blanchet parents: 
42616diff
changeset | 132 | |
| 39941 | 133 | |
| 60758 | 134 | text\<open>Combinator translation helpers\<close> | 
| 39941 | 135 | |
| 136 | definition COMBI :: "'a \<Rightarrow> 'a" where | |
| 54148 | 137 | "COMBI P = P" | 
| 39941 | 138 | |
| 139 | definition COMBK :: "'a \<Rightarrow> 'b \<Rightarrow> 'a" where | |
| 54148 | 140 | "COMBK P Q = P" | 
| 39941 | 141 | |
| 54148 | 142 | definition COMBB :: "('b => 'c) \<Rightarrow> ('a => 'b) \<Rightarrow> 'a \<Rightarrow> 'c" where
 | 
| 39941 | 143 | "COMBB P Q R = P (Q R)" | 
| 144 | ||
| 145 | definition COMBC :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'b \<Rightarrow> 'a \<Rightarrow> 'c" where
 | |
| 54148 | 146 | "COMBC P Q R = P R Q" | 
| 39941 | 147 | |
| 148 | definition COMBS :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'c" where
 | |
| 54148 | 149 | "COMBS P Q R = P R (Q R)" | 
| 39941 | 150 | |
| 54148 | 151 | lemma abs_S: "\<lambda>x. (f x) (g x) \<equiv> COMBS f g" | 
| 39941 | 152 | apply (rule eq_reflection) | 
| 153 | apply (rule ext) | |
| 154 | apply (simp add: COMBS_def) | |
| 155 | done | |
| 156 | ||
| 54148 | 157 | lemma abs_I: "\<lambda>x. x \<equiv> COMBI" | 
| 39941 | 158 | apply (rule eq_reflection) | 
| 159 | apply (rule ext) | |
| 160 | apply (simp add: COMBI_def) | |
| 161 | done | |
| 162 | ||
| 54148 | 163 | lemma abs_K: "\<lambda>x. y \<equiv> COMBK y" | 
| 39941 | 164 | apply (rule eq_reflection) | 
| 165 | apply (rule ext) | |
| 166 | apply (simp add: COMBK_def) | |
| 167 | done | |
| 168 | ||
| 54148 | 169 | lemma abs_B: "\<lambda>x. a (g x) \<equiv> COMBB a g" | 
| 39941 | 170 | apply (rule eq_reflection) | 
| 171 | apply (rule ext) | |
| 172 | apply (simp add: COMBB_def) | |
| 173 | done | |
| 174 | ||
| 54148 | 175 | lemma abs_C: "\<lambda>x. (f x) b \<equiv> COMBC f b" | 
| 39941 | 176 | apply (rule eq_reflection) | 
| 177 | apply (rule ext) | |
| 178 | apply (simp add: COMBC_def) | |
| 179 | done | |
| 180 | ||
| 181 | ||
| 60758 | 182 | subsection \<open>Skolemization helpers\<close> | 
| 39941 | 183 | |
| 184 | definition skolem :: "'a \<Rightarrow> 'a" where | |
| 54148 | 185 | "skolem = (\<lambda>x. x)" | 
| 39941 | 186 | |
| 61076 | 187 | lemma skolem_COMBK_iff: "P \<longleftrightarrow> skolem (COMBK P (i::nat))" | 
| 39941 | 188 | unfolding skolem_def COMBK_def by (rule refl) | 
| 189 | ||
| 190 | lemmas skolem_COMBK_I = iffD1 [OF skolem_COMBK_iff] | |
| 191 | lemmas skolem_COMBK_D = iffD2 [OF skolem_COMBK_iff] | |
| 192 | ||
| 193 | ||
| 60758 | 194 | subsection \<open>Meson package\<close> | 
| 39941 | 195 | |
| 48891 | 196 | ML_file "Tools/Meson/meson.ML" | 
| 197 | ML_file "Tools/Meson/meson_clausify.ML" | |
| 198 | ML_file "Tools/Meson/meson_tactic.ML" | |
| 39941 | 199 | |
| 39953 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 200 | hide_const (open) COMBI COMBK COMBB COMBC COMBS skolem | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 201 | hide_fact (open) not_conjD not_disjD not_notD not_allD not_exD imp_to_disjD | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 202 | not_impD iff_to_disjD not_iffD not_refl_disj_D conj_exD1 conj_exD2 disj_exD | 
| 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 203 | disj_exD1 disj_exD2 disj_assoc disj_comm disj_FalseD1 disj_FalseD2 TruepropI | 
| 47953 
a2c3706c4cb1
added "ext_cong_neq" lemma (not used yet); tuning
 blanchet parents: 
42616diff
changeset | 204 | ext_cong_neq COMBI_def COMBK_def COMBB_def COMBC_def COMBS_def abs_I abs_K | 
| 
a2c3706c4cb1
added "ext_cong_neq" lemma (not used yet); tuning
 blanchet parents: 
42616diff
changeset | 205 | abs_B abs_C abs_S skolem_def skolem_COMBK_iff skolem_COMBK_I skolem_COMBK_D | 
| 39953 
aa54f347e5e2
hide uninteresting MESON/Metis constants and facts and remove "meson_" prefix to (now hidden) fact names
 blanchet parents: 
39950diff
changeset | 206 | |
| 39941 | 207 | end |