• entries
36
• comment
1
• views
239

# Boolean Algebra and De Morgan’s Laws

115 views

## Not ( Having a Computer Science Background )

The FileMaker developer community seems to consist of people with quite a wide range of backgrounds, much more so than is the case with developers from other programming languages and software development platforms. I suspect this is a consequence of the rapid application development (RAD) nature of the platform and its lower learning curve. This makes it possible for individuals to change course in their careers once they serendipitously encounter FileMaker and see how easy and fun software development can be.

## Boolean Algebra

This blog post is intended to provide one small, tiny lesson that I recall from one of my computer science classes (taken long ago). The "lesson" has to do with Boolean algebra which describes the rules for how Boolean operators (AND, OR, NOT) are evaluated.

One of my colleagues, someone who has taken up FileMaker development just a few months ago, recently asked me the following question:

Can a long chain of Boolean operations like the one below be simplified somehow by extracting the negations (the "not's") out of the expression:
not A and not B and not C and not D

## De Morgan's Laws

To find out the answer, we have to learn about De Morgan's laws. There are two of them:

1. not (A or B) = not A and not B
2. not (A and B) = not A or not B

With this knowledge under our belt, we can now rewrite the original expression as:

`not ( A or B or C or D )`

## The "Hide object when" calculation

There are occasions when it's easier to think about when something should be false instead of when it should be true. An example of this is the "Hide object when" FileMaker calculation. For me, it's much easier to think about when an object should be displayed instead of when it should be hidden.

The De Morgan's laws are very useful in these situations. For instance, suppose we have the following expression for when an object should be shown:

`( not A or not B ) and ( not C or not D )   // display object`

I can negate this so that it can be used in the "Hide object when" calculation.

```not ( ( not A or not B ) and ( not C or not D ) ) // hide object
= not ( not A or not B ) or not ( not C or not D )
= ( A and B ) or ( C and D )```

Of course, we could have just kept it as this:

`not ( ( not A or not B ) and ( not C or not D ) )   // hide object`

I tend to go with whichever one I think will be easier to understand later on, in case I (or some other developer) have to return to this calculation down the road.

## References

The post Boolean Algebra and De Morgan’s Laws appeared first on Soliant Consulting.

There are no comments to display.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.