4 min readβ’december 21, 2022

Athena_Codes

Milo Chang

Sometimes there are multiple ways to represent the same boolean expression. To show that they are the same expression, either prove that they can be simplified to the same expression using boolean properties and identities or prove that they can be the same in all cases.

We can simplify one boolean expression to another in order to show that the two expressions are equivalent. To do so, we will use **boolean properties, identities,** and **theorems**. You do NOT need to memorize these, as we will do an easier formulaic way after.

For boolean values a, b, and c, we have the following:

- a && false == false
- a && true == a
- a && a == a
- a && !a == false
- a || false == a
- a || true == true
- a || a == a
- a || !a == true
- !(!a) == a (The inverse of an inverse is the original value)

- a || (!a && b) == a || b
- a || (!a && !b) == a || !b
- !a || (a && b) == !a || b
- !a || (a && !b) == !a || !b

- a && b == b && a
- a || b == b || a

- a && (b && c) == (a && b) && c
- a || (b || c) == (a || b) || c

- a && (b || c) == (a && b) || (a && c)

- !(a && b) == !a || !b
- !(a || b) == !a && !b

We can use these properties to simplify boolean expressions. This example is probably more complicated than what you would see on the exam, but it still serves as a good guide:

```
!a && b && c || a && !b && c || a && b && !c || a && b && c
= !a && b && c || a && b && c || a && b && !c || a && !b && c (Commutative Law)
= (!a || a) && b && c || a && b && !c || a && !b && c (Distributive Law)
= (true) && b && c || a && b && !c || a && !b && c (Basic Theorem 8)
= b && c || a && b && !c || a && !b && c (Basic Theorem 2)
= b && (c || a && !c) || a && !b && c (Distributive Law)
= b && (c || !c && a) || a && !b && c (Commutative Law)
= b && (c || a) || a && !b && c (Consensus Theorem)
= b && c || b && a || a && !b && c (Distributive Law)
= b && c || a && (b || !b && c) (Distributive Law)
= b && c || a && (b || c) (Consensus Theorem)
=
```

`b && c || a && b || a && c. `

`(Distributive Law)`

In this simplification, every row is equivalent to the first row due to boolean properties. However, this can get a little messy at times, as seen above, so we have... *drumroll please...*

Sometimes, the simplification of a boolean expression may not be obvious, so we can test all possible cases of input in a boolean expression to get all possible outputs. If the outputs of two boolean statements are all the same, then these two statements are equivalent. We can do this with truth tables, which are a methodical way to organize these.

Here is a truth table for !a && b || !a && !b:

a | b | !a | !b | !a && b | !a && !b | !a && b || !a && !b |

False | False | True | True | False | True | True |

False | True | True | False | True | False | True |

True | False | False | True | False | False | False |

True | True | False | False | False | False | False |

Note that this expression evaluates to true any time

`a`

is false, so an equivalent boolean expression for this is simply `!a`

.As for the structure of the truth table, the leftmost columns are the inputs with the number of rows dictated by the possible number of inputs. The following columns represent the evaluation of the boolean expression step by step according to the boolean order of operations. Once you become more familiar with these operations, you can skip some of the columns, but it's better to keep all of the columns to be safe.

Here is a truth table for (!a || b) && (!a || !b):

a | b | !a | !b | !a || b | !a || !b | (!a || b) && (!a || !b) |

False | False | True | True | True | True | True |

False | True | True | False | True | True | True |

True | False | False | True | False | True | False |

True | True | False | False | True | False | False |

Note that this expression also evaluates to true any time

`a`

is false, so an equivalent boolean expression for this is also `!a`

.Browse Study Guides By Unit

βUnit 1 β Primitive Types

π±Unit 2 β Using Objects

π₯Unit 3 β Boolean Expressions & if Statements

- Proof By Simplification
- Basic Theorems
- Consensus Theorems (Nice to know, but not required)
- Commutative Law (boolean AND and OR are commutative)
- Associative Law (boolean AND and OR are associative)
- Distributive Law (boolean AND distributes over boolean OR)
- DeMorgan's Theorems (Important to know) (boolean NOT does not distribute over boolean OR or AND)
- Proof By Testing All Cases
- Truth Table Example 1
- Truth Table Example 2

πΉUnit 4 β Iteration

βοΈUnit 5 β Writing Classes

βοΈUnit 6 β Array

πΎUnit 7 β ArrayList

π»Unit 8 β 2D Array

π²Unit 9 β Inheritance

π±Unit 10 β Recursion

Β© 2024 Fiveable Inc. All rights reserved.