src/FOLP/intprover.ML
author haftmann
Thu Nov 23 17:03:27 2017 +0000 (20 months ago)
changeset 67087 733017b19de9
parent 60754 02924903a6fd
permissions -rw-r--r--
generalized more lemmas
haftmann@24584
     1
(*  Title:      FOLP/intprover.ML
clasohm@1459
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@0
     3
    Copyright   1992  University of Cambridge
clasohm@0
     4
clasohm@0
     5
A naive prover for intuitionistic logic
clasohm@0
     6
paulson@2603
     7
BEWARE OF NAME CLASHES WITH CLASSICAL TACTICS -- use IntPr.fast_tac ...
clasohm@0
     8
clasohm@0
     9
Completeness (for propositional logic) is proved in 
clasohm@0
    10
clasohm@0
    11
Roy Dyckhoff.
wenzelm@52457
    12
Contraction-Free Sequent Calculi for Intuitionistic Logic.
clasohm@0
    13
J. Symbolic Logic (in press)
clasohm@0
    14
*)
clasohm@0
    15
clasohm@0
    16
signature INT_PROVER = 
clasohm@0
    17
  sig
wenzelm@58963
    18
  val best_tac: Proof.context -> int -> tactic
wenzelm@58963
    19
  val fast_tac: Proof.context -> int -> tactic
wenzelm@58963
    20
  val inst_step_tac: Proof.context -> int -> tactic
wenzelm@58963
    21
  val safe_step_tac: Proof.context -> int -> tactic
clasohm@0
    22
  val safe_brls: (bool * thm) list
wenzelm@58963
    23
  val safe_tac: Proof.context -> tactic
wenzelm@58963
    24
  val step_tac: Proof.context -> int -> tactic
clasohm@0
    25
  val haz_brls: (bool * thm) list
clasohm@0
    26
  end;
clasohm@0
    27
clasohm@0
    28
paulson@2603
    29
structure IntPr : INT_PROVER   = 
clasohm@0
    30
struct
clasohm@0
    31
clasohm@0
    32
(*Negation is treated as a primitive symbol, with rules notI (introduction),
clasohm@0
    33
  not_to_imp (converts the assumption ~P to P-->False), and not_impE
clasohm@0
    34
  (handles double negations).  Could instead rewrite by not_def as the first
clasohm@0
    35
  step of an intuitionistic proof.
clasohm@0
    36
*)
wenzelm@4440
    37
val safe_brls = sort (make_ord lessb)
wenzelm@26322
    38
    [ (true, @{thm FalseE}), (false, @{thm TrueI}), (false, @{thm refl}),
wenzelm@26322
    39
      (false, @{thm impI}), (false, @{thm notI}), (false, @{thm allI}),
wenzelm@26322
    40
      (true, @{thm conjE}), (true, @{thm exE}),
wenzelm@26322
    41
      (false, @{thm conjI}), (true, @{thm conj_impE}),
wenzelm@26322
    42
      (true, @{thm disj_impE}), (true, @{thm disjE}), 
wenzelm@26322
    43
      (false, @{thm iffI}), (true, @{thm iffE}), (true, @{thm not_to_imp}) ];
clasohm@0
    44
clasohm@0
    45
val haz_brls =
wenzelm@26322
    46
    [ (false, @{thm disjI1}), (false, @{thm disjI2}), (false, @{thm exI}), 
wenzelm@26322
    47
      (true, @{thm allE}), (true, @{thm not_impE}), (true, @{thm imp_impE}), (true, @{thm iff_impE}),
wenzelm@26322
    48
      (true, @{thm all_impE}), (true, @{thm ex_impE}), (true, @{thm impE}) ];
clasohm@0
    49
clasohm@0
    50
(*0 subgoals vs 1 or more: the p in safep is for positive*)
clasohm@0
    51
val (safe0_brls, safep_brls) =
haftmann@17496
    52
    List.partition (curry (op =) 0 o subgoals_of_brl) safe_brls;
clasohm@0
    53
clasohm@0
    54
(*Attack subgoals using safe inferences*)
wenzelm@58963
    55
fun safe_step_tac ctxt = FIRST' [uniq_assume_tac ctxt,
wenzelm@58963
    56
                            int_uniq_mp_tac ctxt,
wenzelm@59498
    57
                            biresolve_tac ctxt safe0_brls,
wenzelm@60754
    58
                            hyp_subst_tac ctxt,
wenzelm@59498
    59
                            biresolve_tac ctxt safep_brls] ;
clasohm@0
    60
clasohm@0
    61
(*Repeatedly attack subgoals using safe inferences*)
wenzelm@58963
    62
fun safe_tac ctxt = DETERM (REPEAT_FIRST (safe_step_tac ctxt));
clasohm@0
    63
clasohm@0
    64
(*These steps could instantiate variables and are therefore unsafe.*)
wenzelm@58963
    65
fun inst_step_tac ctxt = assume_tac ctxt APPEND' mp_tac ctxt;
clasohm@0
    66
clasohm@0
    67
(*One safe or unsafe step. *)
wenzelm@59498
    68
fun step_tac ctxt i = FIRST [safe_tac ctxt, inst_step_tac ctxt i, biresolve_tac ctxt haz_brls i];
clasohm@0
    69
clasohm@0
    70
(*Dumb but fast*)
wenzelm@58963
    71
fun fast_tac ctxt = SELECT_GOAL (DEPTH_SOLVE (step_tac ctxt 1));
clasohm@0
    72
clasohm@0
    73
(*Slower but smarter than fast_tac*)
wenzelm@58963
    74
fun best_tac ctxt =
wenzelm@58963
    75
  SELECT_GOAL (BEST_FIRST (has_fewer_prems 1, size_of_thm) (step_tac ctxt 1));
clasohm@0
    76
clasohm@0
    77
end;