val not_false_rule = @{lemma "\False" by auto} fun explode thm = explode_thm thm (add_lit not_false_rule (add_lit @{thm TrueI} Termtab.empty))
fun find_dual_lit lits (\<^Const_>\<open>Not for t\<close>, thm) = Termtab.lookup lits t |> Option.map (pair thm)
| find_dual_lit _ _ = NONE
fun find_dual_lits lits = Termtab.get_first (find_dual_lit lits) lits
val not_not_rule = @{lemma "P \ \\P" by auto} val ndisj_rule = @{lemma "\P \ \Q \ \(P \ Q)" by auto}
fun join lits t =
(case Termtab.lookup lits t of
SOME thm => thm
| NONE => join_term lits t)
and join_term lits \<^Const_>\<open>conj for t u\<close> = @{thm conjI} OF (map (join lits) [t, u])
| join_term lits \<^Const_>\<open>Not for \<^Const_>\<open>HOL.disj for t u\<close>\<close> =
ndisj_rule OF (map (join lits o HOLogic.mk_not) [t, u])
| join_term lits \<^Const_>\<open>Not for \<^Const>\<open>Not for t\<close>\<close> = join lits t RS not_not_rule
| join_term _ t = raise TERM ("join_term", [t])
fun prove_conj_disj_imp ct cu = with_assumption ct (fn thm => join (explode thm) (Thm.term_of cu))
fun prove_conj_disj_eq (clhs, crhs) = let val thm1 = prove_conj_disj_imp clhs crhs val thm2 = prove_conj_disj_imp crhs clhs in eq_from_impls thm1 thm2 end
val not_not_false_rule = @{lemma "\\False \ P" by auto} val not_true_rule = @{lemma "\True \ P" by auto}
fun prove_any_imp ct =
(case Thm.term_of ct of
\<^Const_>\<open>False\<close> => @{thm FalseE}
| \<^Const_>\<open>Not for \<^Const>\<open>Not for \<^Const>\<open>False\<close>\<close>\<close> => not_not_false_rule
| \<^Const_>\<open>Not for \<^Const>\<open>True\<close>\<close> => not_true_rule
| _ => raise CTERM ("prove_any_imp", [ct]))
fun prove_contradiction_imp ct =
with_assumption ct (fn thm => letval lits = explode thm in
(case Termtab.lookup lits \<^Const>\<open>False\<close> of
SOME thm' => thm' RS @{thm FalseE}
| NONE =>
(case Termtab.lookup lits \<^Const>\<open>Not for \<^Const>\<open>True\<close>\<close> of
SOME thm' => thm' RS not_true_rule
| NONE =>
(case find_dual_lits lits of
SOME (not_lit_thm, lit_thm) => @{thm notE} OF [not_lit_thm, lit_thm]
| NONE => raise CTERM ("prove_contradiction", [ct])))) end)
fun prove_contradiction_eq to_right (clhs, crhs) = let val thm1 = if to_right then prove_contradiction_imp clhs else prove_any_imp clhs val thm2 = if to_right then prove_any_imp crhs else prove_contradiction_imp crhs in eq_from_impls thm1 thm2 end
val contrapos_rule = @{lemma "(\P) = (\Q) \ P = Q" by auto} fun contrapos prove cp = contrapos_rule OF [prove (apply2 (Thm.apply \<^cterm>\<open>HOL.Not\<close>) cp)]
fun choose t _ _ _ \<^Const_>\<open>True\<close> = t
| choose _ f _ _ \<^Const_>\<open>False\<close> = f
| choose _ _ c _ \<^Const_>\<open>conj for _ _\<close> = c
| choose _ _ _ d \<^Const_>\<open>disj for _ _\<close> = d
| choose _ _ _ _ _ = Other
fun kind_of \<^Const_>\<open>Not for t\<close> = choose FalseTrue Disj Conj t
| kind_of t = choose TrueFalse Conj Disj t
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.