src/HOL/TPTP/TPTP_Parser/tptp_reconstruct_library.ML
changeset 59533 e9ffe89a20a4
parent 59498 50b60f501b05
child 59582 0fbed69ff081
equal deleted inserted replaced
59532:82ab8168d940 59533:e9ffe89a20a4
    33        'a list ->
    33        'a list ->
    34        'b list ->
    34        'b list ->
    35        ('a * 'b) list -> ('a * 'b) list * ('a list * 'b list)
    35        ('a * 'b) list -> ('a * 'b) list * ('a list * 'b list)
    36 
    36 
    37   val consts_in : term -> term list
    37   val consts_in : term -> term list
    38   val head_quantified_variable :
    38   val head_quantified_variable : Proof.context -> int -> thm -> (string * typ) option
    39      int -> thm -> (string * typ) option
       
    40   val push_allvar_in : string -> term -> term
    39   val push_allvar_in : string -> term -> term
    41   val strip_top_All_var : term -> (string * typ) * term
    40   val strip_top_All_var : term -> (string * typ) * term
    42   val strip_top_All_vars : term -> (string * typ) list * term
    41   val strip_top_All_vars : term -> (string * typ) list * term
    43   val strip_top_all_vars :
    42   val strip_top_all_vars :
    44      (string * typ) list -> term -> (string * typ) list * term
    43      (string * typ) list -> term -> (string * typ) list * term
    45   val trace_tac' :
    44   val trace_tac' : Proof.context -> string ->
    46      string ->
       
    47      ('a -> thm -> 'b Seq.seq) -> 'a -> thm -> 'b Seq.seq
    45      ('a -> thm -> 'b Seq.seq) -> 'a -> thm -> 'b Seq.seq
    48   val try_dest_Trueprop : term -> term
    46   val try_dest_Trueprop : term -> term
    49 
    47 
    50   val type_devar : ((indexname * sort) * typ) list -> term -> term
    48   val type_devar : ((indexname * sort) * typ) list -> term -> term
    51   val diff_and_instantiate : Proof.context -> thm -> term -> term -> thm
    49   val diff_and_instantiate : Proof.context -> thm -> term -> term -> thm
    52 
    50 
    53   val batter : int -> tactic
    51   val batter_tac : Proof.context -> int -> tactic
    54   val break_hypotheses : int -> tactic
    52   val break_hypotheses_tac : Proof.context -> int -> tactic
    55   val clause_breaker : int -> tactic
    53   val clause_breaker_tac : Proof.context -> int -> tactic
    56   (* val dist_all_and_tac : Proof.context -> int -> tactic *)(*FIXME unused*)
    54   (* val dist_all_and_tac : Proof.context -> int -> tactic *)(*FIXME unused*)
    57   val reassociate_conjs_tac : Proof.context -> int -> tactic
    55   val reassociate_conjs_tac : Proof.context -> int -> tactic
    58 
    56 
    59   val ASAP : (int -> tactic) -> (int -> tactic) -> int -> tactic
    57   val ASAP : (int -> tactic) -> (int -> tactic) -> int -> tactic
    60   val COND' :
    58   val COND' :
   614   end
   612   end
   615 
   613 
   616 
   614 
   617 (** Some tactics **)
   615 (** Some tactics **)
   618 
   616 
   619 val break_hypotheses =
   617 fun break_hypotheses_tac ctxt =
   620  ((REPEAT_DETERM o etac @{thm conjE})
   618   CHANGED o
   621   THEN' (REPEAT_DETERM o etac @{thm disjE})
   619    ((REPEAT_DETERM o eresolve_tac ctxt @{thms conjE}) THEN'
   622  ) #> CHANGED
   620     (REPEAT_DETERM o eresolve_tac ctxt @{thms disjE}))
   623 
   621 
   624 (*Prove subgoals of form A ==> B1 | ... | A | ... | Bn*)
   622 (*Prove subgoals of form A ==> B1 | ... | A | ... | Bn*)
   625 val clause_breaker =
   623 fun clause_breaker_tac ctxt =
   626   (REPEAT o (resolve0_tac [@{thm "disjI1"}, @{thm "disjI2"}, @{thm "conjI"}]))
   624   (REPEAT o resolve_tac ctxt @{thms disjI1 disjI2 conjI}) THEN'
   627   THEN'  atac
   625   assume_tac ctxt
   628 
   626 
   629 (*
   627 (*
   630   Refines a subgoal have the form:
   628   Refines a subgoal have the form:
   631     A1 ... An ==> B1 | ... | Aj | ... | Bi | ... | Ak | ...
   629     A1 ... An ==> B1 | ... | Aj | ... | Bi | ... | Ak | ...
   632   into multiple subgoals of the form:
   630   into multiple subgoals of the form:
   634      :
   632      :
   635     A'm ==> B1 | ... | Aj | ... | Bi | ... | Ak | ...
   633     A'm ==> B1 | ... | Aj | ... | Bi | ... | Ak | ...
   636   where {A'1 .. A'm} is disjoint from {B1, ..., Aj, ..., Bi, ..., Ak, ...}
   634   where {A'1 .. A'm} is disjoint from {B1, ..., Aj, ..., Bi, ..., Ak, ...}
   637   (and solves the subgoal completely if the first set is empty)
   635   (and solves the subgoal completely if the first set is empty)
   638 *)
   636 *)
   639 val batter =
   637 fun batter_tac ctxt i =
   640   break_hypotheses
   638   break_hypotheses_tac ctxt i THEN
   641   THEN' K (ALLGOALS (TRY o clause_breaker))
   639   ALLGOALS (TRY o clause_breaker_tac ctxt)
   642 
   640 
   643 (*Same idiom as ex_expander_tac*)
   641 (*Same idiom as ex_expander_tac*)
   644 fun dist_all_and_tac ctxt i =
   642 fun dist_all_and_tac ctxt i =
   645    let
   643    let
   646      val simpset =
   644      val simpset =
   667         C
   665         C
   668       -----
   666       -----
   669         D
   667         D
   670   This function returns "SOME X" if C = "! X. C'".
   668   This function returns "SOME X" if C = "! X. C'".
   671   If C has no quantification prefix, then returns NONE.*)
   669   If C has no quantification prefix, then returns NONE.*)
   672 fun head_quantified_variable i = fn st =>
   670 fun head_quantified_variable ctxt i = fn st =>
   673   let
   671   let
   674     val thy = Thm.theory_of_thm st
       
   675     val ctxt = Proof_Context.init_global thy
       
   676 
       
   677     val gls =
   672     val gls =
   678       prop_of st
   673       prop_of st
   679       |> Logic.strip_horn
   674       |> Logic.strip_horn
   680       |> fst
   675       |> fst
   681 
   676 
   777     end
   772     end
   778 
   773 
   779 
   774 
   780 (** Tracing **)
   775 (** Tracing **)
   781 (*If "tac i st" succeeds then msg is printed to "trace" channel*)
   776 (*If "tac i st" succeeds then msg is printed to "trace" channel*)
   782 fun trace_tac' msg tac i st =
   777 fun trace_tac' ctxt msg tac i st =
   783   let
   778   let
   784     val thy = Thm.theory_of_thm st
       
   785     val ctxt = Proof_Context.init_global thy
       
   786     val result = tac i st
   779     val result = tac i st
   787   in
   780   in
   788     if Config.get ctxt tptp_trace_reconstruction andalso
   781     if Config.get ctxt tptp_trace_reconstruction andalso
   789      not (is_none (Seq.pull result)) then
   782      not (is_none (Seq.pull result)) then
   790       (tracing msg; result)
   783       (tracing msg; result)