Wop Logic-Final
Wop Logic-Final
Abstract
First order logic is an effective means to the end of knowledge representation and reasoning in
disciplines such as programming, database management, mathematics, and linguistics. However,
there are limits to the power of first order logic. This winter, we shall study Ehrenfreucht-
Fraissé Games: a procedure to prove whether a given property can be expressed using First
Order Logic. In this document, we will revise the basics of First Order Logic, and look at a few
puzzles. The concepts we discuss here will be not only useful going forward in the project, but
also mathematically instructive.
Logistics
It is highly preferred that you’re at least a little familiar with first order logic. If you haven’t
learnt about it in CS 207 - Discrete Structures, or CS 228 - Logic for CS, you might need to put
in extra effort to look up the background as you read this, and work on the winter project.
Depending on public interest in the topic, my convenience, and what the club management is
willing to allow, I will take 5-10 mentees for the winter project. The mentees will have to compile
a report over the winter in order to get certified, and I will do my best to give constructive feedback
about what you write.
The selection will be based on your response to the puzzles in this document (see Section 3). Write
your answers (typed, or neatly handwritten), make a PDF and upload it here. (access Google
form with IITB LDAP)
In any case, I plan to make most the material for this project public, so you can follow this even
if you’re not taken up as a mentee. Even if I don’t and you’re interested, feel free to contact me
later on. My email is vahanwala(at)cse.iitb.ac.in
First Order Logic extends propositional logic: we reason about an arbitrary Universe U, we allow
predicates (relations in U n ; P (t1 , . . . , tn ) returns true or false depending on whether elements
t1 , . . . , tn from U satisfy the relation), functions (from U n to U), and existential quantifiers (∃x.:
there exists x in U; ∀x.: for all x in U). Here, variables take values from U.
A formula F is either a predicate P , or F1 ∧ F2 , or F1 ∨ F2 , or F1 → F2 , or ¬F1 , or ∃x.F1 , or
∀x.F1
The above grammar recursively defines how a formula is supposed to be parsed. An example
formula:
∀x.∃y.(P (x) → Q(x, y, f (x)))
P and Q are predicates, f is a function. x and y are quantified variables. A first order formula is
called a sentence if every occurrence of a variable is in the scope of a quantifier, i.e. there is no
“free” occurrence of a variable. The above formula, is a sentence, the following is not, because z
is free:
P (z) ∧ ∀x.R(x, g(z))
In order to write syntactically valid formulae, we need a signature, which tells us what constant
symbols are available, predicate symbols we can use, what function symbols we can use, what is
their arity (i.e. number of arguments that need to be fed each of these predicate and function
symbols)
Definition 1.1 (Signature). A signature τ is a tuple (P, F, C) where
• P is a set of predicate symbols, annotated with the number of arguments the symbol requires
• F is a set of function symbols, annotated with the number of arguments the symbol requires
• C is a set of constant symbols. They can also be thought of as 0-ary functions
We have the binary equality predicate = included in the signature by default: there is no need to
mention it explicitly.
We also have the set X of variables.
3 Exercises
Exercise 1. You are given a signature that only has one binary predicate < in addition to the
default =. Consider structures N , Z, Q and R, with universes N, Z, Q and R respectively (natural
numbers, integers, rationals and real numbers). The relation corresponding to < in each of these
structures is the usual “less than”. Write a first order logic sentence φ such that N |= φ holds,
but R |= φ does not. Try writing formulae for all permutations. Can you reuse the same formula?
Is it even possible to differentiate Q and R this way? Can we prove it?
This is easy once you use the fact that reals are “complete”.
The next exercise is related to this standard, but it’s nice to do, because:
• We will eventually describe a proof of the limitations of first order logic
• The techniques you will use are ubiquitous in showing limitations in mathematical and
computer scientific techniques
• Some of the side themes will also be seen later in the project
Exercise 2. Prove that there is no bijection from N to R
Hint. Read this if you’re stuck.
1. First, prove that there is no bijection from natural numbers to sets of natural numbers. Use
Cantor’s diagonal argument (look it up!)
2. Next, define a bijection from sets of natural numbers to real numbers in [0, 1]. The geometric
series of 21i should help. Be sure that you justify why this is indeed a bijection
3. Finally, use your favourite bijection from [0, 1] to R (JEE stuff suffices), and conclude.
The next two exercises are indeed formal, but also sort of open ended. Try to justify
as much as you can.
In the next exercise, we will take a closer look at what we usually take for granted: mathematical
induction.
Suppose we claim that something holds for all natural numbers Here’s what a proof by (strong)
mathematical induction looks like, for natural numbers.
Base Case:
n = 1. Proceed to show whatever.
Inductive Step:
Assume the claim holds for all n0 < n. Use the assumption to prove that the claim holds for n.
Conclude, by induction, that the claim does hold for all natural numbers.
Does this inductive reasoning work as it is for integers? Rationals? Reals? Non-negative rationals
or reals? Why?
To get an idea, let’s go backwards in the proof, i.e. consider the contrapositive.
Suppose, there exists a non-empty set S of natural numbers for which the claim is false. Let
n∈S
Use the proof in the inductive step to argue that there exists n0 < n such that the claim is false.
This is exactly the contrapositive of what was proved. Mathematical induction works on natural
numbers because given any non-empty set, we can choose n cleverly and get contradicted about
n0 being in the set.
Exercise 3. Consider the signature with equality =, the binary predicate <, and a unary predicate
P . Structure S is equipped with a universe U, and implementations <S and PS that correspond
to actual relations. Give a sentence φ such that S |= φ regardless of PS if and only if U supports
induction when the “less than” relation used is <S . Justify.
Try your best. Make sure you capture the desired properties of both the universe and the binary
“less than” relation. Naturals with the usual less than relation should satisfy this formula; integers,
rationals, reals should not. The hint here is that the unary predicate should somehow help you to
talk about a set.
One wonders if structures satisfying φ are somehow related. To this end, we define a homomor-
phism from structure A to structure B over the same signature as follows:
Definition 3.1 (Homomorphism). A homomorphism h is a function from UA to UB such that:
• For each k-ary P ∈ P, PB = {(h(a1 ), . . . , h(ak )) : (a1 , . . . , ak ) ∈ PA }
• For each k-ary f ∈ F, h(fA (a1 , . . . , ak )) = fB (h(a1 ), . . . , h(ak ))
• For each c ∈ C, h(cA ) = cB
If the function h is bijective, then it is an isomorphism.
Exercise 4 (Bonus). Consider a structure S that satisfies φ from the previous exercise. Must
there exist a PN such that there is a homomorphism from S to N = (N, <, PN )? Justify, even
informally with examples is fine.
Remark 3.1. Try to think of where else you can apply induction with an appropriate < relation.
Tuples of integers, directed acyclic graphs, arguments to recurisive functions, trees, etc. How does
the induction proceed? What might the homomorphism look like? Can you then generalise your
observations to be able to construct a homomorphism, if one exists?