src/FOL/intprover.ML
author wenzelm
Thu Aug 27 20:46:36 1998 +0200 (1998-08-27)
changeset 5400 645f46a24c72
parent 5203 eb5a1511a07d
child 15570 8d8c70b41bab
permissions -rw-r--r--
made tutorial first;
clasohm@1459
     1
(*  Title:      FOL/int-prover
clasohm@0
     2
    ID:         $Id$
clasohm@1459
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@0
     4
    Copyright   1992  University of Cambridge
clasohm@0
     5
clasohm@0
     6
A naive prover for intuitionistic logic
clasohm@0
     7
paulson@2601
     8
BEWARE OF NAME CLASHES WITH CLASSICAL TACTICS -- use IntPr.fast_tac ...
clasohm@0
     9
clasohm@0
    10
Completeness (for propositional logic) is proved in 
clasohm@0
    11
clasohm@0
    12
Roy Dyckhoff.
clasohm@0
    13
Contraction-Free Sequent Calculi for Intuitionistic Logic.
lcp@1005
    14
J. Symbolic Logic  57(3), 1992, pages 795-807.
lcp@1005
    15
lcp@1005
    16
The approach was developed independently by Roy Dyckhoff and L C Paulson.
clasohm@0
    17
*)
clasohm@0
    18
clasohm@0
    19
signature INT_PROVER = 
clasohm@0
    20
  sig
clasohm@0
    21
  val best_tac: int -> tactic
paulson@5203
    22
  val best_dup_tac: int -> tactic
clasohm@0
    23
  val fast_tac: int -> tactic
clasohm@0
    24
  val inst_step_tac: int -> tactic
clasohm@0
    25
  val safe_step_tac: int -> tactic
clasohm@0
    26
  val safe_brls: (bool * thm) list
clasohm@0
    27
  val safe_tac: tactic
clasohm@0
    28
  val step_tac: int -> tactic
paulson@5203
    29
  val step_dup_tac: int -> tactic
clasohm@0
    30
  val haz_brls: (bool * thm) list
paulson@5203
    31
  val haz_dup_brls: (bool * thm) list
clasohm@0
    32
  end;
clasohm@0
    33
clasohm@0
    34
paulson@2601
    35
structure IntPr : INT_PROVER   = 
clasohm@0
    36
struct
clasohm@0
    37
clasohm@0
    38
(*Negation is treated as a primitive symbol, with rules notI (introduction),
clasohm@0
    39
  not_to_imp (converts the assumption ~P to P-->False), and not_impE
clasohm@0
    40
  (handles double negations).  Could instead rewrite by not_def as the first
clasohm@0
    41
  step of an intuitionistic proof.
clasohm@0
    42
*)
wenzelm@4440
    43
val safe_brls = sort (make_ord lessb)
clasohm@0
    44
    [ (true,FalseE), (false,TrueI), (false,refl),
clasohm@0
    45
      (false,impI), (false,notI), (false,allI),
clasohm@0
    46
      (true,conjE), (true,exE),
clasohm@0
    47
      (false,conjI), (true,conj_impE),
paulson@2572
    48
      (true,disj_impE), (true,disjE), 
paulson@2572
    49
      (false,iffI), (true,iffE), (true,not_to_imp) ];
clasohm@0
    50
clasohm@0
    51
val haz_brls =
clasohm@0
    52
    [ (false,disjI1), (false,disjI2), (false,exI), 
clasohm@0
    53
      (true,allE), (true,not_impE), (true,imp_impE), (true,iff_impE),
paulson@2572
    54
      (true,all_impE), (true,ex_impE), (true,impE) ];
clasohm@0
    55
paulson@5203
    56
val haz_dup_brls =
paulson@5203
    57
    [ (false,disjI1), (false,disjI2), (false,exI), 
paulson@5203
    58
      (true,all_dupE), (true,not_impE), (true,imp_impE), (true,iff_impE),
paulson@5203
    59
      (true,all_impE), (true,ex_impE), (true,impE) ];
paulson@5203
    60
clasohm@0
    61
(*0 subgoals vs 1 or more: the p in safep is for positive*)
clasohm@0
    62
val (safe0_brls, safep_brls) =
clasohm@0
    63
    partition (apl(0,op=) o subgoals_of_brl) safe_brls;
clasohm@0
    64
clasohm@0
    65
(*Attack subgoals using safe inferences -- matching, not resolution*)
clasohm@0
    66
val safe_step_tac = FIRST' [eq_assume_tac,
clasohm@1459
    67
                            eq_mp_tac,
clasohm@1459
    68
                            bimatch_tac safe0_brls,
clasohm@1459
    69
                            hyp_subst_tac,
clasohm@1459
    70
                            bimatch_tac safep_brls] ;
clasohm@0
    71
clasohm@0
    72
(*Repeatedly attack subgoals using safe inferences -- it's deterministic!*)
lcp@702
    73
val safe_tac = REPEAT_DETERM_FIRST safe_step_tac;
clasohm@0
    74
clasohm@0
    75
(*These steps could instantiate variables and are therefore unsafe.*)
clasohm@0
    76
val inst_step_tac =
clasohm@0
    77
  assume_tac APPEND' mp_tac APPEND' 
clasohm@0
    78
  biresolve_tac (safe0_brls @ safep_brls);
clasohm@0
    79
clasohm@0
    80
(*One safe or unsafe step. *)
clasohm@0
    81
fun step_tac i = FIRST [safe_tac, inst_step_tac i, biresolve_tac haz_brls i];
clasohm@0
    82
paulson@5203
    83
fun step_dup_tac i = FIRST [safe_tac, inst_step_tac i, 
paulson@5203
    84
			    biresolve_tac haz_dup_brls i];
paulson@5203
    85
clasohm@0
    86
(*Dumb but fast*)
clasohm@0
    87
val fast_tac = SELECT_GOAL (DEPTH_SOLVE (step_tac 1));
clasohm@0
    88
clasohm@0
    89
(*Slower but smarter than fast_tac*)
clasohm@0
    90
val best_tac = 
clasohm@0
    91
  SELECT_GOAL (BEST_FIRST (has_fewer_prems 1, size_of_thm) (step_tac 1));
clasohm@0
    92
paulson@5203
    93
(*Uses all_dupE: allows multiple use of universal assumptions.  VERY slow.*)
paulson@5203
    94
val best_dup_tac = 
paulson@5203
    95
  SELECT_GOAL (BEST_FIRST (has_fewer_prems 1, size_of_thm) (step_dup_tac 1));
paulson@5203
    96
paulson@5203
    97
clasohm@0
    98
end;
clasohm@0
    99