nobody's blog


logidiff - library and website to determine if two logical statements are equivalent


Margret Riegert14 Jan 2022

blog@eowyn.net - views


This past Fall, I was a teacher’s assistant (TA) for a digital logic class that starts with the basics of digital logic gates and builds up to synthesizing VHDL to an Upduino. This was the second time I’ve been a TA and it’s definitely a lot of fun running lab sections and grading student’s assignments.

To assist myself in grading assignments, specifically with double-checking their work with simplifying logic statements, I wrote logidiff. With this tool, I could enter in the student’s answer, the correct answer, and determine if they were equivalent and for which cases they weren’t. This saved me significant time in grading, and so I released it in hopes that it may be beneficial to others as well.

It operates on a quirk of Python: Infix operations. I used these to create custom operators, as Python doesn’t have bitwise XNOR and NOR (among others) and I was too lazy to try to parse the input to use normal Python functions. I’ve used these in the past for parsing in VHDLproc. All of the operators were replaced with infix operators to preserve order of operations, then all possible values for each variable and whether it evaluates properly are brute forced and the results are given. I also added aliases for *, +, !, and ^.

To make it dead-simple to use, I decided to try experimenting with Brython to integrate it into a website, that way anyone could use it without having to have the correct Python installation. With only minor modifications, and a very small amount of HTML/CSS/Javascript, I had a website up and running. It’s currently available here.

Logidiff website



© 2020-2024 Margret Riegert
Unless otherwise noted, content is under a CC BY 4.0 license.