The Language of Choice
codewords.recurse.com
codewords.recurse.com
~/src/github.com/darius/mccarthy-to-bryant (master)$ python
>>> from nway_logic import *
>>> A, B = Variable('A'), Variable('B')
>>> A
A
>>> B
B
>>> const0 = Constant(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Constant' is not defined
~/src/github.com/darius/mccarthy-to-bryant (master)$ python
Python 2.7.10 (default, Jul 13 2015, 12:05:58)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from dd import *
>>> A, B = Variable('A'), Variable('B')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "dd.py", line 27, in Variable
return build_node(rank, tuple(map(Constant, range(arity))))
File "utils.py", line 7, in memoized
result = memoized._memos[args] = f(*args)
File "dd.py", line 34, in __init__
for b in branches: assert rank < b.rank
AssertionError
>>>I've just backported the renaming to Constant into nway_logic, and that example should work unaltered now -- thanks!
For the second, the interface to the decision diagrams does not use variables with names, as explained under 'Systematic succinctness' and demoed in make_alu_inputs() -- I aimed for the simplest code that shows the ideas. But I think you're right that bdd.Variable should've been called something different from logic.Variable.
Product of sadly declining ambitions: first for SVG toys, which I'm incompetent at; then yesterday I was looking into converting the text into an iPython notebook to provide an easier way to interact with the code, and that turned out to be too hard under the deadline. I ended up pushing the article's code into this repo shortly after the article went live.
But the first draft of the article was already stuffed too full without even trying to go past propositional logic; it had to be cut, not expanded.