Skip to content

Commit b80c422

Browse files
committed
lib/render-proof-tree: Small python script for extracting tree structure
1 parent 89bebf8 commit b80c422

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

prover/lib/render-proof-tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env python
2+
3+
from anytree import NodeMixin, Node, RenderTree
4+
from collections import namedtuple
5+
import textwrap
6+
import fileinput
7+
import re
8+
9+
10+
class Goal(NodeMixin):
11+
def __init__(self, id, parent_id):
12+
self.id = id
13+
self.name = id
14+
self.parent_id = parent_id
15+
self.claim = None
16+
17+
nodes = {}
18+
roots = []
19+
20+
for line in fileinput.input():
21+
match = re.search(' *active: \w*, id: (\w*\d*), parent: (\.|\w*\d*)', line)
22+
if not match is None:
23+
id = match.group(1)
24+
parent = match.group(2)
25+
node = Goal(id, parent)
26+
nodes[id] = node
27+
if parent == '.': roots += [node]
28+
match = re.search('implies', line)
29+
if not match is None:
30+
node.claim = line
31+
32+
for id, node in nodes.items():
33+
if node in roots: continue
34+
node.parent = nodes[node.parent_id]
35+
36+
for pre, fill, node in RenderTree(roots[0]):
37+
print(pre, 'id: ', node.id, 'x')
38+
# if not node.claim is None:
39+
# print(('\n' + fill).join(textwrap.wrap('claim: ' + node.claim)))
40+

0 commit comments

Comments
 (0)