mirror of
https://github.com/google-deepmind/deepmind-research.git
synced 2026-05-09 21:07:49 +08:00
bf886c22bf
PiperOrigin-RevId: 360877125
54 lines
1.5 KiB
Racket
54 lines
1.5 KiB
Racket
#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/clause
|
|
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)))
|