28 val make_hypothesis_clause : Term.term -> clause |
28 val make_hypothesis_clause : Term.term -> clause |
29 val special_equal : bool ref |
29 val special_equal : bool ref |
30 val clause_info : clause -> string * string |
30 val clause_info : clause -> string * string |
31 val typed : unit -> unit |
31 val typed : unit -> unit |
32 val untyped : unit -> unit |
32 val untyped : unit -> unit |
|
33 val num_of_clauses : clause -> int |
33 |
34 |
34 val dfg_clauses2str : string list -> string |
35 val dfg_clauses2str : string list -> string |
35 val clause2dfg : clause -> string * string list |
36 val clause2dfg : clause -> string * string list |
36 val clauses2dfg : clause list -> string -> clause list -> clause list -> |
37 val clauses2dfg : clause list -> string -> clause list -> clause list -> |
37 (string * int) list -> (string * int) list -> string list -> string |
38 (string * int) list -> (string * int) list -> string list -> string |
624 val premLits = map make_TVarLit false_tvars_srts' |
625 val premLits = map make_TVarLit false_tvars_srts' |
625 in |
626 in |
626 make_arity_clause (cls_id,Axiom,conclLit,premLits) |
627 make_arity_clause (cls_id,Axiom,conclLit,premLits) |
627 end; |
628 end; |
628 |
629 |
|
630 (*The number of clauses generated from cls, including type clauses*) |
|
631 fun num_of_clauses (Clause cls) = |
|
632 let val num_tfree_lits = |
|
633 if !keep_types then length (#tfree_type_literals cls) |
|
634 else 0 |
|
635 in 1 + num_tfree_lits end; |
629 |
636 |
630 |
637 |
631 (**** Isabelle class relations ****) |
638 (**** Isabelle class relations ****) |
632 |
639 |
633 |
640 |
814 in |
821 in |
815 if !keep_types andalso typ<>"" |
822 if !keep_types andalso typ<>"" |
816 then name ^ (ResLib.list_to_string (terms_as_strings @ [typ])) |
823 then name ^ (ResLib.list_to_string (terms_as_strings @ [typ])) |
817 else name ^ (ResLib.list_to_string terms_as_strings) |
824 else name ^ (ResLib.list_to_string terms_as_strings) |
818 end; |
825 end; |
819 |
|
820 |
|
821 |
826 |
822 |
827 |
823 fun concat_with sep [] = "" |
828 fun concat_with sep [] = "" |
824 | concat_with sep [x] = "(" ^ x ^ ")" |
829 | concat_with sep [x] = "(" ^ x ^ ")" |
825 | concat_with sep (x::xs) = "(" ^ x ^ ")" ^ sep ^ (concat_with sep xs); |
830 | concat_with sep (x::xs) = "(" ^ x ^ ")" ^ sep ^ (concat_with sep xs); |
952 fun fileout f str = let val out = TextIO.openOut f |
957 fun fileout f str = let val out = TextIO.openOut f |
953 in |
958 in |
954 ResLib.writeln_strs out str; TextIO.closeOut out |
959 ResLib.writeln_strs out str; TextIO.closeOut out |
955 end; |
960 end; |
956 |
961 |
957 (*val filestr = clauses2dfg newcls "flump" [] [] [] []; |
962 |
958 *) |
963 |
959 (* fileout "flump.dfg" [filestr];*) |
964 fun string_of_arClauseID (ArityClause arcls) = |
960 |
965 arclause_prefix ^ string_of_int(#clause_id arcls); |
961 |
|
962 (*FIX: ask Jia what this is for *) |
|
963 |
|
964 |
|
965 fun string_of_arClauseID (ArityClause arcls) = arclause_prefix ^ string_of_int(#clause_id arcls); |
|
966 |
|
967 |
966 |
968 fun string_of_arLit (TConsLit(b,(c,t,args))) = |
967 fun string_of_arLit (TConsLit(b,(c,t,args))) = |
969 let val pol = if b then "++" else "--" |
968 let val pol = if b then "++" else "--" |
970 val arg_strs = (case args of [] => "" | _ => ResLib.list_to_string args) |
969 val arg_strs = (case args of [] => "" | _ => ResLib.list_to_string args) |
971 in |
970 in |
972 pol ^ c ^ "(" ^ t ^ arg_strs ^ ")" |
971 pol ^ c ^ "(" ^ t ^ arg_strs ^ ")" |
973 end |
972 end |
974 | string_of_arLit (TVarLit(b,(c,str))) = |
973 | string_of_arLit (TVarLit(b,(c,str))) = |
975 let val pol = if b then "++" else "--" |
974 let val pol = if b then "++" else "--" |
1024 *) |
1023 *) |
1025 |
1024 |
1026 (********************************) |
1025 (********************************) |
1027 (* code to produce TPTP files *) |
1026 (* code to produce TPTP files *) |
1028 (********************************) |
1027 (********************************) |
1029 |
|
1030 |
|
1031 |
1028 |
1032 fun tptp_literal (Literal(pol,pred,tag)) = |
1029 fun tptp_literal (Literal(pol,pred,tag)) = |
1033 let val pred_string = string_of_predicate pred |
1030 let val pred_string = string_of_predicate pred |
1034 val tagged_pol = |
1031 val tagged_pol = |
1035 if (tag andalso !tagged) then (if pol then "+++" else "---") |
1032 if (tag andalso !tagged) then (if pol then "+++" else "---") |
1051 end; |
1048 end; |
1052 |
1049 |
1053 fun gen_tptp_type_cls (cls_id,knd,tfree_lit,idx) = |
1050 fun gen_tptp_type_cls (cls_id,knd,tfree_lit,idx) = |
1054 "input_clause(" ^ cls_id ^ "_tcs" ^ (string_of_int idx) ^ "," ^ |
1051 "input_clause(" ^ cls_id ^ "_tcs" ^ (string_of_int idx) ^ "," ^ |
1055 knd ^ ",[" ^ tfree_lit ^ "])."; |
1052 knd ^ ",[" ^ tfree_lit ^ "])."; |
1056 |
|
1057 |
1053 |
1058 fun tptp_clause_aux (Clause cls) = |
1054 fun tptp_clause_aux (Clause cls) = |
1059 let val lits = map tptp_literal (#literals cls) |
1055 let val lits = map tptp_literal (#literals cls) |
1060 val tvar_lits_strs = |
1056 val tvar_lits_strs = |
1061 if !keep_types |
1057 if !keep_types |
1064 val tfree_lits = |
1060 val tfree_lits = |
1065 if !keep_types |
1061 if !keep_types |
1066 then (map tptp_of_typeLit (#tfree_type_literals cls)) |
1062 then (map tptp_of_typeLit (#tfree_type_literals cls)) |
1067 else [] |
1063 else [] |
1068 in |
1064 in |
1069 (tvar_lits_strs @ lits,tfree_lits) |
1065 (tvar_lits_strs @ lits, tfree_lits) |
1070 end; |
1066 end; |
1071 |
1067 |
1072 |
|
1073 fun tptp_clause cls = |
1068 fun tptp_clause cls = |
1074 let val (lits,tfree_lits) = tptp_clause_aux cls (*"lits" includes the typing assumptions (TVars)*) |
1069 let val (lits,tfree_lits) = tptp_clause_aux cls |
|
1070 (*"lits" includes the typing assumptions (TVars)*) |
1075 val cls_id = string_of_clauseID cls |
1071 val cls_id = string_of_clauseID cls |
1076 val ax_name = string_of_axiomName cls |
1072 val ax_name = string_of_axiomName cls |
1077 val knd = string_of_kind cls |
1073 val knd = string_of_kind cls |
1078 val lits_str = ResLib.list_to_string' lits |
1074 val lits_str = ResLib.list_to_string' lits |
1079 val cls_str = gen_tptp_cls(cls_id,ax_name,knd,lits_str) fun typ_clss k [] = [] |
1075 val cls_str = gen_tptp_cls(cls_id,ax_name,knd,lits_str) |
|
1076 fun typ_clss k [] = [] |
1080 | typ_clss k (tfree :: tfrees) = |
1077 | typ_clss k (tfree :: tfrees) = |
1081 (gen_tptp_type_cls(cls_id,knd,tfree,k)) :: (typ_clss (k+1) tfrees) |
1078 (gen_tptp_type_cls(cls_id,knd,tfree,k)) :: typ_clss (k+1) tfrees |
1082 in |
1079 in |
1083 cls_str :: (typ_clss 0 tfree_lits) |
1080 cls_str :: (typ_clss 0 tfree_lits) |
1084 end; |
1081 end; |
1085 |
1082 |
1086 |
|
1087 fun clause2tptp cls = |
1083 fun clause2tptp cls = |
1088 let val (lits,tfree_lits) = tptp_clause_aux cls (*"lits" includes the typing assumptions (TVars)*) |
1084 let val (lits,tfree_lits) = tptp_clause_aux cls |
|
1085 (*"lits" includes the typing assumptions (TVars)*) |
1089 val cls_id = string_of_clauseID cls |
1086 val cls_id = string_of_clauseID cls |
1090 val ax_name = string_of_axiomName cls |
1087 val ax_name = string_of_axiomName cls |
1091 val knd = string_of_kind cls |
1088 val knd = string_of_kind cls |
1092 val lits_str = ResLib.list_to_string' lits |
1089 val lits_str = ResLib.list_to_string' lits |
1093 val cls_str = gen_tptp_cls(cls_id,ax_name,knd,lits_str) |
1090 val cls_str = gen_tptp_cls(cls_id,ax_name,knd,lits_str) |