CS 371: Introduction to Artificial Intelligence
First-Order Logic

Outline
When Propositional Logic Isn’t Enough
First-Order Logic (FOL)
Practice with FOL
FOL Proof Method: Resolution
[Why Representing Change in Time is Difficult]

Blocks World
Simple domain: Blocks stacked on a table
Simple problem: Stack blocks in a given configuration
Home to much research in a variety of areas:
Vision (Huffman, 1971)
Constraint Propogation (Waltz, 1975)
Machine Learning (Winston, 1970)
Natural Language Understanding (Winograd, 1972)
Planning (Fahlman, 1974)

Propositional Block World
How would you represent the following:
Block A is on Block D
Block A is not on Block B
If A is on D, A is not on B
No block is on A
If A is on D and D is on B, A is above B.

When Propositional Logic Isn’t Enough
Define Above using transitivity of On
“There’s a/there’s no block on A.”
“All blocks have red letters.”
Need for properties, relationships, and ways to generalize information compactly
Practical applications: mathematical theorem proving, common-sense reasoning (CYC image database), circuit/program design/verification

Propositional Logic
Propositions - T/F atomic sentences about the world
Boolean functions (Ø,Ù,Ú,Þ,Û) - negate and logically combine sentences
Parentheses - disambiguates grammar

First-Order Logic
Atomic sentences - more complex than propositions
Boolean functions (Ø,Ù,Ú,Þ,Û) - make compound sentences
Quantifiers (",$) - tell us first-order facts which correspond to sets of sentences
Parentheses

Building Atomic Sentences: Symbols
Domain of Discourse (DOD) - relevant things in the world that we’re reasoning about
Symbols:
variables - assigned things in the domain of discourse (DOD)
constants - things and relations relations between things in the DOD
An interpretation I maps
variables to things in the DOD.
constants to things and relationships between things in the DOD.

Blocks World Example
Domain of Discourse: blocks (for simplicity, exclude table)
Constant Symbols (A, B, C, D, On, Above, …)
Variables (x, y, z, …)
An interpretation maps variables and constant symbols to things in the world. (e.g. A means this block with an “A”.)

Building Atomic Sentences: Constant Symbols
object constants - corresponding to things in the DOD
relation constants - relationships between things in the DOD
relations also called predicates
n-ary relation - a set of n-tuples from the DOD
1-ary relation - a property constant

Blocks World Example
Object Constants: A, B, C, D correspond to blocks with the same letters on them.
Relations Constants:
OnTable: set of blocks resting on table
On: set of block pairs where the first rests on the second
Above: transitive closure of On
Clear: set of blocks with no blocks above

Building Atomic Sentences: Constant Symbols (cont.)
function constants - mappings between tuples and things in the DOD
0-ary function - an object constant
n-ary function (n>0) - special case of n+1-ary relation where n arguments uniquely determine n+1st argument

Atomic Sentences: Putting Symbols Together
terms - variables, objects, functions of terms
atomic sentence - relationship between terms
Under a given interpretation, an atomic sentence is true or false
compound (or complex) sentences are built of atomic sentences, Boolean functions (negation, connectives), and...

Blocks World Example
Terms: x, A, nextBlock(A)
Atomic sentences: Above(A,D), On(x,B), Clear(y)
These sentence are true under an interpretation where constants and relations are as we described and x, y are interpreted as D, A or D, C.
These sentences are also true under an interpretation where A,B,C,D are the numbers 16, 2, 17, 4, On is “the square of”,  Above is “a power of”, Clear is “greater than 15”.

Universal Quantifier
universal (") - “For all”
"x f - “For all x, f is true.”
"Every block is a red block".
"If x>y and y>z then x>z."

Existential Quantifier
existential ($) - “There exists”
$x f - “There exists x such that f is true.”
same as Ø "x Ø f
"There is a block on the table."
Challenging: "If a block is above another block, then the block is on the other block or on a block that is above it."

Nested Quantifiers
nested quantifiers - "x $y is different than $y "x
"Everybody likes someone."
"Someone likes everyone."
Relations: Person, Time, FoolPersonAtTime
"You can fool all the people some of the time, …"
"… and some of the people all the time, …"
"… but you cannot fool all the people all the time."

Compound (Complex) Sentences
variable scope - the parts of a sentence for which a variable quantifier is relevant
free variables - unquantified variables
formula - another word for sentence
well-formed formula (wff) - a sentence with no free variables

First-Order Logic Semantics

In-Class Exercise
Express the following in FOL using relations On, Above, Clear, OnTable, and objects A, B, C, D:
If block A is on block B, then A is above B, B is not clear, and A is not on the table.
If one block is on another block, it is also above that block.
A or D or C is on the table.
If A is on the table, then D and C are not.

Validity, Satisfiability, Models
A sentence is valid if it is true for all possible interpretations.
A sentence is satisfiable if there exists a “satisfying” interpretation (i.e. an interpretation for which the sentence is true).
An interpretation which satisfies a sentence is a model of that sentence.

Propositional KB and Inference
entailment - whether a sentences follows from other sentences
inference rules - deduce new sentences from old sentences
soundness - what can be inferred is entailed
completeness - what is entailed can be inferred

Knowledge Representation and Reasoning
A logic consists of
 a formal language consisting of
syntax
semantics
a proof theory
terms: sentences, KB, valid, satisfiable, model, entail, inference rule, sound, complete

Inference with FOL
Good News: There exists a complete inference procedure for FOL. (Gödel 1930-31)
Robinson’s resolution algorithm
Bad News: Can’t tell if a sentence isn’t entailed Þ FOL is semidecidable.

FOL Proof Method: Resolution
conversion to normal form
generalized resolution
unification

Why Representing Change in Time is Difficult
situation calculus - situations, actions, result function
frame problem - how to say when things don’t change (e.g. cartoon frames)
qualification problem - how to define circumstances under which an action will work (e.g. banana in tailpipe)
ramification problem - how to infer all of the implicit consequences of actions (e.g. moving luggage)