src/HOL/Tools/res_atp_setup.ML
author paulson
Tue, 31 Jan 2006 10:39:13 +0100
changeset 18863 a113b6839df1
parent 18748 1d7b0830a8a7
child 18920 7635e0060cd4
permissions -rw-r--r--
reorganization of code to support DFG otuput
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17907
c20e4bddcb11 *** empty log message ***
mengj
parents: 17905
diff changeset
     1
(* ID: $Id$ 
c20e4bddcb11 *** empty log message ***
mengj
parents: 17905
diff changeset
     2
   Author: Jia Meng, NICTA
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     3
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     4
*)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     5
structure ResAtpSetup =
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     6
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     7
struct
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     8
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     9
val keep_atp_input = ref false;
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    10
val debug = ref true;
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    11
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    12
val fol_keep_types = ResClause.keep_types;
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    13
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    14
(* use them to set and find type levels of HOL clauses *)
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    15
val hol_full_types = ResHolClause.full_types;
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    16
val hol_partial_types = ResHolClause.partial_types;
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    17
val hol_const_types_only = ResHolClause.const_types_only;
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    18
val hol_no_types = ResHolClause.no_types;
18748
1d7b0830a8a7 Fixed a bug.
mengj
parents: 18727
diff changeset
    19
fun hol_typ_level () = ResHolClause.find_typ_level ();
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    20
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    21
fun is_typed_hol () = 
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    22
    let val tp_level = hol_typ_level()
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    23
    in
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    24
	not (tp_level = ResHolClause.T_NONE)
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    25
    end;
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    26
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    27
val include_combS = ResHolClause.include_combS;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    28
val include_min_comb = ResHolClause.include_min_comb;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    29
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    30
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    31
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    32
(*******************************************************)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    33
(* set up the output paths                             *)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    34
(*******************************************************)
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    35
fun full_typed_comb () =
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    36
    if !ResHolClause.include_combS then 
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    37
	(ResAtp.helper_path "E_HOME" "additionals/full_comb_inclS"
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    38
	 handle _ => ResAtp.helper_path "VAMPIRE_HOME" "additionals/full_comb_inclS")
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    39
    else 
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    40
	(ResAtp.helper_path "E_HOME" "additionals/full_comb_noS"
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    41
	 handle _ => ResAtp.helper_path "VAMPIRE_HOME" "additionals/full_comb_noS");
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    42
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    43
fun partial_typed_comb () = 
18197
082a2bd6f655 -- added combinator reduction axioms (typed and untyped) for HOL goals.
mengj
parents: 18141
diff changeset
    44
    if !ResHolClause.include_combS then 
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    45
	(ResAtp.helper_path "E_HOME" "additionals/par_comb_inclS"
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    46
	 handle _ => ResAtp.helper_path "VAMPIRE_HOME" "additionals/par_comb_inclS")
18197
082a2bd6f655 -- added combinator reduction axioms (typed and untyped) for HOL goals.
mengj
parents: 18141
diff changeset
    47
    else 
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    48
	(ResAtp.helper_path "E_HOME" "additionals/par_comb_noS"
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    49
	 handle _ => ResAtp.helper_path "VAMPIRE_HOME" "additionals/par_comb_noS");
18197
082a2bd6f655 -- added combinator reduction axioms (typed and untyped) for HOL goals.
mengj
parents: 18141
diff changeset
    50
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    51
fun const_typed_comb () =
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    52
    if !ResHolClause.include_combS then 
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    53
	(ResAtp.helper_path "E_HOME" "additionals/const_comb_inclS"
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    54
	 handle _ => ResAtp.helper_path "VAMPIRE_HOME" "additionals/const_comb_inclS")
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    55
    else 
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    56
	(ResAtp.helper_path "E_HOME" "additionals/const_comb_noS"
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    57
	 handle _ => ResAtp.helper_path "VAMPIRE_HOME" "additionals/const_comb_noS");
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    58
	
18197
082a2bd6f655 -- added combinator reduction axioms (typed and untyped) for HOL goals.
mengj
parents: 18141
diff changeset
    59
fun untyped_comb () = 
082a2bd6f655 -- added combinator reduction axioms (typed and untyped) for HOL goals.
mengj
parents: 18141
diff changeset
    60
    if !ResHolClause.include_combS then 
082a2bd6f655 -- added combinator reduction axioms (typed and untyped) for HOL goals.
mengj
parents: 18141
diff changeset
    61
	(ResAtp.helper_path "E_HOME" "additionals/u_comb_inclS"
082a2bd6f655 -- added combinator reduction axioms (typed and untyped) for HOL goals.
mengj
parents: 18141
diff changeset
    62
	 handle _ => ResAtp.helper_path "VAMPIRE_HOME" "additionals/u_comb_inclS")
082a2bd6f655 -- added combinator reduction axioms (typed and untyped) for HOL goals.
mengj
parents: 18141
diff changeset
    63
    else
082a2bd6f655 -- added combinator reduction axioms (typed and untyped) for HOL goals.
mengj
parents: 18141
diff changeset
    64
	(ResAtp.helper_path "E_HOME" "additionals/u_comb_noS"
082a2bd6f655 -- added combinator reduction axioms (typed and untyped) for HOL goals.
mengj
parents: 18141
diff changeset
    65
	 handle _ => ResAtp.helper_path "VAMPIRE_HOME" "additionals/u_comb_noS");
082a2bd6f655 -- added combinator reduction axioms (typed and untyped) for HOL goals.
mengj
parents: 18141
diff changeset
    66
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    67
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    68
fun full_typed_HOL_helper1 () =
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    69
    ResAtp.helper_path "E_HOME" "additionals/full_helper1"
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    70
    handle _ => ResAtp.helper_path "VAMPIRE_HOME" "additionals/full_helper1";
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    71
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    72
fun partial_typed_HOL_helper1 () = 
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    73
    ResAtp.helper_path "E_HOME" "additionals/par_helper1"
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    74
    handle _ => ResAtp.helper_path "VAMPIRE_HOME" "additionals/par_helper1";
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    75
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    76
fun const_typed_HOL_helper1 () = 
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    77
    ResAtp.helper_path "E_HOME" "additionals/const_helper1"
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    78
    handle _ => ResAtp.helper_path "VAMPIRE_HOME" "additionals/const_helper1";
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    79
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    80
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    81
fun untyped_HOL_helper1 () = 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    82
    ResAtp.helper_path "E_HOME" "additionals/u_helper1"
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    83
    handle _ => ResAtp.helper_path "VAMPIRE_HOME" "additionals/u_helper1";
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    84
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    85
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    86
fun HOL_helper1 () =
18748
1d7b0830a8a7 Fixed a bug.
mengj
parents: 18727
diff changeset
    87
    let val tp_level = !ResHolClause.typ_level
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    88
    in
18748
1d7b0830a8a7 Fixed a bug.
mengj
parents: 18727
diff changeset
    89
	case tp_level of ResHolClause.T_PARTIAL => (warning "Partial type helper"; partial_typed_HOL_helper1 ())
1d7b0830a8a7 Fixed a bug.
mengj
parents: 18727
diff changeset
    90
		       | ResHolClause.T_FULL => (warning "Full type helper"; full_typed_HOL_helper1 ())
1d7b0830a8a7 Fixed a bug.
mengj
parents: 18727
diff changeset
    91
		       | ResHolClause.T_CONST => (warning "Const type helper"; const_typed_HOL_helper1 ())
1d7b0830a8a7 Fixed a bug.
mengj
parents: 18727
diff changeset
    92
		       | ResHolClause.T_NONE => (warning "Untyped helper"; untyped_HOL_helper1 ())
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    93
    end;
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    94
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    95
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
    96
fun HOL_comb () =
18748
1d7b0830a8a7 Fixed a bug.
mengj
parents: 18727
diff changeset
    97
    let val tp_level = !ResHolClause.typ_level
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
    98
    in
18748
1d7b0830a8a7 Fixed a bug.
mengj
parents: 18727
diff changeset
    99
	case tp_level of ResHolClause.T_FULL => (warning "Full type comb"; full_typed_comb ())
1d7b0830a8a7 Fixed a bug.
mengj
parents: 18727
diff changeset
   100
		       | ResHolClause.T_PARTIAL => (warning "Partial type comb"; partial_typed_comb ())
1d7b0830a8a7 Fixed a bug.
mengj
parents: 18727
diff changeset
   101
		       | ResHolClause.T_CONST => (warning "Const type comb"; const_typed_comb ())
1d7b0830a8a7 Fixed a bug.
mengj
parents: 18727
diff changeset
   102
		       | ResHolClause.T_NONE => (warning "Untyped comb"; untyped_comb ())
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
   103
    end;
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   104
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   105
18401
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   106
fun atp_input_file file =
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   107
    let val file' = !ResAtp.problem_name ^ "_" ^ file
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   108
    in
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   109
	if !ResAtp.destdir = "" then File.platform_path (File.tmp_path (Path.basic file'))
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   110
	else if File.exists (File.unpack_platform_path (!ResAtp.destdir))
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   111
	then !ResAtp.destdir ^ "/" ^ file'
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   112
	else error ("No such directory: " ^ !ResAtp.destdir)
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   113
    end;
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   114
18401
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   115
fun claset_file () = atp_input_file "claset";
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   116
fun simpset_file () = atp_input_file "simp";
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   117
fun local_lemma_file () = atp_input_file "locallemmas";
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   118
fun hyps_file () = atp_input_file "hyps";
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   119
fun prob_file _ = atp_input_file "";
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   120
18401
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   121
fun types_sorts_file () = atp_input_file "typesorts";
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   122
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   123
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   124
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   125
(*******************************************************)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   126
(* operations on Isabelle theorems:                    *)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   127
(* retrieving from ProofContext,                       *)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   128
(* modifying local theorems,                           *)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   129
(* CNF                                                 *)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   130
(*******************************************************)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   131
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   132
val include_simpset = ref false;
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   133
val include_claset = ref false; 
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   134
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   135
val add_simpset = (fn () => include_simpset:=true);
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   136
val add_claset = (fn () => include_claset:=true);
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   137
val add_clasimp = (fn () => include_simpset:=true;include_claset:=true);
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   138
val rm_simpset = (fn () => include_simpset:=false);
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   139
val rm_claset = (fn () => include_claset:=false);
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   140
val rm_clasimp = (fn () => include_simpset:=false;include_claset:=false);
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   141
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   142
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   143
(******************************************************************)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   144
(* detect whether a given problem (clauses) is FOL/HOL/HOLC/HOLCS *)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   145
(******************************************************************)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   146
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   147
datatype logic = FOL | HOL | HOLC | HOLCS;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   148
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   149
fun string_of_logic FOL = "FOL"
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   150
  | string_of_logic HOL = "HOL"
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   151
  | string_of_logic HOLC = "HOLC"
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   152
  | string_of_logic HOLCS = "HOLCS";
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   153
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   154
(*HOLCS will not occur here*)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   155
fun upgrade_lg HOLC _ = HOLC
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   156
  | upgrade_lg HOL HOLC = HOLC
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   157
  | upgrade_lg HOL _ = HOL
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   158
  | upgrade_lg FOL lg = lg; 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   159
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   160
(* check types *)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   161
fun has_bool (Type("bool",_)) = true
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   162
  | has_bool (Type(_, Ts)) = exists has_bool Ts
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   163
  | has_bool _ = false;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   164
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   165
fun has_bool_arg tp = 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   166
    let val (targs,tr) = strip_type tp
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   167
    in
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   168
	exists has_bool targs
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   169
    end;
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   170
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   171
fun is_fn_tp (Type("fun",_)) = true
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   172
  | is_fn_tp _ = false;
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   173
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   174
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   175
exception FN_LG of term;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   176
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   177
fun fn_lg (t as Const(f,tp)) (lg,seen) = 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   178
    if has_bool tp then (upgrade_lg HOL lg, t ins seen) else (lg, t ins seen) 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   179
  | fn_lg (t as Free(f,tp)) (lg,seen) = 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   180
    if has_bool tp then (upgrade_lg HOL lg, t ins seen) else (lg, t ins seen) 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   181
  | fn_lg (t as Var(f,tp)) (lg,seen) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   182
    if is_fn_tp tp orelse has_bool tp then (upgrade_lg HOL lg,t ins seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   183
    else (lg,t ins seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   184
  | fn_lg (t as Abs(_,_,_)) (lg,seen) = (upgrade_lg HOLC lg,t ins seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   185
  | fn_lg f _ = raise FN_LG(f); 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   186
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   187
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   188
fun term_lg [] (lg,seen) = (lg,seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   189
  | term_lg (tm::tms) (FOL,seen) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   190
    let val (f,args) = strip_comb tm
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   191
	val (lg',seen') = if f mem seen then (FOL,seen) 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   192
			  else fn_lg f (FOL,seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   193
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   194
	 in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   195
	     term_lg (args@tms) (lg',seen')
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   196
    end
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   197
  | term_lg _ (lg,seen) = (lg,seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   198
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   199
exception PRED_LG of term;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   200
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   201
fun pred_lg (t as Const(P,tp)) (lg,seen)= 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   202
    if has_bool_arg tp then (upgrade_lg HOL lg, t ins seen) else (lg,t ins seen) 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   203
  | pred_lg (t as Free(P,tp)) (lg,seen) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   204
    if has_bool_arg tp then (upgrade_lg HOL lg, t ins seen) else (lg,t ins seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   205
  | pred_lg (t as Var(_,_)) (lg,seen) = (upgrade_lg HOL lg, t ins seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   206
  | pred_lg P _ = raise PRED_LG(P);
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   207
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   208
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   209
fun lit_lg (Const("Not",_) $ P) (lg,seen) = lit_lg P (lg,seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   210
  | lit_lg P (lg,seen) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   211
    let val (pred,args) = strip_comb P
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   212
	val (lg',seen') = if pred mem seen then (lg,seen) 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   213
			  else pred_lg pred (lg,seen)
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   214
    in
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   215
	term_lg args (lg',seen')
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   216
    end;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   217
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   218
fun lits_lg [] (lg,seen) = (lg,seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   219
  | lits_lg (lit::lits) (FOL,seen) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   220
    lits_lg lits (lit_lg lit (FOL,seen))
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   221
  | lits_lg lits (lg,seen) = (lg,seen);
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   222
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   223
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   224
fun logic_of_clause tm (lg,seen) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   225
    let val tm' = HOLogic.dest_Trueprop tm
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   226
	val disjs = HOLogic.dest_disj tm'
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   227
    in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   228
	lits_lg disjs (lg,seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   229
    end;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   230
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   231
fun lits_lg [] (lg,seen) = (lg,seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   232
  | lits_lg (lit::lits) (FOL,seen) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   233
    lits_lg lits (lit_lg lit (FOL,seen))
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   234
  | lits_lg lits (lg,seen) = (lg,seen);
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   235
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   236
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   237
fun logic_of_clause tm (lg,seen) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   238
    let val tm' = HOLogic.dest_Trueprop tm
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   239
	val disjs = HOLogic.dest_disj tm'
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   240
    in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   241
	lits_lg disjs (lg,seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   242
    end;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   243
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   244
fun logic_of_clauses [] (lg,seen) = (lg,seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   245
  | logic_of_clauses (cls::clss) (FOL,seen) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   246
    logic_of_clauses clss (logic_of_clause cls (FOL,seen))
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   247
  | logic_of_clauses (cls::clss) (lg,seen) = (lg,seen);
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   248
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   249
fun logic_of_nclauses [] (lg,seen) = (lg,seen)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   250
  | logic_of_nclauses (cls::clss) (FOL,seen) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   251
    logic_of_nclauses clss (logic_of_clauses (snd cls) (FOL,seen))
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   252
  | logic_of_nclauses clss (lg,seen) = (lg,seen);
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   253
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   254
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   255
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   256
fun problem_logic (conj_cls,hyp_cls,userR,claR,simpR) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   257
    let val (lg1,seen1) = logic_of_clauses conj_cls (FOL,[])
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   258
	val (lg2,seen2) = logic_of_clauses hyp_cls (lg1,seen1)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   259
	val (lg3,seen3) = logic_of_nclauses userR (lg2,seen2)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   260
	val (lg4,seen4) = logic_of_nclauses claR (lg3,seen3)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   261
	val (lg5,seen5) = logic_of_nclauses simpR (lg4,seen4)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   262
    in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   263
	lg5
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   264
    end;
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   265
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   266
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   267
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   268
(***************************************************************)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   269
(* prover-specific output format:                              *)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   270
(* TPTP                                                        *)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   271
(***************************************************************)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   272
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   273
(**** CNF rules and hypothesis ****)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   274
fun cnf_rules_tms ctxt ths (include_claset,include_simpset) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   275
    let val local_claR = if include_claset then ResAxioms.claset_rules_of_ctxt ctxt else []
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   276
	val (local_claR_cls,err1) = ResAxioms.cnf_rules2 local_claR []
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   277
	val local_simpR = if include_simpset then ResAxioms.simpset_rules_of_ctxt ctxt else []
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   278
	val (local_simpR_cls,err2) = ResAxioms.cnf_rules2 local_simpR []
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   279
	val (user_ths_cls,err3) = ResAxioms.cnf_rules2 (map ResAxioms.pairname ths) []
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   280
	val errs = err3 @ err2 @ err1
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   281
    in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   282
	(user_ths_cls,local_simpR_cls,local_claR_cls,errs)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   283
    end;
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   284
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   285
fun cnf_hyps_thms ctxt = 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   286
    let val ths = ProofContext.prems_of ctxt
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   287
    in
18508
paulson
parents: 18401
diff changeset
   288
	ResClause.union_all (map ResAxioms.skolem_thm ths)
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   289
    end;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   290
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   291
(**** clausification ****)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   292
fun cls_axiom_fol _ _ [] = []
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   293
  | cls_axiom_fol name i (tm::tms) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   294
   (ResClause.make_axiom_clause tm (name,i)) :: (cls_axiom_fol name (i+1) tms);
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   295
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   296
fun cls_axiom_hol  _ _ [] = []
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   297
  | cls_axiom_hol name i (tm::tms) =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   298
   (ResHolClause.make_axiom_clause tm (name,i)) :: (cls_axiom_hol name (i+1) tms);
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   299
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   300
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   301
fun filtered_tptp_axiom_fol name clss =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   302
    (fst(ListPair.unzip (map ResClause.clause2tptp (filter (fn c => not (ResClause.isTaut c)) (cls_axiom_fol name 0 clss)))),[])
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   303
    handle _ => ([],[name]);
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   304
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   305
fun filtered_tptp_axiom_hol name clss =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   306
    (fst(ListPair.unzip (map ResHolClause.clause2tptp (filter (fn c => not (ResHolClause.isTaut c)) (cls_axiom_hol name 0 clss)))),[])
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   307
    handle _ => ([],[name]);
18001
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   308
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   309
fun tptp_axioms_g filt_ax_fn [] err = ([],err)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   310
  | tptp_axioms_g filt_ax_fn ((name,clss)::nclss) err =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   311
    let val (nclss1,err1) = tptp_axioms_g filt_ax_fn nclss err
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   312
	val (clsstrs,err_name_list) = filt_ax_fn name clss
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   313
    in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   314
	case clsstrs of [] => (nclss1,err_name_list @ err1) 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   315
		      | _ => (clsstrs::nclss1,err1)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   316
    end;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   317
		
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   318
fun tptp_axioms_fol rules = tptp_axioms_g filtered_tptp_axiom_fol rules [];
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   319
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   320
fun tptp_axioms_hol rules = tptp_axioms_g filtered_tptp_axiom_hol rules [];
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   321
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   322
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   323
fun atp_axioms_g tptp_ax_fn rules file =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   324
    let val out = TextIO.openOut file
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   325
	val (clss,errs) = tptp_ax_fn rules
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   326
	val clss' = ResClause.union_all clss
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   327
    in
18863
a113b6839df1 reorganization of code to support DFG otuput
paulson
parents: 18748
diff changeset
   328
	ResClause.writeln_strs out clss';
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   329
	TextIO.closeOut out;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   330
	([file],errs)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   331
    end;
18001
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   332
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   333
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   334
fun atp_axioms_fol rules file = atp_axioms_g tptp_axioms_fol rules file;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   335
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   336
fun atp_axioms_hol rules file = atp_axioms_g tptp_axioms_hol rules file;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   337
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   338
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   339
fun filtered_tptp_conjectures_fol terms =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   340
    let val clss = ResClause.make_conjecture_clauses terms
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   341
	val clss' = filter (fn c => not (ResClause.isTaut c)) clss
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   342
    in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   343
	ListPair.unzip (map ResClause.clause2tptp clss')
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   344
    end;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   345
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   346
fun filtered_tptp_conjectures_hol terms =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   347
    let val clss = ResHolClause.make_conjecture_clauses terms
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   348
	val clss' = filter (fn c => not (ResHolClause.isTaut c)) clss
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   349
    in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   350
	ListPair.unzip (map ResHolClause.clause2tptp clss')
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   351
    end;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   352
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   353
fun atp_conjectures_h_g filt_conj_fn hyp_cls =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   354
    let val (tptp_h_clss,tfree_litss) = filt_conj_fn hyp_cls
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   355
	val tfree_lits = ResClause.union_all tfree_litss
18863
a113b6839df1 reorganization of code to support DFG otuput
paulson
parents: 18748
diff changeset
   356
	val tfree_clss = map ResClause.tptp_tfree_clause tfree_lits 
18401
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   357
	val hypsfile = hyps_file ()
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   358
        val out = TextIO.openOut(hypsfile)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   359
    in
18863
a113b6839df1 reorganization of code to support DFG otuput
paulson
parents: 18748
diff changeset
   360
        ResClause.writeln_strs out (tfree_clss @ tptp_h_clss);
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   361
        TextIO.closeOut out; warning hypsfile;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   362
        ([hypsfile],tfree_lits)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   363
    end;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   364
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   365
fun atp_conjectures_h_fol hyp_cls = atp_conjectures_h_g filtered_tptp_conjectures_fol hyp_cls;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   366
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   367
fun atp_conjectures_h_hol hyp_cls = atp_conjectures_h_g filtered_tptp_conjectures_hol hyp_cls;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   368
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   369
fun atp_conjectures_c_g filt_conj_fn conj_cls n tfrees =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   370
    let val (tptp_c_clss,tfree_litss) = filt_conj_fn conj_cls
18863
a113b6839df1 reorganization of code to support DFG otuput
paulson
parents: 18748
diff changeset
   371
	val tfree_clss = map ResClause.tptp_tfree_clause ((ResClause.union_all tfree_litss) \\ tfrees)
18401
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   372
	val probfile = prob_file n
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   373
	val out = TextIO.openOut(probfile)		 	
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   374
    in
18863
a113b6839df1 reorganization of code to support DFG otuput
paulson
parents: 18748
diff changeset
   375
	ResClause.writeln_strs out (tfree_clss @ tptp_c_clss);
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   376
	TextIO.closeOut out;
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   377
	warning probfile; 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   378
	probfile 
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   379
    end;
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   380
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   381
fun atp_conjectures_c_fol conj_cls n tfrees = atp_conjectures_c_g filtered_tptp_conjectures_fol conj_cls n tfrees;
18001
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   382
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   383
fun atp_conjectures_c_hol conj_cls n tfrees = atp_conjectures_c_g filtered_tptp_conjectures_hol conj_cls n tfrees;
18001
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   384
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   385
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   386
fun atp_conjectures_g atp_conj_h_fn atp_conj_c_fn [] conj_cls n =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   387
    let val probfile = atp_conj_c_fn conj_cls n []
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   388
    in
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   389
	[probfile]
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   390
    end
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   391
  | atp_conjectures_g atp_conj_h_fn atp_conj_c_fn hyp_cls conj_cls n =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   392
    let val (hypsfile,tfree_lits) = atp_conj_h_fn hyp_cls
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   393
	val probfile = atp_conj_c_fn conj_cls n tfree_lits
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   394
    in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   395
	(probfile::hypsfile)
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   396
    end;
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   397
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   398
fun atp_conjectures_fol hyp_cls conj_cls n = atp_conjectures_g atp_conjectures_h_fol atp_conjectures_c_fol hyp_cls conj_cls n;
18001
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   399
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   400
fun atp_conjectures_hol hyp_cls conj_cls n = atp_conjectures_g atp_conjectures_h_hol atp_conjectures_c_hol hyp_cls conj_cls n;
18086
051b7f323b4c Changed the way additional lemmas are passed to ATP methods for proof of a goal: now only list them after the methods' names.
mengj
parents: 18014
diff changeset
   401
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   402
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   403
(**** types and sorts ****)
18001
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   404
fun tptp_types_sorts thy = 
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   405
    let val classrel_clauses = ResClause.classrel_clauses_thy thy
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   406
	val arity_clauses = ResClause.arity_clause_thy thy
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   407
	val classrel_cls = map ResClause.tptp_classrelClause classrel_clauses
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   408
	val arity_cls = map ResClause.tptp_arity_clause arity_clauses
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   409
	fun write_ts () =
18401
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   410
	    let val tsfile = types_sorts_file ()
18001
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   411
		val out = TextIO.openOut(tsfile)
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   412
	    in
18863
a113b6839df1 reorganization of code to support DFG otuput
paulson
parents: 18748
diff changeset
   413
		ResClause.writeln_strs out (classrel_cls @ arity_cls);
18001
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   414
		TextIO.closeOut out;
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   415
		[tsfile]
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   416
	    end
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   417
    in
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   418
	if (List.null arity_cls andalso List.null classrel_cls) then []
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   419
	else
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   420
	    write_ts ()
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   421
    end;
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   422
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   423
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   424
(******* write to files ******)
18001
6ca14bec7cd5 Added new functions to handle HOL goals and lemmas.
mengj
parents: 17939
diff changeset
   425
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   426
datatype mode = Auto | Fol | Hol;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   427
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   428
fun write_out_g logic atp_ax_fn atp_conj_fn (claR,simpR,userR,hyp_cls,conj_cls,n,err) =
18401
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   429
    let val (files1,err1) = if (null claR) then ([],[]) else (atp_ax_fn claR (claset_file()))
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   430
	val (files2,err2) = if (null simpR) then ([],[]) else (atp_ax_fn simpR (simpset_file ()))
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   431
	val (files3,err3) = if (null userR) then ([],[]) else (atp_ax_fn userR (local_lemma_file ()))
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   432
	val files4 = atp_conj_fn hyp_cls conj_cls n
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   433
	val errs = err1 @ err2 @ err3 @ err
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   434
	val logic' = if !include_combS then HOLCS 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   435
		     else 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   436
			 if !include_min_comb then HOLC else logic
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   437
	val _ = warning ("Problems are " ^ (string_of_logic logic'))
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   438
	val _ = if (null errs) then () else warning ("Can't clausify thms: " ^ (ResClause.paren_pack errs))
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   439
	val helpers = case logic' of FOL => []
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   440
				   | HOL => [HOL_helper1 ()]
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   441
				   | _ => [HOL_helper1(),HOL_comb()] (*HOLC or HOLCS*)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   442
    in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   443
	(helpers,files4 @ files1 @ files2 @ files3)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   444
    end;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   445
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   446
fun write_out_fol (claR,simpR,userR,hyp_cls,conj_cls,n,err) = write_out_g FOL atp_axioms_fol atp_conjectures_fol (claR,simpR,userR,hyp_cls,conj_cls,n,err);
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   447
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   448
fun write_out_hol (claR,simpR,userR,hyp_cls,conj_cls,n,err) = write_out_g HOL atp_axioms_hol atp_conjectures_hol (claR,simpR,userR,hyp_cls,conj_cls,n,err);
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   449
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   450
fun write_out_fol_ts ctxt (claR,simpR,userR,hyp_cls,conj_cls,n,err) =  
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   451
    let val ts_file = if (!fol_keep_types) then tptp_types_sorts (ProofContext.theory_of ctxt) else []
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   452
	val (helpers,files) = write_out_fol (claR,simpR,userR,hyp_cls,conj_cls,n,err) 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   453
    in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   454
	(helpers,files@ts_file)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   455
    end;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   456
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   457
fun write_out_hol_ts ctxt (claR,simpR,userR,hyp_cls,conj_cls,n,err) =  
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
   458
    let val ts_file = if (is_typed_hol()) then tptp_types_sorts (ProofContext.theory_of ctxt) else []
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   459
	val (helpers,files) = write_out_hol (claR,simpR,userR,hyp_cls,conj_cls,n,err)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   460
    in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   461
	(helpers,files@ts_file)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   462
    end;
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   463
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   464
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   465
fun prep_atp_input mode ctxt conjectures user_thms n =
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   466
    let val conj_cls = map prop_of (make_clauses conjectures) 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   467
	val (userR,simpR,claR,errs) = cnf_rules_tms ctxt user_thms (!include_claset,!include_simpset) 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   468
	val hyp_cls = map prop_of (cnf_hyps_thms ctxt) 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   469
	val logic = case mode of Auto => problem_logic (conj_cls,hyp_cls,userR,claR,simpR)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   470
			       | Fol => FOL
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   471
			       | Hol => HOL
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   472
    in
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   473
	case logic of FOL => write_out_fol_ts ctxt (claR,simpR,userR,hyp_cls,conj_cls,n,errs)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   474
		    | _ => write_out_hol_ts ctxt (claR,simpR,userR,hyp_cls,conj_cls,n,errs)
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   475
			   
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   476
    end;
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   477
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   478
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   479
(***************************************************************)
18086
051b7f323b4c Changed the way additional lemmas are passed to ATP methods for proof of a goal: now only list them after the methods' names.
mengj
parents: 18014
diff changeset
   480
(* setup ATPs as Isabelle methods                              *)
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   481
(***************************************************************)
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   482
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   483
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   484
fun atp_meth' tac ths ctxt = 
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   485
    Method.SIMPLE_METHOD' HEADGOAL
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   486
    (tac ctxt ths);
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   487
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   488
fun atp_meth tac ths ctxt = 
18357
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
   489
    let val thy = ProofContext.theory_of ctxt
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
   490
	val _ = ResClause.init thy
c5030cdbf8da Added more functions for new type embedding of HOL clauses.
mengj
parents: 18273
diff changeset
   491
	val _ = ResHolClause.init thy
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   492
    in
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   493
	atp_meth' tac ths ctxt
18197
082a2bd6f655 -- added combinator reduction axioms (typed and untyped) for HOL goals.
mengj
parents: 18141
diff changeset
   494
    end;
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   495
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   496
18273
e15a825da262 Added in four control flags for HOL and FOL translations.
mengj
parents: 18197
diff changeset
   497
fun atp_method tac = Method.thms_ctxt_args (atp_meth tac);
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   498
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   499
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   500
(*************Remove tmp files********************************)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   501
fun rm_tmp_files1 [] = ()
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   502
  | rm_tmp_files1 (f::fs) =
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   503
    (OS.FileSys.remove f; rm_tmp_files1 fs);
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   504
17939
3925ab7b8a18 Merged theory ResAtpOracle.thy into ResAtpMethods.thy
mengj
parents: 17907
diff changeset
   505
fun cond_rm_tmp files = 
3925ab7b8a18 Merged theory ResAtpOracle.thy into ResAtpMethods.thy
mengj
parents: 17907
diff changeset
   506
    if !keep_atp_input then warning "ATP input kept..." 
18401
8faa44b32a8c changed ATP input files' names and location.
mengj
parents: 18357
diff changeset
   507
    else if !ResAtp.destdir <> "" then warning ("ATP input kept in directory " ^ (!ResAtp.destdir))
17939
3925ab7b8a18 Merged theory ResAtpOracle.thy into ResAtpMethods.thy
mengj
parents: 17907
diff changeset
   508
    else (warning "deleting ATP inputs..."; rm_tmp_files1 files);
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
   509
17907
c20e4bddcb11 *** empty log message ***
mengj
parents: 17905
diff changeset
   510
end