parse_translation‹ letfun proof_tr [p, P] = Syntax.const 🍋‹Proof› $ P $ p in [(🍋‹_Proof›, K proof_tr)] end ›
(*show_proofs = true displays the proof terms -- they are ENORMOUS*)
ML ‹val show_proofs = Attrib.setup_config_bool 🍋‹show_proofs› (K false)›
print_translation‹ let fun proof_tr' ctxt [P, p] = if Config.get ctxt show_proofs thenSyntax.const 🍋‹_Proof› $ p $ P
else P in [(🍋‹Proof›, proof_tr')] end ›
(**** Propositional logic ****)
(*Equality*) (* Like Intensional Equality in MLTT - but proofs distinct from terms *)
(*This is useful with the special implication rules for each kind of P. *)
schematic_goal not_to_imp: assumes"p:~P" and"!!x. x:(P-->False) ==> q(x):Q" shows"?p:Q" apply (assumption | rule assms impI notE)+ done
(* For substitution int an assumption P, reduce Q to P-->Q, substitute into
this implication, then apply impI to move P back into the assumptions.*)
schematic_goal rev_mp: "[| p:P; q:P --> Q |] ==> ?p:Q" apply (assumption | rule mp)+ done
(*Contrapositive of an inference rule*)
schematic_goal contrapos: assumes major: "p:~Q" and minor: "!!y. y:P==>q(y):Q" shows"?a:~P" apply (rule major [THENnotE, THEN notI]) apply (erule minor) done
(** Unique assumption tactic. Ignores proof objects. Fails unless one assumption is equal and exactly one is unifiable
**)
ML ‹ local fun discard_proof 🍋‹Prooffor P _› = P; in fun uniq_assume_tac ctxt =
SUBGOAL
(fn (prem,i) => let val hyps = map discard_proof (Logic.strip_assums_hyp prem) and concl = discard_proof (Logic.strip_assums_concl prem) in if exists (fn hyp => hyp aconv concl) hyps thencase distinct (op =) (filter (fn hyp => Term.could_unify (hyp, concl)) hyps) of
[_] => assume_tac ctxt i
| _ => no_tac
else no_tac end); end; ›
(*** Modus Ponens Tactics ***)
(*Finds P-->Q and P in the assumptions, replaces implication by Q *)
ML ‹ fun mp_tac ctxt i =
eresolve_tac ctxt [@{thmnotE}, make_elim @{thm mp}] i THEN assume_tac ctxt i › method_setup mp = ‹Scan.succeed (SIMPLE_METHOD' o mp_tac)\
(*Like mp_tac but instantiates no variables*)
ML ‹ fun int_uniq_mp_tac ctxt i =
eresolve_tac ctxt [@{thmnotE}, @{thm impE}] i THEN uniq_assume_tac ctxt i ›
(*** Unique existence. NOTE THAT the following 2 quantifications EX!x such that [EX!y such that P(x,y)] (sequential) EX!x,y such that P(x,y) (simultaneous) do NOT mean the same thing. The parser treats EX!x y.P(x,y) as sequential.
***)
(*Use iffE on a premise. For conj_cong, imp_cong, all_cong, ex_cong*)
ML ‹ fun iff_tac ctxt prems i =
resolve_tac ctxt (prems RL [@{thm iffE}]) i THEN
REPEAT1 (eresolve_tac ctxt [asm_rl, @{thm mp}] i) ›
(*Useful with eresolve_tac for proving equalties from known equalities. a = b | |
c = d *)
schematic_goal box_equals: "[| p:a=b; q:a=c; r:b=d |] ==> ?p:c=d" apply (rule trans) apply (rule trans) apply (rule sym) apply assumption+ done
(*special case for the equality predicate!*) lemmas eq_cong = pred2_cong [where P = "(=)"]
(*** Simplifications of assumed implications. Roy Dyckhoff has proved that conj_impE, disj_impE, and imp_impE used with mp_tac (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) ***)
(*Simplifies the implication. Classical version is stronger.
Still UNSAFE since Q must be provable -- backtracking needed. *)
schematic_goal imp_impE: assumes major: "p:(P-->Q)-->S" and r1: "!!x y.[| x:P; y:Q-->S |] ==> q(x,y):Q" and r2: "!!x. x:S ==> r(x):R" shows"?p:R" apply (assumption | rule impI major [THEN mp] r1 r2)+ done
(*Simplifies the implication. Classical version is stronger.
Still UNSAFE since ~P must be provable -- backtracking needed. *)
schematic_goal not_impE: assumes major: "p:~P --> S" and r1: "!!y. y:P ==> q(y):False" and r2: "!!y. y:S ==> r(y):R" shows"?p:R" apply (assumption | rule notI impI major [THEN mp] r1 r2)+ done
(*Simplifies the implication. UNSAFE. *)
schematic_goal iff_impE: assumes major: "p:(P<->Q)-->S" and r1: "!!x y.[| x:P; y:Q-->S |] ==> q(x,y):Q" and r2: "!!x y.[| x:Q; y:P-->S |] ==> r(x,y):P" and r3: "!!x. x:S ==> s(x):R" shows"?p:R" apply (assumption | rule iffI impI major [THEN mp] r1 r2 r3)+ done
(*What if (ALL x.~~P(x)) --> ~~(ALL x.P(x)) is an assumption? UNSAFE*)
schematic_goal all_impE: assumes major: "p:(ALL x. P(x))-->S" and r1: "!!x. q:P(x)" and r2: "!!y. y:S ==> r(y):R" shows"?p:R" apply (assumption | rule allI impI major [THEN mp] r1 r2)+ done
(*Unsafe: (EX x.P(x))-->S is equivalent to ALL x.P(x)-->S. *)
schematic_goal ex_impE: assumes major: "p:(EX x. P(x))-->S" and r: "!!y. y:P(a)-->S ==> q(y):R" shows"?p:R" apply (assumption | rule exI impI major [THEN mp] r)+ done
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 und die Messung sind noch experimentell.