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 2
(a && b) && !(a && b)
Exercise 3
!((x < y) && (r >= s))
Exercise 4
(x > y) || (x <= y)
Exercise 5
(a && b) && (!a || !b)
Exercise 6
(a || b) && a
Exercise 7
(a && b) || b
Exercise 8
(a && b) || (a && b)
Exercise 9
(a || b) || a
Exercise 10
(a || b) || !(a || b)
Exercise 11
!((x < y) || (q > r))
Exercise 12
(a || b) && (!a && !b)
Exercise 13
Tell when the expression evaluates to true
.
!(a || b)
Exercise 14
Tell when the expression evaluates to true
.
(a || b) && (!a || !b)
Solutions & comments
See the Boolean expression simplification solutions or review them with AP CS Tutor Brandon Horn.