src/HOL/Tools/res_hol_clause.ML
author mengj
Tue, 18 Apr 2006 05:38:18 +0200
changeset 19444 085568445283
parent 19354 aebf9dddccd7
child 19452 ef0ed2fe7bf2
permissions -rw-r--r--
Take conjectures and axioms as thms when convert them to ResHolClause.clause 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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   199
		  | Bool of combterm
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   200
		  | Equal of combterm * 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
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
   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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   206
	 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
   207
		    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
   208
		    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
   209
		    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
   210
		    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
   211
                    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
   212
                    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
   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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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 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
   217
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
   218
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
   219
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   220
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
   221
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
   222
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   223
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   224
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
   225
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   226
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
   227
  | 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
   228
  | 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
   229
  | 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
   230
    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
   231
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   232
	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
   233
		   | _ => ord1
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   234
    end
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 (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
   236
  | 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
   237
  | 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
   238
  | 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
   239
    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
   240
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   241
	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
   242
		   | _ => ord1
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   243
    end
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 (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
   245
  | 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
   246
  | term_ord (CombApp(_,_,_),Equal(_,_)) = LESS
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   247
  | 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
   248
    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
   249
	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
   250
			      | _ => ord1
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   251
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   252
	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
   253
		   | _ => ord2
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   254
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   255
  | term_ord (CombApp(_,_,_),_) = GREATER
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   256
  | term_ord (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
   257
  | term_ord (Equal(t1,t2),Equal(t3,t4)) = ResClause.list_ord term_ord ([t1,t2],[t3,t4])
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   258
  | term_ord (Equal(_,_),_) = GREATER;
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   259
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   260
fun predicate_ord (Equal(_,_),Bool(_)) = LESS
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   261
  | predicate_ord (Equal(t1,t2),Equal(t3,t4)) = 
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   262
    ResClause.list_ord term_ord ([t1,t2],[t3,t4])
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   263
  | predicate_ord (Bool(_),Equal(_,_)) = GREATER
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   264
  | predicate_ord (Bool(t1),Bool(t2)) = term_ord (t1,t2)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   265
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   266
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   267
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
   268
  | 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
   269
  | 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
   270
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   271
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
   272
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
(* 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
   275
(*********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   277
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
   278
    (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
   279
    (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
   280
  | 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
   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
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   283
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
   284
      (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
   285
      (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
   286
  | 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
   287
  
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   289
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   293
    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
   294
    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
   295
    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
   296
	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
   297
		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
   298
		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
   299
		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
   300
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   301
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
   302
    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
   303
	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
   304
    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
   305
	(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
   306
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   307
  | 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
   308
    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
   309
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   310
	(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
   311
    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
   312
  | 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
   313
    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
   314
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   315
	(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
   316
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   317
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
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
   319
    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
   320
	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
   321
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   322
	(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
   323
    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
   324
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   325
(* 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
   326
fun simp_type_of (Type (a, Ts)) = 
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   327
    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
   328
	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
   329
    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
   330
	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
   331
    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
   332
  | 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
   333
  | 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
   334
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   335
fun comb_typ ("COMBI",t) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   336
    let val t' = domain_type t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   337
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   338
	[simp_type_of t']
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   339
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   340
  | comb_typ ("COMBK",t) = 
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   341
    let val a = domain_type t
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   342
	val b = domain_type (range_type t)
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   343
    in
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   344
	map simp_type_of [a,b]
18356
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 ("COMBS",t) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   347
    let val t' = domain_type t
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   348
	val a = domain_type t'
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   349
	val b = domain_type (range_type t')
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   350
	val c = range_type (range_type t')
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   351
    in 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   352
	map simp_type_of [a,b,c]
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   353
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   354
  | comb_typ ("COMBB",t) = 
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   355
    let val ab = domain_type t
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   356
	val ca = domain_type (range_type t)
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   357
	val a = domain_type ab
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   358
	val b = range_type ab
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   359
	val c = domain_type ca
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
  | comb_typ ("COMBC",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   364
    let val t1 = domain_type t
18725
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   365
	val a = domain_type t1
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   366
	val b = domain_type (range_type t1)
2d0af0574588 fixed a bug
mengj
parents: 18449
diff changeset
   367
	val c = range_type (range_type t1)
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   368
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   369
	map simp_type_of [a,b,c]
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   370
    end;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   371
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   372
fun const_type_of ("COMBI",t) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   373
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   374
	val I_var = comb_typ ("COMBI",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   375
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   376
	(tp,ts,I_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   377
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   378
  | const_type_of ("COMBK",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   379
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   380
	val K_var = comb_typ ("COMBK",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   381
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   382
	(tp,ts,K_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   383
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   384
  | const_type_of ("COMBS",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   385
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   386
	val S_var = comb_typ ("COMBS",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   387
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   388
	(tp,ts,S_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   389
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   390
  | const_type_of ("COMBB",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   391
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   392
	val B_var = comb_typ ("COMBB",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   393
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   394
	(tp,ts,B_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   395
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   396
  | const_type_of ("COMBC",t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   397
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   398
	val C_var = comb_typ ("COMBC",t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   399
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   400
	(tp,ts,C_var)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   401
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   402
  | const_type_of (c,t) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   403
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   404
	val tvars = !const_typargs(c,t)
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   405
	val tvars' = map simp_type_of tvars
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   406
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   407
	(tp,ts,tvars')
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   408
    end;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   409
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   410
fun is_bool_type (Type("bool",[])) = true
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   411
  | 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
   412
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
(* 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
   415
fun combterm_of (Const(c,t)) =
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   416
    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
   417
	val is_bool = is_bool_type t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   418
	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
   419
	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
   420
    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
   421
	(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
   422
    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
   423
  | combterm_of (Free(v,t)) =
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   424
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   425
	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
   426
	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
   427
		 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
   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 (Var(v,t)) =
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   433
    let val (tp,ts) = type_of t
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   434
	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
   435
	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
   436
	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
   437
    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
   438
	(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
   439
    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
   440
  | combterm_of (Const("op =",T) $ P $ Q) = (*FIXME: allow equal between bools?*)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
    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
   442
	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
   443
    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
   444
	(Equal(P',Q'),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
   445
    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
   446
  | 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
   447
    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
   448
	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
   449
	val tp = Term.type_of t
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   450
	val tp' = simp_type_of tp
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   451
	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
   452
	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
   453
	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
   454
    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
   455
	(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
   456
    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
   457
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   459
    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
   460
  | 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
   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_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
   464
  | 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
   465
    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
   466
    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
   467
	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
   468
    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
   469
  | 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
   470
    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
   471
	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
   472
    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
   473
	(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
   474
    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
   475
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   476
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   477
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
   478
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   479
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   480
(* 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
   481
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
   482
    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
   483
	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
   484
	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
   485
	val lits' = sort_lits lits
18856
4669dec681f4 tidy-up of res_clause.ML, removing the "predicates" field
paulson
parents: 18725
diff changeset
   486
	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
   487
    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
   488
	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
   489
		    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
   490
    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
   491
19444
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   492
fun make_axiom_clauses [] = []
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   493
  | 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
   494
    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
   495
	val clss = make_axiom_clauses thms
19354
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   496
    in
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   497
	if isTaut cls then clss else (cls::clss)
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   498
    end;
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   499
aebf9dddccd7 tptp_write_file accepts axioms as thm.
mengj
parents: 19198
diff changeset
   500
19444
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   501
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
   502
    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
   503
	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
   504
	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
   505
	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
   506
    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
   507
	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
   508
    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
   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
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   513
  | 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
   514
    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
   515
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   517
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   518
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   519
(**********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   520
(* 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
   521
(* TPTP used by Vampire and E                                         *)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   522
(**********************************************************************)
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   523
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   524
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
   525
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   526
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
   527
19130
b23479b80828 Default type level is T_FULL now.
mengj
parents: 18856
diff changeset
   528
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
   529
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   530
fun full_types () = (typ_level:=T_FULL);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   531
fun partial_types () = (typ_level:=T_PARTIAL);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   532
fun const_types_only () = (typ_level:=T_CONST);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   533
fun no_types () = (typ_level:=T_NONE);
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   534
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   535
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   536
fun find_typ_level () = !typ_level;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   537
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   538
fun wrap_type (c,t) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   539
    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
   540
		     | _ => c;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   541
    
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
   542
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   543
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
   544
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   545
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
   546
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   547
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
   548
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   549
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
   550
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   551
(* 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
   552
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
   553
    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
   554
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   555
	(wrap_type (c,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
   556
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   557
  | 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
   558
    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
   559
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   560
	(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
   561
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   562
  | 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
   563
    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
   564
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   565
	(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
   566
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   567
  | 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
   568
    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
   569
	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
   570
	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
   571
	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
   572
				 | 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
   573
				 | T_NONE => app_str ^ (ResClause.paren_pack [s1,s2])
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   574
				 | 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
   575
    in	(r,tp')
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   576
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   577
    end
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)
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
   584
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   585
  | string_of_combterm1_aux _ (Equal(t1,t2)) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   586
    let val (s1,_) = string_of_combterm1_aux false t1
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   587
	val (s2,_) = string_of_combterm1_aux false t2
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   588
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   589
	("equal" ^ (ResClause.paren_pack [s1,s2]),bool_tp) 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   590
    end;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   591
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   592
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
   593
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   594
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
   595
    let val tvars' = map string_of_ctyp tvars
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   596
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   597
	c ^ (ResClause.paren_pack tvars')
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   598
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   599
  | string_of_combterm2 _ (CombFree(v,tp)) = v
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   600
  | string_of_combterm2 _ (CombVar(v,tp)) = v
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   601
  | string_of_combterm2 is_pred (CombApp(t1,t2,tp)) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   602
    let val s1 = string_of_combterm2 is_pred t1
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   603
	val s2 = string_of_combterm2 is_pred t2
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   604
    in
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   605
	app_str ^ (ResClause.paren_pack [s1,s2])
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   606
    end
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   607
  | string_of_combterm2 is_pred (Bool(t)) = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   608
    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
   609
    in
18200
9d476d1054d7 -- terms are fully typed.
mengj
parents: 17998
diff changeset
   610
	if is_pred then bool_str ^ (ResClause.paren_pack [t'])
9d476d1054d7 -- terms are fully typed.
mengj
parents: 17998
diff changeset
   611
	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
   612
    end
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   613
  | string_of_combterm2 _ (Equal(t1,t2)) =
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   614
    let val s1 = string_of_combterm2 false t1
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   615
	val s2 = string_of_combterm2 false t2
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
   616
    in
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   617
	("equal" ^ (ResClause.paren_pack [s1,s2])) 
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
   618
    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
   619
18356
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
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   622
fun string_of_combterm is_pred term = 
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   623
    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
   624
		     | _ => string_of_combterm1 is_pred term;
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   625
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   626
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
   627
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
   628
    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
   629
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   631
    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
   632
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   633
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. This file also has functions that convert lambda terms to combinator expressions, and functions that convert clauses to TPTP format.
mengj
parents:
diff changeset
   634
fun tptp_literal (Literal(pol,pred)) =
18200
9d476d1054d7 -- terms are fully typed.
mengj
parents: 17998
diff changeset
   635
    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
   636
	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
   637
    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
   638
	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
   639
    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
   640
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
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
   643
    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
   644
	val ctvar_lits_strs =
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   645
	    case !typ_level of T_NONE => []
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   646
			     | _ => (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
   647
	val ctfree_lits = 
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   648
	    case !typ_level of T_NONE => []
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   649
			     | _ => (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
   650
    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
   651
	(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
   652
    end; 
18356
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   653
    
443717b3a9ad Added new type embedding methods for translating HOL clauses.
mengj
parents: 18276
diff changeset
   654
    
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
   655
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
   656
    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
   657
	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
   658
	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
   659
	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
   660
	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
   661
	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
   662
    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
   663
	(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
   664
    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
   665
0a869029ca58 A new file that defines datatypes representing FOL clauses that are derived from HOL formulae. 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
18440
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   667
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   668
(**********************************************************************)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   669
(* 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
   670
(**********************************************************************)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   671
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   672
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   673
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
   674
    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
   675
			    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
   676
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   677
	(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
   678
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   679
  | 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
   680
  | 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
   681
    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
   682
    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
   683
  | 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
   684
  | 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
   685
    (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
   686
						 | 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
   687
						 | 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
   688
  | 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
   689
  | 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
   690
    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
   691
	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
   692
			    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
   693
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   694
	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
   695
	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
   696
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   697
  | 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
   698
  | combterm_eq (Bool(t1),Bool(t2)) vtvars = combterm_eq (t1,t2) vtvars
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   699
  | combterm_eq (Bool(_),_) 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
   700
  | combterm_eq (Equal(t1,t2),Equal(t3,t4)) vtvars =
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   701
    let val (eq1,vtvars1) = combterm_eq (t1,t3) vtvars
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   702
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   703
	if eq1 then combterm_eq (t2,t4) vtvars1
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   704
	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
   705
    end
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   706
  | combterm_eq (Equal(t1,t2),_) 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
   707
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   708
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
   709
    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
   710
    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
   711
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   712
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
   713
  | 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
   714
    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
   715
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   716
	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
   717
	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
   718
    end;
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   719
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   720
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
   721
    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
   722
	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
   723
    in
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   724
	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
   725
    end;
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   726
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   727
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
   728
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   729
fun hash_combterm (CombVar(_,_),w) = w
18449
e314fb38307d new hash table module in HOL/Too/s
paulson
parents: 18440
diff changeset
   730
  | hash_combterm (CombFree(f,_),w) = Polyhash.hashw_string(f,w)
e314fb38307d new hash table module in HOL/Too/s
paulson
parents: 18440
diff changeset
   731
  | 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
   732
  | hash_combterm (CombApp(f,arg,tp),w) = hash_combterm (arg, hash_combterm (f,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
   733
  | hash_combterm (Bool(t),w) = hash_combterm (t,w)
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   734
  | hash_combterm (Equal(t1,t2),w) = 
18449
e314fb38307d new hash table module in HOL/Too/s
paulson
parents: 18440
diff changeset
   735
    List.foldl hash_combterm (Polyhash.hashw_string ("equal",w)) [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
   736
72ee07f4b56b Literals in clauses are sorted now. Added functions for clause equivalence tests and hashing clauses to words.
mengj
parents: 18356
diff changeset
   737
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
   738
  | 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
   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
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
   741
19198
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   742
(**********************************************************************)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   743
(* write clauses to files                                             *)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   744
(**********************************************************************)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   745
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   746
fun read_in [] = []
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   747
  | read_in (f1::fs) =
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   748
    let val lines = read_in fs
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   749
	val input = TextIO.openIn f1
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   750
	fun reading () =
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   751
	    let val nextline = TextIO.inputLine input
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   752
	    in
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   753
		if nextline = "" then (TextIO.closeIn input; [])
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   754
		else nextline::(reading ())
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   755
	    end
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   756
    in
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   757
	((reading ()) @ lines)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   758
    end;
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   759
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   760
 
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   761
fun get_helper_clauses (full,partial,const,untyped) =
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   762
    let val (helper1,noS,inclS) = case !typ_level of T_FULL => (warning "Fully-typed HOL"; full)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   763
						   | T_PARTIAL => (warning "Partially-typed HOL"; partial)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   764
						   | T_CONST => (warning "Const-only-typed HOL"; const)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   765
						   | T_NONE => (warning "Untyped HOL"; untyped)
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   766
	val needed_helpers = if !include_combS then (warning "Include combinator S"; [helper1,inclS]) else
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   767
			     if !include_min_comb then (warning "Include min combinators"; [helper1,noS])
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   768
			     else (warning "No combinator is used"; [helper1])
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   769
    in
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   770
	read_in needed_helpers
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   771
    end;
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   772
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   773
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   774
(* 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
   775
(* when "get_helper_clauses" is called, "include_combS" and "include_min_comb" should have correct values already *)
19444
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   776
fun tptp_write_file thms filename (axclauses,classrel_clauses,arity_clauses) helpers =
085568445283 Take conjectures and axioms as thms when convert them to ResHolClause.clause format.
mengj
parents: 19354
diff changeset
   777
    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
   778
	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
   779
	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
   780
	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
   781
	val out = TextIO.openOut filename
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   782
	val helper_clauses = get_helper_clauses helpers
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   783
    in
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   784
	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
   785
	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
   786
	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
   787
	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
   788
	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
   789
	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
   790
	TextIO.closeOut out
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   791
    end;
e6f1ff40ba99 Added tptp_write_file to write all necessary ATP input clauses to one file.
mengj
parents: 19130
diff changeset
   792
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
   793
end