You are on page 1of 22

Why Do We Need Logic?

• Problem-solving agents were very inflexible: hard code every


possible state.

• Search is almost always exponential in the number of states.

• Problem solving agents cannot infer unobserved information.

• We want an agent that can reason similarly to humans.


Knowledge & Reasoning
To address these issues we will introduce

• A knowledge base (KB): a list of facts that are known


to the agent.

• Rules to infer new facts from old facts using rules of


inference.

• Logic provides the natural language for this.


knowledge-based agent levels
• Knowledge Level.
– The most abstract level: describe agent by saying what it knows.
– Example: A taxi agent might know that the Golden Gate Bridge
connects San Francisco with the Marin County.
• Logical Level.
– The level at which the knowledge is encoded into sentences.
– Example: Links(GoldenGateBridge, SanFrancisco, MarinCounty).
• Implementation Level.
– The physical representation of the sentences in the logical level.
– Example: ‘(links goldengatebridge sanfrancisco
marincounty)

4
• Logics are formal languages for representing
information such that conclusions can be
drawn
• Syntax defines the sentences in the language
• Semantics define the "meaning" of sentences;
– i.e., define truth of a sentence in a world
• E.g., the language of arithmetic
– x+2 ≥ y is a sentence; x2+y > {} is not a sentence syntax
– x+2 ≥ y is true in a world where x = 7, y = 1
• There are two types of logical arguments - 
deductive and inductive.
• Deductive - This type of reasoning provides
complete evidence of the truth of its conclusion.
• Inductive - This type of reasoning is "bottom up,"
meaning that it takes specific information and
makes a broad generalization that is considered
probable, allowing for the fact that the
conclusion may not be accurate. 
First-order logic
• First-order logic—also known as predicate
logic and first-order predicate calculus—is a
collection of formal systems used in 
mathematics, philosophy, linguistics, and
computer science. First-order logic uses 
quantified variables over non-logical objects
and allows the use of sentences that contain
variables, 
• Whereas propositional logic assumes that a world
contains facts, first-order logic (like natural language)
assumes the world contains
• – Objects: people, houses, numbers, theories, Ronald
McDonald, colors, baseball games, wars, centuries : : :
• – Relations: red, round, bogus, prime, multistoried : : :,
brother of, bigger than, inside, part of, has color,
occurred after, owns, comes between, : : :
• – Functions: father of, best friend, third inning of, one
more than, end of
FOL syntax elements
Quantifiers
Models for FOL: Example
Properties of quantifiers
Example sentences
Propositional Logic

• Propositional logic, also known as sentential


logic and statement logic, is the branch of
logic that studies ways of joining and/or
modifying entire propositions, statements or
sentences to form more complicated
propositions, statements or sentences, as well
as the logical relationships and properties that
are derived from these methods of combining
or altering statements.
Propositional logic: Syntax
• Propositional logic is the simplest logic – illustrates basic
ideas

• The proposition symbols P1, P2 etc are sentences

– If S is a sentence, S is a sentence (negation)


– If S1 and S2 are sentences, S1  S2 is a sentence (conjunction)
– If S1 and S2 are sentences, S1  S2 is a sentence (disjunction)
– If S1 and S2 are sentences, S1  S2 is a sentence (implication)
– If S1 and S2 are sentences, S1  S2 is a sentence (biconditional)
Propositional logic: Semantics
Each model/world specifies true or false for each proposition symbol
E.g. P1,2 P2,2 P3,1
false true false
With these symbols, 8 possible models, can be enumerated automatically.

Rules for evaluating truth with respect to a model m:


S is true iff S is false
S1  S2 is true iff S1 is true and S2 is true
S1  S2 is true iff S1is true or S2 is true
S1  S2 is true iff S1 is false or S2 is true
i.e., is false iff S1 is true and S2 is false
S1  S2 is true iff S1S2 is true andS2S1 is true

Simple recursive process evaluates an arbitrary sentence, e.g.,

P1,2  (P2,2  P3,1) = true  (true  false) = true  true = true


Truth tables for connectives

OR: P or Q is true or both are true. Implication is always true


XOR: P or Q is true but not both. when the premises are False!
Validity and satisfiability
A sentence is valid if it is true in all models,
e.g., True, A A, A  A, (A  (A  B))  B

Validity is connected to inference via the Deduction Theorem:


KB ╞ α if and only if (KB  α) is valid

A sentence is satisfiable if it is true in some model


e.g., A B, C

A sentence is unsatisfiable if it is false in all models


e.g., AA

Satisfiability is connected to inference via the following:


KB ╞ α if and only if (KB α) is unsatisfiable

(there is no model for which KB=true and is false)
Predicate Logic

• A predicate is an expression of one or more


variables defined on some specific domain. A
predicate with variables can be made a
proposition by either assigning a value to the
variable or by quantifying the variable.
• The following are some examples of predicates −
• Let E(x, y) denote "x = y"
• Let X(a, b, c) denote "a + b + c = 0"
• Let M(x, y) denote "x is married to y"
comparison
• n propositional logic, we use letters to symbolize entire
propositions. Propositions are statements of the form
"x is y" where x is a subject and y is a predicate. For
example, "Socrates is a man" is a proposition and
might be represented in propositional logic as "S".
• In predicate logic, we symbolize subject and predicate
separately. Logicians often use lowercase letters to
symbolize subjects (or objects) and uppercase letter to
symbolize predicates. For example, Socrates is a
subject and might be represented in predicate logic as
"s" while "man" is a predicate and might be
represented as "M". If so, "Socrates is a man" would be
represented "Ms".
• The important difference is that you can use
predicate logic to say something about a set
of objects. By introducing the universal
quantifier ("∀"), the existential quantifier
("∃") and variables ("x", "y" or "z"), we can
use predicate logic to represent thing like
"Everything is green" as "∀Gx" or "Something
is blue" as "∃Bx".
Backus–Naur form

• In computer science, Backus–Naur form or Backus normal


form (BNF) is a notation technique for 
context-free grammars, often used to describe the syntax
 of languages used in computing, such as
computer programming languages, document
formats, instruction sets and communication protocols.
They are applied wherever exact descriptions of languages
are needed: for instance, in official language specifications,
in manuals, and in textbooks on programming language
theory.
• Many extensions and variants of the original Backus–Naur
notation are used; some are exactly defined,
including extended Backus–Naur form (EBNF)
and augmented Backus–Naur form (ABNF).

You might also like