src/HOL/Tools/res_hol_clause.ML
author paulson
Thu, 06 Jul 2006 12:18:17 +0200
changeset 20022 b07a138b4e7d
parent 20016 9a005f7d95e6
child 20125 20229342ca76
permissions -rw-r--r--
some tidying; fixed the output of theorem names
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
     1
(* ID: $Id$ 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
     2
   Author: Jia Meng, NICTA
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
     3
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
     4
FOL clauses translated from HOL formulae.  Combinators are used to represent lambda terms.
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
     5
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
     6
*)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
     7
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
     8
structure ResHolClause =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
     9
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    10
struct
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    11
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    12
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    13
val include_combS = ref false;
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    14
val include_min_comb = ref false;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    15
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    16
val const_typargs = ref (Library.K [] : (string*typ -> typ list));
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    17
20022
b07a138b4e7d some tidying; fixed the output of theorem names
paulson
parents: 20016
diff changeset
    18
fun init thy = (include_combS:=false; include_min_comb:=false;
b07a138b4e7d some tidying; fixed the output of theorem names
paulson
parents: 20016
diff changeset
    19
                const_typargs := Sign.const_typargs thy);
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
    20
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    21
(**********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    22
(* convert a Term.term with lambdas into a Term.term with combinators *) 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    23
(**********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    24
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    25
fun is_free (Bound(a)) n = (a = n)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    26
  | is_free (Abs(x,_,b)) n = (is_free b (n+1))
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    27
  | is_free (P $ Q) n = ((is_free P n) orelse (is_free Q n))
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    28
  | is_free _ _ = false;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    29
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    30
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    31
exception LAM2COMB of term;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    32
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    33
exception BND of term;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    34
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    35
fun decre_bndVar (Bound n) = Bound (n-1)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    36
  | decre_bndVar (P $ Q) = (decre_bndVar P) $ (decre_bndVar Q)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    37
  | decre_bndVar t =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    38
    case t of Const(_,_) => t
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    39
	    | Free(_,_) => t
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    40
	    | Var(_,_) => t
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    41
	    | Abs(_,_,_) => raise BND(t); (*should not occur*)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    42
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    43
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    44
(*******************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    45
fun lam2comb (Abs(x,tp,Bound 0)) _ = 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    46
    let val tpI = Type("fun",[tp,tp])
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    47
    in 
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    48
	include_min_comb:=true;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    49
	Const("COMBI",tpI) 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    50
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    51
  | lam2comb (Abs(x,tp,Bound n)) Bnds = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    52
    let val (Bound n') = decre_bndVar (Bound n)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    53
	val tb = List.nth(Bnds,n')
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    54
	val tK = Type("fun",[tb,Type("fun",[tp,tb])])
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    55
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    56
	include_min_comb:=true;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    57
	Const("COMBK",tK) $ (Bound n')
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    58
    end
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    59
  | lam2comb (Abs(x,t1,Const(c,t2))) _ = 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    60
    let val tK = Type("fun",[t2,Type("fun",[t1,t2])])
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    61
    in 
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    62
	include_min_comb:=true;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    63
	Const("COMBK",tK) $ Const(c,t2) 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    64
    end
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    65
  | lam2comb (Abs(x,t1,Free(v,t2))) _ =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    66
    let val tK = Type("fun",[t2,Type("fun",[t1,t2])])
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    67
    in
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    68
	include_min_comb:=true;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    69
	Const("COMBK",tK) $ Free(v,t2)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    70
    end
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    71
  | lam2comb (Abs(x,t1,Var(ind,t2))) _=
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    72
    let val tK = Type("fun",[t2,Type("fun",[t1,t2])])
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    73
    in
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    74
	include_min_comb:=true;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    75
	Const("COMBK",tK) $ Var(ind,t2)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    76
    end
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    77
  | lam2comb (t as (Abs(x,t1,P$(Bound 0)))) Bnds =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    78
    let val nfreeP = not(is_free P 0)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    79
	val tr = Term.type_of1(t1::Bnds,P)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    80
    in
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    81
	if nfreeP then (decre_bndVar P)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    82
	else (
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    83
	      let val tI = Type("fun",[t1,t1])
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    84
		  val P' = lam2comb (Abs(x,t1,P)) Bnds
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    85
		  val tp' = Term.type_of1(Bnds,P')
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    86
		  val tS = Type("fun",[tp',Type("fun",[tI,tr])])
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    87
	      in
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    88
		  include_min_comb:=true;
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    89
		  include_combS:=true;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    90
		  Const("COMBS",tS) $ P' $ Const("COMBI",tI)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    91
	      end)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    92
    end
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    93
	    
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    94
  | lam2comb (t as (Abs(x,t1,P$Q))) Bnds =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    95
    let val (nfreeP,nfreeQ) = (not(is_free P 0),not(is_free Q 0))
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    96
	val tpq = Term.type_of1(t1::Bnds, P$Q) 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    97
    in
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    98
	if(nfreeP andalso nfreeQ) then (
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
    99
	    let val tK = Type("fun",[tpq,Type("fun",[t1,tpq])])
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   100
		val PQ' = decre_bndVar(P $ Q)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   101
	    in 
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
   102
		include_min_comb:=true;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   103
		Const("COMBK",tK) $ PQ'
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   104
	    end)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   105
	else (
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   106
	      if nfreeP then (
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   107
			       let val Q' = lam2comb (Abs(x,t1,Q)) Bnds
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   108
				   val P' = decre_bndVar P
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   109
				   val tp = Term.type_of1(Bnds,P')
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   110
				   val tq' = Term.type_of1(Bnds, Q')
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   111
				   val tB = Type("fun",[tp,Type("fun",[tq',Type("fun",[t1,tpq])])])
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   112
			       in
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
   113
				   include_min_comb:=true;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   114
				   Const("COMBB",tB) $ P' $ Q' 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   115
			       end)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   116
	      else (
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   117
		    if nfreeQ then (
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   118
				    let val P' = lam2comb (Abs(x,t1,P)) Bnds
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   119
					val Q' = decre_bndVar Q
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   120
					val tq = Term.type_of1(Bnds,Q')
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   121
					val tp' = Term.type_of1(Bnds, P')
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   122
					val tC = Type("fun",[tp',Type("fun",[tq,Type("fun",[t1,tpq])])])
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   123
				    in
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
   124
					include_min_comb:=true;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   125
					Const("COMBC",tC) $ P' $ Q'
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   126
				    end)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   127
		    else(
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   128
			 let val P' = lam2comb (Abs(x,t1,P)) Bnds
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   129
			     val Q' = lam2comb (Abs(x,t1,Q)) Bnds
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   130
			     val tp' = Term.type_of1(Bnds,P')
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   131
			     val tq' = Term.type_of1(Bnds,Q')
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   132
			     val tS = Type("fun",[tp',Type("fun",[tq',Type("fun",[t1,tpq])])])
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   133
			 in
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
   134
			     include_min_comb:=true;
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
   135
			     include_combS:=true;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   136
			     Const("COMBS",tS) $ P' $ Q'
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   137
			 end)))
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   138
    end
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   139
  | lam2comb (t as (Abs(x,t1,_))) _ = raise LAM2COMB (t);
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   140
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   141
	     
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   142
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   143
(*********************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   144
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   145
fun to_comb (Abs(x,tp,b)) Bnds =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   146
    let val b' = to_comb b (tp::Bnds)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   147
    in lam2comb (Abs(x,tp,b')) Bnds end
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   148
  | to_comb (P $ Q) Bnds = ((to_comb P Bnds) $ (to_comb Q Bnds))
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   149
  | to_comb t _ = t;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   150
 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   151
    
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   152
fun comb_of t = to_comb t [];
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   153
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   154
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   155
(* print a term containing combinators, used for debugging *)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   156
exception TERM_COMB of term;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   157
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   158
fun string_of_term (Const(c,t)) = c
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   159
  | string_of_term (Free(v,t)) = v
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   160
  | string_of_term (Var((x,n),t)) =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   161
    let val xn = x ^ "_" ^ (string_of_int n)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   162
    in xn end
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   163
  | string_of_term (P $ Q) =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   164
    let val P' = string_of_term P
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   165
	val Q' = string_of_term Q
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   166
    in
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   167
	"(" ^ P' ^ " " ^ Q' ^ ")" end
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   168
  | string_of_term t =  raise TERM_COMB (t);
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   169
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   170
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   171
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   172
(******************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   173
(* data types for typed combinator expressions        *)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   174
(******************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   175
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   176
type axiom_name = string;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   177
datatype kind = Axiom | Conjecture;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   178
fun name_of_kind Axiom = "axiom"
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   179
  | name_of_kind Conjecture = "conjecture";
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   180
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   181
type polarity = bool;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   182
type indexname = Term.indexname;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   183
type clause_id = int;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   184
type csort = Term.sort;
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   185
type ctyp = ResClause.fol_type;
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   186
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   187
val string_of_ctyp = ResClause.string_of_fol_type;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   188
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   189
type ctyp_var = ResClause.typ_var;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   190
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   191
type ctype_literal = ResClause.type_literal;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   192
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   193
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   194
datatype combterm = CombConst of string * ctyp * ctyp list
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   195
		  | CombFree of string * ctyp
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   196
		  | CombVar of string * ctyp
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   197
		  | CombApp of combterm * combterm * ctyp
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   198
		  | Bool of combterm;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   199
datatype literal = Literal of polarity * combterm;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   200
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   201
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   202
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   203
datatype clause = 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   204
	 Clause of {clause_id: clause_id,
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   205
		    axiom_name: axiom_name,
19964
73704ba4bed1 added the "th" field to datatype Clause
paulson
parents: 19745
diff changeset
   206
		    th: thm,
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   207
		    kind: kind,
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   208
		    literals: literal list,
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   209
		    ctypes_sorts: (ctyp_var * csort) list, 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   210
                    ctvar_type_literals: ctype_literal list, 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   211
                    ctfree_type_literals: ctype_literal list};
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   212
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   213
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   214
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   215
fun string_of_kind (Clause cls) = name_of_kind (#kind cls);
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   216
fun get_axiomName (Clause cls) = #axiom_name cls;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   217
fun get_clause_id (Clause cls) = #clause_id cls;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   218
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   219
fun get_literals (c as Clause(cls)) = #literals cls;
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   220
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   221
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   222
(*********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   223
(* convert a clause with type Term.term to a clause with type clause *)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   224
(*********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   225
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   226
fun isFalse (Literal(pol,Bool(CombConst(c,_,_)))) =
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   227
    (pol andalso c = "c_False") orelse
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   228
    (not pol andalso c = "c_True")
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   229
  | isFalse _ = false;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   230
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   231
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   232
fun isTrue (Literal (pol,Bool(CombConst(c,_,_)))) =
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   233
      (pol andalso c = "c_True") orelse
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   234
      (not pol andalso c = "c_False")
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   235
  | isTrue _ = false;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   236
  
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   237
fun isTaut (Clause {literals,...}) = exists isTrue literals;  
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   238
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   239
fun type_of (Type (a, Ts)) =
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   240
    let val (folTypes,ts) = types_of Ts
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   241
	val t = ResClause.make_fixed_type_const a
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   242
    in
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   243
	(ResClause.mk_fol_type("Comp",t,folTypes),ts)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   244
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   245
  | type_of (tp as (TFree(a,s))) =
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   246
    let val t = ResClause.make_fixed_type_var a
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   247
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   248
	(ResClause.mk_fol_type("Fixed",t,[]),[ResClause.mk_typ_var_sort tp])
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   249
    end
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   250
  | type_of (tp as (TVar(v,s))) =
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   251
    let val t = ResClause.make_schematic_type_var v
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   252
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   253
	(ResClause.mk_fol_type("Var",t,[]),[ResClause.mk_typ_var_sort tp])
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   254
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   255
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   256
and types_of Ts =
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   257
    let val foltyps_ts = map type_of Ts
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   258
	val (folTyps,ts) = ListPair.unzip foltyps_ts
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   259
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   260
	(folTyps,ResClause.union_all ts)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   261
    end;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   262
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   263
(* same as above, but no gathering of sort information *)
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   264
fun simp_type_of (Type (a, Ts)) = 
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   265
    let val typs = map simp_type_of Ts
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   266
	val t = ResClause.make_fixed_type_const a
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   267
    in
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   268
	ResClause.mk_fol_type("Comp",t,typs)
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   269
    end
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   270
  | simp_type_of (TFree (a,s)) = ResClause.mk_fol_type("Fixed",ResClause.make_fixed_type_var a,[])
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   271
  | simp_type_of (TVar (v,s)) = ResClause.mk_fol_type("Var",ResClause.make_schematic_type_var v,[]);
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   272
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   273
fun comb_typ ("COMBI",t) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   274
    let val t' = domain_type t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   275
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   276
	[simp_type_of t']
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   277
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   278
  | comb_typ ("COMBK",t) = 
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   279
    let val a = domain_type t
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   280
	val b = domain_type (range_type t)
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   281
    in
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   282
	map simp_type_of [a,b]
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   283
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   284
  | comb_typ ("COMBS",t) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   285
    let val t' = domain_type t
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   286
	val a = domain_type t'
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   287
	val b = domain_type (range_type t')
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   288
	val c = range_type (range_type t')
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   289
    in 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   290
	map simp_type_of [a,b,c]
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   291
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   292
  | comb_typ ("COMBB",t) = 
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   293
    let val ab = domain_type t
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   294
	val ca = domain_type (range_type t)
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   295
	val a = domain_type ab
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   296
	val b = range_type ab
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   297
	val c = domain_type ca
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   298
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   299
	map simp_type_of [a,b,c]
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   300
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   301
  | comb_typ ("COMBC",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   302
    let val t1 = domain_type t
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   303
	val a = domain_type t1
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   304
	val b = domain_type (range_type t1)
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   305
	val c = range_type (range_type t1)
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   306
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   307
	map simp_type_of [a,b,c]
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   308
    end;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   309
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   310
fun const_type_of ("COMBI",t) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   311
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   312
	val I_var = comb_typ ("COMBI",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   313
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   314
	(tp,ts,I_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   315
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   316
  | const_type_of ("COMBK",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   317
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   318
	val K_var = comb_typ ("COMBK",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   319
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   320
	(tp,ts,K_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   321
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   322
  | const_type_of ("COMBS",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   323
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   324
	val S_var = comb_typ ("COMBS",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   325
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   326
	(tp,ts,S_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   327
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   328
  | const_type_of ("COMBB",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   329
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   330
	val B_var = comb_typ ("COMBB",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   331
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   332
	(tp,ts,B_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   333
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   334
  | const_type_of ("COMBC",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   335
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   336
	val C_var = comb_typ ("COMBC",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   337
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   338
	(tp,ts,C_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   339
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   340
  | const_type_of (c,t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   341
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   342
	val tvars = !const_typargs(c,t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   343
	val tvars' = map simp_type_of tvars
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   344
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   345
	(tp,ts,tvars')
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   346
    end;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   347
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   348
fun is_bool_type (Type("bool",[])) = true
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   349
  | is_bool_type _ = false;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   350
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   351
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   352
(* convert a Term.term (with combinators) into a combterm, also accummulate sort info *)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   353
fun combterm_of (Const(c,t)) =
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   354
    let val (tp,ts,tvar_list) = const_type_of (c,t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   355
	val is_bool = is_bool_type t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   356
	val c' = CombConst(ResClause.make_fixed_const c,tp,tvar_list)
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   357
	val c'' = if is_bool then Bool(c') else c'
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   358
    in
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   359
	(c'',ts)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   360
    end
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   361
  | combterm_of (Free(v,t)) =
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   362
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   363
	val is_bool = is_bool_type t
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   364
	val v' = if ResClause.isMeta v then CombVar(ResClause.make_schematic_var(v,0),tp)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   365
		 else CombFree(ResClause.make_fixed_var v,tp)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   366
	val v'' = if is_bool then Bool(v') else v'
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   367
    in
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   368
	(v'',ts)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   369
    end
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   370
  | combterm_of (Var(v,t)) =
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   371
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   372
	val is_bool = is_bool_type t
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   373
	val v' = CombVar(ResClause.make_schematic_var v,tp)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   374
	val v'' = if is_bool then Bool(v') else v'
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   375
    in
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   376
	(v'',ts)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   377
    end
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   378
  | combterm_of (t as (P $ Q)) =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   379
    let val (P',tsP) = combterm_of P
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   380
	val (Q',tsQ) = combterm_of Q
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   381
	val tp = Term.type_of t
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   382
	val tp' = simp_type_of tp
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   383
	val is_bool = is_bool_type tp
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   384
	val t' = CombApp(P',Q',tp')
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   385
	val t'' = if is_bool then Bool(t') else t'
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   386
    in
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   387
	(t'',tsP union tsQ)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   388
    end;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   389
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   390
fun predicate_of ((Const("Not",_) $ P), polarity) =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   391
    predicate_of (P, not polarity)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   392
  | predicate_of (term,polarity) = (combterm_of term,polarity);
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   393
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   394
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   395
fun literals_of_term1 args (Const("Trueprop",_) $ P) = literals_of_term1 args P
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   396
  | literals_of_term1 args (Const("op |",_) $ P $ Q) = 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   397
    let val args' = literals_of_term1 args P
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   398
    in
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   399
	literals_of_term1 args' Q
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   400
    end
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   401
  | literals_of_term1 (lits,ts) P =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   402
    let val ((pred,ts'),pol) = predicate_of (P,true)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   403
	val lits' = Literal(pol,pred)::lits
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   404
    in
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   405
	(lits',ts union ts')
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   406
    end;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   407
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   408
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   409
fun literals_of_term P = literals_of_term1 ([],[]) P;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   410
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   411
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   412
(* making axiom and conjecture clauses *)
20016
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   413
fun make_clause(clause_id,axiom_name,kind,thm) =
19444
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   414
    let val term = prop_of thm
20016
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   415
	val term' = comb_of term
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   416
	val (lits,ctypes_sorts) = literals_of_term term'
18856
4669dec681f4 tidy-up of res_clause.ML, removing the "predicates" field
paulson
parents: 18725
diff changeset
   417
	val (ctvar_lits,ctfree_lits) = ResClause.add_typs_aux ctypes_sorts
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   418
    in
20016
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   419
	if forall isFalse lits
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   420
	then error "Problem too trivial for resolution (empty clause)"
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   421
	else
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   422
	    Clause {clause_id = clause_id, axiom_name = axiom_name, th = thm, kind = kind,
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   423
		    literals = lits, ctypes_sorts = ctypes_sorts, 
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   424
		    ctvar_type_literals = ctvar_lits,
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   425
		    ctfree_type_literals = ctfree_lits}
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   426
    end;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   427
20016
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   428
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   429
fun make_axiom_clause thm (ax_name,cls_id) = make_clause(cls_id,ax_name,Axiom,thm);
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   430
 
19444
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   431
fun make_axiom_clauses [] = []
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   432
  | make_axiom_clauses ((thm,(name,id))::thms) =
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   433
    let val cls = make_axiom_clause thm (name,id)
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   434
	val clss = make_axiom_clauses thms
19354
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   435
    in
20022
b07a138b4e7d some tidying; fixed the output of theorem names
paulson
parents: 20016
diff changeset
   436
	if isTaut cls then clss else (name,cls)::clss
19354
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   437
    end;
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   438
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   439
20016
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   440
fun make_conjecture_clause n thm = make_clause(n,"Conjecture",Conjecture,thm);
9a005f7d95e6 Literals aren't sorted any more.
mengj
parents: 19964
diff changeset
   441
 
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   442
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   443
fun make_conjecture_clauses_aux _ [] = []
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   444
  | make_conjecture_clauses_aux n (t::ts) =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   445
    make_conjecture_clause n t :: make_conjecture_clauses_aux (n+1) ts;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   446
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   447
val make_conjecture_clauses = make_conjecture_clauses_aux 0;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   448
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   449
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   450
(**********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   451
(* convert clause into ATP specific formats:                          *)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   452
(* TPTP used by Vampire and E                                         *)
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   453
(* DFG used by SPASS                                                  *)
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   454
(**********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   455
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   456
val type_wrapper = "typeinfo";
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   457
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   458
datatype type_level = T_FULL | T_PARTIAL | T_CONST | T_NONE;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   459
19745
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   460
val typ_level = ref T_CONST;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   461
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   462
fun full_types () = (typ_level:=T_FULL);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   463
fun partial_types () = (typ_level:=T_PARTIAL);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   464
fun const_types_only () = (typ_level:=T_CONST);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   465
fun no_types () = (typ_level:=T_NONE);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   466
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   467
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   468
fun find_typ_level () = !typ_level;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   469
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   470
fun wrap_type (c,t) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   471
    case !typ_level of T_FULL => type_wrapper ^ (ResClause.paren_pack [c,t])
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   472
		     | _ => c;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   473
    
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   474
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   475
val bool_tp = ResClause.make_fixed_type_const "bool";
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   476
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   477
val app_str = "hAPP";
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   478
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   479
val bool_str = "hBOOL";
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   480
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   481
exception STRING_OF_COMBTERM of int;
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   482
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   483
(* convert literals of clauses into strings *)
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   484
fun string_of_combterm1_aux _ (CombConst(c,tp,_)) = 
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   485
    let val tp' = string_of_ctyp tp
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   486
	val c' = if c = "equal" then "fequal" else c
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   487
    in
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   488
	(wrap_type (c',tp'),tp')
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   489
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   490
  | string_of_combterm1_aux _ (CombFree(v,tp)) = 
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   491
    let val tp' = string_of_ctyp tp
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   492
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   493
	(wrap_type (v,tp'),tp')
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   494
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   495
  | string_of_combterm1_aux _ (CombVar(v,tp)) = 
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   496
    let val tp' = string_of_ctyp tp
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   497
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   498
	(wrap_type (v,tp'),tp')
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   499
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   500
  | string_of_combterm1_aux is_pred (CombApp(t1,t2,tp)) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   501
    let val (s1,tp1) = string_of_combterm1_aux is_pred t1
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   502
	val (s2,tp2) = string_of_combterm1_aux is_pred t2
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   503
	val tp' = ResClause.string_of_fol_type tp
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   504
	val r =	case !typ_level of T_FULL => type_wrapper ^  (ResClause.paren_pack [(app_str ^ (ResClause.paren_pack [s1,s2])),tp'])
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   505
				 | T_PARTIAL => app_str ^ (ResClause.paren_pack [s1,s2,tp1])
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   506
				 | T_NONE => app_str ^ (ResClause.paren_pack [s1,s2])
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   507
				 | T_CONST => raise STRING_OF_COMBTERM (1) (*should not happen, if happened may be a bug*)
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   508
    in	(r,tp')
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   509
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   510
    end
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   511
  | string_of_combterm1_aux is_pred (Bool(CombApp(CombApp(CombConst("equal",tp,tps),t1,tp1),t2,tp2))) =
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   512
    if is_pred then 
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   513
	let val (s1,_) = string_of_combterm1_aux false t1
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   514
	    val (s2,_) = string_of_combterm1_aux false t2
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   515
	in
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   516
	    ("equal" ^ (ResClause.paren_pack [s1,s2]),bool_tp)
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   517
	end
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   518
    else
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   519
	let val (t,_) = string_of_combterm1_aux false (CombApp(CombApp(CombConst("equal",tp,tps),t1,tp1),t2,tp2))
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   520
	in
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   521
	    (t,bool_tp)
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   522
	end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   523
  | string_of_combterm1_aux is_pred (Bool(t)) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   524
    let val (t',_) = string_of_combterm1_aux false t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   525
	val r = if is_pred then bool_str ^ (ResClause.paren_pack [t'])
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   526
		else t'
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   527
    in
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   528
	(r,bool_tp)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   529
    end;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   530
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   531
fun string_of_combterm1 is_pred term = fst (string_of_combterm1_aux is_pred term);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   532
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   533
fun string_of_combterm2 _ (CombConst(c,tp,tvars)) = 
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   534
    let val tvars' = map string_of_ctyp tvars
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   535
	val c' = if c = "equal" then "fequal" else c
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   536
    in
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   537
	c' ^ (ResClause.paren_pack tvars')
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   538
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   539
  | string_of_combterm2 _ (CombFree(v,tp)) = v
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   540
  | string_of_combterm2 _ (CombVar(v,tp)) = v
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   541
  | string_of_combterm2 is_pred (CombApp(t1,t2,tp)) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   542
    let val s1 = string_of_combterm2 is_pred t1
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   543
	val s2 = string_of_combterm2 is_pred t2
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   544
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   545
	app_str ^ (ResClause.paren_pack [s1,s2])
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   546
    end
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   547
  | string_of_combterm2 is_pred (Bool(CombApp(CombApp(CombConst("equal",tp,tps),t1,tp1),t2,tp2))) =
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   548
    if is_pred then 
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   549
	let val s1 = string_of_combterm2 false t1
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   550
	    val s2 = string_of_combterm2 false t2
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   551
	in
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   552
	    ("equal" ^ (ResClause.paren_pack [s1,s2]))
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   553
	end
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   554
    else
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   555
	string_of_combterm2 false (CombApp(CombApp(CombConst("equal",tp,tps),t1,tp1),t2,tp2))
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   556
 
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   557
  | string_of_combterm2 is_pred (Bool(t)) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   558
    let val t' = string_of_combterm2 false t
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   559
    in
18200
9d476d1054d7 -- terms are fully typed.
mengj
parents: 17998
diff changeset
   560
	if is_pred then bool_str ^ (ResClause.paren_pack [t'])
9d476d1054d7 -- terms are fully typed.
mengj
parents: 17998
diff changeset
   561
	else t'
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   562
    end;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   563
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   564
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   565
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   566
fun string_of_combterm is_pred term = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   567
    case !typ_level of T_CONST => string_of_combterm2 is_pred term
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   568
		     | _ => string_of_combterm1 is_pred term;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   569
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   570
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   571
fun string_of_clausename (cls_id,ax_name) = 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   572
    ResClause.clause_prefix ^ ResClause.ascii_of ax_name ^ "_" ^ Int.toString cls_id;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   573
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   574
fun string_of_type_clsname (cls_id,ax_name,idx) = 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   575
    string_of_clausename (cls_id,ax_name) ^ "_tcs" ^ (Int.toString idx);
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   576
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   577
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   578
(* tptp format *)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   579
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   580
fun tptp_literal (Literal(pol,pred)) =
18200
9d476d1054d7 -- terms are fully typed.
mengj
parents: 17998
diff changeset
   581
    let val pred_string = string_of_combterm true pred
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   582
	val pol_str = if pol then "++" else "--"
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   583
    in
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   584
	pol_str ^ pred_string
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   585
    end;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   586
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   587
 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   588
fun tptp_type_lits (Clause cls) = 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   589
    let val lits = map tptp_literal (#literals cls)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   590
	val ctvar_lits_strs =
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   591
	    case !typ_level of T_NONE => []
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   592
			     | _ => (map ResClause.tptp_of_typeLit (#ctvar_type_literals cls)) 
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   593
	val ctfree_lits = 
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   594
	    case !typ_level of T_NONE => []
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   595
			     | _ => (map ResClause.tptp_of_typeLit (#ctfree_type_literals cls)) 
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   596
    in
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   597
	(ctvar_lits_strs @ lits, ctfree_lits)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   598
    end; 
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   599
    
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   600
    
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   601
fun clause2tptp cls =
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   602
    let val (lits,ctfree_lits) = tptp_type_lits cls
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   603
	val cls_id = get_clause_id cls
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   604
	val ax_name = get_axiomName cls
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   605
	val knd = string_of_kind cls
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   606
	val lits_str = ResClause.bracket_pack lits
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   607
	val cls_str = ResClause.gen_tptp_cls(cls_id,ax_name,knd,lits_str)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   608
    in
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   609
	(cls_str,ctfree_lits)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   610
    end;
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   611
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   612
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   613
(* dfg format *)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   614
fun dfg_literal (Literal(pol,pred)) = ResClause.dfg_sign pol (string_of_combterm true pred);
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   615
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   616
fun dfg_clause_aux (Clause{literals, ctypes_sorts, ...}) = 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   617
  let val lits = map dfg_literal literals
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   618
      val (tvar_lits,tfree_lits) = ResClause.add_typs_aux ctypes_sorts
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   619
      val tvar_lits_strs = 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   620
	  case !typ_level of T_NONE => [] 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   621
			    | _ => map ResClause.dfg_of_typeLit tvar_lits
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   622
      val tfree_lits =
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   623
          case !typ_level of T_NONE => []
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   624
			    | _ => map ResClause.dfg_of_typeLit tfree_lits 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   625
  in
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   626
      (tvar_lits_strs @ lits, tfree_lits)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   627
  end; 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   628
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   629
fun get_uvars (CombConst(_,_,_)) vars = vars
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   630
  | get_uvars (CombFree(_,_)) vars = vars
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   631
  | get_uvars (CombVar(v,tp)) vars = (v::vars)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   632
  | get_uvars (CombApp(P,Q,tp)) vars = get_uvars P (get_uvars Q vars)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   633
  | get_uvars (Bool(c)) vars = get_uvars c vars;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   634
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   635
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   636
fun get_uvars_l (Literal(_,c)) = get_uvars c [];
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   637
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   638
fun dfg_vars (Clause {literals,...}) = ResClause.union_all (map get_uvars_l literals);
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   639
 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   640
fun clause2dfg (cls as Clause{axiom_name,clause_id,kind,ctypes_sorts,...}) =
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   641
    let val (lits,tfree_lits) = dfg_clause_aux cls 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   642
        val vars = dfg_vars cls
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   643
        val tvars = ResClause.get_tvar_strs ctypes_sorts
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   644
	val knd = name_of_kind kind
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   645
	val lits_str = commas lits
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   646
	val cls_str = ResClause.gen_dfg_cls(clause_id, axiom_name, knd, lits_str, tvars@vars) 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   647
    in (cls_str, tfree_lits) end;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   648
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   649
19725
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   650
fun init_combs (comb,funcs) =
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   651
    case !typ_level of T_CONST => 
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   652
		       (case comb of "c_COMBK" => Symtab.update (comb,2) funcs
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   653
				   | "c_COMBS" => Symtab.update (comb,3) funcs
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   654
				   | "c_COMBI" => Symtab.update (comb,1) funcs
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   655
				   | "c_COMBB" => Symtab.update (comb,3) funcs
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   656
				   | "c_COMBC" => Symtab.update (comb,3) funcs
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   657
				   | _ => funcs)
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   658
		     | _ => Symtab.update (comb,0) funcs;
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   659
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   660
fun init_funcs_tab funcs = 
19724
20d76a40e362 Fixed a bug.
mengj
parents: 19720
diff changeset
   661
    let val tp = !typ_level
19725
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   662
	val funcs0 = foldl init_combs funcs ["c_COMBK","c_COMBS","c_COMBI","c_COMBB","c_COMBC"]
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   663
	val funcs1 = case tp of T_PARTIAL => Symtab.update ("hAPP",3) funcs0
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   664
				      | _ => Symtab.update ("hAPP",2) funcs0
19724
20d76a40e362 Fixed a bug.
mengj
parents: 19720
diff changeset
   665
	val funcs2 = case tp of T_FULL => Symtab.update ("typeinfo",2) funcs1
20d76a40e362 Fixed a bug.
mengj
parents: 19720
diff changeset
   666
				      | _ => funcs1
20d76a40e362 Fixed a bug.
mengj
parents: 19720
diff changeset
   667
    in
20d76a40e362 Fixed a bug.
mengj
parents: 19720
diff changeset
   668
	case tp of T_CONST => Symtab.update ("fequal",1) (Symtab.update ("hEXTENT",2) funcs2)
20d76a40e362 Fixed a bug.
mengj
parents: 19720
diff changeset
   669
			 | _ => Symtab.update ("fequal",0) (Symtab.update ("hEXTENT",0) funcs2)
20d76a40e362 Fixed a bug.
mengj
parents: 19720
diff changeset
   670
    end;
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   671
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   672
19725
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   673
fun add_funcs (CombConst(c,_,tvars),funcs) =
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   674
    if c = "equal" then foldl ResClause.add_foltype_funcs funcs tvars
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   675
    else
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   676
	(case !typ_level of T_CONST => foldl ResClause.add_foltype_funcs (Symtab.update(c,length tvars) funcs) tvars
ada9bb1faba5 Changed the DFG format's functions' declaration procedure.
mengj
parents: 19724
diff changeset
   677
			  | _ => foldl ResClause.add_foltype_funcs (Symtab.update(c,0) funcs) tvars)
19724
20d76a40e362 Fixed a bug.
mengj
parents: 19720
diff changeset
   678
  | add_funcs (CombFree(v,ctp),funcs) = ResClause.add_foltype_funcs (ctp,Symtab.update (v,0) funcs) 
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   679
  | add_funcs (CombVar(_,ctp),funcs) = ResClause.add_foltype_funcs (ctp,funcs)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   680
  | add_funcs (CombApp(P,Q,_),funcs) = add_funcs(P,add_funcs (Q,funcs))
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   681
  | add_funcs (Bool(t),funcs) = add_funcs (t,funcs);
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   682
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   683
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   684
fun add_literal_funcs (Literal(_,c), funcs) = add_funcs (c,funcs);
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   685
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   686
fun add_clause_funcs (Clause {literals, ...}, funcs) =
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   687
    foldl add_literal_funcs funcs literals
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   688
    handle Symtab.DUP a => raise ERROR ("function " ^ a ^ " has multiple arities")
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   689
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   690
fun funcs_of_clauses clauses arity_clauses =
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   691
    Symtab.dest (foldl ResClause.add_arityClause_funcs 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   692
                       (foldl add_clause_funcs (init_funcs_tab Symtab.empty) clauses)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   693
                       arity_clauses)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   694
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   695
fun preds_of clsrel_clauses arity_clauses = 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   696
    Symtab.dest
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   697
	(foldl ResClause.add_classrelClause_preds 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   698
	       (foldl ResClause.add_arityClause_preds
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   699
		      (Symtab.update ("hBOOL",1) Symtab.empty)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   700
		      arity_clauses)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   701
	       clsrel_clauses)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   702
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   703
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   704
(**********************************************************************)
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   705
(* write clauses to files                                             *)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   706
(**********************************************************************)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   707
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   708
(* tptp format *)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   709
19491
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   710
fun read_in fs = map (File.read o File.unpack_platform_path) fs; 
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   711
19491
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   712
fun get_helper_clauses_tptp () =
19745
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   713
  let val tlevel = case !typ_level of 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   714
		       T_FULL => (Output.debug "Fully-typed HOL"; 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   715
				  "~~/src/HOL/Tools/atp-inputs/full_")
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   716
		     | T_PARTIAL => (Output.debug "Partially-typed HOL"; 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   717
				     "~~/src/HOL/Tools/atp-inputs/par_")
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   718
		     | T_CONST => (Output.debug "Const-only-typed HOL"; 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   719
				   "~~/src/HOL/Tools/atp-inputs/const_")
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   720
		     | T_NONE => (Output.debug "Untyped HOL"; 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   721
				  "~~/src/HOL/Tools/atp-inputs/u_")
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   722
      val helpers = if !include_combS 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   723
                    then (Output.debug "Include combinator S"; 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   724
                          ["helper1.tptp","comb_inclS.tptp"]) 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   725
                    else if !include_min_comb 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   726
                    then (Output.debug "Include min combinators"; 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   727
                          ["helper1.tptp","comb_noS.tptp"])
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   728
		    else (Output.debug "No combinator is used"; ["helper1.tptp"])
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   729
      val t_helpers = map (curry (op ^) tlevel) helpers
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   730
  in
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   731
      read_in t_helpers
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   732
  end;
19491
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   733
	
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   734
						  
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   735
(* write TPTP format to a single file *)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   736
(* when "get_helper_clauses" is called, "include_combS" and "include_min_comb" should have correct values already *)
19491
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   737
fun tptp_write_file thms filename (axclauses,classrel_clauses,arity_clauses) =
19444
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   738
    let val clss = make_conjecture_clauses thms
20022
b07a138b4e7d some tidying; fixed the output of theorem names
paulson
parents: 20016
diff changeset
   739
        val (clnames,axclauses') = ListPair.unzip (make_axiom_clauses axclauses)
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   740
	val (tptp_clss,tfree_litss) = ListPair.unzip (map clause2tptp clss)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   741
	val tfree_clss = map ResClause.tptp_tfree_clause (foldl (op union_string) [] tfree_litss)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   742
	val out = TextIO.openOut filename
19491
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   743
	val helper_clauses = get_helper_clauses_tptp ()
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   744
    in
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   745
	List.app (curry TextIO.output out o #1 o clause2tptp) axclauses';
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   746
	ResClause.writeln_strs out tfree_clss;
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   747
	ResClause.writeln_strs out tptp_clss;
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   748
	List.app (curry TextIO.output out o ResClause.tptp_classrelClause) classrel_clauses;
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   749
	List.app (curry TextIO.output out o ResClause.tptp_arity_clause) arity_clauses;
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   750
	List.app (curry TextIO.output out) helper_clauses;
20022
b07a138b4e7d some tidying; fixed the output of theorem names
paulson
parents: 20016
diff changeset
   751
	TextIO.closeOut out;
b07a138b4e7d some tidying; fixed the output of theorem names
paulson
parents: 20016
diff changeset
   752
	clnames
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   753
    end;
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   754
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   755
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   756
(* dfg format *)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   757
fun get_helper_clauses_dfg () = 
19745
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   758
 let val tlevel = case !typ_level of 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   759
                      T_FULL => (Output.debug "Fully-typed HOL"; 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   760
                                 "~~/src/HOL/Tools/atp-inputs/full_")
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   761
		    | T_PARTIAL => (Output.debug "Partially-typed HOL"; 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   762
		                    "~~/src/HOL/Tools/atp-inputs/par_")
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   763
		    | T_CONST => (Output.debug "Const-only-typed HOL"; 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   764
		                  "~~/src/HOL/Tools/atp-inputs/const_")
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   765
		    | T_NONE => (Output.debug "Untyped HOL"; 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   766
		                 "~~/src/HOL/Tools/atp-inputs/u_")
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   767
     val helpers = if !include_combS 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   768
                   then (Output.debug "Include combinator S"; 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   769
                         ["helper1.dfg","comb_inclS.dfg"]) else
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   770
		   if !include_min_comb 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   771
		   then (Output.debug "Include min combinators"; 
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   772
		         ["helper1.dfg","comb_noS.dfg"])
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   773
		   else (Output.debug "No combinator is used"; ["helper1.dfg"])
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   774
     val t_helpers = map (curry (op ^) tlevel) helpers
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   775
 in
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   776
     read_in t_helpers
df6fd56d63a9 warnings to debug outputs; default translation to const-typed
paulson
parents: 19725
diff changeset
   777
 end;
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   778
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   779
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   780
fun dfg_write_file  thms filename (axclauses,classrel_clauses,arity_clauses) =
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   781
    let val _ = Output.debug ("Preparing to write the DFG file " ^ filename) 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   782
	val conjectures = make_conjecture_clauses thms
20022
b07a138b4e7d some tidying; fixed the output of theorem names
paulson
parents: 20016
diff changeset
   783
        val (clnames,axclauses') = ListPair.unzip (make_axiom_clauses axclauses)
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   784
	val (dfg_clss,tfree_litss) = ListPair.unzip (map clause2dfg conjectures)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   785
	val clss = conjectures @ axclauses'
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   786
	val funcs = funcs_of_clauses clss arity_clauses
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   787
	and preds = preds_of classrel_clauses arity_clauses
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   788
	and probname = Path.pack (Path.base (Path.unpack filename))
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   789
	val (axstrs,_) =  ListPair.unzip (map clause2dfg axclauses')
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   790
	val tfree_clss = map ResClause.dfg_tfree_clause (ResClause.union_all tfree_litss)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   791
	val out = TextIO.openOut filename
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   792
	val helper_clauses = get_helper_clauses_dfg ()
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   793
    in
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   794
	TextIO.output (out, ResClause.string_of_start probname); 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   795
	TextIO.output (out, ResClause.string_of_descrip probname); 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   796
	TextIO.output (out, ResClause.string_of_symbols (ResClause.string_of_funcs funcs) (ResClause.string_of_preds preds)); 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   797
	TextIO.output (out, "list_of_clauses(axioms,cnf).\n");
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   798
	ResClause.writeln_strs out axstrs;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   799
	List.app (curry TextIO.output out o ResClause.dfg_classrelClause) classrel_clauses;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   800
	List.app (curry TextIO.output out o ResClause.dfg_arity_clause) arity_clauses;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   801
	ResClause.writeln_strs out helper_clauses;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   802
	TextIO.output (out, "end_of_list.\n\nlist_of_clauses(conjectures,cnf).\n");
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   803
	ResClause.writeln_strs out tfree_clss;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   804
	ResClause.writeln_strs out dfg_clss;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   805
	TextIO.output (out, "end_of_list.\n\nend_problem.\n");
20022
b07a138b4e7d some tidying; fixed the output of theorem names
paulson
parents: 20016
diff changeset
   806
	TextIO.closeOut out;
b07a138b4e7d some tidying; fixed the output of theorem names
paulson
parents: 20016
diff changeset
   807
	clnames
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   808
    end;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   809
17998
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   810
end