Article 6D09Q Boolean function minimization with AI

Boolean function minimization with AI

by
John
from John D. Cook on (#6D09Q)

karnaugh_gpt.png

I was curious how well LLMs would do at minimizing a Boolean expression, that is, taking a Boolean expression and producing a smaller equivalent expression.

I didn't expect good performance because this problem is more about logic than recall, but sometimes LLMs surprise you, so I wanted to give it a chance. I thought it might accomplish some reduction in size though not as much as possible. Let's see what it did.

Prompt

My prompt for the three platforms I tried-GPT4All, ChatGPT, and Google Bard-was

Minimize the boolean expression ABCD + ABCD + ABCD + ABCD + ABCD + ABCD + ABCD + ABCD

I knew the expression could be minimized to

BCD + AD + AC.

GPT4All

I first tried GPT4All using the Groovy data set. It crashed immediately. I tried a few variations on the same prompt and it crashed right away every time.

This was on a MacBook Pro. I didn't try it on Windows or Linux.

ChatGPT

I'll go through ChatGPT's response a little at a time.

To minimize the given boolean expression ABCD + ABCD + ABCD + ABCD + ABCD + ABCD + ABCD + ABCD, we can use Karnaugh maps or Boolean algebra simplification techniques. I'll demonstrate both methods.

This is a sensible start. Karnaugh maps are a common classroom technique for solving small Boolean minimization problems, so there were lots of examples of Karnaugh maps in the data scraped to train ChatGPT.

Next ChatGPT draws a Karnaugh map. The screenshot at the top of the post was from a different experiment, a version of the experiment described here but containing an error on my part. This problem produced a black image simply containing CD" but also contained a Karnaugh map in text. Cleaning up the formatting we get the following.

 | 00 | 01 | 11 | 10 | 00 | 1 | 0 | 1 | 0 | 01 | 1 | 1 | 1 | 1 | 11 | 1 | 1 | 1 | 1 | 10 | 0 | 1 | 0 | 0 | 

This is nonsense. Nine out of sixteen entries are wrong.

ChatGPT concludes

Grouping the adjacent 1's in the Karnaugh map, we can simplify the expression to: AC + AD + AB + ACD

This is also nonsense. It does not correctly solve the original problem, nor does it solve the problem corresponding to the incorrect Karnaugh map above.

Next let's see how it does with Boolean algebra. It starts out OK.

Boolean Algebra Method: We can simplify the expression using Boolean algebra identities and rules.

ABCD + ABCD + ABCD + ABCD + ABCD + ABCD + ABCD + ABCD

Rearranging the terms: ABCD + ABCD + ABCD + ABCD + ABCD + ABCD + ABCD + ABCD

Grouping the terms: ABCD + ABCD + ABCD + ABCD + ABCD + ABCD + ABCD

Combining like terms: (A + A)BCD + (A + A)BCD + ABCD + (A + A)BCD + ABCD + ABCD + ABCD

These steps haven't accomplished anything, but they're not wrong. Then it goes off the rails.

Using the complement law A + A = 1: BCD + BCD + ABCD + BCD + ABCD + ABCD + ABCD

The explanation is wrong and the solution is wrong.

The solution is completely wrong, but it looks plausible. At first glance I thought it might be right, or more right than it was. If you were making a movie and you needed to generate electrical engineering homework, this would be adequate for a realistic-looking homework solution.

Google Bard

Google Bard gives a more succinct solution with five steps:

  1. Identify the common terms in the expression. The common terms are ABCD, ABCD, and ABCD.
  2. Combine the common terms. This gives us the expression (ABCD + ABCD + ABCD) + (ABCD + ABCD).
  3. Apply the distribution property. This gives us the expression ABCD + ABCD + ABCD + ABCD + ABCD.
  4. Identify the redundant terms. The redundant terms are ABCD and ABCD.
  5. Remove the redundant terms. This gives us the expression ABCD + ABCD.

This too is nonsense.

The post Boolean function minimization with AI first appeared on John D. Cook.
External Content
Source RSS or Atom Feed
Feed Location http://feeds.feedburner.com/TheEndeavour?format=xml
Feed Title John D. Cook
Feed Link https://www.johndcook.com/blog
Reply 0 comments