src/FOLP/intprover.ML
author blanchet
Thu, 16 May 2013 14:15:22 +0200
changeset 52032 0370c5f00ce8
parent 35762 af3ff2ba4c54
child 52457 c3b4b74a54fd
permissions -rw-r--r--
more work on SPASS datatypes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24584
01e83ffa6c54 fixed title
haftmann
parents: 17496
diff changeset
     1
(*  Title:      FOLP/intprover.ML
1459
d12da312eff4 expanded tabs
clasohm
parents: 0
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     3
    Copyright   1992  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
A naive prover for intuitionistic logic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
2603
4988dda71c0b Renamed structure Int (intuitionistic prover) to IntPr to prevent clash
paulson
parents: 2572
diff changeset
     7
BEWARE OF NAME CLASHES WITH CLASSICAL TACTICS -- use IntPr.fast_tac ...
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
Completeness (for propositional logic) is proved in 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
Roy Dyckhoff.
2603
4988dda71c0b Renamed structure Int (intuitionistic prover) to IntPr to prevent clash
paulson
parents: 2572
diff changeset
    12
Contraction-Free Sequent Calculi for IntPruitionistic Logic.
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
J. Symbolic Logic (in press)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
signature INT_PROVER = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
  sig
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
  val best_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
  val fast_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
  val inst_step_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
  val safe_step_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
  val safe_brls: (bool * thm) list
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
  val safe_tac: tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
  val step_tac: int -> tactic
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
  val haz_brls: (bool * thm) list
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
  end;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
2603
4988dda71c0b Renamed structure Int (intuitionistic prover) to IntPr to prevent clash
paulson
parents: 2572
diff changeset
    29
structure IntPr : INT_PROVER   = 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
struct
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
(*Negation is treated as a primitive symbol, with rules notI (introduction),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
  not_to_imp (converts the assumption ~P to P-->False), and not_impE
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
  (handles double negations).  Could instead rewrite by not_def as the first
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
  step of an intuitionistic proof.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
*)
4440
9ed4098074bc adapted to new sort function;
wenzelm
parents: 2603
diff changeset
    37
val safe_brls = sort (make_ord lessb)
26322
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 24584
diff changeset
    38
    [ (true, @{thm FalseE}), (false, @{thm TrueI}), (false, @{thm refl}),
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 24584
diff changeset
    39
      (false, @{thm impI}), (false, @{thm notI}), (false, @{thm allI}),
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 24584
diff changeset
    40
      (true, @{thm conjE}), (true, @{thm exE}),
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 24584
diff changeset
    41
      (false, @{thm conjI}), (true, @{thm conj_impE}),
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 24584
diff changeset
    42
      (true, @{thm disj_impE}), (true, @{thm disjE}), 
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 24584
diff changeset
    43
      (false, @{thm iffI}), (true, @{thm iffE}), (true, @{thm not_to_imp}) ];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
val haz_brls =
26322
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 24584
diff changeset
    46
    [ (false, @{thm disjI1}), (false, @{thm disjI2}), (false, @{thm exI}), 
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 24584
diff changeset
    47
      (true, @{thm allE}), (true, @{thm not_impE}), (true, @{thm imp_impE}), (true, @{thm iff_impE}),
eaf634e975fa converted legacy ML scripts;
wenzelm
parents: 24584
diff changeset
    48
      (true, @{thm all_impE}), (true, @{thm ex_impE}), (true, @{thm impE}) ];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
(*0 subgoals vs 1 or more: the p in safep is for positive*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
val (safe0_brls, safep_brls) =
17496
26535df536ae slight adaptions to library changes
haftmann
parents: 15570
diff changeset
    52
    List.partition (curry (op =) 0 o subgoals_of_brl) safe_brls;
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
(*Attack subgoals using safe inferences*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
val safe_step_tac = FIRST' [uniq_assume_tac,
9263
53e09e592278 removal of batch style, and tidying
paulson
parents: 4440
diff changeset
    56
                            int_uniq_mp_tac,
1459
d12da312eff4 expanded tabs
clasohm
parents: 0
diff changeset
    57
                            biresolve_tac safe0_brls,
d12da312eff4 expanded tabs
clasohm
parents: 0
diff changeset
    58
                            hyp_subst_tac,
d12da312eff4 expanded tabs
clasohm
parents: 0
diff changeset
    59
                            biresolve_tac safep_brls] ;
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
(*Repeatedly attack subgoals using safe inferences*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
val safe_tac = DETERM (REPEAT_FIRST safe_step_tac);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
(*These steps could instantiate variables and are therefore unsafe.*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
val inst_step_tac = assume_tac APPEND' mp_tac;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
(*One safe or unsafe step. *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
fun step_tac i = FIRST [safe_tac, inst_step_tac i, biresolve_tac haz_brls i];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
(*Dumb but fast*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
val fast_tac = SELECT_GOAL (DEPTH_SOLVE (step_tac 1));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
(*Slower but smarter than fast_tac*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
val best_tac = 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
  SELECT_GOAL (BEST_FIRST (has_fewer_prems 1, size_of_thm) (step_tac 1));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
end;