Docsity

Understanding First-Order Logic: Syntax, Semantics, and Inference, Slides of Artificial Intelligence

Toggle sidebar
bg1
First-Order Logic
Syntax
Reading: Chapter 8, 9.1-9.2, 9.5.1-9.5.5
FOL Syntax and Semantics read: 8.1-8.2
FOL Knowledge Engineering read: 8.3-8.5
FOL Inference read: Chapter 9.1-9.2, 9.5.1-9.5.5
(Please read lecture topic material before and after each
lecture on that topic)
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39

Partial preview of the text

Download Understanding First-Order Logic: Syntax, Semantics, and Inference and more Slides Artificial Intelligence in PDF only on Docsity!

First-Order Logic

Syntax

Reading: Chapter 8, 9.1-9.2, 9.5.1-9.5.

FOL Syntax and Semantics read: 8.1-8.

FOL Knowledge Engineering read: 8.3-8.

FOL Inference read: Chapter 9.1-9.2, 9.5.1-9.5.

(Please read lecture topic material before and after each

lecture on that topic)

Common Sense Reasoning

Example, adapted from Lenat

You are told: John drove to the grocery store and bought a

pound of noodles, a pound of ground beef, and two pounds of tomatoes.

  • Is John 3 years old?
  • Is John a child?
  • What will John do with the purchases?
  • Did John have any money?
  • Does John have less money after going to the store?
  • Did John buy at least two tomatoes?
  • Were the tomatoes made in the supermarket?
  • Did John buy any meat?
  • Is John a vegetarian?
  • Will the tomatoes fit in John’s car?
  • Can Propositional Logic support these inferences?

FOL Syntax: You will be expected to know

  • FOPC syntax
    • Syntax: Sentences, predicate symbols, function symbols, constant symbols, variables, quantifiers
  • De Morgan’s rules for quantifiers
    • connections between ∀ and ∃
  • Nested quantifiers
    • Difference between “∀ x ∃ y P(x, y)” and “∃ x ∀ y P(x, y)”
    • ∀ x ∃ y Likes(x, y) --- “Everybody likes somebody.”
    • ∃ x ∀ y Likes(x, y) --- “Somebody likes everybody.”
  • Translate simple English sentences to FOPC and back
    • ∀ x ∃ y Likes(x, y) ⇔ “Everyone has someone that they like.”
    • ∃ x ∀ y Likes(x, y) ⇔ “There is someone who likes every person.”

Pros and cons of propositional logic

 Propositional logic is declarative

  • Knowledge and inference are separate

 Propositional logic allows partial/disjunctive/negated information

  • unlike most programming languages and databases

 Propositional logic is compositional:

  • meaning of B1,1 ∧ P1,2 is derived from meaning of B1,1 and of P1,

 Meaning in propositional logic is context-independent

  • unlike natural language, where meaning depends on context

 Propositional logic has limited expressive power

  • E.g., cannot say “Pits cause breezes in adjacent squares.“
    • except by writing one sentence for each square
  • Needs to refer to objects in the world,
  • Needs to express general rules

Aside: First-Order Logic (FOL) vs. Second-Order Logic

  • First Order Logic (FOL) allows variables and general rules
    • “First order” because quantified variables represent objects.
    • “Predicate Calculus” because it quantifies over predicates on objects.
      • E.g., “Integral Calculus” quantifies over functions on numbers.
  • Aside: Second Order logic
    • “Second order” because quantified variables can also represent predicates and functions. - E.g., can define “Transitive Relation,” which is beyond FOPC.
  • Aside: In FOL we can state that a relationship is transitive
    • E.g., BrotherOf is a transitive relationship
    • ∀ x, y, z BrotherOf(x,y) ∧ BrotherOf(y,z) => BrotherOf(x,z)
  • Aside: In Second Order logic we can define “Transitive”
    • ∀ P, x, y, z Transitive(P)  ( P(x,y) ∧ P(y,z) => P(x,z) )
    • Then we can state directly, Transitive(BrotherOf)

FOL (or FOPC) Ontology:

What kind of things exist in the world?

What do we need to describe and reason about?

Objects --- with their relations, functions, predicates, properties, and general rules.

Reasoning

Representation

A Formal

Symbol System

Inference

Formal Pattern

Matching

Syntax

What is

said

Semantics

What it

means

Schema

Rules of

Inference

Execution

Search

Strategy

Syntax of FOL: Basic syntax elements are symbols

  • Constant Symbols (correspond to English nouns)
    • Stand for objects in the world.
      • E.g., KingJohn, 2, UCI, ...
  • Predicate Symbols (correspond to English verbs)
    • Stand for relations (maps a tuple of objects to a truth-value )
      • E.g., Brother(Richard, John), greater_than(3,2), ...
    • P(x, y) is usually read as “x is P of y.”
      • E.g., Mother(Ann, Sue) is usually “Ann is Mother of Sue.”
  • Function Symbols (correspond to English nouns)
    • Stand for functions (maps a tuple of objects to an object )
      • E.g., Sqrt(3), LeftLegOf(John), ...
  • Model (world) = set of domain objects, relations, functions
  • Interpretation maps symbols onto the model (world)
    • Very many interpretations are possible for each KB and world!
    • Job of the KB is to rule out models inconsistent with our knowledge.

Syntax : Relations, Predicates, Properties, Functions

  • Mathematically, all the Relations, Predicates, Properties, and Functions CAN BE represented simply as sets of m -tuples of objects:
  • Let W be the set of objects in the world.
  • Let Wm^ = W x W x … (m times) … x W
    • The set of all possible m -tuples of objects from the world
  • An m -ary Relation is a subset of W m.
    • Example: Let W = {John, Sue, Bill}
    • Then W 2 = {<John, John>, <John, Sue>, …, <Sue, Sue>}
    • E.g., MarriedTo = {<John, Sue>, <Sue, John>}
    • E.g., FatherOf = {<John, Bill>}
  • Analogous to a constraint in CSPs
    • The constraint lists the m -tuples that satisfy it.
    • The relation lists the m -tuples that participate in it.

Syntax of FOL: Terms

  • Term = logical expression that refers to an object
  • There are two kinds of terms:
    • Constant Symbols stand for (or name) objects:
      • E.g., KingJohn, 2, UCI, Wumpus, ...
    • Function Symbols map tuples of objects to an object:
      • E.g., LeftLeg(KingJohn), Mother(Mary), Sqrt(x)
      • This is nothing but a complicated kind of name
        • No “subroutine” call, no “return value”

Syntax of FOL: Atomic Sentences

  • Atomic Sentences state facts (logical truth values).
    • An atomic sentence is a Predicate symbol, optionally

followed by a parenthesized list of any argument terms

  • E.g., Married( Father(Richard), Mother(John) )
  • An atomic sentence asserts that some relationship (some

predicate) holds among the objects that are its arguments.

  • An Atomic Sentence is true in a given model if the relation referred to by the predicate symbol holds among the objects (terms) referred to by the arguments.

Syntax of FOL: Connectives & Complex Sentences

  • Complex Sentences are formed in the same way, and are formed using the same logical connectives, as we already know from propositional logic
  • The Logical Connectives :
    • ⇔ biconditional
    • ⇒ implication
    • ∧ and
    • ∨ or
    • ¬ negation
  • Semantics for these logical connectives are the same as

we already know from propositional logic.

Complex Sentences

  • We make complex sentences with connectives (just like in

propositional logic).

¬ Brother LeftLeg Richard ( ( ), John ) ∨(Democrat Bush ( ))

binary

relation

function

property

objects

connectives

Syntax of FOL: Variables

  • Variables range over objects in the world.
  • A variable is like a term because it represents an object.
  • A variable may be used wherever a term may be used.
    • Variables may be arguments to functions and predicates.
  • (A term with NO variables is called a ground term .)
  • (A variable not bound by a quantifier is called free .)

Syntax of FOL: Logical Quantifiers

  • There are two Logical Quantifiers:
    • Universal: ∀ x P(x) means “For all x, P(x).”
      • The “upside-down A” reminds you of “ALL.”
    • Existential: ∃ x P(x) means “There exists x such that, P(x).”
      • The “backward E” reminds you of “EXISTS.”
  • Syntactic “sugar” --- we really only need one quantifier.
    • ∀ x P(x) ≡ ¬∃ x ¬P(x)
    • ∃ x P(x) ≡ ¬∀ x ¬P(x)
    • You can ALWAYS convert one quantifier to the other.
  • RULES: ∀ ≡ ¬∃¬ and ∃ ≡ ¬∀¬
  • RULE: To move negation “in” across a quantifier, change the quantifier to “the other quantifier” and negate the predicate on “the other side.”
    • ¬∀ x P(x) ≡ ∃ x ¬P(x)
    • ¬∃ x P(x) ≡ ∀ x ¬P(x)