https://slides.com/georgelee/ics141-predicates-quantifiers/live
// What are the preconditions and postconditions?
public void start() {
if (!this.isStarted()) {
this.started = true;
} else {
throw new Exception("Already started");
}
}
When is this true? When is this false?
Set of values which we can use to quantify our function/expression. Must be stated in order to use a quantifier. Examples include "real numbers", "imaginary numbers", "users in the database", etc.
Domains can be restricted, too. For example "Given all real numbers x where x > 3" or "Given all users in the database where role = 'admin'"
For all values in a given domain, P(x) is true. Denoted as "∀". If there is an x in the domain for which P(x) is false, that value is a counterexample of "∀x P(x)".
Another way to think about it: Given (x1, x2, x3, ... xn), the universal quantification ∀x P(x) is the same as:
P(x1) ^ P(x2) ^ P(x3) ^ ... ^ P(xn)
For at least one value in a given domain, P(x) is true. Denoted as "∃". If the statement "∃x P(x)" is false for all x in the domain, then the statement is false.
Another way to think about it: Given (x1, x2, x3, ... xn), the existential quantification ∃x P(x) is the same as:
P(x1) v P(x2) v P(x3) v ... v P(xn)