Title: Formal Methods in Computer Science CS1502 Intro to Quantification
1Formal Methods in Computer ScienceCS1502Intro
to Quantification
- Patchrawat Uthaisombut
- University of Pittsburgh
2Exam result
- No students can do any problem.
3Exam result
- All students can do all problems.
4Exam result
- All students can do at least one problem on the
exam. - There is some problem that all students can do.
- There is some problem that not all students can
do. - There is some student that can do all the
problems. - There are no problems that no students can do.
5Goals
- To understand the limit of propositional logic
(with /\, \/, ) and the need for first-order
logic (with ?, ?). - To learn the definition of well-formed formulas
(wffs) and their use in constructing quantified
sentences. - To learn the notion of satisfaction of wffs and
its use to systematically determine the truth
value of quantified sentences.
6Concepts
- domain of discourse
- variables
- atomic well-formed formulas
- well-formed formulas
- quantifiers
- sentence
- translation between English and logic
- satisfaction
- truth value of a quantified sentence
7Sentences expressible in first-order logic
- Algorithm A1 correctly solves the sorting
problem. - Algorithm A2 has a worst-case running time of
O(n2). - Algorithm A3 is a 2-approximation algorithm.
- No algorithm can sort in time better than ?(n).
- No algorithm can correctly solve the Halting
problem. - Function f1 is continuous.
- Function f2 is one-to-one but not on-to.
8Domain of discourse
- Domain of discourse (or just domain)
- The set of objects of interest.
- If we have a specific world in mind, the domain
often (but not necessarily) refers to the set of
all objects in the world.
9Whats wrong with propositional logic
- Suppose we want to say All objects are cubes.
- What if the domain of discourse is infinite?
- What we can claim with propositional logic.
- 1 atomic sentence
- 1 property of 1 object Cube(b)
- 1 relationship of a fixed number of objects
- Between(a,b,c)
10- Connectives
- Finite number of relationships (properties), each
with a fixed number of objects - Conjunction, disjunction, conditional symbol,
- Cube(b) /\ (Tet(a) \/ (Dodec(c) ?LeftOf(a,b))
11- Objects must be named.
- Finite claims
- Can we use propositional logic to claim something
like the following? - All objects are small.
- No objects are tetrahedron.
- Some object is large.
12- Propositional logic is still possible for finite
domain. - If the domain of discourse is infinite, we cannot
express claims like all objects are cubes. in
propositional logic.
13Sentences expressible in first-order logic
- We will learn how to use them to make claims such
as - Algorithm A1 correctly solves the sorting
problem. - Algorithm A2 has a worst-case running time of
O(n2). - Algorithm A3 is a 2-approximation algorithm.
- No algorithm can sort in time better than ?(n)
- No algorithm can correctly solve the Halting
problem. - Function f1 is continuous.
- Function f2 is one-to-one but not on-to.
14Creating quantified sentences
- Redefining terms
- Defining well-formed formulas
- Redefining sentences
15Definition of terms (so far)
- Names are terms.
- also called basic terms.
- Applications of function symbols on terms are
terms. - Examples
- john
- father(john)
- mother(father(john))
16atomic sentences (so far)
- formed by a single predicatefollowed by one or
more terms - Maxs father is tall Tall(father(max))
- e is larger than bc Larger(e,bc)
- e is identical to a e a
- A sentence expresses a claim that is either true
or false
17Definition of terms (modified)
- Names and variables are terms.
- also called basic terms.
- Applications of function symbols on terms are
terms. - Examples
- x
- father(x)
- mother(father(x))
18atomic well-formed formulas
- formed by a single predicate followed by one or
more terms - xs father is tall Tall(father(x))
- x is larger than bc Larger(x,bc)
- e is identical to x e x
- An atomic wff may not be a sentence and thus may
not have truth value. - Any variable that appears in an atomic wff is
free or unbound.
19Complex Sentences (so far)
- Suppose P and Q are sentences of FOL (atomic or
complex) - Then the followings are also sentences of FOL
- ?P
- P?Q
- P?Q
- P ? Q
- P ? Q
- Examples
- ? Cube(a)
- LeftOf(a,b) ? LeftOf(b,c)
- ?(Large(a) ? Medium(a)) ? Tet(c)
20Well-formed formulas
- Suppose P and Q are wffs (atomic or complex), and
x is a variable. - Then the followings are also wffs of FOL
- ?P P?Q P?Q P ? Q P ? Q
- ?x P ?x P
- Any free occurrence of x in P is bound in ?x P.
Same for ?x P. - Examples
- ?x ?Cube(x)
- ?x LeftOf(x,b) ? ?y LeftOf(b,y)
- ?y (?x ?(Large(x) ? Medium(x)) ? Tet(y))
21Sentences (redefined)
- A sentence is a wff with no free variables.
22Examples wff or sentence
- Gave(x,y,z)
- ?y Gave(claire, y, max)
- ?y (Gave(claire, y, max) /\ (y scruffy))
- ?x Between(a,x,b)
- ?a Between(a,x,b)
23Examples
- ?y Cube(y) /\ Large(y)
- ?x (?y Cube(y) /\ FrontOf(y,x))
- ?x (?y ?z (LeftOf(y,z) \/ FrontOf(x,y)) /\ ?x
Cube(x) - ?x (?x (?x Cube(x) /\ Tet(x)) /\ Dodec(x))
24Translation
25Universal quantifier ?
- everything, each thing, all things,
anything - ?x reads for every object x.
- ?x Cube(x)
- Everything is a cube.
- For every object x, x is a cube.
- ?x (Major(x,cs) ? Smart(x))
- Every CS major is smart.
- For every object x, if x majors in CS, x is
smart.
26Existential quantifier ?
- some thing, at least one thing, a, an.
- ?x reads for some object x
- ?x Cube(x)
- Something is a cube.
- For some object x, x is a cube.
- ?x (Major(x,cs) /\ Smart(x))
- Some CS major is smart.
- For every object x, x majors in CS and x is
smart.
27Nothing
- How to translate these?
- Nothing is both a cube and a tet.
- Nothing is P
- Not one thing is P Ex P(x)
- Everything is not P ?x P(x)
28Determining truth value
- Satisfaction of wff
- Truth values of quantified sentences
- How to do it systematically
29Truth value
- We know how to determine truth value of sentences
in propositional logic. - Complex sentences are built from smaller
sentences. - How to determine truth value of sentences in
first-order logic? - Complex sentences are built from smaller
sentences.
30Domain of discourse
- Is the sentence ?x Cube(x) true or false?
- In general, a quantified sentence is true or
false relative to some domain of discourse or
domain of quantification. - This is the set of objects that we are interested
in. - The domain of discourse could be
- the set of all possible objects.
- the set of objects in the world of interest.
- etc.
31Examples
- ?x Cube(x) is true in this world.
- ?x (Integer(x) ? Integer(x1)) is true when the
domain of discourse contains everything.
32S(x)
- In propositional logic,
- we use single capital letters to represents
sentences. - A Tet(a) /\ Cube(b)
- P Tall(max) \/ Home(claire)
- S (Large(b) ? Small(c))
- In first-order logic,
- we use single capital letters followed by one or
more variables to represents wffs with free
variables. - S(x) is a wff with x as the only free variable.
- A(x) Tet(x) /\ Cube(a)
- P(x,y) ?z Tet(z) \/ Cube(x) \/ Tet(y)
33Replacing variables with names
- Suppose S(x) is a wff
- Cube(x)
- Small(x) /\ Cube(x) /\ ?x Tet(x)
- Consider an object c in the domain of discourse.
- Replace all (free) occurrences of x by c. S(c)
becomes a sentence. - Cube(c)
- Small(c) /\ Cube(c) /\ ?x Tet(x)
34Satisfying a wff
- Object c satisfies S(x) if and only ifS(c) is
true.
35Discussion satisfying a wff
- Object c satisfies S(x) if and only if S(c) is
true. - A sentence has a truth value.
- Everything (names, predicates) is determinate.
- A name refer to a specific object.
- A wff with free variables does not have a truth
value - A variable does not refer to any specific objec
- If we replace variables with some names,
everything becomes determinate. Wff becomes a
sentence, and we can determine truth value.
36Truth value of quantified sentences
- Suppose S(x) is a wff with x as the only free
variable. - Cube(x)
- Small(x) /\ Cube(x) /\ ?x Tet(x)
- ?x S(x) is a sentence (no free variable).
- ?x S(x) is a sentence (no free variable).
37Truth value of quantified sentences
- Truth value of a quantified sentence ?x S(x) is
defined in term of satisfaction of the
constituent wff S(x). - ?x S(x) is true if and only if at least one
object in the domain satisfies S(x). - ?x S(x) is true if and only if every object in
the domain satisfies S(x).
38Examples / Exercises
- ?x ?y SameRow(x,y)
- ?x ?y SameRow(x,y)
- ?x ?y SameRow(x,y)
- ?x ?y SameRow(x,y)