src/Provers/blast.ML
changeset 42477 52fa26b6c524
parent 42369 167e8ba0f4b1
child 42616 92715b528e78
equal deleted inserted replaced
42476:d0bc1268ef09 42477:52fa26b6c524
    38 (*Should be a type abbreviation?*)
    38 (*Should be a type abbreviation?*)
    39 type netpair = (int*(bool*thm)) Net.net * (int*(bool*thm)) Net.net;
    39 type netpair = (int*(bool*thm)) Net.net * (int*(bool*thm)) Net.net;
    40 
    40 
    41 signature BLAST_DATA =
    41 signature BLAST_DATA =
    42 sig
    42 sig
       
    43   structure Classical: CLASSICAL
    43   val thy: theory
    44   val thy: theory
    44   type claset
       
    45   val equality_name: string
    45   val equality_name: string
    46   val not_name: string
    46   val not_name: string
    47   val notE              : thm           (* [| ~P;  P |] ==> R *)
    47   val notE: thm           (* [| ~P;  P |] ==> R *)
    48   val ccontr            : thm
    48   val ccontr: thm
    49   val contr_tac         : int -> tactic
    49   val hyp_subst_tac: bool -> int -> tactic
    50   val dup_intr          : thm -> thm
       
    51   val hyp_subst_tac     : bool -> int -> tactic
       
    52   val rep_cs    : (* dependent on classical.ML *)
       
    53       claset -> {safeIs: thm list, safeEs: thm list,
       
    54                  hazIs: thm list, hazEs: thm list,
       
    55                  swrappers: (string * wrapper) list,
       
    56                  uwrappers: (string * wrapper) list,
       
    57                  safe0_netpair: netpair, safep_netpair: netpair,
       
    58                  haz_netpair: netpair, dup_netpair: netpair, xtra_netpair: Context_Rules.netpair}
       
    59   val cla_modifiers: Method.modifier parser list
       
    60   val cla_meth': (claset -> int -> tactic) -> Proof.context -> Proof.method
       
    61 end;
    50 end;
    62 
    51 
    63 signature BLAST =
    52 signature BLAST =
    64 sig
    53 sig
    65   type claset
    54   type claset
    70     | Free  of string
    59     | Free  of string
    71     | Var   of term option Unsynchronized.ref
    60     | Var   of term option Unsynchronized.ref
    72     | Bound of int
    61     | Bound of int
    73     | Abs   of string*term
    62     | Abs   of string*term
    74     | $  of term*term;
    63     | $  of term*term;
       
    64   val depth_tac: claset -> int -> int -> tactic
       
    65   val depth_limit: int Config.T
       
    66   val blast_tac: claset -> int -> tactic
       
    67   val setup: theory -> theory
       
    68   (*debugging tools*)
    75   type branch
    69   type branch
    76   val depth_tac         : claset -> int -> int -> tactic
    70   val stats: bool Unsynchronized.ref
    77   val depth_limit       : int Config.T
    71   val trace: bool Unsynchronized.ref
    78   val blast_tac         : claset -> int -> tactic
    72   val fullTrace: branch list list Unsynchronized.ref
    79   val setup             : theory -> theory
    73   val fromType: (indexname * term) list Unsynchronized.ref -> Term.typ -> term
    80   (*debugging tools*)
    74   val fromTerm: theory -> Term.term -> term
    81   val stats             : bool Unsynchronized.ref
    75   val fromSubgoal: theory -> Term.term -> term
    82   val trace             : bool Unsynchronized.ref
    76   val instVars: term -> (unit -> unit)
    83   val fullTrace         : branch list list Unsynchronized.ref
    77   val toTerm: int -> term -> Term.term
    84   val fromType          : (indexname * term) list Unsynchronized.ref -> Term.typ -> term
    78   val readGoal: theory -> string -> term
    85   val fromTerm          : theory -> Term.term -> term
    79   val tryInThy: theory -> claset -> int -> string ->
    86   val fromSubgoal       : theory -> Term.term -> term
    80     (int -> tactic) list * branch list list * (int * int * exn) list
    87   val instVars          : term -> (unit -> unit)
    81   val normBr: branch -> branch
    88   val toTerm            : int -> term -> Term.term
       
    89   val readGoal          : theory -> string -> term
       
    90   val tryInThy          : theory -> claset -> int -> string ->
       
    91                   (int->tactic) list * branch list list * (int*int*exn) list
       
    92   val normBr            : branch -> branch
       
    93 end;
    82 end;
    94 
    83 
    95 
    84 functor Blast(Data: BLAST_DATA): BLAST =
    96 functor Blast(Data: BLAST_DATA) : BLAST =
       
    97 struct
    85 struct
    98 
    86 
    99 type claset = Data.claset;
    87 structure Classical = Data.Classical;
       
    88 type claset = Classical.claset;
   100 
    89 
   101 val trace = Unsynchronized.ref false
    90 val trace = Unsynchronized.ref false
   102 and stats = Unsynchronized.ref false;   (*for runtime and search statistics*)
    91 and stats = Unsynchronized.ref false;   (*for runtime and search statistics*)
   103 
    92 
   104 datatype term =
    93 datatype term =
   539   Since haz rules are now delayed, "dup" is always FALSE for
   528   Since haz rules are now delayed, "dup" is always FALSE for
   540   introduction rules.*)
   529   introduction rules.*)
   541 fun fromIntrRule thy vars rl =
   530 fun fromIntrRule thy vars rl =
   542   let val trl = rl |> Thm.prop_of |> fromTerm thy |> convertIntrRule vars
   531   let val trl = rl |> Thm.prop_of |> fromTerm thy |> convertIntrRule vars
   543       fun tac (upd,dup,rot) i =
   532       fun tac (upd,dup,rot) i =
   544          rmtac upd (if dup then Data.dup_intr rl else rl) i
   533          rmtac upd (if dup then Classical.dup_intr rl else rl) i
   545          THEN
   534          THEN
   546          rot_subgoals_tac (rot, #2 trl) i
   535          rot_subgoals_tac (rot, #2 trl) i
   547   in (trl, tac) end;
   536   in (trl, tac) end;
   548 
   537 
   549 
   538 
   926   bound on unsafe expansions.
   915   bound on unsafe expansions.
   927  "start" is CPU time at start, for printing search time
   916  "start" is CPU time at start, for printing search time
   928 *)
   917 *)
   929 fun prove (state, start, cs, brs, cont) =
   918 fun prove (state, start, cs, brs, cont) =
   930  let val State {thy, ntrail, nclosed, ntried, ...} = state;
   919  let val State {thy, ntrail, nclosed, ntried, ...} = state;
   931      val {safe0_netpair, safep_netpair, haz_netpair, ...} = Data.rep_cs cs
   920      val {safe0_netpair, safep_netpair, haz_netpair, ...} = Classical.rep_cs cs
   932      val safeList = [safe0_netpair, safep_netpair]
   921      val safeList = [safe0_netpair, safep_netpair]
   933      and hazList  = [haz_netpair]
   922      and hazList  = [haz_netpair]
   934      fun prv (tacs, trs, choices, []) =
   923      fun prv (tacs, trs, choices, []) =
   935                 (printStats state (!trace orelse !stats, start, tacs);
   924                 (printStats state (!trace orelse !stats, start, tacs);
   936                  cont (tacs, trs, choices))   (*all branches closed!*)
   925                  cont (tacs, trs, choices))   (*all branches closed!*)
  1312 (** method setup **)
  1301 (** method setup **)
  1313 
  1302 
  1314 val setup =
  1303 val setup =
  1315   setup_depth_limit #>
  1304   setup_depth_limit #>
  1316   Method.setup @{binding blast}
  1305   Method.setup @{binding blast}
  1317     (Scan.lift (Scan.option Parse.nat) --| Method.sections Data.cla_modifiers >>
  1306     (Scan.lift (Scan.option Parse.nat) --| Method.sections Classical.cla_modifiers >>
  1318       (fn NONE => Data.cla_meth' blast_tac
  1307       (fn NONE => Classical.cla_meth' blast_tac
  1319         | SOME lim => Data.cla_meth' (fn cs => depth_tac cs lim)))
  1308         | SOME lim => Classical.cla_meth' (fn cs => depth_tac cs lim)))
  1320     "classical tableau prover";
  1309     "classical tableau prover";
  1321 
  1310 
  1322 end;
  1311 end;