Propositional logic lets us express complex propositions in terms of their constituent parts (atomic propositions) joined by connectives.
Predicate logic lets us express how propositions depend on the objects they mention.
Key notions in predicate logic
Syntax
Predicate logic extends propositional logic with two key constructs: predicates and quantifiers ($\exists,\forall$).
Semantics
We define the meaning of formulas in predicate logic with respect to a domain of discourse.
Predicates
Predicate is a function that returns a truth value.
Cat(x) $::=$ “x is a cat”
Prime(x) $::=$ “x is prime”
HasTaken(x, y) $::=$ “student x has taken course y”
LessThan(x, y) $::=$ “x < y”
Sum(x, y, z) $::=$ “x + y = z”
GreaterThan5(x) $::=$ “x > 5”
HasNChars(s, n) $::=$ “string s has length n”
Predicates can have varying arity (numbers of arguments).
Domain of discourse
To give meaning to predicates in a formula, we define a set of objects
that those predicates can take as input.
This set of objects is called the domain of discourse for a formula.
For each of the following, what might the domain be?
“x is a cat”, “x barks”, “x ruined my couch”
“mammals” or “sentient beings” or “cats and dogs” or …
“x is prime”, “x = 0”, “x < 0”, “x is a power of two”
“numbers” or “integers” or “integers greater than 5” or …
“student x has taken course y” “x is a pre-req for z”
“students and courses” or “university entities” or …
Quantifiers
Quantifiers let us talk about all or some objects in the domain.
$\forall x. P(x)$
$P(x)$ is true for every $x$ in the domain.
Read as “for all $x$, $P(x)$”.
Called the universal quantifier.
$\exists x. P(x)$
There is an $x$ in the domain for which $P(x)$ is true.
Read as “there exists $x$, $P(x)$”.
Called the existential quantifier.
Universal quantifier $\forall$
$\forall x. P(x)$
$P(x)$ is true for every $x$ in the domain.
Examples: are these true?
$\forall x. \text{Odd}(x)$
$\forall x. \text{LessThan5}(x)$
Depends on the domain.
$\{-3, 3\}$
Integers
Odd Integers
$\forall x. \text{Odd}(x)$
True
False
True
$\forall x. \text{LessThan5}(x)$
True
False
False
You can think of $\forall x. P(x)$ as conjunction over all objects in the domain.
$\forall x. \text{Odd}(x)$
over $\{-3, 3\}$ is the conjunction $\text{Odd}(-3)\wedge\text{Odd}(3)$
over integers is the infinite conjunction $\ldots\wedge\text{Odd}(-1)\wedge\text{Odd}(0)\wedge\text{Odd}(1)\wedge\ldots$
Existential quantifier $\exists$
$\exists x. P(x)$
There is an $x$ in the domain for which $P(x)$ is true.
Examples: are these true?
$\exists x. \text{Odd}(x)$
$\exists x. \text{LessThan5}(x)$
Depends on the domain.
$\{-3, 3\}$
Integers
Positive Multiples of 5
$\exists x. \text{Odd}(x)$
True
True
True
$\exists x. \text{LessThan5}(x)$
True
True
False
You can think of $\exists x. P(x)$ as disjunction over all objects in the domain.
$\exists x. \text{Odd}(x)$
over $\{-3, 3\}$ is the disjunction $\text{Odd}(-3)\vee\text{Odd}(3)$
over integers is the infinite disjunction $\ldots\vee\text{Odd}(-1)\vee\text{Odd}(0)\vee\text{Odd}(1)\vee\ldots$
Statements with quantifiers
Just like with propositional logic, we need to define variables (this time predicates).
And we must also now define a domain of discourse.
What is the truth value of these statements?
$\exists x. \text{Even}(x)$
T
$\forall x. \text{Odd}(x)$
F
$\forall x. \text{Even}(x)\vee\text{Odd}(x)$
T
$\exists x. \text{Even}(x)\wedge\text{Odd}(x)$
F
$\forall x. \text{Greater}(x+1,x)$
T
$\exists x. \text{Even}(x)\wedge\text{Prime}(x)$
T
Domain of discourse
Positive integers
Predicate definitions
Even(x) $:=$ “x is even”
Odd(x) $:=$ “x is odd”
Prime(x) $:=$ “x is prime”
Greater(x, y) $:=$ “x > y”
Equal(x, y) $:=$ “x = y”
Sum(x, y, z) $:=$ “z = x + y”
Predicate logic to English
Translate the following statements to English
$\forall x. \exists y. \text{Greater}(y, x)$
For every positive integer $x$, there is a positive integer $y$, such that $y > x$.
$\forall x. \exists y. \text{Greater}(x, y)$
For every positive integer $x$, there is a positive integer $y$, such that $x > y$.
$\forall x. \exists y. \text{Greater}(y, x)\wedge\text{Prime}(y)$
For every positive integer $x$, there is a positive integer $y$, such that $y > x$ and $y$ is prime.