22 lines
518 B
Markdown
22 lines
518 B
Markdown
## anf.py
|
|
|
|
Takes a boolean expression with 'not' (!) 'and' (AND) and 'or' (OR) in input and outputs its simplified ANF form (with XOR (⊕) and AND (⸱)).
|
|
|
|
#### example:
|
|
|
|
input:
|
|
```
|
|
!X11 AND (!X3 AND !X4 OR X3 AND X4 OR X3 AND !X4 AND X12) OR X11 AND !X12 AND (X3 OR X4)
|
|
```
|
|
input (using '+' for or and '*' for and):
|
|
```
|
|
!X11*(!X3*!X4+X3*X4+X3*!X4*X12)+X11*!X12*(X3+X4)
|
|
```
|
|
|
|
output:
|
|
```
|
|
1⊕X11⊕X3⊕X4⊕(X3⸱X12)⊕(X4⸱X11⸱X12)⊕(X3⸱X4⸱X11)⊕(X3⸱X4⸱X12)
|
|
```
|
|
|
|
*term order may differ a little*
|