-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated invariant computation plugin
- Loading branch information
Ruediger Ehlers
committed
Apr 3, 2024
1 parent
ae09249
commit ab770fa
Showing
7 changed files
with
326 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env python3 | ||
# This script takes a DOT output as generated by | ||
# slugs and produces an equivalent Boolean expression | ||
# for the Boollab, which you can find at: | ||
# | ||
# https://www.ruediger-ehlers.de/boollab/ | ||
# | ||
# This allows you "play" with the boolean function | ||
# and analyze it manually, for instance | ||
# by reordering the variables manually until | ||
# the Boolean function becomes easier to comprehend. | ||
import os, sys | ||
|
||
# Read input file | ||
if len(sys.argv) < 2: | ||
print("Error: No input file given.",file=sys.stderr) | ||
sys.exit(1) | ||
allLines = [a.strip() for a in open(sys.argv[1],"r").readlines()] | ||
|
||
# Variables | ||
vars = [] | ||
nodeToVar = {} | ||
nodeListInOrder = [] | ||
for line in allLines: | ||
if line.startswith("{ rank = same;"): | ||
line = line[14:] | ||
lineparts = [a.strip() for a in line.split(";")] | ||
varName = lineparts[0][1:] | ||
varName = varName[0:varName.find("-")] | ||
if varName!="CONST NODES": | ||
vars.append(varName) | ||
for node in lineparts[1:]: | ||
if len(node)>0: | ||
node = node[1:len(node)-1] | ||
nodeToVar[node] = varName | ||
nodeListInOrder.append(node) | ||
|
||
# Output vars | ||
for var in vars: | ||
print("var "+var) | ||
|
||
# Nodes | ||
nodesIn = {} | ||
startFound = False | ||
for line in allLines: | ||
if line=="{ node [shape = box]; \"1\"; }}": | ||
startFound = True | ||
elif startFound: | ||
if line.find("->")!=-1: | ||
if line.find("[color=red];")!=-1: | ||
negated = True | ||
else: | ||
negated = False | ||
parts = line.split("\"") | ||
fromNode = parts[1] | ||
toNode = parts[3] | ||
if not toNode in nodesIn: | ||
nodesIn[toNode] = [] | ||
if negated: | ||
nodesIn[toNode].append("(!"+nodeToVar[fromNode]+" & n"+fromNode+")") | ||
else: | ||
nodesIn[toNode].append("("+nodeToVar[fromNode]+" & n"+fromNode+")") | ||
|
||
print("n"+nodeListInOrder[0]+" = 1") | ||
for node in nodeListInOrder[1:] + ["1"]: | ||
print("n"+node+" = "+"|".join(nodesIn[node])) | ||
|
||
print("printBDD n1") |
Oops, something went wrong.