forked from google-deepmind/deepmind-research
-
Notifications
You must be signed in to change notification settings - Fork 0
/
json-output.rkt
69 lines (63 loc) · 2.02 KB
/
json-output.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#lang racket/base
;***************************************************************************************;
;**** Json Output ****;
;***************************************************************************************;
(require racket/dict
racket/string)
(provide (all-defined-out))
;; Correspondance with Eprover output values
(define status-dict
'((running . UNSPECIFIED_PROOF_STATUS)
(refuted . REFUTATION_FOUND)
(time . TIME_LIMIT_REACHED)
(memory . MEMORY_LIMIT_REACHED)
(steps . STEP_LIMIT_REACHED)
(saturated . COUNTER_SATISFIABLE)))
;; Take a result dictionary from `saturation` and returns a JSON string representation of it.
;;
;; dict? -> string?
(define (saturation-result->json res)
(define d
(let* ([res (dict-remove res 'name)]
[res (dict-remove res 'file)]
[res (dict-update res 'status (λ (v) (dict-ref status-dict v)))])
res))
(string-join
#:before-first "{\n "
(for/list ([(k v) (in-dict d)])
(define kstr (regexp-replace* #px"-|:" (symbol->string k) "_"))
(format "~s: ~s" kstr (if (symbol? v) (symbol->string v) v)))
",\n "
#:after-last "\n}"))
;; Simple visual test.
(module+ drracket
(define res
'((name . "GEO170+1.p")
(file . "data/tptp_geo/GEO170+1.p")
(status . refuted)
(steps . 205)
(generated . 3186)
(actives . 106)
(candidates . 2651)
(priority-remaining . 0)
(tautologies . 156)
(rules . 30)
(unit-rules . 24)
(binary-rules . 6)
(binary-rules-static . 0)
(binary-rules-dynamic . 6)
(binary-rewrites . 164)
(forward-subsumed . 96)
(backward-subsumed . 0)
(subsumes-checks . 7654)
(subsumes-steps . 13268)
(subsumes-breaks . 0)
(L-resolvent-pruning . 0)
(memory . 181509744)
(time . 196)
(proof-length . 12)
(proof-inferences . 5)
(proof-type:in . 7)
(proof-type:res . 4)
(proof-type:rw . 1)))
(displayln (saturation-result->json res)))