src/HOL/Tools/res_hol_clause.ML
author mengj
Thu, 25 May 2006 08:09:10 +0200
changeset 19720 f68f6f958a1d
parent 19491 cd6c71c57f53
child 19724 20d76a40e362
permissions -rw-r--r--
HOL problems now have DFG output format.
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
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    18
fun init thy = (include_combS:=false;include_min_comb:=false;const_typargs := Sign.const_typargs thy);
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
    19
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
    20
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
    21
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
    22
(**********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
(* 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
    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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
    27
  | 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
    28
  | 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
    29
  | 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
    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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
    33
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
    35
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
    37
  | 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
    38
  | 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
    39
    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
    40
	    | 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
    41
	    | 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
    42
	    | 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
    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
(*******************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
    47
    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
    48
    in 
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    49
	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
    50
	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
    51
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    52
  | lam2comb (Abs(x,tp,Bound n)) Bnds = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    53
    let val (Bound n') = decre_bndVar (Bound n)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    54
	val tb = List.nth(Bnds,n')
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    55
	val tK = Type("fun",[tb,Type("fun",[tp,tb])])
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    56
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    57
	include_min_comb:=true;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    58
	Const("COMBK",tK) $ (Bound n')
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
    59
    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
    60
  | 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
    61
    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
    62
    in 
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    63
	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
    64
	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
    65
    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
    66
  | 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
    67
    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
    68
    in
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    69
	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
    70
	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
    71
    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
    72
  | 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
    73
    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
    74
    in
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    75
	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
    76
	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
    77
    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
    78
  | 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
    79
    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
    80
	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
    81
    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
    82
	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
    83
	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
    84
	      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
    85
		  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
    86
		  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
    87
		  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
    88
	      in
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    89
		  include_min_comb:=true;
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
    90
		  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
    91
		  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
    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
    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
    94
	    
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
  | 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
    96
    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
    97
	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
    98
    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
    99
	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
   100
	    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
   101
		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
   102
	    in 
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
   103
		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
   104
		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
   105
	    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
   106
	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
   107
	      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
   108
			       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
   109
				   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
   110
				   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
   111
				   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
   112
				   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
   113
			       in
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
   114
				   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
   115
				   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
   116
			       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
   117
	      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
   118
		    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
   119
				    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
   120
					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
   121
					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
   122
					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
   123
					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
   124
				    in
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
   125
					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
   126
					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
   127
				    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
   128
		    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
   129
			 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
   130
			     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
   131
			     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
   132
			     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
   133
			     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
   134
			 in
18276
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
   135
			     include_min_comb:=true;
c62ec94e326e Added flags for setting and detecting whether a problem needs combinators.
mengj
parents: 18200
diff changeset
   136
			     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
   137
			     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
   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
    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
   140
  | 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
   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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   147
    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
   148
    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
   149
  | 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
   150
  | 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
   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
    
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
(* 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
   157
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
   158
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   160
  | 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
   161
  | 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
   162
    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
   163
    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
   164
  | 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
   165
    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
   166
	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
   167
    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
   168
	"(" ^ 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
   169
  | 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
   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
(******************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
(* 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
   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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   178
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
   179
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
   180
  | 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
   181
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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 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
   183
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
   184
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
   185
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
   186
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
   187
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   188
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
   189
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   191
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   193
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   194
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   195
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
   196
		  | 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
   197
		  | 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
   198
		  | CombApp of combterm * combterm * ctyp
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   199
		  | 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
   200
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
   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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   205
	 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
   206
		    axiom_name: axiom_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
   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
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   223
exception TERM_ORD of string
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   224
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   225
fun term_ord (CombVar(_,_),CombVar(_,_)) = EQUAL
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   226
  | term_ord (CombVar(_,_),_) = LESS
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   227
  | term_ord (CombFree(_,_),CombVar(_,_)) = GREATER
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   228
  | term_ord (CombFree(f1,tp1),CombFree(f2,tp2)) = 
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   229
    let val ord1 = string_ord(f1,f2)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   230
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   231
	case ord1 of EQUAL => ResClause.types_ord ([tp1],[tp2])
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   232
		   | _ => ord1
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   233
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   234
  | term_ord (CombFree(_,_),_) = LESS
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   235
  | term_ord (CombConst(_,_,_),CombVar(_,_)) = GREATER
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   236
  | term_ord (CombConst(_,_,_),CombFree(_,_)) = GREATER
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   237
  | term_ord (CombConst(c1,tp1,_),CombConst(c2,tp2,_)) = 
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   238
    let val ord1 = string_ord (c1,c2)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   239
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   240
	case ord1 of EQUAL => ResClause.types_ord ([tp1],[tp2])
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   241
		   | _ => ord1
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   242
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   243
  | term_ord (CombConst(_,_,_),_) = LESS
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   244
  | term_ord (CombApp(_,_,_),Bool(_)) = raise TERM_ORD("bool")
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   245
  | term_ord (CombApp(f1,arg1,tp1),CombApp(f2,arg2,tp2)) =
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 ord1 = term_ord (f1,f2)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   247
	val ord2 = case ord1 of EQUAL => term_ord (arg1,arg2)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   248
			      | _ => ord1
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   249
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   250
	case ord2 of EQUAL => ResClause.types_ord ([tp1],[tp2])
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   251
		   | _ => ord2
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   252
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   253
  | term_ord (CombApp(_,_,_),_) = GREATER
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   254
  | term_ord (Bool(_),_) = raise TERM_ORD("bool");
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   255
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   256
fun predicate_ord (Bool(t1),Bool(t2)) = term_ord (t1,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
   257
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   258
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   259
fun literal_ord (Literal(false,_),Literal(true,_)) = LESS
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   260
  | literal_ord (Literal(true,_),Literal(false,_)) = GREATER
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   261
  | literal_ord (Literal(_,pred1),Literal(_,pred2)) = predicate_ord(pred1,pred2);
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   262
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   263
fun sort_lits lits = sort literal_ord 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
   264
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   265
(*********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
(* 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
   267
(*********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   268
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   269
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
   270
    (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
   271
    (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
   272
  | 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
   273
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   274
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   275
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
   276
      (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
   277
      (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
   278
  | 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
   279
  
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   280
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
   281
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   282
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   283
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   284
fun make_clause(clause_id,axiom_name,kind,literals,ctypes_sorts,ctvar_type_literals,ctfree_type_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
   285
    if forall isFalse 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
   286
    then error "Problem too trivial for resolution (empty 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
   287
    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
   288
	Clause {clause_id = clause_id, axiom_name = axiom_name, 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
   289
		literals = literals, ctypes_sorts = ctypes_sorts, 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   290
		ctvar_type_literals = ctvar_type_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
   291
		ctfree_type_literals = ctfree_type_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
   292
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   293
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
   294
    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
   295
	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
   296
    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
   297
	(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
   298
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   299
  | 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
   300
    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
   301
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   302
	(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
   303
    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
   304
  | 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
   305
    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
   306
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   307
	(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
   308
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   309
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   310
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
   311
    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
   312
	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
   313
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   314
	(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
   315
    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
   316
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   317
(* 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
   318
fun simp_type_of (Type (a, Ts)) = 
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   319
    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
   320
	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
   321
    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
   322
	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
   323
    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
   324
  | 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
   325
  | 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
   326
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   327
fun comb_typ ("COMBI",t) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   328
    let val t' = domain_type t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   329
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   330
	[simp_type_of t']
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   331
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   332
  | comb_typ ("COMBK",t) = 
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   333
    let val a = domain_type t
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   334
	val b = domain_type (range_type t)
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   335
    in
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   336
	map simp_type_of [a,b]
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   337
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   338
  | comb_typ ("COMBS",t) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   339
    let val t' = domain_type t
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   340
	val a = domain_type t'
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   341
	val b = domain_type (range_type t')
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   342
	val c = range_type (range_type t')
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   343
    in 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   344
	map simp_type_of [a,b,c]
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   345
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   346
  | comb_typ ("COMBB",t) = 
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   347
    let val ab = domain_type t
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   348
	val ca = domain_type (range_type t)
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   349
	val a = domain_type ab
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   350
	val b = range_type ab
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   351
	val c = domain_type ca
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   352
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   353
	map simp_type_of [a,b,c]
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   354
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   355
  | comb_typ ("COMBC",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   356
    let val t1 = domain_type t
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   357
	val a = domain_type t1
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   358
	val b = domain_type (range_type t1)
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   359
	val c = range_type (range_type t1)
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   360
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   361
	map simp_type_of [a,b,c]
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   362
    end;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   363
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   364
fun const_type_of ("COMBI",t) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   365
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   366
	val I_var = comb_typ ("COMBI",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   367
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   368
	(tp,ts,I_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   369
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   370
  | const_type_of ("COMBK",t) =
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 K_var = comb_typ ("COMBK",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   373
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   374
	(tp,ts,K_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   375
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   376
  | const_type_of ("COMBS",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   377
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   378
	val S_var = comb_typ ("COMBS",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   379
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   380
	(tp,ts,S_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   381
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   382
  | const_type_of ("COMBB",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   383
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   384
	val B_var = comb_typ ("COMBB",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   385
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   386
	(tp,ts,B_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   387
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   388
  | const_type_of ("COMBC",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   389
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   390
	val C_var = comb_typ ("COMBC",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   391
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   392
	(tp,ts,C_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   393
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   394
  | const_type_of (c,t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   395
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   396
	val tvars = !const_typargs(c,t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   397
	val tvars' = map simp_type_of tvars
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   398
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   399
	(tp,ts,tvars')
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   400
    end;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   401
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   402
fun is_bool_type (Type("bool",[])) = true
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   403
  | 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
   404
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
(* 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
   407
fun combterm_of (Const(c,t)) =
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   408
    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
   409
	val is_bool = is_bool_type t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   410
	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
   411
	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
   412
    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
   413
	(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
   414
    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
   415
  | combterm_of (Free(v,t)) =
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   416
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   417
	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
   418
	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
   419
		 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
   420
	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
   421
    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
   422
	(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
   423
    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
   424
  | combterm_of (Var(v,t)) =
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   425
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   426
	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
   427
	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
   428
	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
   429
    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
   430
	(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
   431
    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
   432
  | 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
   433
    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
   434
	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
   435
	val tp = Term.type_of t
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   436
	val tp' = simp_type_of tp
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   437
	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
   438
	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
   439
	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
   440
    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
   441
	(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
   442
    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
   443
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   445
    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
   446
  | 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
   447
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   450
  | 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
   451
    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
   452
    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
   453
	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
   454
    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
   455
  | 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
   456
    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
   457
	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
   458
    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
   459
	(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
   460
    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
   461
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   462
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   463
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
   464
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   465
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   466
(* making axiom and conjecture clauses *)
19444
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   467
fun make_axiom_clause thm (ax_name,cls_id) =
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   468
    let val term = prop_of thm
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   469
	val term' = comb_of term
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
   470
	val (lits,ctypes_sorts) = literals_of_term term'
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   471
	val lits' = sort_lits lits
18856
4669dec681f4 tidy-up of res_clause.ML, removing the "predicates" field
paulson
parents: 18725
diff changeset
   472
	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
   473
    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
   474
	make_clause(cls_id,ax_name,Axiom,
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   475
		    lits',ctypes_sorts,ctvar_lits,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
   476
    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
   477
19444
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   478
fun make_axiom_clauses [] = []
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   479
  | 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
   480
    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
   481
	val clss = make_axiom_clauses thms
19354
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   482
    in
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   483
	if isTaut cls then clss else (cls::clss)
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   484
    end;
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   485
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   486
19444
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   487
fun make_conjecture_clause n thm =
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   488
    let val t = prop_of thm
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   489
	val t' = comb_of 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
   490
	val (lits,ctypes_sorts) = literals_of_term t'
18856
4669dec681f4 tidy-up of res_clause.ML, removing the "predicates" field
paulson
parents: 18725
diff changeset
   491
	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
   492
    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
   493
	make_clause(n,"conjecture",Conjecture,lits,ctypes_sorts,ctvar_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
   494
    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
   495
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   496
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   497
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   498
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
   499
  | 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
   500
    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
   501
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   502
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
   503
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   504
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   505
(**********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   506
(* 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
   507
(* TPTP used by Vampire and E                                         *)
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   508
(* 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
   509
(**********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   510
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   511
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
   512
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   513
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
   514
19130
b23479b80828 Default type level is T_FULL now.
mengj
parents: 18856
diff changeset
   515
val typ_level = ref T_FULL;
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
   516
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   517
fun full_types () = (typ_level:=T_FULL);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   518
fun partial_types () = (typ_level:=T_PARTIAL);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   519
fun const_types_only () = (typ_level:=T_CONST);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   520
fun no_types () = (typ_level:=T_NONE);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   521
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   522
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   523
fun find_typ_level () = !typ_level;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   524
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   525
fun wrap_type (c,t) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   526
    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
   527
		     | _ => c;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   528
    
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
   529
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   530
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
   531
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   532
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
   533
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   534
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
   535
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   536
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
   537
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   538
(* 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
   539
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
   540
    let val tp' = string_of_ctyp tp
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   541
	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
   542
    in
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   543
	(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
   544
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   545
  | 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
   546
    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
   547
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   548
	(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
   549
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   550
  | 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
   551
    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
   552
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   553
	(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
   554
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   555
  | 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
   556
    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
   557
	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
   558
	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
   559
	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
   560
				 | 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
   561
				 | T_NONE => app_str ^ (ResClause.paren_pack [s1,s2])
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   562
				 | 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
   563
    in	(r,tp')
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
    end
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   566
  | 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
   567
    if is_pred then 
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   568
	let val (s1,_) = string_of_combterm1_aux false t1
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   569
	    val (s2,_) = string_of_combterm1_aux false t2
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   570
	in
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   571
	    ("equal" ^ (ResClause.paren_pack [s1,s2]),bool_tp)
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   572
	end
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   573
    else
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   574
	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
   575
	in
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   576
	    (t,bool_tp)
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   577
	end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   578
  | string_of_combterm1_aux is_pred (Bool(t)) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   579
    let val (t',_) = string_of_combterm1_aux false t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   580
	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
   581
		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
   582
    in
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   583
	(r,bool_tp)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   584
    end;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   585
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   586
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
   587
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   588
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
   589
    let val tvars' = map string_of_ctyp tvars
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   590
	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
   591
    in
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   592
	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
   593
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   594
  | string_of_combterm2 _ (CombFree(v,tp)) = v
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   595
  | string_of_combterm2 _ (CombVar(v,tp)) = v
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   596
  | string_of_combterm2 is_pred (CombApp(t1,t2,tp)) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   597
    let val s1 = string_of_combterm2 is_pred t1
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   598
	val s2 = string_of_combterm2 is_pred t2
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   599
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   600
	app_str ^ (ResClause.paren_pack [s1,s2])
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   601
    end
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   602
  | 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
   603
    if is_pred then 
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   604
	let val s1 = string_of_combterm2 false t1
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   605
	    val s2 = string_of_combterm2 false t2
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   606
	in
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   607
	    ("equal" ^ (ResClause.paren_pack [s1,s2]))
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   608
	end
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   609
    else
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   610
	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
   611
 
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   612
  | string_of_combterm2 is_pred (Bool(t)) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   613
    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
   614
    in
18200
9d476d1054d7 -- terms are fully typed.
mengj
parents: 17998
diff changeset
   615
	if is_pred then bool_str ^ (ResClause.paren_pack [t'])
9d476d1054d7 -- terms are fully typed.
mengj
parents: 17998
diff changeset
   616
	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
   617
    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
   618
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   619
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   620
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   621
fun string_of_combterm is_pred term = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   622
    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
   623
		     | _ => string_of_combterm1 is_pred term;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   624
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   625
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
   626
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
   627
    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
   628
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   629
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
   630
    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
   631
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   632
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   633
(* tptp format *)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   634
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
   635
fun tptp_literal (Literal(pol,pred)) =
18200
9d476d1054d7 -- terms are fully typed.
mengj
parents: 17998
diff changeset
   636
    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
   637
	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
   638
    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
   639
	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
   640
    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
   641
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   642
 
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   643
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
   644
    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
   645
	val ctvar_lits_strs =
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   646
	    case !typ_level of T_NONE => []
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   647
			     | _ => (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
   648
	val ctfree_lits = 
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   649
	    case !typ_level of T_NONE => []
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   650
			     | _ => (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
   651
    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
   652
	(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
   653
    end; 
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   654
    
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   655
    
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
   656
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
   657
    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
   658
	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
   659
	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
   660
	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
   661
	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
   662
	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
   663
    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
   664
	(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
   665
    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
   666
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   667
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   668
(* dfg format *)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   669
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
   670
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   671
fun dfg_clause_aux (Clause{literals, ctypes_sorts, ...}) = 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   672
  let val lits = map dfg_literal literals
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   673
      val (tvar_lits,tfree_lits) = ResClause.add_typs_aux ctypes_sorts
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   674
      val tvar_lits_strs = 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   675
	  case !typ_level of T_NONE => [] 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   676
			    | _ => map ResClause.dfg_of_typeLit tvar_lits
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   677
      val tfree_lits =
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   678
          case !typ_level of T_NONE => []
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   679
			    | _ => map ResClause.dfg_of_typeLit tfree_lits 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   680
  in
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   681
      (tvar_lits_strs @ lits, tfree_lits)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   682
  end; 
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 get_uvars (CombConst(_,_,_)) vars = vars
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   685
  | get_uvars (CombFree(_,_)) vars = vars
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   686
  | get_uvars (CombVar(v,tp)) vars = (v::vars)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   687
  | 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
   688
  | get_uvars (Bool(c)) vars = get_uvars c vars;
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
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   691
fun get_uvars_l (Literal(_,c)) = get_uvars c [];
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   692
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   693
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
   694
 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   695
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
   696
    let val (lits,tfree_lits) = dfg_clause_aux cls 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   697
        val vars = dfg_vars cls
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   698
        val tvars = ResClause.get_tvar_strs ctypes_sorts
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   699
	val knd = name_of_kind kind
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   700
	val lits_str = commas lits
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   701
	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
   702
    in (cls_str, tfree_lits) end;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   703
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   704
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   705
fun init_funcs_tab funcs = 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   706
    case !typ_level of T_CONST => Symtab.update ("hEXTENT", 2) (Symtab.update ("fequal",1) funcs)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   707
		     | T_FULL => Symtab.update ("typeinfo",2) (Symtab.update ("hEXTENT",0) (Symtab.update ("fequal",0) funcs))
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   708
		     | _ => Symtab.update ("hEXTENT",0) (Symtab.update ("fequal",0) funcs);
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   709
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   710
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   711
fun add_funcs (CombConst(c,_,tvars),funcs) = 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   712
    (case !typ_level of T_CONST => foldl ResClause.add_foltype_funcs (Symtab.update(c,length tvars) funcs) tvars
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   713
		     | _ => foldl ResClause.add_foltype_funcs (Symtab.update(c,0) funcs) tvars)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   714
  | add_funcs (CombFree(_,ctp),funcs) = ResClause.add_foltype_funcs (ctp,funcs) 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   715
  | add_funcs (CombVar(_,ctp),funcs) = ResClause.add_foltype_funcs (ctp,funcs)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   716
  | 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
   717
  | add_funcs (Bool(t),funcs) = add_funcs (t,funcs);
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   718
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   719
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   720
fun add_literal_funcs (Literal(_,c), funcs) = add_funcs (c,funcs);
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   721
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   722
fun add_clause_funcs (Clause {literals, ...}, funcs) =
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   723
    foldl add_literal_funcs funcs literals
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   724
    handle Symtab.DUP a => raise ERROR ("function " ^ a ^ " has multiple arities")
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   725
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   726
fun funcs_of_clauses clauses arity_clauses =
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   727
    Symtab.dest (foldl ResClause.add_arityClause_funcs 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   728
                       (foldl add_clause_funcs (init_funcs_tab Symtab.empty) clauses)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   729
                       arity_clauses)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   730
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   731
fun preds_of clsrel_clauses arity_clauses = 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   732
    Symtab.dest
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   733
	(foldl ResClause.add_classrelClause_preds 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   734
	       (foldl ResClause.add_arityClause_preds
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   735
		      (Symtab.update ("hBOOL",1) Symtab.empty)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   736
		      arity_clauses)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   737
	       clsrel_clauses)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   738
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   739
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   740
(**********************************************************************)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   741
(* clause equalities and hashing functions                            *)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   742
(**********************************************************************)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   743
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   744
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   745
fun combterm_eq (CombConst(c1,tp1,tps1),CombConst(c2,tp2,tps2)) vtvars =
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   746
    let val (eq1,vtvars1) = if c1 = c2 then ResClause.types_eq (tps1,tps2) vtvars
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   747
			    else (false,vtvars)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   748
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   749
	(eq1,vtvars1)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   750
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   751
  | combterm_eq (CombConst(_,_,_),_) vtvars = (false,vtvars)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   752
  | combterm_eq (CombFree(a1,tp1),CombFree(a2,tp2)) vtvars = 
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   753
    if a1 = a2 then ResClause.types_eq ([tp1],[tp2]) vtvars
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   754
    else (false,vtvars)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   755
  | combterm_eq (CombFree(_,_),_) vtvars = (false,vtvars)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   756
  | combterm_eq (CombVar(v1,tp1),CombVar(v2,tp2)) (vars,tvars) = 
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   757
    (case ResClause.check_var_pairs(v1,v2) vars of 0 => ResClause.types_eq ([tp1],[tp2]) ((v1,v2)::vars,tvars)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   758
						 | 1 => ResClause.types_eq ([tp1],[tp2]) (vars,tvars)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   759
						 | 2 => (false,(vars,tvars)))
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   760
  | combterm_eq (CombVar(_,_),_) vtvars = (false,vtvars)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   761
  | combterm_eq (CombApp(f1,arg1,tp1),CombApp(f2,arg2,tp2)) vtvars =
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   762
    let val (eq1,vtvars1) = combterm_eq (f1,f2) vtvars
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   763
	val (eq2,vtvars2) = if eq1 then combterm_eq (arg1,arg2) vtvars1
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   764
			    else (eq1,vtvars1)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   765
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   766
	if eq2 then ResClause.types_eq ([tp1],[tp2]) vtvars2
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   767
	else (eq2,vtvars2)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   768
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   769
  | combterm_eq (CombApp(_,_,_),_) vtvars = (false,vtvars)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   770
  | combterm_eq (Bool(t1),Bool(t2)) vtvars = combterm_eq (t1,t2) vtvars
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   771
  | combterm_eq (Bool(_),_) vtvars = (false,vtvars);
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   772
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   773
fun lit_eq (Literal(pol1,pred1),Literal(pol2,pred2)) vtvars =
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   774
    if (pol1 = pol2) then combterm_eq (pred1,pred2) vtvars
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   775
    else (false,vtvars);
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   776
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   777
fun lits_eq ([],[]) vtvars = (true,vtvars)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   778
  | lits_eq (l1::ls1,l2::ls2) vtvars = 
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   779
    let val (eq1,vtvars1) = lit_eq (l1,l2) vtvars
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   780
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   781
	if eq1 then lits_eq (ls1,ls2) vtvars1
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   782
	else (false,vtvars1)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   783
    end;
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   784
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   785
fun clause_eq (cls1,cls2) =
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   786
    let val lits1 = get_literals cls1
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   787
	val lits2 = get_literals cls2
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   788
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   789
	length lits1 = length lits2 andalso #1 (lits_eq (lits1,lits2) ([],[]))
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   790
    end;
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   791
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   792
val xor_words = List.foldl Word.xorb 0w0;
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   793
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   794
fun hash_combterm (CombVar(_,_),w) = w
18449
e314fb38307d new hash table module in HOL/Too/s
paulson
parents: 18440
diff changeset
   795
  | hash_combterm (CombFree(f,_),w) = Polyhash.hashw_string(f,w)
e314fb38307d new hash table module in HOL/Too/s
paulson
parents: 18440
diff changeset
   796
  | hash_combterm (CombConst(c,tp,tps),w) = Polyhash.hashw_string(c,w)
e314fb38307d new hash table module in HOL/Too/s
paulson
parents: 18440
diff changeset
   797
  | hash_combterm (CombApp(f,arg,tp),w) = hash_combterm (arg, hash_combterm (f,w))
19452
ef0ed2fe7bf2 Changed the treatment of equalities.
mengj
parents: 19444
diff changeset
   798
  | hash_combterm (Bool(t),w) = hash_combterm (t,w);
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   799
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   800
fun hash_literal (Literal(true,pred)) = hash_combterm(pred,0w0)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   801
  | hash_literal (Literal(false,pred)) = Word.notb(hash_combterm(pred,0w0));
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   802
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   803
fun hash_clause clause = xor_words (map hash_literal (get_literals clause));
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   804
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   805
(**********************************************************************)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   806
(* write clauses to files                                             *)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   807
(**********************************************************************)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   808
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   809
(* tptp format *)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   810
19491
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   811
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
   812
19491
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   813
fun get_helper_clauses_tptp () =
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   814
    let val tlevel = case !typ_level of T_FULL => (warning "Fully-typed HOL"; "~~/src/HOL/Tools/atp-inputs/full_")
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   815
				      | T_PARTIAL => (warning "Partially-typed HOL"; "~~/src/HOL/Tools/atp-inputs/par_")
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   816
				      | T_CONST => (warning "Const-only-typed HOL"; "~~/src/HOL/Tools/atp-inputs/const_")
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   817
				      | T_NONE => (warning "Untyped HOL"; "~~/src/HOL/Tools/atp-inputs/u_")
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   818
	val helpers = if !include_combS then (warning "Include combinator S"; ["helper1.tptp","comb_inclS.tptp"]) else
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   819
		     if !include_min_comb then (warning "Include min combinators"; ["helper1.tptp","comb_noS.tptp"])
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   820
		     else (warning "No combinator is used"; ["helper1.tptp"])
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   821
	val t_helpers = map (curry (op ^) tlevel) helpers
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   822
    in
19491
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   823
	read_in t_helpers
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   824
    end;
19491
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   825
	
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   826
						  
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   827
(* 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
   828
(* 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
   829
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
   830
    let val clss = make_conjecture_clauses thms
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   831
	val axclauses' = 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
   832
	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
   833
	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
   834
	val out = TextIO.openOut filename
19491
cd6c71c57f53 changed the functions for getting HOL helper clauses.
mengj
parents: 19452
diff changeset
   835
	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
   836
    in
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   837
	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
   838
	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
   839
	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
   840
	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
   841
	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
   842
	List.app (curry TextIO.output out) helper_clauses;
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   843
	TextIO.closeOut out
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   844
    end;
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   845
19720
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   846
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   847
(* dfg format *)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   848
fun get_helper_clauses_dfg () = 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   849
    let val tlevel = case !typ_level of T_FULL => (warning "Fully-typed HOL"; "~~/src/HOL/Tools/atp-inputs/full_")
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   850
				      | T_PARTIAL => (warning "Partially-typed HOL"; "~~/src/HOL/Tools/atp-inputs/par_")
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   851
				      | T_CONST => (warning "Const-only-typed HOL"; "~~/src/HOL/Tools/atp-inputs/const_")
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   852
				      | T_NONE => (warning "Untyped HOL"; "~~/src/HOL/Tools/atp-inputs/u_")
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   853
	val helpers = if !include_combS then (warning "Include combinator S"; ["helper1.dfg","comb_inclS.dfg"]) else
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   854
		      if !include_min_comb then (warning "Include min combinators"; ["helper1.dfg","comb_noS.dfg"])
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   855
		      else (warning "No combinator is used"; ["helper1.dfg"])
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   856
	val t_helpers = map (curry (op ^) tlevel) helpers
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   857
    in
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   858
	read_in t_helpers
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   859
    end;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   860
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   861
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   862
fun dfg_write_file  thms filename (axclauses,classrel_clauses,arity_clauses) =
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   863
    let val _ = Output.debug ("Preparing to write the DFG file " ^ filename) 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   864
	val conjectures = make_conjecture_clauses thms
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   865
	val axclauses' = make_axiom_clauses axclauses
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   866
	val (dfg_clss,tfree_litss) = ListPair.unzip (map clause2dfg conjectures)
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   867
	val clss = conjectures @ axclauses'
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   868
	val funcs = funcs_of_clauses clss arity_clauses
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   869
	and preds = preds_of classrel_clauses arity_clauses
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   870
	and probname = Path.pack (Path.base (Path.unpack filename))
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   871
	val (axstrs,_) =  ListPair.unzip (map clause2dfg axclauses')
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   872
	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
   873
	val out = TextIO.openOut filename
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   874
	val helper_clauses = get_helper_clauses_dfg ()
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   875
    in
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   876
	TextIO.output (out, ResClause.string_of_start probname); 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   877
	TextIO.output (out, ResClause.string_of_descrip probname); 
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   878
	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
   879
	TextIO.output (out, "list_of_clauses(axioms,cnf).\n");
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   880
	ResClause.writeln_strs out axstrs;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   881
	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
   882
	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
   883
	ResClause.writeln_strs out helper_clauses;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   884
	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
   885
	ResClause.writeln_strs out tfree_clss;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   886
	ResClause.writeln_strs out dfg_clss;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   887
	TextIO.output (out, "end_of_list.\n\nend_problem.\n");
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   888
	TextIO.closeOut out
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   889
    end;
f68f6f958a1d HOL problems now have DFG output format.
mengj
parents: 19491
diff changeset
   890
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
   891
end