Slide 1 Propositional Logic Intro, Syntax Jim Little UBC CS 322 – CSP October 17, 2014 Textbook §...
-
Upload
jemima-hunt -
Category
Documents
-
view
224 -
download
4
description
Transcript of Slide 1 Propositional Logic Intro, Syntax Jim Little UBC CS 322 – CSP October 17, 2014 Textbook §...
Slide 1
Propositional Logic Intro, Syntax
Jim LittleUBC CS 322 – CSP October 17, 2014
Textbook § 5.1- 5.1.1 – 5.2
Slide 2
Lecture Overview
• Recap Planning
• Logic Intro
• Propositional Definite Clause Logic: Syntax
Slide 3
Recap Planning
• Represent possible actions with …..
• Plan can be found by…..
• Or can be found by mapping planning problem into…
STRIPS
CSP
search
Solve planning as CSP: pseudo code
Slide 4
solved = falsefor horizon h=0,1,2,… map STRIPS into a CSP csp with horizon h solve that csp if solution exists then return solution else horizon = horizon + 1end
Planning as CSP
Slide 5
STRIPS to CSP applet
Slide 6
Allows you:• to specify a planning problem in STRIPS• to map it into a CSP for a given horizon• the CSP translation is automatically loaded into the CSP applet where it can be solved
Practice exercise using STRIPS to CSP is available on AIspace
West
North
East
South
62
8Q
QJ65
97
AK53
A9
Slide 7
Now, do you know how to implement a planner for….
• Emergency Evacuation?• Robotics?• Space Exploration?• Manufacturing Analysis?• Games (e.g., Bridge)?• Generating Natural language
• Product Recommendations ….
Slide 8
No , but you (will) know the
key ideas !• Ghallab, Nau, and TraversoAutomated Planning: Theory and PracticeMorgan Kaufmann, May 2004ISBN 1-55860-856-7
• Web site: http://www.laas.fr/planning
Slide 9
Lecture Overview
• Recap Planning
• Logic Intro
• Propositional Definite Clause Logic: Syntax
Lecture Overview
• Recap of Lecture 6• Planning as CSP • Logic
• Intro• Propositional Definite Clause Logic (PDCL)• Logical Consequences and Proof Procedures• Bottom Up Proof Procedure
Slide 10
Where Are We?Environment
Problem Type
Query
Planning
Deterministic Stochastic
Constraint Satisfaction Search
Arc Consistency
Search
Search
Logics
STRIPS
Vars + Constraints
Value Iteration
Variable Elimination
Belief Nets
Decision Nets
Markov Processes
Static
Sequential
RepresentationReasoningTechnique
Variable Elimination
First Part of the Course Slide 11
Where Are We?Environment
Problem Type
Query
Planning
Deterministic Stochastic
Constraint Satisfaction Search
Arc Consistency
Search
Search
Logics
STRIPS
Vars + Constraints
Value Iteration
Variable Elimination
Belief Nets
Decision Nets
Markov Processes
Static
Sequential
RepresentationReasoningTechnique
Variable Elimination
Back to static problems, but with
richer representation
Slide 12
Logics in AI: Similar slide to the one for planning
Propositional Logics
First-Order Logics
Propositional Definite Clause
Logics
Semantics and Proof Theory
Satisfiability Testing (SAT)
Description Logics
Cognitive Architectures
Video Games
Ontologies
Semantic Web
Information Extraction
Summarization
Production Systems
Tutoring Systems
Hardware Verification
Product Configuration
Software Verification
Applications
Slide 13
Logics in AI: Similar slide to the one for planning
Propositional Logics
First-Order Logics
Propositional Definite Clause
Logics
Semantics and Proof Theory
Description Logics
Cognitive Architectures
Video Games
Hardware Verification
Product ConfigurationOntologies
Semantic Web
Information Extraction
Summarization
Production Systems
Tutoring Systems
Software Verification
You will know
You will know a little
Applications
Satisfiability Testing (SAT)
Slide 14
What you already know about logic...• From programming: Some logical
operators• If ((amount > 0) && (amount < 1000)) || !(age < 30) • ...
Logic is the language of Mathematics. To define formal structures (e.g., sets, graphs) and to prove statements about those
You know what they mean in a “procedural” way
We use logic as a Representation and Reasoning Systemthat can be used to formalize a domain and to reason about it
Slide 15
Logic: a framework for representation & reasoning
• When we represent a domain about which we have only partial (but certain) information, we need to represent….• Objects, properties, sets, groups, actions, events, time,
space, …• All these can be represented as
• Objects• Relationships between objects
• Logic is the language to express knowledge about the world this way• http://en.wikipedia.org/wiki/John_McCarthy (1927 - 2011) Logic and AI “The Advice Taker” Coined “Artificial Intelligence”. Dartmouth W’shop (1956)
Slide 16
Why Logics?“Natural” to express knowledge about the world(more natural than a “flat” set of variables & constraints)
e.g. “Every 101 student will pass the course” Course (c1) Name-of (c1, 101)
• It is easy to incrementally add knowledge • It is easy to check and debug knowledge• Provides language for asking complex
queries• Well understood formal properties
Slide 17
Logic: A general framework for reasoning
General problem: Query answering• tell the computer how the world works• tell the computer some facts about the world• ask a yes/no question about whether other facts must be
true
Solving it with Logic1. Begin with a task domain.2. Distinguish those things you want to talk about (the
ontology)3. Choose symbols in the computer to denote elements of your
ontology4. Tell the system knowledge about the domain5. Ask the system whether new statements about the domain
are true or false
live_w4? lit_l2? Slide 18
Example: Electrical Circuit
/ up
/down
Slide 19
/ up
/down
Syntax: are these sentences that a reasoning procedure can process?
Semantics: what do these statements say about the world I need to represent?
Slide 20
To Define a Logic We Need
• Syntax: specifies the symbols used, and how they can be combined to form legal sentences • Knowledge base is a set of sentences in the language
• Semantics: specifies the meaning of symbols and sentences
• Reasoning theory or proof procedure: a specification of how an answer can be produced.• Sound: only generates correct answers with respect to
the semantics• Complete: Guaranteed to find an answer if it exists
Slide 21
Propositional Definite ClausesWe will start with a simple logic
• Primitive elements are propositions: Boolean variables that can be {true, false}
Two kinds of statements:• that a proposition is true• that a proposition is true if one or more other propositions
are true
Why only propositions?• We can exploit the Boolean nature for efficient reasoning• Starting point for more complex logics
We need to specify: syntax, semantics, proof procedure Slide 22
Lecture Overview
• Recap of Lecture 6• Planning as CSP • Logic
• Intro• Propositional Definite Clause Logic (PDCL)
• Syntax and Semantics• Logical Consequences and Proof Procedures• Bottom Up Proof Procedure
Slide 23
Propositional Definite Clauses: Syntax
Definition (atom)An atom is a symbol starting with a lower case letter
Definition (body)A body is an atom or is of the form b1 ∧ b2 where b1 and b2 are bodies.
Definition (definite clause)A definite clause is - an atom or - a rule of the form h ← b where h is an atom (“head”) and b is a body. (Read this as “h if b”.)
Definition (KB)A knowledge base (KB) is a set of definite clauses
Examples: p1; live_l1
Examples: p1 ∧ p2; ok_w1 ∧ live_w0
Examples: p1 ← p2; live_w0 ← live_w1 ∧ up_s2
Slide 24
atoms
rules
definiteclauses, KB
Slide 25
PDCL Syntax: more examples
a) ai_is_fun
b) ai_is_fun ∨ ai_is_boring
c) ai_is_fun ← learn_useful_techniques
d) ai_is_fun ← learn_useful_techniques ∧ notTooMuch_work
e) ai_is_fun ← learn_useful_techniques ∧ TooMuch_work
f) ai_is_fun ← f(time_spent, material_learned)
g) srtsyj ← errt ∧ gffdgdgd
How many of the clauses below are legal PDCL clauses?
Definition (definite clause)A definite clause is - an atom or - a rule of the form h ← b where h is an atom (‘head’) and b is a body.
(Read this as ‘h if b.’) A body is an atom or is of the form b1 ∧ b2 where b1 and b2 are bodies
B. 4 C. 5A. 3 D. 6 E. 7
Slide 26
PDC Syntax: more examples
a) ai_is_fun
b) ai_is_fun ∨ ai_is_boring
c) ai_is_fun ← learn_useful_techniques
d) ai_is_fun ← learn_useful_techniques ∧ notTooMuch_work
e) ai_is_fun ← learn_useful_techniques ∧ TooMuch_work
f) ai_is_fun ← f(time_spent, material_learned)
g) srtsyj ← errt ∧ gffdgdgd
Do any of these statements mean anything? Syntax doesn't answer this question!
Legal PDC clause Not a legal PDC clause
Slide 27
To Define a Logic We Need
• Syntax: specifies the symbols used, and how they can be combined to form legal sentences • Knowledge base is a set of sentences in the language
• Semantics: specifies the meaning of symbols and sentences
• Reasoning theory or proof procedure: a specification of how an answer can be produced.• Sound: only generates correct answers with respect to
the semantics• Complete: Guaranteed to find an answer if it exists
Slide 28
Propositional Definite Clauses: Semantics
• Semantics allows you to relate the symbols in the logic to the domain you’re trying to model.Definition (interpretation)An interpretation I assigns a truth value to each atom.
Slide 29
Propositional Definite Clauses: Semantics
• Semantics allows you to relate the symbols in the logic to the domain you're trying to model.
Definition (interpretation)An interpretation I assigns a truth value to each atom.
Slide 30
Propositional Definite Clauses: Semantics
Semantics allows you to relate the symbols in the logic to the domain you're trying to model.
We can use the interpretation to determine the truth value of clauses
Definition (interpretation)An interpretation I assigns a truth value to each atom.
Definition (truth values of statements)• A body b1 ∧ b2 is true in I if and only if b1 is true in
I and b2 is true in I.• A rule h ← b is false in I if and only if b is true in I
and h is false in I.
Slide 31
h b h ← bI1 F F TI2 F T FI3 T F TI4 T T T
PDC Semantics: Example
a1 a2 a1 ∧ a2
I1 F F FI2 F T FI3 T F FI4 T T T
Truth values under different interpretationsF=false, T=true
Slide 32
PDC Semantics: ExampleTruth values under different interpretations
F=false, T=true h a1 a2 h ← a1 ∧ a2
I1 F F FI2 F F TI3 F T FI4 F T TI5 T F FI6 T F TI7 T T FI8 T T T
Slide 33
h b h ← bI1 F F TI2 F T FI3 T F TI4 T T T
PDC Semantics: Example for truth values
Truth values under different interpretationsF=false, T=true
h ← a1 ∧ a2
Body of the clause: a1 ∧ a2
Body is only true if both a1 and a2 are true in I
h a1 a2 h ← a1 ∧ a2
I1 F F F TI2 F F T TI3 F T F TI4 F T T FI5 T F F TI6 T F T TI7 T T F TI8 T T T T
Slide 34
Propositional Definite Clauses: Semantics
Semantics allows you to relate the symbols in the logic to the domain you're trying to model.
We can use the interpretation to determine the truth value of clauses
Definition (interpretation)An interpretation I assigns a truth value to each atom.
Definition (truth values of statements)• A body b1 ∧ b2 is true in I if and only if b1 is true in
I and b2 is true in I.• A rule h ← b is false in I if and only if b is true in I
and h is false in I.
• A knowledge base KB is true in I if and only if every clause in KB is true in I. Slide 35
Propositional Definite Clauses: Semantics
Definition (model)A model of a knowledge base KB is an interpretation in
which KB is true.
Similar to CSPs: a model of a set of clauses is an interpretation that makes all of the clauses true
Definition (interpretation)An interpretation I assigns a truth value to each atom.
Definition (truth values of statements)• A body b1 ∧ b2 is true in I if and only if b1 is true in
I and b2 is true in I.• A rule h ← b is false in I if and only if b is true in I
and h is false in I.• A knowledge base KB is true in I if and only if
every clause in KB is true in I.
Slide 36
PDC Semantics: Knowledge Base (KB)
p q r s
I1 true true false false
• A knowledge base KB is true in I if and only if every clause in KB is true in I.
Slide 37
PDC Semantics: Knowledge Base (KB)
p q r s
I1 true true false false
• A knowledge base KB is true in I if and only if every clause in KB is true in I.
Slide 38
PDC Semantics: Example for models
p ← q KB = q r ← s
Definition (model)A model of a knowledge base KB is an interpretation in
which every clause in KB is true.
p q r sI1 T T T TI2 F F F FI3 T T F FI4 T T T FI5 F T F T
Which of the interpretations below are models of KB?
B. I1 , I3
C. I1, I3, I4
D. All of them
A. I3
Slide 39
PDC Semantics: Example for models
p q r s p ← q q r ← s KBI1 T T T TI2 F F F FI3 T T F FI4 T T T FI5 F T F T
Definition (model)A model of a knowledge base KB is an interpretation in
which every clause in KB is true.
p ← q KB = q r ← s
Which of the interpretations below are models of KB? All interpretations where KB is true: I1, I3, and I4
Slide 40
PDC Semantics: Example for models
p q r s p ← q q r ← s KBI1 T T T T T T T TI2 F F F F T F T FI3 T T F F T T T TI4 T T T F T T T TI5 F T F T F T F F
Definition (model)A model of a knowledge base KB is an interpretation in
which every clause in KB is true.
p ← q KB = q r ← s
Which of the interpretations below are models of KB? All interpretations where KB is true: I1, I3, and I4
Slide 41
OK but….…. Who cares? Where are we going with this?
Remember what we want to do with Logic
1) Tell the system knowledge about a task domain.• This is your KB• which expresses true statements about the world
2) Ask the system whether new statements about the domain are true or false.• We want the system responses to be
– Sound: only generates correct answers with respect to the semantics– Complete: Guaranteed to find an answer if it exists
Slide 42
For Instance…
1) Tell the system knowledge about a task domain.
2) Ask the system whether new statements about the domain are true or false
p? r? s?
..
.
srq
qpKB
Slide 43
Or, More Interestingly1) Tell the system knowledge about a task domain.
2) Ask the system whether new statements about the domain are true or false
• live_w4? lit_l2?
Slide 44
To Obtain This We Need One More Definition
We want a reasoning procedure that can find all and only the logical consequences of a knowledge base
Slide 45
Slide 46
Study for midterm (Mon Oct 27)Midterm: ~6 short questions (10pts each) + 2 problems
(20pts each)
• Study: textbook and slides
• Work on all practice exercises and revise assignments!
• While you revise the learning goals, work on practice questions
• Will post a couple of problems from previous offering (maybe slightly more difficult) … but I’ll give you the solutions
Slide 47
Next class• Definite clauses Semantics and
Proofs (textbook 5.1.2, 5.2.2)