0% found this document useful (0 votes)
42 views

Sentences and The Real World

Syntax describes the principles for constructing and combining sentences. Semantics establishes the relationship between a sentence and the aspects of the Real World it describes. Rules of inference guarantee that, given true facts or premises, the new facts or premises derived by applying the rules are also true.

Uploaded by

scratel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Sentences and The Real World

Syntax describes the principles for constructing and combining sentences. Semantics establishes the relationship between a sentence and the aspects of the Real World it describes. Rules of inference guarantee that, given true facts or premises, the new facts or premises derived by applying the rules are also true.

Uploaded by

scratel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 64

Sentences

Sentences and
and the
the Real
Real World
World
 syntax
 describes the principles for constructing and combining sentences
 e.g. BNF grammar for admissible sentences
 inference rules to derive new sentences from existing ones
 semantics
 establishes the relationship between a sentence and the aspects of the real world it describes
 can be checked directly by comparing sentences with the corresponding objects in the real world
 not always feasible or practical
 complex sentences can be checked by examining their individual parts

Sentences Sentence

Logic and Reasoning 1


Diagram:
Diagram: Sentences
Sentences and
and the
the Real
Real World
World
Real World

Follows
Semantics

Semantics
Model Entails

Sentences Sentence

Syntax
Syntax

Symbols Derives
Symbol String
Symbol Strings
Logic and Reasoning 2
Introduction
Introduction to
to Logic
Logic
 expresses knowledge in a particular mathematical
notation
All birds have wings --> ¥x. Bird(x) ->
HasWings(x)
 rules of inference
 guarantee that, given true facts or premises, the new facts
or premises derived by applying the rules are also true
All robins are birds --> ¥x Robin(x) -> Bird(x)
 given these two facts, application of an inference
rule gives:
¥x Robin(x) -> HasWings(x)

Logic and Reasoning 3


Logic
Logic and
and Knowledge
Knowledge
 rules
of inference act on the superficial structure or
syntax of the first 2 formulas
 doesn'tsay anything about the meaning of birds and robins
 could have substituted mammals and elephants etc.
 major advantages of this approach
 deductions are guaranteed to be correct to an extent that
other representation schemes have not yet reached
 easy to automate derivation of new facts
 problems
 computational efficiency
 uncertain, incomplete, imprecise knowledge

Logic and Reasoning 4


Summary
Summary of
of Logic
Logic Languages
Languages
 propositional logic
 facts
 true/false/unknown
 first-order logic
 facts, objects, relations
 true/false/unknown
 temporal logic
 facts, objects, relations, times
 true/false/unknown
 probability theory
 facts
 degree of belief [0..1]
 fuzzy logic
 degree of truth
 degree of belief [0..1]

Logic and Reasoning 5


Propositional
Propositional Logic
Logic
◆ Syntax
◆ Semantics
◆ Validity and Inference
◆ Models
◆ InferenceRules
◆ Complexity

Logic and Reasoning 6


Syntax
Syntax
◆ symbols
◆ logical constants True, False
◆ propositional symbols P, Q, …
◆ logical connectives
◆ conjunction ∧, disjunction ∨,
◆ negation ¬,
◆ implication ⇒, equivalence ⇔
◆ parentheses (, )
◆ sentences
◆ constructed from simple sentences
◆ conjunction, disjunction, implication, equivalence, negation

Logic and Reasoning 7


BNF
BNF Grammar
Grammar Propositional
Propositional Logic
Logic
Sentence → AtomicSentence | ComplexSentence
AtomicSentence → True | False | P | Q | R | ...
ComplexSentence → (Sentence )
| Sentence Connective Sentence
| ¬ Sentence

Connective → ∧| ∨| ⇒ | ⇔

ambiguities are resolved through precedence ¬ ∧∨⇒ ⇔


or parentheses

e.g. ¬ P ∨Q ∧R ⇒ S is equivalent to (¬ P) ∨(Q ∧R)) ⇒ S

Logic and Reasoning 8


Semantics
Semantics
◆ interpretation of the propositional symbols and
constants
◆ symbols can be any arbitrary fact
◆ sentences consisting of only a propositional symbols are
satisfiable, but not valid
◆ the constants True and False have a fixed interpretation
◆ True indicates that the world is as stated
◆ False indicates that the world is not as stated
◆ specification of the logical connectives
◆ frequently explicitly via truth tables

Logic and Reasoning 9


Validity
Validity and
and Satisfiability
Satisfiability
a sentence is valid or necessarily true if and only if it is true
under all possible interpretations in all possible worlds
 also called a tautology
 since computers reason mostly at the syntactic level, valid sentences
are very important
 interpretations can be neglected
a sentence is satisfiable iff there is some interpretation in
some world for which it is true
 a sentence that is not satisfiable is unsatisfiable
 also known as a contradiction

Logic and Reasoning 10


Truth
Truth Tables for Connectives
Tables for Connectives

P Q ¬ P P ∧Q P ∨Q P ⇒ Q P ⇔ Q
False False True False False True True
False True True False True True False
True False False False True False False
True True False True True True True

Logic and Reasoning 11


Validity
Validity and
and Inference
Inference
◆ truth tables can be used to test sentences for validity
◆ one row for each possible combination of truth values for
the symbols in the sentence
◆ the final value must be True for every sentence

Logic and Reasoning 12


Propositional
Propositional Calculus
Calculus
 properly formed statements that are either True or False
 syntax
 logical constants, True and False
 proposition symbols such as P and Q
 logical connectives: and ^, or V, equivalence <=>, implies => and not ~
 parentheses to indicate complex sentences
 sentences in this language are created through application of
the following rules
 True and False are each (atomic) sentences
 Propositional symbols such as P or Q are each (atomic) sentences
 Enclosing symbols and connective in parentheses yields (complex)
sentences, e.g., (P ^ Q)

Logic and Reasoning 13


Complex
Complex Sentences
Sentences
 Combining simpler sentences with logical connectives yields complex
sentences
 conjunction
 sentence whose main connective is and: P ^ (Q V R)
 disjunction
 sentence whose main connective is or: A V (P ^ Q)
 implication (conditional)
 sentence such as (P ^ Q) => R
 the left hand side is called the premise or antecedent
 the right hand side is called the conclusion or consequent
 implications are also known as rules or if-then statements
 equivalence (biconditional)
 (P ^ Q) <=> (Q ^ P)
 negation
 the only unary connective (operates only on one sentence)
 e.g., ~P

Logic and Reasoning 14


Syntax
Syntax of
of Propositional
Propositional Logic
Logic
A BNF (Backus-Naur Form) grammar of sentences in
propositional logic
Sentence -> AtomicSentence | ComplexSentence

AtomicSentence -> True | False | P | Q | R | ...

ComplexSentence -> (Sentence)


| Sentence Connective Sentence
| ~Sentence

Connective -> ^ | V | <=> | =>

Logic and Reasoning 15


Semantics
Semantics
 propositions can be interpreted as any facts you want
 e.g., P means "robins are birds", Q means "the wumpus is dead", etc.
 meaning of complex sentences is derived from the meaning
of its parts
 one method is to use a truth table
 all are easy except P => Q
 this says that if P is true, then I claim that Q is true; otherwise I make no
claim;
 P is true and Q is true, then P => Q is true
 P is true and Q is false, then P => Q is false
 P is false and Q is true, then P => Q is true
 P is false and Q is false, then P => Q is true

Logic and Reasoning 16


Exercise
Exercise Semantics
Semantics and
and Truth
Truth Tables
Tables
 Use a truth table to prove the following:
P represents the fact "Wally is in location [1, 3]”: W[1,3]
 H represents the fact "Wally is in location [2, 2]”: W[2,2]
 We know that Wally is either in [1,3] or [2,2]: (P V H)
 We learn that Wally is not in [2,2]: ~H
 Can we prove that Wally is in [1,3]: ((P V H) ^ ~H) => P
 This says that if the agent has some premises, and a possible
conclusion, it can determine if the conclusion is true (i.e., all the
rows of the truth table are true)

Logic and Reasoning 17


Inference
Inference Rules
Rules
 more efficient than truth tables

Logic and Reasoning 18


Modus
Modus Ponens
Ponens
 eliminates
=>
(X => Y), X
______________
Y
 If it rains, then the streets will be wet.
 It is raining.
 Infer the conclusion: The streets will be wet. (affirms the
antecedent)

Logic and Reasoning 19


Modus
Modus tollens
tollens
(X => Y), ~Y
_______________
¬X
 If it rains, then the streets will be wet.
 The streets are not wet.
 Infer the conclusion: It is not raining.

 NOTE: Avoid the fallacy of affirming the consequent:


 If it rains, then the streets will be wet.
 The streets are wet.
 cannot conclude that it is raining.

 If Bacon wrote Hamlet, then Bacon was a great writer.


 Bacon was a great writer.
 cannot conclude that Bacon wrote Hamlet.

Logic and Reasoning 20


Syllogism
Syllogism
 chain implications to deduce a conclusion)
(X => Y), (Y => Z)
_____________________
(X => Z)

Logic and Reasoning 21


More
More Inference
Inference Rules
Rules
 and-elimination
 and-introduction
 or-introduction
 double-negation elimination
 unit resolution

Logic and Reasoning 22


Resolution
Resolution
(X v Y), (~Y v Z)
_________________
(X v Z)
 basis for the inference mechanism in the Prolog
language and some theorem provers

Logic and Reasoning 23


Complexity
Complexity issues
issues
 truthtable enumerates 2n rows of the table for any proof
involving n symbol
 it is complete
 computation time is exponential in n
 checking a set of sentences for satisfiability is NP-complete
 but there are some circumstances where the proof only involves a
small subset of the KB, so can do some of the work in polynomial time
 if a KB is monotonic (i.e., even if we add new sentences to a KB, all
the sentences entailed by the original KB are still entailed by the new
larger KB), then you can apply an inference rule locally (i.e., don't have
to go checking the entire KB)

Logic and Reasoning 24


Inference
Inference Methods
Methods 11
 deduction sound
 conclusions must follow from their premises; prototype of logical
reasoning
 induction unsound
 inference from specific cases (examples) to the general
 abduction unsound
 reasoning from a true conclusion to premises that may have
caused the conclusion
 resolution sound
 find two clauses with complementary literals, and combine them
 generate and test unsound
 a tentative solution is generated and tested for validity
 often used for efficiency (trial and error)

Logic and Reasoning 25


Inference
Inference Methods
Methods 22
 default reasoning unsound
 general or common knowledge is assumed in the absence of
specific knowledge
 analogy unsound
 a conclusion is drawn based on similarities to another situation
 heuristics unsound
 rules of thumb based on experience
 intuition unsound
 typically human reasoning method
 nonmonotonic reasoning unsound
 new evidence may invalidate previous knowledge
 autoepistemic unsound
 reasoning about your own knowledge

Logic and Reasoning 26


Predicate
Predicate Logic
Logic
 new concepts (in addition to propositional logic)
 complex objects
 terms
 relations
 predicates
 quantifiers
 syntax
 semantics
 inference rules
 usage

Logic and Reasoning 27


Objects
Objects
 distinguishable things in the real world
 people, cars, computers, programs, ...
 frequently includes concepts
 colors, stories, light, money, love, ...
 properties
 describe specific aspects of objects
 green, round, heavy, visible,
 can be used to distinguish between objects

Logic and Reasoning 28


Relations
Relations
 establish connections between objects
 relations can be defined by the designer or user
 neighbor, successor, next to, taller than, younger than, …
 functions are a special type of relation
 non-ambiguous: only one output for a given input

Logic and Reasoning 29


Syntax
Syntax
 also based on sentences, but more complex
 sentences can contain terms, which represent objects
 constant symbols: A, B, C, Franz, Square1,3, …
 stand for unique objects ( in a specific context)
 predicate symbols: Adjacent-To, Younger-Than, ...
 describes relations between objects
 function symbols: Father-Of, Square-Position, …
 the given object is related to exactly one other object

Logic and Reasoning 30


Semantics
Semantics
 provided by interpretations for the basic constructs
 usually suggested by meaningful names
 constants
 the interpretation identifies the object in the real world
 predicate symbols
 the interpretation specifies the particular relation in a model
 may be explicitly defined through the set of tuples of objects that satisfy the
relation
 function symbols
 identifies the object referred to by a tuple of objects
 may be defined implicitly through other functions, or explicitly through tables

Logic and Reasoning 31


BNF
BNF Grammar
Grammar Predicate
Predicate Logic
Logic
Sentence → AtomicSentence
| Sentence Connective Sentence
| Quantifier Variable, ... Sentence
| ¬ Sentence | (Sentence)
AtomicSentence → Predicate(Term, …) | Term = Term
Term → Function(Term, …) | Constant | Variable
Connective → ∧| ∨| ⇒ | ⇔
Quantifier →∀ | ∃
Constant→ A, B, C, X1 , X2, Jim, Jack
Variable → a, b, c, x1 , x2, counter, position
Predicate → Adjacent-To, Younger-Than,
Function → Father-Of, Square-Position, Sqrt, Cosine

ambiguities are resolved through precedence or parentheses

Logic and Reasoning 32


Terms
Terms
 logical
expressions that specify objects
 constants and variables are terms
 more complex terms are constructed from function
symbols and simpler terms, enclosed in parentheses
 basically a complicated name of an object
 semantics
is constructed from the basic
components, and the definition of the functions
involved
 either through explicit descriptions (e.g. table), or via other
functions

Logic and Reasoning 33


Unification
Unification
 anoperation that tries to find consistent variable
bindings (substitutions) for two terms
a substitution is the simultaneous replacement of variable
instances by terms, providing a “binding” for the variable
 without unification, the matching between rules would be
restricted to constants
 often used together with the resolution inference rule
 unification itself is a very powerful and possibly complex
operation
 in many practical implementations, restrictions are imposed
 e.g. substitutions may occur only in one direction (“matching”)

Logic and Reasoning 34


Atomic
Atomic Sentences
Sentences
 statefacts about objects and their relations
 specified through predicates and terms
 the predicate identifies the relation, the terms identify the
objects that have the relation
 anatomic sentence is true if the relation between
the objects holds
 this can be verified by looking it up in the set of tuples that
define the relation

Logic and Reasoning 35


Complex
Complex Sentences
Sentences
 logical
connectives can be used to build more
complex sentences
 semantics is specified as in propositional logic

Logic and Reasoning 36


Quantifiers
Quantifiers
 canbe used to express properties of collections of
objects
 eliminates the need to explicitly enumerate all objects
 predicate logic uses two quantifiers
 universal quantifier ∀
 existential quantifier ∃

Logic and Reasoning 37


Universal
Universal Quantification
Quantification
 states that a predicate P is holds for all objects x in
the universe under discourse
∀x P(x)
 the sentence is true if and only if all the individual
sentences where the variable x is replaced by the
individual objects it can stand for are true

Logic and Reasoning 38


Existential
Existential Quantification
Quantification
 states that a predicate P holds for some objects in
the universe
∃ x P(x)
 the sentence is true if and only if there is at least one
true individual sentence where the variable x is
replaced by the individual objects it can stand for

Logic and Reasoning 39


Horn
Horn clauses
clauses or
or sentences
sentences
 classof sentences for which a polynomial-time
inference procedure exists
 P1 ∧P2 ∧...∧Pn => Q
where Pi and Q are non-negated atomic
sentences
 not every knowledge base can be written as a
collection of Horn sentences
 Horn clauses are essentially rules of the form
 If P1 ∧P2 ∧...∧Pn then Q

Logic and Reasoning 40


Reasoning
Reasoning in
in Knowledge-Based
Knowledge-Based
Systems
Systems
 shallow and deep reasoning
 forward and backward chaining
 alternative inference methods
 metaknowledge

Logic and Reasoning 41


Shallow
Shallow and
and Deep
Deep Reasoning
Reasoning
 shallow reasoning
 also called experiential reasoning
 aims at describing aspects of the world heuristically
 short inference chains
 possibly complex rules
 deep reasoning
 also called causal reasoning
 aims at building a model of the world that behaves like the “real thing”
 long inference chains
 often simple rules that describe cause and effect relationships

Logic and Reasoning 42


Examples
Examples Shallow
Shallow and
and Deep
Deep
Reasoning
Reasoning
 shallow reasoning  deep reasoning
IF a car has IF the battery is good
THEN there is electricity
a good battery
IF there is electricity AND
good spark plugs
good spark plugs
gas THEN the spark plugs will fire
good tires IF the spark plugs fire AND
there is gas
THEN the car can move
THEN the engine will run
IF the engine runs AND
there are good tires
THEN the car can move

Logic and Reasoning 43


Forward
Forward Chaining
Chaining
 given a set of basic facts, we try to derive a
conclusion from these facts
 example: What can we conjecture about Clyde?

IF elephant(x) THEN mammal(x)


IF mammal(x) THEN animal(x)
elephant (Clyde)

modus ponens:
unification:
IF p THEN q
p find compatible values for
variables
q
Logic and Reasoning 44
Forward
Forward Chaining
Chaining Example
Example
IF elephant(x) THEN mammal(x) unification:
IF mammal(x) THEN animal(x) find compatible values for
variables
elephant(Clyde)

modus ponens:
IF p THEN q
p
q

IF elephant( x ) THEN mammal( x )

elephant (Clyde)
Logic and Reasoning 45
Forward
Forward Chaining
Chaining Example
Example
IF elephant(x) THEN mammal(x) unification:
IF mammal(x) THEN animal(x) find compatible values for
variables
elephant(Clyde)

modus ponens:
IF p THEN q
p
q

IF elephant(Clyde) THEN mammal(Clyde)

elephant (Clyde)
Logic and Reasoning 46
Forward
Forward Chaining
Chaining Example
Example
IF elephant(x) THEN mammal(x) unification:
IF mammal(x) THEN animal(x) find compatible values for
variables
elephant(Clyde)

modus ponens:
IF p THEN q
p
q

IF mammal( x ) THEN animal( x )

IF elephant(Clyde) THEN mammal(Clyde)

elephant (Clyde)
Logic and Reasoning 47
Forward
Forward Chaining
Chaining Example
Example
IF elephant(x) THEN mammal(x) unification:
IF mammal(x) THEN animal(x) find compatible values for
variables
elephant(Clyde)

modus ponens:
IF p THEN q
p
q

IF mammal(Clyde) THEN animal(Clyde)

IF elephant(Clyde) THEN mammal(Clyde)

elephant (Clyde)
Logic and Reasoning 48
Forward
Forward Chaining
Chaining Example
Example
IF elephant(x) THEN mammal(x) unification:
IF mammal(x) THEN animal(x) find compatible values for
variables
elephant(Clyde)

modus ponens:
IF p THEN q
p
animal( x )
q

IF mammal(Clyde) THEN animal(Clyde)

IF elephant(Clyde) THEN mammal(Clyde)

elephant (Clyde)
Logic and Reasoning 49
Forward
Forward Chaining
Chaining Example
Example
IF elephant(x) THEN mammal(x) unification:
IF mammal(x) THEN animal(x) find compatible values for
variables
elephant(Clyde)

modus ponens:
IF p THEN q
p
animal(Clyde)
q

IF mammal(Clyde) THEN animal(Clyde)

IF elephant(Clyde) THEN mammal(Clyde)

elephant (Clyde)
Logic and Reasoning 50
Backward
Backward Chaining
Chaining

Logic and Reasoning 51


Backward
Backward Chaining
Chaining
 tryto find supportive evidence (i.e. facts) for a
hypothesis
 example: Is there evidence that Clyde is an animal?

IF elephant(x) THEN mammal(x)


IF mammal(x) THEN animal(x)
elephant (Clyde)

modus ponens:
unification:
IF p THEN q
p find compatible values for
variables
q
Logic and Reasoning 52
Backward
Backward Chaining
Chaining Example
Example
IF elephant(x) THEN mammal(x) unification:
IF mammal(x) THEN animal(x) find compatible values for
variables
elephant(Clyde)

modus ponens:
IF p THEN q
p
q
animal(Clyde) ?
IF mammal( x ) THEN animal( x )

Logic and Reasoning 53


Backward
Backward Chaining
Chaining Example
Example
IF elephant(x) THEN mammal(x) unification:
IF mammal(x) THEN animal(x) find compatible values for
variables
elephant(Clyde)

modus ponens:
IF p THEN q
p
q
animal(Clyde) ?
IF mammal(Clyde) THEN animal(Clyde)

Logic and Reasoning 54


Backward
Backward Chaining
Chaining Example
Example
IF elephant(x) THEN mammal(x) unification:
IF mammal(x) THEN animal(x) find compatible values for
variables
elephant(Clyde)

modus ponens:
IF p THEN q
p
q
animal(Clyde) ?
IF mammal(Clyde) THEN animal(Clyde)
?
IF elephant( x ) THEN mammal( x )

Logic and Reasoning 55


Backward
Backward Chaining
Chaining Example
Example
IF elephant(x) THEN mammal(x) unification:
IF mammal(x) THEN animal(x) find compatible values for
variables
elephant(Clyde)

modus ponens:
IF p THEN q
p
q
animal(Clyde) ?
IF mammal(Clyde) THEN animal(Clyde)
?
IF elephant(Clyde) THEN mammal(Clyde)

Logic and Reasoning 56


Backward
Backward Chaining
Chaining Example
Example
IF elephant(x) THEN mammal(x) unification:
IF mammal(x) THEN animal(x) find compatible values for
variables
elephant(Clyde)

modus ponens:
IF p THEN q
p
q
animal(Clyde) ?
IF mammal(Clyde) THEN animal(Clyde)
?
IF elephant(Clyde) THEN mammal(Clyde)

elephant ( x ) ? Logic and Reasoning 57


Backward
Backward Chaining
Chaining Example
Example
IF elephant(x) THEN mammal(x) unification:
IF mammal(x) THEN animal(x) find compatible values for
variables
elephant(Clyde)

modus ponens:
IF p THEN q
p
animal(Clyde)
q

IF mammal(Clyde) THEN animal(Clyde)

IF elephant(Clyde) THEN mammal(Clyde)

elephant (Clyde)
Logic and Reasoning 58
Forward
Forward vs.
vs. Backward
Backward Chaining
Chaining
Forward Chaining Backward Chaining
planning, control diagnosis
data-driven goal-driven (hypothesis)
bottom-up reasoning top-down reasoning
find possible conclusions find facts that support a given
supported by given facts hypothesis
similar to breadth-first search similar to depth-first search
antecedents (LHS) control consequents (RHS) control
evaluation evaluation

Logic and Reasoning 59


Alternative
Alternative Inference
Inference Methods
Methods
 theorem proving
 emphasis on mathematical proofs, not so much on
performance and ease of use
 probabilistic reasoning
 integrates probabilities into the reasoning process
 fuzzy reasoning
 enables the use of ill-defined predicates

Logic and Reasoning 60


Metaknowledge
Metaknowledge
 deals with “knowledge about knowledge”
 e.g.reasoning about properties of knowledge
representation schemes, or inference mechanisms
 usually relies on higher order logic
 in (first order) predicate logic, quantifiers are applied to variables
 second-order predicate logic allows the use of quantifiers for
function and predicate symbols
 equality is an important second order axiom
» two objects are equal if all their properties (predicates) are equal
 may result in substantial performance problems

Logic and Reasoning 61


Important
Important Concepts
Concepts and
and Terms
Terms
 and operator  not operator
 atomic sentence  or operator
 backward chaining  predicate logic
 existential quantifier  propositional logic
 expert system shell
 forward chaining
 production rules
 higher order logic  quantifier
 Horn clause  reasoning
 inference  rule
 inference mechanism  satisfiability
 If-Then rules  semantics
 implication  sentence
 knowledge
 symbol
 knowledge base
 knowledge-based system
 syntax
 knowledge representation  term
 matching  validity
 meta-knowledge  unification
 universal quantifier

Logic and Reasoning 62


Summary
Summary Reasoning
Reasoning
 reasoning relies on the ability to generate new knowledge
from existing knowledge
 implemented through inference rules
 related terms: inference procedure, inference mechanism, inference engine
 computer-based reasoning relies on syntactic symbol
manipulation (derivation)
 inference rules prescribe which combination of sentences can be used
to generate new sentences
 ideally, the outcome should be consistent with the meaning of the
respective sentences (“sound” inference rules)
 logicprovides the formal foundations for many knowledge
representation schemes
 rules are frequently used in expert systems

Logic and Reasoning 63


Logic and Reasoning 64

You might also like