guide to first-order logic...
TRANSCRIPT
![Page 1: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/1.jpg)
Guide to First-Order Logic Translations
![Page 2: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/2.jpg)
Hi everybody!
![Page 3: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/3.jpg)
In last Friday's lecture, we talked abouthow to translate statements from English
into frst-order logic.
![Page 4: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/4.jpg)
Translating into logic is a skill that takessome practice to get used to, but onceyou get the hang of it, it's actuallynot too bad – and honestly it can be
a lot of fun!
![Page 5: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/5.jpg)
In many ways, learning how to translateinto frst-order logic is like learning
how to program.
![Page 6: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/6.jpg)
You've got this crazy set of symbols andterms with precise meanings.
∀
∃
→
∧
=
∨
P(x)
Q(x, y)
R(x)
S(y)
![Page 7: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/7.jpg)
.and the goal is combine them togetherin a way that says something interesting.
∀x. (P(x) ∨ R(x) → ∃y. (S(y) ∧ Q(x, y)))
![Page 8: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/8.jpg)
The good news is that, like programming,there are a lot of common patterns thatcome up time and time again in frst-
order logic.
![Page 9: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/9.jpg)
Once you've gotten the handle on thesepatterns and the methodology of how todo a translation, you'll fnd that it's
a lot easier to approach logic translations.
![Page 10: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/10.jpg)
Let's illustrate this with an analogy.
![Page 11: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/11.jpg)
Take a look at this Java code.
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 12: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/12.jpg)
This is a method that takes in an arrayof integers and returns the sum of the
elements in that array.
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 13: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/13.jpg)
Let's focus on this for loop.
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 14: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/14.jpg)
If you've been programming for a while,you can look at this loop and pretty quicklyread it as “loop over the elements of an
array” loop.
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 15: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/15.jpg)
There's actually a lot going on in thisloop, though.
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 16: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/16.jpg)
There's a variable declaration herethat makes a new variable that tracks
an index.
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 17: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/17.jpg)
.there's an increment operator used toadvance that index through the array.
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 18: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/18.jpg)
.a selection statement that picks out asingle array element by using the variable
we declared in the loop.
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 19: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/19.jpg)
.and a test to see whether we've readeverything that relies specifcally on usingthe < operator and not other operators
like == or <=.
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 20: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/20.jpg)
When you're frst learning to program,code like this can seem really, reallycomplicated, but when you've beenprogramming for a while you don't
think about it that much.
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 21: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/21.jpg)
It's just “idiomatic” code – you know whatit does by sight even if you don't think
too hard about what it means.
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 22: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/22.jpg)
In many ways, frst-order logic formulasare the same way.
![Page 23: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/23.jpg)
∀p. (Person(p) → ∃q. (Person(q) ∧ p ≠ q ∧
Loves(p, q))
) Here's a frst-order logic formulafrom lecture. It objectively has a lot
of symbols strewn throughout it.
![Page 24: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/24.jpg)
∀p. (Person(p) → ∃q. (Person(q) ∧ p ≠ q ∧
Loves(p, q))
) However, once you've gotten the hangof the idiomatic frst-order logic
patterns, you'll see that this actuallyisn't that bad!
![Page 25: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/25.jpg)
∀p. (Person(p) → ∃q. (Person(q) ∧ p ≠ q ∧
Loves(p, q))
)If you tried to build this formula
completely from scratch, it would bereally challenging. However, if you know thepatterns and how to string them together,this is a very natural formula to write.
![Page 26: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/26.jpg)
∀p. (Person(p) → ∃q. (Person(q) ∧ p ≠ q ∧
Loves(p, q))
)This guide is designed to teach youwhat these common patterns are, howto combine them together, and how to
use them to translate complicatedstatements.
![Page 27: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/27.jpg)
∀p. (Person(p) → ∃q. (Person(q) ∧ p ≠ q ∧
Loves(p, q))
)Think of it as a crash course infrst-order logic programming.
![Page 28: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/28.jpg)
∀p. (Person(p) → ∃q. (Person(q) ∧ p ≠ q ∧
Loves(p, q))
)With that said, let's get started!
![Page 29: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/29.jpg)
Most of the time, when you're writingstatements in frst-order logic, you'llbe making a statement of the form
“every X has property Y” or “some X hasproperty Y.”
![Page 30: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/30.jpg)
Statements of these (usually) fall intoone of four fundamental types of
statements.
![Page 31: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/31.jpg)
These four classes of statements are calledAristotelian Forms, since they were frst describedby Aristotle in his work “Prior Analytics” . thoughyou don't need to know that unless you want to
show of at cocktail parties. ^_^
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
![Page 32: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/32.jpg)
On Wednesday, we saw how to translate these statements intofrst-order logic. Here's what we came up with.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
![Page 33: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/33.jpg)
In lecture we spent time talking about why gets∀
paired with and why gets paired with . We already talked→ ∃ ∧
in lecture about why this is, so we're not going to review ithere. After all, our goal is to see how to use these
patterns, not how to derive them.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
![Page 34: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/34.jpg)
However, you absolutely should memorize these patterns.They're like the “loop over an array” for loop pattern in
Java, C, or C++ – they come up frequently and you ultimatelywant to get to the point where you can easily read and
write them as a unit.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
![Page 35: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/35.jpg)
Now, let's see how we can use these four statementsas building blocks for constructing larger statements.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
![Page 36: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/36.jpg)
Imagine that we have these predicates available to usto use.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 37: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/37.jpg)
.and that we want to translate this statement intofrst-order logic.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Every orange cat is fluffy.
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 38: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/38.jpg)
Let's see how we can use these formulas to helpout our translation.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Every orange cat is fluffy.
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 39: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/39.jpg)
First, what kind of statement is this?
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Every orange cat is fluffy.
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 40: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/40.jpg)
It seems to look a lot like this one – we're saying thatall objects of one kind (orange cats) are also of
another kind (fufy).
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Every orange cat is fluffy.
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 41: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/41.jpg)
Based on that.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Every orange cat is fluffy.
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 42: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/42.jpg)
.we can start adding in a bit of structure to ourfrst-order logic formula.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is an orange cat → x is fluffy)
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 43: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/43.jpg)
From here, our goal is to keep replacing the remainingEnglish statements in the formula with something in
frst-order logic that says the same thing.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is an orange cat → x is fluffy)
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 44: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/44.jpg)
For example, this part of the formula is easy totranslate.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is an orange cat → x is fluffy)
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 45: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/45.jpg)
.because we have a predicate that directly expressesthis idea!
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is an orange cat → x is fluffy)
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 46: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/46.jpg)
So let's go and snap that predicate in there.Progress!
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is an orange cat → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 47: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/47.jpg)
So what about the rest of the formula? How do weexpress the idea that x is an orange cat?
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is an orange cat → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 48: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/48.jpg)
Well, we have two independent predicates – Orange(x)and Cat(x) – that each express a part of the idea.
How can we combine them together?
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is an orange cat → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 49: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/49.jpg)
Let's begin by seeing how not to do this.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is an orange cat → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 50: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/50.jpg)
I'm going to put up our trusty warning indicators toshow that what we're about to do is a really bad
idea.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is an orange cat → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
⚠ ⚠
![Page 51: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/51.jpg)
Here's something common we see people do thatdoesn't work,
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (Orange(Cat(x)) → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
⚠ ⚠
![Page 52: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/52.jpg)
This superfcially looks like it works correctly – it seemslike it's saying that x is a cat that's orange.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (Orange(Cat(x)) → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
⚠ ⚠
![Page 53: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/53.jpg)
The problem is that it's not syntactically valid – it's thesort of mistake that would be a “compiler error” in
many languages.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (Orange(Cat(x)) → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
⚠ ⚠
![Page 54: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/54.jpg)
The reason this doesn't work is that Orange and Catare predicates – they take in objects and produce either
true or false.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (Orange(Cat(x)) → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
⚠ ⚠
![Page 55: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/55.jpg)
This means that the statement Cat(x) evaluates toeither “true” or “false.” Intuitively, it takes in an
object and returns a boolean.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (Orange(Cat(x)) → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
⚠ ⚠
boolean
![Page 56: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/56.jpg)
The problem is that Orange expects that it will take inan object and return a boolean – but it's not being
provided an object as input!
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (Orange(Cat(x)) → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
⚠ ⚠
boolean
![Page 57: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/57.jpg)
This is the frst-order logic equivalent of a typeerror.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (Orange(Cat(x)) → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
⚠ ⚠
boolean
![Page 58: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/58.jpg)
So even though this might at frst glance seem right,it's not actually legal. so we're going to have to
fnd some other way of expressing this idea!
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (Orange(Cat(x)) → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
⚠ ⚠
boolean
![Page 59: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/59.jpg)
Let's revert back to what we had before.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is an orange cat → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 60: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/60.jpg)
We're trying to express the idea that x is an orangecat.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is an orange cat → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 61: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/61.jpg)
If you think about it, that's the same as saying thatx is an orange and that x is a cat.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is orange and x is a cat → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 62: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/62.jpg)
This is something that's a lot easier to translate intofrst-order logic.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is orange and x is a cat → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 63: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/63.jpg)
The “and,” for example, just becomes a ∧connective.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (x is orange ∧ x is a cat → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 64: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/64.jpg)
And, given the predicates we have available, we cantranslate the left and right halves of that expression
directly into frst-order logic.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (Orange(x) ∧ Cat(x) → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 65: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/65.jpg)
Tada! We're done.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (Orange(x) ∧ Cat(x) → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 66: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/66.jpg)
Although this wasn't a particularly complicated example,especially compared to what we did in class the other
day, I do think it's helpful to see where it comes from,since we walked through it step-by-step.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (Orange(x) ∧ Cat(x) → Flufy(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 67: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/67.jpg)
Hopefully that wasn't too bad! Let's go and do anotherone.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Orange(x)Cat(x)
Flufy(x)
Available Predicates:
![Page 68: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/68.jpg)
Let's change our available set of predicates so that wecan talk about whether something's a corgi, whether
something's a person, and whether one thing xloves another thing y.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
![Page 69: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/69.jpg)
With these predicates, let's see how to translatethis statement into frst-order logic.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
There's a corgi that loves everyone.
![Page 70: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/70.jpg)
Again, we can start of by asking what kind of statementthis is. What exactly is it that we're talking about here?
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
There's a corgi that loves everyone.
![Page 71: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/71.jpg)
Fundamentally, we're saying that somewhere out there inthe vast, magical world we live in, there is a corgi that
has some specifc set of properties.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
There's a corgi that loves everyone.
![Page 72: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/72.jpg)
(Specifcally, the corgi has the property that it loveseveryone!)
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
There's a corgi that loves everyone.
![Page 73: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/73.jpg)
That statement looks a lot like this one over here – we'resaying that some corgis happen to love everyone.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
There's a corgi that loves everyone.
![Page 74: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/74.jpg)
We'll partially translate our statement by using thatgeneral pattern.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (x is a corgi ∧ x loves everyone)
![Page 75: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/75.jpg)
As before, we'll continue to make incremental progresstranslating bits and pieces of this formula until we
arrive at the fnal result.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (x is a corgi ∧ x loves everyone)
![Page 76: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/76.jpg)
For example, we can directly express the idea that x isa corgi, so let's go do that.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧ x loves everyone)
![Page 77: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/77.jpg)
Now, we have to think about how to translate thestatement “x loves everyone.”
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧ x loves everyone)
![Page 78: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/78.jpg)
It's not immediately clear how to do this given thefour general forms we have above. This means that
we need to think a bit before we move on.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧ x loves everyone)
![Page 79: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/79.jpg)
When translating statements like these, it sometimes helpsto introduce variables representing names for things.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧ x loves everyone)
![Page 80: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/80.jpg)
So, for example, we could rewrite “x loves everyone” to“x loves every person y.”
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧ x loves every person y)
![Page 81: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/81.jpg)
This is suggesting that we're probably going to want touse one of the templates on the left, since thisstatement says something about every person y.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧ x loves every person y)
![Page 82: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/82.jpg)
To see exactly how this matches, we might want torewrite this blue part to focus more on what we're
saying about y.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧ x loves every person y)
![Page 83: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/83.jpg)
When I was learning how to write, I remember being toldthat the passive voice should not be used. But sometimes,like in this case, it's actually helpful for exposing thestructure of what's going on – every person y is
loved by x.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧ every person y is loved by x)
![Page 84: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/84.jpg)
If we write things this way, it becomes a bit clearerthat this statement matches this frst general
pattern. Let's go and apply it!
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧ every person y is loved by x)
![Page 85: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/85.jpg)
Tada!
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (y is a person → y is loved by x)
)
![Page 86: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/86.jpg)
You'll notice that I've written this part of the formulaon the next line and indented it. It's extremely useful
to structure the formula this way – it shows what's nestedinside of what and clarifes the scope of the variablesinvolved. While it's not strictly required that you dothis in your own translations, we highly recommend it!
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (y is a person → y is loved by x)
)
![Page 87: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/87.jpg)
Now that we're here, we can do the fnishing touchesof translating this statement by replacing these blue
parts with predicates!
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (y is a person → y is loved by x)
)
![Page 88: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/88.jpg)
That gives this, our fnal statement.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 89: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/89.jpg)
And hey! We're done!
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 90: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/90.jpg)
Before we move on, let's pause and look at theformula that we came up with.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 91: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/91.jpg)
Just as we can use the above patterns to translatethe original statement into logic, we can use those
same patterns to translate this out of logic and backinto English (or any language of your choice,
really!)
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 92: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/92.jpg)
This frst part is the start of a statement of theform “some Ps are Qs”.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 93: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/93.jpg)
So we can start our translation like this.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
There is a corgi... that every person is loved by.
![Page 94: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/94.jpg)
This part of the statement starts of a statement ofthe form “all Ps are Qs”.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
There is a corgi... that every person is loved by.
![Page 95: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/95.jpg)
.so we can continue our translation like this.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
There is a corgi that every person... is loved by.
![Page 96: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/96.jpg)
The last bit is a predicate, so we can just read it of.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
There is a corgi that every person is loved by.
![Page 97: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/97.jpg)
We now have a (grammatically awkward) but correcttranslation of our logic statement back into English.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
There is a corgi that every person is loved by.
![Page 98: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/98.jpg)
With a bit of English rewriting, we can get back to ouroriginal statement. Nifty! Looks like we got it right!
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
“There is a corgi that loves everyone.”
![Page 99: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/99.jpg)
Let's try another translation, just to get some morepractice with this skill.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
![Page 100: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/100.jpg)
How might we translate this statement?
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
Everybody loves at least one corgi.
![Page 101: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/101.jpg)
Before we walk through this one, why don't you trytranslating this one on your own? Try using a similar
thought process to the one we used earlier.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
Everybody loves at least one corgi.
![Page 102: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/102.jpg)
Did you actually try this? Because if you didn't, youreally should. Like, seriously.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
Everybody loves at least one corgi.
![Page 103: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/103.jpg)
So you translated the statement on your own? Great!Let's do this one together.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
Everybody loves at least one corgi.
![Page 104: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/104.jpg)
First, we need to start of by thinking about whatexactly this statement says.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
Everybody loves at least one corgi.
![Page 105: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/105.jpg)
This says “if you pick any person, you'll fnd thatthere's some corgi that they like.”
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
Everybody loves at least one corgi.
![Page 106: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/106.jpg)
That's a statement of this type.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
Everybody loves at least one corgi.
![Page 107: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/107.jpg)
.so we can make some initial progress like this.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (x is a person → x loves at least one corgi)
![Page 108: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/108.jpg)
From here, we can translate the “x is a person” partdirectly into frst-order logic.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) → x loves at least one corgi)
![Page 109: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/109.jpg)
Now, we have to fgure out how to translate thatlast part.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →) x loves at least one corgi)
![Page 110: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/110.jpg)
As before, let's introduce more variables so that wehave names for things.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →) x loves at least one corgi y)
![Page 111: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/111.jpg)
And, as before, let's fddle around with the verbstructure to make clearer what kind of statement this is.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →) there is a corgi y that is loved by x)
![Page 112: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/112.jpg)
From here it's (hopefully) a bit clearer that this isa “some P's are Q's” statement – some corgis
happen to be loved by person x.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →) there is a corgi y that is loved by x)
![Page 113: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/113.jpg)
We can make more progress on our translation byusing that template.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →) ∃y. (y is a corgi ∧ y is loved by x))
![Page 114: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/114.jpg)
At this point we just need to put in the fnishing touchesand rewrite the blue parts using predicates.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →) ∃y. (y is a corgi ∧ y is loved by x))
![Page 115: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/115.jpg)
.like this! Tada! We're done.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →) ∃y. (Corgi(y) ∧ Loves(x, y)))
![Page 116: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/116.jpg)
It's interesting to put the two statements wetranslated side-by-side with one another.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →) ∃y. (Corgi(y) ∧ Loves(x, y)))
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 117: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/117.jpg)
These statements have a lot of similarities, thoughthey're clearly diferent in a number of ways.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →) ∃y. (Corgi(y) ∧ Loves(x, y)))
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 118: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/118.jpg)
One major diference between these two is the orderin which the quantifers appear. The frst has them
in the order , and the second has them in the order∃∀
∀∃.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Corgi(y) ∧ Loves(x, y))
)
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 119: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/119.jpg)
Something we'd really like to stress is that, when wedid these translations, we didn't just magically “guess”
that we needed those particular quantifers and that theywould be in these orders.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Corgi(y) ∧ Loves(x, y))
)
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 120: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/120.jpg)
Instead, we started of with the original statement andincrementally translated it top-down, only adding in the
quantifers when we needed them.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Corgi(y) ∧ Loves(x, y))
)
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 121: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/121.jpg)
One of the biggest mistakes we see people make whenlearning frst-order logic for the frst time is tryingto write the whole statement in a single go, adding inquantifers somewhat randomly to try to get things to
work.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Corgi(y) ∧ Loves(x, y))
)
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 122: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/122.jpg)
Don't do that! It's really, really hard to get right ona frst try.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Corgi(y) ∧ Loves(x, y))
)
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 123: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/123.jpg)
Instead, use the approach we outlined here. Work slowly,going one step at a time, and only adding in quantifers
when you need them.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Corgi(y) ∧ Loves(x, y))
)
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 124: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/124.jpg)
If you do, you're a lot less likely to make mistakes.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Corgi(y) ∧ Loves(x, y))
)
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 125: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/125.jpg)
Going back to our programming analogy, you can writea lot of similar programs that all use if statements and
for loops.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Corgi(y) ∧ Loves(x, y))
)
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 126: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/126.jpg)
However, you rarely write programs by just throwing abunch of loops and if statements randomly and hoping
that it'll work – because chances are, it won't.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Corgi(y) ∧ Loves(x, y))
)
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 127: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/127.jpg)
Instead, you work from the outside in – add in a loopwhen you need it, and if you need to nest an ifstatement, then you add it when you need it.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
Corgi(x)Person(x)
Loves(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Corgi(y) ∧ Loves(x, y))
)
∃x. (Corgi(x) ∧∀y. (Person(y) → Loves(x, y))
)
![Page 128: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/128.jpg)
So at this point we've gotten some practice with thefundamentals of translation. Pretty much everything else
we'll be doing is just more advanced applications of theseconcepts.
![Page 129: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/129.jpg)
To give you a better sense of how these conceptsscale up to more complicated examples, let's walk throughsome more complex statements and how to translate them.
Along the way, you'll see a bunch of nifty tricks andinsights that will help you out going forward.
![Page 130: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/130.jpg)
Let's start of by seeing how to talk about pairs ofthings.
![Page 131: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/131.jpg)
Earlier, we talked about this Java code for iteratingover all the elements of an array.
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 132: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/132.jpg)
Let's imagine we want to write a diferent piece of codethat iterates over all pairs of elements in the array.
How might we do that?
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
private int sumOf(int[] elems) { int result = 0; for (int i = 0; i < elems.length; i++) { result += elems[i]; } return result;}
![Page 133: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/133.jpg)
Here's one possible option using the venerable“double-for-loop” pattern that you've probably gotten
to know and love.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
![Page 134: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/134.jpg)
As with the regular “loop over the elements of an array”loop, the double-for-loop is a programming idiom. Onceyou've seen it enough times, you just know what it means
and don't have to think too much about it.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
![Page 135: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/135.jpg)
One interesting detail about the double-for-loop patternis that putting one loop inside of another yields a way
of iterating over pairs of things.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
![Page 136: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/136.jpg)
Turns out, we can adapt this idea to work in frst-orderlogic as well!
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
![Page 137: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/137.jpg)
Let's imagine that we have these two predicates, oneof which says something is a pancake, and one of which
says that two things taste similar.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
![Page 138: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/138.jpg)
How might we translate this statement into frst-orderlogic?
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
Any two pancakes taste similar
![Page 139: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/139.jpg)
This statement is diferent from our earlier onebecause it talks about any possible pair of objects
rather than any possible individual object.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
Any two pancakes taste similar
![Page 140: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/140.jpg)
The good news is that we can translate it in a waythat bears a strong resemblance to the above Java
code with a double for loop.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
Any two pancakes taste similar
![Page 141: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/141.jpg)
Specifcally, we'll proceed as follows.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
Any two pancakes taste similar
![Page 142: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/142.jpg)
First, let's introduce some new variables into ourEnglish so that we have names for things.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
Any two pancakes x and y taste similar
![Page 143: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/143.jpg)
We can then rejigger the English statement so that itlooks like this. After all, this means the same thing
as what we started with.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
Any pancake x tastes similar to any pancake y
![Page 144: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/144.jpg)
Now, we can think back to our Aristotelean form templatesthat we just got really familiar with and see how to
apply them here.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
Any pancake x tastes similar to any pancake y
![Page 145: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/145.jpg)
Since this statement says something to the efect of“any pancake x has some special property.”
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
Any pancake x tastes similar to any pancake y
![Page 146: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/146.jpg)
. we can begin translating it into logic like this.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. (Pancake(x) →) x tastes similar to any pancake y)
![Page 147: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/147.jpg)
Now, let's look at that middle portion and see if wecan translate it as well.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. (Pancake(x) →) x tastes similar to any pancake y)
![Page 148: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/148.jpg)
Reordering the statement gives us this to work with,which exposes a bit more structure.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. (Pancake(x) →) any pancake y tastes similar to x)
![Page 149: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/149.jpg)
We can then rewrite it like this.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. (Pancake(x) →∀y. (Pancake(y) →
( x tastes similar to y)
)
![Page 150: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/150.jpg)
As a fnal step, we'll translate that innermost portion.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. (Pancake(x) →∀y. (Pancake(y) →
( x tastes similar to y)
)
![Page 151: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/151.jpg)
Tada! We're done.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
![Page 152: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/152.jpg)
We now have a statement that says that any two pancakestaste similar. (We can debate whether this is true or not
in a separate guide.)
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
![Page 153: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/153.jpg)
Hopefully, you can notice that there's a bit of a parallelto the Java double for loop given above.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
![Page 154: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/154.jpg)
If you think as quantifers as a sort of “loop overeverything” – which isn't that far from the truth – thenthe program and the formula both say “loop over onething, then loop over another, then do something with
the pair.”
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
![Page 155: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/155.jpg)
So if you ever need to write something where you'redealing with a pair of things, you now know how! Youcan just write two independent quantifers like this.
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
private void printPairsIn(int[] elems) { for (int i = 0; i < elems.length; i++) { for (int j = 0; j < elems.length; j++) { System.out.println(elems[i] + ", " + elems[j]); } }}
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
![Page 156: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/156.jpg)
It turns out, though, that there's another way toexpress this concept that some people fnd a bit easierto wrap their head around. For completeness, let's
quickly talk about this before moving on.Pancake(x)
TasteSimilar(x, y)
Available Predicates:
![Page 157: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/157.jpg)
Let's go back to our original statement.Pancake(x)
TasteSimilar(x, y)
Available Predicates:
Any two pancakes taste similar
![Page 158: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/158.jpg)
As before, let's add in some variables names so thatwe have ways of keeping our pancakes straight.
(Ever gotten your pancakes confused? It's a horribleway to start of your day.)
Pancake(x)TasteSimilar(x, y)
Available Predicates:
Any two pancakes x and y taste similar
![Page 159: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/159.jpg)
The idea is that we know that, at this point, we'regoing to be reasoning about a pair of pancakes, and
we're going to reason about them right now.Pancake(x)
TasteSimilar(x, y)
Available Predicates:
Any two pancakes x and y taste similar
![Page 160: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/160.jpg)
Therefore, rather than introducing two quantifers atdiferent points in time, we'll introduce both quantifers
at the same time.Pancake(x)
TasteSimilar(x, y)
Available Predicates:
Any two pancakes x and y taste similar
![Page 161: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/161.jpg)
.like this.Pancake(x)
TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (x and y are pancakes → x and y taste similar)
![Page 162: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/162.jpg)
Generally speaking, it is not a good idea to introducequantifers for variables all at once, but in the special
case of working with pairs, it's perfectly safe.Pancake(x)
TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (x and y are pancakes → x and y taste similar)
![Page 163: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/163.jpg)
So now all we have to do is translate each of theremaining English parts into English.
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (x and y are pancakes → x and y taste similar)
![Page 164: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/164.jpg)
Here's one way to do this.Pancake(x)
TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (Pancake(x) ∧ Pancake(y) → TasteSimilar(x, y))
![Page 165: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/165.jpg)
And we're done! This is a totally valid way to translateour original statement into frst-order logic.
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (Pancake(x) ∧ Pancake(y) → TasteSimilar(x, y))
![Page 166: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/166.jpg)
It's interesting, and useful, to put this secondtranslation side-by-side with our original one.
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (Pancake(x) ∧ Pancake(y) → TasteSimilar(x, y))
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
![Page 167: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/167.jpg)
These statements look pretty diferent, but they sayexactly the same thing. Both are perfectly correct.
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (Pancake(x) ∧ Pancake(y) → TasteSimilar(x, y))
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
![Page 168: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/168.jpg)
There's actually something pretty cool and prettydeep going on here.
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (Pancake(x) ∧ Pancake(y) → TasteSimilar(x, y))
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
![Page 169: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/169.jpg)
For now, ignore the quantifers. Just look at thepredicates and how they relate.
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (Pancake(x) ∧ Pancake(y) → TasteSimilar(x, y))
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
![Page 170: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/170.jpg)
Abstractly, here are the two propositional logic patternsused in the two statements.
Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (Pancake(x) ∧ Pancake(y) → TasteSimilar(x, y))
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
A → B → C A ∧ B → C
![Page 171: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/171.jpg)
These statements are actually logically equivalent to oneanother. (If you've checked out the Guide to Negating
Formulas, you'll see a cool way to derive this!)Pancake(x)
TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (Pancake(x) ∧ Pancake(y) → TasteSimilar(x, y))
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
A → B → C A ∧ B → C≡
![Page 172: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/172.jpg)
This pattern – changing a chain of implications intoa single implication and a lot of ANDs and vice-versa –
is sometimes called Currying and has applications infunctional programming. (This is a total aside. you're not
expected to know this.)Pancake(x)TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (Pancake(x) ∧ Pancake(y) → TasteSimilar(x, y))
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
A → B → C A ∧ B → C≡
![Page 173: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/173.jpg)
Ultimately, what's important is that you understandthat both of these statements say exactly the samething and that you end up comfortable working with
both of them. Feel free to use whichever one you likemore, but make sure you can quickly interpret both.Pancake(x)
TasteSimilar(x, y)
Available Predicates:
∀x. ∀y. (Pancake(x) ∧ Pancake(y) → TasteSimilar(x, y))
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
A → B → C A ∧ B → C≡
![Page 174: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/174.jpg)
Let's do another example of where we might want togo and work with pairs.
![Page 175: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/175.jpg)
Let's switch our predicates from pancakes to people.Person(x)
Knows(x, y)
Available Predicates:
![Page 176: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/176.jpg)
How might we translate this statement into frst-orderlogic?
Person(x)Knows(x, y)
Available Predicates:
Everyone knows at least two people
![Page 177: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/177.jpg)
Well, it seems like there's going to be a pair involvedhere somewhere, since there's something about
“at least two people” here.Person(x)
Knows(x, y)
Available Predicates:
Everyone knows at least two people
![Page 178: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/178.jpg)
However, that does not mean that we should immediatelystart writing out something about a pair of people.Remember – we should only introduce quantifers whenwe immediately need them, and it's not clear thatwe need to start talking about these two people
yet.Person(x)
Knows(x, y)
Available Predicates:
Everyone knows at least two people
![Page 179: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/179.jpg)
Instead, let's look at the overall structure of thisstatement and see what it is that we're trying to say.
Person(x)Knows(x, y)
Available Predicates:
Everyone knows at least two people
![Page 180: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/180.jpg)
As usual, let's start by introducing some variables sothat we can keep track of who we're talking about.
Person(x)Knows(x, y)
Available Predicates:
Every person x knows at least two people y and z
![Page 181: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/181.jpg)
We can then partially translate this statement usingthe techniques we've seen so far.
Person(x)Knows(x, y)
Available Predicates:
∀x. (Person(x) → x knows at least two people y and z)
![Page 182: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/182.jpg)
Now, we need to express the idea that x knows twopeople x and y.
Person(x)Knows(x, y)
Available Predicates:
∀x. (Person(x) → x knows at least two people y and z)
![Page 183: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/183.jpg)
There are a couple of ways to do it, and since we'vegot time, we'll do it in two diferent ways.
Person(x)Knows(x, y)
Available Predicates:
∀x. (Person(x) → x knows at least two people y and z)
![Page 184: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/184.jpg)
Previously, we talked about working with pairs ina universally-quantifed setting. Here, though, thisparticular pair is going to be existentially quantifed,since we're saying that there exist two people with
certain properties.Person(x)Knows(x, y)
Available Predicates:
∀x. (Person(x) → x knows at least two people y and z)
![Page 185: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/185.jpg)
It might be easier to see that if we rewrite things likethis.
Person(x)Knows(x, y)
Available Predicates:
∀x. (Person(x) → there are two people y and z that x knows)
![Page 186: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/186.jpg)
Thinking back to our double for loop intuition, let's seeif we can translate this statement by nesting some
existential statements inside of one anothter.Person(x)
Knows(x, y)
Available Predicates:
∀x. (Person(x) → there are two people y and z that x knows)
![Page 187: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/187.jpg)
Let's begin by rewriting the English like this.Person(x)
Knows(x, y)
Available Predicates:
∀x. (Person(x) → there is a person y that x knows and a different
person z that x knows.)
![Page 188: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/188.jpg)
We can now make some progress translating this.Person(x)
Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
there is a different person z that x knows)
)
![Page 189: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/189.jpg)
We can then fnish up the rest of this translation bytranslating this blue part in the middle. But that
shouldn't be too bad!Person(x)
Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
there is a different person z that x knows)
)
![Page 190: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/190.jpg)
Here's one way to do it.Person(x)
Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
∃z. (Person(z) ∧ Knows(x, z) ∧z is a different person from y
))
)
![Page 191: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/191.jpg)
The last step is to say that z and y aren't the sameperson.
Person(x)Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
∃z. (Person(z) ∧ Knows(x, z) ∧z is a different person from y
))
)
![Page 192: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/192.jpg)
Even though we didn't explicitly list it in our list ofpredicates, remember that frst-order logic has the
equality predicate built into it, so we're always allowed tostate that two things are the same or are diferent.
Person(x)Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
∃z. (Person(z) ∧ Knows(x, z) ∧z is a different person from y
))
)
![Page 193: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/193.jpg)
Here's one way to do that.Person(x)
Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
∃z. (Person(z) ∧ Knows(x, z) ∧ z ≠ y))
)
![Page 194: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/194.jpg)
And hey! We're done!Person(x)
Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
∃z. (Person(z) ∧ Knows(x, z) ∧ z ≠ y))
)
![Page 195: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/195.jpg)
Notice how we're using a pair of nested existentialquantifers to express the idea that there's a pair of
people with specifc properties.Person(x)
Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
∃z. (Person(z) ∧ Knows(x, z) ∧ z ≠ y))
)
![Page 196: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/196.jpg)
Hopefully, this seems familiar, since it's closely relatedto the analogous doubly-nested quantifers we saw
when talking about pairs of pancakes.Person(x)
Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
∃z. (Person(z) ∧ Knows(x, z) ∧ z ≠ y))
)
![Page 197: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/197.jpg)
Just as we could write “any pair of pancakes” in twoways, we can write “some pair of diferent people” in
two ways.Person(x)
Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
∃z. (Person(z) ∧ Knows(x, z) ∧ z ≠ y))
)
![Page 198: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/198.jpg)
Here's the alternative approach. Here, we introducethe quantifers for y and z at the same time, then
constrain y and z with preconditions at the same time.Person(x)
Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. ∃z. (Person(y) ∧ Person(z) ∧ z ≠ y ∧
Knows(x, y) ∧ Knows(x, z))
)
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
∃z. (Person(z) ∧ Knows(x, z) ∧ z ≠ y))
)
![Page 199: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/199.jpg)
These two approaches are completely equivalent, and bothof them are correct. As with quantifying over pairsusing , it's a good idea to get comfortable with∀
quantifying over pairs using with both of these∃
approaches.Person(x)Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. ∃z. (Person(y) ∧ Person(z) ∧ z ≠ y ∧
Knows(x, y) ∧ Knows(x, z))
)
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
∃z. (Person(z) ∧ Knows(x, z) ∧ z ≠ y))
)
![Page 200: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/200.jpg)
On Problem Set Two, you'll get to consider a variationon this problem: how would you express the idea that
this person x knows exactly two people? That's a trickierproposition, but (hypothetically speaking) you may want
to use this basic setup as a starting point.Person(x)Knows(x, y)
Available Predicates:
∀x. (Person(x) →∃y. ∃z. (Person(y) ∧ Person(z) ∧ z ≠ y ∧
Knows(x, y) ∧ Knows(x, z))
)
∀x. (Person(x) →∃y. (Person(y) ∧ Knows(x, y) ∧
∃z. (Person(z) ∧ Knows(x, z) ∧ z ≠ y))
)
![Page 201: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/201.jpg)
There's one last topic I'd like to speak about in thisguide, and that's what happens when you start talking
about sets and set theory in frst-order logic.
![Page 202: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/202.jpg)
Even if you don't fnd yourself talking about set theorymuch in frst-order logic, the lessons we'll learn in the
course of exploring these sorts of translations areextremely valuable, especially when it comes to checking
your work.
![Page 203: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/203.jpg)
Let's imagine that we have the set of predicates over tothe left. We can say that something is a set, that onething is an element of something else, that something
is an integer, and that something is negative.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
![Page 204: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/204.jpg)
How might we translate this statement into frst-orderlogic?Set(x)
x ∈ yInteger(x)
Negative(x)
Available Predicates:
The set of all natural numbers exists
![Page 205: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/205.jpg)
This statement is, in many ways, quite diferent from theones we've seen so far.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
The set of all natural numbers exists
![Page 206: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/206.jpg)
First, the statement doesn't seem to look anything likethe Aristotelian forms that we saw earlier. Instead,
it just says that something exists.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
The set of all natural numbers exists
![Page 207: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/207.jpg)
Second, this statement refers to a specifc thing – theset of all natural numbers – and so it's not exactlyclear how we'd actually translate this into logic.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
The set of all natural numbers exists
![Page 208: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/208.jpg)
If you encounter a statement like this one, which asksyou to show that something exists, it often helps to
reframe the statement to translate in a diferent light.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
The set of all natural numbers exists
![Page 209: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/209.jpg)
Rather than saying “this specifc thing exists.”
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
The set of all natural numbers exists
![Page 210: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/210.jpg)
.we can say something like this – that of the sets thatare out there, one of them has some special properties.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
There is a set that is the set of all natural numbers
![Page 211: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/211.jpg)
This looks a lot more like the forms that we saw earlier,so we can start to translate it into frst-order logic
using similar techniques.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
There is a set that is the set of all natural numbers
![Page 212: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/212.jpg)
Here's one way that we can get this translation started.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 213: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/213.jpg)
So now we need to fnd a way to pin down the factthat S is the set of all natural numbers.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 214: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/214.jpg)
To do so, let's take a few minutes to think abouthow we might do that.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 215: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/215.jpg)
If we're going to say that S is the set of all naturalnumbers, we're probably going to need to fnd someway to talk about its elements. After all, sets are
uniquely defned by their elements, so if we want to saythat we have a set with a certain property, we cando so by saying that it has the right elements.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 216: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/216.jpg)
We're not sure how we're going to do that, but at leastwe know to keep an eye out for that.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 217: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/217.jpg)
Next, we need to fnd a way to say that something isa natural number.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 218: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/218.jpg)
We have the ability to say that something is an integeror that something is negative, and that might comein handy – the natural numbers are the integers
that aren't negative!Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 219: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/219.jpg)
So even if we have no idea where we're going right now,we at least know that (1) we want to say something about the elements of S, and (2) we're going to try to say
something about how they're integers that aren't negative.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 220: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/220.jpg)
Rather than just show you the fnal answer, let's see hownot to do this.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 221: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/221.jpg)
As before, I'm going to put up the emergency warningfags indicating that we're doing something wrong here.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)⚠ ⚠
![Page 222: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/222.jpg)
Let's try an initial approach. What does it mean for Sto be the set of all natural numbers?
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)⚠ ⚠
![Page 223: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/223.jpg)
Here's a reasonable – but incorrect – way of thinkingabout it. If you don't see why this is incorrect, don'tworry! It's subtle, which is precisely why we're taking
the time to go down this route.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S contains all the natural numbers
)⚠ ⚠
![Page 224: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/224.jpg)
Now, how might we translate this red statement intofrst-order logic?
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S contains all the natural numbers
)⚠ ⚠
![Page 225: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/225.jpg)
Again, let's change up the ordering of the English toexpose a bit more structure.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧every natural number is an element of S
)⚠ ⚠
![Page 226: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/226.jpg)
This matches one of our nice Aristotelian forms, so wecan rewrite it like this.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x is a natural number →
x is an element of S)
)
⚠ ⚠
![Page 227: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/227.jpg)
We can clean up the consequent of that implication (thepart that's implied) using the predicates we have available.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x is a natural number →
x ∈ S)
)
⚠ ⚠
![Page 228: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/228.jpg)
As for the antecedent – as we saw earlier, thenatural numbers are the integers that aren't negative,
so we can say something like this.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x is an integer and x isn't negative →
x ∈ S)
)
⚠ ⚠
![Page 229: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/229.jpg)
We can then translate that into logic like this. Done! .ishSet(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
![Page 230: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/230.jpg)
So it seems like we're done, but we still have thosebig red warning signs everywhere. Why doesn't this
work?Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
![Page 231: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/231.jpg)
Well, fundamentally, the way this statement works is bysaying “there is some set S that is the set of all
natural numbers.”Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
![Page 232: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/232.jpg)
Since this is an existentially-quantifed statement, it'strue if we can fnd a choice of S that makes it true.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
![Page 233: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/233.jpg)
We've tried to structure this statement with the intentthat, specifcally, the only choice of S that will work
should be , the set of all natural numbers.ℕSet(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
![Page 234: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/234.jpg)
If we can make this statement true without choosingS to be the set of all natural numbers, then we haven't
actually stated that exists.ℕSet(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
![Page 235: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/235.jpg)
Unfortunately, it is entirely possible to choose a setbesides that makes this formula true.ℕ
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
![Page 236: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/236.jpg)
Specifcally, what if we choose S to be the set ?ℝSet(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
Choose S = ℝ.
![Page 237: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/237.jpg)
That means that S is defnitely a set.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
Choose S = ℝ.
![Page 238: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/238.jpg)
.and this part of the formula is true: every nonnegativeinteger is contained in S.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
Choose S = ℝ.
![Page 239: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/239.jpg)
This means that the statement we've written doesn'tsay “the set of all natural numbers exists.” It says
“there is some set that contains all the natural numbers,”which is similar, but not the same thing.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
Choose S = ℝ.
![Page 240: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/240.jpg)
Fundamentally, the issue with this translation is that we'veput on a set of minimum requirements on S, not a set ofexact requirements. As a result, it's possible to makethis formula true with a choice of S that has some, butnot all, of the properties of . We're going to needℕ
to rework the formula to correct that defciency.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
Choose S = ℝ.
![Page 241: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/241.jpg)
To do so, let's go back in time to the last point whereeverything was working correctly.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
⚠ ⚠
Choose S = ℝ.
![Page 242: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/242.jpg)
. which was this point here!Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 243: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/243.jpg)
Okay, so we know that just saying “S contains all thenatural numbers” isn't going to work, because othersets besides can also contains all the natural ℝ
numbers.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 244: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/244.jpg)
So what other approaches can we take?Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 245: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/245.jpg)
I'm going to show you another approach that doesn'twork, which is a common strategy that we see students
take after they realize that the previous approachis incorrect.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 246: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/246.jpg)
Again, up go the warning signs!Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)⚠ ⚠
![Page 247: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/247.jpg)
Maybe we should think about this diferently. The reasonthat we could get away with choosing for our set ℝ Swas that our formula said “S has to have at least theseelements.” What if we try a diferent tactic and say
that S has to have at most these elements?Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)⚠ ⚠
![Page 248: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/248.jpg)
That is, what if we try replacing the previous bluestatement with this red statement?
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧the only elements of S are natural numbers
)⚠ ⚠
![Page 249: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/249.jpg)
This isn't the same thing as before. do you see why?Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧the only elements of S are natural numbers
)⚠ ⚠
![Page 250: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/250.jpg)
Given that it's diferent, let's see if we can translatethis into frst-order logic.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧the only elements of S are natural numbers
)⚠ ⚠
![Page 251: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/251.jpg)
Rewording this statement and introducing some variableshelps make clearer what we're going to do next.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧every element of S is a natural number
)⚠ ⚠
![Page 252: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/252.jpg)
This statement matches one of our forms, so let'sgo and translate it.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
x is a natural number)
)
⚠ ⚠
![Page 253: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/253.jpg)
And, since we've seen earlier how to express the ideathat x is a natural number.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
x is a natural number)
)
⚠ ⚠
![Page 254: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/254.jpg)
.we can complete our translation like this.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x))
)
⚠ ⚠
![Page 255: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/255.jpg)
So we're done! But is it correct?Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x))
)
⚠ ⚠
![Page 256: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/256.jpg)
As before, we should check to make sure that the onlyway this statement can be made true is by picking S tobe the set of all natural numbers. Is that really the
case?Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x))
)
⚠ ⚠
![Page 257: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/257.jpg)
Unfortunately, no. What if we pick this choice for S?Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x))
)
⚠ ⚠
Choose S = {137}.
![Page 258: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/258.jpg)
Well, it's a set.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x))
)
⚠ ⚠
Choose S = {137}.
![Page 259: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/259.jpg)
. and this statement is true: every element of S is indeeda natural number.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x))
)
⚠ ⚠
Choose S = {137}.
![Page 260: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/260.jpg)
So our translation isn't correct – even if there is noset of all natural numbers, we can still make the formulatrue by picking some other set. in this case, any set
that happens to only contain natural numbers.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x))
)
⚠ ⚠
Choose S = {137}.
![Page 261: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/261.jpg)
Interesting, we could have also chosen S = Ø as acounterexample. Then this inner statement happens tobe vacuously true because there are no elements of S
to speak of!Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x))
)
⚠ ⚠
Choose S = Ø
![Page 262: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/262.jpg)
So here are our two attempted translations, each ofwhich isn't correct.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)⚠ ⚠∃S. (Set(S) ∧
∀x. (x ∈ S →Integer(x) ∧ ¬Negative(x)
))
![Page 263: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/263.jpg)
Interestingly, although each of them is wrong, they'rewrong in complementary ways.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)⚠ ⚠∃S. (Set(S) ∧
∀x. (x ∈ S →Integer(x) ∧ ¬Negative(x)
))
![Page 264: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/264.jpg)
Our frst statement was wrong because it let us choosesets that had all the natural numbers, plus some other
things that shouldn't be there.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)⚠ ⚠∃S. (Set(S) ∧
∀x. (x ∈ S →Integer(x) ∧ ¬Negative(x)
))
![Page 265: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/265.jpg)
However, notice that we can't pick an S that missesany natural numbers, because the inside says that all
the natural numbers should be there.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)⚠ ⚠∃S. (Set(S) ∧
∀x. (x ∈ S →Integer(x) ∧ ¬Negative(x)
))
![Page 266: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/266.jpg)
This second statement was incorrect because it let uschoose sets S with too few elements, since all it requiredwas that elements that were present were natural numbers.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)⚠ ⚠∃S. (Set(S) ∧
∀x. (x ∈ S →Integer(x) ∧ ¬Negative(x)
))
![Page 267: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/267.jpg)
However, note that this formula doesn't let us choosea set S that contains anything that's not a natural number,since it requires everything in S to be a natural number.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)⚠ ⚠∃S. (Set(S) ∧
∀x. (x ∈ S →Integer(x) ∧ ¬Negative(x)
))
![Page 268: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/268.jpg)
In a sense, you can think of our translations this way.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)⚠ ⚠∃S. (Set(S) ∧
∀x. (x ∈ S →Integer(x) ∧ ¬Negative(x)
))
![Page 269: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/269.jpg)
This frst part says “ ℕ ⊆ S,” since it requires thatevery natural number be in S.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)⚠ ⚠∃S. (Set(S) ∧
∀x. (x ∈ S →Integer(x) ∧ ¬Negative(x)
))
(ℕ ⊆ S)
![Page 270: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/270.jpg)
This second part says S , since it requires that⊆ ℕ
every element of S be a natural number.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)⚠ ⚠∃S. (Set(S) ∧
∀x. (x ∈ S →Integer(x) ∧ ¬Negative(x)
))
(ℕ ⊆ S)
(S ⊆ ℕ)
![Page 271: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/271.jpg)
In other words, each individual constraint doesn'tguarantee that S has to be , but the two statementsℕ
collectively would require that S = !ℕSet(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)⚠ ⚠∃S. (Set(S) ∧
∀x. (x ∈ S →Integer(x) ∧ ¬Negative(x)
))
(ℕ ⊆ S)
(S ⊆ ℕ)
![Page 272: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/272.jpg)
Let's wind back the clock and see if we can use thisto our advantage.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)⚠ ⚠∃S. (Set(S) ∧
∀x. (x ∈ S →Integer(x) ∧ ¬Negative(x)
))
(ℕ ⊆ S)
(S ⊆ ℕ)
![Page 273: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/273.jpg)
So this is the last point where we had the right idea.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 274: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/274.jpg)
The problem was that in the last two cases, we keptmistranslating this blue statement, which got us the wrong
answer.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S is the set of all natural numbers
)
![Page 275: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/275.jpg)
So what if we translate it like this?Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S ⊆ ℕ ∧
ℕ ⊆ S)
![Page 276: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/276.jpg)
We can then snap in the two parts of the formulasthat we built up earlier.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧S ⊆ ℕ ∧
ℕ ⊆ S)
![Page 277: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/277.jpg)
.like this.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x)) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
![Page 278: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/278.jpg)
And hey! This actually works!Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x)) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
![Page 279: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/279.jpg)
If we choose an S that contains something it shouldn't,this part will catch it.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x)) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
![Page 280: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/280.jpg)
.and if we pick an S that misses something it wassupposed to contain, this part catches it!
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x)) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
![Page 281: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/281.jpg)
So in that sense, we have a working formula!Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x)) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
![Page 282: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/282.jpg)
As a fnal step, though, we can clean this up a bit.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x)) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
![Page 283: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/283.jpg)
Look at these two implications.Notice anything about them?
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x)) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
![Page 284: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/284.jpg)
Except for the fact that the antecedent and theconsequent have been swapped, they're the same!
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x)) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
![Page 285: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/285.jpg)
And hey. don't we have a special symbol to say thatA B and that B A?→ →
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x)) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
![Page 286: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/286.jpg)
So as a fnal step, let's take this formula andrewrite it using the biconditional connective.
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x)) ∧∀x. (Integer(x) ∧ ¬Negative(x) →
x ∈ S)
)
![Page 287: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/287.jpg)
That ends up looking like this.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S ↔ Integer(x) ∧ ¬Negative(x))
)
![Page 288: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/288.jpg)
This single biconditional contains everything we need.Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S ↔ Integer(x) ∧ ¬Negative(x))
)
![Page 289: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/289.jpg)
In the forwards direction, it says “everything in S needsto be a natural number.”
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S ↔ Integer(x) ∧ ¬Negative(x))
)
![Page 290: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/290.jpg)
In the reverse direction, it says “every natural numberneeds to be in S.”
Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S ↔ Integer(x) ∧ ¬Negative(x))
)
![Page 291: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/291.jpg)
Generally, if you're trying to write a statementin frst-order logic that says that some set exists (which,hypothetically speaking, might happen sometime soon),
you might fnd yourself using a biconditional to pin downthe elements of the set. It's an easy way to say
“the set contains precisely these elements.”Set(x)x ∈ y
Integer(x)Negative(x)
Available Predicates:
∃S. (Set(S) ∧∀x. (x ∈ S ↔ Integer(x) ∧ ¬Negative(x))
)
![Page 292: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/292.jpg)
Wow! We've covered a ton in this guide. Before wewrap up, let's briefy recap the major themes and ideas
from what we've seen here.
![Page 293: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/293.jpg)
First, we saw these four basic statement building blocks.These are idiomatic expressions in frst-order logic – the same
way that a for loop over an array is idiomatic in mostprogramming languages – and are extremely useful in
assembling more complex statements.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
![Page 294: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/294.jpg)
We saw that translating things incrementally, going onestep at a time and judiciously rewriting the English, isa reliable way to end up with good translations. Plus,
it sidesteps a ton of classes of mistakes.
“All Ps are Qs.” “Some Ps are Qs.”
“No Ps are Qs.” “Some Ps aren't Qs.”
∀x. (P(x) → Q(x)) ∃x. (P(x) ∧ Q(x))
∀x. (P(x) → ¬Q(x)) ∃x. (P(x) ∧ ¬Q(x))
∀x. (Person(x) →) x loves at least one corgi y)
![Page 295: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/295.jpg)
We saw how to quantify over pairs of things, and sawthat there are multiple ways of doing so.
∀x. ∀y. (Pancake(x) ∧ Pancake(y) → TasteSimilar(x, y))
∀x. (Pancake(x) →∀y. (Pancake(y) →
TasteSimilar(x, y))
)
![Page 296: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/296.jpg)
We saw that we can check our work by plugging in specifcvalues and seeing whether they work they way we expect
them to work.
∃S. (Set(S) ∧∀x. (x ∈ S →
Integer(x) ∧ ¬Negative(x))
)
⚠ ⚠
Choose S = {137}.
![Page 297: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/297.jpg)
And, fnally, we saw where biconditionals come from,especially in set theory contexts.
∃S. (Set(S) ∧∀x. (x ∈ S ↔ Integer(x) ∧ ¬Negative(x))
)
![Page 298: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/298.jpg)
Hope this helps!
Please feel free to askquestions if you have them.
![Page 299: Guide to First-Order Logic Translationsweb.stanford.edu/class/archive/cs/cs103/cs103.1184/notes...how to translate statements from English into frst-order logic. Translating into logic](https://reader033.vdocuments.us/reader033/viewer/2022042116/5e937fb08122751e6053fee1/html5/thumbnails/299.jpg)
Did you fnd this useful? Ifso, let us know! We can go
and make more guides like these.