parse_translation\<open> letfun proof_tr [p, P] = Syntax.const \<^const_syntax>\<open>Proof\<close> $ P $ p in [(\<^syntax_const>\<open>_Proof\<close>, K proof_tr)] end \<close>
(*show_proofs = true displays the proof terms -- they are ENORMOUS*)
ML \<open>val show_proofs = Attrib.setup_config_bool \<^binding>\<open>show_proofs\<close> (K false)\<close>
print_translation\<open> let fun proof_tr' ctxt [P, p] = if Config.get ctxt show_proofs thenSyntax.const \<^syntax_const>\<open>_Proof\<close> $ p $ P
else P in [(\<^const_syntax>\<open>Proof\<close>, proof_tr')] end \<close>
(**** 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 \<open> local fun discard_proof \<^Const_>\<open>Proof for P _\<close> = 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; \<close>
(*** Modus Ponens Tactics ***)
(*Finds P-->Q and P in the assumptions, replaces implication by Q *)
ML \<open> fun mp_tac ctxt i =
eresolve_tac ctxt [@{thmnotE}, make_elim @{thm mp}] i THEN assume_tac ctxt i \<close> method_setup mp = \<open>Scan.succeed (SIMPLE_METHOD' o mp_tac)\<close>
(*Like mp_tac but instantiates no variables*)
ML \<open> fun int_uniq_mp_tac ctxt i =
eresolve_tac ctxt [@{thmnotE}, @{thm impE}] i THEN uniq_assume_tac ctxt i \<close>
(*** 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 \<open> fun iff_tac ctxt prems i =
resolve_tac ctxt (prems RL [@{thm iffE}]) i THEN
REPEAT1 (eresolve_tac ctxt [asm_rl, @{thm mp}] i) \<close>
(*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
ML \<open> structure Hypsubst = Hypsubst
( (*Take apart an equality judgement; otherwise raise Match!*) fun dest_eq \<^Const_>\<open>Proof for \<^Const_>\<open>eq _ for t u\<close> _\<close> = (t, u);
val imp_intr = @{thm impI}
(*etac rev_cut_eq moves an equality to be the last premise. *)
val rev_cut_eq = @{thm rev_cut_eq}
val rev_mp = @{thm rev_mp}
val subst = @{thm subst}
val sym = @{thm sym}
val thin_refl = @{thm thin_refl}
); open Hypsubst; \<close>
ML_file \<open>intprover.ML\<close>
(*** Rewrite rules ***)
schematic_goal conj_rews: "?p1 : P & True <-> P" "?p2 : True & P <-> P" "?p3 : P & False <-> False" "?p4 : False & P <-> False" "?p5 : P & P <-> P" "?p6 : P & ~P <-> False" "?p7 : ~P & P <-> False" "?p8 : (P & Q) & R <-> P & (Q & R)" apply (tactic \<open>fn st => IntPr.fast_tac \<^context> 1 st\<close>)+ done
schematic_goal disj_rews: "?p1 : P | True <-> True" "?p2 : True | P <-> True" "?p3 : P | False <-> P" "?p4 : False | P <-> P" "?p5 : P | P <-> P" "?p6 : (P | Q) | R <-> P | (Q | R)" apply (tactic \<open>IntPr.fast_tac \<^context> 1\<close>)+ 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 ist noch experimentell.