\myheading{TAOCP 7.1.1 exercises 4 and 5} \renewcommand{\CURPATH}{synth/logic/TAOCP_711_4_and_5} Found this exercise in \href{http://www.cs.utsa.edu/~wagner/knuth/fasc0b.pdf}{TAOCP section 7.1.1 (Boolean basics)}: \begin{figure}[H] \centering \frame{\includegraphics[scale=0.7]{\CURPATH/page3.png}} \caption{Page 3} \end{figure} \begin{figure}[H] \centering \frame{\includegraphics[scale=0.7]{\CURPATH/page34.png}} \caption{Page 34} \end{figure} I'm not clever enough to solve this manually (yet), but I could try using logic synthesis, as I did before. As they say, ``machines should work; people should think''. The modified Z3Py script: \lstinputlisting[style=custompy]{\CURPATH/logic_for_TAOCP.py} My solution for NAND: \lstinputlisting{\CURPATH/nand.txt} My solution for NAND with 0/1 constants: \lstinputlisting{\CURPATH/nand_constants.txt} My solution for ANDN: \lstinputlisting{\CURPATH/andn.txt} My solution for ANDN with 0/1 constants: \lstinputlisting{\CURPATH/andn_constants.txt} Correct answers from \ac{TAOCP}: \begin{figure}[H] \centering \frame{\includegraphics[scale=0.7]{\CURPATH/page51.png}} \caption{Page 51} \end{figure} My solutions are slightly different: I haven't "pass through" instruction, so sometimes a value is copied from the input to the output using NAND/ANDN. Also, my versions are sometimes different, but correct and has the same length. % FIXME: bruteforce?