Skip to content

Commit

Permalink
lib/render-proof-tree: Small python script for extracting tree structure
Browse files Browse the repository at this point in the history
  • Loading branch information
nishantjr committed Feb 11, 2020
1 parent 89bebf8 commit b80c422
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions prover/lib/render-proof-tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python

from anytree import NodeMixin, Node, RenderTree
from collections import namedtuple
import textwrap
import fileinput
import re


class Goal(NodeMixin):
def __init__(self, id, parent_id):
self.id = id
self.name = id
self.parent_id = parent_id
self.claim = None

nodes = {}
roots = []

for line in fileinput.input():
match = re.search(' *active: \w*, id: (\w*\d*), parent: (\.|\w*\d*)', line)
if not match is None:
id = match.group(1)
parent = match.group(2)
node = Goal(id, parent)
nodes[id] = node
if parent == '.': roots += [node]
match = re.search('implies', line)
if not match is None:
node.claim = line

for id, node in nodes.items():
if node in roots: continue
node.parent = nodes[node.parent_id]

for pre, fill, node in RenderTree(roots[0]):
print(pre, 'id: ', node.id, 'x')
# if not node.claim is None:
# print(('\n' + fill).join(textwrap.wrap('claim: ' + node.claim)))

0 comments on commit b80c422

Please sign in to comment.