-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint.ml
More file actions
171 lines (144 loc) · 4.13 KB
/
print.ml
File metadata and controls
171 lines (144 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
open Terms
open Tptp
let rec string_of_suffix i =
match i with
0 -> "0"
| x -> (string_of_int x) (* "'" ^ (string_of_suffix (i-1)) *)
;;
let string_of_variable s i =
s ^ (string_of_suffix i)
;;
let rec string_of_term = function
| V(s,i) -> string_of_variable s i
| T(s,[]) -> s
| T(s,t::[]) -> s ^ "(" ^ (string_of_term t) ^ ")"
| T(s,t::tl) -> s ^ "(" ^
(List.fold_left (fun s t -> s ^ "," ^ (string_of_term t))
(string_of_term t) tl ) ^ ")"
;;
let rec reflect_term = function
| V(s,i) -> "V(\"" ^ s ^ "\"," ^ (string_of_int i) ^ ")"
| T(s,ts) -> "T(\"" ^ s ^ "\",[" ^
(List.fold_left (fun a b -> a ^ (reflect_term b) ^ ";") "" ts)
^ "])"
;;
let reflect_rule (l,r) =
(reflect_term l) ^ " -> " ^
(reflect_term r)
;;
let string_of_equation (s,t) =
(string_of_term s) ^ " = " ^
(string_of_term t)
;;
let string_of_disequation (s,t) =
(string_of_term s) ^ " = " ^
(string_of_term t)
;;
let string_of_conjecture (s,t) =
(string_of_term s) ^ " =? " ^
(string_of_term t)
;;
let string_of_identity (s,t) =
(string_of_term s) ^ " = " ^
(string_of_term t)
;;
let string_of_rule (s,t) =
(string_of_term s) ^ " -> " ^
(string_of_term t)
;;
let string_of_rewrite s t =
(string_of_term s) ^ " -->! " ^
(string_of_term t)
;;
let string_of_rewrite_inv s t =
(string_of_term t) ^ " !<-- " ^
(string_of_term s)
;;
(* let rec string_of_relation f s = function *)
(* x::xs -> (f x) ^ (match s with Some(x) -> " " ^ x | _ -> "") ^ *)
(* (match xs with [] -> "" | _ -> "\n") ^ *)
(* (string_of_relation f s xs) *)
(* | [] -> "" *)
(* ;; *)
let string_of_relation_old f s x =
let rec string_of_rel_h f s i = function
x::xs ->
(Printf.sprintf "%02d. " i) ^
(f x) ^ (match s with Some(x) -> " " ^ x | _ -> "") ^
(match xs with [] -> "" | _ -> "\n") ^
(string_of_rel_h f s (i+1) xs)
| [] -> ""
in
string_of_rel_h f s 0 x
;;
let string_of_relation f pre post eqs =
let rec string_of_rel_h i = function
x::xs ->
(pre i) ^ (f x) ^ (post i) ^
(match xs with [] -> "" | _ -> "\n") ^
(string_of_rel_h (i+1) xs)
| [] -> ""
in
string_of_rel_h 0 eqs
;;
let f_empty = fun i -> "";;
let f_mark = fun i -> " #";;
let f_number = fun i -> Printf.sprintf "%02d. " i;;
let string_of_trs_marked t =
string_of_relation string_of_rule f_empty f_mark t
;;
let string_of_trs_numbered t =
string_of_relation string_of_rule f_number f_empty t
;;
let string_of_trs_tpdb t =
"(RULES \n" ^
(string_of_relation string_of_rule f_empty f_empty t) ^ ")"
;;
let string_of_theory t =
string_of_relation string_of_identity f_empty f_empty t
;;
let string_of_trs t =
string_of_relation string_of_rule f_empty f_empty t
;;
let string_of_unifier sigma =
Hashtbl.fold
(fun k d l ->
k ^ " -> " ^ (string_of_term d) ^
(if l = "" then l else (", " ^ l)))
sigma ""
;;
let string_of_vars vars =
"[" ^
(List.fold_left
(fun s (x,i) ->
(if s = "" then "" else (s ^ ",")) ^ (string_of_variable x i))
"" vars) ^ "]"
;;
let string_of_vars_tpdb vars =
"(VAR " ^
(List.fold_left
(fun s (x,i) ->
(if s = "" then "" else (s ^ " ")) ^ (string_of_variable x i))
"" vars) ^ ")"
;;
let string_of_status = function
| Axiom -> "axiom"
| Hypothesis -> "hypothesis"
| Conjecture -> "conjecture"
;;
let rec string_of_formula = function
| Equal(t1, t2) -> "++equal(" ^ (string_of_term t1) ^ "," ^
(string_of_term t2) ^ ")"
| DisEqual(t1, t2) -> "--equal(" ^ (string_of_term t1) ^ "," ^
(string_of_term t2) ^ ")"
;;
let string_of_clause = function
| InputClause(s,t,[]) -> "input_clause(" ^ s ^ "," ^
(string_of_status t) ^ ",\n\t[ ])."
| InputClause(s,t,f::[]) -> "input_clause(" ^ s ^ "," ^
(string_of_status t) ^ ",\n\t[ " ^ (string_of_formula f) ^ " ])."
| InputClause(s,t,f::fl) -> "input_clause(" ^ s ^ "," ^
(string_of_status t) ^ ",\n\t[ " ^
(List.fold_left (fun s f -> s ^ ", " ^ (string_of_formula f))
(string_of_formula f) fl) ^ " ])."
;;