axiomatization
eq :: \<open>['a, 'a] \<Rightarrow> o\<close> (infixl \<open>=\<close> 50) where
refl: \<open>a = a\<close> and
subst: \<open>a = b \<Longrightarrow> P(a) \<Longrightarrow> P(b)\<close>
subsubsection \<open>Propositional logic\<close>
axiomatization
False :: \<open>o\<close> and
conj :: \<open>[o, o] => o\<close> (infixr \<open>\<and>\<close> 35) and
disj :: \<open>[o, o] => o\<close> (infixr \<open>\<or>\<close> 30) and
imp :: \<open>[o, o] => o\<close> (infixr \<open>\<longrightarrow>\<close> 25) where
conjI: \<open>\<lbrakk>P; Q\<rbrakk> \<Longrightarrow> P \<and> Q\<close> and
conjunct1: \<open>P \<and> Q \<Longrightarrow> P\<close> and
conjunct2: \<open>P \<and> Q \<Longrightarrow> Q\<close> and
disjI1: \<open>P \<Longrightarrow> P \<or> Q\<close> and
disjI2: \<open>Q \<Longrightarrow> P \<or> Q\<close> and
disjE: \<open>\<lbrakk>P \<or> Q; P \<Longrightarrow> R; Q \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R\<close> and
impI: \<open>(P \<Longrightarrow> Q) \<Longrightarrow> P \<longrightarrow> Q\<close> and
mp: \<open>\<lbrakk>P \<longrightarrow> Q; P\<rbrakk> \<Longrightarrow> Q\<close> and
FalseE: \<open>False \<Longrightarrow> P\<close>
subsubsection \<open>Quantifiers\<close>
axiomatization
All :: \<open>('a \<Rightarrow> o) \<Rightarrow> o\<close> (binder \<open>\<forall>\<close> 10) and
Ex :: \<open>('a \<Rightarrow> o) \<Rightarrow> o\<close> (binder \<open>\<exists>\<close> 10) where
allI: \<open>(\<And>x. P(x)) \<Longrightarrow> (\<forall>x. P(x))\<close> and
spec: \<open>(\<forall>x. P(x)) \<Longrightarrow> P(x)\<close> and
exI: \<open>P(x) \<Longrightarrow> (\<exists>x. P(x))\<close> and
exE: \<open>\<lbrakk>\<exists>x. P(x); \<And>x. P(x) \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R\<close>
definition Not (\<open>(\<open>open_block notation=\<open>prefix \<not>\<close>\<close>\<not> _)\<close> [40] 40) where not_def: \<open>\<not> P \<equiv> P \<longrightarrow> False\<close>
notation (ASCII)
not_equal (infixl\<open>~=\<close> 50) and
Not (\<open>(\<open>open_block notation=\<open>prefix ~\<close>\<close>~ _)\<close> [40] 40) and
conj (infixr\<open>&\<close> 35) and
disj (infixr\<open>|\<close> 30) and
All (binder\<open>ALL \<close> 10) and
Ex (binder\<open>EX \<close> 10) and
Ex1 (binder\<open>EX! \<close> 10) and
imp (infixr\<open>-->\<close> 25) and
iff (infixr\<open><->\<close> 25)
subsection \<open>Lemmas and proof tools\<close>
lemmas strip = impI allI
lemma TrueI: \<open>True\<close> unfolding True_def by (rule impI)
subsubsection \<open>Sequent-style elimination rules for \<open>\<and>\<close> \<open>\<longrightarrow>\<close> and \<open>\<forall>\<close>\<close>
lemma conjE: assumes major: \<open>P \<and> Q\<close> and r: \<open>\<lbrakk>P; Q\<rbrakk> \<Longrightarrow> R\<close> shows\<open>R\<close> proof (rule r) show"P" by (rule major [THEN conjunct1]) show"Q" by (rule major [THEN conjunct2]) qed
lemma impE: assumes major: \<open>P \<longrightarrow> Q\<close> and\<open>P\<close> and r: \<open>Q \<Longrightarrow> R\<close> shows\<open>R\<close> proof (rule r) show"Q" by (rule mp [OF major \<open>P\<close>]) qed
lemma allE: assumes major: \<open>\<forall>x. P(x)\<close> and r: \<open>P(x) \<Longrightarrow> R\<close> shows\<open>R\<close> proof (rule r) show"P(x)" by (rule major [THEN spec]) qed
text\<open>Duplicates the quantifier; for use with \<^ML>\<open>eresolve_tac\<close>.\<close> lemma all_dupE: assumes major: \<open>\<forall>x. P(x)\<close> and r: \<open>\<lbrakk>P(x); \<forall>x. P(x)\<rbrakk> \<Longrightarrow> R\<close> shows\<open>R\<close> proof (rule r) show"P(x)" by (rule major [THEN spec]) qed (rule major)
subsubsection \<open>Negation rules, which translate between \<open>\<not> P\<close> and \<open>P \<longrightarrow> False\<close>\<close>
lemma rev_notE: \<open>\<lbrakk>P; \<not> P\<rbrakk> \<Longrightarrow> R\<close> by (erule notE)
text\<open>This is useful with the special implication rules for each kind of \<open>P\<close>.\<close> lemma not_to_imp: assumes\<open>\<not> P\<close> and r: \<open>P \<longrightarrow> False \<Longrightarrow> Q\<close> shows\<open>Q\<close> apply (rule r) apply (rule impI) apply (erule notE [OF \<open>\<not> P\<close>]) done
text\<open> For substitution into an assumption \<open>P\<close>, reduce \<open>Q\<close> to \<open>P \<longrightarrow> Q\<close>, substitute into this implication, then apply \<open>impI\<close> to
move \<open>P\<close> back into the assumptions. \<close> lemma rev_mp: \<open>\<lbrakk>P; P \<longrightarrow> Q\<rbrakk> \<Longrightarrow> Q\<close> by (erule mp)
text\<open>Contrapositive of an inference rule.\<close> lemma contrapos: assumes major: \<open>\<not> Q\<close> and minor: \<open>P \<Longrightarrow> Q\<close> shows\<open>\<not> P\<close> apply (rule major [THENnotE, THEN notI]) apply (erule minor) done
subsubsection \<open>Modus Ponens Tactics\<close>
text\<open>
Finds \<open>P \<longrightarrow> Q\<close> and P in the assumptions, replaces implication by \<open>Q\<close>. \<close>
ML \<open> fun mp_tac ctxt i =
eresolve_tac ctxt @{thms notE impE} i THEN assume_tac ctxt i; fun eq_mp_tac ctxt i =
eresolve_tac ctxt @{thms notE impE} i THEN eq_assume_tac i; \<close>
subsection \<open>If-and-only-if\<close>
lemma iffI: \<open>\<lbrakk>P \<Longrightarrow> Q; Q \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P \<longleftrightarrow> Q\<close> unfolding iff_def by (rule conjI; erule impI)
text\<open> NOTE THAT the following 2 quantifications:
\<^item> \<open>\<exists>!x\<close> such that [\<open>\<exists>!y\<close> such that P(x,y)] (sequential) \<^item> \<open>\<exists>!x,y\<close> such that P(x,y) (simultaneous)
do NOT mean the same thing. The parser treats \<open>\<exists>!x y.P(x,y)\<close> as sequential. \<close>
subsubsection \<open>\<open>\<longleftrightarrow>\<close> congruence rules for simplification\<close>
text\<open>Use \<open>iffE\<close> on a premise. For \<open>conj_cong\<close>, \<open>imp_cong\<close>, \<open>all_cong\<close>, \<open>ex_cong\<close>.\<close>
ML \<open> fun iff_tac ctxt prems i =
resolve_tac ctxt (prems RL @{thms iffE}) i THEN
REPEAT1 (eresolve_tac ctxt @{thms asm_rl mp} i); \<close>
text\<open>A special case of \<open>ex1E\<close> that would otherwise need quantifier
expansion.\<close> lemma ex1_equalsE: \<open>\<lbrakk>\<exists>!x. P(x); P(a); P(b)\<rbrakk> \<Longrightarrow> a = b\<close> apply (erule ex1E) apply (rule trans) apply (rule_tac [2] sym) apply (assumption | erule spec [THEN mp])+ done
subsection \<open>Simplifications of assumed implications\<close>
text\<open>
Roy Dyckhoff has proved that \<open>conj_impE\<close>, \<open>disj_impE\<close>, and \<open>imp_impE\<close> used with \<^ML>\<open>mp_tac\<close> (restricted to atomic formulae) is
COMPLETE for intuitionistic propositional logic.
See R. Dyckhoff, Contraction-free sequent calculi for intuitionistic logic
(preprint, University of St Andrews, 1991). \<close>
lemma conj_impE: assumes major: \<open>(P \<and> Q) \<longrightarrow> S\<close> and r: \<open>P \<longrightarrow> (Q \<longrightarrow> S) \<Longrightarrow> R\<close> shows\<open>R\<close> by (assumption | rule conjI impI major [THEN mp] r)+
text\<open>Simplifies the implication. Classical version is stronger.
Still UNSAFE since Q must be provable -- backtracking needed.\<close> lemma imp_impE: assumes major: \<open>(P \<longrightarrow> Q) \<longrightarrow> S\<close> and r1: \<open>\<lbrakk>P; Q \<longrightarrow> S\<rbrakk> \<Longrightarrow> Q\<close> and r2: \<open>S \<Longrightarrow> R\<close> shows\<open>R\<close> by (assumption | rule impI major [THEN mp] r1 r2)+
text\<open>Simplifies the implication. Classical version is stronger.
Still UNSAFE since ~P must be provable -- backtracking needed.\<close> lemma not_impE: \<open>\<not> P \<longrightarrow> S \<Longrightarrow> (P \<Longrightarrow> False) \<Longrightarrow> (S \<Longrightarrow> R) \<Longrightarrow> R\<close> apply (drule mp) apply (rule notI | assumption)+ done
text\<open>Simplifies the implication. UNSAFE.\<close> lemma iff_impE: assumes major: \<open>(P \<longleftrightarrow> Q) \<longrightarrow> S\<close> and r1: \<open>\<lbrakk>P; Q \<longrightarrow> S\<rbrakk> \<Longrightarrow> Q\<close> and r2: \<open>\<lbrakk>Q; P \<longrightarrow> S\<rbrakk> \<Longrightarrow> P\<close> and r3: \<open>S \<Longrightarrow> R\<close> shows\<open>R\<close> by (assumption | rule iffI impI major [THEN mp] r1 r2 r3)+
text\<open>What if \<open>(\<forall>x. \<not> \<not> P(x)) \<longrightarrow> \<not> \<not> (\<forall>x. P(x))\<close> is an assumption?
UNSAFE.\<close> lemma all_impE: assumes major: \<open>(\<forall>x. P(x)) \<longrightarrow> S\<close> and r1: \<open>\<And>x. P(x)\<close> and r2: \<open>S \<Longrightarrow> R\<close> shows\<open>R\<close> by (rule allI impI major [THEN mp] r1 r2)+
text\<open>
Unsafe: \<open>\<exists>x. P(x)) \<longrightarrow> S\<close> is equivalent to\<open>\<forall>x. P(x) \<longrightarrow> S\<close>.\<close> lemma ex_impE: assumes major: \<open>(\<exists>x. P(x)) \<longrightarrow> S\<close> and r: \<open>P(x) \<longrightarrow> S \<Longrightarrow> R\<close> shows\<open>R\<close> by (assumption | rule exI impI major [THEN mp] r)+
ML \<open> structure Hypsubst = Hypsubst
(
val dest_eq = FOLogic.dest_eq
val dest_Trueprop = \<^dest_judgment>
val dest_imp = FOLogic.dest_imp
val eq_reflection = @{thm eq_reflection}
val rev_eq_reflection = @{thm meta_eq_to_obj_eq}
val imp_intr = @{thm impI}
val rev_mp = @{thm rev_mp}
val subst = @{thm subst}
val sym = @{thm sym}
val thin_refl = @{thm thin_refl}
); open Hypsubst; \<close>
lemma impE': assumes 1: \<open>P \<longrightarrow> Q\<close> and 2: \<open>Q \<Longrightarrow> R\<close> and 3: \<open>P \<longrightarrow> Q \<Longrightarrow> P\<close> shows\<open>R\<close> proof - from 3 and 1 have\<open>P\<close> . with 1 have\<open>Q\<close> by (rule impE) with 2 show\<open>R\<close> . qed
lemma allE': assumes 1: \<open>\<forall>x. P(x)\<close> and 2: \<open>P(x) \<Longrightarrow> \<forall>x. P(x) \<Longrightarrow> Q\<close> shows\<open>Q\<close> proof - from 1 have\<open>P(x)\<close> by (rule spec) from this and 1 show\<open>Q\<close> by (rule 2) qed
lemmanotE': assumes 1: \<open>\<not> P\<close> and 2: \<open>\<not> P \<Longrightarrow> P\<close> shows\<open>R\<close> proof - from 2 and 1 have\<open>P\<close> . with 1 show\<open>R\<close> by (rule notE) qed
lemmas [Pure.elim!] = disjE iffE FalseE conjE exE and [Pure.intro!] = iffI conjI impI TrueI notI allI refl and [Pure.elim 2] = allE notE' impE' and [Pure.intro] = exI disjI2 disjI1
lemma subst_context: \<open>a = b \<Longrightarrow> t(a) = t(b)\<close> by iprover
lemma subst_context2: \<open>\<lbrakk>a = b; c = d\<rbrakk> \<Longrightarrow> t(a,c) = t(b,d)\<close> by iprover
lemma subst_context3: \<open>\<lbrakk>a = b; c = d; e = f\<rbrakk> \<Longrightarrow> t(a,c,e) = t(b,d,f)\<close> by iprover
text\<open>
Useful with\<^ML>\<open>eresolve_tac\<close> for proving equalities from known
equalities.
a = b
| |
c = d \<close> lemma box_equals: \<open>\<lbrakk>a = b; a = c; b = d\<rbrakk> \<Longrightarrow> c = d\<close> by iprover
text\<open>Dual of \<open>box_equals\<close>: for proving equalities backwards.\<close> lemma simp_equals: \<open>\<lbrakk>a = c; b = d; c = d\<rbrakk> \<Longrightarrow> a = b\<close> by iprover
subsubsection \<open>Congruence rules for predicate letters\<close>
lemma pred1_cong: \<open>a = a' \<Longrightarrow> P(a) \<longleftrightarrow> P(a')\<close> by iprover
lemma pred2_cong: \<open>\<lbrakk>a = a'; b = b'\<rbrakk> \<Longrightarrow> P(a,b) \<longleftrightarrow> P(a',b')\<close> by iprover
lemma pred3_cong: \<open>\<lbrakk>a = a'; b = b'; c = c'\<rbrakk> \<Longrightarrow> P(a,b,c) \<longleftrightarrow> P(a',b',c')\<close> by iprover
text\<open>Special case for the equality predicate!\<close> lemma eq_cong: \<open>\<lbrakk>a = a'; b = b'\<rbrakk> \<Longrightarrow> a = b \<longleftrightarrow> a' = b'\<close> by iprover
lemma atomize_imp [atomize]: \<open>(A \<Longrightarrow> B) \<equiv> Trueprop (A \<longrightarrow> B)\<close> proof assume\<open>A \<Longrightarrow> B\<close> thenshow\<open>A \<longrightarrow> B\<close> .. next assume\<open>A \<longrightarrow> B\<close> and \<open>A\<close> thenshow\<open>B\<close> by (rule mp) qed
lemma atomize_eq [atomize]: \<open>(x \<equiv> y) \<equiv> Trueprop (x = y)\<close> proof assume\<open>x \<equiv> y\<close> show\<open>x = y\<close> unfolding \<open>x \<equiv> y\<close> by (rule refl) next assume\<open>x = y\<close> thenshow\<open>x \<equiv> y\<close> by (rule eq_reflection) qed
lemma atomize_iff [atomize]: \<open>(A \<equiv> B) \<equiv> Trueprop (A \<longleftrightarrow> B)\<close> proof assume\<open>A \<equiv> B\<close> show\<open>A \<longleftrightarrow> B\<close> unfolding \<open>A \<equiv> B\<close> by (rule iff_refl) next assume\<open>A \<longleftrightarrow> B\<close> thenshow\<open>A \<equiv> B\<close> by (rule iff_reflection) qed
lemma atomize_conj [atomize]: \<open>(A &&& B) \<equiv> Trueprop (A \<and> B)\<close> proof assume conj: \<open>A &&& B\<close> show\<open>A \<and> B\<close> proof (rule conjI) from conj show\<open>A\<close> by (rule conjunctionD1) from conj show\<open>B\<close> by (rule conjunctionD2) qed next assume conj: \<open>A \<and> B\<close> show\<open>A &&& B\<close> proof - from conj show\<open>A\<close> .. from conj show\<open>B\<close> .. qed qed
lemma atomize_conjL[atomize_elim]: \<open>(A \<Longrightarrow> B \<Longrightarrow> C) \<equiv> (A \<and> B \<Longrightarrow> C)\<close> by rule iprover+
lemma atomize_disjL[atomize_elim]: \<open>((A \<Longrightarrow> C) \<Longrightarrow> (B \<Longrightarrow> C) \<Longrightarrow> C) \<equiv> ((A \<or> B \<Longrightarrow> C) \<Longrightarrow> C)\<close> by rule iprover+
lemma atomize_elimL[atomize_elim]: \<open>(\<And>B. (A \<Longrightarrow> B) \<Longrightarrow> B) \<equiv> Trueprop(A)\<close> ..
subsection \<open>Calculational rules\<close>
lemma forw_subst: \<open>a = b \<Longrightarrow> P(b) \<Longrightarrow> P(a)\<close> by (rule ssubst)
lemma back_subst: \<open>P(a) \<Longrightarrow> a = b \<Longrightarrow> P(b)\<close> by (rule subst)
text\<open> Note that this list of rules isin reverse order of priorities. \<close>
lemmas basic_trans_rules [trans] =
forw_subst
back_subst
rev_mp
mp
trans
syntax "_bind" :: \<open>[pttrn, 'a] => letbind\<close> (\<open>(\<open>indent=2 notation=\<open>infix let binding\<close>\<close>_ =/ _)\<close> 10) "" :: \<open>letbind => letbinds\<close> (\<open>_\<close>) "_binds" :: \<open>[letbind, letbinds] => letbinds\<close> (\<open>_;/ _\<close>) "_Let" :: \<open>[letbinds, 'a] => 'a\<close> (\<open>(\<open>notation=\<open>mixfix let expression\<close>\<close>let (_)/ in (_))\<close> 10)
syntax_consts "_Let"\<rightleftharpoons> Let translations "_Let(_binds(b, bs), e)" == "_Let(b, _Let(bs, e))" "let x = a in e" == "CONST Let(a, \x. e)"
lemma LetI: assumes\<open>\<And>x. x = t \<Longrightarrow> P(u(x))\<close> shows\<open>P(let x = t in u(x))\<close> unfolding Let_def apply (rule refl [THEN assms]) done
text\<open>The \<open>x = t\<close> versions are needed for the simplification
procedures.\<close> lemma quant_simps: \<open>\<And>P. (\<forall>x. P) \<longleftrightarrow> P\<close> \<open>(\<forall>x. x = t \<longrightarrow> P(x)) \<longleftrightarrow> P(t)\<close> \<open>(\<forall>x. t = x \<longrightarrow> P(x)) \<longleftrightarrow> P(t)\<close> \<open>\<And>P. (\<exists>x. P) \<longleftrightarrow> P\<close> \<open>\<exists>x. x = t\<close> \<open>\<exists>x. t = x\<close> \<open>(\<exists>x. x = t \<and> P(x)) \<longleftrightarrow> P(t)\<close> \<open>(\<exists>x. t = x \<and> P(x)) \<longleftrightarrow> P(t)\<close> by iprover+
text\<open>These are NOT supplied by default!\<close> lemma distrib_simps: \<open>P \<and> (Q \<or> R) \<longleftrightarrow> P \<and> Q \<or> P \<and> R\<close> \<open>(Q \<or> R) \<and> P \<longleftrightarrow> Q \<and> P \<or> R \<and> P\<close> \<open>(P \<or> Q \<longrightarrow> R) \<longleftrightarrow> (P \<longrightarrow> R) \<and> (Q \<longrightarrow> R)\<close> by iprover+
lemma subst_all: \<open>(\<And>x. x = a \<Longrightarrow> PROP P(x)) \<equiv> PROP P(a)\<close> \<open>(\<And>x. a = x \<Longrightarrow> PROP P(x)) \<equiv> PROP P(a)\<close> proof - show\<open>(\<And>x. x = a \<Longrightarrow> PROP P(x)) \<equiv> PROP P(a)\<close> proof (rule equal_intr_rule) assume *: \<open>\<And>x. x = a \<Longrightarrow> PROP P(x)\<close> show\<open>PROP P(a)\<close> by (rule *) (rule refl) next fix x assume\<open>PROP P(a)\<close> and \<open>x = a\<close> from\<open>x = a\<close> have \<open>x \<equiv> a\<close> by (rule eq_reflection) with\<open>PROP P(a)\<close> show \<open>PROP P(x)\<close> by simp qed show\<open>(\<And>x. a = x \<Longrightarrow> PROP P(x)) \<equiv> PROP P(a)\<close> proof (rule equal_intr_rule) assume *: \<open>\<And>x. a = x \<Longrightarrow> PROP P(x)\<close> show\<open>PROP P(a)\<close> by (rule *) (rule refl) next fix x assume\<open>PROP P(a)\<close> and \<open>a = x\<close> from\<open>a = x\<close> have \<open>a \<equiv> x\<close> by (rule eq_reflection) with\<open>PROP P(a)\<close> show \<open>PROP P(x)\<close> by simp qed qed
subsubsection \<open>Conversion into rewrite rules\<close>
lemma P_iff_F: \<open>\<not> P \<Longrightarrow> (P \<longleftrightarrow> False)\<close> by iprover lemma iff_reflection_F: \<open>\<not> P \<Longrightarrow> (P \<equiv> False)\<close> by (rule P_iff_F [THEN iff_reflection])
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.17Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.