-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
clause-format.rkt
52 lines (44 loc) · 1.49 KB
/
clause-format.rkt
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
#lang racket/base
;***************************************************************************************;
;**** Clause <-> String Conversions ****;
;***************************************************************************************;
;;; In a separate file because of cyclic dependencies with "tptp.rkt" if in "clause.rkt"
(require define2
racket/format
racket/list
racket/pretty
satore/tptp
satore/unification
text-table)
(provide (all-defined-out))
;; Returns a string representation of the clause.
;;
;; clause? -> string?
(define (clause->string cl)
((if (*tptp-out?*)
clause->tptp-string
~a)
(Vars->symbols cl)))
;; Same as clause->string but pretty prints the result for better reading.
;;
;; clause? -> string?
(define (clause->string/pretty cl)
(pretty-format (Vars->symbols cl)))
;; clause? -> void?
(define (print-clause cl)
(displayln (clause->string cl)))
;; Prints the list of clauses in a table, possibly sothing them first.
;;
;; cls : (listof clause?)
;; sort? : boolean?
(define (print-clauses cls #:? [sort? #false])
(unless (empty? cls)
(print-table
(for/list ([cl (in-list (if sort?
(sort cls < #:key tree-size #:cache-keys? #true)
cls))]
[i (in-naturals)])
(cons i (Vars->symbols cl)))
#:border-style 'space
#:row-sep? #false
#:framed? #false)))