src/FOL/int-prover.ML
author wenzelm
Sat, 01 Jul 2000 19:55:22 +0200
changeset 9230 17ae63f82ad8
parent 0 a5a9c433f639
permissions -rw-r--r--
GPLed;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     1
(*  Title: 	FOL/int-prover
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1992  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
A naive prover for intuitionistic logic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
BEWARE OF NAME CLASHES WITH CLASSICAL TACTICS -- use Int.fast_tac ...
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
Completeness (for propositional logic) is proved in 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
Roy Dyckhoff.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
Contraction-Free Sequent Calculi for Intuitionistic Logic.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
J. Symbolic Logic (in press)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
signature INT_PROVER = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
  sig
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
  val best_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
  val fast_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
  val inst_step_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
  val safe_step_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
  val safe_brls: (bool * thm) list
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
  val safe_tac: tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
  val step_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
  val haz_brls: (bool * thm) list
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
  end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
structure Int : INT_PROVER   = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
struct
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
(*Negation is treated as a primitive symbol, with rules notI (introduction),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
  not_to_imp (converts the assumption ~P to P-->False), and not_impE
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
  (handles double negations).  Could instead rewrite by not_def as the first
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
  step of an intuitionistic proof.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
val safe_brls = sort lessb 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
    [ (true,FalseE), (false,TrueI), (false,refl),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
      (false,impI), (false,notI), (false,allI),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
      (true,conjE), (true,exE),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
      (false,conjI), (true,conj_impE),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
      (true,disj_impE), (true,ex_impE),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
      (true,disjE), (false,iffI), (true,iffE), (true,not_to_imp) ];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
val haz_brls =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
    [ (false,disjI1), (false,disjI2), (false,exI), 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
      (true,allE), (true,not_impE), (true,imp_impE), (true,iff_impE),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
      (true,all_impE), (true,impE) ];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
(*0 subgoals vs 1 or more: the p in safep is for positive*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
val (safe0_brls, safep_brls) =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
    partition (apl(0,op=) o subgoals_of_brl) safe_brls;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
(*Attack subgoals using safe inferences -- matching, not resolution*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
val safe_step_tac = FIRST' [eq_assume_tac,
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
			    eq_mp_tac,
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
			    bimatch_tac safe0_brls,
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
			    hyp_subst_tac,
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
			    bimatch_tac safep_brls] ;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
(*Repeatedly attack subgoals using safe inferences -- it's deterministic!*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
val safe_tac = DETERM (REPEAT_FIRST safe_step_tac);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
(*These steps could instantiate variables and are therefore unsafe.*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
val inst_step_tac =
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
  assume_tac APPEND' mp_tac APPEND' 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
  biresolve_tac (safe0_brls @ safep_brls);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
(*One safe or unsafe step. *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
fun step_tac i = FIRST [safe_tac, inst_step_tac i, biresolve_tac haz_brls i];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
(*Dumb but fast*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
val fast_tac = SELECT_GOAL (DEPTH_SOLVE (step_tac 1));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
(*Slower but smarter than fast_tac*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
val best_tac = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
  SELECT_GOAL (BEST_FIRST (has_fewer_prems 1, size_of_thm) (step_tac 1));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81