# Boolean expression simplification

Recognizing Boolean expressions that simplify is valuable while programming and on the AP CS A Exam. An expression that always evaluates to `true` or always evaluates to `false` is likely a logical error. Similarly, an expression that includes an irrelevant part is likely an error.

Identifying equivalent Boolean expressions is often tested on the AP CS A Exam multiple choice. The question is often phrased as “Which of the following is equivalent to … ?”

The exercises below are presented without multiple choice options. Each expression simplifies in some way, which is not always the case with Boolean expressions on the AP CS A Exam. Answers and explanations are available individually (linked with each exercise) and as a single page (linked at the end).

The expressions below imply the types of the variables. Problems on the AP CS A Exam typically explicitly specify types.

Simplify each expression, except when otherwise noted.

## Exercise 1

Distribute the not.

``````!(a && b && c)
``````

Exercise 1 solution

## Exercise 2

``````(a && b) && !(a && b)
``````

Exercise 2 solution

## Exercise 3

``````!((x < y) && (r >= s))
``````

Exercise 3 solution

## Exercise 4

``````(x > y) || (x <= y)
``````

Exercise 4 solution

## Exercise 5

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

Exercise 5 solution

## Exercise 6

``````(a || b) && a
``````

Exercise 6 solution

## Exercise 7

``````(a && b) || b
``````

Exercise 7 solution

## Exercise 8

``````(a && b) || (a && b)
``````

Exercise 8 solution

## Exercise 9

``````(a || b) || a
``````

Exercise 9 solution

## Exercise 10

``````(a || b) || !(a || b)
``````

Exercise 10 solution

## Exercise 11

``````!((x < y) || (q > r))
``````

Exercise 11 solution

## Exercise 12

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

Exercise 12 solution

## Exercise 13

Tell when the expression evaluates to `true`.

``````!(a || b)
``````

Exercise 13 solution

## Exercise 14

Tell when the expression evaluates to `true`.

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

Exercise 14 solution